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_CaptureAndHoldObjectiveDisplayObject.c
Go to the documentation of this file.
1
2
class
SCR_CaptureAndHoldObjectiveDisplayObject
3
{
5
protected
Widget
m_wRoot
;
7
protected
TextWidget
m_wDistanceText
;
9
protected
TextWidget
m_wNameText
;
10
12
protected
ImageWidget
m_wIcon
;
14
protected
ImageWidget
m_wUnderAttackIcon
;
16
protected
ImageWidget
m_wMajorIcon
;
18
protected
ImageWidget
m_wBackdropIcon
;
19
20
protected
VerticalLayoutWidget
m_wLayout
;
21
23
protected
float
m_fBlendScreenPosition
;
25
protected
const
float
COLOR_BLEND_SPEED
= 5.5;
27
protected
const
float
POSITION_BLEND_SPEED
= 2.5;
28
29
// Initial values
30
protected
float
m_fOriginalXSize
;
31
protected
float
m_fOriginalYSize
;
32
protected
float
m_fOriginalTitleSize
;
33
protected
float
m_fOriginalTextSize
;
34
35
// Loaded texture indices
36
protected
const
int
ATLAS_INDEX_NEUTRAL
= 0;
37
protected
const
int
ATLAS_INDEX_BLUFOR
= 1;
38
protected
const
int
ATLAS_INDEX_OPFOR
= 2;
39
40
42
protected
SCR_CaptureAndHoldArea
m_AffiliatedArea
;
43
44
//------------------------------------------------------------------------------------------------
46
SCR_CaptureAndHoldArea
GetArea
()
47
{
48
return
m_AffiliatedArea
;
49
}
50
51
//------------------------------------------------------------------------------------------------
53
Widget
GetRootWidget
()
54
{
55
return
m_wRoot
;
56
}
57
58
//------------------------------------------------------------------------------------------------
60
void
SCR_CaptureAndHoldObjectiveDisplayObject
(notnull
Widget
root, notnull
SCR_CaptureAndHoldArea
area)
61
{
62
m_wRoot
= root;
63
m_AffiliatedArea
= area;
64
m_wNameText
=
TextWidget
.Cast(
m_wRoot
.FindAnyWidget(
"Name"
));
65
m_fOriginalTitleSize
= 15;
66
67
m_wDistanceText
=
TextWidget
.Cast(
m_wRoot
.FindAnyWidget(
"Distance"
));
68
m_wIcon
=
ImageWidget
.Cast(
m_wRoot
.FindAnyWidget(
"Icon_Faction"
));
69
m_wBackdropIcon
=
ImageWidget
.Cast(
m_wRoot
.FindAnyWidget(
"Icon_Backdrop"
));
70
71
m_wUnderAttackIcon
=
ImageWidget
.Cast(
m_wRoot
.FindAnyWidget(
"Icon_UnderAttack"
));
72
m_wLayout
=
VerticalLayoutWidget
.Cast(
m_wRoot
.FindAnyWidget(
"VerticalLayout"
));
73
m_fOriginalXSize
=
FrameSlot
.GetSizeX(
m_wLayout
);
74
m_fOriginalYSize
=
FrameSlot
.GetSizeY(
m_wLayout
);
75
76
m_wMajorIcon
=
ImageWidget
.Cast(
m_wRoot
.FindAnyWidget(
"Icon_MajorMark"
));
77
78
m_fOriginalTextSize
= 14;
79
}
80
81
//------------------------------------------------------------------------------------------------
83
protected
void
UpdateImageState
(
Widget
root,
float
timeSlice)
84
{
85
Faction
owningFaction =
m_AffiliatedArea
.GetOwningFaction();
86
87
Color
targetColor;
88
if
(!owningFaction)
89
targetColor =
Color
.FromRGBA(249, 210, 103, 255);
90
else
91
targetColor = owningFaction.GetFactionColor();
92
93
int
rootColor =
m_wRoot
.GetColor().PackToInt();
94
Color
currentColor =
Color
.FromInt(rootColor);
95
if
(currentColor != targetColor)
96
currentColor.Lerp(targetColor, timeSlice *
COLOR_BLEND_SPEED
);
97
98
// Only show major symbol when area is marked as one
99
m_wMajorIcon
.SetVisible(
m_AffiliatedArea
.IsMajor());
100
101
// Imageset for Base state icon
102
const
string
AtlasImageset =
"{225B7CAD5CEC4AE3}UI/Imagesets/CaptureAndHold/CaptureAndHoldAtlas.imageset"
;
103
104
// Area is completely neutral
105
if
(!owningFaction)
106
{
107
m_wIcon
.LoadImageFromSet(0,AtlasImageset,
"CAH_NEUTRAL_LARGE"
);
108
m_wBackdropIcon
.LoadImageFromSet(0,AtlasImageset,
"CAH_NEUTRAL_BACKDROP"
);
109
110
m_wRoot
.SetColor(currentColor);
111
// With no owning faction, there is no contesting faction
112
m_wUnderAttackIcon
.SetVisible(
false
);
113
return
;
114
}
115
116
// TODO: Improvement desirable
117
// This is far from ideal and is not sandbox enough.
118
FactionKey
factionKey = owningFaction.GetFactionKey();
119
if
(factionKey ==
"US"
|| factionKey ==
"FIA"
)
120
{
121
m_wIcon
.LoadImageFromSet(0,AtlasImageset,
"CAH_BLUFOR_LARGE"
);
122
m_wBackdropIcon
.LoadImageFromSet(0,AtlasImageset,
"CAH_BLUFOR_BACKDROP"
);
123
124
m_wUnderAttackIcon
.SetRotation(0);
125
}
126
else
if
(factionKey ==
"USSR"
)
127
{
128
m_wIcon
.LoadImageFromSet(0,AtlasImageset,
"CAH_OPFOR_LARGE"
);
129
m_wBackdropIcon
.LoadImageFromSet(0,AtlasImageset,
"CAH_OPFOR_BACKDROP"
);
130
131
m_wUnderAttackIcon
.SetRotation(45);
132
}
133
134
m_wRoot
.SetColor(currentColor);
135
136
Faction
contestingFaction =
m_AffiliatedArea
.GetContestingFaction();
137
if
(contestingFaction)
138
{
139
m_wUnderAttackIcon
.SetVisible(
true
);
140
// Pulsing animation
141
//Color col = new Color(1.0, 1.0, 1.0, 1.0);
142
Color
col =
Color
.FromRGBA(249, 210, 103, 255);
143
float
val01 =
Math
.Sin(
m_AffiliatedArea
.GetWorld().GetWorldTime() * 0.01 ) * 0.5 + 0.5;
144
col.Lerp(contestingFaction.GetFactionColor(), val01);
145
m_wUnderAttackIcon
.SetColor(col);
146
147
//Color selfCol = new Color(1.0, 1.0, 1.0, 1.0);
148
Color
selfCol =
Color
.FromRGBA(249, 210, 103, 255);
149
selfCol.Lerp(owningFaction.GetFactionColor(), val01);
150
m_wRoot
.SetColor(selfCol);
151
}
152
else
153
{
154
m_wUnderAttackIcon
.SetVisible(
false
);
155
}
156
}
157
158
//------------------------------------------------------------------------------------------------
160
void
UpdateStatic
(
float
timeSlice)
161
{
162
m_wDistanceText
.SetVisible(
false
);
163
UpdateImageState
(
m_wRoot
, timeSlice);
164
// Set objective symbol
165
m_wNameText
.SetText(
m_AffiliatedArea
.GetAreaSymbol());
166
}
167
168
//------------------------------------------------------------------------------------------------
170
void
UpdateDynamic
(
IEntity
playerEntity,
float
timeSlice)
171
{
172
vector
objectiveWorldPosition =
m_AffiliatedArea
.GetWorldObjectiveCenter();
173
vector
projectedScreenPosition =
m_wRoot
.GetWorkspace().ProjWorldToScreen(objectiveWorldPosition,
m_AffiliatedArea
.GetWorld());
174
175
vector
cameraMatrix[4];
176
m_AffiliatedArea
.GetWorld().GetCurrentCamera(cameraMatrix);
177
178
float
alpha = 1.0;
179
bool
visible =
true
;
180
181
// This case should rarely happen as we do not expect spawn protection area
182
// to overlay a capture area, but regardless..
183
bool
isPopupDrawn;
184
SCR_PopUpNotification
popupNotifications =
SCR_PopUpNotification
.
GetInstance
();
185
if
(popupNotifications && popupNotifications.
GetCurrentMsg
())
186
isPopupDrawn =
true
;
187
188
// Center to screen and stay fixed
189
if
(playerEntity &&
m_AffiliatedArea
.IsCharacterInside(SCR_ChimeraCharacter.Cast(playerEntity)) && !isPopupDrawn)
190
{
191
// Update screen space blend
192
m_fBlendScreenPosition
+= (timeSlice *
POSITION_BLEND_SPEED
);
193
visible =
true
;
// Always draw inside
194
}
195
else
196
{
197
// Worldprojection
198
vector
dirToCamera = (objectiveWorldPosition - cameraMatrix[3]).Normalized();
199
float
dot =
vector
.Dot(dirToCamera, cameraMatrix[2]);
200
if
(dot < 0.6666 &&
m_fBlendScreenPosition
<= 0)
// Force animation
201
visible =
false
;
202
203
float
alphaScale =
Math
.InverseLerp(0.667, 1.0, dot);
204
alphaScale =
Math
.Clamp(alphaScale, 0.0, 1.0);
205
206
if
(
m_fBlendScreenPosition
<= 0.0)
207
alpha =
Math
.Lerp(0.5, 1.0, alphaScale);
208
else
209
alpha = 1.0;
210
211
// Blend the point out significantly in optics, because the projection is misaligned
212
if
(ArmaReforgerScripted.IsScreenPointInPIPSights(projectedScreenPosition, ArmaReforgerScripted.GetCurrentPIPSights()))
213
alpha =
Math
.Min(alpha, 0.65);
214
215
m_fBlendScreenPosition
-= (timeSlice *
POSITION_BLEND_SPEED
);
216
}
217
218
// Clamp the blend so we don't overshoot
219
m_fBlendScreenPosition
=
Math
.Clamp(
m_fBlendScreenPosition
, 0.0, 1.0);
220
221
// If not visible, do not draw and that's it
222
if
(!visible)
223
{
224
m_wRoot
.SetVisible(
false
);
225
return
;
226
}
227
228
// Otherwise update widget
229
m_wDistanceText
.SetVisible(
true
);
230
231
// Distance text
232
float
distance
=
vector
.Distance(cameraMatrix[3], objectiveWorldPosition);
233
distance
=
Math
.Round(
distance
);
234
m_wDistanceText
.SetTextFormat(
"#AR-CAH-Objective_Distance"
,
distance
);
235
236
// Update image state
237
UpdateImageState
(
m_wRoot
, timeSlice);
238
239
// Opacity
240
m_wRoot
.SetOpacity(alpha);
241
242
float
x, y;
243
float
scale
= 1.0;
244
float
textScale = 1.0;
245
// Interpolate position
246
if
(
m_fBlendScreenPosition
> 0.0)
247
{
248
WorkspaceWidget
ww =
m_wRoot
.GetWorkspace();
249
int
w = ww.GetWidth();
250
int
h = ww.GetHeight();
251
float
fixedX = ww.DPIUnscale(0.5 * w);
252
float
fixedY = ww.DPIUnscale(0.15 * h);
253
254
SCR_EditorManagerEntity
editorManager =
SCR_EditorManagerEntity
.GetInstance();
255
if
(editorManager && editorManager.IsOpened())
256
fixedY += 40;
257
258
x =
Math
.Lerp(projectedScreenPosition[0], fixedX,
m_fBlendScreenPosition
);
259
y =
Math
.Lerp(projectedScreenPosition[1], fixedY,
m_fBlendScreenPosition
);
260
scale
=
m_fBlendScreenPosition
* 2.25;
261
textScale =
m_fBlendScreenPosition
* 1.85;
262
}
263
else
264
{
265
x = projectedScreenPosition[0];
266
y = projectedScreenPosition[1];
267
}
268
269
float
xScale =
m_fOriginalXSize
*
scale
;
270
float
yScale =
m_fOriginalYSize
*
scale
;
271
// Apply
272
FrameSlot
.SetPos(
m_wRoot
, x - 0.5 * xScale, y - 0.5 * yScale);
273
274
// Scale
275
FrameSlot
.SetSize(
m_wLayout
, xScale, yScale);
276
277
m_wNameText
.SetExactFontSize(
m_fOriginalTitleSize
* textScale);
278
m_wDistanceText
.SetExactFontSize(
m_fOriginalTextSize
* textScale);
279
280
// Set objective symbol
281
m_wNameText
.SetText(
m_AffiliatedArea
.GetAreaSymbol());
282
283
// And make widget visible
284
m_wRoot
.SetVisible(
true
);
285
}
286
}
scale
vector scale
Definition
BlenderEndpoints.c:50
distance
float distance
Definition
SCR_DestructibleTreeV2.c:29
SCR_EditorManagerEntity
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
Definition
SCR_EditorManagerEntity.c:2211
Color
Definition
Color.c:13
Faction
Definition
Faction.c:13
FactionKey
Definition
FactionKey.c:3
FrameSlot
Definition
FrameSlot.c:13
IEntity
Definition
IEntity.c:13
ImageWidget
Definition
ImageWidget.c:13
Math
Definition
Math.c:13
SCR_CaptureAndHoldArea
Definition
SCR_CaptureAndHoldArea.c:14
SCR_CaptureAndHoldObjectiveDisplayObject::UpdateImageState
void UpdateImageState(Widget root, float timeSlice)
Update image state according to provided area state.
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:83
SCR_CaptureAndHoldObjectiveDisplayObject::UpdateStatic
void UpdateStatic(float timeSlice)
Update this widget as static UI element, ie. not reprojecting it automatically.
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:160
SCR_CaptureAndHoldObjectiveDisplayObject::m_fOriginalYSize
float m_fOriginalYSize
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:31
SCR_CaptureAndHoldObjectiveDisplayObject::m_wRoot
Widget m_wRoot
Topmost widget of this object.
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:5
SCR_CaptureAndHoldObjectiveDisplayObject::ATLAS_INDEX_OPFOR
const int ATLAS_INDEX_OPFOR
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:38
SCR_CaptureAndHoldObjectiveDisplayObject::m_wUnderAttackIcon
ImageWidget m_wUnderAttackIcon
The objective is under attack symbol image.
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:14
SCR_CaptureAndHoldObjectiveDisplayObject::m_wNameText
TextWidget m_wNameText
Text that displays name or symbol of the objective.
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:9
SCR_CaptureAndHoldObjectiveDisplayObject::m_fOriginalTextSize
float m_fOriginalTextSize
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:33
SCR_CaptureAndHoldObjectiveDisplayObject::COLOR_BLEND_SPEED
const float COLOR_BLEND_SPEED
Color blending rate.
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:25
SCR_CaptureAndHoldObjectiveDisplayObject::GetArea
SCR_CaptureAndHoldArea GetArea()
Returns the area this element represents.
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:46
SCR_CaptureAndHoldObjectiveDisplayObject::POSITION_BLEND_SPEED
const float POSITION_BLEND_SPEED
Position blending rate.
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:27
SCR_CaptureAndHoldObjectiveDisplayObject::m_fBlendScreenPosition
float m_fBlendScreenPosition
Blend progress of when within the area.
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:23
SCR_CaptureAndHoldObjectiveDisplayObject::m_wBackdropIcon
ImageWidget m_wBackdropIcon
The backdrop image of this element.
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:18
SCR_CaptureAndHoldObjectiveDisplayObject::m_wMajorIcon
ImageWidget m_wMajorIcon
The major objective symbol image.
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:16
SCR_CaptureAndHoldObjectiveDisplayObject::m_AffiliatedArea
SCR_CaptureAndHoldArea m_AffiliatedArea
The area this object represents.
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:42
SCR_CaptureAndHoldObjectiveDisplayObject::m_fOriginalXSize
float m_fOriginalXSize
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:30
SCR_CaptureAndHoldObjectiveDisplayObject::GetRootWidget
Widget GetRootWidget()
Returns root widget of this element.
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:53
SCR_CaptureAndHoldObjectiveDisplayObject::m_wDistanceText
TextWidget m_wDistanceText
Text that displays objective distance.
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:7
SCR_CaptureAndHoldObjectiveDisplayObject::ATLAS_INDEX_NEUTRAL
const int ATLAS_INDEX_NEUTRAL
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:36
SCR_CaptureAndHoldObjectiveDisplayObject::ATLAS_INDEX_BLUFOR
const int ATLAS_INDEX_BLUFOR
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:37
SCR_CaptureAndHoldObjectiveDisplayObject::SCR_CaptureAndHoldObjectiveDisplayObject
void SCR_CaptureAndHoldObjectiveDisplayObject(notnull Widget root, notnull SCR_CaptureAndHoldArea area)
Create new wrapper for objective display.
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:60
SCR_CaptureAndHoldObjectiveDisplayObject::m_fOriginalTitleSize
float m_fOriginalTitleSize
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:32
SCR_CaptureAndHoldObjectiveDisplayObject::m_wLayout
VerticalLayoutWidget m_wLayout
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:20
SCR_CaptureAndHoldObjectiveDisplayObject::m_wIcon
ImageWidget m_wIcon
The objective image.
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:12
SCR_CaptureAndHoldObjectiveDisplayObject::UpdateDynamic
void UpdateDynamic(IEntity playerEntity, float timeSlice)
Update this widget as dynamic UI element projected to screen space.
Definition
SCR_CaptureAndHoldObjectiveDisplayObject.c:170
SCR_PopUpNotification
Takes care of dynamic and static onscreen popups.
Definition
SCR_PopupNotification.c:25
SCR_PopUpNotification::GetInstance
static SCR_PopUpNotification GetInstance()
Definition
SCR_PopupNotification.c:59
SCR_PopUpNotification::GetCurrentMsg
SCR_PopupMessage GetCurrentMsg()
Definition
SCR_PopupNotification.c:322
TextWidget
Definition
TextWidget.c:16
VerticalLayoutWidget
Definition
VerticalLayoutWidget.c:13
Widget
Definition
Widget.c:13
WorkspaceWidget
Definition
WorkspaceWidget.c:16
vector
Definition
vector.c:13
scripts
Game
UI
CaptureAndHold
SCR_CaptureAndHoldObjectiveDisplayObject.c
Generated by
1.17.0