DayZ 1.24
Loading...
Searching...
No Matches
Icon Class Reference
Inheritance diagram for Icon:
[legend]
Collaboration diagram for Icon:
[legend]

Protected Member Functions

void Icon (LayoutHolder parent, bool hands_icon=false)
 
void ~Icon ()
 
Widget GetSelectedWidget ()
 
Widget GetCursorWidget ()
 
Widget GetMicromanagedPanel ()
 
bool IsDragged ()
 
override void SetActive (bool active)
 
override void SetParentWidget ()
 
int GetRelevantInventoryAction (int relevantActions)
 
void RefreshQuickbar ()
 
void DoubleClick (Widget w, int x, int y, int button)
 
void DraggingOverSwap (Widget w, int x, int y, Widget receiver)
 
void DraggingOverCombine (Widget w, int x, int y, Widget receiver)
 
bool MouseEnter (Widget w, int x, int y)
 
bool MouseLeave (Widget w, Widget s, int x, int y)
 
void DraggingOver (Widget w, int x, int y, Widget receiver)
 
void OnPerformCombination (int combinationFlags)
 
bool PerformCombination (EntityAI selectedEntity, EntityAI targetEntity, int combinationFlag, InventoryLocation ilSwapDst=null)
 
void UpdateFrameColor (EntityAI selectedEntity, EntityAI targetEntity, int combinationFlag, Widget w, InventoryLocation il=null)
 
void ShowActionMenuCombine (EntityAI entity1, EntityAI entity2, int combinationFlags, Widget w, bool color_test)
 
void OnPerformRecipe (int id)
 
void Combine (Widget w, int x, int y, Widget receiver)
 
bool CombineItems (EntityAI entity1, EntityAI entity2)
 
bool FlagAction (EntityAI entity1, EntityAI entity2, int combinationFlags)
 
void MouseClick (Widget w, int x, int y, int button)
 
void DropReceivedFromMain (Widget w, int x, int y, Widget receiver)
 
void Swap (Widget w, int x, int y, Widget receiver)
 
void ToRefresh (Icon icon, Icon icon2)
 
override void SetLayoutName ()
 
void SetSize (int x, int y)
 
void SetPos (int x, int y)
 
int GetCargoPos ()
 
void SetCargoPos (int x)
 
void DestroyWhiteBackground ()
 
void CreateWhiteBackground ()
 
void OnDraggingOverBackground (Widget w, int x, int y, Widget reciever)
 
void DropReceivedFromBackground (Widget w, int x, int y, Widget reciever)
 
void RevertToOriginalFlip ()
 
override void Refresh ()
 
void SetTemperature ()
 
void RefreshIconPos ()
 
void FullScreen ()
 
void RefreshPos (int row, int column)
 
Object GetObject ()
 
void RefreshMuzzleIcon ()
 
void SetQuantity ()
 
void SetSort (int index)
 
int GetSort ()
 
void SetItemPreviewEx (bool refresh=true)
 
void SetItemPreview ()
 
void SetItemSizeEx (bool refresh=true)
 
void SetItemSize ()
 
void UpdateFlip (bool flipped)
 
void InitLock (EntityAI parent, EntityAI obj, int x_pos, int y_pos, bool flip)
 
void InitEx (EntityAI obj, bool refresh=true)
 
void Init (EntityAI obj)
 
void CheckIsWeapon ()
 
void CheckIsMagazineEx (bool refresh=true)
 
void CheckIsMagazine ()
 
void CheckHasTemperature ()
 
void CheckHasQuantityEx (bool refresh=true)
 
void CheckHasQuantity ()
 
void SetPosX (int x)
 
void SetPosY (int y)
 
void SetSizeX (int x)
 
void SetSizeY (int y)
 
int GetPosX ()
 
int GetPosY ()
 
int GetSizeX ()
 
int GetSizeY ()
 
void SetPosEx (bool refresh=true)
 
void SetPos ()
 
void SetSize ()
 
override void UpdateInterval ()
 

Protected Attributes

int m_SizeX
 
int m_SizeY
 
int m_PosX
 
int m_PosY
 
EntityAI m_Lock
 
bool m_IsWeapon = false
 
bool m_IsMagazine = false
 
bool m_HasTemperature = false
 
bool m_HasQuantity = false
 
float m_CurrQuantity = -1
 
EntityAI m_Obj
 
ItemBase m_Item
 
bool m_HandsIcon
 
int m_CargoPos
 
bool m_IsDragged
 
bool m_PreviousFlipOrientation
 
const int NUMBER_OF_TIMERS = 2
 
ItemPreviewWidget m_ItemPreview
 
Widget m_ColorWidget
 
Widget m_SelectedPanel
 
Widget m_MicromanagedPanel
 
Widget m_CursorWidget
 
Widget m_QuantityPanel
 
TextWidget m_QuantityItem
 
ProgressBarWidget m_QuantityProgress
 
Widget m_QuantityStack
 
Widget m_ItemSizePanel
 
TextWidget m_ItemSizeWidget
 
ref array< ImageWidgetm_AmmoIcons
 
ImageWidget m_AmmoTypeIcon
 

Additional Inherited Members

- Private Member Functions inherited from LayoutHolder
void OnDropReceivedFromHeader (Widget w, int x, int y, Widget receiver)
 
void DraggingOver (Widget w, int x, int y, Widget receiver)
 
void DraggingOverHeader (Widget w, int x, int y, Widget receiver)
 
void UpdateSpacer ()
 
Header GetHeader ()
 
void SetHeader (Header header)
 
void CheckHeaderDragability ()
 
void Container (LayoutHolder parent)
 
Container GetFocusedContainer ()
 
Container GetContainer (int index)
 
void SetFocusedContainer (Container cont)
 
SlotsIcon GetFocusedSlotsIcon ()
 
int GetActiveIndex ()
 
void SetActiveIndex (int index)
 
ScrollWidget GetScrollWidget ()
 
void UpdateRadialIcon ()
 
void SetSlotIcon (SlotsIcon icon)
 
void SetDefaultFocus (bool while_micromanagment_mode=false)
 
void SetLastFocus ()
 
void Unfocus ()
 
void MoveGridCursor (int direction)
 
void ScrollToActiveContainer ()
 
void CheckScrollbarVisibility ()
 
void Open ()
 
void Close ()
 
bool IsOpened ()
 
void SetOpenForSlotIcon (bool open, SlotsIcon icon=null)
 
void Toggle ()
 
float GetFocusedContainerHeight (bool contents=false)
 
float GetFocusedContainerYPos (bool contents=false)
 
float GetFocusedContainerYScreenPos (bool contents=false)
 
int Count ()
 
bool SelectItem ()
 
bool Select ()
 
bool OnSelectButton ()
 
bool Combine ()
 
bool TransferItemToVicinity ()
 
bool TransferItem ()
 
bool InspectItem ()
 
bool SplitItem ()
 
bool EquipItem ()
 
bool CanOpenCloseContainer ()
 
bool CanOpenCloseContainerEx (EntityAI focusedEntity)
 
bool CanSplit ()
 
bool CanSplitEx (EntityAI focusedEntity)
 
bool CanDrop ()
 
bool CanDropEx (EntityAI focusedEntity)
 
bool CanSwapOrTakeToHands ()
 
bool CanSwapOrTakeToHandsEx (EntityAI focusedEntity)
 
bool CanEquip ()
 
bool CanEquipEx (EntityAI focusedEntity)
 
bool CanTakeToInventory ()
 
bool CanTakeToInventoryEx (EntityAI focusedEntity)
 
bool CanCombine ()
 
bool CanCombineEx (EntityAI focusedEntity)
 
bool CanCombineAmmo ()
 
bool CanAddToQuickbarEx (EntityAI focusedEntity)
 
bool AddItemToQuickbarRadial (EntityAI itemToAssign)
 
bool IsEmpty ()
 
bool IsItemActive ()
 
bool IsItemWithQuantityActive ()
 
EntityAI GetFocusedItem ()
 
EntityAI GetFocusedContainerEntity ()
 
int GetColumnCount ()
 
void SetColumnCount (int count)
 
int GetFocusedColumn ()
 
void SetFocusedColumn (int column)
 
override void UpdateInterval ()
 
override void SetLastActive ()
 
override void SetFirstActive ()
 
override void SetActive (bool active)
 
void UnfocusAll ()
 
void UnfocusGrid ()
 
bool IsLastIndex ()
 
bool IsFirstIndex ()
 
bool IsFirstContainerFocused ()
 
bool IsLastContainerFocused ()
 
void ResetFocusedContainer ()
 
void SetNextActive ()
 
void SetPreviousActive (bool force=false)
 
void SetNextRightActive ()
 
void SetNextLeftActive ()
 
void SetSameLevelNextActive ()
 
void SetSameLevelPreviousActive ()
 
void RecomputeOpenedContainers ()
 
override void SetLayoutName ()
 
void Insert (LayoutHolder container, int pos=-1, bool immedUpdate=true)
 
void Remove (LayoutHolder container)
 
LayoutHolder Get (int x)
 
override void Refresh ()
 
void UpdateBodySpacers ()
 
void HideContent (bool force_hide=false)
 
void ShowContent (bool force_show=false)
 
void SetForceShow (bool value)
 
override void UpdateSelectionIcons ()
 
void ExpandCollapseContainer ()
 
- Private Attributes inherited from LayoutHolder
ref array< ref LayoutHolderm_Body
 
ref array< LayoutHolderm_OpenedContainers
 
int m_ActiveIndex = 0
 
bool m_LastIndex
 
bool m_Closed
 
Container m_FocusedContainer
 
float m_PrevAlpha
 
const int ITEMS_IN_ROW = 8
 
int m_ColumnCount
 
int m_FocusedColumn = 0
 
bool m_ForcedHide
 
bool m_ForcedShow
 
SlotsIcon m_SlotIcon
 
EntityAI m_Entity
 
const int SORT_ATTACHMENTS_OWN = 1
 
const int SORT_CARGO_OWN = 2
 
const int SORT_ATTACHMENTS_NEXT_OFFSET = 2
 
const int SORT_CARGO_NEXT_OFFSET = 3
 

Detailed Description

Definition at line 1 of file Icon.c.

Constructor & Destructor Documentation

◆ Icon()

void Icon::Icon ( LayoutHolder parent,
bool hands_icon = false )
inlineprotected

Definition at line 42 of file Icon.c.

