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_PlayMenuComponent.c
Go to the documentation of this file.
1
class
SCR_PlayMenuComponent
:
ScriptedWidgetComponent
2
{
3
[
Attribute
(
"3"
)]
4
protected
int
m_iColumns
;
5
[
Attribute
(
"1"
)]
6
protected
int
m_iRows
;
7
8
protected
int
m_iItems
;
9
protected
int
m_iSelectedItem
;
10
11
[
Attribute
(
"2"
)]
12
protected
int
m_iPaddingHorizontal
;
13
[
Attribute
(
"2"
)]
14
protected
int
m_iPaddingVertical
;
15
16
[
Attribute
(
"{4FFBD0D5E9A5ED50}UI/layouts/Menus/PlayMenu/PlayMenuTile_Recent.layout"
,
UIWidgets
.ResourceNamePicker,
""
,
"layout"
)]
17
protected
ResourceName
m_sItemLayout
;
18
19
[
Attribute
(
"0.2"
)]
20
protected
float
m_fAnimationTime
;
21
22
protected
ref array<Widget>
m_aWidgets
= {};
23
protected
GridLayoutWidget
m_wContentRoot
;
24
protected
Widget
m_wRoot
;
25
protected
float
m_fAnimationRate
=
SCR_WLibComponentBase
.
START_ANIMATION_RATE
;
26
27
//------------------------------------------------------------------------------------------------
28
override
void
HandlerAttached
(
Widget
w)
29
{
30
m_wRoot
= w;
31
m_wContentRoot
=
GridLayoutWidget
.Cast(w.FindAnyWidget(
"Content"
));
32
33
if
(!
m_wContentRoot
)
34
return
;
35
36
m_iItems
=
m_iColumns
*
m_iRows
;
37
38
if
(
m_iItems
== 0)
39
return
;
40
41
// Convert time to animation speed
42
GetGame
().GetCallqueue().CallLater(
SetAnimationRate
,
SCR_WLibComponentBase
.
START_ANIMATION_PERIOD
);
43
44
CreateWidgets
(
m_iColumns
,
m_iRows
);
45
46
m_iSelectedItem
= 0;
47
SetFocusedItem
(
m_iSelectedItem
);
48
}
49
50
//------------------------------------------------------------------------------------------------
51
protected
void
CreateWidgets
(
int
columns,
int
rows)
52
{
53
if
(!
m_wContentRoot
)
54
return
;
55
56
// Delete old widgets
57
foreach
(
Widget
w:
m_aWidgets
)
58
{
59
if
(w)
60
w.RemoveFromHierarchy();
61
}
62
m_aWidgets
.Clear();
63
64
// Create new grid tile widgets
65
for
(
int
r = 0; r < rows; r++)
66
{
67
for
(
int
c = 0; c < columns; c++)
68
{
69
CreateWidget
(c, r);
70
}
71
}
72
}
73
74
//------------------------------------------------------------------------------------------------
75
protected
Widget
CreateWidget
(
int
column,
int
row)
76
{
77
if
(!
m_wContentRoot
)
78
return
null;
79
80
Widget
w =
GetGame
().GetWorkspace().CreateWidgets(
m_sItemLayout
,
m_wContentRoot
);
81
if
(!w)
82
return
null;
83
84
GridSlot
.SetColumn(w, column);
85
GridSlot
.SetRow(w, row);
86
m_wContentRoot
.SetRowFillWeight(row, 1);
87
m_wContentRoot
.SetColumnFillWeight(column, 1);
88
89
// Listen on focus event
90
SCR_EventHandlerComponent
comp =
SCR_EventHandlerComponent
.Cast(w.FindHandler(
SCR_EventHandlerComponent
));
91
if
(!comp)
92
{
93
comp =
new
SCR_EventHandlerComponent
();
94
w.AddHandler(comp);
95
}
96
comp.
GetOnFocus
().Insert(
OnItemFocused
);
97
98
// Check if root is actually a button
99
ButtonWidget
button =
ButtonWidget
.Cast(w);
100
101
if
(!button)
102
Print
(
"Gallery element root has to be a button, otherwise interactivity will not work"
,
LogLevel
.WARNING);
103
104
// Apply spacing
105
int
left, top, right, bottom;
106
107
if
(column > 0)
108
left =
m_iPaddingHorizontal
;
109
110
if
(column <
m_iColumns
- 1)
111
right =
m_iPaddingHorizontal
;
112
113
if
(row > 0)
114
top =
m_iPaddingVertical
;
115
116
if
(row <
m_iRows
- 1)
117
bottom =
m_iPaddingVertical
;
118
119
AlignableSlot
.SetPadding(w, left, top, right, bottom);
120
121
m_aWidgets
.Insert(w);
122
123
return
w;
124
}
125
126
//------------------------------------------------------------------------------------------------
127
protected
void
SetAnimationRate
()
128
{
129
if
(
m_fAnimationTime
<= 0)
130
m_fAnimationRate
= 1000;
131
else
132
m_fAnimationRate
= 1 /
m_fAnimationTime
;
133
}
134
135
//------------------------------------------------------------------------------------------------
136
void
OnItemFocused
(
Widget
w)
137
{
138
m_iSelectedItem
=
m_aWidgets
.Find(w);
139
}
140
141
//------------------------------------------------------------------------------------------------
142
void
SetFocusedItem
(
int
index
)
143
{
144
if
(!
m_aWidgets
.IsIndexValid(
index
))
145
return
;
146
147
Widget
w =
m_aWidgets
[
index
];
148
149
if
(!w.IsEnabled())
150
return
;
151
152
GetGame
().GetWorkspace().SetFocusedWidget(w);
153
m_iSelectedItem
=
index
;
154
}
155
156
//------------------------------------------------------------------------------------------------
157
array<Widget>
GetWidgets
()
158
{
159
return
m_aWidgets
;
160
}
161
162
//------------------------------------------------------------------------------------------------
165
static
SCR_PlayMenuComponent
GetComponent
(
string
name,
Widget
parent,
bool
searchAllChildren =
true
)
166
{
167
if
(!parent || name ==
string
.Empty)
168
return
null;
169
170
Widget
w;
171
if
(searchAllChildren)
172
w = parent.FindAnyWidget(name);
173
else
174
w = parent.FindWidget(name);
175
176
if
(!w)
177
return
null;
178
179
return
SCR_PlayMenuComponent
.Cast(w.FindHandler(
SCR_PlayMenuComponent
));
180
}
181
};
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition
SCR_DestructionSynchronizationComponent.c:17
AlignableSlot
Definition
AlignableSlot.c:13
ButtonWidget
Definition
ButtonWidget.c:16
GridLayoutWidget
Definition
GridLayoutWidget.c:16
GridSlot
Definition
GridSlot.c:13
ResourceName
Definition
ResourceName.c:13
SCR_EventHandlerComponent
Definition
SCR_EventHandlerComponent.c:9
SCR_EventHandlerComponent::GetOnFocus
ScriptInvoker GetOnFocus()
Definition
SCR_EventHandlerComponent.c:146
SCR_PlayMenuComponent
Definition
SCR_PlayMenuComponent.c:2
SCR_PlayMenuComponent::m_aWidgets
ref array< Widget > m_aWidgets
Definition
SCR_PlayMenuComponent.c:22
SCR_PlayMenuComponent::m_wRoot
Widget m_wRoot
Definition
SCR_PlayMenuComponent.c:24
SCR_PlayMenuComponent::m_fAnimationRate
float m_fAnimationRate
Definition
SCR_PlayMenuComponent.c:25
SCR_PlayMenuComponent::m_wContentRoot
GridLayoutWidget m_wContentRoot
Definition
SCR_PlayMenuComponent.c:23
SCR_PlayMenuComponent::SetAnimationRate
void SetAnimationRate()
Definition
SCR_PlayMenuComponent.c:127
SCR_PlayMenuComponent::CreateWidget
Widget CreateWidget(int column, int row)
Definition
SCR_PlayMenuComponent.c:75
SCR_PlayMenuComponent::m_sItemLayout
ResourceName m_sItemLayout
Definition
SCR_PlayMenuComponent.c:17
SCR_PlayMenuComponent::CreateWidgets
void CreateWidgets(int columns, int rows)
Definition
SCR_PlayMenuComponent.c:51
SCR_PlayMenuComponent::m_iPaddingVertical
int m_iPaddingVertical
Definition
SCR_PlayMenuComponent.c:14
SCR_PlayMenuComponent::m_iSelectedItem
int m_iSelectedItem
Definition
SCR_PlayMenuComponent.c:9
SCR_PlayMenuComponent::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_PlayMenuComponent.c:28
SCR_PlayMenuComponent::GetWidgets
array< Widget > GetWidgets()
Definition
SCR_PlayMenuComponent.c:157
SCR_PlayMenuComponent::m_fAnimationTime
float m_fAnimationTime
Definition
SCR_PlayMenuComponent.c:20
SCR_PlayMenuComponent::m_iItems
int m_iItems
Definition
SCR_PlayMenuComponent.c:8
SCR_PlayMenuComponent::m_iRows
int m_iRows
Definition
SCR_PlayMenuComponent.c:6
SCR_PlayMenuComponent::m_iColumns
int m_iColumns
Definition
SCR_PlayMenuComponent.c:4
SCR_PlayMenuComponent::OnItemFocused
void OnItemFocused(Widget w)
Definition
SCR_PlayMenuComponent.c:136
SCR_PlayMenuComponent::SetFocusedItem
void SetFocusedItem(int index)
Definition
SCR_PlayMenuComponent.c:142
SCR_PlayMenuComponent::m_iPaddingHorizontal
int m_iPaddingHorizontal
Definition
SCR_PlayMenuComponent.c:12
SCR_PlayMenuComponent::GetComponent
static SCR_PlayMenuComponent GetComponent(string name, Widget parent, bool searchAllChildren=true)
Definition
SCR_PlayMenuComponent.c:165
SCR_WLibComponentBase
Base class for all final Reforger interactive elements.
Definition
SCR_WLibComponentBase.c:9
SCR_WLibComponentBase::START_ANIMATION_PERIOD
static const float START_ANIMATION_PERIOD
Definition
SCR_WLibComponentBase.c:33
SCR_WLibComponentBase::START_ANIMATION_RATE
static const float START_ANIMATION_RATE
Definition
SCR_WLibComponentBase.c:32
ScriptedWidgetComponent
Definition
ScriptedWidgetComponent.c:13
UIWidgets
Definition
attributes.c:40
Widget
Definition
Widget.c:13
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
LogLevel
Enum with severity of the logging message.
Definition
LogLevel.c:14
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
scripts
Game
UI
Menu
PlayMenu
SCR_PlayMenuComponent.c
Generated by
1.17.0