57 m_QuantityStack = GetMainWidget().FindAnyWidget(
"QuantityStackPanel" );
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");
181 if (!targetEntity.GetInventory().CanRemoveEntity())
186 if (controlledPlayer.GetHumanInventory().CanRemoveEntityInHands())
187 controlledPlayer.PredictiveMoveItemFromHandsToInventory();
194 EntityAI entityInHands = controlledPlayer.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))
228 if (targetEntity.GetInventory().CanRemoveEntity())
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");
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;
469 if (m_am_entity1 == player.GetEntityInHands())
483 if (m_am_entity1 == player.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);
523 switch (combinationFlag)
526 return player.PredictiveTakeEntityToTargetAttachment(targetEntity, selectedEntity);
531 targetEntity.CombineItemsClient(selectedEntity);
535 if (targetEntity == player.GetEntityInHands())
546 if (targetEntity == player.GetEntityInHands())
556 return player.GetWeaponManager().SwapMagazine(Magazine.Cast(selectedEntity));
558 return player.PredictiveSwapEntities(targetEntity, selectedEntity);
560 return player.PredictiveForceSwapEntities(selectedEntity, targetEntity, ilSwapDst);
574 switch (combinationFlag)
619 ContextMenu cmenu = ContextMenu.Cast(
g_Game.GetUIManager().GetMenu().GetContextMenu());
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;
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");
740 ContextMenu cmenu = ContextMenu.Cast(
g_Game.GetUIManager().GetMenu().GetContextMenu());
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(
g_Game.GetMission() );
832 g_Game.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);
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.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 g_Game.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();
1152 if (parent && parent.GetHierarchyRootPlayer() ==
g_Game.GetPlayer())
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;
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(
g_Game.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.
static ColorManager GetInstance()
void SetColor(Widget w, int color)
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
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 DraggingOver(Widget w, int x, int y, Widget receiver)
ItemPreviewWidget m_ItemPreview
void UpdateFrameColor(EntityAI selectedEntity, EntityAI targetEntity, int combinationFlag, Widget w, InventoryLocation il=null)
TextWidget m_ItemSizeWidget
ImageWidget m_AmmoTypeIcon
Widget GetSelectedWidget()
ProgressBarWidget m_QuantityProgress
void DropReceivedFromBackground(Widget w, int x, int y, Widget reciever)
void SetItemPreviewEx(bool refresh=true)
void Combine(Widget w, int x, int y, Widget receiver)
void RefreshPos(int row, int column)
override void UpdateInterval()
bool MouseLeave(Widget w, Widget s, int x, int y)
bool MouseEnter(Widget w, int x, int y)
void SetItemSizeEx(bool refresh=true)
void OnPerformRecipe(int id)
TextWidget m_QuantityItem
bool PerformCombination(EntityAI selectedEntity, EntityAI targetEntity, int combinationFlag, InventoryLocation ilSwapDst=null)
void CheckHasTemperature()
void SetSize(int x, int y)
override void SetActive(bool active)
void CheckHasQuantityEx(bool refresh=true)
ref array< ImageWidget > m_AmmoIcons
Widget m_MicromanagedPanel
void MouseClick(Widget w, int x, int y, int button)
const int NUMBER_OF_TIMERS
void DoubleClick(Widget w, int x, int y, int button)
void ToRefresh(Icon icon, Icon icon2)
void RevertToOriginalFlip()
void ShowActionMenuCombine(EntityAI entity1, EntityAI entity2, int combinationFlags, Widget w, bool color_test)
bool FlagAction(EntityAI entity1, EntityAI entity2, int combinationFlags)
void Swap(Widget w, int x, int y, Widget receiver)
override void SetParentWidget()
void OnDraggingOverBackground(Widget w, int x, int y, Widget reciever)
void DraggingOverCombine(Widget w, int x, int y, Widget receiver)
void CreateWhiteBackground()
void InitEx(EntityAI obj, bool refresh=true)
void SetPosEx(bool refresh=true)
void InitLock(EntityAI parent, EntityAI obj, int x_pos, int y_pos, bool flip)
int GetRelevantInventoryAction(int relevantActions)
bool CombineItems(EntityAI entity1, EntityAI entity2)
void CheckIsMagazineEx(bool refresh=true)
void DraggingOverSwap(Widget w, int x, int y, Widget receiver)
void OnPerformCombination(int combinationFlags)
void UpdateFlip(bool flipped)
bool m_PreviousFlipOrientation
override void SetLayoutName()
void Icon(LayoutHolder parent, bool hands_icon=false)
void SetPos(int x, int y)
Widget GetMicromanagedPanel()
void DropReceivedFromMain(Widget w, int x, int y, Widget receiver)
void DestroyWhiteBackground()
static const int ATTACH_MAGAZINE
static const int ADD_AS_CARGO
static const int PERFORM_ACTION
static const int ADD_AS_ATTACHMENT
static const int COMBINE_QUANTITY2
static const int SET_ACTION
static const int SWAP_MAGAZINE
proto native int GetSlot()
returns slot id if current type is Attachment
proto native EntityAI GetParent()
returns parent of current inventory location
proto native bool IsValid()
verify current set inventory location
proto native int GetType()
returns type of InventoryLocation
proto native void SetCargoAuto(notnull CargoBase cargo, EntityAI e, int row, int col, bool flip)
Widget GetCenterDropzone()
void SetDraggedIcon(Icon dragged_icon)
void ShowSourceDropzone(EntityAI item)
static int GetCombinationFlags(EntityAI entity1, EntityAI entity2)
void SetWidgetDraggable(Widget w, bool draggable)
void SetDraggedItem(EntityAI dragged_item)
void SetSelectedItemEx(EntityAI selected_item, Container selected_container, LayoutHolder selected_icon)
static int GetChosenCombinationFlag(EntityAI selectedEntity, EntityAI targetEntity, int relevantFlags, out InventoryLocation dst=null)
void SetIconTemperature(EntityAI item, Widget item_w)
Widget GetRightDropzone()
void SetIsDragging(bool is_dragging)
static ItemManager GetInstance()
static float GetItemQuantityMax(InventoryItem item)
static string GetItemQuantityText(EntityAI item, bool showMax=false)
static int HasItemQuantity(notnull EntityAI item)
static float GetItemQuantity(InventoryItem item)
static void TakeOrSplitToInventory(notnull PlayerBase player, notnull EntityAI target, notnull EntityAI item)
static void TakeOrSplitToInventoryLocation(notnull PlayerBase player, notnull InventoryLocation dst)
override bool IsShowingChamberedBullet()
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
const int QUANTITY_PROGRESS
const int QUANTITY_HIDDEN
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto float Round(float f)
Returns mathematical round of value.
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.