Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_BaseGroup.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
5{
7 protected IEntity m_pOwner;
9 protected ref array<ref SCR_BaseGroupEntry> m_aEntries;
11 protected int m_iSelectedIndex;
16
17 //------------------------------------------------------------------------------------------------
19 protected override bool CanBePerformedScript(IEntity user, BaseSelectionMenu sourceMenu)
20 {
21 // TODO: Define actual logic?
22 if (m_iSelectedIndex < 0)
23 return false;
24
25 if (m_iSelectedIndex > Count() - 1)
26 return false;
27
28 return m_aEntries[m_iSelectedIndex].CanBePerformed(user, sourceMenu);
29 }
30
31 //------------------------------------------------------------------------------------------------
32 protected override bool GetEntryNameScript(out string outName)
33 {
35 {
36 outName = m_pSelectedEntry.GetEntryName();
37 return true;
38 }
39
40 outName = "Empty";
41 return true;
42 }
43
44 //------------------------------------------------------------------------------------------------
45 protected override UIInfo GetUIInfoScript()
46 {
48 {
49 return m_pSelectedEntry.GetUIInfo();
50 }
51
52 return null;
53 }
54
55 //------------------------------------------------------------------------------------------------
57 int Count() { return m_aEntries.Count(); }
58
59 //------------------------------------------------------------------------------------------------
62 {
63 auto index = m_iSelectedIndex+1;
64 if (index > Count() -1)
65 index = 0;
66
68 }
69
70 //------------------------------------------------------------------------------------------------
73 {
74 auto index = m_iSelectedIndex-1;
75 if (index < 0)
76 index = Count() - 1;
77
79 }
80
81 //------------------------------------------------------------------------------------------------
84 void Select(int index)
85 {
86 // Deselect selected item
87 if (index == -1)
88 {
91
92
93 m_pSelectedEntry = null;
95 return;
96 }
97
98 // Make sure selection is valid and not out of range
100 return;
101
102 // Try to actually select the entry
104 if (entry)
105 {
106 // Deselect previous entry
107 if (m_pSelectedEntry && m_pSelectedEntry != entry)
108 {
110 m_pSelectedEntry = null;
111 }
112
113 m_pSelectedEntry = entry;
115 }
116 }
117
119 protected override void OnPerform(IEntity user, BaseSelectionMenu sourceMenu)
120 {
122 {
123 m_pSelectedEntry.Perform(user, sourceMenu);
124 }
125 }
126
127 //------------------------------------------------------------------------------------------------
130
131 //------------------------------------------------------------------------------------------------
134
135 //------------------------------------------------------------------------------------------------
137 void SCR_BaseGroup(IEntity owner, array<ref SCR_BaseGroupEntry> entries)
138 {
139 // Assign the owner entity
140 m_pOwner = owner;
141
142 // Prepare array and set all the entries
143 m_aEntries = new array<ref SCR_BaseGroupEntry>();
144 foreach (auto entry : entries)
145 m_aEntries.Insert(entry);
146 }
147};
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
An abstract wrapper to provide common interface for items that can be stored in a BaseGroup.
SCR_BaseGroupEntry m_pSelectedEntry
Currently selected entry or null if none.
override bool GetEntryNameScript(out string outName)
void SelectNext()
Select next item.
override bool CanBePerformedScript(IEntity user, BaseSelectionMenu sourceMenu)
Can this entry be performed?
int Count()
How many items this group contains.
void SCR_BaseGroup(IEntity owner, array< ref SCR_BaseGroupEntry > entries)
Create a group with provided entries.
IEntity GetOwner()
Return the owner of this group.
ref array< ref SCR_BaseGroupEntry > m_aEntries
List of all entries in this group.
BaseSelectionMenu m_pSourceMenu
The menu we belong to.
void SelectPrevious()
Select next item.
IEntity m_pOwner
Owner of this group.
override UIInfo GetUIInfoScript()
override void OnPerform(IEntity user, BaseSelectionMenu sourceMenu)
Callback for when this entry is supposed to be performed.
int m_iSelectedIndex
Currently selected entry or -1 if none.
SCR_BaseGroupEntry GetSelectedEntry()
Return the currently selected item.
void Select(int index)
UIInfo - allows to define UI elements.
Definition UIInfo.c:14