9 protected bool m_IsWeapon =
false;
10 protected bool m_IsMagazine =
false;
11 protected bool m_HasTemperature =
false;
12 protected bool m_HasQuantity =
false;
13 protected float m_CurrQuantity = -1;
17 protected bool m_HandsIcon;
18 protected int m_CargoPos;
19 protected bool m_IsDragged;
20 protected bool m_PreviousFlipOrientation;
22 const int NUMBER_OF_TIMERS = 2;
26 protected Widget m_ColorWidget;
27 protected Widget m_SelectedPanel;
28 protected Widget m_MicromanagedPanel;
29 protected Widget m_CursorWidget;
31 protected Widget m_QuantityPanel;
33 protected ProgressBarWidget m_QuantityProgress;
34 protected Widget m_QuantityStack;
36 protected Widget m_ItemSizePanel;
40 protected ImageWidget m_AmmoTypeIcon;
44 m_HandsIcon = hands_icon;
45 ItemManager.GetInstance().SetSelectedItemEx(
null,
null,
null);
49 m_ColorWidget = GetMainWidget().FindAnyWidget(
"Color" );
51 m_MicromanagedPanel = GetMainWidget().FindAnyWidget(
"Micromanaged" );
52 m_CursorWidget = GetMainWidget().FindAnyWidget(
"Cursor" );
54 m_QuantityPanel = GetMainWidget().FindAnyWidget(
"QuantityPanel" );
56 m_QuantityProgress = ProgressBarWidget.Cast( GetMainWidget().
FindAnyWidget(
"QuantityBar" ) );
57 m_QuantityStack = GetMainWidget().FindAnyWidget(
"QuantityStackPanel" );
59 m_ItemSizePanel = GetMainWidget().FindAnyWidget(
"ItemSizePanel" );
62 m_AmmoTypeIcon = ImageWidget.Cast( GetMainWidget().
FindAnyWidget(
"AmmoTypeIcon" ) );
70 m_Obj.GetOnItemFlipped().Remove(UpdateFlip);
71 m_Obj.GetOnViewIndexChanged().Remove(SetItemPreview);
76 RevertToOriginalFlip();
90 return m_CursorWidget;
93 Widget GetMicromanagedPanel()
95 return m_MicromanagedPanel;
103 override void SetActive(
bool active )
105 super.SetActive(active);
106 if (active && GetObject())
109 GetMainWidget().GetScreenPos(
x,
y);
110 PrepareOwnedTooltip(
EntityAI.Cast( GetObject() ), -1,
y);
116 override void SetParentWidget()
118 #ifndef PLATFORM_CONSOLE
121 super.SetParentWidget();
127 CargoContainer gridContainer = CargoContainer.Cast(
m_Parent);
135 super.SetParentWidget();
139 int GetRelevantInventoryAction(
int relevantActions)
145 void RefreshQuickbar()
151 menu.RefreshQuickbar();
155 void DoubleClick(
Widget w,
int x,
int y,
int button)
160 if (controlledPlayer.GetInventory().HasInventoryReservation(m_Obj,
null) || controlledPlayer.GetInventory().IsInventoryLocked() || controlledPlayer.IsItemsToDelete())
166 string name = w.GetName();
167 name.Replace(
"PanelWidget",
"Render");
174 EntityAI targetEntity = targetIpw.GetItem();
177 if (!targetEntity.GetInventory().CanRemoveEntity())
182 if (controlledPlayer.GetHumanInventory().CanRemoveEntityInHands())
183 controlledPlayer.PredictiveMoveItemFromHandsToInventory();
190 EntityAI entityInHands = controlledPlayer.GetHumanInventory().GetEntityInHands();
191 EntityAI entityRootParent = targetEntity.GetHierarchyRoot();
193 if (controlledPlayer.GetInventory().HasEntityInInventory(targetEntity) && controlledPlayer.GetHumanInventory().CanAddEntityInHands(targetEntity))
195 controlledPlayer.PredictiveTakeEntityToHands(targetEntity);
197 else if (entityInHands && entityRootParent == controlledPlayer)
200 int index = controlledPlayer.GetHumanInventory().FindUserReservedLocationIndex(entityInHands);
202 controlledPlayer.GetHumanInventory().GetUserReservedLocation(index, inventoryLocation);
204 if (controlledPlayer.GetInventory().CanForceSwapEntitiesEx(targetEntity,
null, entityInHands, inventoryLocation))
206 controlledPlayer.PredictiveForceSwapEntities(targetEntity, entityInHands, inventoryLocation);
208 else if (controlledPlayer.GetInventory().CanSwapEntitiesEx(targetEntity, entityInHands ))
210 controlledPlayer.PredictiveSwapEntities(targetEntity, entityInHands);
215 if (inventoryLocation.IsValid() && controlledPlayer.GetInventory().LocationCanAddEntity(inventoryLocation))
216 SplitItemUtils.TakeOrSplitToInventoryLocation(controlledPlayer, inventoryLocation);
222 if (targetEntity.GetInventory().CanRemoveEntity())
230 if (i2.GetParent() != controlledPlayer)
238 if (controlledPlayer.GetHumanInventory().CanAddEntityToInventory(targetEntity))
243 if (controlledPlayer.GetHumanInventory().CanAddEntityInHands(targetEntity))
244 controlledPlayer.PredictiveTakeEntityToHands(targetEntity);
260 string name = w.GetName();
261 name.Replace(
"PanelWidget",
"Render");
266 targetIpw =
ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget(
"Render" ));
270 if (selectedIpw ==
null)
275 if (selectedIpw ==
null)
282 if (!selectedEntity || !targetEntity)
289 int index = player.GetHumanInventory().FindUserReservedLocationIndex(
m_Item);
293 player.GetHumanInventory().GetUserReservedLocation(index, il);
295 if (
GameInventory.CanForceSwapEntitiesEx(selectedEntity,
null, targetEntity, il))
299 ItemManager.GetInstance().ShowSourceDropzone(il.GetParent());
305 int chosenInventoryAction =
ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags, il);
306 UpdateFrameColor(selectedEntity, targetEntity, chosenInventoryAction, w, il);
319 string name = w.GetName();
320 name.Replace(
"PanelWidget",
"Render");
329 if (!selectedIpw.GetItem())
333 EntityAI selectedEntity = selectedIpw.GetItem();
334 EntityAI targetEntity =
GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
338 int chosenInventoryAction =
ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags);
339 UpdateFrameColor(selectedEntity, targetEntity, chosenInventoryAction, w);
342 bool MouseEnter(
Widget w,
int x,
int y)
346 PrepareOwnedTooltip(m_Obj,
x,
y);
347 m_CursorWidget.Show(
true);
358 m_CursorWidget.Show(
false);
371 string name = w.GetName();
372 name.Replace(
"PanelWidget",
"Render");
377 targetIpw =
ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget(
"Render" ));
381 if (selectedIpw ==
null)
385 if (selectedIpw ==
null)
394 if (!targetEntity || !selectedEntity)
401 if (targetEntity == selectedEntity)
404 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
408 CargoContainer parentContainer = CargoContainer.Cast(
m_Parent);
413 parentContainer.GetRootWidget().GetScreenPos(parentX, parentY);
415 float iconSize = parentContainer.GetIconSize();
416 float spaceSize = parentContainer.GetSpaceSize();
418 int PosX = (
x - parentX) / (iconSize + spaceSize);
419 int PosY = (
y - parentY) / (iconSize + spaceSize);
422 CargoBase targetCargo = parent.GetInventory().GetCargo();
425 ilDst.SetCargoAuto(targetCargo, selectedEntity, PosY, PosX, selectedEntity.GetInventory().GetFlipCargo());
427 if (parent.GetInventory().LocationCanAddEntity(ilDst))
430 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
435 ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
443 int chosenInventoryAction =
ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags, ilDst);
444 UpdateFrameColor(selectedEntity, targetEntity, chosenInventoryAction, w, ilDst);
448 void OnPerformCombination(
int combinationFlags )
451 if (m_am_entity1 ==
null || m_am_entity2 ==
null)
return;
461 Class.CastTo(amc, player.GetActionManager());
463 if (m_am_entity1 == player.GetHumanInventory().GetEntityInHands())
465 amc.PerformActionFromInventory(
ItemBase.Cast( m_am_entity1 ),
ItemBase.Cast( m_am_entity2 ));
469 amc.PerformActionFromInventory(
ItemBase.Cast( m_am_entity2 ),
ItemBase.Cast( m_am_entity1 ));
475 Class.CastTo(amc2, player.GetActionManager());
477 if (m_am_entity1 == player.GetHumanInventory().GetEntityInHands())
479 amc2.SetActionFromInventory(
ItemBase.Cast( m_am_entity1 ),
ItemBase.Cast( m_am_entity2 ));
483 amc2.SetActionFromInventory(
ItemBase.Cast( m_am_entity2 ),
ItemBase.Cast( m_am_entity1 ));
489 entity.CombineItemsClient(
ItemBase.Cast( m_am_entity2 ));
493 float stackable = m_am_entity2.GetTargetQuantityMax(-1);
495 if (stackable == 0 || stackable >= m_am_entity2.GetQuantity())
497 player.PredictiveTakeEntityToTargetAttachment(m_am_entity1, m_am_entity2);
503 ItemBase.Cast(m_am_entity2).SplitIntoStackMaxToInventoryLocationClient(il);
508 SplitItemUtils.TakeOrSplitToInventory(player, m_am_entity1, m_am_entity2);
517 switch (combinationFlag)
520 float stackable = targetEntity.GetTargetQuantityMax(-1);
522 if (stackable == 0 || stackable >= targetEntity.GetQuantity())
524 return player.PredictiveTakeEntityToTargetAttachment(targetEntity, selectedEntity);
530 ItemBase.Cast(selectedEntity).SplitIntoStackMaxToInventoryLocationClient(il);
535 SplitItemUtils.TakeOrSplitToInventory(player, targetEntity, selectedEntity);
538 targetEntity.CombineItemsClient(selectedEntity);
541 Class.CastTo(amc, player.GetActionManager());
542 if (targetEntity == player.GetHumanInventory().GetEntityInHands())
544 amc.SetActionFromInventory(
ItemBase.Cast(targetEntity),
ItemBase.Cast(selectedEntity));
548 amc.SetActionFromInventory(
ItemBase.Cast(selectedEntity),
ItemBase.Cast(targetEntity));
552 Class.CastTo(amc, player.GetActionManager());
553 if (targetEntity == player.GetHumanInventory().GetEntityInHands())
555 amc.PerformActionFromInventory(
ItemBase.Cast(targetEntity),
ItemBase.Cast(selectedEntity));
559 amc.PerformActionFromInventory(
ItemBase.Cast(selectedEntity),
ItemBase.Cast(targetEntity));
563 return player.GetWeaponManager().SwapMagazine(Magazine.Cast(selectedEntity));
565 return player.PredictiveSwapEntities(targetEntity, selectedEntity);
567 return player.PredictiveForceSwapEntities(selectedEntity, targetEntity, ilSwapDst);
581 switch (combinationFlag)
586 ItemManager.GetInstance().ShowSourceDropzone(targetEntity);
592 ItemManager.GetInstance().ShowSourceDropzone(targetEntity);
596 ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
600 ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
606 ItemManager.GetInstance().ShowSourceDropzone(il.GetParent());
610 ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
615 ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
623 void ShowActionMenuCombine(
EntityAI entity1,
EntityAI entity2,
int combinationFlags,
Widget w ,
bool color_test )
627 m_am_entity1 = entity1;
628 m_am_entity2 = entity2;
633 if ( entity1 ==
null || entity2 ==
null )
return;
640 ItemManager.GetInstance().ShowSourceDropzone( entity2 );
648 cmenu.Add(
"#inv_context_add_as_cargo",
this,
"OnPerformCombination",
new Param1<int>( lastFlag ) );
653 cmenu.Add(
"#inv_context_add_as_attachment",
this,
"OnPerformCombination",
new Param1<int>( lastFlag ));
659 cmenu.Add(
"#inv_context_combine_quantity",
this,
"OnPerformCombination",
new Param1<int>( lastFlag ));
665 cmenu.Add(
"#inv_context_attach_magazine",
this,
"OnPerformCombination",
new Param1<int>( lastFlag ));
671 cmenu.Add(
"Perform action",
this,
"OnPerformCombination",
new Param1<int>( lastFlag ));
679 ItemManager.GetInstance().GetCenterDropzone().SetAlpha( 1 );
685 ItemManager.GetInstance().GetCenterDropzone().SetAlpha( 1 );
691 ItemManager.GetInstance().GetCenterDropzone().SetAlpha( 1 );
695 else if (cmenu.Count() >= 1)
697 OnPerformCombination(combinationFlags);
702 void OnPerformRecipe(
int id)
704 if ( m_am_entity1 ==
null || m_am_entity2 ==
null )
return;
706 Debug.Log(
"OnPerformRecipe called for id:"+
id.
ToString(),
"recipes");
708 player.GetCraftingManager().SetInventoryCraft(
id,
ItemBase.Cast(m_am_entity1),
ItemBase.Cast(m_am_entity2));
718 string name = w.GetName();
719 name.Replace(
"PanelWidget",
"Render");
726 if (!selectedIpw.GetItem())
730 EntityAI selectedEntity = selectedIpw.GetItem();
731 EntityAI targetEntity =
GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
734 int chosenInventoryAction =
ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags);
735 PerformCombination(selectedEntity, targetEntity, chosenInventoryAction);
740 int flags =
ItemManager.GetCombinationFlags( entity1, entity2 );
741 return FlagAction( entity1, entity2, flags );
748 m_am_entity1 = entity1;
749 m_am_entity2 = entity2;
757 entity.CombineItemsClient(
ItemBase.Cast( entity2 ) );
767 cmenu.Add(
"#inv_context_add_as_attachment",
this,
"OnPerformCombination",
new Param1<int>( current_flag ) );
777 cmenu.Add(
"#inv_context_attach_magazine",
this,
"OnPerformCombination",
new Param1<int>( current_flag ) );
783 cmenu.Add(
"#inv_context_add_as_cargo",
this,
"OnPerformCombination",
new Param1<int>( current_flag ) );
789 cmenu.Add(
"#inv_context_swap",
this,
"OnPerformCombination",
new Param1<int>( current_flag ) );
795 cmenu.Add(
"#inv_context_combine",
this,
"OnPerformCombination",
new Param1<int>( current_flag ) );
801 cmenu.Add(
"#inv_context_attach_magazine",
this,
"OnPerformCombination",
new Param1<int>( current_flag ) );
807 cmenu.Add(
"Perform Action2",
this,
"OnPerformCombination",
new Param1<int>( current_flag ) );
810 int m_am_Pos_x, m_am_Pos_y;
815 MissionGameplay
mission = MissionGameplay.Cast(
GetGame().GetMission() );
823 OnPerformCombination( current_flag );
833 void MouseClick(
Widget w,
int x,
int y,
int button)
839 GetGame().GetPlayer().GetHumanInventory().ClearUserReservedLocationSynced(
m_Item);
849 #ifdef DIAG_DEVELOPER
867 if (
g_Game.IsLeftCtrlDown())
869 if (controlledPlayer.CanDropEntity(
m_Item))
871 if (
m_Item.GetTargetQuantityMax() <
m_Item.GetQuantity())
872 m_Item.SplitIntoStackMaxClient(
null, -1);
874 controlledPlayer.PhysicalPredictiveDropItem(
m_Item);
876 ItemManager.GetInstance().SetWidgetDraggable(w,
false);
882 m_Obj.GetInventory().GetCurrentInventoryLocation(il);
884 bool draggable = !controlledPlayer.GetInventory().HasInventoryReservation(m_Obj,
null) && !controlledPlayer.GetInventory().IsInventoryLocked() && !controlledPlayer.IsItemsToDelete();
885 draggable = draggable && (m_Obj.GetHierarchyRoot() && m_Obj.GetInventory().CanRemoveEntity() || !m_Obj.GetHierarchyRoot() &&
AttachmentsOutOfReach.IsAttachmentReachable(m_Obj,
"", il.GetSlot()));
887 ItemManager.GetInstance().SetWidgetDraggable(w, draggable);
894 void DropReceivedFromMain(
Widget w,
int x,
int y,
Widget receiver )
898 string name = w.GetName();
899 name.Replace(
"PanelWidget",
"Render");
905 targetIpw =
ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget(
"Render" ));
909 if (selectedIpw ==
null)
913 if (selectedIpw ==
null)
927 if (m_Lock && targetEntity == selectedEntity)
929 index = player.GetHumanInventory().FindUserReservedLocationIndex(
m_Item);
933 m_Item.GetInventory().GetCurrentInventoryLocation(ilSrc);
934 player.GetHumanInventory().GetUserReservedLocation(index, ilDst);
936 if (ilDst.GetParent().GetInventory().LocationCanAddEntity(ilDst))
939 player.GetHumanInventory().ClearUserReservedLocation(
m_Item);
940 player.PredictiveTakeToDst(ilSrc, ilDst);
946 CargoContainer parentCargo = CargoContainer.Cast(
m_Parent);
951 parentCargo.GetRootWidget().GetScreenPos(parentX, parentY);
953 float iconSize = parentCargo.GetIconSize();
954 float spaceSize = parentCargo.GetSpaceSize();
956 int PosX = (
x-parentX) / (iconSize + spaceSize);
957 int PosY = (
y-parentY) / (iconSize + spaceSize);
960 CargoBase targetCargo = parent.GetInventory().GetCargo();
963 ilDst.SetCargoAuto(targetCargo, selectedEntity, PosY, PosX, selectedEntity.GetInventory().GetFlipCargo());
965 if (parent.GetInventory().LocationCanAddEntity(ilDst))
967 player.GetHumanInventory().ClearUserReservedLocation(
m_Item);
978 int chosenInventoryAction =
ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags, ilDst);
979 PerformCombination(selectedEntity, targetEntity, chosenInventoryAction, ilDst);
987 string name = w.GetName();
988 name.Replace(
"PanelWidget",
"Render");
993 targetIpw =
ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget(
"Render" ));
997 if (selectedIpw ==
null)
1001 if (selectedIpw ==
null)
1008 if (!selectedEntity || !targetEntity)
1014 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
1018 targetEntity.GetInventory().GetCurrentInventoryLocation(ilSrc);
1021 int index = player.GetHumanInventory().FindUserReservedLocationIndex(targetEntity);
1024 player.GetHumanInventory().GetUserReservedLocation(index, ilDst);
1026 if (
GameInventory.CanForceSwapEntitiesEx( selectedEntity, ilSrc, targetEntity, ilDst ))
1028 if (m_HandsIcon && !player.GetInventory().HasInventoryReservation(itemInHands,
null) && !player.IsItemsToDelete())
1030 GetGame().GetPlayer().PredictiveForceSwapEntities(selectedEntity, targetEntity, ilDst);
1037 int chosenInventoryAction =
ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags, ilDst);
1038 PerformCombination(selectedEntity, targetEntity, chosenInventoryAction, ilDst);
1041 void ToRefresh(
Icon icon,
Icon icon2 )
1047 override void SetLayoutName()
1049 #ifdef PLATFORM_CONSOLE
1074 void SetSize(
int x,
int y )
1080 void SetPos(
int x,
int y )
1091 void SetCargoPos(
int x)
1093 GetMainWidget().SetSort(
x );
1097 void DestroyWhiteBackground()
1101 m_IsDragged =
false;
1103 RevertToOriginalFlip();
1107 m_ItemPreview.SetForceFlipEnable(
true);
1108 m_ItemPreview.SetForceFlip(
false);
1113 m_CursorWidget.SetColor(
ARGBF( 1, 1, 1, 1 ) );
1114 m_CursorWidget.Show(
false );
1119 menu.RefreshQuickbar();
1122 void CreateWhiteBackground()
1124 m_PreviousFlipOrientation =
m_Item.GetInventory().GetFlipCargo();
1131 if (
m_Item.GetInventory().GetFlipCargo())
1144 m_ItemPreview.SetForceFlipEnable(
false);
1146 m_ColorWidget.SetAlpha(0.1);
1149 m_CursorWidget.Show(
true);
1152 void OnDraggingOverBackground(
Widget w,
int x,
int y,
Widget reciever )
1156 EntityAI parent = entity.GetHierarchyParent();
1159 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
1161 else if (!m_HandsIcon)
1163 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
1166 if (w ==
null || reciever ==
null)
1171 reciever.GetUserData(pa);
1174 ContainerWithCargo item = ContainerWithCargo.Cast(
m_Parent.m_Parent);
1177 item.DraggingOverGrid(w, m_PosY + pa.y, m_PosX + pa.x, reciever);
1182 hands_item.DraggingOverGrid(w, m_PosY + pa.y, m_PosX + pa.x, reciever,
null);
1187 void DropReceivedFromBackground(
Widget w,
int x,
int y,
Widget reciever )
1192 reciever.GetUserData(pa);
1195 ContainerWithCargo item = ContainerWithCargo.Cast(
m_Parent.m_Parent);
1198 item.DropReceived(w, m_PosY + pa.y, m_PosX + pa.x);
1204 void RevertToOriginalFlip()
1208 m_Item.GetInventory().SetFlipCargo(m_PreviousFlipOrientation);
1212 if (m_PreviousFlipOrientation)
1221 override void Refresh()
1228 if (m_HasTemperature)
1232 RefreshMuzzleIcon();
1238 void SetTemperature()
1243 void RefreshIconPos()
1246 GetMainWidget().Update();
1256 GetRootWidget().SetSize(1, 1);
1257 m_ColorWidget.SetColor(
ARGB( 0, 0, 0, 0 ));
1260 void RefreshPos(
int row,
int column )
1262 if (row != m_PosY || column != m_PosX)
1276 void RefreshMuzzleIcon()
1282 ImageWidget ammoIcon;
1283 if (!wpn.IsShowingChamberedBullet())
1285 for (i = 0; i < m_AmmoIcons.Count(); i++)
1287 ammoIcon = m_AmmoIcons.Get(i);
1288 ammoIcon.Show(
false);
1347 for (i = 0; i < wpn.GetMuzzleCount(); i++)
1349 if ( i > m_AmmoIcons.Count() )
1355 ammoIcon = m_AmmoIcons.Get(i);
1357 if (wpn.IsChamberFull(i))
1361 ammoIcon.Show(
true);
1362 ammoIcon.SetImage(2);
1364 else if (wpn.IsChamberFiredOut(i))
1366 ammoIcon.Show(
true);
1367 ammoIcon.SetImage(1);
1371 ammoIcon.Show(
true );
1372 ammoIcon.SetImage( 0 );
1377 ammoIcon.Show(
false);
1399 m_QuantityStack.Show(
false);
1403 m_QuantityItem.SetText(quantityText);
1404 m_QuantityStack.Show(
true);
1407 m_QuantityProgress.Show(
false);
1411 int max =
m_Item.GetQuantityMax();
1412 int count =
m_Item.ConfigGetInt(
"count");
1413 float quantity = m_CurrQuantity;
1422 float value =
Math.Round((quantity / max) * 100);
1423 m_QuantityProgress.SetCurrent(value);
1426 m_QuantityStack.Show(
false);
1427 m_QuantityProgress.Show(
true);
1433 void SetSort(
int index)
1435 GetMainWidget().SetSort(index);
1436 GetMainWidget().Update();
1441 return GetMainWidget().GetSort();
1444 void SetItemPreviewEx(
bool refresh =
true)
1446 m_ItemPreview.Show(
true, refresh);
1447 m_ItemPreview.SetItem(
EntityAI.Cast(m_Obj));
1448 m_ItemPreview.SetModelOrientation(
"0 0 0");
1449 m_ItemPreview.SetView(m_Obj.GetViewIndex());
1452 void SetItemPreview()
1457 void SetItemSizeEx(
bool refresh =
true)
1459 #ifdef PLATFORM_CONSOLE
1460 m_ItemSizePanel.Show(
true, refresh);
1461 m_ItemSizeWidget.Show(
true, refresh);
1465 int capacity = sizeX * sizeY;
1466 m_ItemSizeWidget.SetText(capacity.ToString());
1475 void UpdateFlip(
bool flipped)
1481 SetSize(sizeY, sizeX);
1483 SetSize(sizeX, sizeY);
1488 void InitLock(
EntityAI parent,
EntityAI obj,
int x_pos,
int y_pos,
bool flip)
1494 SetPos(x_pos, y_pos);
1497 ItemManager.GetInstance().SetWidgetDraggable( GetMainWidget(),
false );
1498 WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown( GetMainWidget(),
this,
"MouseClick" );
1499 WidgetEventHandler.GetInstance().RegisterOnDropReceived( GetMainWidget(),
this,
"DropReceivedFromMain" );
1500 WidgetEventHandler.GetInstance().RegisterOnDraggingOver( GetMainWidget(),
this,
"DraggingOver" );
1503 m_ItemPreview.SetForceFlipEnable(
true);
1504 m_ItemPreview.SetForceFlip(flip);
1509 void InitEx(
EntityAI obj,
bool refresh =
true )
1515 m_Obj.GetOnItemFlipped().Remove(UpdateFlip );
1516 m_Obj.GetOnViewIndexChanged().Remove(SetItemPreview);
1520 obj.GetOnItemFlipped().Insert(UpdateFlip);
1521 obj.GetOnViewIndexChanged().Insert(SetItemPreview);
1527 m_ItemPreview.SetForceFlipEnable(
true);
1528 m_ItemPreview.SetForceFlip(
false);
1535 SetItemPreviewEx(refresh);
1537 WidgetEventHandler.GetInstance().RegisterOnDrag( GetMainWidget(),
this,
"CreateWhiteBackground" );
1538 WidgetEventHandler.GetInstance().RegisterOnDrop( GetMainWidget(),
this,
"DestroyWhiteBackground" );
1539 WidgetEventHandler.GetInstance().RegisterOnDropReceived( GetMainWidget(),
this,
"DropReceivedFromMain" );
1540 WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown( GetMainWidget(),
this,
"MouseClick" );
1545 WidgetEventHandler.GetInstance().RegisterOnDraggingOver( GetMainWidget(),
this,
"DraggingOver" );
1546 WidgetEventHandler.GetInstance().RegisterOnMouseEnter( GetMainWidget(),
this,
"MouseEnter" );
1547 WidgetEventHandler.GetInstance().RegisterOnMouseLeave( GetMainWidget(),
this,
"MouseLeave" );
1548 WidgetEventHandler.GetInstance().RegisterOnDoubleClick( GetMainWidget(),
this,
"DoubleClick" );
1550 SetItemSizeEx(refresh);
1552 CheckIsMagazineEx(refresh);
1553 CheckHasTemperature();
1554 CheckHasQuantityEx(refresh);
1555 m_RootWidget.FindAnyWidget(
"Reserved").Show(
false, refresh);
1566 void CheckIsWeapon()
1574 float widht = 0.0, height = 0.0;
1575 for (
int i = 0; i < wpn.GetMuzzleCount(); i++)
1579 m_AmmoIcons[0].GetSize(widht,height);
1583 Widget ammoIcon =
Widget.Cast(
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/inventory_new/ammo_icon.layout", GetMainWidget() ));
1584 ammoIcon.SetPos(posX, 0.0,
false);
1586 ImageWidget ammoIconImg = ImageWidget.Cast(ammoIcon.GetChildren());
1588 AmmoData data = Magazine.GetAmmoData(wpn.GetChamberAmmoTypeName(i));
1596 ammoIconImg.LoadImageFile(0,
"set:dayz_gui image:cartridge_pistol");
1597 ammoIconImg.LoadImageFile(1,
"set:dayz_gui image:shell_pistol");
1598 ammoIconImg.LoadImageFile(2,
"set:dayz_gui image:jam_pistol");
1603 ammoIconImg.LoadImageFile(0,
"set:dayz_gui image:cartridge_int");
1604 ammoIconImg.LoadImageFile(1,
"set:dayz_gui image:shell_int");
1605 ammoIconImg.LoadImageFile(2,
"set:dayz_gui image:jam_int");
1610 ammoIconImg.LoadImageFile(0,
"set:dayz_gui image:cartridge_fp");
1611 ammoIconImg.LoadImageFile(1,
"set:dayz_gui image:shell_fp");
1612 ammoIconImg.LoadImageFile(2,
"set:dayz_gui image:jam_fp");
1617 ammoIconImg.LoadImageFile(0,
"set:dayz_gui image:cartridge_shell");
1618 ammoIconImg.LoadImageFile(1,
"set:dayz_gui image:shell_shell");
1619 ammoIconImg.LoadImageFile(2,
"set:dayz_gui image:jam_shell");
1624 m_AmmoIcons.Insert(ammoIconImg);
1633 void CheckIsMagazineEx(
bool refresh =
true )
1635 Magazine mag = Magazine.Cast(m_Obj);
1638 m_IsMagazine =
true;
1639 AmmoData data = Magazine.GetAmmoData(mag.ClassName());
1642 ProjectileType p_type = data.m_ProjectileType;
1645 case ProjectileType.None:
1647 m_AmmoTypeIcon.Show(
false, refresh);
1650 case ProjectileType.Tracer:
1652 m_AmmoTypeIcon.LoadImageFile(0,
"set:dayz_gui image:tracer");
1653 m_AmmoTypeIcon.Show(
true, refresh);
1656 case ProjectileType.AP:
1658 m_AmmoTypeIcon.LoadImageFile(0,
"set:dayz_gui image:armor_piercing");
1659 m_AmmoTypeIcon.Show(
true, refresh);
1667 m_IsMagazine =
false;
1671 void CheckIsMagazine()
1673 CheckIsMagazineEx();
1676 void CheckHasTemperature()
1680 m_HasTemperature = (
m_Item.GetTemperatureMax() != 0 &&
m_Item.GetTemperatureMin() != 0);
1684 void CheckHasQuantityEx(
bool refresh =
true)
1691 m_QuantityPanel.Show(
true, refresh);
1695 void CheckHasQuantity()
1697 CheckHasQuantityEx();
1710 void SetSizeX(
int x)
1715 void SetSizeY(
int y)
1740 void SetPosEx(
bool refresh =
true)
1742 CargoContainer parentContainer = CargoContainer.Cast(
m_Parent);
1744 Widget rootWidget = GetRootWidget();
1745 float iconSize, spaceSize;
1746 if (parentContainer)
1748 iconSize = parentContainer.GetIconSize();
1749 spaceSize = parentContainer.GetSpaceSize();
1751 else if (parentHPrevContainer)
1753 iconSize = parentHPrevContainer.GetIconSize();
1756 rootWidget.SetFlags(
WidgetFlags.EXACTSIZE, refresh);
1762 #ifndef PLATFORM_CONSOLE
1763 rootWidget.SetPos(iconSize * GetPosX() + ( GetPosX() + 1 ) * spaceSize, iconSize * GetPosY() + ( GetPosY() + 1 ) * spaceSize, refresh);
1764 rootWidget.SetSize(iconSize * m_SizeX + ( m_SizeX ) * spaceSize, iconSize * m_SizeY + ( m_SizeY ) * spaceSize, refresh);
1766 int row = m_CargoPos / 5;
1767 int column = m_CargoPos % 5;
1768 rootWidget.SetPos(iconSize * column, iconSize * row, refresh);
1769 rootWidget.SetSize(iconSize, iconSize, refresh);
1781 CargoContainer parentContainer = CargoContainer.Cast(
m_Parent);
1783 float iconSize, spaceSize;
1784 Widget rootWidget = GetRootWidget();
1785 if (parentContainer)
1787 iconSize = parentContainer.GetIconSize();
1788 spaceSize = parentContainer.GetSpaceSize();
1790 else if (parentHPrevContainer)
1792 iconSize = parentHPrevContainer.GetIconSize();
1801 #ifndef PLATFORM_CONSOLE
1802 GetRootWidget().SetSize(iconSize * m_SizeX + ( m_SizeX ) * spaceSize, iconSize * m_SizeY + ( m_SizeY ) * spaceSize);
1804 GetRootWidget().SetSize(iconSize, iconSize);
1809 override void UpdateInterval()
1813 if (m_HasTemperature)
1817 RefreshMuzzleIcon();