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_PagingButtonComponent.c
Go to the documentation of this file.
1
//------------------------------------------------------------------------------------------------
2
class
SCR_PagingButtonComponent
:
SCR_ButtonBaseComponent
3
{
4
[
Attribute
()]
5
protected
bool
m_bIsPositive
;
6
7
[
Attribute
(
"false"
,
UIWidgets
.Auto,
"Use action hint instead of an image"
)]
8
bool
m_bUseActionHint
;
9
10
[
Attribute
(
"MenuSearch"
)]
11
string
m_sActionName
;
12
13
protected
string
m_sBackgroundImageName
=
"BackgroundImage"
;
14
protected
string
m_sFrontImageName
=
"Panel"
;
15
protected
string
m_sActionTextName
=
"ActionText"
;
16
17
protected
ImageWidget
m_wPanel
;
18
protected
TextWidget
m_wText
;
19
protected
Widget
m_wBackgroundImage
;
20
21
ref
ScriptInvoker
m_OnActivated
=
new
ScriptInvoker
();
// Returns -1 if negative, 1 if positive
22
23
//------------------------------------------------------------------------------------------------
24
override
void
HandlerAttached
(
Widget
w)
25
{
26
super.HandlerAttached(w);
27
28
m_wBackgroundImage
= w.FindAnyWidget(
m_sBackgroundImageName
);
29
m_wPanel
=
ImageWidget
.Cast(w.FindAnyWidget(
m_sFrontImageName
));
30
m_wText
=
TextWidget
.Cast(w.FindAnyWidget(
m_sActionTextName
));
31
32
if
(
m_wPanel
)
33
m_wPanel
.SetVisible(!
m_bUseActionHint
);
34
35
if
(
m_wBackgroundImage
)
36
{
37
m_wBackgroundImage
.SetVisible(!
m_bUseActionHint
);
38
m_wBackgroundImage
.SetColor(
m_BackgroundDefault
);
39
}
40
41
if
(
m_wText
)
42
{
43
m_wText
.SetVisible(
m_bUseActionHint
);
44
if
(
m_bUseActionHint
)
45
{
46
m_wText
.SetTextFormat(
"<action name='%1' scale='1.5'/>"
,
m_sActionName
);
47
}
48
}
49
50
SetAction
(
m_sActionName
);
51
52
FlipImage
(!
m_bIsPositive
);
53
}
54
55
//------------------------------------------------------------------------------------------------
56
override
bool
OnClick
(
Widget
w,
int
x,
int
y,
int
button)
57
{
58
super.OnClick(w, x, y, button);
59
60
if
(button != 0)
61
return
false
;
62
63
if
(
m_bIsPositive
)
64
m_OnActivated
.Invoke(
m_wRoot
, 1);
65
else
66
m_OnActivated
.Invoke(
m_wRoot
, -1);
67
68
return
false
;
69
}
70
71
//------------------------------------------------------------------------------------------------
72
protected
void
FlipImage
(
bool
flip)
73
{
74
if
(!
m_wPanel
|| !
m_wBackgroundImage
)
75
return
;
76
77
if
(flip)
78
{
79
m_wPanel
.SetFlags(
WidgetFlags
.FLIPU);
80
m_wBackgroundImage
.SetFlags(
WidgetFlags
.FLIPU);
81
}
82
else
83
{
84
m_wPanel
.ClearFlags(
WidgetFlags
.FLIPU);
85
m_wBackgroundImage
.ClearFlags(
WidgetFlags
.FLIPU);
86
}
87
}
88
89
//------------------------------------------------------------------------------------------------
90
override
protected
void
OnMenuSelect
()
91
{
92
MenuSelectBase
();
93
if
(!
m_wRoot
.IsEnabled())
94
return
;
95
96
// Bail if attached to menu but menu is not focused
97
if
(!
IsParentMenuFocused
())
98
return
;
99
100
if
(
m_bIsPositive
)
101
m_OnActivated
.Invoke(
m_wRoot
, 1);
102
else
103
m_OnActivated
.Invoke(
m_wRoot
, -1);
104
}
105
106
//------------------------------------------------------------------------------------------------
107
override
void
SetEnabled
(
bool
enabled,
bool
animate =
true
)
108
{
109
super.SetEnabled(enabled, animate);
110
if
(
m_wBackgroundImage
&& !
m_bUseActionHint
)
111
m_wBackgroundImage
.SetVisible(enabled);
112
}
113
114
// User API
115
//------------------------------------------------------------------------------------------------
116
bool
IsPositive
()
117
{
118
return
m_bIsPositive
;
119
}
120
121
//------------------------------------------------------------------------------------------------
122
void
SetPositive
(
bool
positive)
123
{
124
m_bIsPositive
= positive;
125
}
126
127
//------------------------------------------------------------------------------------------------
128
void
SetAction
(
string
name)
129
{
130
if
(!
m_wText
)
131
return
;
132
133
GetGame
().GetInputManager().RemoveActionListener(
m_sActionName
,
EActionTrigger
.DOWN,
OnMenuSelect
);
134
m_sActionName
= name;
135
136
// Handle case of empty action
137
name = name.Trim();
138
if
(name ==
string
.Empty)
139
{
140
if
(
m_wText
)
141
m_wText
.SetText(
" "
);
142
}
143
else
144
{
145
GetGame
().GetInputManager().AddActionListener(
m_sActionName
,
EActionTrigger
.DOWN,
OnMenuSelect
);
146
147
//---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
148
// Hardcoded scale. Baaaaaaaaaad
149
150
m_wText
.SetTextFormat(
"<action name='%1' scale='1.5'/>"
,
m_sActionName
);
151
152
//---- REFACTOR NOTE END ----
153
}
154
}
155
156
//------------------------------------------------------------------------------------------------
157
override
bool
OnMouseEnter
(
Widget
w,
int
x,
int
y)
158
{
159
super.OnMouseEnter(w, x, y);
160
161
if
(!
m_bUseColorization
)
162
return
false
;
163
164
PlaySound
(
m_sSoundHovered
);
165
166
if
(
m_bUseActionHint
)
167
AnimateWidget
.
Color
(
m_wText
,
m_BackgroundHovered
,
m_fAnimationRate
);
168
else
169
AnimateWidget
.
Color
(
m_wBackgroundImage
,
m_BackgroundHovered
,
m_fAnimationRate
);
170
171
return
false
;
172
}
173
174
//------------------------------------------------------------------------------------------------
175
override
bool
OnMouseLeave
(
Widget
w,
Widget
enterW,
int
x,
int
y)
176
{
177
super.OnMouseLeave(w, enterW, x, y);
178
179
if
(!
m_bUseColorization
)
180
return
false
;
181
182
if
(
m_bUseActionHint
)
183
AnimateWidget
.
Color
(
m_wText
,
m_BackgroundDefault
,
m_fAnimationRate
);
184
else
185
AnimateWidget
.
Color
(
m_wBackgroundImage
,
m_BackgroundDefault
,
m_fAnimationRate
);
186
187
return
false
;
188
}
189
190
//------------------------------------------------------------------------------------------------
191
string
GetAction
()
192
{
193
return
m_sActionName
;
194
}
195
196
//------------------------------------------------------------------------------------------------
197
static
SCR_PagingButtonComponent
GetPagingButtonComponent
(
string
name,
Widget
parent,
bool
searchAllChildren =
true
)
198
{
199
return
SCR_PagingButtonComponent
.Cast(
SCR_PagingButtonComponent
.GetComponent(
SCR_ButtonBaseComponent
, name, parent, searchAllChildren));
200
}
201
};
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
AnimateWidget
Definition
AnimateWidget.c:3
AnimateWidget::Color
static WidgetAnimationColor Color(Widget widget, Color color, float speed)
Definition
AnimateWidget.c:200
ImageWidget
Definition
ImageWidget.c:13
SCR_ButtonBaseComponent
Base class for any button, regardless its own content.
Definition
SCR_ButtonBaseComponent.c:7
SCR_ButtonBaseComponent::m_BackgroundDefault
ref Color m_BackgroundDefault
Definition
SCR_ButtonBaseComponent.c:18
SCR_ButtonBaseComponent::m_BackgroundHovered
ref Color m_BackgroundHovered
Definition
SCR_ButtonBaseComponent.c:21
SCR_ButtonBaseComponent::MenuSelectBase
void MenuSelectBase()
Definition
SCR_ButtonBaseComponent.c:211
SCR_ButtonBaseComponent::m_bUseColorization
bool m_bUseColorization
Definition
SCR_ButtonBaseComponent.c:15
SCR_ButtonBaseComponent::IsParentMenuFocused
bool IsParentMenuFocused()
Returns true if parent menu is focused, or if there is no parent menu.
Definition
SCR_ButtonBaseComponent.c:366
SCR_PagingButtonComponent
Definition
SCR_PagingButtonComponent.c:3
SCR_PagingButtonComponent::OnClick
override bool OnClick(Widget w, int x, int y, int button)
Definition
SCR_PagingButtonComponent.c:56
SCR_PagingButtonComponent::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_PagingButtonComponent.c:24
SCR_PagingButtonComponent::m_wBackgroundImage
Widget m_wBackgroundImage
Definition
SCR_PagingButtonComponent.c:19
SCR_PagingButtonComponent::SetAction
void SetAction(string name)
Definition
SCR_PagingButtonComponent.c:128
SCR_PagingButtonComponent::m_wText
TextWidget m_wText
Definition
SCR_PagingButtonComponent.c:18
SCR_PagingButtonComponent::m_sActionTextName
string m_sActionTextName
Definition
SCR_PagingButtonComponent.c:15
SCR_PagingButtonComponent::SetEnabled
override void SetEnabled(bool enabled, bool animate=true)
Definition
SCR_PagingButtonComponent.c:107
SCR_PagingButtonComponent::IsPositive
bool IsPositive()
Definition
SCR_PagingButtonComponent.c:116
SCR_PagingButtonComponent::m_bUseActionHint
bool m_bUseActionHint
Definition
SCR_PagingButtonComponent.c:8
SCR_PagingButtonComponent::GetAction
string GetAction()
Definition
SCR_PagingButtonComponent.c:191
SCR_PagingButtonComponent::OnMouseLeave
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Definition
SCR_PagingButtonComponent.c:175
SCR_PagingButtonComponent::SetPositive
void SetPositive(bool positive)
Definition
SCR_PagingButtonComponent.c:122
SCR_PagingButtonComponent::OnMouseEnter
override bool OnMouseEnter(Widget w, int x, int y)
Definition
SCR_PagingButtonComponent.c:157
SCR_PagingButtonComponent::m_OnActivated
ref ScriptInvoker m_OnActivated
Definition
SCR_PagingButtonComponent.c:21
SCR_PagingButtonComponent::m_sBackgroundImageName
string m_sBackgroundImageName
Definition
SCR_PagingButtonComponent.c:13
SCR_PagingButtonComponent::FlipImage
void FlipImage(bool flip)
Definition
SCR_PagingButtonComponent.c:72
SCR_PagingButtonComponent::OnMenuSelect
void OnMenuSelect()
Definition
SCR_PagingButtonComponent.c:90
SCR_PagingButtonComponent::m_sFrontImageName
string m_sFrontImageName
Definition
SCR_PagingButtonComponent.c:14
SCR_PagingButtonComponent::m_wPanel
ImageWidget m_wPanel
Definition
SCR_PagingButtonComponent.c:17
SCR_PagingButtonComponent::m_sActionName
string m_sActionName
Definition
SCR_PagingButtonComponent.c:11
SCR_PagingButtonComponent::GetPagingButtonComponent
static SCR_PagingButtonComponent GetPagingButtonComponent(string name, Widget parent, bool searchAllChildren=true)
Definition
SCR_PagingButtonComponent.c:197
SCR_PagingButtonComponent::m_bIsPositive
bool m_bIsPositive
Definition
SCR_PagingButtonComponent.c:5
SCR_ScriptedWidgetComponent::m_wRoot
Widget m_wRoot
Definition
SCR_ScriptedWidgetComponent.c:9
SCR_WLibComponentBase::m_fAnimationRate
float m_fAnimationRate
Definition
SCR_WLibComponentBase.c:28
SCR_WLibComponentBase::PlaySound
void PlaySound(string sound)
Definition
SCR_WLibComponentBase.c:123
SCR_WLibComponentBase::m_sSoundHovered
string m_sSoundHovered
Definition
SCR_WLibComponentBase.c:11
TextWidget
Definition
TextWidget.c:16
UIWidgets
Definition
attributes.c:40
Widget
Definition
Widget.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
EActionTrigger
EActionTrigger
Definition
EActionTrigger.c:13
WidgetFlags
WidgetFlags
Widget flags. See enf::Widget::SetFlags().
Definition
WidgetFlags.c:14
ScriptInvoker
ScriptInvokerBase< func > ScriptInvoker
Definition
tools.c:134
scripts
Game
UI
Components
WidgetLibrary
SCR_PagingButton
SCR_PagingButtonComponent.c
Generated by
1.17.0