icon.c 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780
  1. class Icon: LayoutHolder
  2. {
  3. protected int m_SizeX;
  4. protected int m_SizeY;
  5. protected int m_PosX;
  6. protected int m_PosY;
  7. protected EntityAI m_Lock;
  8. protected bool m_IsWeapon = false;
  9. protected bool m_IsMagazine = false;
  10. protected bool m_HasTemperature = false;
  11. protected bool m_HasQuantity = false;
  12. protected float m_CurrQuantity = -1;
  13. protected EntityAI m_Obj;
  14. protected ItemBase m_Item;
  15. protected bool m_HandsIcon;
  16. protected int m_CargoPos;
  17. protected bool m_IsDragged;
  18. protected bool m_PreviousFlipOrientation;
  19. const int NUMBER_OF_TIMERS = 2;
  20. protected ItemPreviewWidget m_ItemPreview;
  21. protected Widget m_ColorWidget;
  22. protected Widget m_SelectedPanel;
  23. protected Widget m_MicromanagedPanel;
  24. protected Widget m_CursorWidget;
  25. protected Widget m_QuantityPanel;
  26. protected TextWidget m_QuantityItem;
  27. protected ProgressBarWidget m_QuantityProgress;
  28. protected Widget m_QuantityStack;
  29. protected Widget m_ItemSizePanel;
  30. protected TextWidget m_ItemSizeWidget;
  31. protected ref array<ImageWidget> m_AmmoIcons;
  32. protected ImageWidget m_AmmoTypeIcon;
  33. void Icon( LayoutHolder parent, bool hands_icon = false )
  34. {
  35. m_HandsIcon = hands_icon;
  36. ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
  37. m_ItemPreview = ItemPreviewWidget.Cast( GetMainWidget().FindAnyWidget( "Render" ));
  38. m_ColorWidget = GetMainWidget().FindAnyWidget( "Color" );
  39. m_SelectedPanel = GetMainWidget().FindAnyWidget( "Selected" );
  40. m_MicromanagedPanel = GetMainWidget().FindAnyWidget( "Micromanaged" );
  41. m_CursorWidget = GetMainWidget().FindAnyWidget( "Cursor" );
  42. m_QuantityPanel = GetMainWidget().FindAnyWidget( "QuantityPanel" );
  43. m_QuantityItem = TextWidget.Cast( GetMainWidget().FindAnyWidget( "Quantity" ) );
  44. m_QuantityProgress = ProgressBarWidget.Cast( GetMainWidget().FindAnyWidget( "QuantityBar" ) );
  45. m_QuantityStack = GetMainWidget().FindAnyWidget( "QuantityStackPanel" );
  46. m_ItemSizePanel = GetMainWidget().FindAnyWidget( "ItemSizePanel" );
  47. m_ItemSizeWidget = TextWidget.Cast( GetMainWidget().FindAnyWidget( "ItemSize" ) );
  48. m_AmmoTypeIcon = ImageWidget.Cast( GetMainWidget().FindAnyWidget( "AmmoTypeIcon" ) );
  49. SetActive( false );
  50. }
  51. void ~Icon()
  52. {
  53. if (m_Obj)
  54. {
  55. m_Obj.GetOnItemFlipped().Remove(UpdateFlip);
  56. m_Obj.GetOnViewIndexChanged().Remove(SetItemPreview);
  57. }
  58. if (m_IsDragged)
  59. {
  60. RevertToOriginalFlip();
  61. ItemManager.GetInstance().HideDropzones();
  62. ItemManager.GetInstance().SetIsDragging(false);
  63. m_IsDragged = false;
  64. }
  65. }
  66. Widget GetSelectedWidget()
  67. {
  68. return m_SelectedPanel;
  69. }
  70. Widget GetCursorWidget()
  71. {
  72. return m_CursorWidget;
  73. }
  74. Widget GetMicromanagedPanel()
  75. {
  76. return m_MicromanagedPanel;
  77. }
  78. bool IsDragged()
  79. {
  80. return m_IsDragged;
  81. }
  82. override void SetActive( bool active )
  83. {
  84. super.SetActive(active);
  85. if (active && GetObject())
  86. {
  87. float x, y;
  88. GetMainWidget().GetScreenPos(x, y);
  89. PrepareOwnedTooltip(EntityAI.Cast( GetObject() ), -1, y);
  90. }
  91. else
  92. {
  93. HideOwnedTooltip();
  94. }
  95. m_SelectedPanel.Show(active);
  96. }
  97. override void SetParentWidget()
  98. {
  99. #ifndef PLATFORM_CONSOLE
  100. if (m_Parent.IsInherited(HandsPreview))
  101. {
  102. super.SetParentWidget();
  103. }
  104. else
  105. {
  106. if (m_Parent != null)
  107. {
  108. CargoContainer gridContainer = CargoContainer.Cast(m_Parent);
  109. if (gridContainer)
  110. {
  111. m_ParentWidget = gridContainer.GetMainWidget();
  112. }
  113. }
  114. }
  115. #else
  116. super.SetParentWidget();
  117. #endif
  118. }
  119. int GetRelevantInventoryAction(int relevantActions)
  120. {
  121. return 0;
  122. }
  123. void RefreshQuickbar()
  124. {
  125. InventoryMenu menu = InventoryMenu.Cast(GetGame().GetUIManager().FindMenu(MENU_INVENTORY));
  126. HideOwnedTooltip();
  127. if (menu)
  128. {
  129. menu.RefreshQuickbar();
  130. }
  131. }
  132. void DoubleClick(Widget w, int x, int y, int button)
  133. {
  134. if (button == MouseState.LEFT && !g_Game.IsLeftCtrlDown())
  135. {
  136. PlayerBase controlledPlayer = PlayerBase.Cast(GetGame().GetPlayer());
  137. if (controlledPlayer.GetInventory().HasInventoryReservation(m_Obj, null) || controlledPlayer.GetInventory().IsInventoryLocked() || controlledPlayer.IsItemsToDelete())
  138. return;
  139. ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
  140. if (!targetIpw)
  141. {
  142. string name = w.GetName();
  143. name.Replace("PanelWidget", "Render");
  144. targetIpw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
  145. }
  146. if (!targetIpw)
  147. targetIpw = ItemPreviewWidget.Cast(w);
  148. EntityAI targetEntity = targetIpw.GetItem();
  149. if (targetIpw)
  150. {
  151. if (!targetEntity.GetInventory().CanRemoveEntity())
  152. return;
  153. if (m_HandsIcon)
  154. {
  155. if (controlledPlayer.GetHumanInventory().CanRemoveEntityInHands())
  156. controlledPlayer.PredictiveMoveItemFromHandsToInventory();
  157. RefreshQuickbar();
  158. return;
  159. }
  160. EntityAI entityInHands = controlledPlayer.GetHumanInventory().GetEntityInHands();
  161. EntityAI entityRootParent = targetEntity.GetHierarchyRoot();
  162. if (controlledPlayer.GetInventory().HasEntityInInventory(targetEntity) && controlledPlayer.GetHumanInventory().CanAddEntityInHands(targetEntity))
  163. {
  164. controlledPlayer.PredictiveTakeEntityToHands(targetEntity);
  165. }
  166. else if (entityInHands && entityRootParent == controlledPlayer)
  167. {
  168. InventoryLocation targetItemLocation = new InventoryLocation();
  169. InventoryLocation handsItemLocation = new InventoryLocation();
  170. entityInHands.GetInventory().GetCurrentInventoryLocation(handsItemLocation);
  171. int index = controlledPlayer.GetHumanInventory().FindUserReservedLocationIndex(entityInHands);
  172. if (index >= 0)
  173. controlledPlayer.GetHumanInventory().GetUserReservedLocation(index, targetItemLocation);
  174. if (controlledPlayer.GetInventory().CanForceSwapEntitiesEx(targetEntity, targetItemLocation, entityInHands, handsItemLocation))
  175. {
  176. controlledPlayer.PredictiveForceSwapEntities(targetEntity, entityInHands, targetItemLocation);
  177. }
  178. else if (controlledPlayer.GetInventory().CanSwapEntitiesEx(targetEntity, entityInHands ))
  179. {
  180. controlledPlayer.PredictiveSwapEntities(targetEntity, entityInHands);
  181. }
  182. else
  183. {
  184. controlledPlayer.GetInventory().FindFreeLocationFor(targetEntity, FindInventoryLocationType.ANY, targetItemLocation);
  185. if (targetItemLocation.IsValid() && controlledPlayer.GetInventory().LocationCanAddEntity(targetItemLocation))
  186. SplitItemUtils.TakeOrSplitToInventoryLocation(controlledPlayer, targetItemLocation);
  187. }
  188. }
  189. else
  190. {
  191. bool found = false;
  192. if (targetEntity.GetInventory().CanRemoveEntity())
  193. {
  194. InventoryLocation i2 = new InventoryLocation();
  195. found = controlledPlayer.GetInventory().FindFreeLocationFor(targetEntity, FindInventoryLocationType.ANY, i2);
  196. if (found)
  197. {
  198. if (i2.GetType() == FindInventoryLocationType.ATTACHMENT)
  199. {
  200. if (i2.GetParent() != controlledPlayer)
  201. found = false;
  202. }
  203. }
  204. }
  205. if (found)
  206. {
  207. if (controlledPlayer.GetHumanInventory().CanAddEntityToInventory(targetEntity))
  208. controlledPlayer.PredictiveTakeEntityToInventory(FindInventoryLocationType.ANY, targetEntity);
  209. }
  210. else
  211. {
  212. if (controlledPlayer.GetHumanInventory().CanAddEntityInHands(targetEntity))
  213. controlledPlayer.PredictiveTakeEntityToHands(targetEntity);
  214. }
  215. }
  216. RefreshQuickbar();
  217. }
  218. }
  219. }
  220. void DraggingOverSwap( Widget w, int x, int y, Widget receiver )
  221. {
  222. if (w == null)
  223. {
  224. return;
  225. }
  226. string name = w.GetName();
  227. name.Replace("PanelWidget", "Render");
  228. ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(receiver.FindAnyWidget( "Render" ));
  229. if (m_HandsIcon)
  230. {
  231. targetIpw = ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget( "Render" ));
  232. }
  233. ItemPreviewWidget selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
  234. if (selectedIpw == null)
  235. {
  236. selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
  237. }
  238. if (selectedIpw == null)
  239. {
  240. return;
  241. }
  242. InventoryItem targetEntity = InventoryItem.Cast(targetIpw.GetItem());
  243. InventoryItem selectedEntity = InventoryItem.Cast(selectedIpw.GetItem());
  244. if (!selectedEntity || !targetEntity)
  245. {
  246. return;
  247. }
  248. InventoryLocation il = new InventoryLocation();
  249. PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
  250. int index = player.GetHumanInventory().FindUserReservedLocationIndex(m_Item);
  251. if (index >= 0)
  252. {
  253. player.GetHumanInventory().GetUserReservedLocation(index, il);
  254. if (GameInventory.CanForceSwapEntitiesEx(selectedEntity, null, targetEntity, il))
  255. {
  256. ColorManager.GetInstance().SetColor(w, ColorManager.FSWAP_COLOR);
  257. ItemManager.GetInstance().HideDropzones();
  258. ItemManager.GetInstance().ShowSourceDropzone(il.GetParent());
  259. return;
  260. }
  261. }
  262. static int testedFlags = InventoryCombinationFlags.SWAP | InventoryCombinationFlags.FSWAP;
  263. int chosenInventoryAction = ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags, il);
  264. UpdateFrameColor(selectedEntity, targetEntity, chosenInventoryAction, w, il);
  265. }
  266. void DraggingOverCombine(Widget w, int x, int y, Widget receiver)
  267. {
  268. if (w == null)
  269. {
  270. return;
  271. }
  272. ItemPreviewWidget selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
  273. if (!selectedIpw)
  274. {
  275. string name = w.GetName();
  276. name.Replace("PanelWidget", "Render");
  277. selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
  278. }
  279. if (!selectedIpw)
  280. {
  281. selectedIpw = ItemPreviewWidget.Cast(w);
  282. }
  283. if (!selectedIpw.GetItem())
  284. {
  285. return;
  286. }
  287. EntityAI selectedEntity = selectedIpw.GetItem();
  288. EntityAI targetEntity = GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
  289. static int testedFlags = InventoryCombinationFlags.SET_ACTION | InventoryCombinationFlags.PERFORM_ACTION | InventoryCombinationFlags.COMBINE_QUANTITY2 | InventoryCombinationFlags.ADD_AS_CARGO | InventoryCombinationFlags.ADD_AS_ATTACHMENT;
  290. int chosenInventoryAction = ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags);
  291. UpdateFrameColor(selectedEntity, targetEntity, chosenInventoryAction, w);
  292. }
  293. bool MouseEnter(Widget w, int x, int y)
  294. {
  295. if (!m_IsDragged)
  296. {
  297. PrepareOwnedTooltip(m_Obj, x, y);
  298. m_CursorWidget.Show(true);
  299. }
  300. return true;
  301. }
  302. bool MouseLeave( Widget w, Widget s, int x, int y)
  303. {
  304. HideOwnedTooltip();
  305. if (!m_IsDragged)
  306. {
  307. m_CursorWidget.Show(false);
  308. }
  309. return true;
  310. }
  311. void DraggingOver( Widget w, int x, int y, Widget receiver )
  312. {
  313. ItemManager.GetInstance().HideDropzones();
  314. if (w == null)
  315. {
  316. return;
  317. }
  318. string name = w.GetName();
  319. name.Replace("PanelWidget", "Render");
  320. ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(receiver.FindAnyWidget( "Render" ));
  321. if (m_HandsIcon)
  322. {
  323. targetIpw = ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget( "Render" ));
  324. }
  325. ItemPreviewWidget selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget( name ));
  326. if (selectedIpw == null)
  327. {
  328. selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget( "Render" ));
  329. }
  330. if (selectedIpw == null)
  331. {
  332. return;
  333. }
  334. PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
  335. InventoryItem targetEntity = InventoryItem.Cast(targetIpw.GetItem());
  336. InventoryItem selectedEntity = InventoryItem.Cast(selectedIpw.GetItem());
  337. InventoryLocation ilDst;
  338. if (!targetEntity || !selectedEntity)
  339. {
  340. return;
  341. }
  342. if (m_Lock)
  343. {
  344. if (targetEntity == selectedEntity)
  345. {
  346. ColorManager.GetInstance().SetColor( w, ColorManager.SWAP_COLOR );
  347. ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
  348. }
  349. else
  350. {
  351. CargoContainer parentContainer = CargoContainer.Cast(m_Parent);
  352. float parentX;
  353. float parentY;
  354. parentContainer.GetRootWidget().GetScreenPos(parentX, parentY);
  355. float iconSize = parentContainer.GetIconSize();
  356. float spaceSize = parentContainer.GetSpaceSize();
  357. int PosX = (x - parentX) / (iconSize + spaceSize);
  358. int PosY = (y - parentY) / (iconSize + spaceSize);
  359. EntityAI parent = m_Lock;
  360. CargoBase targetCargo = parent.GetInventory().GetCargo();
  361. ilDst = new InventoryLocation();
  362. ilDst.SetCargoAuto(targetCargo, selectedEntity, PosY, PosX, selectedEntity.GetInventory().GetFlipCargo());
  363. if (parent.GetInventory().LocationCanAddEntity(ilDst))
  364. {
  365. ColorManager.GetInstance().SetColor(w, ColorManager.GREEN_COLOR);
  366. ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
  367. }
  368. else
  369. {
  370. ColorManager.GetInstance().SetColor(w, ColorManager.RED_COLOR);
  371. ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
  372. }
  373. }
  374. }
  375. else
  376. {
  377. static int testedFlags = InventoryCombinationFlags.COMBINE_QUANTITY2 | InventoryCombinationFlags.ADD_AS_CARGO | InventoryCombinationFlags.ADD_AS_ATTACHMENT | InventoryCombinationFlags.SWAP | InventoryCombinationFlags.FSWAP | InventoryCombinationFlags.SWAP_MAGAZINE;
  378. int chosenInventoryAction = ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags, ilDst);
  379. UpdateFrameColor(selectedEntity, targetEntity, chosenInventoryAction, w, ilDst);
  380. }
  381. }
  382. void OnPerformCombination( int combinationFlags )
  383. {
  384. PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
  385. if (m_am_entity1 == null || m_am_entity2 == null) return;
  386. if (combinationFlags == InventoryCombinationFlags.NONE) return;
  387. Weapon_Base wpn;
  388. Magazine mag;
  389. if (combinationFlags & InventoryCombinationFlags.PERFORM_ACTION)
  390. {
  391. ActionManagerClient amc;
  392. Class.CastTo(amc, player.GetActionManager());
  393. if (m_am_entity1 == player.GetHumanInventory().GetEntityInHands())
  394. {
  395. amc.PerformActionFromInventory(ItemBase.Cast( m_am_entity1 ),ItemBase.Cast( m_am_entity2 ));
  396. }
  397. else
  398. {
  399. amc.PerformActionFromInventory(ItemBase.Cast( m_am_entity2 ),ItemBase.Cast( m_am_entity1 ));
  400. }
  401. }
  402. else if (combinationFlags & InventoryCombinationFlags.SET_ACTION)
  403. {
  404. ActionManagerClient amc2;
  405. Class.CastTo(amc2, player.GetActionManager());
  406. if (m_am_entity1 == player.GetHumanInventory().GetEntityInHands())
  407. {
  408. amc2.SetActionFromInventory(ItemBase.Cast( m_am_entity1 ), ItemBase.Cast( m_am_entity2 ));
  409. }
  410. else
  411. {
  412. amc2.SetActionFromInventory(ItemBase.Cast( m_am_entity2 ), ItemBase.Cast( m_am_entity1 ));
  413. }
  414. }
  415. else if (combinationFlags & InventoryCombinationFlags.COMBINE_QUANTITY2)
  416. {
  417. ItemBase entity = ItemBase.Cast(m_am_entity1);
  418. entity.CombineItemsClient(ItemBase.Cast( m_am_entity2 ));
  419. }
  420. else if (combinationFlags & InventoryCombinationFlags.ADD_AS_ATTACHMENT)
  421. {
  422. float stackable = m_am_entity2.GetTargetQuantityMax(-1);
  423. if (stackable == 0 || stackable >= m_am_entity2.GetQuantity())
  424. {
  425. player.PredictiveTakeEntityToTargetAttachment(m_am_entity1, m_am_entity2);
  426. }
  427. else
  428. {
  429. InventoryLocation il = new InventoryLocation();
  430. m_am_entity1.GetInventory().FindFreeLocationFor(m_am_entity2, FindInventoryLocationType.ATTACHMENT, il);
  431. ItemBase.Cast(m_am_entity2).SplitIntoStackMaxToInventoryLocationClient(il);
  432. }
  433. }
  434. else if (combinationFlags & InventoryCombinationFlags.ADD_AS_CARGO)
  435. {
  436. SplitItemUtils.TakeOrSplitToInventory(player, m_am_entity1, m_am_entity2);
  437. }
  438. }
  439. bool PerformCombination(EntityAI selectedEntity, EntityAI targetEntity, int combinationFlag, InventoryLocation ilSwapDst = null)
  440. {
  441. PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
  442. ActionManagerClient amc;
  443. switch (combinationFlag)
  444. {
  445. case InventoryCombinationFlags.ADD_AS_ATTACHMENT:
  446. return player.PredictiveTakeEntityToTargetAttachment(targetEntity, selectedEntity);
  447. case InventoryCombinationFlags.ADD_AS_CARGO:
  448. SplitItemUtils.TakeOrSplitToInventory(player, targetEntity, selectedEntity);
  449. return true;
  450. case InventoryCombinationFlags.COMBINE_QUANTITY2:
  451. targetEntity.CombineItemsClient(selectedEntity);
  452. return true;
  453. case InventoryCombinationFlags.SET_ACTION:
  454. Class.CastTo(amc, player.GetActionManager());
  455. if (targetEntity == player.GetHumanInventory().GetEntityInHands())
  456. {
  457. amc.SetActionFromInventory(ItemBase.Cast(targetEntity), ItemBase.Cast(selectedEntity));
  458. }
  459. else
  460. {
  461. amc.SetActionFromInventory(ItemBase.Cast(selectedEntity), ItemBase.Cast(targetEntity));
  462. }
  463. return true;
  464. case InventoryCombinationFlags.PERFORM_ACTION:
  465. Class.CastTo(amc, player.GetActionManager());
  466. if (targetEntity == player.GetHumanInventory().GetEntityInHands())
  467. {
  468. amc.PerformActionFromInventory(ItemBase.Cast(targetEntity), ItemBase.Cast(selectedEntity));
  469. }
  470. else
  471. {
  472. amc.PerformActionFromInventory(ItemBase.Cast(selectedEntity), ItemBase.Cast(targetEntity));
  473. }
  474. return true;
  475. case InventoryCombinationFlags.SWAP_MAGAZINE:
  476. return player.GetWeaponManager().SwapMagazine(Magazine.Cast(selectedEntity));
  477. case InventoryCombinationFlags.SWAP:
  478. return player.PredictiveSwapEntities(targetEntity, selectedEntity);
  479. case InventoryCombinationFlags.FSWAP:
  480. return player.PredictiveForceSwapEntities(selectedEntity, targetEntity, ilSwapDst);
  481. default:
  482. return false;
  483. }
  484. return false;
  485. }
  486. void UpdateFrameColor(EntityAI selectedEntity, EntityAI targetEntity, int combinationFlag, Widget w, InventoryLocation il = null)
  487. {
  488. int color;
  489. Widget targetDropzone;
  490. ItemManager.GetInstance().HideDropzones();
  491. switch (combinationFlag)
  492. {
  493. case InventoryCombinationFlags.ADD_AS_ATTACHMENT:
  494. case InventoryCombinationFlags.ADD_AS_CARGO:
  495. color = ColorManager.GREEN_COLOR;
  496. ItemManager.GetInstance().ShowSourceDropzone(targetEntity);
  497. break;
  498. case InventoryCombinationFlags.COMBINE_QUANTITY2:
  499. case InventoryCombinationFlags.SET_ACTION:
  500. case InventoryCombinationFlags.PERFORM_ACTION:
  501. color = ColorManager.COMBINE_COLOR;
  502. ItemManager.GetInstance().ShowSourceDropzone(targetEntity);
  503. break;
  504. case InventoryCombinationFlags.SWAP_MAGAZINE:
  505. color = ColorManager.SWAP_COLOR;
  506. ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
  507. break;
  508. case InventoryCombinationFlags.SWAP:
  509. color = ColorManager.SWAP_COLOR;
  510. ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
  511. break;
  512. case InventoryCombinationFlags.FSWAP:
  513. color = ColorManager.FSWAP_COLOR;
  514. if (il)
  515. {
  516. ItemManager.GetInstance().ShowSourceDropzone(il.GetParent());
  517. }
  518. else
  519. {
  520. ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
  521. }
  522. break;
  523. default:
  524. color = ColorManager.RED_COLOR;
  525. ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
  526. }
  527. ColorManager.GetInstance().SetColor( w, color );
  528. }
  529. void ShowActionMenuCombine( EntityAI entity1, EntityAI entity2, int combinationFlags, Widget w , bool color_test )
  530. {
  531. int lastFlag = 0;
  532. ContextMenu cmenu = ContextMenu.Cast(GetGame().GetUIManager().GetMenu().GetContextMenu());
  533. m_am_entity1 = entity1;
  534. m_am_entity2 = entity2;
  535. cmenu.Hide();
  536. cmenu.Clear();
  537. int id = -1;
  538. if ( entity1 == null || entity2 == null ) return;
  539. if ( combinationFlags == InventoryCombinationFlags.NONE )
  540. {
  541. if ( color_test )
  542. {
  543. ColorManager.GetInstance().SetColor( w, ColorManager.RED_COLOR );
  544. ItemManager.GetInstance().ShowSourceDropzone( entity2 );
  545. }
  546. return;
  547. }
  548. if (combinationFlags & InventoryCombinationFlags.ADD_AS_CARGO)
  549. {
  550. lastFlag = InventoryCombinationFlags.ADD_AS_CARGO;
  551. cmenu.Add( "#inv_context_add_as_cargo", this, "OnPerformCombination", new Param1<int>( lastFlag ) );
  552. }
  553. if (combinationFlags & InventoryCombinationFlags.ADD_AS_ATTACHMENT)
  554. {
  555. lastFlag = InventoryCombinationFlags.ADD_AS_ATTACHMENT;
  556. cmenu.Add( "#inv_context_add_as_attachment", this, "OnPerformCombination", new Param1<int>( lastFlag ));
  557. }
  558. if (combinationFlags & InventoryCombinationFlags.COMBINE_QUANTITY2)
  559. {
  560. lastFlag = InventoryCombinationFlags.COMBINE_QUANTITY2;
  561. cmenu.Add("#inv_context_combine_quantity", this, "OnPerformCombination", new Param1<int>( lastFlag ));
  562. }
  563. if (combinationFlags & InventoryCombinationFlags.SET_ACTION)
  564. {
  565. lastFlag = InventoryCombinationFlags.SET_ACTION;
  566. cmenu.Add("#inv_context_attach_magazine", this, "OnPerformCombination", new Param1<int>( lastFlag ));
  567. }
  568. if (combinationFlags & InventoryCombinationFlags.PERFORM_ACTION)
  569. {
  570. lastFlag = InventoryCombinationFlags.PERFORM_ACTION;
  571. cmenu.Add("Perform action", this, "OnPerformCombination", new Param1<int>( lastFlag ));
  572. }
  573. if (color_test)
  574. {
  575. if (lastFlag == 0)
  576. {
  577. ItemManager.GetInstance().HideDropzones();
  578. ItemManager.GetInstance().GetCenterDropzone().SetAlpha( 1 );
  579. ColorManager.GetInstance().SetColor( w, ColorManager.RED_COLOR );
  580. }
  581. else if (lastFlag == InventoryCombinationFlags.ADD_AS_ATTACHMENT || lastFlag == InventoryCombinationFlags.ADD_AS_CARGO )
  582. {
  583. ItemManager.GetInstance().HideDropzones();
  584. ItemManager.GetInstance().GetCenterDropzone().SetAlpha( 1 );
  585. ColorManager.GetInstance().SetColor( w, ColorManager.GREEN_COLOR );
  586. }
  587. else
  588. {
  589. ItemManager.GetInstance().HideDropzones();
  590. ItemManager.GetInstance().GetCenterDropzone().SetAlpha( 1 );
  591. ColorManager.GetInstance().SetColor( w, ColorManager.COMBINE_COLOR );
  592. }
  593. }
  594. else if (cmenu.Count() >= 1)
  595. {
  596. OnPerformCombination(combinationFlags);
  597. return;
  598. }
  599. }
  600. void OnPerformRecipe(int id)
  601. {
  602. if ( m_am_entity1 == null || m_am_entity2 == null ) return;
  603. Debug.Log("OnPerformRecipe called for id:"+id.ToString(),"recipes");
  604. PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
  605. player.GetCraftingManager().SetInventoryCraft( id, ItemBase.Cast(m_am_entity1), ItemBase.Cast(m_am_entity2));
  606. }
  607. void Combine( Widget w, int x, int y, Widget receiver )
  608. {
  609. ItemManager.GetInstance().HideDropzones();
  610. ItemManager.GetInstance().SetIsDragging(false);
  611. ItemPreviewWidget selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
  612. if (!selectedIpw)
  613. {
  614. string name = w.GetName();
  615. name.Replace("PanelWidget", "Render");
  616. selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget( name ));
  617. }
  618. if (!selectedIpw)
  619. {
  620. selectedIpw = ItemPreviewWidget.Cast(w);
  621. }
  622. if (!selectedIpw.GetItem())
  623. {
  624. return;
  625. }
  626. EntityAI selectedEntity = selectedIpw.GetItem();
  627. EntityAI targetEntity = GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
  628. static int testedFlags = InventoryCombinationFlags.SET_ACTION | InventoryCombinationFlags.PERFORM_ACTION | InventoryCombinationFlags.COMBINE_QUANTITY2 | InventoryCombinationFlags.ADD_AS_CARGO | InventoryCombinationFlags.ADD_AS_ATTACHMENT;
  629. int chosenInventoryAction = ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags);
  630. PerformCombination(selectedEntity, targetEntity, chosenInventoryAction);
  631. }
  632. bool CombineItems( EntityAI entity1, EntityAI entity2 )
  633. {
  634. int flags = ItemManager.GetCombinationFlags( entity1, entity2 );
  635. return FlagAction( entity1, entity2, flags );
  636. }
  637. bool FlagAction( EntityAI entity1, EntityAI entity2, int combinationFlags )
  638. {
  639. int current_flag;
  640. ContextMenu cmenu = ContextMenu.Cast(GetGame().GetUIManager().GetMenu().GetContextMenu());
  641. m_am_entity1 = entity1;
  642. m_am_entity2 = entity2;
  643. cmenu.Hide();
  644. cmenu.Clear();
  645. int id = -1;
  646. if (combinationFlags & InventoryCombinationFlags.COMBINE_QUANTITY2 )
  647. {
  648. ItemBase entity = ItemBase.Cast( entity1 );
  649. entity.CombineItemsClient( ItemBase.Cast( entity2 ) );
  650. return false;
  651. }
  652. if (entity1 == null || entity2 == null || combinationFlags == InventoryCombinationFlags.NONE )
  653. return true;
  654. if (combinationFlags & InventoryCombinationFlags.ADD_AS_ATTACHMENT )
  655. {
  656. current_flag = InventoryCombinationFlags.ADD_AS_ATTACHMENT;
  657. cmenu.Add( "#inv_context_add_as_attachment", this, "OnPerformCombination", new Param1<int>( current_flag ) );
  658. }
  659. /*if (combinationFlags & InventoryCombinationFlags.LOAD_CHAMBER )
  660. {
  661. current_flag = InventoryCombinationFlags.LOAD_CHAMBER;
  662. cmenu.Add( "#inv_context_load_chamber", this, "OnPerformCombination", new Param1<int>( current_flag ) );
  663. }*/
  664. if(combinationFlags & InventoryCombinationFlags.ATTACH_MAGAZINE)
  665. {
  666. current_flag = InventoryCombinationFlags.ATTACH_MAGAZINE;
  667. cmenu.Add("#inv_context_attach_magazine", this, "OnPerformCombination", new Param1<int>( current_flag ) );
  668. }
  669. if (combinationFlags & InventoryCombinationFlags.ADD_AS_CARGO )
  670. {
  671. current_flag = InventoryCombinationFlags.ADD_AS_CARGO;
  672. cmenu.Add( "#inv_context_add_as_cargo", this, "OnPerformCombination", new Param1<int>( current_flag ) );
  673. }
  674. if (combinationFlags & InventoryCombinationFlags.SWAP )
  675. {
  676. current_flag = InventoryCombinationFlags.SWAP;
  677. cmenu.Add( "#inv_context_swap", this, "OnPerformCombination", new Param1<int>( current_flag ) );
  678. }
  679. if (combinationFlags & InventoryCombinationFlags.COMBINE_QUANTITY2 )
  680. {
  681. current_flag = InventoryCombinationFlags.COMBINE_QUANTITY2;
  682. cmenu.Add( "#inv_context_combine", this, "OnPerformCombination", new Param1<int>( current_flag ) );
  683. }
  684. if(combinationFlags & InventoryCombinationFlags.SET_ACTION)
  685. {
  686. current_flag = InventoryCombinationFlags.SET_ACTION;
  687. cmenu.Add("#inv_context_attach_magazine", this, "OnPerformCombination", new Param1<int>( current_flag ) );
  688. }
  689. if(combinationFlags & InventoryCombinationFlags.PERFORM_ACTION)
  690. {
  691. current_flag = InventoryCombinationFlags.PERFORM_ACTION;
  692. cmenu.Add("Perform Action2", this, "OnPerformCombination", new Param1<int>( current_flag ) );
  693. }
  694. int m_am_Pos_x, m_am_Pos_y;
  695. GetMousePos( m_am_Pos_x, m_am_Pos_y );
  696. m_am_Pos_x -= 5;
  697. m_am_Pos_y -= 5;
  698. MissionGameplay mission = MissionGameplay.Cast( GetGame().GetMission() );
  699. /*if (combinationFlags & InventoryCombinationFlags.RECIPE_HANDS || combinationFlags & InventoryCombinationFlags.RECIPE_ANYWHERE )
  700. {
  701. OnPerformRecipe( id );
  702. return true;
  703. }
  704. else /*if (cmenu.Count() == 1 )*/
  705. //{
  706. OnPerformCombination( current_flag );
  707. return true;
  708. //}
  709. /*else
  710. {
  711. cmenu.Show( m_am_Pos_x, m_am_Pos_y );
  712. return true;
  713. }*/
  714. }
  715. void MouseClick(Widget w, int x, int y, int button)
  716. {
  717. if (button == MouseState.RIGHT)
  718. {
  719. if (m_Lock)
  720. {
  721. GetGame().GetPlayer().GetHumanInventory().ClearUserReservedLocationSynced(m_Item);
  722. }
  723. else if (m_Item)
  724. {
  725. #ifdef DIAG_DEVELOPER
  726. if (GetDayZGame().IsLeftCtrlDown())
  727. ShowActionMenu(m_Item);
  728. else
  729. #endif
  730. {
  731. m_Item.OnRightClick();
  732. if (m_HasQuantity)
  733. SetQuantity();
  734. }
  735. }
  736. }
  737. else if (!m_Lock)
  738. {
  739. switch (button)
  740. {
  741. case MouseState.MIDDLE:
  742. InspectItem(m_Item);
  743. break;
  744. case MouseState.LEFT:
  745. PlayerBase controlledPlayer = PlayerBase.Cast(GetGame().GetPlayer());
  746. if (g_Game.IsLeftCtrlDown())
  747. {
  748. if (controlledPlayer.CanDropEntity(m_Item))
  749. {
  750. if (m_Item.GetTargetQuantityMax() < m_Item.GetQuantity())
  751. m_Item.SplitIntoStackMaxClient(null, -1);
  752. else
  753. controlledPlayer.PhysicalPredictiveDropItem(m_Item);
  754. ItemManager.GetInstance().SetWidgetDraggable(w, false);
  755. }
  756. }
  757. else
  758. {
  759. InventoryLocation il = new InventoryLocation();
  760. m_Obj.GetInventory().GetCurrentInventoryLocation(il);
  761. bool draggable = !controlledPlayer.GetInventory().HasInventoryReservation(m_Obj, null) && !controlledPlayer.GetInventory().IsInventoryLocked() && !controlledPlayer.IsItemsToDelete();
  762. draggable = draggable && (m_Obj.GetHierarchyRoot() && m_Obj.GetInventory().CanRemoveEntity() || !m_Obj.GetHierarchyRoot() && AttachmentsOutOfReach.IsAttachmentReachable(m_Obj, "", il.GetSlot()));
  763. ItemManager.GetInstance().SetWidgetDraggable(w, draggable);
  764. }
  765. break;
  766. }
  767. }
  768. }
  769. void DropReceivedFromMain( Widget w, int x, int y, Widget receiver )
  770. {
  771. ItemManager.GetInstance().HideDropzones();
  772. ItemManager.GetInstance().SetIsDragging(false);
  773. string name = w.GetName();
  774. name.Replace("PanelWidget", "Render");
  775. PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
  776. ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(receiver.FindAnyWidget( "Render" ));
  777. if (m_HandsIcon)
  778. {
  779. targetIpw = ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget( "Render" ));
  780. }
  781. ItemPreviewWidget selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget( name ));
  782. if (selectedIpw == null)
  783. {
  784. selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget( "Render" ));
  785. }
  786. if (selectedIpw == null)
  787. {
  788. return;
  789. }
  790. InventoryItem targetEntity = InventoryItem.Cast(targetIpw.GetItem());
  791. InventoryItem selectedEntity = InventoryItem.Cast(selectedIpw.GetItem());
  792. if (!selectedEntity)
  793. {
  794. return;
  795. }
  796. int index;
  797. InventoryLocation ilSrc;
  798. InventoryLocation ilDst;
  799. if (m_Lock && targetEntity == selectedEntity)
  800. {
  801. index = player.GetHumanInventory().FindUserReservedLocationIndex(m_Item);
  802. ilSrc = new InventoryLocation();
  803. ilDst = new InventoryLocation();
  804. m_Item.GetInventory().GetCurrentInventoryLocation(ilSrc);
  805. player.GetHumanInventory().GetUserReservedLocation(index, ilDst);
  806. if (ilDst.GetParent().GetInventory().LocationCanAddEntity(ilDst))
  807. {
  808. player.GetHumanInventory().ClearUserReservedLocation(m_Item);
  809. player.PredictiveTakeToDst(ilSrc, ilDst);
  810. m_Item.GetOnReleaseLock().Invoke(m_Item);
  811. }
  812. }
  813. else if (m_Lock)
  814. {
  815. CargoContainer parentCargo = CargoContainer.Cast(m_Parent);
  816. float parentX;
  817. float parentY;
  818. parentCargo.GetRootWidget().GetScreenPos(parentX, parentY);
  819. float iconSize = parentCargo.GetIconSize();
  820. float spaceSize = parentCargo.GetSpaceSize();
  821. int PosX = (x-parentX) / (iconSize + spaceSize);
  822. int PosY = (y-parentY) / (iconSize + spaceSize);
  823. EntityAI parent = m_Lock;
  824. CargoBase targetCargo = parent.GetInventory().GetCargo();
  825. ilDst = new InventoryLocation();
  826. ilDst.SetCargoAuto(targetCargo, selectedEntity, PosY, PosX, selectedEntity.GetInventory().GetFlipCargo());
  827. if (parent.GetInventory().LocationCanAddEntity(ilDst))
  828. {
  829. player.GetHumanInventory().ClearUserReservedLocation(m_Item);
  830. m_Item.GetOnReleaseLock().Invoke(m_Item);
  831. SplitItemUtils.TakeOrSplitToInventoryLocation(player, ilDst);
  832. }
  833. }
  834. else
  835. {
  836. ilDst = new InventoryLocation();
  837. static int testedFlags = InventoryCombinationFlags.COMBINE_QUANTITY2 | InventoryCombinationFlags.ADD_AS_CARGO | InventoryCombinationFlags.ADD_AS_ATTACHMENT | InventoryCombinationFlags.SWAP | InventoryCombinationFlags.FSWAP | InventoryCombinationFlags.SWAP_MAGAZINE;
  838. int chosenInventoryAction = ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags, ilDst);
  839. PerformCombination(selectedEntity, targetEntity, chosenInventoryAction, ilDst);
  840. }
  841. }
  842. void Swap( Widget w, int x, int y, Widget receiver )
  843. {
  844. ItemManager.GetInstance().HideDropzones();
  845. ItemManager.GetInstance().SetIsDragging(false);
  846. string name = w.GetName();
  847. name.Replace("PanelWidget", "Render");
  848. ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(receiver.FindAnyWidget( "Render" ));
  849. if (m_HandsIcon)
  850. {
  851. targetIpw = ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget( "Render" ));
  852. }
  853. ItemPreviewWidget selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget( name ));
  854. if (selectedIpw == null)
  855. {
  856. selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget( "Render" ));
  857. }
  858. if (selectedIpw == null)
  859. {
  860. return;
  861. }
  862. InventoryItem targetEntity = InventoryItem.Cast(targetIpw.GetItem());
  863. InventoryItem selectedEntity = InventoryItem.Cast(selectedIpw.GetItem());
  864. if (!selectedEntity || !targetEntity)
  865. {
  866. return;
  867. }
  868. PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
  869. EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
  870. InventoryLocation ilDst = new InventoryLocation();
  871. InventoryLocation ilSrc = new InventoryLocation();
  872. targetEntity.GetInventory().GetCurrentInventoryLocation(ilSrc);
  873. Icon icon = ItemManager.GetInstance().GetDraggedIcon();
  874. int index = player.GetHumanInventory().FindUserReservedLocationIndex(targetEntity);
  875. if (index>=0)
  876. {
  877. player.GetHumanInventory().GetUserReservedLocation(index, ilDst);
  878. if (GameInventory.CanForceSwapEntitiesEx( selectedEntity, ilSrc, targetEntity, ilDst ))
  879. {
  880. if (m_HandsIcon && !player.GetInventory().HasInventoryReservation(itemInHands, null) && !player.IsItemsToDelete())
  881. {
  882. GetGame().GetPlayer().PredictiveForceSwapEntities(selectedEntity, targetEntity, ilDst);
  883. return;
  884. }
  885. }
  886. }
  887. static int testedFlags = InventoryCombinationFlags.SWAP | InventoryCombinationFlags.FSWAP;
  888. int chosenInventoryAction = ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags, ilDst);
  889. PerformCombination(selectedEntity, targetEntity, chosenInventoryAction, ilDst);
  890. }
  891. void ToRefresh( Icon icon, Icon icon2 )
  892. {
  893. ( IconsContainer.Cast( m_Parent ) ).RemoveItem( icon );
  894. ( IconsContainer.Cast( m_Parent ) ).RemoveItem( icon2 );
  895. }
  896. override void SetLayoutName()
  897. {
  898. #ifdef PLATFORM_CONSOLE
  899. m_LayoutName = WidgetLayoutName.IconXbox;
  900. #else
  901. switch (InventoryMenu.GetWidthType())
  902. {
  903. case ScreenWidthType.NARROW:
  904. {
  905. m_LayoutName = WidgetLayoutName.IconNarrow;
  906. break;
  907. }
  908. case ScreenWidthType.MEDIUM:
  909. {
  910. m_LayoutName = WidgetLayoutName.IconMedium;
  911. break;
  912. }
  913. case ScreenWidthType.WIDE:
  914. {
  915. m_LayoutName = WidgetLayoutName.IconWide;
  916. break;
  917. }
  918. }
  919. #endif
  920. }
  921. void SetSize( int x, int y )
  922. {
  923. m_SizeX = x;
  924. m_SizeY = y;
  925. }
  926. void SetPos( int x, int y )
  927. {
  928. m_PosX = x;
  929. m_PosY = y;
  930. }
  931. int GetCargoPos()
  932. {
  933. return m_CargoPos;
  934. }
  935. void SetCargoPos(int x)
  936. {
  937. GetMainWidget().SetSort( x );
  938. m_CargoPos = x;
  939. }
  940. void DestroyWhiteBackground()
  941. {
  942. ItemManager.GetInstance().HideDropzones();
  943. ItemManager.GetInstance().SetIsDragging( false );
  944. m_IsDragged = false;
  945. RevertToOriginalFlip();
  946. if (m_HandsIcon)
  947. {
  948. m_ItemPreview.SetForceFlipEnable(true);
  949. m_ItemPreview.SetForceFlip(false);
  950. Refresh();
  951. FullScreen();
  952. }
  953. m_ColorWidget.Show(false);
  954. m_CursorWidget.SetColor( ARGBF( 1, 1, 1, 1 ) );
  955. m_CursorWidget.Show( false );
  956. InventoryMenu menu = InventoryMenu.Cast(GetGame().GetUIManager().FindMenu( MENU_INVENTORY ));
  957. if (menu)
  958. menu.RefreshQuickbar();
  959. }
  960. void CreateWhiteBackground()
  961. {
  962. m_PreviousFlipOrientation = m_Item.GetInventory().GetFlipCargo();
  963. ItemManager.GetInstance().SetDraggedIcon(this);
  964. ItemManager.GetInstance().SetDraggedItem(m_Item);
  965. m_IsDragged = true;
  966. ItemManager.GetInstance().SetIsDragging(true);
  967. int ww, hh;
  968. GetGame().GetInventoryItemSize(m_Item, ww, hh);
  969. if (m_Item.GetInventory().GetFlipCargo())
  970. SetSize(hh, ww);
  971. else
  972. SetSize(ww, hh);
  973. SetSize();
  974. if (!m_HandsIcon)
  975. {
  976. Refresh();
  977. }
  978. else
  979. {
  980. m_ItemPreview.SetForceFlipEnable(false);
  981. m_ColorWidget.SetColor(ColorManager.BASE_COLOR);
  982. }
  983. m_ColorWidget.Show(m_HandsIcon);
  984. m_CursorWidget.Show(true);
  985. }
  986. void OnDraggingOverBackground( Widget w, int x, int y, Widget reciever )
  987. {
  988. ItemManager.GetInstance().HideDropzones();
  989. EntityAI entity = EntityAI.Cast( m_Obj );
  990. EntityAI parent = entity.GetHierarchyParent();
  991. if (parent && parent.GetHierarchyRootPlayer() == GetGame().GetPlayer())
  992. {
  993. ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
  994. }
  995. else if (!m_HandsIcon)
  996. {
  997. ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
  998. }
  999. if (w == null || reciever == null)
  1000. {
  1001. return;
  1002. }
  1003. Pos pa;
  1004. reciever.GetUserData(pa);
  1005. if (m_Parent)
  1006. {
  1007. ContainerWithCargo item = ContainerWithCargo.Cast(m_Parent.m_Parent);
  1008. if (item)
  1009. {
  1010. item.DraggingOverGrid(w, m_PosY + pa.y, m_PosX + pa.x, reciever);
  1011. }
  1012. HandsContainer hands_item = HandsContainer.Cast(m_Parent.m_Parent);
  1013. if (hands_item)
  1014. {
  1015. hands_item.DraggingOverGrid(w, m_PosY + pa.y, m_PosX + pa.x, reciever, null);
  1016. }
  1017. }
  1018. }
  1019. void DropReceivedFromBackground( Widget w, int x, int y, Widget reciever )
  1020. {
  1021. Pos pa;
  1022. if (reciever)
  1023. {
  1024. reciever.GetUserData(pa);
  1025. if (m_Parent)
  1026. {
  1027. ContainerWithCargo item = ContainerWithCargo.Cast(m_Parent.m_Parent);
  1028. if (item)
  1029. {
  1030. item.DropReceived(w, m_PosY + pa.y, m_PosX + pa.x);
  1031. }
  1032. }
  1033. }
  1034. }
  1035. void RevertToOriginalFlip()
  1036. {
  1037. if (m_Item)
  1038. {
  1039. m_Item.GetInventory().SetFlipCargo(m_PreviousFlipOrientation);
  1040. int ww, hh;
  1041. GetGame().GetInventoryItemSize(m_Item, ww, hh);
  1042. if (m_PreviousFlipOrientation)
  1043. SetSize(hh, ww);
  1044. else
  1045. SetSize(ww, hh);
  1046. SetSize();
  1047. }
  1048. }
  1049. override void Refresh()
  1050. {
  1051. super.Refresh();
  1052. if (!m_HandsIcon)
  1053. SetPos();
  1054. if (m_HasTemperature)
  1055. SetTemperature();
  1056. if (m_IsWeapon)
  1057. RefreshMuzzleIcon();
  1058. if (m_HasQuantity)
  1059. SetQuantity();
  1060. }
  1061. void SetTemperature()
  1062. {
  1063. ItemManager.GetInstance().SetIconTemperature(EntityAI.Cast( m_Obj ), m_RootWidget);
  1064. }
  1065. void RefreshIconPos()
  1066. {
  1067. Refresh();
  1068. GetMainWidget().Update();
  1069. }
  1070. void FullScreen()
  1071. {
  1072. if (m_IsDragged)
  1073. {
  1074. return;
  1075. }
  1076. GetRootWidget().ClearFlags(WidgetFlags.HEXACTSIZE + WidgetFlags.VEXACTSIZE);
  1077. GetRootWidget().SetSize(1, 1);
  1078. m_ColorWidget.SetColor(ARGB( 0, 0, 0, 0 ));
  1079. }
  1080. void RefreshPos( int row, int column )
  1081. {
  1082. if (row != m_PosY || column != m_PosX)
  1083. {
  1084. m_PosX = column;
  1085. m_PosY = row;
  1086. SetPos();
  1087. RefreshIconPos();
  1088. }
  1089. }
  1090. Object GetObject()
  1091. {
  1092. return m_Obj;
  1093. }
  1094. void RefreshMuzzleIcon()
  1095. {
  1096. Weapon_Base wpn = Weapon_Base.Cast(GetObject());
  1097. if (wpn)
  1098. {
  1099. int i;
  1100. ImageWidget ammoIcon;
  1101. if (!wpn.IsShowingChamberedBullet())
  1102. {
  1103. for (i = 0; i < m_AmmoIcons.Count(); i++)
  1104. {
  1105. ammoIcon = m_AmmoIcons.Get(i);
  1106. ammoIcon.Show(false);
  1107. }
  1108. }
  1109. else
  1110. {
  1111. for (i = 0; i < wpn.GetMuzzleCount(); i++)
  1112. {
  1113. if (i > m_AmmoIcons.Count())
  1114. break;
  1115. ammoIcon = m_AmmoIcons.Get(i);
  1116. if (wpn.IsChamberFull(i))
  1117. {
  1118. if (wpn.IsJammed())
  1119. {
  1120. ammoIcon.Show(true);
  1121. ammoIcon.SetImage(2);
  1122. }
  1123. else if (wpn.IsChamberFiredOut(i))
  1124. {
  1125. ammoIcon.Show(true);
  1126. ammoIcon.SetImage(1);
  1127. }
  1128. else
  1129. {
  1130. ammoIcon.Show(true);
  1131. ammoIcon.SetImage(0);
  1132. }
  1133. }
  1134. else
  1135. {
  1136. ammoIcon.Show(false);
  1137. }
  1138. }
  1139. }
  1140. }
  1141. }
  1142. void SetQuantity()
  1143. {
  1144. if (m_Item)
  1145. {
  1146. int quantityType = QuantityConversions.HasItemQuantity(m_Item);
  1147. if (quantityType != QUANTITY_HIDDEN && m_CurrQuantity != QuantityConversions.GetItemQuantity(m_Item))
  1148. {
  1149. m_CurrQuantity = QuantityConversions.GetItemQuantity(m_Item);
  1150. if (quantityType == QUANTITY_COUNT)
  1151. {
  1152. string quantityText = QuantityConversions.GetItemQuantityText(m_Item);
  1153. if (QuantityConversions.GetItemQuantityMax(m_Item) == 1 || quantityText == "")
  1154. {
  1155. m_QuantityStack.Show(false);
  1156. }
  1157. else
  1158. {
  1159. m_QuantityItem.SetText(quantityText);
  1160. m_QuantityStack.Show(true);
  1161. }
  1162. m_QuantityProgress.Show(false);
  1163. }
  1164. else if (quantityType == QUANTITY_PROGRESS)
  1165. {
  1166. int max = m_Item.GetQuantityMax();
  1167. int count = m_Item.ConfigGetInt("count");
  1168. float quantity = m_CurrQuantity;
  1169. if (count > 0)
  1170. {
  1171. max = count;
  1172. }
  1173. if (max > 0)
  1174. {
  1175. float value = Math.Round((quantity / max) * 100);
  1176. m_QuantityProgress.SetCurrent(value);
  1177. }
  1178. m_QuantityStack.Show(false);
  1179. m_QuantityProgress.Show(true);
  1180. }
  1181. }
  1182. }
  1183. }
  1184. void SetSort(int index)
  1185. {
  1186. GetMainWidget().SetSort(index);
  1187. GetMainWidget().Update();
  1188. }
  1189. int GetSort()
  1190. {
  1191. return GetMainWidget().GetSort();
  1192. }
  1193. void SetItemPreviewEx(bool refresh = true)
  1194. {
  1195. m_ItemPreview.Show(true, refresh);
  1196. m_ItemPreview.SetItem(EntityAI.Cast(m_Obj));
  1197. m_ItemPreview.SetModelOrientation("0 0 0");
  1198. m_ItemPreview.SetView(m_Obj.GetViewIndex());
  1199. }
  1200. void SetItemPreview()
  1201. {
  1202. SetItemPreviewEx();
  1203. }
  1204. void SetItemSizeEx(bool refresh = true)
  1205. {
  1206. #ifdef PLATFORM_CONSOLE
  1207. m_ItemSizePanel.Show(true, refresh);
  1208. m_ItemSizeWidget.Show(true, refresh);
  1209. int sizeX, sizeY;
  1210. GetGame().GetInventoryItemSize(m_Item, sizeX, sizeY);
  1211. int capacity = sizeX * sizeY;
  1212. m_ItemSizeWidget.SetText(capacity.ToString());
  1213. #endif
  1214. }
  1215. void SetItemSize()
  1216. {
  1217. SetItemSizeEx();
  1218. }
  1219. void UpdateFlip(bool flipped)
  1220. {
  1221. int sizeX, sizeY;
  1222. GetGame().GetInventoryItemSize(m_Item, sizeX, sizeY);
  1223. if (flipped)
  1224. SetSize(sizeY, sizeX);
  1225. else
  1226. SetSize(sizeX, sizeY);
  1227. SetSize();
  1228. }
  1229. void InitLock( EntityAI parent, EntityAI obj, int x_pos, int y_pos, bool flip)
  1230. {
  1231. m_Lock = parent;
  1232. m_Obj = obj;
  1233. m_Item = ItemBase.Cast(m_Obj);
  1234. SetPos(x_pos, y_pos);
  1235. UpdateFlip( flip );
  1236. ItemManager.GetInstance().SetWidgetDraggable( GetMainWidget(), false );
  1237. WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown( GetMainWidget(), this, "MouseClick" );
  1238. WidgetEventHandler.GetInstance().RegisterOnDropReceived( GetMainWidget(), this, "DropReceivedFromMain" );
  1239. WidgetEventHandler.GetInstance().RegisterOnDraggingOver( GetMainWidget(), this, "DraggingOver" );
  1240. m_RootWidget.FindAnyWidget( "Reserved" ).Show( true );
  1241. m_ItemPreview.SetForceFlipEnable(true);
  1242. m_ItemPreview.SetForceFlip(flip);
  1243. SetItemPreview();
  1244. Refresh();
  1245. }
  1246. void InitEx( EntityAI obj, bool refresh = true )
  1247. {
  1248. if (obj != m_Obj)
  1249. {
  1250. if (m_Obj)
  1251. {
  1252. m_Obj.GetOnItemFlipped().Remove(UpdateFlip );
  1253. m_Obj.GetOnViewIndexChanged().Remove(SetItemPreview);
  1254. }
  1255. if (obj)
  1256. {
  1257. obj.GetOnItemFlipped().Insert(UpdateFlip);
  1258. obj.GetOnViewIndexChanged().Insert(SetItemPreview);
  1259. }
  1260. }
  1261. if (m_HandsIcon)
  1262. {
  1263. m_ItemPreview.SetForceFlipEnable(true);
  1264. m_ItemPreview.SetForceFlip(false);
  1265. }
  1266. m_Obj = obj;
  1267. m_Item = ItemBase.Cast(m_Obj);
  1268. m_Lock = null;
  1269. SetItemPreviewEx(refresh);
  1270. WidgetEventHandler.GetInstance().RegisterOnDrag( GetMainWidget(), this, "CreateWhiteBackground" );
  1271. WidgetEventHandler.GetInstance().RegisterOnDrop( GetMainWidget(), this, "DestroyWhiteBackground" );
  1272. WidgetEventHandler.GetInstance().RegisterOnDropReceived( GetMainWidget(), this, "DropReceivedFromMain" );
  1273. WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown( GetMainWidget(), this, "MouseClick" );
  1274. WidgetEventHandler.GetInstance().RegisterOnDropReceived( GetMainWidget().FindAnyWidget( "Swap" ), this, "Swap" );
  1275. WidgetEventHandler.GetInstance().RegisterOnDraggingOver( GetMainWidget().FindAnyWidget( "Swap" ), this, "DraggingOverSwap" );
  1276. WidgetEventHandler.GetInstance().RegisterOnDropReceived( GetMainWidget().FindAnyWidget( "Combine" ), this, "Combine" );
  1277. WidgetEventHandler.GetInstance().RegisterOnDraggingOver( GetMainWidget().FindAnyWidget( "Combine" ), this, "DraggingOverCombine" );
  1278. WidgetEventHandler.GetInstance().RegisterOnDraggingOver( GetMainWidget(), this, "DraggingOver" );
  1279. WidgetEventHandler.GetInstance().RegisterOnMouseEnter( GetMainWidget(), this, "MouseEnter" );
  1280. WidgetEventHandler.GetInstance().RegisterOnMouseLeave( GetMainWidget(), this, "MouseLeave" );
  1281. WidgetEventHandler.GetInstance().RegisterOnDoubleClick( GetMainWidget(), this, "DoubleClick" );
  1282. SetItemSizeEx(refresh);
  1283. CheckIsWeapon();
  1284. CheckIsMagazineEx(refresh);
  1285. CheckHasTemperature();
  1286. CheckHasQuantityEx(refresh);
  1287. m_RootWidget.FindAnyWidget("Reserved").Show(false, refresh);
  1288. m_ColorWidget.Show(false);
  1289. if (refresh)
  1290. Refresh();
  1291. }
  1292. void Init(EntityAI obj)
  1293. {
  1294. InitEx(obj);
  1295. }
  1296. void CheckIsWeapon()
  1297. {
  1298. Weapon_Base wpn = Weapon_Base.Cast(m_Obj);
  1299. if (wpn)
  1300. {
  1301. m_AmmoIcons = new array<ImageWidget>();
  1302. m_IsWeapon = true;
  1303. float posX = 0.0;
  1304. float width = 0.0, height = 0.0;
  1305. for (int i = 0; i < wpn.GetMuzzleCount(); i++)
  1306. {
  1307. if (i == 1)
  1308. {
  1309. m_AmmoIcons[0].GetSize(width, height);
  1310. }
  1311. posX += width;
  1312. Widget ammoIcon = Widget.Cast(GetGame().GetWorkspace().CreateWidgets("gui/layouts/inventory_new/ammo_icon.layout", GetMainWidget()));
  1313. ammoIcon.SetPos(posX, 0.0, false);
  1314. ImageWidget ammoIconImg = ImageWidget.Cast(ammoIcon.GetChildren());
  1315. AmmoData data = Magazine.GetAmmoData(wpn.GetChamberAmmoTypeName(i));
  1316. if (data)
  1317. {
  1318. CartridgeType cartridgeType = data.m_CartridgeType;
  1319. switch (cartridgeType)
  1320. {
  1321. case CartridgeType.Pistol:
  1322. {
  1323. ammoIconImg.LoadImageFile(0, "set:dayz_gui image:cartridge_pistol");
  1324. ammoIconImg.LoadImageFile(1, "set:dayz_gui image:shell_pistol");
  1325. ammoIconImg.LoadImageFile(2, "set:dayz_gui image:jam_pistol");
  1326. break;
  1327. }
  1328. case CartridgeType.Intermediate:
  1329. {
  1330. ammoIconImg.LoadImageFile(0, "set:dayz_gui image:cartridge_int");
  1331. ammoIconImg.LoadImageFile(1, "set:dayz_gui image:shell_int");
  1332. ammoIconImg.LoadImageFile(2, "set:dayz_gui image:jam_int");
  1333. break;
  1334. }
  1335. case CartridgeType.FullPower:
  1336. {
  1337. ammoIconImg.LoadImageFile(0, "set:dayz_gui image:cartridge_fp");
  1338. ammoIconImg.LoadImageFile(1, "set:dayz_gui image:shell_fp");
  1339. ammoIconImg.LoadImageFile(2, "set:dayz_gui image:jam_fp");
  1340. break;
  1341. }
  1342. case CartridgeType.Shell:
  1343. {
  1344. ammoIconImg.LoadImageFile(0, "set:dayz_gui image:cartridge_shell");
  1345. ammoIconImg.LoadImageFile(1, "set:dayz_gui image:shell_shell");
  1346. ammoIconImg.LoadImageFile(2, "set:dayz_gui image:jam_shell");
  1347. break;
  1348. }
  1349. //@note: Crossbows cant jam so we dont add a icon for the jam state
  1350. case CartridgeType.Arrow:
  1351. {
  1352. ammoIconImg.LoadImageFile(0, "set:dayz_gui image:arrow_int");
  1353. ammoIconImg.LoadImageFile(1, "set:dayz_gui image:arrow_int");
  1354. break;
  1355. }
  1356. }
  1357. }
  1358. m_AmmoIcons.Insert(ammoIconImg);
  1359. }
  1360. }
  1361. else
  1362. {
  1363. m_IsWeapon = false;
  1364. }
  1365. }
  1366. void CheckIsMagazineEx( bool refresh = true )
  1367. {
  1368. Magazine mag = Magazine.Cast(m_Obj);
  1369. if (mag)
  1370. {
  1371. m_IsMagazine = true;
  1372. AmmoData data = Magazine.GetAmmoData(mag.ClassName());
  1373. if (data)
  1374. {
  1375. ProjectileType p_type = data.m_ProjectileType;
  1376. switch (p_type)
  1377. {
  1378. case ProjectileType.None:
  1379. {
  1380. m_AmmoTypeIcon.Show(false, refresh);
  1381. break;
  1382. }
  1383. case ProjectileType.Tracer:
  1384. {
  1385. m_AmmoTypeIcon.LoadImageFile(0, "set:dayz_gui image:tracer");
  1386. m_AmmoTypeIcon.Show(true, refresh);
  1387. break;
  1388. }
  1389. case ProjectileType.AP:
  1390. {
  1391. m_AmmoTypeIcon.LoadImageFile(0, "set:dayz_gui image:armor_piercing");
  1392. m_AmmoTypeIcon.Show(true, refresh);
  1393. break;
  1394. }
  1395. }
  1396. }
  1397. }
  1398. else
  1399. {
  1400. m_IsMagazine = false;
  1401. }
  1402. }
  1403. void CheckIsMagazine()
  1404. {
  1405. CheckIsMagazineEx();
  1406. }
  1407. void CheckHasTemperature()
  1408. {
  1409. if (m_Item)
  1410. {
  1411. m_HasTemperature = m_Item.CanHaveTemperature();
  1412. }
  1413. }
  1414. void CheckHasQuantityEx(bool refresh = true)
  1415. {
  1416. if (m_Item)
  1417. {
  1418. m_HasQuantity = (QuantityConversions.HasItemQuantity( m_Item ) != QUANTITY_HIDDEN);
  1419. if (m_HasQuantity)
  1420. m_QuantityPanel.Show(true, refresh);
  1421. }
  1422. }
  1423. void CheckHasQuantity()
  1424. {
  1425. CheckHasQuantityEx();
  1426. }
  1427. void SetPosX(int x)
  1428. {
  1429. m_PosX = x;
  1430. }
  1431. void SetPosY(int y)
  1432. {
  1433. m_PosY = y;
  1434. }
  1435. void SetSizeX(int x)
  1436. {
  1437. m_SizeX = x;
  1438. }
  1439. void SetSizeY(int y)
  1440. {
  1441. m_SizeY = y;
  1442. }
  1443. int GetPosX()
  1444. {
  1445. return m_PosX;
  1446. }
  1447. int GetPosY()
  1448. {
  1449. return m_PosY;
  1450. }
  1451. int GetSizeX()
  1452. {
  1453. return m_SizeX;
  1454. }
  1455. int GetSizeY()
  1456. {
  1457. return m_SizeY;
  1458. }
  1459. void SetPosEx(bool refresh = true)
  1460. {
  1461. CargoContainer parentContainer = CargoContainer.Cast(m_Parent);
  1462. HandsPreview parentHPrevContainer = HandsPreview.Cast(m_Parent);
  1463. Widget rootWidget = GetRootWidget();
  1464. float iconSize, spaceSize;
  1465. if (parentContainer)
  1466. {
  1467. iconSize = parentContainer.GetIconSize();
  1468. spaceSize = parentContainer.GetSpaceSize();
  1469. }
  1470. else if (parentHPrevContainer)
  1471. {
  1472. iconSize = parentHPrevContainer.GetIconSize();
  1473. if (rootWidget)
  1474. {
  1475. rootWidget.SetFlags(WidgetFlags.EXACTSIZE, refresh);
  1476. }
  1477. }
  1478. if (rootWidget)
  1479. {
  1480. #ifndef PLATFORM_CONSOLE
  1481. rootWidget.SetPos(iconSize * GetPosX() + ( GetPosX() + 1 ) * spaceSize, iconSize * GetPosY() + ( GetPosY() + 1 ) * spaceSize, refresh);
  1482. rootWidget.SetSize(iconSize * m_SizeX + ( m_SizeX ) * spaceSize, iconSize * m_SizeY + ( m_SizeY ) * spaceSize, refresh);
  1483. #else
  1484. int row = m_CargoPos / 5;
  1485. int column = m_CargoPos % 5;
  1486. rootWidget.SetPos(iconSize * column, iconSize * row, refresh);
  1487. rootWidget.SetSize(iconSize, iconSize, refresh);
  1488. #endif
  1489. }
  1490. }
  1491. void SetPos()
  1492. {
  1493. SetPosEx();
  1494. }
  1495. void SetSize()
  1496. {
  1497. CargoContainer parentContainer = CargoContainer.Cast(m_Parent);
  1498. HandsPreview parentHPrevContainer = HandsPreview.Cast(m_Parent);
  1499. float iconSize, spaceSize;
  1500. Widget rootWidget = GetRootWidget();
  1501. if (parentContainer)
  1502. {
  1503. iconSize = parentContainer.GetIconSize();
  1504. spaceSize = parentContainer.GetSpaceSize();
  1505. }
  1506. else if (parentHPrevContainer)
  1507. {
  1508. iconSize = parentHPrevContainer.GetIconSize();
  1509. if (rootWidget)
  1510. {
  1511. GetRootWidget().SetFlags(WidgetFlags.EXACTSIZE);
  1512. }
  1513. }
  1514. if (rootWidget)
  1515. {
  1516. #ifndef PLATFORM_CONSOLE
  1517. GetRootWidget().SetSize(iconSize * m_SizeX + ( m_SizeX ) * spaceSize, iconSize * m_SizeY + ( m_SizeY ) * spaceSize);
  1518. #else
  1519. GetRootWidget().SetSize(iconSize, iconSize);
  1520. #endif
  1521. }
  1522. }
  1523. override void UpdateInterval()
  1524. {
  1525. if (m_Item)
  1526. {
  1527. if (m_HasTemperature)
  1528. SetTemperature();
  1529. if (m_IsWeapon)
  1530. RefreshMuzzleIcon();
  1531. if (m_HasQuantity)
  1532. SetQuantity();
  1533. }
  1534. }
  1535. }
  1536. class Pos
  1537. {
  1538. int x, y;
  1539. void Pos(int _x, int _y)
  1540. {
  1541. x = _x;
  1542. y = _y;
  1543. }
  1544. }