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_SelectionHintComponent.c
Go to the documentation of this file.
1
//------------------------------------------------------------------------------------------------
2
class
SCR_SelectionHintComponent
:
ScriptedWidgetComponent
3
{
4
[
Attribute
(
"{73B3D8BBB785B5B9}UI/Textures/Common/circleFull.edds"
,
UIWidgets
.ResourceNamePicker,
""
)]
5
protected
ResourceName
m_sHintElementTexture
;
6
7
[
Attribute
(
""
,
UIWidgets
.ResourceNamePicker,
""
)]
8
protected
ResourceName
m_sHintElementImage
;
9
10
[
Attribute
(
"SelectionHintElement"
,
UIWidgets
.EditBox,
"Name for generated selection hints widgets"
)]
11
protected
string
m_sSelectionHintElementName
;
12
13
[
Attribute
(
"0.760 0.392 0.08 1"
,
UIWidgets
.ColorPicker)]
14
protected
ref
Color
m_ColorSelected
;
15
16
[
Attribute
(
"0.25 0.25 0.25 1"
,
UIWidgets
.ColorPicker)]
17
protected
ref
Color
m_ColorDeselected
;
18
19
[
Attribute
(
"true"
)]
20
protected
bool
m_bSetCustomSize
;
21
22
[
Attribute
(
"16"
)]
23
protected
float
m_fItemWidth
;
24
25
[
Attribute
(
"16"
)]
26
protected
float
m_fItemHeight
;
27
28
[
Attribute
(
"0.2"
)]
29
protected
float
m_fAnimationTime
;
30
31
[
Attribute
(
"8"
)]
32
protected
float
m_fItemSpacing
;
33
34
[
Attribute
(
"0"
)]
35
protected
int
m_iCurrent
;
36
37
[
Attribute
(
"0"
)]
38
protected
int
m_iItemCount
;
39
40
protected
float
m_fAnimationRate
=
SCR_WLibComponentBase
.
START_ANIMATION_RATE
;
41
protected
Widget
m_wRoot
;
42
protected
Widget
m_wCurrent
;
43
protected
ref array<Widget>
m_aWidgets
= {};
44
45
//------------------------------------------------------------------------------------------------
46
override
void
HandlerAttached
(
Widget
w)
47
{
48
m_wRoot
= w;
49
50
// Convert time to animation speed
51
GetGame
().GetCallqueue().CallLater(
SetAnimationRate
,
SCR_WLibComponentBase
.
START_ANIMATION_PERIOD
);
52
53
CreateWidgets
(
m_iItemCount
);
54
55
// Highlight correct item
56
if
(
m_iItemCount
>
m_iCurrent
)
57
SetCurrentItem
(
m_iCurrent
,
false
);
58
}
59
60
//------------------------------------------------------------------------------------------------
61
protected
void
CreateWidgets
(
int
count)
62
{
63
int
currentCount =
m_aWidgets
.Count();
64
bool
addWidgets;
65
66
if
(currentCount == count)
67
return
;
68
else
if
(currentCount < count)
69
addWidgets =
true
;
70
71
// Add
72
if
(addWidgets)
73
{
74
int
iterations = count - currentCount;
75
for
(
int
i = 0 ; i < iterations; i++)
76
{
77
CreateWidget
();
78
}
79
}
80
else
81
{
82
int
iterations = currentCount - count;
83
for
(
int
i = 0 ; i < iterations; i++)
84
{
85
// Go from the last
86
m_aWidgets
[currentCount - i - 1].RemoveFromHierarchy();
87
}
88
m_aWidgets
.Resize(count);
89
}
90
}
91
92
//------------------------------------------------------------------------------------------------
93
protected
void
CreateWidget
()
94
{
95
Widget
w =
GetGame
().GetWorkspace().CreateWidget(
WidgetType
.ImageWidgetTypeID,
WidgetFlags
.VISIBLE |
96
WidgetFlags
.STRETCH |
WidgetFlags
.BLEND |
WidgetFlags
.INHERIT_CLIPPING,
m_ColorDeselected
, 0,
m_wRoot
);
97
98
ImageWidget
img =
ImageWidget
.Cast(w);
99
if
(!img)
100
return
;
101
102
m_aWidgets
.Insert(img);
103
104
if
(
m_sHintElementTexture
!=
string
.Empty)
105
SCR_WLibComponentBase
.
SetTexture
(img,
m_sHintElementTexture
,
m_sHintElementImage
);
106
107
if
(
m_bSetCustomSize
)
108
img.SetSize(
m_fItemWidth
,
m_fItemHeight
);
109
110
img.SetName(
m_sSelectionHintElementName
);
111
112
AlignableSlot
.SetPadding(img,
m_fItemSpacing
* 0.5, 0,
m_fItemSpacing
* 0.5, 0);
113
AlignableSlot
.SetVerticalAlign(img,
LayoutVerticalAlign
.Center);
114
AlignableSlot
.SetHorizontalAlign(img,
LayoutHorizontalAlign
.Center);
115
}
116
117
//------------------------------------------------------------------------------------------------
118
protected
void
SetAnimationRate
()
119
{
120
if
(
m_fAnimationTime
<= 0)
121
m_fAnimationRate
= 1000;
122
else
123
m_fAnimationRate
= 1 /
m_fAnimationTime
;
124
}
125
126
// Public API
127
//------------------------------------------------------------------------------------------------
128
void
SetItemCount
(
int
count,
bool
animate =
true
)
129
{
130
if
(count ==
m_iItemCount
|| count == 1)
// Do not show for only one item
131
return
;
132
133
m_iItemCount
= count;
134
CreateWidgets
(count);
135
SetCurrentItem
(
m_iCurrent
, animate);
136
}
137
138
//------------------------------------------------------------------------------------------------
139
int
GetItemCount
()
140
{
141
return
m_iItemCount
;
142
}
143
144
//------------------------------------------------------------------------------------------------
145
int
GetCurrentItem
()
146
{
147
return
m_iCurrent
;
148
}
149
150
//------------------------------------------------------------------------------------------------
151
void
SetCurrentItem
(
int
index
,
bool
animate =
true
)
152
{
153
Widget
newWidget;
154
155
if
(
index
>= 0 &&
index
<
m_iItemCount
)
156
newWidget =
m_aWidgets
[
index
];
157
158
//if (m_wCurrent == newWidget)
159
//return;
160
161
Color
color;
162
foreach
(
int
i,
Widget
w :
m_aWidgets
)
163
{
164
if
(i ==
index
)
165
color =
m_ColorSelected
;
166
else
167
color =
m_ColorDeselected
;
168
169
ColorizeItem
(w, color, animate);
170
}
171
172
m_iCurrent
=
index
;
173
m_wCurrent
= newWidget;
174
}
175
176
//------------------------------------------------------------------------------------------------
177
void
ColorizeItem
(
Widget
w,
Color
color,
bool
animate)
178
{
179
if
(!color || !w || w.GetColor() == color)
180
return
;
181
182
if
(animate &&
m_fAnimationRate
<
SCR_WLibComponentBase
.
START_ANIMATION_RATE
)
183
AnimateWidget
.
Color
(w, color,
m_fAnimationRate
);
184
else
185
w.SetColor(color);
186
}
187
};
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition
SCR_DestructionSynchronizationComponent.c:17
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
ResourceName
Definition
ResourceName.c:13
SCR_SelectionHintComponent
Definition
SCR_SelectionHintComponent.c:3
SCR_SelectionHintComponent::GetItemCount
int GetItemCount()
Definition
SCR_SelectionHintComponent.c:139
SCR_SelectionHintComponent::SetCurrentItem
void SetCurrentItem(int index, bool animate=true)
Definition
SCR_SelectionHintComponent.c:151
SCR_SelectionHintComponent::m_bSetCustomSize
bool m_bSetCustomSize
Definition
SCR_SelectionHintComponent.c:20
SCR_SelectionHintComponent::m_wCurrent
Widget m_wCurrent
Definition
SCR_SelectionHintComponent.c:42
SCR_SelectionHintComponent::m_sHintElementImage
ResourceName m_sHintElementImage
Definition
SCR_SelectionHintComponent.c:8
SCR_SelectionHintComponent::m_fItemSpacing
float m_fItemSpacing
Definition
SCR_SelectionHintComponent.c:32
SCR_SelectionHintComponent::m_fItemWidth
float m_fItemWidth
Definition
SCR_SelectionHintComponent.c:23
SCR_SelectionHintComponent::SetItemCount
void SetItemCount(int count, bool animate=true)
Definition
SCR_SelectionHintComponent.c:128
SCR_SelectionHintComponent::GetCurrentItem
int GetCurrentItem()
Definition
SCR_SelectionHintComponent.c:145
SCR_SelectionHintComponent::m_ColorSelected
ref Color m_ColorSelected
Definition
SCR_SelectionHintComponent.c:14
SCR_SelectionHintComponent::m_wRoot
Widget m_wRoot
Definition
SCR_SelectionHintComponent.c:41
SCR_SelectionHintComponent::m_sSelectionHintElementName
string m_sSelectionHintElementName
Definition
SCR_SelectionHintComponent.c:11
SCR_SelectionHintComponent::m_fAnimationRate
float m_fAnimationRate
Definition
SCR_SelectionHintComponent.c:40
SCR_SelectionHintComponent::CreateWidget
void CreateWidget()
Definition
SCR_SelectionHintComponent.c:93
SCR_SelectionHintComponent::CreateWidgets
void CreateWidgets(int count)
Definition
SCR_SelectionHintComponent.c:61
SCR_SelectionHintComponent::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_SelectionHintComponent.c:46
SCR_SelectionHintComponent::m_iItemCount
int m_iItemCount
Definition
SCR_SelectionHintComponent.c:38
SCR_SelectionHintComponent::m_aWidgets
ref array< Widget > m_aWidgets
Definition
SCR_SelectionHintComponent.c:43
SCR_SelectionHintComponent::m_fAnimationTime
float m_fAnimationTime
Definition
SCR_SelectionHintComponent.c:29
SCR_SelectionHintComponent::m_fItemHeight
float m_fItemHeight
Definition
SCR_SelectionHintComponent.c:26
SCR_SelectionHintComponent::m_iCurrent
int m_iCurrent
Definition
SCR_SelectionHintComponent.c:35
SCR_SelectionHintComponent::m_sHintElementTexture
ResourceName m_sHintElementTexture
Definition
SCR_SelectionHintComponent.c:5
SCR_SelectionHintComponent::SetAnimationRate
void SetAnimationRate()
Definition
SCR_SelectionHintComponent.c:118
SCR_SelectionHintComponent::ColorizeItem
void ColorizeItem(Widget w, Color color, bool animate)
Definition
SCR_SelectionHintComponent.c:177
SCR_SelectionHintComponent::m_ColorDeselected
ref Color m_ColorDeselected
Definition
SCR_SelectionHintComponent.c:17
SCR_WLibComponentBase
Base class for all final Reforger interactive elements.
Definition
SCR_WLibComponentBase.c:9
SCR_WLibComponentBase::SetTexture
static bool SetTexture(ImageWidget widget, ResourceName texture, string image="")
Definition
SCR_WLibComponentBase.c:130
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
WidgetType
Definition
EnWidgets.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
WidgetFlags
WidgetFlags
Widget flags. See enf::Widget::SetFlags().
Definition
WidgetFlags.c:14
LayoutHorizontalAlign
LayoutHorizontalAlign
Definition
LayoutHorizontalAlign.c:13
LayoutVerticalAlign
LayoutVerticalAlign
Definition
LayoutVerticalAlign.c:13
scripts
Game
UI
Components
WidgetLibrary
GalleryView
SCR_SelectionHintComponent.c
Generated by
1.17.0