43 {
45 ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
46
47 m_ItemPreview = ItemPreviewWidget.Cast(GetMainWidget().FindAnyWidget("Render"));
48
49 m_ColorWidget = GetMainWidget().FindAnyWidget("Color");
50 m_SelectedPanel = GetMainWidget().FindAnyWidget("Selected");
51 m_MicromanagedPanel = GetMainWidget().FindAnyWidget("Micromanaged");
52 m_CursorWidget = GetMainWidget().FindAnyWidget("Cursor");
53
54 m_QuantityPanel = GetMainWidget().FindAnyWidget("QuantityPanel");
55 m_QuantityItem = TextWidget.Cast(GetMainWidget().FindAnyWidget("Quantity"));
56 m_QuantityProgress = ProgressBarWidget.Cast(GetMainWidget().FindAnyWidget("QuantityBar"));
57 m_QuantityStack = GetMainWidget().FindAnyWidget("QuantityStackPanel");
58
59 m_ItemSizePanel = GetMainWidget().FindAnyWidget("ItemSizePanel");
60 m_ItemSizeWidget = TextWidget.Cast(GetMainWidget().FindAnyWidget("ItemSize"));
61
62 m_AmmoTypeIcon = ImageWidget.Cast(GetMainWidget().FindAnyWidget("AmmoTypeIcon"));
63 SetActive(false);
64 }
void SetActive()
Definition TrapBase.c:409
Widget m_MicromanagedPanel
Definition Icon.c:28
Widget m_QuantityPanel
Definition Icon.c:31
Widget m_ColorWidget
Definition Icon.c:26
Widget m_SelectedPanel
Definition Icon.c:27
Widget m_ItemSizePanel
Definition Icon.c:36
Widget m_QuantityStack
Definition Icon.c:34
TextWidget m_QuantityItem
Definition Icon.c:32
bool m_HandsIcon
Definition Icon.c:17
Widget m_CursorWidget
Definition Icon.c:29
ProgressBarWidget m_QuantityProgress
Definition Icon.c:33
TextWidget m_ItemSizeWidget
Definition Icon.c:37
ItemPreviewWidget m_ItemPreview
Definition Icon.c:24
ImageWidget m_AmmoTypeIcon
Definition Icon.c:40
static ItemManager GetInstance()
proto native Widget FindAnyWidget(string pathname)

References FindAnyWidget(), ItemManager::GetInstance(), m_AmmoTypeIcon, m_ColorWidget, m_CursorWidget, m_HandsIcon, m_ItemPreview, m_ItemSizePanel, m_ItemSizeWidget, m_MicromanagedPanel, m_QuantityItem, m_QuantityPanel, m_QuantityProgress, m_QuantityStack, m_SelectedPanel, and SetActive().

◆ ~Icon()

void Icon::~Icon ( )
inlineprotected

Definition at line 66 of file Icon.c.

67 {
68 if (m_Obj)
69 {
70 m_Obj.GetOnItemFlipped().Remove(UpdateFlip);
71 m_Obj.GetOnViewIndexChanged().Remove(SetItemPreview);
72 }
73
74 if (m_IsDragged)
75 {
77 ItemManager.GetInstance().HideDropzones();
78 ItemManager.GetInstance().SetIsDragging(false);
79 m_IsDragged = false;
80 }
81 }
void RevertToOriginalFlip()
Definition Icon.c:1101
void UpdateFlip(bool flipped)
Definition Icon.c:1364
EntityAI m_Obj
Definition Icon.c:15
void SetItemPreview()
Definition Icon.c:1341
bool m_IsDragged
Definition Icon.c:19

References ItemManager::GetInstance(), m_IsDragged, m_Obj, RevertToOriginalFlip(), SetItemPreview(), and UpdateFlip().

Member Function Documentation

◆ CheckHasQuantity()

void Icon::CheckHasQuantity ( )
inlineprotected

Definition at line 1576 of file Icon.c.

1577 {
1579 }
void CheckHasQuantityEx(bool refresh=true)
Definition Icon.c:1565

References CheckHasQuantityEx().

◆ CheckHasQuantityEx()

void Icon::CheckHasQuantityEx ( bool refresh = true)
inlineprotected

Definition at line 1565 of file Icon.c.

1566 {
1567 if (m_Item)
1568 {
1570
1571 if (m_HasQuantity)
1572 m_QuantityPanel.Show(true, refresh);
1573 }
1574 }
ItemBase m_Item
Definition Icon.c:16
bool m_HasQuantity
Definition Icon.c:12
static int HasItemQuantity(notnull EntityAI item)
const int QUANTITY_HIDDEN
Definition constants.c:482

References QuantityConversions::HasItemQuantity(), m_HasQuantity, m_Item, m_QuantityPanel, and QUANTITY_HIDDEN.

Referenced by CheckHasQuantity(), and InitEx().

◆ CheckHasTemperature()

void Icon::CheckHasTemperature ( )
inlineprotected

Definition at line 1559 of file Icon.c.

1560 {
1561 if (m_Item)
1562 m_HasTemperature = (m_Item.GetTemperatureMax() != 0 && m_Item.GetTemperatureMin() != 0);
1563 }
bool m_HasTemperature
Definition Icon.c:11

References m_HasTemperature, and m_Item.

Referenced by InitEx().

◆ CheckIsMagazine()

void Icon::CheckIsMagazine ( )
inlineprotected

Definition at line 1554 of file Icon.c.

1555 {
1557 }
void CheckIsMagazineEx(bool refresh=true)
Definition Icon.c:1518

References CheckIsMagazineEx().

◆ CheckIsMagazineEx()

void Icon::CheckIsMagazineEx ( bool refresh = true)
inlineprotected

Definition at line 1518 of file Icon.c.

1519 {
1520 Magazine mag = Magazine.Cast(m_Obj);
1521 if (mag)
1522 {
1523 m_IsMagazine = true;
1524 AmmoData data = Magazine.GetAmmoData(mag.ClassName());
1525 if (data)
1526 {
1527 ProjectileType p_type = data.m_ProjectileType;
1528 switch (p_type)
1529 {
1530 case ProjectileType.None:
1531 {
1532 m_AmmoTypeIcon.Show(false, refresh);
1533 break;
1534 }
1535 case ProjectileType.Tracer:
1536 {
1537 m_AmmoTypeIcon.LoadImageFile(0, "set:dayz_gui image:tracer");
1538 m_AmmoTypeIcon.Show(true, refresh);
1539 break;
1540 }
1541 case ProjectileType.AP:
1542 {
1543 m_AmmoTypeIcon.LoadImageFile(0, "set:dayz_gui image:armor_piercing");
1544 m_AmmoTypeIcon.Show(true, refresh);
1545 break;
1546 }
1547 }
1548 }
1549 }
1550 else
1551 m_IsMagazine = false;
1552 }
bool m_IsMagazine
Definition Icon.c:10

References m_AmmoTypeIcon, m_IsMagazine, and m_Obj.

Referenced by CheckIsMagazine(), and InitEx().

◆ CheckIsWeapon()

void Icon::CheckIsWeapon ( )
inlineprotected

Definition at line 1455 of file Icon.c.

1456 {
1458 if (wpn)
1459 {
1461 m_IsWeapon = true;
1462 float posX = 0.0;
1463 float widht = 0.0, height = 0.0;
1464 for (int i = 0; i < wpn.GetMuzzleCount(); i++)
1465 {
1466 if (i == 1)
1467 m_AmmoIcons[0].GetSize(widht, height);
1468 posX += widht;
1469
1470 Widget ammoIcon = Widget.Cast(GetGame().GetWorkspace().CreateWidgets("gui/layouts/inventory_new/ammo_icon.layout", GetMainWidget()));
1471 ammoIcon.SetPos(posX, 0.0, false);
1472
1473 ImageWidget ammoIconImg = ImageWidget.Cast(ammoIcon.GetChildren());
1474
1475 AmmoData data = Magazine.GetAmmoData(wpn.GetChamberAmmoTypeName(i));
1476 if (data)
1477 {
1478 CartridgeType c_type = data.m_CartridgeType;
1479 switch (c_type)
1480 {
1481 case CartridgeType.Pistol:
1482 {
1483 ammoIconImg.LoadImageFile(0, "set:dayz_gui image:cartridge_pistol");
1484 ammoIconImg.LoadImageFile(1, "set:dayz_gui image:shell_pistol");
1485 ammoIconImg.LoadImageFile(2, "set:dayz_gui image:jam_pistol");
1486 break;
1487 }
1488 case CartridgeType.Intermediate:
1489 {
1490 ammoIconImg.LoadImageFile(0, "set:dayz_gui image:cartridge_int");
1491 ammoIconImg.LoadImageFile(1, "set:dayz_gui image:shell_int");
1492 ammoIconImg.LoadImageFile(2, "set:dayz_gui image:jam_int");
1493 break;
1494 }
1495 case CartridgeType.FullPower:
1496 {
1497 ammoIconImg.LoadImageFile(0, "set:dayz_gui image:cartridge_fp");
1498 ammoIconImg.LoadImageFile(1, "set:dayz_gui image:shell_fp");
1499 ammoIconImg.LoadImageFile(2, "set:dayz_gui image:jam_fp");
1500 break;
1501 }
1502 case CartridgeType.Shell:
1503 {
1504 ammoIconImg.LoadImageFile(0, "set:dayz_gui image:cartridge_shell");
1505 ammoIconImg.LoadImageFile(1, "set:dayz_gui image:shell_shell");
1506 ammoIconImg.LoadImageFile(2, "set:dayz_gui image:jam_shell");
1507 break;
1508 }
1509 }
1510 }
1511 m_AmmoIcons.Insert(ammoIconImg);
1512 }
1513 }
1514 else
1515 m_IsWeapon = false;
1516 }
CartridgeType
Definition Magazine.c:4
ref array< ImageWidget > m_AmmoIcons
Definition Icon.c:39
bool m_IsWeapon
Definition Icon.c:9
proto native CGame GetGame()

References GetGame(), m_AmmoIcons, m_IsWeapon, and m_Obj.

Referenced by InitEx().

◆ Combine()

void Icon::Combine ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 644 of file Icon.c.

645 {
646 ItemManager.GetInstance().HideDropzones();
647 ItemManager.GetInstance().SetIsDragging(false);
648 ItemPreviewWidget selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
649 if (!selectedIpw)
650 {
651 string name = w.GetName();
652 name.Replace("PanelWidget", "Render");
653 selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
654 }
655 if (!selectedIpw)
657 if (!selectedIpw.GetItem())
658 return;
660 EntityAI targetEntity = GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
662
665 }
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
bool PerformCombination(EntityAI selectedEntity, EntityAI targetEntity, int combinationFlag, InventoryLocation ilSwapDst=null)
Definition Icon.c:460
static int GetChosenCombinationFlag(EntityAI selectedEntity, EntityAI targetEntity, int relevantFlags, out InventoryLocation dst=null)

References InventoryCombinationFlags::ADD_AS_ATTACHMENT, InventoryCombinationFlags::ADD_AS_CARGO, InventoryCombinationFlags::COMBINE_QUANTITY2, ItemManager::GetChosenCombinationFlag(), GetGame(), ItemManager::GetInstance(), name, InventoryCombinationFlags::PERFORM_ACTION, PerformCombination(), and InventoryCombinationFlags::SET_ACTION.

◆ CombineItems()

bool Icon::CombineItems ( EntityAI entity1,
EntityAI entity2 )
inlineprotected

Definition at line 667 of file Icon.c.

668 {
670 return FlagAction(entity1, entity2, flags);
671 }
bool FlagAction(EntityAI entity1, EntityAI entity2, int combinationFlags)
Definition Icon.c:673
static int GetCombinationFlags(EntityAI entity1, EntityAI entity2)

References FlagAction(), and ItemManager::GetCombinationFlags().

◆ CreateWhiteBackground()

void Icon::CreateWhiteBackground ( )
inlineprotected

