55 m_QuantityItem = TextWidget.Cast( GetMainWidget().FindAnyWidget(
"Quantity" ) );
56 m_QuantityProgress = ProgressBarWidget.Cast( GetMainWidget().FindAnyWidget(
"QuantityBar" ) );
57 m_QuantityStack = GetMainWidget().FindAnyWidget(
"QuantityStackPanel" );
60 m_ItemSizeWidget = TextWidget.Cast( GetMainWidget().FindAnyWidget(
"ItemSize" ) );
62 m_AmmoTypeIcon = ImageWidget.Cast( GetMainWidget().FindAnyWidget(
"AmmoTypeIcon" ) );
105 super.SetActive(active);
109 GetMainWidget().GetScreenPos(
x,
y);
122 #ifndef PLATFORM_CONSOLE
125 super.SetParentWidget();
131 CargoContainer gridContainer = CargoContainer.Cast(
m_Parent);
139 super.SetParentWidget();
155 menu.RefreshQuickbar();
164 if (controlledPlayer.GetInventory().HasInventoryReservation(
m_Obj, null) || controlledPlayer.GetInventory().IsInventoryLocked() || controlledPlayer.IsItemsToDelete())
170 string name = w.GetName();
171 name.Replace(
"PanelWidget",
"Render");
178 EntityAI targetEntity = targetIpw.GetItem();
181 if (!targetEntity.GetInventory().CanRemoveEntity())
186 if (controlledPlayer.GetHumanInventory().CanRemoveEntityInHands())
187 controlledPlayer.PredictiveMoveItemFromHandsToInventory();
194 EntityAI entityInHands = controlledPlayer.GetHumanInventory().GetEntityInHands();
195 EntityAI entityRootParent = targetEntity.GetHierarchyRoot();
197 if (controlledPlayer.GetInventory().HasEntityInInventory(targetEntity) && controlledPlayer.GetHumanInventory().CanAddEntityInHands(targetEntity))
199 controlledPlayer.PredictiveTakeEntityToHands(targetEntity);
201 else if (entityInHands && entityRootParent == controlledPlayer)
205 entityInHands.GetInventory().GetCurrentInventoryLocation(handsItemLocation);
206 int index = controlledPlayer.GetHumanInventory().FindUserReservedLocationIndex(entityInHands);
208 controlledPlayer.GetHumanInventory().GetUserReservedLocation(index, targetItemLocation);
210 if (controlledPlayer.GetInventory().CanForceSwapEntitiesEx(targetEntity, targetItemLocation, entityInHands, handsItemLocation))
212 controlledPlayer.PredictiveForceSwapEntities(targetEntity, entityInHands, targetItemLocation);
214 else if (controlledPlayer.GetInventory().CanSwapEntitiesEx(targetEntity, entityInHands ))
216 controlledPlayer.PredictiveSwapEntities(targetEntity, entityInHands);
221 if (targetItemLocation.IsValid() && controlledPlayer.GetInventory().LocationCanAddEntity(targetItemLocation))
222 SplitItemUtils.TakeOrSplitToInventoryLocation(controlledPlayer, targetItemLocation);
228 if (targetEntity.GetInventory().CanRemoveEntity())
236 if (i2.GetParent() != controlledPlayer)
244 if (controlledPlayer.GetHumanInventory().CanAddEntityToInventory(targetEntity))
249 if (controlledPlayer.GetHumanInventory().CanAddEntityInHands(targetEntity))
250 controlledPlayer.PredictiveTakeEntityToHands(targetEntity);
266 string name = w.GetName();
267 name.Replace(
"PanelWidget",
"Render");
272 targetIpw =
ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget(
"Render" ));
276 if (selectedIpw == null)
281 if (selectedIpw == null)
288 if (!selectedEntity || !targetEntity)
295 int index = player.GetHumanInventory().FindUserReservedLocationIndex(
m_Item);
299 player.GetHumanInventory().GetUserReservedLocation(index, il);
312 UpdateFrameColor(selectedEntity, targetEntity, chosenInventoryAction, w, il);
325 string name = w.GetName();
326 name.Replace(
"PanelWidget",
"Render");
335 if (!selectedIpw.GetItem())
339 EntityAI selectedEntity = selectedIpw.GetItem();
340 EntityAI targetEntity =
GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
352 PrepareOwnedTooltip(
m_Obj,
x,
y);
377 string name = w.GetName();
378 name.Replace(
"PanelWidget",
"Render");
383 targetIpw =
ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget(
"Render" ));
387 if (selectedIpw == null)
391 if (selectedIpw == null)
400 if (!targetEntity || !selectedEntity)
407 if (targetEntity == selectedEntity)
414 CargoContainer parentContainer = CargoContainer.Cast(
m_Parent);
419 parentContainer.GetRootWidget().GetScreenPos(parentX, parentY);
421 float iconSize = parentContainer.GetIconSize();
422 float spaceSize = parentContainer.GetSpaceSize();
424 int PosX = (
x - parentX) / (iconSize + spaceSize);
425 int PosY = (
y - parentY) / (iconSize + spaceSize);
428 CargoBase targetCargo = parent.GetInventory().GetCargo();
431 ilDst.SetCargoAuto(targetCargo, selectedEntity, PosY, PosX, selectedEntity.GetInventory().GetFlipCargo());
433 if (parent.GetInventory().LocationCanAddEntity(ilDst))
450 UpdateFrameColor(selectedEntity, targetEntity, chosenInventoryAction, w, ilDst);
457 if (m_am_entity1 == null || m_am_entity2 == null)
return;
467 Class.CastTo(amc, player.GetActionManager());
469 if (m_am_entity1 == player.GetHumanInventory().GetEntityInHands())
481 Class.CastTo(amc2, player.GetActionManager());
483 if (m_am_entity1 == player.GetHumanInventory().GetEntityInHands())
495 entity.CombineItemsClient(
ItemBase.Cast( m_am_entity2 ));
499 float stackable = m_am_entity2.GetTargetQuantityMax(-1);
501 if (stackable == 0 || stackable >= m_am_entity2.GetQuantity())
503 player.PredictiveTakeEntityToTargetAttachment(m_am_entity1, m_am_entity2);
509 ItemBase.Cast(m_am_entity2).SplitIntoStackMaxToInventoryLocationClient(il);
514 SplitItemUtils.TakeOrSplitToInventory(player, m_am_entity1, m_am_entity2);
523 switch (combinationFlag)
526 return player.PredictiveTakeEntityToTargetAttachment(targetEntity, selectedEntity);
528 SplitItemUtils.TakeOrSplitToInventory(player, targetEntity, selectedEntity);
531 targetEntity.CombineItemsClient(selectedEntity);
534 Class.CastTo(amc, player.GetActionManager());
535 if (targetEntity == player.GetHumanInventory().GetEntityInHands())
545 Class.CastTo(amc, player.GetActionManager());
546 if (targetEntity == player.GetHumanInventory().GetEntityInHands())
556 return player.GetWeaponManager().SwapMagazine(Magazine.Cast(selectedEntity));
558 return player.PredictiveSwapEntities(targetEntity, selectedEntity);
560 return player.PredictiveForceSwapEntities(selectedEntity, targetEntity, ilSwapDst);
571 Widget targetDropzone;
574 switch (combinationFlag)
620 m_am_entity1 = entity1;
621 m_am_entity2 = entity2;
626 if ( entity1 == null || entity2 == null )
return;
641 cmenu.Add(
"#inv_context_add_as_cargo",
this,
"OnPerformCombination",
new Param1<int>( lastFlag ) );
646 cmenu.Add(
"#inv_context_add_as_attachment",
this,
"OnPerformCombination",
new Param1<int>( lastFlag ));
652 cmenu.Add(
"#inv_context_combine_quantity",
this,
"OnPerformCombination",
new Param1<int>( lastFlag ));
658 cmenu.Add(
"#inv_context_attach_magazine",
this,
"OnPerformCombination",
new Param1<int>( lastFlag ));
664 cmenu.Add(
"Perform action",
this,
"OnPerformCombination",
new Param1<int>( lastFlag ));
688 else if (cmenu.Count() >= 1)
697 if ( m_am_entity1 == null || m_am_entity2 == null )
return;
699 Debug.Log(
"OnPerformRecipe called for id:"+
id.
ToString(),
"recipes");
701 player.GetCraftingManager().SetInventoryCraft(
id,
ItemBase.Cast(m_am_entity1),
ItemBase.Cast(m_am_entity2));
711 string name = w.GetName();
712 name.Replace(
"PanelWidget",
"Render");
719 if (!selectedIpw.GetItem())
723 EntityAI selectedEntity = selectedIpw.GetItem();
724 EntityAI targetEntity =
GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
741 m_am_entity1 = entity1;
742 m_am_entity2 = entity2;
750 entity.CombineItemsClient(
ItemBase.Cast( entity2 ) );
760 cmenu.Add(
"#inv_context_add_as_attachment",
this,
"OnPerformCombination",
new Param1<int>( current_flag ) );
770 cmenu.Add(
"#inv_context_attach_magazine",
this,
"OnPerformCombination",
new Param1<int>( current_flag ) );
776 cmenu.Add(
"#inv_context_add_as_cargo",
this,
"OnPerformCombination",
new Param1<int>( current_flag ) );
782 cmenu.Add(
"#inv_context_swap",
this,
"OnPerformCombination",
new Param1<int>( current_flag ) );
788 cmenu.Add(
"#inv_context_combine",
this,
"OnPerformCombination",
new Param1<int>( current_flag ) );
794 cmenu.Add(
"#inv_context_attach_magazine",
this,
"OnPerformCombination",
new Param1<int>( current_flag ) );
800 cmenu.Add(
"Perform Action2",
this,
"OnPerformCombination",
new Param1<int>( current_flag ) );
803 int m_am_Pos_x, m_am_Pos_y;
808 MissionGameplay
mission = MissionGameplay.Cast(
GetGame().GetMission() );
832 GetGame().GetPlayer().GetHumanInventory().ClearUserReservedLocationSynced(
m_Item);
836 #ifdef DIAG_DEVELOPER
860 if (
g_Game.IsLeftCtrlDown())
862 if (controlledPlayer.CanDropEntity(
m_Item))
864 if (
m_Item.GetTargetQuantityMax() <
m_Item.GetQuantity())
865 m_Item.SplitIntoStackMaxClient(null, -1);
867 controlledPlayer.PhysicalPredictiveDropItem(
m_Item);
875 m_Obj.GetInventory().GetCurrentInventoryLocation(il);
877 bool draggable = !controlledPlayer.GetInventory().HasInventoryReservation(
m_Obj, null) && !controlledPlayer.GetInventory().IsInventoryLocked() && !controlledPlayer.IsItemsToDelete();
891 string name = w.GetName();
892 name.Replace(
"PanelWidget",
"Render");
898 targetIpw =
ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget(
"Render" ));
902 if (selectedIpw == null)
906 if (selectedIpw == null)
920 if (
m_Lock && targetEntity == selectedEntity)
922 index = player.GetHumanInventory().FindUserReservedLocationIndex(
m_Item);
926 m_Item.GetInventory().GetCurrentInventoryLocation(ilSrc);
927 player.GetHumanInventory().GetUserReservedLocation(index, ilDst);
929 if (ilDst.GetParent().GetInventory().LocationCanAddEntity(ilDst))
932 player.GetHumanInventory().ClearUserReservedLocation(
m_Item);
933 player.PredictiveTakeToDst(ilSrc, ilDst);
939 CargoContainer parentCargo = CargoContainer.Cast(
m_Parent);
944 parentCargo.GetRootWidget().GetScreenPos(parentX, parentY);
946 float iconSize = parentCargo.GetIconSize();
947 float spaceSize = parentCargo.GetSpaceSize();
949 int PosX = (
x-parentX) / (iconSize + spaceSize);
950 int PosY = (
y-parentY) / (iconSize + spaceSize);
953 CargoBase targetCargo = parent.GetInventory().GetCargo();
956 ilDst.SetCargoAuto(targetCargo, selectedEntity, PosY, PosX, selectedEntity.GetInventory().GetFlipCargo());
958 if (parent.GetInventory().LocationCanAddEntity(ilDst))
960 player.GetHumanInventory().ClearUserReservedLocation(
m_Item);
976 void Swap( Widget w,
int x,
int y, Widget receiver )
980 string name = w.GetName();
981 name.Replace(
"PanelWidget",
"Render");
986 targetIpw =
ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget(
"Render" ));
990 if (selectedIpw == null)
994 if (selectedIpw == null)
1001 if (!selectedEntity || !targetEntity)
1007 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
1011 targetEntity.GetInventory().GetCurrentInventoryLocation(ilSrc);
1014 int index = player.GetHumanInventory().FindUserReservedLocationIndex(targetEntity);
1017 player.GetHumanInventory().GetUserReservedLocation(index, ilDst);
1021 if (
m_HandsIcon && !player.GetInventory().HasInventoryReservation(itemInHands, null) && !player.IsItemsToDelete())
1023 GetGame().GetPlayer().PredictiveForceSwapEntities(selectedEntity, targetEntity, ilDst);
1042 #ifdef PLATFORM_CONSOLE
1086 GetMainWidget().SetSort(
x );
1114 menu.RefreshQuickbar();
1126 if (
m_Item.GetInventory().GetFlipCargo())
1151 EntityAI parent = entity.GetHierarchyParent();
1161 if (w == null || reciever == null)
1166 reciever.GetUserData(pa);
1169 ContainerWithCargo item = ContainerWithCargo.Cast(
m_Parent.m_Parent);
1172 item.DraggingOverGrid(w,
m_PosY + pa.y,
m_PosX + pa.x, reciever);
1187 reciever.GetUserData(pa);
1190 ContainerWithCargo item = ContainerWithCargo.Cast(
m_Parent.m_Parent);
1241 GetMainWidget().Update();
1251 GetRootWidget().SetSize(1, 1);
1277 ImageWidget ammoIcon;
1278 if (!wpn.IsShowingChamberedBullet())
1283 ammoIcon.Show(
false);
1288 for (i = 0; i < wpn.GetMuzzleCount(); i++)
1295 if (wpn.IsChamberFull(i))
1299 ammoIcon.Show(
true);
1300 ammoIcon.SetImage(2);
1302 else if (wpn.IsChamberFiredOut(i))
1304 ammoIcon.Show(
true);
1305 ammoIcon.SetImage(1);
1309 ammoIcon.Show(
true);
1310 ammoIcon.SetImage(0);
1315 ammoIcon.Show(
false);
1349 int max =
m_Item.GetQuantityMax();
1350 int count =
m_Item.ConfigGetInt(
"count");
1360 float value =
Math.Round((quantity / max) * 100);
1373 GetMainWidget().SetSort(index);
1374 GetMainWidget().Update();
1379 return GetMainWidget().GetSort();
1397 #ifdef PLATFORM_CONSOLE
1403 int capacity = sizeX * sizeY;
1493 m_RootWidget.FindAnyWidget(
"Reserved").Show(
false, refresh);
1513 float width = 0.0, height = 0.0;
1514 for (
int i = 0; i < wpn.GetMuzzleCount(); i++)
1522 Widget ammoIcon = Widget.Cast(
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/inventory_new/ammo_icon.layout", GetMainWidget()));
1523 ammoIcon.SetPos(posX, 0.0,
false);
1525 ImageWidget ammoIconImg = ImageWidget.Cast(ammoIcon.GetChildren());
1527 AmmoData data = Magazine.GetAmmoData(wpn.GetChamberAmmoTypeName(i));
1531 switch (cartridgeType)
1535 ammoIconImg.LoadImageFile(0,
"set:dayz_gui image:cartridge_pistol");
1536 ammoIconImg.LoadImageFile(1,
"set:dayz_gui image:shell_pistol");
1537 ammoIconImg.LoadImageFile(2,
"set:dayz_gui image:jam_pistol");
1542 ammoIconImg.LoadImageFile(0,
"set:dayz_gui image:cartridge_int");
1543 ammoIconImg.LoadImageFile(1,
"set:dayz_gui image:shell_int");
1544 ammoIconImg.LoadImageFile(2,
"set:dayz_gui image:jam_int");
1549 ammoIconImg.LoadImageFile(0,
"set:dayz_gui image:cartridge_fp");
1550 ammoIconImg.LoadImageFile(1,
"set:dayz_gui image:shell_fp");
1551 ammoIconImg.LoadImageFile(2,
"set:dayz_gui image:jam_fp");
1556 ammoIconImg.LoadImageFile(0,
"set:dayz_gui image:cartridge_shell");
1557 ammoIconImg.LoadImageFile(1,
"set:dayz_gui image:shell_shell");
1558 ammoIconImg.LoadImageFile(2,
"set:dayz_gui image:jam_shell");
1564 ammoIconImg.LoadImageFile(0,
"set:dayz_gui image:arrow_int");
1565 ammoIconImg.LoadImageFile(1,
"set:dayz_gui image:arrow_int");
1581 Magazine mag = Magazine.Cast(
m_Obj);
1585 AmmoData data = Magazine.GetAmmoData(mag.ClassName());
1588 ProjectileType p_type = data.m_ProjectileType;
1591 case ProjectileType.None:
1596 case ProjectileType.Tracer:
1602 case ProjectileType.AP:
1604 m_AmmoTypeIcon.LoadImageFile(0,
"set:dayz_gui image:armor_piercing");
1688 CargoContainer parentContainer = CargoContainer.Cast(
m_Parent);
1690 Widget rootWidget = GetRootWidget();
1691 float iconSize, spaceSize;
1692 if (parentContainer)
1694 iconSize = parentContainer.GetIconSize();
1695 spaceSize = parentContainer.GetSpaceSize();
1697 else if (parentHPrevContainer)
1702 rootWidget.SetFlags(
WidgetFlags.EXACTSIZE, refresh);
1708 #ifndef PLATFORM_CONSOLE
1709 rootWidget.SetPos(iconSize *
GetPosX() + (
GetPosX() + 1 ) * spaceSize, iconSize *
GetPosY() + (
GetPosY() + 1 ) * spaceSize, refresh);
1714 rootWidget.SetPos(iconSize * column, iconSize * row, refresh);
1715 rootWidget.SetSize(iconSize, iconSize, refresh);
1727 CargoContainer parentContainer = CargoContainer.Cast(
m_Parent);
1729 float iconSize, spaceSize;
1730 Widget rootWidget = GetRootWidget();
1731 if (parentContainer)
1733 iconSize = parentContainer.GetIconSize();
1734 spaceSize = parentContainer.GetSpaceSize();
1736 else if (parentHPrevContainer)
1747 #ifndef PLATFORM_CONSOLE
1750 GetRootWidget().SetSize(iconSize, iconSize);
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
void SetActionFromInventory(ItemBase mainItem, ItemBase targetItem)
void PerformActionFromInventory(ItemBase mainItem, ItemBase targetItem)
static bool IsAttachmentReachable(EntityAI e, string att_slot_name="", int slot_id=-1, float range=1.5)
represents base for cargo storage for entities
Super root of all classes in Enforce script.
script counterpart to engine's class Inventory
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
bool DraggingOverGrid(Widget w, int x, int y, Widget reciever, CargoContainer cargo)
void ShowActionMenuCombine(EntityAI entity1, EntityAI entity2, int combinationFlags, Widget w, bool color_test)
Widget m_MicromanagedPanel
void RevertToOriginalFlip()
void UpdateFrameColor(EntityAI selectedEntity, EntityAI targetEntity, int combinationFlag, Widget w, InventoryLocation il=null)
void DoubleClick(Widget w, int x, int y, int button)
void DraggingOverCombine(Widget w, int x, int y, Widget receiver)
bool m_PreviousFlipOrientation
override void SetParentWidget()
int GetRelevantInventoryAction(int relevantActions)
void ToRefresh(Icon icon, Icon icon2)
void DraggingOverSwap(Widget w, int x, int y, Widget receiver)
bool MouseEnter(Widget w, int x, int y)
void OnDraggingOverBackground(Widget w, int x, int y, Widget reciever)
override void SetLayoutName()
void OnPerformRecipe(int id)
void SetPosEx(bool refresh=true)
void SetItemSizeEx(bool refresh=true)
void MouseClick(Widget w, int x, int y, int button)
Widget GetSelectedWidget()
void DraggingOver(Widget w, int x, int y, Widget receiver)
void UpdateFlip(bool flipped)
bool CombineItems(EntityAI entity1, EntityAI entity2)
TextWidget m_QuantityItem
override void SetActive(bool active)
void CheckHasQuantityEx(bool refresh=true)
void CheckHasTemperature()
void SetSize(int x, int y)
void RefreshPos(int row, int column)
void OnPerformCombination(int combinationFlags)
void SetPos(int x, int y)
const int NUMBER_OF_TIMERS
void DestroyWhiteBackground()
Widget GetMicromanagedPanel()
void Icon(LayoutHolder parent, bool hands_icon=false)
void SetItemPreviewEx(bool refresh=true)
void Swap(Widget w, int x, int y, Widget receiver)
void DropReceivedFromMain(Widget w, int x, int y, Widget receiver)
ProgressBarWidget m_QuantityProgress
bool MouseLeave(Widget w, Widget s, int x, int y)
TextWidget m_ItemSizeWidget
ref array< ImageWidget > m_AmmoIcons
void CreateWhiteBackground()
ItemPreviewWidget m_ItemPreview
void InitLock(EntityAI parent, EntityAI obj, int x_pos, int y_pos, bool flip)
override void UpdateInterval()
bool FlagAction(EntityAI entity1, EntityAI entity2, int combinationFlags)
void Combine(Widget w, int x, int y, Widget receiver)
void InitEx(EntityAI obj, bool refresh=true)
bool PerformCombination(EntityAI selectedEntity, EntityAI targetEntity, int combinationFlag, InventoryLocation ilSwapDst=null)
ImageWidget m_AmmoTypeIcon
void DropReceivedFromBackground(Widget w, int x, int y, Widget reciever)
void CheckIsMagazineEx(bool refresh=true)
static int GetCombinationFlags(EntityAI entity1, EntityAI entity2)
void SetSelectedItemEx(EntityAI selected_item, Container selected_container, LayoutHolder selected_icon)
Widget GetCenterDropzone()
void ShowSourceDropzone(EntityAI item)
void SetIconTemperature(EntityAI item, Widget item_w)
void SetDraggedItem(EntityAI dragged_item)
Widget GetRightDropzone()
void SetWidgetDraggable(Widget w, bool draggable)
void SetDraggedIcon(Icon dragged_icon)
void SetIsDragging(bool is_dragging)
static int GetChosenCombinationFlag(EntityAI selectedEntity, EntityAI targetEntity, int relevantFlags, out InventoryLocation dst=null)
static ItemManager GetInstance()
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
const int QUANTITY_PROGRESS
const int QUANTITY_HIDDEN
proto void GetMousePos(out int x, out int y)
FindInventoryLocationType
flags for searching locations in inventory
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
int ARGB(int a, int r, int g, int b)
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.