Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
ButtonComponent.c
Go to the documentation of this file.
1
// More complex button handling 6 states:
2
// Default, hovered, focused, hovered+focused, clicked, disabled.
3
// Used for more complex buttons types requiring hovering over a button
4
5
class
ButtonComponent
:
SimpleButtonComponent
6
{
7
[
Attribute
(
"1 1 1 0.05"
,
UIWidgets
.ColorPicker,
""
)]
8
protected
ref
Color
m_ColorButtonHovered
;
9
10
[
Attribute
(
"1 1 1 0.25"
,
UIWidgets
.ColorPicker,
""
)]
11
protected
ref
Color
m_ColorButtonHoveredFocused
;
12
13
[
Attribute
(
"1 1 1 1"
,
UIWidgets
.ColorPicker,
""
)]
14
protected
ref
Color
m_ColorChildHovered
;
15
16
[
Attribute
(
"0 0 0 1"
,
UIWidgets
.ColorPicker,
""
)]
17
protected
ref
Color
m_ColorChildHoveredFocused
;
18
19
[
Attribute
(
SCR_SoundEvent
.SOUND_FE_BUTTON_HOVER,
UIWidgets
.EditBox,
""
)]
20
protected
string
m_sSoundHovered
;
21
22
protected
bool
m_bIsHovered
=
false
;
23
24
//------------------------------------------------------------------------------------------------
25
override
void
HandlerDeattached
(
Widget
w)
26
{
27
super.HandlerDeattached(w);
28
m_ColorButtonHovered
= null;
29
m_ColorChildHovered
= null;
30
m_ColorButtonHoveredFocused
= null;
31
m_ColorChildHoveredFocused
= null;
32
}
33
34
//------------------------------------------------------------------------------------------------
35
override
bool
OnMouseButtonUp
(
Widget
w,
int
x,
int
y,
int
button)
36
{
37
AnimateWidget
.
Color
(w,
m_ColorButtonHoveredFocused
,
m_fAnimationLength
);
38
39
if
(
m_bColorizeChildren
&&
m_wChild
)
40
AnimateWidget
.
Color
(
m_wChild
,
m_ColorChildHoveredFocused
,
m_fAnimationLength
);
41
42
return
false
;
43
}
44
45
//------------------------------------------------------------------------------------------------
46
override
bool
OnFocus
(
Widget
w,
int
x,
int
y)
47
{
48
m_bIsFocused
=
true
;
49
SCR_UISoundEntity
.SoundEvent(
m_sSoundFocused
);
50
51
Color
buttonColor;
52
Color
childColor;
53
if
(
m_bIsHovered
)
54
{
55
buttonColor =
m_ColorButtonHoveredFocused
;
56
childColor =
m_ColorChildHoveredFocused
;
57
}
58
else
59
{
60
buttonColor =
m_ColorButtonFocused
;
61
childColor =
m_ColorChildFocused
;
62
}
63
64
AnimateWidget
.
Color
(w, buttonColor,
m_fAnimationLength
);
65
if
(
m_bColorizeChildren
&&
m_wChild
)
66
AnimateWidget
.
Color
(
m_wChild
, childColor,
m_fAnimationLength
);
67
68
return
false
;
69
}
70
71
//------------------------------------------------------------------------------------------------
72
override
bool
OnFocusLost
(
Widget
w,
int
x,
int
y)
73
{
74
m_bIsFocused
=
false
;
75
76
Color
buttonColor;
77
Color
childColor;
78
if
(
m_bIsHovered
)
79
{
80
buttonColor =
m_ColorButtonHovered
;
81
childColor =
m_ColorChildHovered
;
82
}
83
else
84
{
85
buttonColor =
m_ColorButtonDefault
;
86
childColor =
m_ColorChildDefault
;
87
}
88
89
AnimateWidget
.
Color
(w, buttonColor,
m_fAnimationLength
);
90
if
(
m_bColorizeChildren
&&
m_wChild
)
91
AnimateWidget
.
Color
(
m_wChild
, childColor,
m_fAnimationLength
);
92
93
return
false
;
94
}
95
96
//------------------------------------------------------------------------------------------------
97
override
bool
OnMouseEnter
(
Widget
w,
int
x,
int
y)
98
{
99
m_bIsHovered
=
true
;
100
SCR_UISoundEntity
.SoundEvent(
m_sSoundHovered
);
101
102
Color
buttonColor;
103
Color
childColor;
104
if
(
m_bIsFocused
)
105
{
106
buttonColor =
m_ColorButtonHoveredFocused
;
107
childColor =
m_ColorChildHoveredFocused
;
108
}
109
else
110
{
111
buttonColor =
m_ColorButtonHovered
;
112
childColor =
m_ColorChildHovered
;
113
}
114
115
AnimateWidget
.
Color
(w, buttonColor,
m_fAnimationLength
);
116
if
(
m_bColorizeChildren
&&
m_wChild
)
117
AnimateWidget
.
Color
(
m_wChild
, childColor,
m_fAnimationLength
);
118
119
return
false
;
120
}
121
122
//------------------------------------------------------------------------------------------------
123
override
bool
OnMouseLeave
(
Widget
w,
Widget
enterW,
int
x,
int
y)
124
{
125
m_bIsHovered
=
false
;
126
127
Color
buttonColor;
128
Color
childColor;
129
if
(
m_bIsFocused
)
130
{
131
buttonColor =
m_ColorButtonFocused
;
132
childColor =
m_ColorChildFocused
;
133
}
134
else
135
{
136
buttonColor =
m_ColorButtonDefault
;
137
childColor =
m_ColorChildDefault
;
138
}
139
140
AnimateWidget
.
Color
(w, buttonColor,
m_fAnimationLength
);
141
if
(
m_bColorizeChildren
&&
m_wChild
)
142
AnimateWidget
.
Color
(
m_wChild
, childColor,
m_fAnimationLength
);
143
144
return
false
;
145
}
146
};
AnimateWidget
Definition
AnimateWidget.c:3
AnimateWidget::Color
static WidgetAnimationColor Color(Widget widget, Color color, float speed)
Definition
AnimateWidget.c:200
ButtonComponent
Definition
ButtonComponent.c:6
ButtonComponent::HandlerDeattached
override void HandlerDeattached(Widget w)
Definition
ButtonComponent.c:25
ButtonComponent::m_sSoundHovered
string m_sSoundHovered
Definition
ButtonComponent.c:20
ButtonComponent::OnMouseLeave
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Definition
ButtonComponent.c:123
ButtonComponent::OnFocus
override bool OnFocus(Widget w, int x, int y)
Definition
ButtonComponent.c:46
ButtonComponent::m_ColorChildHovered
ref Color m_ColorChildHovered
Definition
ButtonComponent.c:14
ButtonComponent::OnFocusLost
override bool OnFocusLost(Widget w, int x, int y)
Definition
ButtonComponent.c:72
ButtonComponent::OnMouseButtonUp
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
Definition
ButtonComponent.c:35
ButtonComponent::m_ColorChildHoveredFocused
ref Color m_ColorChildHoveredFocused
Definition
ButtonComponent.c:17
ButtonComponent::OnMouseEnter
override bool OnMouseEnter(Widget w, int x, int y)
Definition
ButtonComponent.c:97
ButtonComponent::m_bIsHovered
bool m_bIsHovered
Definition
ButtonComponent.c:22
ButtonComponent::m_ColorButtonHovered
ref Color m_ColorButtonHovered
Definition
ButtonComponent.c:8
ButtonComponent::m_ColorButtonHoveredFocused
ref Color m_ColorButtonHoveredFocused
Definition
ButtonComponent.c:11
Color
Definition
Color.c:13
SCR_SoundEvent
Definition
SCR_SoundEvent.c:2
SCR_UISoundEntity
Definition
SCR_UISoundEntity.c:8
SimpleButtonComponent
Definition
SimpleButtonComponent.c:10
SimpleButtonComponent::m_bColorizeChildren
bool m_bColorizeChildren
Definition
SimpleButtonComponent.c:24
SimpleButtonComponent::m_ColorChildFocused
ref Color m_ColorChildFocused
Definition
SimpleButtonComponent.c:30
SimpleButtonComponent::m_sSoundFocused
string m_sSoundFocused
Definition
SimpleButtonComponent.c:45
SimpleButtonComponent::m_wChild
Widget m_wChild
Definition
SimpleButtonComponent.c:48
SimpleButtonComponent::m_bIsFocused
bool m_bIsFocused
Definition
SimpleButtonComponent.c:49
SimpleButtonComponent::m_fAnimationLength
float m_fAnimationLength
Definition
SimpleButtonComponent.c:39
SimpleButtonComponent::m_ColorButtonDefault
ref Color m_ColorButtonDefault
Definition
SimpleButtonComponent.c:12
SimpleButtonComponent::m_ColorChildDefault
ref Color m_ColorChildDefault
Definition
SimpleButtonComponent.c:27
SimpleButtonComponent::m_ColorButtonFocused
ref Color m_ColorButtonFocused
Definition
SimpleButtonComponent.c:15
UIWidgets
Definition
attributes.c:40
Widget
Definition
Widget.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
scripts
Game
UI
Deprecated
ButtonComponent.c
Generated by
1.17.0