Definition at line 1033 of file Icon.c.

1034 {
1035 m_PreviousFlipOrientation = m_Item.GetInventory().GetFlipCargo();
1036 ItemManager.GetInstance().SetDraggedIcon(this);
1037 ItemManager.GetInstance().SetDraggedItem(m_Item);
1038 m_IsDragged = true;
1039 ItemManager.GetInstance().SetIsDragging(true);
1040 int ww, hh;
1041 GetGame().GetInventoryItemSize(m_Item, ww, hh);
1042 if (m_Item.GetInventory().GetFlipCargo())
1043 SetSize(hh, ww);
1044 else
1045 SetSize(ww, hh);
1046
1047 SetSize();
1048
1049 if (!m_HandsIcon)
1050 Refresh();
1051 else
1052 {
1055 m_ColorWidget.SetAlpha(0.1);
1056 }
1057
1058 m_CursorWidget.Show(true);
1059 }
static int BASE_COLOR
bool m_PreviousFlipOrientation
Definition Icon.c:20
void SetSize()
Definition Icon.c:1658
override void Refresh()
Definition Icon.c:1118
proto native void SetForceFlipEnable(bool enable)

References ColorManager::BASE_COLOR, GetGame(), ItemManager::GetInstance(), m_ColorWidget, m_CursorWidget, m_HandsIcon, m_IsDragged, m_Item, m_ItemPreview, m_PreviousFlipOrientation, Refresh(), ItemPreviewWidget::SetForceFlipEnable(), and SetSize().

◆ DestroyWhiteBackground()

void Icon::DestroyWhiteBackground ( )
inlineprotected

Definition at line 1008 of file Icon.c.

1009 {
1010 ItemManager.GetInstance().HideDropzones();
1011 ItemManager.GetInstance().SetIsDragging(false);
1012 m_IsDragged = false;
1013
1015
1016 if (m_HandsIcon)
1017 {
1020 Refresh();
1021 FullScreen();
1022 }
1023
1024 m_CursorWidget.SetColor(ARGBF(1, 1, 1, 1));
1025 m_CursorWidget.Show(false);
1026
1027 InventoryMenu menu = InventoryMenu.Cast(GetGame().GetUIManager().FindMenu(MENU_INVENTORY));
1028
1029 if (menu)
1030 menu.RefreshQuickbar();
1031 }
void InventoryMenu()
void FullScreen()
Definition Icon.c:1146
proto native void SetForceFlip(bool value)
const int MENU_INVENTORY
Definition constants.c:170
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
Definition proto.c:332

References ARGBF(), FullScreen(), GetGame(), ItemManager::GetInstance(), InventoryMenu(), m_CursorWidget, m_HandsIcon, m_IsDragged, m_ItemPreview, MENU_INVENTORY, Refresh(), RevertToOriginalFlip(), ItemPreviewWidget::SetForceFlip(), and ItemPreviewWidget::SetForceFlipEnable().

◆ DoubleClick()

void Icon::DoubleClick ( Widget w,
int x,
int y,
int button )
inlineprotected

Definition at line 149 of file Icon.c.

150 {
151 if (button == MouseState.LEFT && !g_Game.IsLeftCtrlDown())
152 {
154 if (controlledPlayer.GetInventory().HasInventoryReservation(m_Obj, null) || controlledPlayer.GetInventory().IsInventoryLocked() || controlledPlayer.IsItemsToDelete())
155 return;
156
157 ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
158 if (!targetIpw)
159 {
160 string name = w.GetName();
161 name.Replace("PanelWidget", "Render");
162 targetIpw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
163 }
164
165 if (!targetIpw)
167
168 EntityAI targetEntity = targetIpw.GetItem();
169 if (targetIpw)
170 {
171 if (!targetEntity.GetInventory().CanRemoveEntity())
172 return;
173
174 if (m_HandsIcon)
175 {
176 if (controlledPlayer.GetHumanInventory().CanRemoveEntityInHands())
177 controlledPlayer.PredictiveMoveItemFromHandsToInventory();
178
180
181 return;
182 }
183
184 EntityAI entityInHands = controlledPlayer.GetHumanInventory().GetEntityInHands();
185 EntityAI entityRootParent = targetEntity.GetHierarchyRoot();
186
187 if (controlledPlayer.GetInventory().HasEntityInInventory(targetEntity) && controlledPlayer.GetHumanInventory().CanAddEntityInHands(targetEntity))
188 controlledPlayer.PredictiveTakeEntityToHands(targetEntity);
190 {
192 int index = controlledPlayer.GetHumanInventory().FindUserReservedLocationIndex(entityInHands);
193 if (index >= 0)
194 controlledPlayer.GetHumanInventory().GetUserReservedLocation(index, inventoryLocation);
195
196 if (controlledPlayer.GetInventory().CanForceSwapEntitiesEx(targetEntity, null, entityInHands, inventoryLocation))
197 controlledPlayer.PredictiveForceSwapEntities(targetEntity, entityInHands, inventoryLocation);
198 else if (controlledPlayer.GetInventory().CanSwapEntitiesEx(targetEntity, entityInHands))
199 controlledPlayer.PredictiveSwapEntities(targetEntity, entityInHands);
200 else
201 {
202 controlledPlayer.GetInventory().FindFreeLocationFor(targetEntity, FindInventoryLocationType.ANY, inventoryLocation);
203 if (inventoryLocation.IsValid() && controlledPlayer.GetInventory().LocationCanAddEntity(inventoryLocation))
205 }
206 }
207 else
208 {
209 bool found = false;
210 if (targetEntity.GetInventory().CanRemoveEntity())
211 {
213 found = controlledPlayer.GetInventory().FindFreeLocationFor(targetEntity, FindInventoryLocationType.ANY, i2);
214 if (found)
215 {
216 if (i2.GetType() == FindInventoryLocationType.ATTACHMENT)
217 {
218 if (i2.GetParent() != controlledPlayer)
219 found = false;
220 }
221 }
222 }
223
224 if (found)
225 {
226 if (controlledPlayer.GetHumanInventory().CanAddEntityToInventory(targetEntity))
227 controlledPlayer.PredictiveTakeEntityToInventory(FindInventoryLocationType.ANY, targetEntity);
228 }
229 else
230 {
231 if (controlledPlayer.GetHumanInventory().CanAddEntityInHands(targetEntity))
232 controlledPlayer.PredictiveTakeEntityToHands(targetEntity);
233 }
234 }
235
237 }
238 }
239 }
DayZGame g_Game
Definition DayZGame.c:3528
FindInventoryLocationType
flags for searching locations in inventory
PlayerBase GetPlayer()
void RefreshQuickbar()
Definition Icon.c:141
InventoryLocation.
static void TakeOrSplitToInventoryLocation(notnull PlayerBase player, notnull InventoryLocation dst)
MouseState
Definition EnSystem.c:311

References g_Game, GetGame(), GetPlayer(), m_HandsIcon, m_Obj, name, RefreshQuickbar(), and SplitItemUtils::TakeOrSplitToInventoryLocation().

◆ DraggingOver()

void Icon::DraggingOver ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 333 of file Icon.c.

334 {
335 ItemManager.GetInstance().HideDropzones();
336
337 if (w == null)
338 return;
339 string name = w.GetName();
340 name.Replace("PanelWidget", "Render");
341
342 ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(receiver.FindAnyWidget("Render"));
343 if (m_HandsIcon)
344 targetIpw = ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget("Render"));
345
347 if (selectedIpw == null)
348 selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
349 if (selectedIpw == null)
350 return;
351
357 return;
358
359 if (m_Lock)
360 {
362 {
364 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
365 }
366 else
367 {
368 CargoContainer parentContainer = CargoContainer.Cast(m_Parent);
369
370 float parentX;
371 float parentY;
372
373 parentContainer.GetRootWidget().GetScreenPos(parentX, parentY);
374
375 float iconSize = parentContainer.GetIconSize();
376 float spaceSize = parentContainer.GetSpaceSize();
377
378 int PosX = (x - parentX) / (iconSize + spaceSize);
379 int PosY = (y - parentY) / (iconSize + spaceSize);
380
381 EntityAI parent = m_Lock;
382 CargoBase targetCargo = parent.GetInventory().GetCargo();
383
384 ilDst = new InventoryLocation();
385 ilDst.SetCargoAuto(targetCargo, selectedEntity, PosY, PosX, selectedEntity.GetInventory().GetFlipCargo());
386
387 if (parent.GetInventory().LocationCanAddEntity(ilDst))
388 {
390 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
391 }
392 else
393 {
395 ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
396 }
397 }
398 }
399 else
400 {
402
405 }
406 }
Icon x
Icon y
Widget m_Parent
Definition SizeToChild.c:86
represents base for cargo storage for entities
Definition Cargo.c:7
static int SWAP_COLOR
static int GREEN_COLOR
static int RED_COLOR
static ColorManager GetInstance()
void UpdateFrameColor(EntityAI selectedEntity, EntityAI targetEntity, int combinationFlag, Widget w, InventoryLocation il=null)
Definition Icon.c:513
EntityAI m_Lock
Definition Icon.c:8

References InventoryCombinationFlags::ADD_AS_ATTACHMENT, InventoryCombinationFlags::ADD_AS_CARGO, InventoryCombinationFlags::COMBINE_QUANTITY2, InventoryCombinationFlags::FSWAP, ItemManager::GetChosenCombinationFlag(), GetGame(), ColorManager::GetInstance(), ItemManager::GetInstance(), GetPlayer(), ColorManager::GREEN_COLOR, m_HandsIcon, m_Lock, m_Parent, name, ColorManager::RED_COLOR, InventoryCombinationFlags::SWAP, ColorManager::SWAP_COLOR, InventoryCombinationFlags::SWAP_MAGAZINE, UpdateFrameColor(), x, and y.

◆ DraggingOverCombine()

◆ DraggingOverSwap()

void Icon::DraggingOverSwap ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 241 of file Icon.c.

242 {
243 if (w == null)
244 return;
245
246 string name = w.GetName();
247 name.Replace("PanelWidget", "Render");
248
249 ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(receiver.FindAnyWidget("Render"));
250 if (m_HandsIcon)
251 targetIpw = ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget("Render"));
252
254 if (selectedIpw == null)
255 selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
256
257 if (selectedIpw == null)
258 return;
259
263 return;
264
267 int index = player.GetHumanInventory().FindUserReservedLocationIndex(m_Item);
268
269 if (index >= 0)
270 {
271 player.GetHumanInventory().GetUserReservedLocation(index, il);
272
274 {
276 ItemManager.GetInstance().HideDropzones();
277 ItemManager.GetInstance().ShowSourceDropzone(il.GetParent());
278 return;
279 }
280 }
282
285 }
static int FSWAP_COLOR
script counterpart to engine's class Inventory
Definition Inventory.c:79
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
Definition Inventory.c:645

References GameInventory::CanForceSwapEntitiesEx(), InventoryCombinationFlags::FSWAP, ColorManager::FSWAP_COLOR, ItemManager::GetChosenCombinationFlag(), GetGame(), ColorManager::GetInstance(), ItemManager::GetInstance(), GetPlayer(), m_HandsIcon, m_Item, name, InventoryCombinationFlags::SWAP, and UpdateFrameColor().

