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();
149 menu.RefreshQuickbar();
158 if (controlledPlayer.GetInventory().HasInventoryReservation(
m_Obj, null) || controlledPlayer.GetInventory().IsInventoryLocked() || controlledPlayer.IsItemsToDelete())
164 string name = w.GetName();
165 name.Replace(
"PanelWidget",
"Render");
175 if (!targetEntity.GetInventory().CanRemoveEntity())
180 if (controlledPlayer.GetHumanInventory().CanRemoveEntityInHands())
181 controlledPlayer.PredictiveMoveItemFromHandsToInventory();
188 EntityAI entityInHands = controlledPlayer.GetEntityInHands();
189 EntityAI entityRootParent = targetEntity.GetHierarchyRoot();
191 if (controlledPlayer.GetInventory().HasEntityInInventory(targetEntity) && controlledPlayer.GetHumanInventory().CanAddEntityInHands(targetEntity))
193 controlledPlayer.PredictiveTakeEntityToHands(targetEntity);
195 else if (entityInHands && entityRootParent == controlledPlayer)
199 entityInHands.GetInventory().GetCurrentInventoryLocation(handsItemLocation);
200 int index = controlledPlayer.GetHumanInventory().FindUserReservedLocationIndex(entityInHands);
202 controlledPlayer.GetHumanInventory().GetUserReservedLocation(index, targetItemLocation);
204 if (controlledPlayer.GetInventory().CanForceSwapEntitiesEx(targetEntity, targetItemLocation, entityInHands, handsItemLocation))
206 controlledPlayer.PredictiveForceSwapEntities(targetEntity, entityInHands, targetItemLocation);
208 else if (controlledPlayer.GetInventory().CanSwapEntitiesEx(targetEntity, entityInHands ))
210 controlledPlayer.PredictiveSwapEntities(targetEntity, entityInHands);
215 if (targetItemLocation.
IsValid() && controlledPlayer.GetInventory().LocationCanAddEntity(targetItemLocation))
222 if (targetEntity.GetInventory().CanRemoveEntity())
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 if (selectedEntity.GetHierarchyRootPlayer() == player)
291 int index = player.GetHumanInventory().FindUserReservedLocationIndex(
m_Item);
294 player.GetHumanInventory().GetUserReservedLocation(index, il);
308 UpdateFrameColor(selectedEntity, targetEntity, chosenInventoryAction, w, il);
321 string name = w.GetName();
322 name.Replace(
"PanelWidget",
"Render");
348 PrepareOwnedTooltip(
m_Obj,
x,
y);
373 string name = w.GetName();
374 name.Replace(
"PanelWidget",
"Render");
379 targetIpw =
ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget(
"Render" ));
383 if (selectedIpw == null)
387 if (selectedIpw == null)
396 if (!targetEntity || !selectedEntity)
403 if (targetEntity == selectedEntity)
410 CargoContainer parentContainer = CargoContainer.Cast(
m_Parent);
415 parentContainer.GetRootWidget().GetScreenPos(parentX, parentY);
417 float iconSize = parentContainer.GetIconSize();
418 float spaceSize = parentContainer.GetSpaceSize();
420 int PosX = (
x - parentX) / (iconSize + spaceSize);
421 int PosY = (
y - parentY) / (iconSize + spaceSize);
424 CargoBase targetCargo = parent.GetInventory().GetCargo();
427 ilDst.
SetCargoAuto(targetCargo, selectedEntity, PosY, PosX, selectedEntity.GetInventory().GetFlipCargo());
429 if (parent.GetInventory().LocationCanAddEntity(ilDst))
446 UpdateFrameColor(selectedEntity, targetEntity, chosenInventoryAction, w, ilDst);
453 if (m_am_entity1 == null || m_am_entity2 == null)
return;
465 if (m_am_entity1 == player.GetEntityInHands())
479 if (m_am_entity1 == player.GetEntityInHands())
491 entity.CombineItemsClient(
ItemBase.Cast( m_am_entity2 ));
495 float stackable = m_am_entity2.GetTargetQuantityMax(-1);
497 if (stackable == 0 || stackable >= m_am_entity2.GetQuantity())
499 player.PredictiveTakeEntityToTargetAttachment(m_am_entity1, m_am_entity2);
505 ItemBase.Cast(m_am_entity2).SplitIntoStackMaxToInventoryLocationClient(il);
519 switch (combinationFlag)
522 return player.PredictiveTakeEntityToTargetAttachment(targetEntity, selectedEntity);
527 targetEntity.CombineItemsClient(selectedEntity);
531 if (targetEntity == player.GetEntityInHands())
542 if (targetEntity == player.GetEntityInHands())
552 return player.GetWeaponManager().SwapMagazine(Magazine.Cast(selectedEntity));
554 return player.PredictiveSwapEntities(targetEntity, selectedEntity);
556 return player.PredictiveForceSwapEntities(selectedEntity, targetEntity, ilSwapDst);
570 switch (combinationFlag)
615 ContextMenu cmenu = ContextMenu.Cast(
g_Game.GetUIManager().GetMenu().GetContextMenu());
616 m_am_entity1 = entity1;
617 m_am_entity2 = entity2;
622 if ( entity1 == null || entity2 == null )
return;
637 cmenu.Add(
"#inv_context_add_as_cargo",
this,
"OnPerformCombination",
new Param1<int>( lastFlag ) );
642 cmenu.Add(
"#inv_context_add_as_attachment",
this,
"OnPerformCombination",
new Param1<int>( lastFlag ));
648 cmenu.Add(
"#inv_context_combine_quantity",
this,
"OnPerformCombination",
new Param1<int>( lastFlag ));
654 cmenu.Add(
"#inv_context_attach_magazine",
this,
"OnPerformCombination",
new Param1<int>( lastFlag ));
660 cmenu.Add(
"Perform action",
this,
"OnPerformCombination",
new Param1<int>( lastFlag ));
684 else if (cmenu.Count() >= 1)
693 if ( m_am_entity1 == null || m_am_entity2 == null )
return;
697 player.GetCraftingManager().SetInventoryCraft(
id,
ItemBase.Cast(m_am_entity1),
ItemBase.Cast(m_am_entity2));
707 string name = w.GetName();
708 name.Replace(
"PanelWidget",
"Render");
736 ContextMenu cmenu = ContextMenu.Cast(
g_Game.GetUIManager().GetMenu().GetContextMenu());
737 m_am_entity1 = entity1;
738 m_am_entity2 = entity2;
746 entity.CombineItemsClient(
ItemBase.Cast( entity2 ) );
756 cmenu.Add(
"#inv_context_add_as_attachment",
this,
"OnPerformCombination",
new Param1<int>( current_flag ) );
766 cmenu.Add(
"#inv_context_attach_magazine",
this,
"OnPerformCombination",
new Param1<int>( current_flag ) );
772 cmenu.Add(
"#inv_context_add_as_cargo",
this,
"OnPerformCombination",
new Param1<int>( current_flag ) );
778 cmenu.Add(
"#inv_context_swap",
this,
"OnPerformCombination",
new Param1<int>( current_flag ) );
784 cmenu.Add(
"#inv_context_combine",
this,
"OnPerformCombination",
new Param1<int>( current_flag ) );
790 cmenu.Add(
"#inv_context_attach_magazine",
this,
"OnPerformCombination",
new Param1<int>( current_flag ) );
796 cmenu.Add(
"Perform Action2",
this,
"OnPerformCombination",
new Param1<int>( current_flag ) );
799 int m_am_Pos_x, m_am_Pos_y;
804 MissionGameplay
mission = MissionGameplay.Cast(
g_Game.GetMission() );
828 g_Game.GetPlayer().GetHumanInventory().ClearUserReservedLocationSynced(
m_Item);
832 #ifdef DIAG_DEVELOPER
856 if (
g_Game.IsLeftCtrlDown())
858 if (controlledPlayer.CanDropEntity(
m_Item))
860 if (
m_Item.GetTargetQuantityMax() <
m_Item.GetQuantity())
861 m_Item.SplitIntoStackMaxClient(null, -1);
863 controlledPlayer.PhysicalPredictiveDropItem(
m_Item);
871 m_Obj.GetInventory().GetCurrentInventoryLocation(il);
873 bool draggable = !controlledPlayer.GetInventory().HasInventoryReservation(
m_Obj, null) && !controlledPlayer.GetInventory().IsInventoryLocked() && !controlledPlayer.IsItemsToDelete();
887 string name = w.GetName();
888 name.Replace(
"PanelWidget",
"Render");
894 targetIpw =
ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget(
"Render" ));
898 if (selectedIpw == null)
902 if (selectedIpw == null)
916 if (
m_Lock && targetEntity == selectedEntity)
918 index = player.GetHumanInventory().FindUserReservedLocationIndex(
m_Item);
922 m_Item.GetInventory().GetCurrentInventoryLocation(ilSrc);
923 player.GetHumanInventory().GetUserReservedLocation(index, ilDst);
925 if (ilDst.
GetParent().GetInventory().LocationCanAddEntity(ilDst))
928 player.GetHumanInventory().ClearUserReservedLocation(
m_Item);
929 player.PredictiveTakeToDst(ilSrc, ilDst);
935 CargoContainer parentCargo = CargoContainer.Cast(
m_Parent);
940 parentCargo.GetRootWidget().GetScreenPos(parentX, parentY);
942 float iconSize = parentCargo.GetIconSize();
943 float spaceSize = parentCargo.GetSpaceSize();
945 int PosX = (
x-parentX) / (iconSize + spaceSize);
946 int PosY = (
y-parentY) / (iconSize + spaceSize);
949 CargoBase targetCargo = parent.GetInventory().GetCargo();
952 ilDst.
SetCargoAuto(targetCargo, selectedEntity, PosY, PosX, selectedEntity.GetInventory().GetFlipCargo());
954 if (parent.GetInventory().LocationCanAddEntity(ilDst))
956 player.GetHumanInventory().ClearUserReservedLocation(
m_Item);
976 string name = w.GetName();
977 name.Replace(
"PanelWidget",
"Render");
982 targetIpw =
ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget(
"Render" ));
986 if (selectedIpw == null)
990 if (selectedIpw == null)
997 if (!selectedEntity || !targetEntity)
1003 EntityAI itemInHands = player.GetEntityInHands();
1007 targetEntity.GetInventory().GetCurrentInventoryLocation(ilSrc);
1010 if (selectedEntity.GetHierarchyRootPlayer() == player)
1012 int index = player.GetHumanInventory().FindUserReservedLocationIndex(targetEntity);
1015 player.GetHumanInventory().GetUserReservedLocation(index, ilDst);
1019 if (
m_HandsIcon && !player.GetInventory().HasInventoryReservation(itemInHands, null) && !player.IsItemsToDelete())
1021 g_Game.GetPlayer().PredictiveForceSwapEntities(selectedEntity, targetEntity, ilDst);
1041 #ifdef PLATFORM_CONSOLE
1085 GetMainWidget().SetSort(
x );
1113 menu.RefreshQuickbar();
1125 if (
m_Item.GetInventory().GetFlipCargo())
1150 EntityAI parent = entity.GetHierarchyParent();
1151 if (parent && parent.GetHierarchyRootPlayer() ==
g_Game.GetPlayer())
1160 if (w == null || reciever == null)
1165 reciever.GetUserData(pa);
1168 ContainerWithCargo item = ContainerWithCargo.Cast(
m_Parent.m_Parent);
1171 item.DraggingOverGrid(w,
m_PosY + pa.y,
m_PosX + pa.x, reciever);
1186 reciever.GetUserData(pa);
1189 ContainerWithCargo item = ContainerWithCargo.Cast(
m_Parent.m_Parent);
1240 GetMainWidget().Update();
1250 GetRootWidget().SetSize(1, 1);
1276 ImageWidget ammoIcon;
1282 ammoIcon.Show(
false);
1287 for (i = 0; i < wpn.GetMuzzleCount(); i++)
1294 if (wpn.IsChamberFull(i))
1298 ammoIcon.Show(
true);
1299 ammoIcon.SetImage(2);
1301 else if (wpn.IsChamberFiredOut(i))
1303 ammoIcon.Show(
true);
1304 ammoIcon.SetImage(1);
1308 ammoIcon.Show(
true);
1309 ammoIcon.SetImage(0);
1314 ammoIcon.Show(
false);
1348 int max =
m_Item.GetQuantityMax();
1349 int count =
m_Item.ConfigGetInt(
"count");
1359 float value =
Math.
Round((quantity / max) * 100);
1372 GetMainWidget().SetSort(index);
1373 GetMainWidget().Update();
1378 return GetMainWidget().GetSort();
1396 #ifdef PLATFORM_CONSOLE
1402 int capacity = sizeX * sizeY;
1492 m_RootWidget.FindAnyWidget(
"Reserved").Show(
false, refresh);
1512 float width = 0.0, height = 0.0;
1513 for (
int i = 0; i < wpn.GetMuzzleCount(); i++)
1521 Widget ammoIcon =
Widget.Cast(
g_Game.GetWorkspace().CreateWidgets(
"gui/layouts/inventory_new/ammo_icon.layout", GetMainWidget()));
1522 ammoIcon.SetPos(posX, 0.0,
false);
1524 ImageWidget ammoIconImg = ImageWidget.Cast(ammoIcon.GetChildren());
1526 AmmoData data = Magazine.GetAmmoData(wpn.GetChamberAmmoTypeName(i));
1530 switch (cartridgeType)
1534 ammoIconImg.LoadImageFile(0,
"set:dayz_gui image:cartridge_pistol");
1535 ammoIconImg.LoadImageFile(1,
"set:dayz_gui image:shell_pistol");
1536 ammoIconImg.LoadImageFile(2,
"set:dayz_gui image:jam_pistol");
1541 ammoIconImg.LoadImageFile(0,
"set:dayz_gui image:cartridge_int");
1542 ammoIconImg.LoadImageFile(1,
"set:dayz_gui image:shell_int");
1543 ammoIconImg.LoadImageFile(2,
"set:dayz_gui image:jam_int");
1548 ammoIconImg.LoadImageFile(0,
"set:dayz_gui image:cartridge_fp");
1549 ammoIconImg.LoadImageFile(1,
"set:dayz_gui image:shell_fp");
1550 ammoIconImg.LoadImageFile(2,
"set:dayz_gui image:jam_fp");
1555 ammoIconImg.LoadImageFile(0,
"set:dayz_gui image:cartridge_shell");
1556 ammoIconImg.LoadImageFile(1,
"set:dayz_gui image:shell_shell");
1557 ammoIconImg.LoadImageFile(2,
"set:dayz_gui image:jam_shell");
1563 ammoIconImg.LoadImageFile(0,
"set:dayz_gui image:arrow_int");
1564 ammoIconImg.LoadImageFile(1,
"set:dayz_gui image:arrow_int");
1580 Magazine mag = Magazine.Cast(
m_Obj);
1584 AmmoData data = Magazine.GetAmmoData(mag.ClassName());
1587 ProjectileType p_type = data.m_ProjectileType;
1590 case ProjectileType.None:
1595 case ProjectileType.Tracer:
1601 case ProjectileType.AP:
1603 m_AmmoTypeIcon.LoadImageFile(0,
"set:dayz_gui image:armor_piercing");
1687 CargoContainer parentContainer = CargoContainer.Cast(
m_Parent);
1689 Widget rootWidget = GetRootWidget();
1690 float iconSize, spaceSize;
1691 if (parentContainer)
1693 iconSize = parentContainer.GetIconSize();
1694 spaceSize = parentContainer.GetSpaceSize();
1696 else if (parentHPrevContainer)
1701 rootWidget.SetFlags(
WidgetFlags.EXACTSIZE, refresh);
1707 #ifndef PLATFORM_CONSOLE
1708 rootWidget.SetPos(iconSize *
GetPosX() + (
GetPosX() + 1 ) * spaceSize, iconSize *
GetPosY() + (
GetPosY() + 1 ) * spaceSize, refresh);
1713 rootWidget.SetPos(iconSize * column, iconSize * row, refresh);
1714 rootWidget.SetSize(iconSize, iconSize, refresh);
1726 CargoContainer parentContainer = CargoContainer.Cast(
m_Parent);
1728 float iconSize, spaceSize;
1729 Widget rootWidget = GetRootWidget();
1730 if (parentContainer)
1732 iconSize = parentContainer.GetIconSize();
1733 spaceSize = parentContainer.GetSpaceSize();
1735 else if (parentHPrevContainer)
1746 #ifndef PLATFORM_CONSOLE
1749 GetRootWidget().SetSize(iconSize, iconSize);
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
FindInventoryLocationType
flags for searching locations in inventory
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
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.
void SetColor(Widget w, int color)
static ColorManager GetInstance()
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.
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
script counterpart to engine's class Inventory
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 const int PERFORM_ACTION
static const int ADD_AS_CARGO
static const int ATTACH_MAGAZINE
static const int SWAP_MAGAZINE
static const int SET_ACTION
static const int ADD_AS_ATTACHMENT
static const int COMBINE_QUANTITY2
proto native bool IsValid()
verify current set inventory location
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
proto native void SetCargoAuto(notnull CargoBase cargo, EntityAI e, int row, int col, bool flip)
based on Cargo.IsProxyCargo uses SetProxyCargo or SetCargo respectively
proto native int GetType()
returns type of InventoryLocation
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()
static float GetItemQuantity(InventoryItem item)
static int HasItemQuantity(notnull EntityAI item)
static float GetItemQuantityMax(InventoryItem item)
static string GetItemQuantityText(EntityAI item, bool showMax=false)
static void TakeOrSplitToInventoryLocation(notnull PlayerBase player, notnull InventoryLocation dst)
static void TakeOrSplitToInventory(notnull PlayerBase player, notnull EntityAI target, notnull EntityAI item)
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.
void Obsolete(string msg="")
static proto float Round(float f)
Returns mathematical round of value.
proto void GetMousePos(out int x, out int y)
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.