Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MapMarkerWidgetComponent.c
Go to the documentation of this file.
1
4{
5 protected const string PRIVATE_QUAD = "private";
6 protected const string PUBLIC_QUAD = "public";
7
8 protected const string AUTHOR_NAME_FORMAT = "[%1]";
9
10 protected const int UPDATE_TIMESTAMP_INTERVAL = 10000;
11
12 protected bool m_bIsEventListening; // whether this marker reacts to events
13 protected bool m_bIsSymbolMode; // app-6 symbol visualization mode
14 protected bool m_bIsOwnerMode; // player is the markers owner
15 protected bool m_bShowAuthor;
16 protected bool m_bShowText;
17 protected int m_iLayerID; // map layer ID
18
20 protected bool m_bIsTimestampVisible;
21
38
39 protected ref Color m_GlowDefault = Color.FromSRGBA(21, 29, 32, 155);
40 protected ref Color m_GlowSelected = Color.FromSRGBA(226, 168, 79, 155);
41
42 protected ref Color m_TextColor = new Color(0.0, 0.0, 0.0, 1.0);
43 protected ref Color m_CurrentImageColor = new Color(0.0, 0.0, 0.0, 1.0);
45
46 protected SCR_MapMarkerManagerComponent m_MapMarkerManager;
47
48 //------------------------------------------------------------------------------------------------
51 {
52 m_MarkerObject = marker;
53 }
54
55 //------------------------------------------------------------------------------------------------
57 void SetLayerID(int id)
58 {
59 m_iLayerID = id;
60 }
61
62 //------------------------------------------------------------------------------------------------
64 void SetRotation(float angle)
65 {
66 m_wMarkerIcon.SetRotation(angle);
67 m_wMarkerGlowIcon.SetRotation(angle);
68 }
69
70 //------------------------------------------------------------------------------------------------
75 void SetImage(ResourceName icon, string quad, float aspectRatio = 1)
76 {
77 m_wMarkerIcon.LoadImageFromSet(0, icon, quad);
78 if (aspectRatio != 1 && aspectRatio != 0)
79 {
80 vector size = m_wMarkerIcon.GetSize();
81 m_wMarkerIcon.SetSize(size[0] * 0.9, (size[1] * (1/aspectRatio)) * 0.9); // todo, temp size adjust before symbols group side are fixed
82 }
83 }
84
85 //------------------------------------------------------------------------------------------------
88 void SetGlowImage(ResourceName icon, string quad)
89 {
90 m_wMarkerGlowIcon.SetVisible(true);
91 m_wMarkerGlowIcon.LoadImageFromSet(0, icon, quad);
92 }
93
94 //------------------------------------------------------------------------------------------------
97 void SetMilitarySymbolMode(bool state)
98 {
99 m_bIsSymbolMode = state;
100
101 m_wSymbolRoot.SetEnabled(state);
102 m_wSymbolRoot.SetVisible(state);
103
104 m_wMarkerIcon.SetVisible(!state);
105 }
106
107 //------------------------------------------------------------------------------------------------
109 void SetEventListening(bool state)
110 {
111 m_bIsEventListening = state;
112 }
113
114 //------------------------------------------------------------------------------------------------
118 {
120 if (symbolComp)
121 symbolComp.Update(milSymbol);
122 }
123
124 //------------------------------------------------------------------------------------------------
127 void SetText(string text, bool skipProfanityFilter = false)
128 {
129 if (skipProfanityFilter || text.IsEmpty() || !m_MarkerObject.GetMarkerOwnerID() <= -1)
130 {
131 OnFilteredCallback({text});
132 return;
133 }
134
136 return;
137
138 SCR_ScriptProfanityFilterRequestCallback profanityCallback = m_MapMarkerManager.RequestProfanityFilter(text);
139
140 if (!profanityCallback)
141 {
142 OnFilteredCallback({text});
143 return;
144 }
145
146 profanityCallback.m_OnResult.Insert(OnFilteredCallback);
147 }
148
149 //------------------------------------------------------------------------------------------------
150 protected void OnFilteredCallback(array<string> text)
151 {
152 string resultText;
153
154 if (GetGame().GetPlatformService().GetLocalPlatformKind() == PlatformKind.XBOX == PlatformKind.XBOX)
155 {
156 SCR_ProfaneFilter.ReplaceProfanities(text.Get(0), resultText);
157 }
158 else
159 {
160 resultText = text.Get(0);
161 }
162
163 if (!resultText.IsEmpty())
164 m_wMarkerText.SetText(resultText);
165 }
166
167 //------------------------------------------------------------------------------------------------
169 void SetTextVisible(bool state)
170 {
171 m_bShowText = state;
172
173 m_wMarkerText.SetVisible(false);
174 }
175
176 //------------------------------------------------------------------------------------------------
178 void SetTypeIcon(int type, string text)
179 {
180 if (type == 1)
181 {
182 m_wTypeIcon1.SetText(text);
183 m_wTypeOverlay1.SetVisible(true);
184 }
185 else if (type == 2)
186 {
187 m_wTypeIcon2.SetText(text);
188 m_wTypeOverlay2.SetVisible(true);
189 }
190 else if (type == 3)
191 {
192 m_wTypeIcon3.SetText(text);
193 m_wTypeOverlay3.SetVisible(true);
194 }
195 }
196
197 //------------------------------------------------------------------------------------------------
199 void SetTypeIconsVisible(bool state)
200 {
201 m_wTypeIconRoot.SetVisible(state);
202 }
203
204 //------------------------------------------------------------------------------------------------
206 void SetAuthor(string text)
207 {
208 m_bIsOwnerMode = false;
209
210 m_wMarkerAuthor.SetTextFormat(AUTHOR_NAME_FORMAT, text);
211 }
212
213 //------------------------------------------------------------------------------------------------
215 void SetAuthorVisible(bool state)
216 {
217 state = true;
218 m_bShowAuthor = state;
219
220 ShowAuthor(false);
221 }
222
223 //------------------------------------------------------------------------------------------------
226 void SetModeIcon(bool state, bool isPublic)
227 {
228 m_bIsOwnerMode = true;
229
230 m_wMarkerModeIcon.SetVisible(m_MarkerObject.GetMarkerOwnerID() == SCR_PlayerController.GetLocalPlayerId());
231
232 if (isPublic)
233 m_wMarkerModeIcon.LoadImageFromSet(0, UIConstants.ICONS_IMAGE_SET, PUBLIC_QUAD);
234 else
235 m_wMarkerModeIcon.LoadImageFromSet(0, UIConstants.ICONS_IMAGE_SET, PRIVATE_QUAD);
236 }
237
238 //------------------------------------------------------------------------------------------------
240 void SetColor(Color color)
241 {
242 m_CurrentImageColor = color;
243
244 if (m_bIsSymbolMode)
245 m_wSymbolOverlay.SetColor(color);
246 else
247 m_wMarkerIcon.SetColor(color);
248
249 m_wMarkerText.SetColor(m_TextColor);
251 }
252
253 //------------------------------------------------------------------------------------------------
259
260 //------------------------------------------------------------------------------------------------
261 protected void ShowAuthor(bool state)
262 {
263 m_wMarkerAuthor.SetVisible(state);
264
266 if (playerController)
267 {
268 bool showIconNametag = true;
269
270 // Always show on PSN
271 PlatformKind ownPlatformKind = GetGame().GetPlayerManager().GetPlatformKind(playerController.GetLocalPlayerId());
272 if (ownPlatformKind == PlatformKind.STEAM)
273 {
274 BaseContainer settings = GetGame().GetGameUserSettings().GetModule("SCR_GameplaySettings");
275 if (settings)
276 settings.Get("m_bPlatformIconNametag", showIconNametag);
277 }
278
279 m_wAuthorPlatformIcon.SetVisible(state && showIconNametag);
280 }
281 }
282
283 //------------------------------------------------------------------------------------------------
286 {
287 if (!timestamp)
288 return;
289
290 m_Timestamp = timestamp;
291 GetGame().GetCallqueue().CallLater(UpdateCachedTimestamp, UPDATE_TIMESTAMP_INTERVAL, true);
292 UpdateTimestamp(timestamp);
293 }
294
295 //------------------------------------------------------------------------------------------------
296 void SetTimestampVisibility(bool isVisible)
297 {
298 m_bIsTimestampVisible = isVisible;
299 m_wMarkerTimestamp.SetVisible(isVisible);
300 }
301
302 //------------------------------------------------------------------------------------------------
303 protected void UpdateCachedTimestamp()
304 {
306 }
307
308 //------------------------------------------------------------------------------------------------
311 {
312 if (!timestamp)
313 return;
314
315 ChimeraWorld world = GetGame().GetWorld();
316 if (!world)
317 return;
318
319 string text = SCR_FormatHelper.GetTimeSinceEventImprecise(world.GetServerTimestamp().DiffSeconds(timestamp));
320 m_wMarkerTimestamp.SetText(text);
321 }
322
323 //------------------------------------------------------------------------------------------------
324 override bool OnMouseEnter(Widget w, int x, int y)
325 {
327 return false;
328
329 m_MarkerObject.LayerChangeLogic(0);
330
332
333 if (m_bShowAuthor)
334 ShowAuthor(true);
335
336 if (m_bShowText)
337 m_wMarkerText.SetVisible(true);
338
340 return false;
341
342 if (m_bIsSymbolMode)
343 m_wSymbolOverlay.SetColor(GUIColors.ORANGE);
344 else
346
347 return true;
348 }
349
350 //------------------------------------------------------------------------------------------------
351 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
352 {
354 return false;
355
356 m_MarkerObject.LayerChangeLogic(m_iLayerID);
357
358 SetTypeIconsVisible(false);
359
360 if (m_bShowAuthor)
361 ShowAuthor(false);
362
363 if (m_bShowText)
364 m_wMarkerText.SetVisible(false);
365
367 return false;
368
369 if (m_bIsSymbolMode)
371 else
373
374 return true;
375 }
376
377 //------------------------------------------------------------------------------------------------
378 override bool OnFocus(Widget w, int x, int y)
379 {
380 return OnMouseEnter(w, x, y);
381 }
382
383 //------------------------------------------------------------------------------------------------
384 override bool OnFocusLost(Widget w, int x, int y)
385 {
386 return OnMouseLeave(w, null, x, y);
387 }
388
389 //------------------------------------------------------------------------------------------------
390 protected void OnMapClose(MapConfiguration config)
391 {
393 GetGame().GetCallqueue().Remove(UpdateCachedTimestamp);
394 }
395
396 //------------------------------------------------------------------------------------------------
397 override void HandlerAttached(Widget w)
398 {
399 super.HandlerAttached(w);
400
401 m_wMarkerIcon = ImageWidget.Cast(m_wRoot.FindAnyWidget("MarkerIcon"));
402 m_wMarkerGlowIcon = ImageWidget.Cast(m_wRoot.FindAnyWidget("MarkerIconGlow"));
403 m_wMarkerText = TextWidget.Cast(m_wRoot.FindAnyWidget("MarkerText"));
404 m_wMarkerAuthor = TextWidget.Cast(m_wRoot.FindAnyWidget("MarkerAuthor"));
405 m_wMarkerModeIcon = ImageWidget.Cast(m_wRoot.FindAnyWidget("MarkerModeIcon"));
406 m_wAuthorPlatformIcon = ImageWidget.Cast(m_wRoot.FindAnyWidget("PlatformIcon"));
407 m_wSymbolRoot = m_wRoot.FindAnyWidget("SymbolWidget");
408 m_wSymbolOverlay = m_wSymbolRoot.FindAnyWidget("SymbolOverlay");
409 m_wTypeIconRoot = m_wRoot.FindAnyWidget("TypeIconHLayout");
410 m_wTypeOverlay1 = m_wTypeIconRoot.FindAnyWidget("TypeOverlay1");
411 m_wTypeOverlay2 = m_wTypeIconRoot.FindAnyWidget("TypeOverlay2");
412 m_wTypeOverlay3 = m_wTypeIconRoot.FindAnyWidget("TypeOverlay3");
413 m_wTypeIcon1 = TextWidget.Cast(m_wTypeIconRoot.FindAnyWidget("TypeText1"));
414 m_wTypeIcon2 = TextWidget.Cast(m_wTypeIconRoot.FindAnyWidget("TypeText2"));
415 m_wTypeIcon3 = TextWidget.Cast(m_wTypeIconRoot.FindAnyWidget("TypeText3"));
416
417 m_MapMarkerManager = SCR_MapMarkerManagerComponent.GetInstance();
418
419 m_wMarkerTimestamp = TextWidget.Cast(m_wRoot.FindAnyWidget("MarkerTimestamp"));
420 m_wMarkerTimestamp.SetText(string.Empty); // set empty
421
422 if (m_Timestamp)
423 GetGame().GetCallqueue().CallLater(UpdateCachedTimestamp, UPDATE_TIMESTAMP_INTERVAL, true);
424
426 }
427
428 //------------------------------------------------------------------------------------------------
429 override void HandlerDeattached(Widget w)
430 {
431 super.HandlerDeattached(w);
432
433 GetGame().GetCallqueue().Remove(UpdateCachedTimestamp);
434 }
435}
AddonBuildInfoTool id
ArmaReforgerScripted GetGame()
Definition game.c:1398
PlatformKind
Definition PlatformKind.c:8
int size
EDamageType type
Definition Color.c:13
static string GetTimeSinceEventImprecise(int timeDiffSeconds)
static ScriptInvokerBase< MapConfigurationInvoker > GetOnMapClose()
Get on map close invoker.
void SetText(string text, bool skipProfanityFilter=false)
void OnMapClose(MapConfiguration config)
SCR_MapMarkerManagerComponent m_MapMarkerManager
override bool OnFocusLost(Widget w, int x, int y)
void OnFilteredCallback(array< string > text)
void SetTypeIcon(int type, string text)
Not synched secondary text.
void SetGlowImage(ResourceName icon, string quad)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
override bool OnMouseEnter(Widget w, int x, int y)
void UpdateMilitarySymbol(SCR_MilitarySymbol milSymbol)
void SetImage(ResourceName icon, string quad, float aspectRatio=1)
void SetTimestamp(WorldTimestamp timestamp)
void SetMarkerObject(notnull SCR_MapMarkerBase marker)
override bool OnFocus(Widget w, int x, int y)
void UpdateTimestamp(WorldTimestamp timestamp)
void SetModeIcon(bool state, bool isPublic)
Markers UI map component.
static bool IsOwnedMarker(notnull SCR_MapMarkerBase marker)
Check whether the marker is owned by the local player.
void Update(notnull SCR_MilitarySymbol symbol, SCR_MilitarySymbolConfig config=null)
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
Handles filtering profanities in texts.
proto external PlayerController GetPlayerController()