◆ DropReceivedFromBackground()

void Icon::DropReceivedFromBackground ( Widget w,
int x,
int y,
Widget reciever )
inlineprotected

Definition at line 1086 of file Icon.c.

1087 {
1088 Pos pa;
1089 if (reciever)
1090 {
1091 reciever.GetUserData(pa);
1092 if (m_Parent)
1093 {
1094 ContainerWithCargo item = ContainerWithCargo.Cast(m_Parent.m_Parent);
1095 if (item)
1096 item.DropReceived(w, m_PosY + pa.y, m_PosX + pa.x);
1097 }
1098 }
1099 }
void Pos(int _x, int _y)
Definition Icon.c:1706
int m_PosX
Definition Icon.c:5
int m_PosY
Definition Icon.c:6

References m_Parent, m_PosX, m_PosY, and Pos().

◆ DropReceivedFromMain()

void Icon::DropReceivedFromMain ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 821 of file Icon.c.

822 {
823 ItemManager.GetInstance().HideDropzones();
824 ItemManager.GetInstance().SetIsDragging(false);
825 string name = w.GetName();
826 name.Replace("PanelWidget", "Render");
828
829 ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(receiver.FindAnyWidget("Render"));
830 if (m_HandsIcon)
831 targetIpw = ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget("Render"));
832
834 if (selectedIpw == null)
835 selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
836 if (selectedIpw == null)
837 return;
838
841 if (!selectedEntity)
842 return;
843 int index;
847 {
848 index = player.GetHumanInventory().FindUserReservedLocationIndex(m_Item);
849 ilSrc = new InventoryLocation();
850 ilDst = new InventoryLocation();
851
852 m_Item.GetInventory().GetCurrentInventoryLocation(ilSrc);
853 player.GetHumanInventory().GetUserReservedLocation(index, ilDst);
854
855 if (ilDst.GetParent().GetInventory().LocationCanAddEntity(ilDst))
856 {
857
858 player.GetHumanInventory().ClearUserReservedLocation(m_Item);
859 player.PredictiveTakeToDst(ilSrc, ilDst);
860 m_Item.GetOnReleaseLock().Invoke(m_Item);
861 }
862 }
863 else if (m_Lock)
864 {
865 CargoContainer parentCargo = CargoContainer.Cast(m_Parent);
866
867 float parentX;
868 float parentY;
869
870 parentCargo.GetRootWidget().GetScreenPos(parentX, parentY);
871
872 float iconSize = parentCargo.GetIconSize();
873 float spaceSize = parentCargo.GetSpaceSize();
874
875 int PosX = (x - parentX) / (iconSize + spaceSize);
876 int PosY = (y - parentY) / (iconSize + spaceSize);
877
878 EntityAI parent = m_Lock;
879 CargoBase targetCargo = parent.GetInventory().GetCargo();
880
881 ilDst = new InventoryLocation();
882 ilDst.SetCargoAuto(targetCargo, selectedEntity, PosY, PosX, selectedEntity.GetInventory().GetFlipCargo());
883
884 if (parent.GetInventory().LocationCanAddEntity(ilDst))
885 {
886 player.GetHumanInventory().ClearUserReservedLocation(m_Item);
887 m_Item.GetOnReleaseLock().Invoke(m_Item);
888
890 }
891 }
892 else
893 {
894 ilDst = new InventoryLocation();
896
899 }
900 }

References InventoryCombinationFlags::ADD_AS_ATTACHMENT, InventoryCombinationFlags::ADD_AS_CARGO, InventoryCombinationFlags::COMBINE_QUANTITY2, InventoryCombinationFlags::FSWAP, ItemManager::GetChosenCombinationFlag(), GetGame(), ItemManager::GetInstance(), GetPlayer(), m_HandsIcon, m_Item, m_Lock, m_Parent, name, PerformCombination(), InventoryCombinationFlags::SWAP, InventoryCombinationFlags::SWAP_MAGAZINE, SplitItemUtils::TakeOrSplitToInventoryLocation(), x, and y.

◆ FlagAction()

bool Icon::FlagAction ( EntityAI entity1,
EntityAI entity2,
int combinationFlags )
inlineprotected

Definition at line 673 of file Icon.c.

674 {
675 int current_flag;
676 ContextMenu cmenu = ContextMenu.Cast(GetGame().GetUIManager().GetMenu().GetContextMenu());
677 m_am_entity1 = entity1;
678 m_am_entity2 = entity2;
679 cmenu.Hide();
680 cmenu.Clear();
681 int id = -1;
682
684 {
686 entity.CombineItemsClient(ItemBase.Cast(entity2));
687 return false;
688 }
689
691 return true;
692
694 {
696 cmenu.Add("#inv_context_add_as_attachment", this, "OnPerformCombination", new Param1<int>(current_flag));
697 }
698 /*if (combinationFlags & InventoryCombinationFlags.LOAD_CHAMBER )
699 {
700 current_flag = InventoryCombinationFlags.LOAD_CHAMBER;
701 cmenu.Add( "#inv_context_load_chamber", this, "OnPerformCombination", new Param1<int>( current_flag ) );
702 }*/
704 {
706 cmenu.Add("#inv_context_attach_magazine", this, "OnPerformCombination", new Param1<int>(current_flag));
707 }
708
710 {
712 cmenu.Add("#inv_context_add_as_cargo", this, "OnPerformCombination", new Param1<int>(current_flag));
713 }
714
716 {
718 cmenu.Add("#inv_context_swap", this, "OnPerformCombination", new Param1<int>(current_flag));
719 }
720
722 {
724 cmenu.Add("#inv_context_combine", this, "OnPerformCombination", new Param1<int>(current_flag));
725 }
726
728 {
730 cmenu.Add("#inv_context_attach_magazine", this, "OnPerformCombination", new Param1<int>(current_flag));
731 }
732
734 {
736 cmenu.Add("Perform Action2", this, "OnPerformCombination", new Param1<int>(current_flag));
737 }
738
741 m_am_Pos_x -= 5;
742 m_am_Pos_y -= 5;
743
744 MissionGameplay mission = MissionGameplay.Cast(GetGame().GetMission());
745 /*if (combinationFlags & InventoryCombinationFlags.RECIPE_HANDS || combinationFlags & InventoryCombinationFlags.RECIPE_ANYWHERE )
746 {
747 OnPerformRecipe( id );
748 return true;
749 }
750 else /*if (cmenu.Count() == 1 )*/
751 //{
753 return true;
754 //}
755 /*else
756 {
757 cmenu.Show( m_am_Pos_x, m_am_Pos_y );
758 return true;
759 }*/
760 }
Mission mission
override ContextMenu GetContextMenu()
void OnPerformCombination(int combinationFlags)
Definition Icon.c:408
proto void GetMousePos(out int x, out int y)

References InventoryCombinationFlags::ADD_AS_ATTACHMENT, InventoryCombinationFlags::ADD_AS_CARGO, InventoryCombinationFlags::ATTACH_MAGAZINE, InventoryCombinationFlags::COMBINE_QUANTITY2, GetContextMenu(), GetGame(), GetMousePos(), mission, InventoryCombinationFlags::NONE, OnPerformCombination(), InventoryCombinationFlags::PERFORM_ACTION, InventoryCombinationFlags::SET_ACTION, and InventoryCombinationFlags::SWAP.

Referenced by CombineItems().

◆ FullScreen()

void Icon::FullScreen ( )
inlineprotected

Definition at line 1146 of file Icon.c.

1147 {
1148 if (m_IsDragged)
1149 return;
1150 GetRootWidget().ClearFlags(WidgetFlags.HEXACTSIZE + WidgetFlags.VEXACTSIZE);
1151 GetRootWidget().SetSize(1, 1);
1152 m_ColorWidget.SetColor(ARGB(0, 0, 0, 0));
1153 }
WidgetFlags
Definition EnWidgets.c:58
int ARGB(int a, int r, int g, int b)
Definition proto.c:322

References ARGB(), m_ColorWidget, and m_IsDragged.

Referenced by DestroyWhiteBackground().

◆ GetCargoPos()

int Icon::GetCargoPos ( )
inlineprotected

Definition at line 997 of file Icon.c.

998 {
999 return m_CargoPos;
1000 }
int m_CargoPos
Definition Icon.c:18

References m_CargoPos.

◆ GetCursorWidget()

Widget Icon::GetCursorWidget ( )
inlineprotected

Definition at line 88 of file Icon.c.

89 {
90 return m_CursorWidget;
91 }

References m_CursorWidget.

◆ GetMicromanagedPanel()

Widget Icon::GetMicromanagedPanel ( )
inlineprotected

Definition at line 93 of file Icon.c.

94 {
96 }

References m_MicromanagedPanel.

◆ GetObject()

Object Icon::GetObject ( )
inlineprotected

Definition at line 1166 of file Icon.c.

1167 {
1168 return m_Obj;
1169 }

References m_Obj.

Referenced by RefreshMuzzleIcon(), and SetActive().

◆ GetPosX()

int Icon::GetPosX ( )
inlineprotected

Definition at line 1601 of file Icon.c.

1602 {
1603 return m_PosX;
1604 }

References m_PosX.

Referenced by SetPosEx().

◆ GetPosY()

int Icon::GetPosY ( )
inlineprotected

Definition at line 1606 of file Icon.c.

1607 {
1608 return m_PosY;
1609 }

References m_PosY.

Referenced by SetPosEx().

◆ GetRelevantInventoryAction()

int Icon::GetRelevantInventoryAction ( int relevantActions)
inlineprotected

Definition at line 135 of file Icon.c.

136 {
137 return 0;
138
139 }

◆ GetSelectedWidget()

Widget Icon::GetSelectedWidget ( )
inlineprotected

Definition at line 83 of file Icon.c.

84 {
85 return m_SelectedPanel;
86 }

References m_SelectedPanel.

◆ GetSizeX()

int Icon::GetSizeX ( )
inlineprotected

Definition at line 1611 of file Icon.c.

1612 {
1613 return m_SizeX;
1614 }
int m_SizeX
Definition Icon.c:3

References m_SizeX.

◆ GetSizeY()

int Icon::GetSizeY ( )
inlineprotected

Definition at line 1616 of file Icon.c.

1617 {
1618 return m_SizeY;
1619 }
int m_SizeY
Definition Icon.c:4

References m_SizeY.

◆ GetSort()

int Icon::GetSort ( )
inlineprotected

Definition at line 1328 of file Icon.c.

1329 {
1330 return GetMainWidget().GetSort();
1331 }

◆ Init()

void Icon::Init ( EntityAI obj)
inlineprotected

Definition at line 1450 of file Icon.c.

1451 {
1452 InitEx(obj);
1453 }
void InitEx(EntityAI obj, bool refresh=true)
Definition Icon.c:1398

References InitEx().

◆ InitEx()

void Icon::InitEx ( EntityAI obj,
bool refresh = true )
inlineprotected

Definition at line 1398 of file Icon.c.

