Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ItemSelectionMenuEntry.c
Go to the documentation of this file.
2{
3 protected const ResourceName LAYOUT_ITEM = "{93472DECDA62C46F}UI/layouts/Common/RadialMenu/SelectionMenuEntryPreview.layout";
5 protected int m_iQuickSlotID = -1;
6
7 //------------------------------------------------------------------------------------------------
8 override void Update()
9 {
11 if (!entry)
12 return;
13
14 bool enabled;
15 string name;
16 string description;
17
18 IEntity item = GetItem();
19 if (item)
20 {
21 enabled = true;
22
23 UIInfo uiInfo = GetUIInfo(item);
24 if (uiInfo)
25 {
26 name = uiInfo.GetName();
27 description = uiInfo.GetDescription();
28 }
29 }
30
31 // Widget setup
32 SetName(name);
33
34 if (entry)
35 entry.SetEnabled(enabled);
36
38 if (entryPreview)
39 entryPreview.SetPreviewItem(item);
40
41 return;
42 }
43
44 //------------------------------------------------------------------------------------------------
46 {
47 return m_iQuickSlotID;
48 }
49
50 //------------------------------------------------------------------------------------------------
51 void SetQuickSlotID(int id)
52 {
54 }
55
56 //------------------------------------------------------------------------------------------------
57 protected IEntity GetItem()
58 {
59 if (m_iQuickSlotID < 0)
60 return null;
61
62 if (!m_Storage)
63 return null;
64
65 array<ref SCR_QuickslotBaseContainer> quickSlotItems = m_Storage.GetQuickSlotItems();
66 if (quickSlotItems && m_iQuickSlotID < quickSlotItems.Count())
67 {
68 SCR_QuickslotEntityContainer entityContainer = SCR_QuickslotEntityContainer.Cast(quickSlotItems[m_iQuickSlotID]);
69 if (entityContainer)
70 return entityContainer.GetEntity();
71 }
72
73 return null;
74 }
75
76 //------------------------------------------------------------------------------------------------
78 override void OnPerform()
79 {
80 super.OnPerform();
81
82 IEntity item = GetItem();
83 if (item && m_Storage && m_Storage.CanUseItem(item))
84 m_Storage.UseItem(item);
85 }
86
87 //------------------------------------------------------------------------------------------------
88 protected UIInfo GetUIInfo(IEntity item)
89 {
90 if (!item)
91 return null;
92
94 if (!itemComponent)
95 return null;
96
97 return itemComponent.GetUIInfo();
98 }
99
100 //------------------------------------------------------------------------------------------------
102 {
103 m_Storage = storage;
104 m_iQuickSlotID = quickSlotID;
105
107
108 Enable(GetItem() != null);
109 }
110};
AddonBuildInfoTool id
void SCR_QuickslotEntityContainer(IEntity entity)
proto external Managed FindComponent(typename typeName)
override void Update()
int GetQuickSlotID()
override void OnPerform()
Callback for when this entry is supposed to be performed.
SCR_CharacterInventoryStorageComponent m_Storage
IEntity GetItem()
void SetQuickSlotID(int id)
const ResourceName LAYOUT_ITEM
void SCR_ItemSelectionMenuEntry(notnull SCR_CharacterInventoryStorageComponent storage, int quickSlotID)
UIInfo GetUIInfo(IEntity item)
int m_iQuickSlotID
void SetEnabled(bool enabled)
void SetName(string name)
void Enable(bool enable)
void SCR_SelectionMenuEntry()
SCR_SelectionMenuEntryComponent GetEntryComponent()
void SetCustomLayout(ResourceName layout)
void SetPreviewItem(IEntity item)
Prepare preview item and render given entity.
UIInfo - allows to define UI elements.
Definition UIInfo.c:14