Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_BaseGroup.c
Go to the documentation of this file.
1
//------------------------------------------------------------------------------------------------
4
class
SCR_BaseGroup
:
ScriptedSelectionMenuEntry
5
{
7
protected
IEntity
m_pOwner
;
9
protected
ref array<ref SCR_BaseGroupEntry>
m_aEntries
;
11
protected
int
m_iSelectedIndex
;
13
protected
SCR_BaseGroupEntry
m_pSelectedEntry
;
15
protected
BaseSelectionMenu
m_pSourceMenu
;
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
{
34
if
(
m_pSelectedEntry
)
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
{
47
if
(
m_pSelectedEntry
)
48
{
49
return
m_pSelectedEntry
.GetUIInfo();
50
}
51
52
return
null;
53
}
54
55
//------------------------------------------------------------------------------------------------
57
int
Count
() {
return
m_aEntries
.Count(); }
58
59
//------------------------------------------------------------------------------------------------
61
void
SelectNext
()
62
{
63
auto
index
=
m_iSelectedIndex
+1;
64
if
(
index
>
Count
() -1)
65
index
= 0;
66
67
Select
(
index
);
68
}
69
70
//------------------------------------------------------------------------------------------------
72
void
SelectPrevious
()
73
{
74
auto
index
=
m_iSelectedIndex
-1;
75
if
(
index
< 0)
76
index
=
Count
() - 1;
77
78
Select
(
index
);
79
}
80
81
//------------------------------------------------------------------------------------------------
84
void
Select
(
int
index
)
85
{
86
// Deselect selected item
87
if
(
index
== -1)
88
{
89
if
(
m_pSelectedEntry
)
90
m_pSelectedEntry
.OnDonePerform(
m_pOwner
,
m_pSourceMenu
);
91
92
93
m_pSelectedEntry
= null;
94
m_iSelectedIndex
= -1;
95
return
;
96
}
97
98
// Make sure selection is valid and not out of range
99
if
(
index < 0 || index >
Count
() -1)
100
return
;
101
102
// Try to actually select the entry
103
SCR_BaseGroupEntry
entry =
m_aEntries
[
index
];
104
if
(entry)
105
{
106
// Deselect previous entry
107
if
(
m_pSelectedEntry
&&
m_pSelectedEntry
!= entry)
108
{
109
m_pSelectedEntry
.OnDonePerform(
m_pOwner
,
m_pSourceMenu
);
110
m_pSelectedEntry
= null;
111
}
112
113
m_pSelectedEntry
= entry;
114
m_iSelectedIndex
=
index
;
115
}
116
}
117
119
protected
override
void
OnPerform
(
IEntity
user,
BaseSelectionMenu
sourceMenu)
120
{
121
if
(
m_pSelectedEntry
)
122
{
123
m_pSelectedEntry
.Perform(user, sourceMenu);
124
}
125
}
126
127
//------------------------------------------------------------------------------------------------
129
IEntity
GetOwner
() {
return
m_pOwner
; }
130
131
//------------------------------------------------------------------------------------------------
133
SCR_BaseGroupEntry
GetSelectedEntry
() {
return
m_pSelectedEntry
; }
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
};
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition
SCR_DestructionSynchronizationComponent.c:17
BaseSelectionMenu
Definition
BaseSelectionMenu.c:13
IEntity
Definition
IEntity.c:13
SCR_BaseGroupEntry
An abstract wrapper to provide common interface for items that can be stored in a BaseGroup.
Definition
SCR_BaseGroupEntry.c:4
SCR_BaseGroup::m_pSelectedEntry
SCR_BaseGroupEntry m_pSelectedEntry
Currently selected entry or null if none.
Definition
SCR_BaseGroup.c:13
SCR_BaseGroup::GetEntryNameScript
override bool GetEntryNameScript(out string outName)
Definition
SCR_BaseGroup.c:32
SCR_BaseGroup::SelectNext
void SelectNext()
Select next item.
Definition
SCR_BaseGroup.c:61
SCR_BaseGroup::CanBePerformedScript
override bool CanBePerformedScript(IEntity user, BaseSelectionMenu sourceMenu)
Can this entry be performed?
Definition
SCR_BaseGroup.c:19
SCR_BaseGroup::Count
int Count()
How many items this group contains.
Definition
SCR_BaseGroup.c:57
SCR_BaseGroup::SCR_BaseGroup
void SCR_BaseGroup(IEntity owner, array< ref SCR_BaseGroupEntry > entries)
Create a group with provided entries.
Definition
SCR_BaseGroup.c:137
SCR_BaseGroup::GetOwner
IEntity GetOwner()
Return the owner of this group.
Definition
SCR_BaseGroup.c:129
SCR_BaseGroup::m_aEntries
ref array< ref SCR_BaseGroupEntry > m_aEntries
List of all entries in this group.
Definition
SCR_BaseGroup.c:9
SCR_BaseGroup::m_pSourceMenu
BaseSelectionMenu m_pSourceMenu
The menu we belong to.
Definition
SCR_BaseGroup.c:15
SCR_BaseGroup::SelectPrevious
void SelectPrevious()
Select next item.
Definition
SCR_BaseGroup.c:72
SCR_BaseGroup::m_pOwner
IEntity m_pOwner
Owner of this group.
Definition
SCR_BaseGroup.c:7
SCR_BaseGroup::GetUIInfoScript
override UIInfo GetUIInfoScript()
Definition
SCR_BaseGroup.c:45
SCR_BaseGroup::OnPerform
override void OnPerform(IEntity user, BaseSelectionMenu sourceMenu)
Callback for when this entry is supposed to be performed.
Definition
SCR_BaseGroup.c:119
SCR_BaseGroup::m_iSelectedIndex
int m_iSelectedIndex
Currently selected entry or -1 if none.
Definition
SCR_BaseGroup.c:11
SCR_BaseGroup::GetSelectedEntry
SCR_BaseGroupEntry GetSelectedEntry()
Return the currently selected item.
Definition
SCR_BaseGroup.c:133
SCR_BaseGroup::Select
void Select(int index)
Definition
SCR_BaseGroup.c:84
ScriptedSelectionMenuEntry
Definition
ScriptedSelectionMenuEntry.c:2
UIInfo
UIInfo - allows to define UI elements.
Definition
UIInfo.c:14
scripts
Game
ItemSelection
SCR_BaseGroup.c
Generated by
1.17.0