1399 {
1400 if (obj != m_Obj)
1401 {
1402 if (m_Obj)
1403 {
1404 m_Obj.GetOnItemFlipped().Remove(UpdateFlip);
1405 m_Obj.GetOnViewIndexChanged().Remove(SetItemPreview);
1406 }
1407 if (obj)
1408 {
1409 obj.GetOnItemFlipped().Insert(UpdateFlip);
1410 obj.GetOnViewIndexChanged().Insert(SetItemPreview);
1411 }
1412 }
1413
1414 if (m_HandsIcon)
1415 {
1418 }
1419
1420 m_Obj = obj;
1421 m_Item = ItemBase.Cast(m_Obj);
1422 m_Lock = null;
1423
1425
1426 WidgetEventHandler.GetInstance().RegisterOnDrag(GetMainWidget(), this, "CreateWhiteBackground");
1427 WidgetEventHandler.GetInstance().RegisterOnDrop(GetMainWidget(), this, "DestroyWhiteBackground");
1428 WidgetEventHandler.GetInstance().RegisterOnDropReceived(GetMainWidget(), this, "DropReceivedFromMain");
1429 WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown(GetMainWidget(), this, "MouseClick");
1430 WidgetEventHandler.GetInstance().RegisterOnDropReceived(GetMainWidget().FindAnyWidget("Swap"), this, "Swap");
1431 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(GetMainWidget().FindAnyWidget("Swap"), this, "DraggingOverSwap");
1432 WidgetEventHandler.GetInstance().RegisterOnDropReceived(GetMainWidget().FindAnyWidget("Combine"), this, "Combine");
1433 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(GetMainWidget().FindAnyWidget("Combine"), this, "DraggingOverCombine");
1434 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(GetMainWidget(), this, "DraggingOver");
1435 WidgetEventHandler.GetInstance().RegisterOnMouseEnter(GetMainWidget(), this, "MouseEnter");
1436 WidgetEventHandler.GetInstance().RegisterOnMouseLeave(GetMainWidget(), this, "MouseLeave");
1437 WidgetEventHandler.GetInstance().RegisterOnDoubleClick(GetMainWidget(), this, "DoubleClick");
1438
1440 CheckIsWeapon();
1444 m_RootWidget.FindAnyWidget("Reserved").Show(false, refresh);
1445
1446 if (refresh)
1447 Refresh();
1448 }
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
void SetItemSizeEx(bool refresh=true)
Definition Icon.c:1346
void CheckHasTemperature()
Definition Icon.c:1559
void CheckIsWeapon()
Definition Icon.c:1455
void SetItemPreviewEx(bool refresh=true)
Definition Icon.c:1333
static WidgetEventHandler GetInstance()

References CheckHasQuantityEx(), CheckHasTemperature(), CheckIsMagazineEx(), CheckIsWeapon(), FindAnyWidget(), WidgetEventHandler::GetInstance(), m_HandsIcon, m_Item, m_ItemPreview, m_Lock, m_Obj, m_RootWidget, Refresh(), ItemPreviewWidget::SetForceFlip(), ItemPreviewWidget::SetForceFlipEnable(), SetItemPreview(), SetItemPreviewEx(), SetItemSizeEx(), and UpdateFlip().

Referenced by Init().

◆ InitLock()

void Icon::InitLock ( EntityAI parent,
EntityAI obj,
int x_pos,
int y_pos,
bool flip )
inlineprotected

Definition at line 1377 of file Icon.c.

1378 {
1379 m_Lock = parent;
1380 m_Obj = obj;
1381 m_Item = ItemBase.Cast(m_Obj);
1382
1383 SetPos(x_pos, y_pos);
1385
1386 ItemManager.GetInstance().SetWidgetDraggable(GetMainWidget(), false);
1387 WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown(GetMainWidget(), this, "MouseClick");
1388 WidgetEventHandler.GetInstance().RegisterOnDropReceived(GetMainWidget(), this, "DropReceivedFromMain");
1389 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(GetMainWidget(), this, "DraggingOver");
1390
1391 m_RootWidget.FindAnyWidget("Reserved").Show(true);
1395 Refresh();
1396 }
void SetPos()
Definition Icon.c:1653

References ItemManager::GetInstance(), WidgetEventHandler::GetInstance(), m_Item, m_ItemPreview, m_Lock, m_Obj, m_RootWidget, Refresh(), ItemPreviewWidget::SetForceFlip(), ItemPreviewWidget::SetForceFlipEnable(), SetItemPreview(), SetPos(), and UpdateFlip().

◆ IsDragged()

bool Icon::IsDragged ( )
inlineprotected

Definition at line 98 of file Icon.c.

99 {
100 return m_IsDragged;
101 }

References m_IsDragged.

◆ MouseClick()

void Icon::MouseClick ( Widget w,
int x,
int y,
int button )
inlineprotected

Definition at line 762 of file Icon.c.

763 {
764 if (button == MouseState.RIGHT)
765 {
766 if (m_Lock)
767 GetGame().GetPlayer().GetHumanInventory().ClearUserReservedLocationSynced(m_Item);
768 else
769 {
770 if (m_Item && m_Item.IsItemBase())
771 {
772 m_Item.OnRightClick();
773
774 if (m_HasQuantity)
775 SetQuantity();
776#ifdef DIAG_DEVELOPER
777 if (GetDayZGame().IsLeftCtrlDown())
778 ShowActionMenu(m_Item);
779#endif
780 }
781 }
782
783 }
784 else if (!m_Lock)
785 {
786 switch (button)
787 {
788 case MouseState.MIDDLE:
790 break;
791
792 case MouseState.LEFT:
794 if (g_Game.IsLeftCtrlDown())
795 {
796 if (controlledPlayer.CanDropEntity(m_Item))
797 {
798 if (m_Item.GetTargetQuantityMax() < m_Item.GetQuantity())
799 m_Item.SplitIntoStackMaxClient(null, -1);
800 else
801 controlledPlayer.PhysicalPredictiveDropItem(m_Item);
802
803 ItemManager.GetInstance().SetWidgetDraggable(w, false);
804 }
805 }
806 else
807 {
809 m_Obj.GetInventory().GetCurrentInventoryLocation(il);
810
811 bool draggable = !controlledPlayer.GetInventory().HasInventoryReservation(m_Obj, null) && !controlledPlayer.GetInventory().IsInventoryLocked() && !controlledPlayer.IsItemsToDelete();
812 draggable = draggable && (m_Obj.GetHierarchyRoot() && m_Obj.GetInventory().CanRemoveEntity() || !m_Obj.GetHierarchyRoot() && AttachmentsOutOfReach.IsAttachmentReachable(m_Obj, "", il.GetSlot()));
813
814 ItemManager.GetInstance().SetWidgetDraggable(w, draggable);
815 }
816 break;
817 }
818 }
819 }
DayZGame GetDayZGame()
Definition DayZGame.c:3530
static bool IsAttachmentReachable(EntityAI e, string att_slot_name="", int slot_id=-1, float range=1.5)
void SetQuantity()
Definition Icon.c:1277
bool InspectItem()
Definition Container.c:321

References g_Game, GetDayZGame(), GetGame(), ItemManager::GetInstance(), GetPlayer(), LayoutHolder::InspectItem(), AttachmentsOutOfReach::IsAttachmentReachable(), m_HasQuantity, m_Item, m_Lock, m_Obj, and SetQuantity().

◆ MouseEnter()

bool Icon::MouseEnter ( Widget w,
int x,
int y )
inlineprotected

Definition at line 314 of file Icon.c.

315 {
316 if (!m_IsDragged)
317 {
318 PrepareOwnedTooltip(m_Obj, x, y);
319 m_CursorWidget.Show(true);
320 }
321
322 return true;
323 }

References m_CursorWidget, m_IsDragged, m_Obj, x, and y.

◆ MouseLeave()

bool Icon::MouseLeave ( Widget w,
Widget s,
int x,
int y )
inlineprotected

Definition at line 325 of file Icon.c.

326 {
327 HideOwnedTooltip();
328 if (!m_IsDragged)
329 m_CursorWidget.Show(false);
330 return true;
331 }

References m_CursorWidget, and m_IsDragged.

◆ OnDraggingOverBackground()

void Icon::OnDraggingOverBackground ( Widget w,
int x,
int y,
Widget reciever )
inlineprotected

Definition at line 1061 of file Icon.c.

1062 {
1063 ItemManager.GetInstance().HideDropzones();
1064 EntityAI entity = EntityAI.Cast(m_Obj);
1065 EntityAI parent = entity.GetHierarchyParent();
1066 if (parent && parent.GetHierarchyRootPlayer() == GetGame().GetPlayer())
1067 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
1068 else if (!m_HandsIcon)
1069 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
1070
1071 if (w == null || reciever == null)
1072 return;
1073 Pos pa;
1074 reciever.GetUserData(pa);
1075 if (m_Parent)
1076 {
1077 ContainerWithCargo item = ContainerWithCargo.Cast(m_Parent.m_Parent);
1078 if (item)
1079 item.DraggingOverGrid(w, m_PosY + pa.y, m_PosX + pa.x, reciever);
1081 if (hands_item)
1082 hands_item.DraggingOverGrid(w, m_PosY + pa.y, m_PosX + pa.x, reciever, null);
1083 }
1084 }

References GetGame(), ItemManager::GetInstance(), GetPlayer(), m_HandsIcon, m_Obj, m_Parent, m_PosX, m_PosY, and Pos().

◆ OnPerformCombination()

void Icon::OnPerformCombination ( int combinationFlags)
inlineprotected

Definition at line 408 of file Icon.c.

409 {
411 if (m_am_entity1 == null || m_am_entity2 == null) return;
412
414
417
419 {
421 Class.CastTo(amc, player.GetActionManager());
422
423 if (m_am_entity1 == player.GetHumanInventory().GetEntityInHands())
424 amc.PerformActionFromInventory(ItemBase.Cast(m_am_entity1), ItemBase.Cast(m_am_entity2));
425 else
426 amc.PerformActionFromInventory(ItemBase.Cast(m_am_entity2), ItemBase.Cast(m_am_entity1));
427 }
429 {
431 Class.CastTo(amc2, player.GetActionManager());
432
433 if (m_am_entity1 == player.GetHumanInventory().GetEntityInHands())
434 amc2.SetActionFromInventory(ItemBase.Cast(m_am_entity1), ItemBase.Cast(m_am_entity2));
435 else
436 amc2.SetActionFromInventory(ItemBase.Cast(m_am_entity2), ItemBase.Cast(m_am_entity1));
437 }
439 {
440 ItemBase entity = ItemBase.Cast(m_am_entity1);
441 entity.CombineItemsClient(ItemBase.Cast(m_am_entity2));
442 }
444 {
445 float stackable = m_am_entity2.GetTargetQuantityMax(-1);
446
447 if (stackable == 0 || stackable >= m_am_entity2.GetQuantity())
448 player.PredictiveTakeEntityToTargetAttachment(m_am_entity1, m_am_entity2);
449 else
450 {
452 m_am_entity1.GetInventory().FindFreeLocationFor(m_am_entity2, FindInventoryLocationType.ATTACHMENT, il);
453 ItemBase.Cast(m_am_entity2).SplitIntoStackMaxToInventoryLocationClient(il);
454 }
455 }
457 SplitItemUtils.TakeOrSplitToInventory(player, m_am_entity1, m_am_entity2);
458 }
Super root of all classes in Enforce script.
Definition EnScript.c:11
static void TakeOrSplitToInventory(notnull PlayerBase player, notnull EntityAI target, notnull EntityAI item)
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

