icon.c 48 KB

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