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_BaseVehicleInfo.c
Go to the documentation of this file.
1
//#define DEBUG_VEHICLE_UI
2
3
//------------------------------------------------------------------------------------------------
5
enum
EVehicleInfoState
6
{
7
NOT_INITIALIZED
,
8
DISABLED
,
9
ENABLED,
10
WARNING
,
11
ERROR
12
};
13
14
//------------------------------------------------------------------------------------------------
16
enum
EVehicleInfoColor
17
{
18
WHITE
,
19
BLUE,
20
GREEN,
21
ORANGE,
22
RED
23
};
24
25
//------------------------------------------------------------------------------------------------
27
[
BaseContainerProps
(configRoot:
true
)]
28
class
SCR_BaseVehicleInfo
: SCR_InfoDisplayExtended
29
{
30
protected
ResourceName
m_Imageset
=
"{3262679C50EF4F01}UI/Textures/Icons/icons_wrapperUI.imageset"
;
31
protected
ResourceName
m_ImagesetGlow
=
"{00FE3DBDFD15227B}UI/Textures/Icons/icons_wrapperUI-glow.imageset"
;
32
33
protected
ImageWidget
m_wIcon
;
34
protected
ImageWidget
m_wGlow
;
35
protected
OverlayWidget
m_wSizeOverlay
;
36
37
[
Attribute
(
""
,
UIWidgets
.EditBox,
"Indicator icon to be displayed."
)]
38
protected
string
m_sIcon
;
39
40
[
Attribute
(
SCR_Enum
.GetDefault(
EVehicleInfoColor
.WHITE),
UIWidgets
.ComboBox, enums: ParamEnumArray.FromEnum(
EVehicleInfoColor
))]
41
EVehicleInfoColor
m_eColor
;
42
43
[
Attribute
(
"0.8"
,
UIWidgets
.Slider,
"Indicator scale"
,
"0.25 2 0.05"
)]
44
protected
float
m_fWidgetScale
;
45
46
[
Attribute
(
"1"
,
UIWidgets
.CheckBox,
"Show the greyed-out indicator, if it is inactive, otherwise it will be hidden."
)]
47
protected
bool
m_bShowGhost
;
48
49
protected
EVehicleInfoState
m_eState
=
EVehicleInfoState
.ERROR;
50
protected
bool
m_bIsBlinking
;
51
protected
int
m_iBlinkingOffset
;
52
53
protected
Color
m_aColors
[5];
54
protected
Color
m_aColorsGlow
[5];
55
56
protected
const
int
ICON_SIZE
= 64;
57
58
//------------------------------------------------------------------------------------------------
60
protected
EVehicleInfoState
GetState
()
61
{
62
return
m_eState
;
63
}
64
65
//------------------------------------------------------------------------------------------------
67
protected
bool
IsBlinking
()
68
{
69
return
m_bIsBlinking
;
70
}
71
72
//------------------------------------------------------------------------------------------------
73
protected
void
Scale
(
ImageWidget
widget,
float
scale
)
74
{
75
if
(!widget)
76
return
;
77
78
int
imageWidth = 0;
79
int
imageHeight = 0;
80
int
image = widget.GetImage();
81
82
widget.GetImageSize(image, imageWidth, imageHeight);
83
widget.SetSize((
float
)imageWidth *
scale
, (
float
)imageHeight *
scale
);
84
}
85
86
//------------------------------------------------------------------------------------------------
87
protected
void
Scale
(
TextWidget
widget,
float
scale
)
88
{
89
if
(!widget)
90
return
;
91
92
float
sizeY =
FrameSlot
.GetSizeY(widget);
93
94
FrameSlot
.SetSizeY(widget, sizeY *
scale
);
95
}
96
97
//------------------------------------------------------------------------------------------------
98
protected
void
Scale
(
OverlayWidget
widget,
float
scale
)
99
{
100
if
(!widget)
101
return
;
102
103
FrameSlot
.SetSizeX(widget,
scale
*
ICON_SIZE
);
104
FrameSlot
.SetSizeY(widget,
scale
*
ICON_SIZE
);
105
}
106
107
//------------------------------------------------------------------------------------------------
108
protected
void
SetIcon
(
string
icon)
109
{
110
if
(!
m_wIcon
|| !
m_wGlow
)
111
return
;
112
113
m_wIcon
.LoadImageFromSet(0,
m_Imageset
, icon);
114
m_wGlow
.LoadImageFromSet(0,
m_ImagesetGlow
, icon);
115
116
Scale
(
m_wSizeOverlay
,
m_fWidgetScale
);
117
}
118
119
//------------------------------------------------------------------------------------------------
120
protected
void
SetColor
(
EVehicleInfoState
state,
EVehicleInfoColor
color)
121
{
122
if
(!
m_wIcon
|| !
m_wGlow
)
123
return
;
124
125
switch
(state)
126
{
127
case
EVehicleInfoState
.DISABLED:
128
m_wIcon
.SetColor(
Color
.FromInt(GUIColors.DISABLED.PackToInt()));
129
m_wGlow
.SetColor(
Color
.FromInt(GUIColors.DISABLED_GLOW.PackToInt()));
130
break
;
131
132
case
EVehicleInfoState
.ENABLED:
133
m_wIcon
.SetColor(
Color
.FromInt(
m_aColors
[color].PackToInt()));
134
m_wGlow
.SetColor(
Color
.FromInt(
m_aColorsGlow
[color].PackToInt()));
135
break
;
136
137
case
EVehicleInfoState
.WARNING:
138
m_wIcon
.SetColor(
Color
.FromInt(GUIColors.ORANGE.PackToInt()));
139
m_wGlow
.SetColor(
Color
.FromInt(GUIColors.ORANGE_DARK.PackToInt()));
140
break
;
141
142
case
EVehicleInfoState
.ERROR:
143
m_wIcon
.SetColor(
Color
.FromInt(GUIColors.RED.PackToInt()));
144
m_wGlow
.SetColor(
Color
.FromInt(GUIColors.RED_DARK.PackToInt()));
145
break
;
146
}
147
}
148
149
//------------------------------------------------------------------------------------------------
150
protected
bool
UpdateRequired
(
EVehicleInfoState
state)
151
{
152
return
m_eState
!= state;
153
}
154
155
//------------------------------------------------------------------------------------------------
156
override
event
void
DisplayUpdate
(
IEntity
owner,
float
timeSlice)
157
{
158
if
(!
m_wRoot
)
159
return
;
160
161
EVehicleInfoState
state =
GetState
();
162
163
bool
isBlinking =
IsBlinking
();
164
int
time =
GetGame
().GetWorld().GetWorldTime();
165
166
if
(isBlinking)
167
{
168
if
(
Math
.Mod(time -
m_iBlinkingOffset
, 1000) < 500)
169
state =
Math
.Max(state - 1,
EVehicleInfoState
.DISABLED);
170
}
171
else
172
{
173
m_iBlinkingOffset
=
Math
.Mod(time, 1000);
174
}
175
176
if
(
UpdateRequired
(state))
177
{
178
#ifdef DEBUG_VEHICLE_UI
179
PrintFormat
(
"%1 Update -> state: %2 | icon: %3"
,
this
, state,
m_sIcon
);
180
#endif
181
182
m_eState
= state;
183
184
SetIcon
(
m_sIcon
);
185
SetColor
(state,
m_eColor
);
186
187
bool
show = isBlinking ||
m_bShowGhost
|| state !=
EVehicleInfoState
.DISABLED;
188
189
if
(
m_bShown
!= show)
190
Show
(show);
191
}
192
}
193
194
//------------------------------------------------------------------------------------------------
195
override
bool
DisplayStartDrawInit
(
IEntity
owner)
196
{
197
// Terminate if widget already exists
198
if
(
m_wRoot
)
199
return
false
;
200
201
// Fallback to avoid the need to fill-in always the same layout filename
202
if
(m_LayoutPath ==
""
)
203
m_LayoutPath =
"{D2E54F91C85CAB6C}UI/layouts/HUD/VehicleInfo/VehicleInfoIcon.layout"
;
204
205
return
true
;
206
}
207
208
//------------------------------------------------------------------------------------------------
210
override
void
DisplayStartDraw
(
IEntity
owner)
211
{
212
if
(!
m_wRoot
)
213
return
;
214
215
m_wIcon
=
ImageWidget
.Cast(
m_wRoot
.FindAnyWidget(
"Icon"
));
216
m_wGlow
=
ImageWidget
.Cast(
m_wRoot
.FindAnyWidget(
"Glow"
));
217
m_wSizeOverlay
=
OverlayWidget
.Cast(
m_wRoot
.FindAnyWidget(
"SizeOverlay"
));
218
219
m_eState
=
EVehicleInfoState
.NOT_INITIALIZED;
220
221
DisplayUpdate
(owner, 0);
222
}
223
224
//------------------------------------------------------------------------------------------------
226
override
void
DisplayStopDraw
(
IEntity
owner)
227
{
228
}
229
230
//------------------------------------------------------------------------------------------------
232
override
void
DisplayInit
(
IEntity
owner)
233
{
234
if
(
m_wRoot
)
235
m_wRoot
.RemoveFromHierarchy();
236
237
m_aColors
[
EVehicleInfoColor
.WHITE] = GUIColors.ENABLED;
238
m_aColors
[
EVehicleInfoColor
.BLUE] = GUIColors.BLUE_BRIGHT2;
239
m_aColors
[
EVehicleInfoColor
.GREEN] = GUIColors.GREEN_BRIGHT2;
240
m_aColors
[
EVehicleInfoColor
.ORANGE] = GUIColors.ORANGE_BRIGHT2;
241
m_aColors
[
EVehicleInfoColor
.RED] = GUIColors.RED_BRIGHT2;
242
243
m_aColorsGlow
[
EVehicleInfoColor
.WHITE] = GUIColors.ENABLED_GLOW;
244
m_aColorsGlow
[
EVehicleInfoColor
.BLUE] = GUIColors.BLUE;
245
m_aColorsGlow
[
EVehicleInfoColor
.GREEN] = GUIColors.GREEN;
246
m_aColorsGlow
[
EVehicleInfoColor
.ORANGE] = GUIColors.ORANGE;
247
m_aColorsGlow
[
EVehicleInfoColor
.RED] = GUIColors.RED;
248
}
249
};
scale
vector scale
Definition
BlenderEndpoints.c:50
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
BaseContainerProps
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Definition
SCR_AIAnimationWaypoint.c:14
EVehicleInfoColor
EVehicleInfoColor
Predefined colors that can be assigned in the InfoDisplay configuration.
Definition
SCR_BaseVehicleInfo.c:17
WHITE
@ WHITE
Definition
SCR_BaseVehicleInfo.c:18
EVehicleInfoState
EVehicleInfoState
UI indicator state, controlling colors and opacity.
Definition
SCR_BaseVehicleInfo.c:6
NOT_INITIALIZED
@ NOT_INITIALIZED
Definition
SCR_BaseVehicleInfo.c:7
m_wRoot
Widget m_wRoot
Definition
SCR_GameModeCleanSweep.c:25
m_bShown
bool m_bShown
Definition
SCR_InfoDisplay.c:61
Color
Definition
Color.c:13
FrameSlot
Definition
FrameSlot.c:13
IEntity
Definition
IEntity.c:13
ImageWidget
Definition
ImageWidget.c:13
Math
Definition
Math.c:13
OverlayWidget
Definition
OverlayWidget.c:16
ResourceName
Definition
ResourceName.c:13
SCR_BaseVehicleInfo
Base class for all vehicle UI state and damage indicators.
Definition
SCR_BaseVehicleInfo.c:29
SCR_BaseVehicleInfo::DisplayStartDraw
override void DisplayStartDraw(IEntity owner)
Create the UI.
Definition
SCR_BaseVehicleInfo.c:210
SCR_BaseVehicleInfo::m_wGlow
ImageWidget m_wGlow
Definition
SCR_BaseVehicleInfo.c:34
SCR_BaseVehicleInfo::Scale
void Scale(OverlayWidget widget, float scale)
Definition
SCR_BaseVehicleInfo.c:98
SCR_BaseVehicleInfo::m_aColorsGlow
Color m_aColorsGlow[5]
Definition
SCR_BaseVehicleInfo.c:54
SCR_BaseVehicleInfo::ICON_SIZE
const int ICON_SIZE
Definition
SCR_BaseVehicleInfo.c:56
SCR_BaseVehicleInfo::m_eColor
EVehicleInfoColor m_eColor
Definition
SCR_BaseVehicleInfo.c:41
SCR_BaseVehicleInfo::m_bShowGhost
bool m_bShowGhost
Definition
SCR_BaseVehicleInfo.c:47
SCR_BaseVehicleInfo::m_aColors
Color m_aColors[5]
Definition
SCR_BaseVehicleInfo.c:53
SCR_BaseVehicleInfo::Scale
void Scale(ImageWidget widget, float scale)
Definition
SCR_BaseVehicleInfo.c:73
SCR_BaseVehicleInfo::m_fWidgetScale
float m_fWidgetScale
Definition
SCR_BaseVehicleInfo.c:44
SCR_BaseVehicleInfo::m_iBlinkingOffset
int m_iBlinkingOffset
Definition
SCR_BaseVehicleInfo.c:51
SCR_BaseVehicleInfo::DisplayUpdate
override event void DisplayUpdate(IEntity owner, float timeSlice)
Definition
SCR_BaseVehicleInfo.c:156
SCR_BaseVehicleInfo::m_sIcon
string m_sIcon
Definition
SCR_BaseVehicleInfo.c:38
SCR_BaseVehicleInfo::Scale
void Scale(TextWidget widget, float scale)
Definition
SCR_BaseVehicleInfo.c:87
SCR_BaseVehicleInfo::m_wSizeOverlay
OverlayWidget m_wSizeOverlay
Definition
SCR_BaseVehicleInfo.c:35
SCR_BaseVehicleInfo::m_ImagesetGlow
ResourceName m_ImagesetGlow
Definition
SCR_BaseVehicleInfo.c:31
SCR_BaseVehicleInfo::m_eState
EVehicleInfoState m_eState
Definition
SCR_BaseVehicleInfo.c:49
SCR_BaseVehicleInfo::DisplayStopDraw
override void DisplayStopDraw(IEntity owner)
Destroy the UI.
Definition
SCR_BaseVehicleInfo.c:226
SCR_BaseVehicleInfo::IsBlinking
bool IsBlinking()
Can be overridden to get state of actual system or linked to an event.
Definition
SCR_BaseVehicleInfo.c:67
SCR_BaseVehicleInfo::SetColor
void SetColor(EVehicleInfoState state, EVehicleInfoColor color)
Definition
SCR_BaseVehicleInfo.c:120
SCR_BaseVehicleInfo::DisplayInit
override void DisplayInit(IEntity owner)
Init the UI, runs 1x at the start of the game.
Definition
SCR_BaseVehicleInfo.c:232
SCR_BaseVehicleInfo::m_bIsBlinking
bool m_bIsBlinking
Definition
SCR_BaseVehicleInfo.c:50
SCR_BaseVehicleInfo::m_Imageset
ResourceName m_Imageset
Definition
SCR_BaseVehicleInfo.c:30
SCR_BaseVehicleInfo::m_wIcon
ImageWidget m_wIcon
Definition
SCR_BaseVehicleInfo.c:33
SCR_BaseVehicleInfo::SetIcon
void SetIcon(string icon)
Definition
SCR_BaseVehicleInfo.c:108
SCR_BaseVehicleInfo::UpdateRequired
bool UpdateRequired(EVehicleInfoState state)
Definition
SCR_BaseVehicleInfo.c:150
SCR_BaseVehicleInfo::DisplayStartDrawInit
override bool DisplayStartDrawInit(IEntity owner)
Definition
SCR_BaseVehicleInfo.c:195
SCR_BaseVehicleInfo::GetState
EVehicleInfoState GetState()
Can be overridden to get state of actual system or linked to an event.
Definition
SCR_BaseVehicleInfo.c:60
SCR_Enum
Definition
SCR_Enum.c:2
TextWidget
Definition
TextWidget.c:16
UIWidgets
Definition
attributes.c:40
Scale
float Scale
Definition
gameLib.c:128
Show
override void Show()
Definition
gameLib.c:262
PrintFormat
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
WARNING
@ WARNING
Definition
LogLevel.c:19
ERROR
@ ERROR
Same as DELETE, but global error count for OnAfterLoad is affected.
Definition
LogLevel.c:20
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
DISABLED
@ DISABLED
General event switch.
Definition
EntityEvent.c:35
scripts
Game
UI
HUD
VehicleInfo
SCR_BaseVehicleInfo.c
Generated by
1.17.0