References InventoryCombinationFlags::ADD_AS_ATTACHMENT, InventoryCombinationFlags::ADD_AS_CARGO, Class::CastTo(), InventoryCombinationFlags::COMBINE_QUANTITY2, GetGame(), GetPlayer(), InventoryCombinationFlags::NONE, InventoryCombinationFlags::PERFORM_ACTION, InventoryCombinationFlags::SET_ACTION, and SplitItemUtils::TakeOrSplitToInventory().

Referenced by FlagAction(), and ShowActionMenuCombine().

◆ OnPerformRecipe()

void Icon::OnPerformRecipe ( int id)
inlineprotected

Definition at line 635 of file Icon.c.

636 {
637 if (m_am_entity1 == null || m_am_entity2 == null) return;
638
639 Debug.Log("OnPerformRecipe called for id:" + id.ToString(), "recipes");
641 player.GetCraftingManager().SetInventoryCraft(id, ItemBase.Cast(m_am_entity1), ItemBase.Cast(m_am_entity2));
642 }
proto string ToString()
Definition Debug.c:14
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.
Definition Debug.c:133

References GetGame(), GetPlayer(), Debug::Log(), and ToString().

◆ PerformCombination()

bool Icon::PerformCombination ( EntityAI selectedEntity,
EntityAI targetEntity,
int combinationFlag,
InventoryLocation ilSwapDst = null )
inlineprotected

Definition at line 460 of file Icon.c.

461 {
464
465 switch (combinationFlag)
466 {
468 float stackable = targetEntity.GetTargetQuantityMax(-1);
469
470 if (stackable == 0 || stackable >= targetEntity.GetQuantity())
471 return player.PredictiveTakeEntityToTargetAttachment(targetEntity, selectedEntity);
472 else
473 {
475 targetEntity.GetInventory().FindFreeLocationFor(selectedEntity, FindInventoryLocationType.ATTACHMENT, il);
476 ItemBase.Cast(selectedEntity).SplitIntoStackMaxToInventoryLocationClient(il);
477 return true;
478 }
479 break;
482 return true;
484 targetEntity.CombineItemsClient(selectedEntity);
485 return true;
487 Class.CastTo(amc, player.GetActionManager());
488 if (targetEntity == player.GetHumanInventory().GetEntityInHands())
489 amc.SetActionFromInventory(ItemBase.Cast(targetEntity), ItemBase.Cast(selectedEntity));
490 else
491 amc.SetActionFromInventory(ItemBase.Cast(selectedEntity), ItemBase.Cast(targetEntity));
492 return true;
494 Class.CastTo(amc, player.GetActionManager());
495 if (targetEntity == player.GetHumanInventory().GetEntityInHands())
496 amc.PerformActionFromInventory(ItemBase.Cast(targetEntity), ItemBase.Cast(selectedEntity));
497 else
498 amc.PerformActionFromInventory(ItemBase.Cast(selectedEntity), ItemBase.Cast(targetEntity));
499 return true;
501 return player.GetWeaponManager().SwapMagazine(Magazine.Cast(selectedEntity));
503 return player.PredictiveSwapEntities(targetEntity, selectedEntity);
505 return player.PredictiveForceSwapEntities(selectedEntity, targetEntity, ilSwapDst);
506 default:
507 return false;
508 }
509
510 return false;
511 }

References InventoryCombinationFlags::ADD_AS_ATTACHMENT, InventoryCombinationFlags::ADD_AS_CARGO, Class::CastTo(), InventoryCombinationFlags::COMBINE_QUANTITY2, InventoryCombinationFlags::FSWAP, GetGame(), GetPlayer(), InventoryCombinationFlags::PERFORM_ACTION, InventoryCombinationFlags::SET_ACTION, InventoryCombinationFlags::SWAP, InventoryCombinationFlags::SWAP_MAGAZINE, and SplitItemUtils::TakeOrSplitToInventory().

Referenced by Combine(), DropReceivedFromMain(), and Swap().

◆ Refresh()

override void Icon::Refresh ( )
inlineprotected

Definition at line 1118 of file Icon.c.

1119 {
1120 super.Refresh();
1121
1122 if (!m_HandsIcon)
1123 SetPos();
1124
1125 if (m_HasTemperature)
1127
1128 if (m_IsWeapon)
1130
1131 if (m_HasQuantity)
1132 SetQuantity();
1133 }
void SetTemperature()
Definition Icon.c:1135
void RefreshMuzzleIcon()
Definition Icon.c:1171

References m_HandsIcon, m_HasQuantity, m_HasTemperature, m_IsWeapon, RefreshMuzzleIcon(), SetPos(), SetQuantity(), and SetTemperature().

Referenced by CreateWhiteBackground(), DestroyWhiteBackground(), InitEx(), InitLock(), and RefreshIconPos().

◆ RefreshIconPos()

void Icon::RefreshIconPos ( )
inlineprotected

Definition at line 1140 of file Icon.c.

1141 {
1142 Refresh();
1143 GetMainWidget().Update();
1144 }

References Refresh().

Referenced by RefreshPos().

◆ RefreshMuzzleIcon()

void Icon::RefreshMuzzleIcon ( )
inlineprotected

Definition at line 1171 of file Icon.c.

1172 {
1174 if (wpn)
1175 {
1176 int i;
1178 if (!wpn.IsShowingChamberedBullet())
1179 {
1180 for (i = 0; i < m_AmmoIcons.Count(); i++)
1181 {
1182 ammoIcon = m_AmmoIcons.Get(i);
1183 ammoIcon.Show(false);
1184 }
1185 /* int bullet_count = 0;
1186 int fireout_count = 0;
1187
1188 for ( i = 0; i < wpn.GetMuzzleCount(); i++ )
1189 {
1190 if (wpn.IsChamberFull(i))
1191 {
1192 if (wpn.IsChamberFiredOut(i))
1193 {
1194 fireout_count++;
1195 }
1196 else
1197 {
1198 bullet_count++;
1199 }
1200 }
1201 }
1202
1203 int j;
1204 i = 0;
1205 for ( j= 0; j < bullet_count; j++ )
1206 {
1207 if ( i > m_AmmoIcons.Count() )
1208 {
1209 //add plus ammo
1210 break;
1211 }
1212
1213 ammoIcon = m_AmmoIcons.Get(i);
1214 ammoIcon.Show( true );
1215 ammoIcon.SetImage( 0 );
1216 i++;
1217 }
1218
1219 for ( j= 0; j < fireout_count; j++ )
1220 {
1221 if ( i > m_AmmoIcons.Count() )
1222 {
1223 //add plus ammo
1224 break;
1225 }
1226
1227 ammoIcon = m_AmmoIcons.Get(i);
1228 ammoIcon.Show( true );
1229 ammoIcon.SetImage( 1 );
1230 i++;
1231 }
1232
1233 for (j = i; j < m_AmmoIcons.Count(); j++)
1234 {
1235 ammoIcon = m_AmmoIcons.Get(j);
1236 ammoIcon.Show(false);
1237 }*/
1238 }
1239 else
1240 {
1241 //TODO MW - add more conplex logic
1242 for (i = 0; i < wpn.GetMuzzleCount(); i++)
1243 {
1244 if (i > m_AmmoIcons.Count())
1245 {
1246 //add plus ammo
1247 break;
1248 }
1249
1250 ammoIcon = m_AmmoIcons.Get(i);
1251
1252 if (wpn.IsChamberFull(i))
1253 {
1254 if (wpn.IsJammed())
1255 {
1256 ammoIcon.Show(true);
1257 ammoIcon.SetImage(2);
1258 }
1259 else if (wpn.IsChamberFiredOut(i))
1260 {
1261 ammoIcon.Show(true);
1262 ammoIcon.SetImage(1);
1263 }
1264 else
1265 {
1266 ammoIcon.Show(true);
1267 ammoIcon.SetImage(0);
1268 }
1269 }
1270 else
1271 ammoIcon.Show(false);
1272 }
1273 }
1274 }
1275 }
Object GetObject()
Definition Icon.c:1166

References GetObject(), and m_AmmoIcons.

Referenced by Refresh(), and UpdateInterval().

◆ RefreshPos()

void Icon::RefreshPos ( int row,
int column )
inlineprotected

Definition at line 1155 of file Icon.c.

1156 {
1157 if (row != m_PosY || column != m_PosX)
1158 {
1159 m_PosX = column;
1160 m_PosY = row;
1161 SetPos();
1163 }
1164 }
void RefreshIconPos()
Definition Icon.c:1140

References m_PosX, m_PosY, RefreshIconPos(), and SetPos().

◆ RefreshQuickbar()

void Icon::RefreshQuickbar ( )
inlineprotected

Definition at line 141 of file Icon.c.

142 {
143 InventoryMenu menu = InventoryMenu.Cast(GetGame().GetUIManager().FindMenu(MENU_INVENTORY));
144 HideOwnedTooltip();
145 if (menu)
146 menu.RefreshQuickbar();
147 }

References GetGame(), InventoryMenu(), and MENU_INVENTORY.

Referenced by DoubleClick().

◆ RevertToOriginalFlip()

void Icon::RevertToOriginalFlip ( )
inlineprotected

Definition at line 1101 of file Icon.c.

1102 {
1103 if (m_Item)
1104 {
1105 m_Item.GetInventory().SetFlipCargo(m_PreviousFlipOrientation);
1106 int ww, hh;
1107 GetGame().GetInventoryItemSize(m_Item, ww, hh);
1108
1110 SetSize(hh, ww);
1111 else
1112 SetSize(ww, hh);
1113
1114 SetSize();
1115 }
1116 }

References GetGame(), m_Item, m_PreviousFlipOrientation, and SetSize().

Referenced by DestroyWhiteBackground(), and ~Icon().

◆ SetActive()

override void Icon::SetActive ( bool active)
inlineprotected

Definition at line 103 of file Icon.c.

104 {
105 super.SetActive(active);
106 if (active && GetObject())
107 {
108 float x, y;
109 GetMainWidget().GetScreenPos(x, y);
110 PrepareOwnedTooltip(EntityAI.Cast(GetObject()), -1, y);
111 }
112
114 }

References GetObject(), m_SelectedPanel, x, and y.

Referenced by Container::SetLastActive().

◆ SetCargoPos()

void Icon::SetCargoPos ( int x)
inlineprotected

Definition at line 1002 of file Icon.c.

1003 {
1004 GetMainWidget().SetSort(x);
1005 m_CargoPos = x;
1006 }

References m_CargoPos, and x.

◆ SetItemPreview()

void Icon::SetItemPreview ( )
inlineprotected

Definition at line 1341 of file Icon.c.

1342 {
1344 }

References SetItemPreviewEx().

Referenced by InitEx(), InitLock(), and ~Icon().

◆ SetItemPreviewEx()

void Icon::SetItemPreviewEx ( bool refresh = true)
inlineprotected

Definition at line 1333 of file Icon.c.

