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_SpinBoxPaging.c
Go to the documentation of this file.
1
//------------------------------------------------------------------------------------------------
2
class
SCR_SpinBoxPagingComponent
:
SCR_WLibComponentBase
3
{
4
[
Attribute
(
"MenuTabRight"
)]
5
protected
string
m_sLeftAction
;
6
7
[
Attribute
(
"MenuTabLeft"
)]
8
protected
string
m_sRightAction
;
9
10
//---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
11
// Why is this even an attribute? Why is this string not localized?
12
13
[
Attribute
(
"%1 / %2"
,
UIWidgets
.Auto,
"Text which will be visualized. %1 contains the actual page and %2 total pages"
)]
14
protected
string
m_sText
;
15
16
//---- REFACTOR NOTE END ----
17
18
[
Attribute
()]
19
ref array<string>
m_aElementNames
;
20
21
[
Attribute
()]
22
protected
int
m_iPageCount
;
23
24
[
Attribute
()]
25
protected
int
m_iPageCurrent
;
26
27
[
Attribute
()]
28
bool
m_bCycleMode
;
29
30
//---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
31
// Unused
32
33
protected
bool
m_bEnabled
=
true
;
34
protected
bool
m_bCanNavigate
=
true
;
35
36
//---- REFACTOR NOTE END ----
37
38
protected
TextWidget
m_wText
;
39
40
protected
SCR_PagingButtonComponent
m_ButtonLeft
;
41
protected
SCR_PagingButtonComponent
m_ButtonRight
;
42
43
ref
ScriptInvoker
m_OnChanged
=
new
ScriptInvoker
();
44
45
//------------------------------------------------------------------------------------------------
46
override
void
HandlerAttached
(
Widget
w)
47
{
48
super.HandlerAttached(w);
49
50
m_wText
=
TextWidget
.Cast(
m_wRoot
.FindAnyWidget(
"Text"
));
51
52
m_ButtonLeft
=
SCR_PagingButtonComponent
.
GetPagingButtonComponent
(
"ButtonLeft"
, w);
53
if
(
m_ButtonLeft
)
54
{
55
m_ButtonLeft
.m_OnActivated.Insert(
OnButtonLeft
);
56
m_ButtonLeft
.SetAction(
m_sLeftAction
);
57
}
58
59
m_ButtonRight
=
SCR_PagingButtonComponent
.
GetPagingButtonComponent
(
"ButtonRight"
, w);
60
if
(
m_ButtonRight
)
61
{
62
m_ButtonRight
.m_OnActivated.Insert(
OnButtonRight
);
63
m_ButtonRight
.SetAction(
m_sRightAction
);
64
}
65
66
m_iPageCurrent
=
Math
.Clamp(
m_iPageCurrent
, 0,
m_iPageCount
- 1);
67
if
(
m_iPageCurrent
< -1)
68
m_iPageCurrent
= 0;
69
70
UpdateTextAndButtons
(
false
);
71
}
72
73
//------------------------------------------------------------------------------------------------
74
protected
void
OnButtonLeft
()
75
{
76
if
(
m_ButtonLeft
.IsEnabled())
77
SetCurrentItem
(
m_iPageCurrent
- 1);
78
}
79
80
//------------------------------------------------------------------------------------------------
81
protected
void
OnButtonRight
()
82
{
83
if
(
m_ButtonRight
.IsEnabled())
84
SetCurrentItem
(
m_iPageCurrent
+ 1);
85
}
86
87
//------------------------------------------------------------------------------------------------
88
protected
void
UpdateTextAndButtons
(
bool
animate =
true
)
89
{
90
bool
disableLeft, disableRight;
91
92
if
(
m_iPageCount
< 2)
93
{
94
disableLeft =
true
;
95
disableRight =
true
;
96
}
97
else
if
(!
m_bCycleMode
)
98
{
99
if
(
m_iPageCurrent
<= 0)
100
disableLeft =
true
;
101
else
if
(
m_iPageCurrent
>=
m_iPageCount
-1)
102
disableRight =
true
;
103
}
104
105
if
(
m_ButtonLeft
)
106
m_ButtonLeft
.SetEnabled(!disableLeft, animate);
107
108
if
(
m_ButtonRight
)
109
m_ButtonRight
.SetEnabled(!disableRight, animate);
110
111
// Change text
112
if
(!
m_wText
)
113
return
;
114
115
int
currentPage =
Math
.Min(
m_iPageCurrent
+ 1,
m_iPageCount
);
116
m_wText
.SetTextFormat(
m_sText
, currentPage,
m_iPageCount
);
117
}
118
119
//------------------------------------------------------------------------------------------------
120
void
SetCurrentItem
(
int
page,
bool
invokeChange =
true
)
121
{
122
if
(
m_iPageCurrent
== page)
123
return
;
124
125
if
(page < 0 || page >=
m_iPageCount
)
126
{
127
if
(
m_bCycleMode
)
128
{
129
if
(page == -1)
130
page =
m_iPageCount
- 1;
131
else
132
page = 0;
133
}
134
else
135
{
136
return
;
137
}
138
}
139
140
m_iPageCurrent
= page;
141
UpdateTextAndButtons
();
142
143
// Invoke change
144
if
(invokeChange)
145
m_OnChanged
.Invoke(
this
, page);
146
}
147
148
//------------------------------------------------------------------------------------------------
149
void
SetPageCount
(
int
count,
bool
animate =
true
)
150
{
151
if
(count == 0 || count == 1)
152
AnimateWidget
.
Opacity
(
m_wRoot
, 0,
UIConstants
.FADE_RATE_DEFAULT);
153
else
154
AnimateWidget
.
Opacity
(
m_wRoot
, 1,
UIConstants
.FADE_RATE_DEFAULT);
155
156
if
(count ==
m_iPageCount
)
157
return
;
158
159
m_iPageCount
=
Math
.Max(count, 0);
160
if
(
m_iPageCurrent
>=
m_iPageCount
)
161
SetCurrentItem
(
m_iPageCount
- 1);
162
163
UpdateTextAndButtons
(animate);
164
}
165
166
//------------------------------------------------------------------------------------------------
167
int
GetPageCount
()
168
{
169
return
m_iPageCount
;
170
}
171
172
//------------------------------------------------------------------------------------------------
173
int
GetCurrentIndex
()
174
{
175
return
m_iPageCurrent
;
176
}
177
178
//------------------------------------------------------------------------------------------------
179
void
SetCanNavigate
(
bool
enable)
180
{
181
if
(
m_ButtonLeft
)
182
m_ButtonLeft
.SetEnabled(enable);
183
184
if
(
m_ButtonRight
)
185
m_ButtonRight
.SetEnabled(enable);
186
}
187
188
//------------------------------------------------------------------------------------------------
189
void
SetButtonsVisible
(
bool
visible)
190
{
191
if
(
m_ButtonLeft
)
192
m_ButtonLeft
.SetVisible(visible);
193
194
if
(
m_ButtonRight
)
195
m_ButtonRight
.SetVisible(visible);
196
}
197
198
//------------------------------------------------------------------------------------------------
199
void
SetButtonsActive
(
bool
active)
200
{
201
if
(
m_ButtonLeft
)
202
{
203
m_ButtonLeft
.m_OnActivated.Remove(
OnButtonLeft
);
204
if
(active)
205
m_ButtonLeft
.m_OnActivated.Insert(
OnButtonLeft
);
206
}
207
208
if
(
m_ButtonRight
)
209
{
210
m_ButtonRight
.m_OnActivated.Remove(
OnButtonRight
);
211
if
(active)
212
m_ButtonRight
.m_OnActivated.Insert(
OnButtonRight
);
213
}
214
}
215
216
//------------------------------------------------------------------------------------------------
219
static
SCR_SpinBoxPagingComponent
GetSpinBoxPagingComponent
(
string
name,
Widget
parent,
bool
searchAllChildren =
true
)
220
{
221
auto
comp =
SCR_SpinBoxPagingComponent
.Cast(
222
SCR_WLibComponentBase
.GetComponent(
SCR_SpinBoxPagingComponent
, name, parent, searchAllChildren)
223
);
224
return
comp;
225
}
226
};
AnimateWidget
Definition
AnimateWidget.c:3
AnimateWidget::Opacity
static WidgetAnimationOpacity Opacity(Widget widget, float targetValue, float speed, bool toggleVisibility=false)
Definition
AnimateWidget.c:167
Math
Definition
Math.c:13
SCR_PagingButtonComponent
Definition
SCR_PagingButtonComponent.c:3
SCR_PagingButtonComponent::GetPagingButtonComponent
static SCR_PagingButtonComponent GetPagingButtonComponent(string name, Widget parent, bool searchAllChildren=true)
Definition
SCR_PagingButtonComponent.c:197
SCR_ScriptedWidgetComponent::m_wRoot
Widget m_wRoot
Definition
SCR_ScriptedWidgetComponent.c:9
SCR_SpinBoxPagingComponent
Definition
SCR_SpinBoxPaging.c:3
SCR_SpinBoxPagingComponent::m_bCycleMode
bool m_bCycleMode
Definition
SCR_SpinBoxPaging.c:28
SCR_SpinBoxPagingComponent::UpdateTextAndButtons
void UpdateTextAndButtons(bool animate=true)
Definition
SCR_SpinBoxPaging.c:88
SCR_SpinBoxPagingComponent::m_ButtonLeft
SCR_PagingButtonComponent m_ButtonLeft
Definition
SCR_SpinBoxPaging.c:40
SCR_SpinBoxPagingComponent::m_wText
TextWidget m_wText
Definition
SCR_SpinBoxPaging.c:38
SCR_SpinBoxPagingComponent::GetPageCount
int GetPageCount()
Definition
SCR_SpinBoxPaging.c:167
SCR_SpinBoxPagingComponent::SetButtonsVisible
void SetButtonsVisible(bool visible)
Definition
SCR_SpinBoxPaging.c:189
SCR_SpinBoxPagingComponent::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_SpinBoxPaging.c:46
SCR_SpinBoxPagingComponent::m_sRightAction
string m_sRightAction
Definition
SCR_SpinBoxPaging.c:8
SCR_SpinBoxPagingComponent::OnButtonLeft
void OnButtonLeft()
Definition
SCR_SpinBoxPaging.c:74
SCR_SpinBoxPagingComponent::m_ButtonRight
SCR_PagingButtonComponent m_ButtonRight
Definition
SCR_SpinBoxPaging.c:41
SCR_SpinBoxPagingComponent::m_iPageCount
int m_iPageCount
Definition
SCR_SpinBoxPaging.c:22
SCR_SpinBoxPagingComponent::SetButtonsActive
void SetButtonsActive(bool active)
Definition
SCR_SpinBoxPaging.c:199
SCR_SpinBoxPagingComponent::m_OnChanged
ref ScriptInvoker m_OnChanged
Definition
SCR_SpinBoxPaging.c:43
SCR_SpinBoxPagingComponent::GetCurrentIndex
int GetCurrentIndex()
Definition
SCR_SpinBoxPaging.c:173
SCR_SpinBoxPagingComponent::OnButtonRight
void OnButtonRight()
Definition
SCR_SpinBoxPaging.c:81
SCR_SpinBoxPagingComponent::m_iPageCurrent
int m_iPageCurrent
Definition
SCR_SpinBoxPaging.c:25
SCR_SpinBoxPagingComponent::m_sLeftAction
string m_sLeftAction
Definition
SCR_SpinBoxPaging.c:5
SCR_SpinBoxPagingComponent::m_bCanNavigate
bool m_bCanNavigate
Definition
SCR_SpinBoxPaging.c:34
SCR_SpinBoxPagingComponent::SetCanNavigate
void SetCanNavigate(bool enable)
Definition
SCR_SpinBoxPaging.c:179
SCR_SpinBoxPagingComponent::m_sText
string m_sText
Definition
SCR_SpinBoxPaging.c:14
SCR_SpinBoxPagingComponent::SetCurrentItem
void SetCurrentItem(int page, bool invokeChange=true)
Definition
SCR_SpinBoxPaging.c:120
SCR_SpinBoxPagingComponent::m_aElementNames
ref array< string > m_aElementNames
Definition
SCR_SpinBoxPaging.c:19
SCR_SpinBoxPagingComponent::SetPageCount
void SetPageCount(int count, bool animate=true)
Definition
SCR_SpinBoxPaging.c:149
SCR_SpinBoxPagingComponent::m_bEnabled
bool m_bEnabled
Definition
SCR_SpinBoxPaging.c:33
SCR_SpinBoxPagingComponent::GetSpinBoxPagingComponent
static SCR_SpinBoxPagingComponent GetSpinBoxPagingComponent(string name, Widget parent, bool searchAllChildren=true)
Definition
SCR_SpinBoxPaging.c:219
SCR_WLibComponentBase
Base class for all final Reforger interactive elements.
Definition
SCR_WLibComponentBase.c:9
TextWidget
Definition
TextWidget.c:16
UIConstants
Definition
Constants.c:151
UIWidgets
Definition
attributes.c:40
Widget
Definition
Widget.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
ScriptInvoker
ScriptInvokerBase< func > ScriptInvoker
Definition
tools.c:134
scripts
Game
UI
Components
WidgetLibrary
SCR_Slider
SCR_SpinBoxPaging.c
Generated by
1.17.0