Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ItemSelectionMenuEntry.c
Go to the documentation of this file.
2 {
3  protected const ResourceName LAYOUT_ITEM = "{93472DECDA62C46F}UI/layouts/Common/RadialMenu/SelectionMenuEntryPreview.layout";
4  protected SCR_CharacterInventoryStorageComponent m_Storage;
5  protected int m_iQuickSlotID = -1;
6 
7  //------------------------------------------------------------------------------------------------
8  override void Update()
9  {
10  SCR_SelectionMenuEntryComponent entry = GetEntryComponent();
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  //------------------------------------------------------------------------------------------------
45  int GetQuickSlotID()
46  {
47  return m_iQuickSlotID;
48  }
49 
50  //------------------------------------------------------------------------------------------------
51  void SetQuickSlotID(int id)
52  {
53  m_iQuickSlotID = id;
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<IEntity> quickSlotItems = m_Storage.GetQuickSlotItems();
66  if (quickSlotItems && m_iQuickSlotID < quickSlotItems.Count())
67  return quickSlotItems[m_iQuickSlotID];
68 
69  return null;
70  }
71 
72  //------------------------------------------------------------------------------------------------
74  override void OnPerform()
75  {
76  super.OnPerform();
77 
78  IEntity item = GetItem();
79  if (item && m_Storage && m_Storage.CanUseItem(item))
80  m_Storage.UseItem(item);
81  }
82 
83  //------------------------------------------------------------------------------------------------
84  protected UIInfo GetUIInfo(IEntity item)
85  {
86  if (!item)
87  return null;
88 
89  InventoryItemComponent itemComponent = InventoryItemComponent.Cast(item.FindComponent(InventoryItemComponent));
90  if (!itemComponent)
91  return null;
92 
93  return itemComponent.GetUIInfo();
94  }
95 
96  //------------------------------------------------------------------------------------------------
97  void SCR_ItemSelectionMenuEntry(notnull SCR_CharacterInventoryStorageComponent storage, int quickSlotID)
98  {
99  m_Storage = storage;
100  m_iQuickSlotID = quickSlotID;
101 
102  SetCustomLayout(LAYOUT_ITEM);
103 
104  Enable(GetItem() != null);
105  }
106 };
UIInfo
UIInfo - declare object, allows to define UI elements.
Definition: UIInfo.c:13
Enable
void Enable(bool enable)
Definition: SCR_TabViewComponent.c:806
SCR_SelectionMenuEntryComponent
Definition: SCR_SelectionMenuEntryComponent.c:6
InventoryItemComponent
Definition: InventoryItemComponent.c:12
SCR_ItemSelectionMenuEntry
Definition: SCR_ItemSelectionMenuEntry.c:1
SCR_SelectionMenuEntry
Definition: SCR_SelectionMenuEntry.c:7
m_Storage
BaseInventoryStorageComponent m_Storage
Definition: SCR_TourniquetStorageComponent.c:10
SCR_SelectionMenuEntryPreviewComponent
Definition: SCR_SelectionMenuEntryPreviewComponent.c:6