1334 {
1335 m_ItemPreview.Show(true, refresh);
1338 m_ItemPreview.SetView(m_Obj.GetViewIndex());
1339 }
proto native void SetView(int viewIndex)
proto native void SetItem(EntityAI object)
proto native void SetModelOrientation(vector vOrientation)

References m_ItemPreview, m_Obj, ItemPreviewWidget::SetItem(), ItemPreviewWidget::SetModelOrientation(), and ItemPreviewWidget::SetView().

Referenced by InitEx(), and SetItemPreview().

◆ SetItemSize()

void Icon::SetItemSize ( )
inlineprotected

Definition at line 1359 of file Icon.c.

1360 {
1361 SetItemSizeEx();
1362 }

References SetItemSizeEx().

◆ SetItemSizeEx()

void Icon::SetItemSizeEx ( bool refresh = true)
inlineprotected

Definition at line 1346 of file Icon.c.

1347 {
1348#ifdef PLATFORM_CONSOLE
1349 m_ItemSizePanel.Show(true, refresh);
1350 m_ItemSizeWidget.Show(true, refresh);
1351
1352 int sizeX, sizeY;
1353 GetGame().GetInventoryItemSize(m_Item, sizeX, sizeY);
1354 int capacity = sizeX * sizeY;
1355 m_ItemSizeWidget.SetText(capacity.ToString());
1356#endif
1357 }

References GetGame(), m_Item, m_ItemSizePanel, and m_ItemSizeWidget.

Referenced by InitEx(), and SetItemSize().

◆ SetLayoutName()

override void Icon::SetLayoutName ( )
inlineprotected

Definition at line 958 of file Icon.c.

959 {
960#ifdef PLATFORM_CONSOLE
961 m_LayoutName = WidgetLayoutName.IconXbox;
962#else
963 switch (InventoryMenu.GetWidthType())
964 {
965 case ScreenWidthType.NARROW:
966 {
967 m_LayoutName = WidgetLayoutName.IconNarrow;
968 break;
969 }
970 case ScreenWidthType.MEDIUM:
971 {
972 m_LayoutName = WidgetLayoutName.IconMedium;
973 break;
974 }
975 case ScreenWidthType.WIDE:
976 {
977 m_LayoutName = WidgetLayoutName.IconWide;
978 break;
979 }
980 }
981#endif
982
983 }
ScreenWidthType
const string IconWide
const string IconMedium
const string IconXbox
const string IconNarrow

References WidgetLayoutName::IconMedium, WidgetLayoutName::IconNarrow, WidgetLayoutName::IconWide, WidgetLayoutName::IconXbox, and InventoryMenu().

◆ SetParentWidget()

override void Icon::SetParentWidget ( )
inlineprotected

Definition at line 116 of file Icon.c.

117 {
118#ifndef PLATFORM_CONSOLE
119 if (m_Parent.IsInherited(HandsPreview))
120 super.SetParentWidget();
121 else
122 {
123 if (m_Parent != null)
124 {
125 CargoContainer gridContainer = CargoContainer.Cast(m_Parent);
126 if (gridContainer)
127 m_ParentWidget = gridContainer.GetMainWidget();
128 }
129 }
130#else
131 super.SetParentWidget();
132#endif
133 }
Widget m_ParentWidget

References m_Parent, and m_ParentWidget.

◆ SetPos() [1/2]

void Icon::SetPos ( )
inlineprotected

Definition at line 1653 of file Icon.c.

1654 {
1655 SetPosEx();
1656 }
void SetPosEx(bool refresh=true)
Definition Icon.c:1621

References SetPosEx().

Referenced by InitLock(), Refresh(), and RefreshPos().

◆ SetPos() [2/2]

void Icon::SetPos ( int x,
int y )
inlineprotected

Definition at line 991 of file Icon.c.

992 {
993 m_PosX = x;
994 m_PosY = y;
995 }

References m_PosX, m_PosY, x, and y.

◆ SetPosEx()

void Icon::SetPosEx ( bool refresh = true)
inlineprotected

Definition at line 1621 of file Icon.c.

1622 {
1623 CargoContainer parentContainer = CargoContainer.Cast(m_Parent);
1625 Widget rootWidget = GetRootWidget();
1626 float iconSize, spaceSize;
1627 if (parentContainer)
1628 {
1629 iconSize = parentContainer.GetIconSize();
1630 spaceSize = parentContainer.GetSpaceSize();
1631 }
1632 else if (parentHPrevContainer)
1633 {
1634 iconSize = parentHPrevContainer.GetIconSize();
1635 if (rootWidget)
1636 rootWidget.SetFlags(WidgetFlags.EXACTSIZE, refresh);
1637 }
1638
1639 if (rootWidget)
1640 {
1641#ifndef PLATFORM_CONSOLE
1642 rootWidget.SetPos(iconSize * GetPosX() + (GetPosX() + 1) * spaceSize, iconSize * GetPosY() + (GetPosY() + 1) * spaceSize, refresh);
1644#else
1645 int row = m_CargoPos / 5;
1646 int column = m_CargoPos % 5;
1649#endif
1650 }
1651 }
int GetPosY()
Definition Icon.c:1606
int GetPosX()
Definition Icon.c:1601

References GetPosX(), GetPosY(), m_CargoPos, m_Parent, m_SizeX, and m_SizeY.

Referenced by SetPos().

◆ SetPosX()

void Icon::SetPosX ( int x)
inlineprotected

Definition at line 1581 of file Icon.c.

1582 {
1583 m_PosX = x;
1584 }

References m_PosX, and x.

◆ SetPosY()

void Icon::SetPosY ( int y)
inlineprotected

Definition at line 1586 of file Icon.c.

1587 {
1588 m_PosY = y;
1589 }

References m_PosY, and y.

◆ SetQuantity()

void Icon::SetQuantity ( )
inlineprotected

Definition at line 1277 of file Icon.c.

1278 {
1279 if (m_Item)
1280 {
1283 {
1285
1287 {
1289
1291 m_QuantityStack.Show(false);
1292 else
1293 {
1295 m_QuantityStack.Show(true);
1296 }
1297
1298 m_QuantityProgress.Show(false);
1299 }
1300 else if (quantityType == QUANTITY_PROGRESS)
1301 {
1302 int max = m_Item.GetQuantityMax();
1303 int count = m_Item.ConfigGetInt("count");
1304 float quantity = m_CurrQuantity;
1305
1306 if (count > 0)
1307 max = count;
1308
1309 if (max > 0)
1310 {
1311 float value = Math.Round((quantity / max) * 100);
1312 m_QuantityProgress.SetCurrent(value);
1313 }
1314
1315 m_QuantityStack.Show(false);
1316 m_QuantityProgress.Show(true);
1317 }
1318 }
1319 }
1320 }
float m_CurrQuantity
Definition Icon.c:13
Definition EnMath.c:7
static float GetItemQuantity(InventoryItem item)
static float GetItemQuantityMax(InventoryItem item)
static string GetItemQuantityText(EntityAI item, bool showMax=false)
const int QUANTITY_PROGRESS
Definition constants.c:484
const int QUANTITY_COUNT
Definition constants.c:483
static proto float Round(float f)
Returns mathematical round of value.

References QuantityConversions::GetItemQuantity(), QuantityConversions::GetItemQuantityMax(), QuantityConversions::GetItemQuantityText(), QuantityConversions::HasItemQuantity(), m_CurrQuantity, m_Item, m_QuantityItem, m_QuantityProgress, m_QuantityStack, QUANTITY_COUNT, QUANTITY_HIDDEN, QUANTITY_PROGRESS, and Math::Round().

Referenced by MouseClick(), Refresh(), and UpdateInterval().

◆ SetSize() [1/2]

void Icon::SetSize ( )
inlineprotected

Definition at line 1658 of file Icon.c.

1659 {
1660 CargoContainer parentContainer = CargoContainer.Cast(m_Parent);
1662 float iconSize, spaceSize;
1663 Widget rootWidget = GetRootWidget();
1664 if (parentContainer)
1665 {
1666 iconSize = parentContainer.GetIconSize();
1667 spaceSize = parentContainer.GetSpaceSize();
1668 }
1669 else if (parentHPrevContainer)
1670 {
1671 iconSize = parentHPrevContainer.GetIconSize();
1672 if (rootWidget)
1673 GetRootWidget().SetFlags(WidgetFlags.EXACTSIZE);
1674 }
1675
1676 if (rootWidget)
1677 {
1678#ifndef PLATFORM_CONSOLE
1679 GetRootWidget().SetSize(iconSize * m_SizeX + (m_SizeX) * spaceSize, iconSize * m_SizeY + (m_SizeY) * spaceSize);
1680#else
1681 GetRootWidget().SetSize(iconSize, iconSize);
1682#endif
1683 }
1684 }

References m_Parent, m_SizeX, and m_SizeY.

Referenced by CreateWhiteBackground(), RevertToOriginalFlip(), and UpdateFlip().

◆ SetSize() [2/2]

void Icon::SetSize ( int x,
int y )
inlineprotected

Definition at line 985 of file Icon.c.

986 {
987 m_SizeX = x;
988 m_SizeY = y;
989 }

References m_SizeX, m_SizeY, x, and y.

◆ SetSizeX()

void Icon::SetSizeX ( int x)
inlineprotected

Definition at line 1591 of file Icon.c.

1592 {
1593 m_SizeX = x;
1594 }

References m_SizeX, and x.

◆ SetSizeY()

void Icon::SetSizeY ( int y)
inlineprotected

Definition at line 1596 of file Icon.c.

1597 {
1598 m_SizeY = y;
1599 }

References m_SizeY, and y.

◆ SetSort()

void Icon::SetSort ( int index)
inlineprotected

Definition at line 1322 of file Icon.c.

1323 {
1324 GetMainWidget().SetSort(index);
1325 GetMainWidget().Update();
1326 }

◆ SetTemperature()

void Icon::SetTemperature ( )
inlineprotected

Definition at line 1135 of file Icon.c.

1136 {
1137 ItemManager.GetInstance().SetIconTemperature(EntityAI.Cast(m_Obj), m_RootWidget);
1138 }

References ItemManager::GetInstance(), m_Obj, and m_RootWidget.

Referenced by Refresh(), and UpdateInterval().

◆ ShowActionMenuCombine()

void Icon::ShowActionMenuCombine ( EntityAI entity1,
EntityAI entity2,
int combinationFlags,
Widget w,
bool color_test )
inlineprotected

Definition at line 556 of file Icon.c.

