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_ButtonComponent.c
Go to the documentation of this file.
1
2
3
//------------------------------------------------------------------------------------------------
4
class
SCR_ButtonComponent
:
SCR_ButtonBaseComponent
5
{
6
[
Attribute
(uiwidget:
UIWidgets
.LocaleEditBox)]
7
protected
LocalizedString
m_sContent
;
8
9
protected
Widget
m_wOverlay
;
10
protected
Widget
m_wContent
;
11
12
protected
ref
Color
COLOR_BACKGROUND_DEFAULT
=
UIColors
.BACKGROUND_DEFAULT;
13
protected
ref
Color
COLOR_BACKGROUND_HOVERED
=
UIColors
.BACKGROUND_HOVERED;
14
protected
ref
Color
COLOR_BACKGROUND_FOCUSED
=
UIColors
.BACKGROUND_HOVERED;
15
protected
ref
Color
COLOR_BACKGROUND_CLICKED
=
UIColors
.BACKGROUND_HOVERED;
16
17
protected
ref
Color
COLOR_CONTENT_DEFAULT
=
Color
.White;
18
protected
ref
Color
COLOR_CONTENT_HOVERED
=
Color
.White;
19
protected
ref
Color
COLOR_CONTENT_FOCUSED
=
Color
.White;
20
protected
ref
Color
COLOR_CONTENT_CLICKED
=
Color
.White;
21
22
//ref ScriptInvoker m_OnClicked = new ScriptInvoker();
23
ref
ScriptInvoker
m_OnHover
=
new
ScriptInvoker
();
24
ref
ScriptInvoker<Widget>
m_OnHoverLeave
=
new
ScriptInvoker
();
25
26
//------------------------------------------------------------------------------------------------
27
override
void
HandlerAttached
(
Widget
w)
28
{
29
super.HandlerAttached(w);
30
m_wOverlay
= w.FindAnyWidget(
"Overlay"
);
31
m_wBackground
= w.FindAnyWidget(
"Background"
);
32
33
m_wContent
= w.FindAnyWidget(
"Content"
);
34
if
(
m_wContent
&&
m_sContent
!=
string
.Empty)
35
SetContent
(
m_sContent
);
36
37
if
(
m_wBackground
)
38
m_wBackground
.SetColor(
COLOR_BACKGROUND_DEFAULT
);
39
40
if
(
m_wOverlay
)
41
m_wOverlay
.SetColor(
COLOR_CONTENT_DEFAULT
);
42
}
43
44
/*
45
//------------------------------------------------------------------------------------------------
46
override bool OnClick(Widget w, int x, int y, int button)
47
{
48
super.OnClick(w, x, y, button);
49
if (button != 0)
50
return false;
51
52
m_OnClicked.Invoke(w);
53
return false;
54
}
55
*/
56
57
/*
58
//------------------------------------------------------------------------------------------------
59
override protected void OnMenuSelect()
60
{
61
super.OnMenuSelect();
62
if (!m_wRoot.IsEnabled())
63
return;
64
65
//ColorizeWidgets(COLOR_BACKGROUND_CLICKED, COLOR_CONTENT_CLICKED, m_fAnimationRate * 2);
66
//GetGame().GetCallqueue().CallLater(ResetPadding, m_fAnimationTime * 500 + 1, false);
67
}
68
*/
69
70
/*
71
//------------------------------------------------------------------------------------------------
72
override bool OnMouseButtonDown(Widget w, int x, int y, int button)
73
{
74
if (GetGame().GetWorkspace().GetFocusedWidget() == w)
75
ColorizeWidgets(COLOR_BACKGROUND_CLICKED, COLOR_CONTENT_CLICKED);
76
return false;
77
}
78
79
//------------------------------------------------------------------------------------------------
80
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
81
{
82
if (GetGame().GetWorkspace().GetFocusedWidget() == w)
83
ColorizeWidgets(COLOR_BACKGROUND_FOCUSED, COLOR_CONTENT_FOCUSED);
84
else
85
ColorizeWidgets(COLOR_BACKGROUND_HOVERED, COLOR_CONTENT_HOVERED);
86
87
return false;
88
}
89
*/
90
91
//------------------------------------------------------------------------------------------------
92
override
bool
OnMouseEnter
(
Widget
w,
int
x,
int
y)
93
{
94
super.OnMouseEnter(w, x, y);
95
m_OnHover
.Invoke();
96
//if (GetGame().GetWorkspace().GetFocusedWidget() != w)
97
//ColorizeWidgets(COLOR_BACKGROUND_HOVERED, COLOR_CONTENT_HOVERED);
98
99
return
false
;
100
}
101
102
//------------------------------------------------------------------------------------------------
103
override
bool
OnMouseLeave
(
Widget
w,
Widget
enterW,
int
x,
int
y)
104
{
105
super.OnMouseLeave(w, enterW, x, y);
106
m_OnHoverLeave
.Invoke(w);
107
//if (GetGame().GetWorkspace().GetFocusedWidget() != w)
108
//ColorizeWidgets(COLOR_BACKGROUND_DEFAULT, COLOR_CONTENT_DEFAULT);
109
110
return
false
;
111
}
112
113
//------------------------------------------------------------------------------------------------
114
override
bool
OnFocus
(
Widget
w,
int
x,
int
y)
115
{
116
super.OnFocus(w, x, y);
117
m_OnFocus
.Invoke(w);
118
return
false
;
119
}
120
121
//------------------------------------------------------------------------------------------------
122
override
bool
OnFocusLost
(
Widget
w,
int
x,
int
y)
123
{
124
super.OnFocusLost(w, x, y);
125
return
false
;
126
}
127
128
//------------------------------------------------------------------------------------------------
129
void
ColorizeWidgets
(
Color
colorBackground,
Color
colorContent,
float
speed = -1)
130
{
131
if
(speed < 0)
132
speed =
m_fAnimationRate
;
133
134
AnimateWidget
.
Color
(
m_wBackground
, colorBackground, speed);
135
AnimateWidget
.
Color
(
m_wOverlay
, colorContent, speed);
136
}
137
138
//------------------------------------------------------------------------------------------------
139
void
SetHorizontalAlign
(
LayoutHorizontalAlign
horizontalAlign)
140
{
141
if
(!
m_wContent
)
142
return
;
143
144
TextWidget
content
=
TextWidget
.Cast(
m_wContent
);
145
if
(
content
)
146
AlignableSlot
.SetHorizontalAlign(
content
, horizontalAlign);
147
}
148
149
//------------------------------------------------------------------------------------------------
150
void
SetContent
(
string
text)
151
{
152
if
(!
m_wContent
)
153
return
;
154
155
TextWidget
content
=
TextWidget
.Cast(
m_wContent
);
156
if
(
content
)
157
{
158
content
.SetText(text);
159
return
;
160
}
161
162
ImageWidget
img =
ImageWidget
.Cast(
m_wContent
);
163
if
(img)
164
{
165
img.LoadImageTexture(0, text);
166
return
;
167
}
168
}
169
170
//------------------------------------------------------------------------------------------------
171
void
SetContentFromUIInfo
(
SCR_UIInfo
info)
172
{
173
if
(!
m_wContent
)
174
return
;
175
176
if
(!info.SetNameTo(
TextWidget
.Cast(
m_wContent
)))
177
info.
SetIconTo
(
ImageWidget
.Cast(
m_wContent
));
178
}
179
180
//------------------------------------------------------------------------------------------------
181
string
GetContent
()
182
{
183
return
m_sContent
;
184
}
185
186
//------------------------------------------------------------------------------------------------
189
static
SCR_ButtonComponent
GetButtonComponent
(
string
name,
Widget
parent,
bool
searchAllChildren =
true
)
190
{
191
auto
comp =
SCR_ButtonComponent
.Cast(
192
SCR_WLibComponentBase
.GetComponent(
SCR_ButtonComponent
, name, parent, searchAllChildren)
193
);
194
return
comp;
195
}
196
};
content
class RestAPIHelper< JsonApiStruct T > content
AlignableSlot
Definition
AlignableSlot.c:13
AnimateWidget
Definition
AnimateWidget.c:3
AnimateWidget::Color
static WidgetAnimationColor Color(Widget widget, Color color, float speed)
Definition
AnimateWidget.c:200
Color
Definition
Color.c:13
ImageWidget
Definition
ImageWidget.c:13
LocalizedString
Definition
LocalizedString.c:22
SCR_ButtonBaseComponent
Base class for any button, regardless its own content.
Definition
SCR_ButtonBaseComponent.c:7
SCR_ButtonBaseComponent::m_wBackground
Widget m_wBackground
Definition
SCR_ButtonBaseComponent.c:47
SCR_ButtonBaseComponent::m_OnFocus
ref ScriptInvoker< Widget > m_OnFocus
Definition
SCR_ButtonBaseComponent.c:56
SCR_ButtonComponent
Deprecated button component. Still used in many prefabs, so it works, it's just stripped of most of t...
Definition
SCR_ButtonComponent.c:5
SCR_ButtonComponent::OnFocusLost
override bool OnFocusLost(Widget w, int x, int y)
Definition
SCR_ButtonComponent.c:122
SCR_ButtonComponent::SetHorizontalAlign
void SetHorizontalAlign(LayoutHorizontalAlign horizontalAlign)
Definition
SCR_ButtonComponent.c:139
SCR_ButtonComponent::GetButtonComponent
static SCR_ButtonComponent GetButtonComponent(string name, Widget parent, bool searchAllChildren=true)
Definition
SCR_ButtonComponent.c:189
SCR_ButtonComponent::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_ButtonComponent.c:27
SCR_ButtonComponent::COLOR_BACKGROUND_FOCUSED
ref Color COLOR_BACKGROUND_FOCUSED
Definition
SCR_ButtonComponent.c:14
SCR_ButtonComponent::OnMouseEnter
override bool OnMouseEnter(Widget w, int x, int y)
Definition
SCR_ButtonComponent.c:92
SCR_ButtonComponent::m_sContent
LocalizedString m_sContent
Definition
SCR_ButtonComponent.c:7
SCR_ButtonComponent::OnFocus
override bool OnFocus(Widget w, int x, int y)
Definition
SCR_ButtonComponent.c:114
SCR_ButtonComponent::COLOR_CONTENT_HOVERED
ref Color COLOR_CONTENT_HOVERED
Definition
SCR_ButtonComponent.c:18
SCR_ButtonComponent::COLOR_BACKGROUND_CLICKED
ref Color COLOR_BACKGROUND_CLICKED
Definition
SCR_ButtonComponent.c:15
SCR_ButtonComponent::ColorizeWidgets
void ColorizeWidgets(Color colorBackground, Color colorContent, float speed=-1)
Definition
SCR_ButtonComponent.c:129
SCR_ButtonComponent::COLOR_BACKGROUND_HOVERED
ref Color COLOR_BACKGROUND_HOVERED
Definition
SCR_ButtonComponent.c:13
SCR_ButtonComponent::SetContentFromUIInfo
void SetContentFromUIInfo(SCR_UIInfo info)
Definition
SCR_ButtonComponent.c:171
SCR_ButtonComponent::SetContent
void SetContent(string text)
Definition
SCR_ButtonComponent.c:150
SCR_ButtonComponent::COLOR_CONTENT_FOCUSED
ref Color COLOR_CONTENT_FOCUSED
Definition
SCR_ButtonComponent.c:19
SCR_ButtonComponent::m_OnHoverLeave
ref ScriptInvoker< Widget > m_OnHoverLeave
Definition
SCR_ButtonComponent.c:24
SCR_ButtonComponent::COLOR_CONTENT_CLICKED
ref Color COLOR_CONTENT_CLICKED
Definition
SCR_ButtonComponent.c:20
SCR_ButtonComponent::m_wOverlay
Widget m_wOverlay
Definition
SCR_ButtonComponent.c:9
SCR_ButtonComponent::COLOR_BACKGROUND_DEFAULT
ref Color COLOR_BACKGROUND_DEFAULT
Definition
SCR_ButtonComponent.c:12
SCR_ButtonComponent::GetContent
string GetContent()
Definition
SCR_ButtonComponent.c:181
SCR_ButtonComponent::m_OnHover
ref ScriptInvoker m_OnHover
Definition
SCR_ButtonComponent.c:23
SCR_ButtonComponent::OnMouseLeave
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Definition
SCR_ButtonComponent.c:103
SCR_ButtonComponent::COLOR_CONTENT_DEFAULT
ref Color COLOR_CONTENT_DEFAULT
Definition
SCR_ButtonComponent.c:17
SCR_ButtonComponent::m_wContent
Widget m_wContent
Definition
SCR_ButtonComponent.c:10
SCR_UIInfo
Definition
SCR_UIInfo.c:8
SCR_UIInfo::SetIconTo
bool SetIconTo(ImageWidget imageWidget)
Definition
SCR_UIInfo.c:102
SCR_WLibComponentBase
Base class for all final Reforger interactive elements.
Definition
SCR_WLibComponentBase.c:9
SCR_WLibComponentBase::m_fAnimationRate
float m_fAnimationRate
Definition
SCR_WLibComponentBase.c:28
TextWidget
Definition
TextWidget.c:16
UIColors
Definition
Constants.c:17
UIWidgets
Definition
attributes.c:40
Widget
Definition
Widget.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
LayoutHorizontalAlign
LayoutHorizontalAlign
Definition
LayoutHorizontalAlign.c:13
ScriptInvoker
ScriptInvokerBase< func > ScriptInvoker
Definition
tools.c:134
scripts
Game
UI
Components
WidgetLibrary
SCR_ButtonComponent.c
Generated by
1.17.0