557 {
558 int lastFlag = 0;
559 ContextMenu cmenu = ContextMenu.Cast(GetGame().GetUIManager().GetMenu().GetContextMenu());
560 m_am_entity1 = entity1;
561 m_am_entity2 = entity2;
562 cmenu.Hide();
563 cmenu.Clear();
564 int id = -1;
565
566 if (entity1 == null || entity2 == null) return;
567
569 {
570 if (color_test)
571 {
573 ItemManager.GetInstance().ShowSourceDropzone(entity2);
574 }
575 return;
576 }
577
579 {
581 cmenu.Add("#inv_context_add_as_cargo", this, "OnPerformCombination", new Param1<int>(lastFlag));
582 }
584 {
586 cmenu.Add("#inv_context_add_as_attachment", this, "OnPerformCombination", new Param1<int>(lastFlag));
587 }
588
590 {
592 cmenu.Add("#inv_context_combine_quantity", this, "OnPerformCombination", new Param1<int>(lastFlag));
593 }
594
596 {
598 cmenu.Add("#inv_context_attach_magazine", this, "OnPerformCombination", new Param1<int>(lastFlag));
599 }
600
602 {
604 cmenu.Add("Perform action", this, "OnPerformCombination", new Param1<int>(lastFlag));
605 }
606
607 if (color_test)
608 {
609 if (lastFlag == 0)
610 {
611 ItemManager.GetInstance().HideDropzones();
612 ItemManager.GetInstance().GetCenterDropzone().SetAlpha(1);
614 }
616 {
617 ItemManager.GetInstance().HideDropzones();
618 ItemManager.GetInstance().GetCenterDropzone().SetAlpha(1);
620 }
621 else
622 {
623 ItemManager.GetInstance().HideDropzones();
624 ItemManager.GetInstance().GetCenterDropzone().SetAlpha(1);
626 }
627 }
628 else if (cmenu.Count() >= 1)
629 {
631 return;
632 }
633 }
static int COMBINE_COLOR

References InventoryCombinationFlags::ADD_AS_ATTACHMENT, InventoryCombinationFlags::ADD_AS_CARGO, ColorManager::COMBINE_COLOR, InventoryCombinationFlags::COMBINE_QUANTITY2, GetContextMenu(), GetGame(), ColorManager::GetInstance(), ItemManager::GetInstance(), ColorManager::GREEN_COLOR, InventoryCombinationFlags::NONE, OnPerformCombination(), InventoryCombinationFlags::PERFORM_ACTION, ColorManager::RED_COLOR, and InventoryCombinationFlags::SET_ACTION.

◆ Swap()

void Icon::Swap ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 902 of file Icon.c.

903 {
904 ItemManager.GetInstance().HideDropzones();
905 ItemManager.GetInstance().SetIsDragging(false);
906 string name = w.GetName();
907 name.Replace("PanelWidget", "Render");
908
909 ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(receiver.FindAnyWidget("Render"));
910 if (m_HandsIcon)
911 targetIpw = ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget("Render"));
912
914 if (selectedIpw == null)
915 selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
916 if (selectedIpw == null)
917 return;
918
922 return;
923
925 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
926
929 targetEntity.GetInventory().GetCurrentInventoryLocation(ilSrc);
930 Icon icon = ItemManager.GetInstance().GetDraggedIcon();
931
932 int index = player.GetHumanInventory().FindUserReservedLocationIndex(targetEntity);
933 if (index >= 0)
934 {
935 player.GetHumanInventory().GetUserReservedLocation(index, ilDst);
936
938 {
939 if (m_HandsIcon && !player.GetInventory().HasInventoryReservation(itemInHands, null) && !player.IsItemsToDelete())
940 {
941 GetGame().GetPlayer().PredictiveForceSwapEntities(selectedEntity, targetEntity, ilDst);
942 return;
943 }
944 }
945 }
947
950 }
Definition Icon.c:2

References GameInventory::CanForceSwapEntitiesEx(), InventoryCombinationFlags::FSWAP, ItemManager::GetChosenCombinationFlag(), GetGame(), ItemManager::GetInstance(), GetPlayer(), m_HandsIcon, name, PerformCombination(), and InventoryCombinationFlags::SWAP.

◆ ToRefresh()

void Icon::ToRefresh ( Icon icon,
Icon icon2 )
inlineprotected

Definition at line 952 of file Icon.c.

953 {
954 (IconsContainer.Cast(m_Parent)).RemoveItem(icon);
955 (IconsContainer.Cast(m_Parent)).RemoveItem(icon2);
956 }

References m_Parent.

◆ UpdateFlip()

void Icon::UpdateFlip ( bool flipped)
inlineprotected

Definition at line 1364 of file Icon.c.

1365 {
1366 int sizeX, sizeY;
1367 GetGame().GetInventoryItemSize(m_Item, sizeX, sizeY);
1368
1369 if (flipped)
1371 else
1373
1374 SetSize();
1375 }

References GetGame(), m_Item, and SetSize().

Referenced by InitEx(), InitLock(), and ~Icon().

◆ UpdateFrameColor()

void Icon::UpdateFrameColor ( EntityAI selectedEntity,
EntityAI targetEntity,
int combinationFlag,
Widget w,
InventoryLocation il = null )
inlineprotected

Definition at line 513 of file Icon.c.

514 {
515 int color;
517
518 ItemManager.GetInstance().HideDropzones();
519 switch (combinationFlag)
520 {
524 ItemManager.GetInstance().ShowSourceDropzone(targetEntity);
525 break;
530 ItemManager.GetInstance().ShowSourceDropzone(targetEntity);
531 break;
534 ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
535 break;
538 ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
539 break;
542 if (il)
543 ItemManager.GetInstance().ShowSourceDropzone(il.GetParent());
544 else
545 ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
546 break;
547 default:
549 ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
550 }
551
552 ColorManager.GetInstance().SetColor(w, color);
553 }

References InventoryCombinationFlags::ADD_AS_ATTACHMENT, InventoryCombinationFlags::ADD_AS_CARGO, ColorManager::COMBINE_COLOR, InventoryCombinationFlags::COMBINE_QUANTITY2, InventoryCombinationFlags::FSWAP, ColorManager::FSWAP_COLOR, ColorManager::GetInstance(), ItemManager::GetInstance(), ColorManager::GREEN_COLOR, InventoryCombinationFlags::PERFORM_ACTION, ColorManager::RED_COLOR, InventoryCombinationFlags::SET_ACTION, InventoryCombinationFlags::SWAP, ColorManager::SWAP_COLOR, and InventoryCombinationFlags::SWAP_MAGAZINE.

Referenced by DraggingOver(), DraggingOverCombine(), and DraggingOverSwap().

◆ UpdateInterval()

override void Icon::UpdateInterval ( )
inlineprotected

Definition at line 1686 of file Icon.c.

1687 {
1688 if (m_Item)
1689 {
1690 if (m_HasTemperature)
1692
1693 if (m_IsWeapon)
1695
1696 if (m_HasQuantity)
1697 SetQuantity();
1698 }
1699 }

References m_HasQuantity, m_HasTemperature, m_IsWeapon, m_Item, RefreshMuzzleIcon(), SetQuantity(), and SetTemperature().

Member Data Documentation

◆ m_AmmoIcons

ref array<ImageWidget> Icon::m_AmmoIcons
protected

Definition at line 39 of file Icon.c.

Referenced by CheckIsWeapon(), and RefreshMuzzleIcon().

◆ m_AmmoTypeIcon

ImageWidget Icon::m_AmmoTypeIcon
protected

Definition at line 40 of file Icon.c.

Referenced by CheckIsMagazineEx(), and Icon().

◆ m_CargoPos

int Icon::m_CargoPos
protected

Definition at line 18 of file Icon.c.

Referenced by GetCargoPos(), SetCargoPos(), and SetPosEx().

◆ m_ColorWidget

Widget Icon::m_ColorWidget
protected

Definition at line 26 of file Icon.c.

Referenced by CreateWhiteBackground(), FullScreen(), and Icon().

◆ m_CurrQuantity

float Icon::m_CurrQuantity = -1
protected

Definition at line 13 of file Icon.c.

Referenced by SetQuantity().

◆ m_CursorWidget

Widget Icon::m_CursorWidget
protected

◆ m_HandsIcon

◆ m_HasQuantity

bool Icon::m_HasQuantity = false
protected

Definition at line 12 of file Icon.c.

Referenced by CheckHasQuantityEx(), MouseClick(), Refresh(), and UpdateInterval().

◆ m_HasTemperature

bool Icon::m_HasTemperature = false
protected

Definition at line 11 of file Icon.c.

Referenced by CheckHasTemperature(), Refresh(), and UpdateInterval().

◆ m_IsDragged

bool Icon::m_IsDragged
protected

◆ m_IsMagazine

bool Icon::m_IsMagazine = false
protected

Definition at line 10 of file Icon.c.

Referenced by CheckIsMagazineEx().

◆ m_IsWeapon

bool Icon::m_IsWeapon = false
protected

Definition at line 9 of file Icon.c.

Referenced by CheckIsWeapon(), Refresh(), and UpdateInterval().

◆ m_Item

◆ m_ItemPreview

ItemPreviewWidget Icon::m_ItemPreview
protected

◆ m_ItemSizePanel

Widget Icon::m_ItemSizePanel
protected

Definition at line 36 of file Icon.c.

Referenced by Icon(), and SetItemSizeEx().

◆ m_ItemSizeWidget

TextWidget Icon::m_ItemSizeWidget
protected

Definition at line 37 of file Icon.c.

Referenced by Icon(), and SetItemSizeEx().

◆ m_Lock

EntityAI Icon::m_Lock
protected

Definition at line 8 of file Icon.c.

Referenced by DraggingOver(), DropReceivedFromMain(), InitEx(), InitLock(), and MouseClick().

◆ m_MicromanagedPanel

Widget Icon::m_MicromanagedPanel
protected

Definition at line 28 of file Icon.c.

Referenced by GetMicromanagedPanel(), and Icon().

◆ m_Obj

◆ m_PosX

int Icon::m_PosX
protected

◆ m_PosY

int Icon::m_PosY
protected

◆ m_PreviousFlipOrientation

bool Icon::m_PreviousFlipOrientation
protected

Definition at line 20 of file Icon.c.

Referenced by CreateWhiteBackground(), and RevertToOriginalFlip().

◆ m_QuantityItem

TextWidget Icon::m_QuantityItem
protected

Definition at line 32 of file Icon.c.

Referenced by Icon(), and SetQuantity().

◆ m_QuantityPanel

Widget Icon::m_QuantityPanel
protected

Definition at line 31 of file Icon.c.

Referenced by CheckHasQuantityEx(), and Icon().

◆ m_QuantityProgress

ProgressBarWidget Icon::m_QuantityProgress
protected

Definition at line 33 of file Icon.c.

Referenced by Icon(), and SetQuantity().

◆ m_QuantityStack

Widget Icon::m_QuantityStack
protected

Definition at line 34 of file Icon.c.

Referenced by Icon(), and SetQuantity().

◆ m_SelectedPanel

Widget Icon::m_SelectedPanel
protected

Definition at line 27 of file Icon.c.

Referenced by GetSelectedWidget(), Icon(), and SetActive().

◆ m_SizeX

int Icon::m_SizeX
protected

Definition at line 3 of file Icon.c.

Referenced by GetSizeX(), SetPosEx(), SetSize(), SetSize(), and SetSizeX().

◆ m_SizeY

int Icon::m_SizeY
protected

Definition at line 4 of file Icon.c.

Referenced by GetSizeY(), SetPosEx(), SetSize(), SetSize(), and SetSizeY().

◆ NUMBER_OF_TIMERS

const int Icon::NUMBER_OF_TIMERS = 2
protected

Definition at line 22 of file Icon.c.


The documentation for this class was generated from the following file: