Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MapMarkersUI.c
Go to the documentation of this file.
1
2void MarkerPlacedInvoker(int posX, int posY, bool isLocal); // world pos X, world pos Y, is visible to everyone or just the player who placed it
4
7{
8 [Attribute("#AR-MapMarker_ParentCategory", UIWidgets.Auto, "Menu category name" )]
9 protected string m_sCategoryName;
10
11 [Attribute("{3262679C50EF4F01}UI/Textures/Icons/icons_wrapperUI.imageset", UIWidgets.ResourceNamePicker, desc: "Icons imageset", params: "imageset" )]
13
14 [Attribute("scenarios", UIWidgets.Auto, "Category icon quad" )]
15 protected string m_sCategoryIconName;
16
17 [Attribute("{46C46D97D1FE6241}UI/layouts/Map/MapMarkerEditBox.layout", UIWidgets.ResourceNamePicker, desc: "Edit box dialog when placing custom marker", params: "layout" )]
19
20 [Attribute("{DEA2D3B788CDCB4F}UI/layouts/Map/MapIconSelectorEntry.layout", UIWidgets.ResourceNamePicker, desc: "Icon selection entry layout", params: "layout" )]
22
23 [Attribute("{8A5D43FC8AC6C171}UI/layouts/Map/MapColorSelectorEntry.layout", UIWidgets.ResourceNamePicker, desc: "Color selection entry layout", params: "layout" )]
25
26 [Attribute("{4B6A50B3D8200779}UI/layouts/Map/MapDimensionSelectorEntry.layout", UIWidgets.ResourceNamePicker, desc: "Dimension selection entry layout", params: "layout" )]
28
29 [Attribute("{DF5BCE91F8A59977}UI/layouts/Map/MapMilitaryMarkerEditBox.layout", UIWidgets.ResourceNamePicker, desc: "Edit box dialog when placing military symbol marker", params: "layout" )]
31
32 [Attribute("cancel", UIWidgets.Auto, "Delete icon quad" )]
33 protected string m_sDeleteIconName;
34
35 [Attribute("20", UIWidgets.Auto, "Icon selector entries per line" )]
36 protected int m_iIconsPerLine;
37
38 protected const int USERID_EDITBOX = 1000; // unique id set to editbox allowing us to find it in case there are other editboxes
39 protected const int USERID_EDITBOX_MIL = 1001; // unique id set to military editbox allowing us to find it in case there are other editboxes
40 protected const string ICON_ENTRY = "IconEntry";
41 protected const string COLOR_ENTRY = "ColorEntry";
42 protected const string ICON_SELECTOR = "IconSelector";
43 protected const string COLOR_SELECTOR = "ColorSelector";
44 protected const ResourceName SELECTOR_LINE = "{CF8EC7A0D310A8D9}UI/layouts/Map/MapColorSelectorLine.layout";
45 protected const int SPIN_BOX_YES = 1;
46
47 protected ref Color BACKGROUND_DEFAULT = new Color(4,4,4,255);
48 protected ref Color BACKGROUND_SELECTED = new Color(16,16,16,255);
49
50 protected bool m_bIsMilitaryMarker; // is custom or military marker
51 protected int m_bIsDelayed; // used to delay input context for marker dialog by one frame so it doesnt trigger inputs used to open it
52 protected int m_iIconEntryCount; // how many icon entries are within the current tab
53 protected int m_iIconLines;
54 protected SCR_MapMarkerEntryPlaced m_PlacedMarkerConfig; // saved entry for custom text placed markers
73
74 // Placed marker attributes
75 protected int m_iWantedIconEntry;
76 protected int m_iSelectedIconID; // used for selecting icon when edit dialog is confirmed
77 protected int m_iSelectedColorID;
78 protected int m_iSelectedFactionID;
81 protected float m_fRotation;
82 protected bool m_bIsTimestampVisible;
83 protected SCR_MarkerMilitaryType m_eMilitaryTypeA;
84 protected SCR_MarkerMilitaryType m_eMilitaryTypeB;
87 protected SCR_ButtonBaseComponent m_SelectedIconButton; // used for (un)coloring and selecting proper button when navigating on controller
91
92 protected SCR_MapMarkerManagerComponent m_MarkerMgr;
96 protected SCR_MapMarkerBase m_EditedMarker; // when edit is used, original marked being edited is hidden and cached here so it doesnt clash with edit preview
97 protected SCR_MapCursorModule m_CursorModule;
98
99 protected ref ScriptInvokerBase<MarkerPlacedInvoker> m_OnCustomMarkerPlaced = new ScriptInvokerBase<MarkerPlacedInvoker>();
100
101 protected ref map<SCR_ButtonBaseComponent, int> m_mIconIDs = new map<SCR_ButtonBaseComponent, int>(); // marker icon buttons to config ids
102 protected ref map<SCR_ButtonBaseComponent, int> m_mColorIDs = new map<SCR_ButtonBaseComponent, int>(); // marker color buttons to config ids
103 protected ref map<SCR_ButtonBaseComponent, int> m_mFactionIDs = new map<SCR_ButtonBaseComponent, int>();// marker faction buttons to config ids
104 protected ref map<SCR_ButtonBaseComponent, int> m_mDimensionIDs = new map<SCR_ButtonBaseComponent, int>();// marker dimension buttons to config ids
105
106 //------------------------------------------------------------------------------------------------
107 ScriptInvokerBase<MarkerPlacedInvoker> GetOnCustomMarkerPlaced()
108 {
110 }
111
112 //------------------------------------------------------------------------------------------------
114 static bool IsOwnedMarker(notnull SCR_MapMarkerBase marker)
115 {
116 PlayerController localController = GetGame().GetPlayerController();
117 if (localController)
118 {
119 if (marker.GetMarkerOwnerID() == localController.GetPlayerId())
120 return true;
121 }
122
123 return false;
124 }
125
126 //------------------------------------------------------------------------------------------------
130 protected void CreateMarkerEditDialog(bool isEditing = false, int tabID = 0, int selectedIconEntry = -1, int selectedColorEntry = -1)
131 {
132 m_bIsMilitaryMarker = false;
133
136
137 m_iWantedIconEntry = selectedIconEntry;
138
139 m_MarkerEditRoot = GetGame().GetWorkspace().CreateWidgets(m_sEditBoxLayout, m_RootWidget);
140
141 float screenX, screenY;
142 m_MapEntity.GetMapWidget().GetScreenSize(screenX, screenY);
143 FrameSlot.SetPos(m_MarkerEditRoot, GetGame().GetWorkspace().DPIUnscale(screenX * 0.5), GetGame().GetWorkspace().DPIUnscale(screenY * 0.5));
144
145 m_wMarkerPreview = ImageWidget.Cast(m_MarkerEditRoot.FindAnyWidget("MarkerIcon"));
146 m_wMarkerPreviewGlow = ImageWidget.Cast(m_MarkerEditRoot.FindAnyWidget("MarkerIconGlow"));
147 m_wMarkerPreviewText = TextWidget.Cast(m_MarkerEditRoot.FindAnyWidget("MarkerText"));
148
149 InitColorIcons(selectedColorEntry);
150
151 Widget sliderRotation = m_MarkerEditRoot.FindAnyWidget("SliderRoot");
152 m_SliderComp = SCR_SliderComponent.Cast(sliderRotation.FindHandler(SCR_SliderComponent));
153 m_SliderComp.m_OnChanged.Insert(OnSliderChanged);
154
155 Widget categoryTab = m_MarkerEditRoot.FindAnyWidget("MarkerEditTab");
156 m_TabComponent = SCR_TabViewComponent.Cast(categoryTab.FindHandler(SCR_TabViewComponent));
157
158 array<ref SCR_MarkerIconCategory> categoriesArr = m_PlacedMarkerConfig.GetIconCategories();
159 foreach (SCR_MarkerIconCategory category : categoriesArr)
160 {
161 m_TabComponent.AddTab(string.Empty, category.m_sName, identifier: category.m_sIdentifier);
162 }
163
164 m_TabComponent.GetOnChanged().Insert(OnTabChanged);
165 m_TabComponent.ShowTab(tabID, true, false);
166
167 Widget editBoxRoot = m_MarkerEditRoot.FindAnyWidget("EditBoxRoot");
168 editBoxRoot.FindAnyWidget("EditBox").SetUserID(USERID_EDITBOX);
169 m_EditBoxComp = SCR_EditBoxComponent.Cast(editBoxRoot.FindHandler(SCR_EditBoxComponent));
170 m_EditBoxComp.m_OnTextChange.Insert(OnEditBoxTextChanged);
171 m_EditBoxComp.SetValue(string.Empty);
172
173 SCR_InputButtonComponent confirmComp = SCR_InputButtonComponent.Cast(m_MarkerEditRoot.FindAnyWidget("ButtonPublic").FindHandler(SCR_InputButtonComponent));
174
175 if (isEditing)
176 {
177 if (m_EditedMarker.GetMarkerID() >= 0)
178 confirmComp.m_OnClicked.Insert(OnPlaceMarkerConfirmed);
179 else
180 confirmComp.m_OnClicked.Insert(OnPlaceMarkerConfirmedPrivate);
181
182 confirmComp.SetLabel("#AR-ServerHosting_Edit");
183
184 m_MarkerEditRoot.FindAnyWidget("ButtonPrivate").SetVisible(false);
185 m_MarkerEditRoot.FindAnyWidget("ButtonPrivate").SetEnabled(false);
186 }
187 else
188 {
189 confirmComp.m_OnClicked.Insert(OnPlaceMarkerConfirmed);
190 confirmComp.SetLabel("#AR-MapMarker_PlacePublic");
191
192 SocialComponent sc = GetSocialComponent();
193 if (sc && !sc.IsPrivilegedTo(EUserInteraction.UserGeneratedContent))
194 confirmComp.SetEnabled(false);
195 else
196 confirmComp.SetEnabled(true);
197
198 confirmComp = SCR_InputButtonComponent.Cast(m_MarkerEditRoot.FindAnyWidget("ButtonPrivate").FindHandler(SCR_InputButtonComponent));
199 confirmComp.m_OnClicked.Insert(OnPlaceMarkerConfirmedPrivate);
200 }
201
202 confirmComp = SCR_InputButtonComponent.Cast(m_MarkerEditRoot.FindAnyWidget("ButtonCancel").FindHandler(SCR_InputButtonComponent));
203 confirmComp.m_OnClicked.Insert(OnEditCancelled);
204
205 FocusWidget(m_SelectedIconButton.GetRootWidget());
206
207 m_CursorModule.HandleDialog(true);
208 }
209
210 //------------------------------------------------------------------------------------------------
211 protected void CreateMilitaryMarkerEditDialog(bool isEditing = false, int selectedFactionEntry = -1, int selectedDimensionEntry = -1)
212 {
213 m_bIsMilitaryMarker = true;
214 m_iWantedDimensionEntry = selectedDimensionEntry;
215
216 m_MarkerEditRoot = GetGame().GetWorkspace().CreateWidgets(m_sMilitaryEditBoxLayout, m_RootWidget);
217
218 float screenX, screenY;
219 m_MapEntity.GetMapWidget().GetScreenSize(screenX, screenY);
220 FrameSlot.SetPos(m_MarkerEditRoot, GetGame().GetWorkspace().DPIUnscale(screenX * 0.5), GetGame().GetWorkspace().DPIUnscale(screenY * 0.5));
221
222 m_wMarkerPreviewMilitary = OverlayWidget.Cast(m_MarkerEditRoot.FindAnyWidget("SymbolOverlay"));
224 m_wMarkerPreviewText = TextWidget.Cast(m_MarkerEditRoot.FindAnyWidget("MarkerText"));
225
229
230 InitFactionIcons(selectedFactionEntry);
231
232 m_ComboBoxComp1 = SCR_ComboBoxComponent.Cast(m_MarkerEditRoot.FindAnyWidget("ComboBox1").FindHandler(SCR_ComboBoxComponent));
233 m_ComboBoxComp1.m_OnChanged.Insert(OnComboBoxChangedA);
234
235 m_ComboBoxComp2 = SCR_ComboBoxComponent.Cast(m_MarkerEditRoot.FindAnyWidget("ComboBox2").FindHandler(SCR_ComboBoxComponent));
236 m_ComboBoxComp2.m_OnChanged.Insert(OnComboBoxChangedB);
237
238 m_ComboBoxComp1.AddItem("");
239 m_ComboBoxComp2.AddItem("");
240
241 array<ref SCR_MarkerMilitaryType> types = m_MilitaryMarkerConfig.GetMilitaryTypes();
242 foreach (int i, SCR_MarkerMilitaryType markerType : types)
243 {
244 m_ComboBoxComp1.AddItem(markerType.GetTranslation(), false, markerType);
245 m_ComboBoxComp2.AddItem(markerType.GetTranslation(), false, markerType);
246 }
247
248 m_ComboBoxComp1.SetCurrentItem(0);
250
251 m_ComboBoxComp2.SetCurrentItem(0);
253
254 Widget editBoxRoot = m_MarkerEditRoot.FindAnyWidget("EditBoxRoot");
255 editBoxRoot.FindAnyWidget("EditBox").SetUserID(USERID_EDITBOX_MIL);
256 m_EditBoxComp = SCR_EditBoxComponent.Cast(editBoxRoot.FindHandler(SCR_EditBoxComponent));
257 m_EditBoxComp.m_OnTextChange.Insert(OnEditBoxTextChanged);
258 m_EditBoxComp.SetValue(string.Empty);
259
260 SCR_InputButtonComponent confirmComp = SCR_InputButtonComponent.Cast(m_MarkerEditRoot.FindAnyWidget("ButtonPublic").FindHandler(SCR_InputButtonComponent));
261 confirmComp.m_OnClicked.Insert(OnPlaceMarkerConfirmed);
262
263 if (isEditing)
264 confirmComp.SetLabel("#AR-ServerHosting_Edit");
265 else
266 confirmComp.SetLabel("#AR-MapMarker_PlacePublic");
267
268 confirmComp = SCR_InputButtonComponent.Cast(m_MarkerEditRoot.FindAnyWidget("ButtonCancel").FindHandler(SCR_InputButtonComponent));
269 confirmComp.m_OnClicked.Insert(OnEditCancelled);
270
271 FocusWidget(m_SelectedFactionButton.GetRootWidget());
272
273 m_CursorModule.HandleDialog(true);
274
275 Widget timestampWidget = m_MarkerEditRoot.FindAnyWidget("TimestampSpinBox");
276 if (timestampWidget)
277 {
278 m_TimestampSpinBox = SCR_SpinBoxComponent.Cast(timestampWidget.FindHandler(SCR_SpinBoxComponent));
280 m_TimestampSpinBox.SetCurrentItem(SPIN_BOX_YES, false, false);
282 }
283 }
284
285 //------------------------------------------------------------------------------------------------
286 protected void FocusWidget(Widget widget)
287 {
288 GetGame().GetWorkspace().SetFocusedWidget(widget);
289 }
290
291 //------------------------------------------------------------------------------------------------
293 protected void InitFactionIcons(int selectedFactionEntry)
294 {
295 array<ref SCR_MarkerMilitaryFactionEntry> factionsArr = m_MilitaryMarkerConfig.GetMilitaryFactionEntries();
296 Widget factionSelector = m_MarkerEditRoot.FindAnyWidget("FactionSelector");
297 Widget factionSelectorLine = factionSelector.FindAnyWidget("FactionSelectorLine");
298 m_wFactionSelectionText = TextWidget.Cast(factionSelector.FindAnyWidget("TextSelection"));
299 SCR_ButtonImageComponent firstFactionEntry;
300
301 m_mFactionIDs.Clear();
303
304 string imageset, quad;
305
306 foreach (int i, SCR_MarkerMilitaryFactionEntry factionEntry : factionsArr)
307 {
308 Widget button = GetGame().GetWorkspace().CreateWidgets(m_sSelectorIconEntry, factionSelectorLine);
309 button.SetName("FactionEntry" + i.ToString());
311 buttonComp.GetImageWidget().SetColor(factionEntry.GetColor());
312 factionEntry.GetIconResource(imageset, quad);
313 buttonComp.SetImage(imageset, quad);
314
315 buttonComp.m_OnClicked.Insert(OnFactionEntryClicked);
316 buttonComp.m_OnFocus.Insert(OnFactionEntryFocused);
317
318 m_mFactionIDs.Insert(buttonComp, i);
319
320 if (!firstFactionEntry)
321 firstFactionEntry = buttonComp;
322 }
323
324 if (selectedFactionEntry == -1)
325 {
326 OnFactionEntryClicked(firstFactionEntry);
327 }
328 else
329 {
330 SCR_ButtonBaseComponent buttonComp = SCR_MapHelper<SCR_ButtonBaseComponent, int>.GetKeyByValue(m_mFactionIDs, selectedFactionEntry);
331 if (buttonComp)
332 OnFactionEntryClicked(buttonComp);
333 else
334 OnFactionEntryClicked(firstFactionEntry);
335 }
336 }
337
338 //------------------------------------------------------------------------------------------------
340 protected void InitDimensionIcons()
341 {
342 SCR_MarkerMilitaryFactionEntry factionEntry = m_MilitaryMarkerConfig.GetFactionEntry(m_iSelectedFactionID);
343 array<ref SCR_MarkerMilitaryDimension> dimensionsArr = m_MilitaryMarkerConfig.GetMilitaryDimensions();
344 if (!factionEntry || dimensionsArr.IsEmpty())
345 return;
346
347 Widget dimensionSelector = m_MarkerEditRoot.FindAnyWidget("DimensionSelector");
348 Widget dimensionSelectorLine = dimensionSelector.FindAnyWidget("DimensionSelectorLine");
349 m_wDimensionSelectionText = TextWidget.Cast(dimensionSelector.FindAnyWidget("TextSelection"));
350 SCR_ButtonImageComponent firstDimensionEntry;
351
352 m_mDimensionIDs.Clear();
354
355 Widget child = dimensionSelectorLine.GetChildren();
356 while (child)
357 {
358 child.RemoveFromHierarchy();
359 child = dimensionSelectorLine.GetChildren();
360 }
361
362 foreach (int i, SCR_MarkerMilitaryDimension dimensionEntry : dimensionsArr)
363 {
364 Widget button = GetGame().GetWorkspace().CreateWidgets(m_sSelectorDimensionEntry, dimensionSelectorLine);
365 button.SetName("DimensionEntry" + i.ToString());
366
367 SCR_MilitarySymbol milSymbol = new SCR_MilitarySymbol();
368 milSymbol.SetIdentity(factionEntry.GetFactionIdentity());
369 milSymbol.SetDimension(dimensionEntry.GetDimension());
370
371 Widget overlay = button.FindAnyWidget("OverlaySymbol");
372 overlay.SetColor(factionEntry.GetColor());
373
375 symbolComp.Update(milSymbol);
376
378 buttonComp.m_OnClicked.Insert(OnDimensionEntryClicked);
379 buttonComp.m_OnFocus.Insert(OnDimensionEntryFocused);
380
381 m_mDimensionIDs.Insert(buttonComp, i);
382
383 if (!firstDimensionEntry)
384 firstDimensionEntry = buttonComp;
385 }
386
387 if (m_iWantedDimensionEntry == -1)
388 {
389 OnDimensionEntryClicked(firstDimensionEntry);
390 }
391 else
392 {
393 SCR_ButtonBaseComponent buttonComp = SCR_MapHelper<SCR_ButtonBaseComponent, int>.GetKeyByValue(m_mDimensionIDs, m_iWantedDimensionEntry);
394 if (buttonComp)
395 OnDimensionEntryClicked(buttonComp);
396 else
397 OnDimensionEntryClicked(firstDimensionEntry);
398 }
399 }
400
401 //------------------------------------------------------------------------------------------------
403 protected void InitColorIcons(int selectedColorEntry)
404 {
405 array<ref SCR_MarkerColorEntry> colorsArr = m_PlacedMarkerConfig.GetColorEntries();
406 Widget colorSelector = m_MarkerEditRoot.FindAnyWidget(COLOR_SELECTOR);
407 Widget colorSelectorLine = colorSelector.FindAnyWidget("ColorSelectorLine");
408 SCR_ButtonImageComponent firstColorEntry;
409
410 m_mColorIDs.Clear();
412
413 foreach (int i, SCR_MarkerColorEntry colorEntry : colorsArr)
414 {
415 Widget button = GetGame().GetWorkspace().CreateWidgets(m_sSelectorColorEntry, colorSelectorLine);
416 button.SetName(COLOR_ENTRY + i.ToString());
418 buttonComp.GetImageWidget().SetColor(colorEntry.GetColor());
419 buttonComp.m_OnClicked.Insert(OnColorEntryClicked);
420 buttonComp.m_OnFocus.Insert(OnColorEntryFocused);
421
422 m_mColorIDs.Insert(buttonComp, i);
423
424 if (!firstColorEntry)
425 firstColorEntry = buttonComp;
426 }
427
428 if (selectedColorEntry == -1)
429 {
430 OnColorEntryClicked(firstColorEntry);
431 }
432 else
433 {
434 SCR_ButtonBaseComponent buttonComp = SCR_MapHelper<SCR_ButtonBaseComponent, int>.GetKeyByValue(m_mColorIDs, selectedColorEntry);
435 if (buttonComp)
436 OnColorEntryClicked(buttonComp);
437 else
438 OnColorEntryClicked(firstColorEntry);
439 }
440 }
441
442 //------------------------------------------------------------------------------------------------
444 protected void InitCategoryIcons(SCR_TabViewContent tabContent)
445 {
446 m_mIconIDs.Clear();
448
449 string imageset, imagesetGlow, quad;
450
452 array<ref SCR_MarkerIconEntry> iconsArr = m_PlacedMarkerConfig.GetIconEntries();
453
454 Widget child = m_IconSelector.GetChildren();
455 while (child)
456 {
457 child.RemoveFromHierarchy();
458 child = m_IconSelector.GetChildren();
459 }
460
461 Widget iconSelectorLine = GetGame().GetWorkspace().CreateWidgets(SELECTOR_LINE, m_IconSelector);
463 m_iIconLines = 1;
464
465 SCR_ButtonImageComponent firstEntry;
466
467 foreach (int i, SCR_MarkerIconEntry iconEntry : iconsArr)
468 {
469 if (iconEntry.m_sCategoryIdentifier != tabContent.m_sTabIdentifier)
470 continue;
471
474 {
475 iconSelectorLine = GetGame().GetWorkspace().CreateWidgets(SELECTOR_LINE, m_IconSelector);
476 m_iIconLines++;
477 }
478
479 Widget button = GetGame().GetWorkspace().CreateWidgets(m_sSelectorIconEntry, iconSelectorLine);
480 button.SetName(ICON_ENTRY + m_iIconEntryCount.ToString());
482 m_mIconIDs.Insert(buttonComp, i);
483 if (!firstEntry)
484 firstEntry = buttonComp;
485
486 iconEntry.GetIconResource(imageset, imagesetGlow, quad);
487 buttonComp.SetImage(imageset, quad);
488 buttonComp.m_OnClicked.Insert(OnIconEntryClicked);
489 buttonComp.m_OnFocus.Insert(OnIconEntryFocused);
490 }
491
492 if (m_iWantedIconEntry == -1)
493 {
494 OnIconEntryClicked(firstEntry);
495 }
496 else
497 {
498 SCR_ButtonBaseComponent buttonComp = SCR_MapHelper<SCR_ButtonBaseComponent, int>.GetKeyByValue(m_mIconIDs, m_iWantedIconEntry);
499 if (buttonComp)
500 OnIconEntryClicked(buttonComp);
501 else
502 OnIconEntryClicked(firstEntry);
503 }
504 }
505
506 //------------------------------------------------------------------------------------------------
508 protected void CreateStaticMarkers()
509 {
510 SCR_FactionManager factionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
511
512 Faction localFaction;
513 int localFactionIndex = -1;
514 if (factionManager)
515 {
516 localFaction = factionManager.SGetLocalPlayerFaction();
517 localFactionIndex = factionManager.GetFactionIndex(localFaction);
518 }
519
520 array<SCR_MapMarkerBase> markersSimple = m_MarkerMgr.GetStaticMarkers();
521 foreach(SCR_MapMarkerBase markerDis: m_MarkerMgr.GetDisabledMarkers())
522 {
523 markersSimple.Insert(markerDis);
524 }
525
526 foreach (SCR_MapMarkerBase marker: markersSimple)
527 {
528 if (!factionManager || marker.GetMarkerFactionFlags() == 0)
529 {
530 marker.OnCreateMarker(true);
531 continue;
532 }
533
534 if (!localFaction || !marker.IsFaction(localFactionIndex))
535 {
536 if (Replication.IsServer()) // if server, enemy markers have to be kept for sync but are disabled
537 marker.SetServerDisabled(true);
538 else
539 continue;
540 }
541
542 marker.OnCreateMarker(true);
543 }
544 }
545
546 //------------------------------------------------------------------------------------------------
548 protected void CreateDynamicMarkers()
549 {
550 array<SCR_MapMarkerEntity> markersDynamic = m_MarkerMgr.GetDynamicMarkers();
551 foreach (SCR_MapMarkerEntity marker : markersDynamic)
552 {
553 marker.OnCreateMarker();
554 }
555 }
556
557 //------------------------------------------------------------------------------------------------
558 // Remove callback from radial menu
559 protected void RemoveMarkerMenu()
560 {
562 }
563
564 //------------------------------------------------------------------------------------------------
567 {
568 if (marker)
569 m_MarkerMgr.RemoveStaticMarker(marker);
570 }
571
572 //------------------------------------------------------------------------------------------------
574 protected void CleanupMarkerEditWidget()
575 {
577 m_MarkerEditRoot.RemoveFromHierarchy();
578
579 m_bIsDelayed = false;
580
581 m_CursorModule.HandleDialog(false);
582 }
583
584 //------------------------------------------------------------------------------------------------
585 protected SocialComponent GetSocialComponent()
586 {
587 PlayerController pc = GetGame().GetPlayerController();
588 if (!pc)
589 return null;
590
591 return SocialComponent.Cast(pc.FindComponent(SocialComponent));
592 }
593
594 //------------------------------------------------------------------------------------------------
595 // EVENTS
596 //------------------------------------------------------------------------------------------------
598 protected void OnTabChanged(SCR_TabViewComponent tabView, Widget widget, int index)
599 {
600 SCR_TabViewContent tab = tabView.GetEntryContent(index);
601
603 m_SliderComp.SetValue(0);
604 }
605
606 //------------------------------------------------------------------------------------------------
609 {
611 {
612 m_SelectedFactionButton.ColorizeBackground();
613 }
614
615 component.ColorizeBackground(); // this will color the button to hover color for KBM
616 m_SelectedFactionButton = component;
617 m_iSelectedFactionID = m_mFactionIDs.Get(component);
618
619 SCR_MarkerMilitaryFactionEntry entry = m_MilitaryMarkerConfig.GetFactionEntry(m_iSelectedFactionID);
620 m_wFactionSelectionText.SetText(entry.GetTranslation());
621 m_wMarkerPreviewMilitary.SetColor(entry.GetColor());
622 m_MilSymbolPreview.SetIdentity(entry.GetFactionIdentity());
624
626 }
627
628 //------------------------------------------------------------------------------------------------
630 protected void OnFactionEntryFocused(Widget rootW)
631 {
632 if (GetGame().GetInputManager().IsUsingMouseAndKeyboard())
633 return;
634
635 SCR_ButtonBaseComponent buttonComp = SCR_ButtonBaseComponent.Cast(rootW.FindHandler(SCR_ButtonBaseComponent));
636 if (buttonComp)
637 OnFactionEntryClicked(buttonComp);
638 }
639
640 //------------------------------------------------------------------------------------------------
643 {
645 {
646 m_SelectedDimensionButton.ColorizeBackground();
647 }
648
649 component.ColorizeBackground(); // this will color the button to hover color for KBM
650 m_SelectedDimensionButton = component;
653
654 SCR_MarkerMilitaryDimension entry = m_MilitaryMarkerConfig.GetDimensionEntry(m_iSelectedDimensionID);
655 m_wDimensionSelectionText.SetText(entry.GetTranslation());
656 m_MilSymbolPreview.SetDimension(entry.GetDimension());
658 }
659
660 //------------------------------------------------------------------------------------------------
662 protected void OnDimensionEntryFocused(Widget rootW)
663 {
664 if (GetGame().GetInputManager().IsUsingMouseAndKeyboard())
665 return;
666
667 SCR_ButtonBaseComponent buttonComp = SCR_ButtonBaseComponent.Cast(rootW.FindHandler(SCR_ButtonBaseComponent));
668 if (buttonComp)
669 OnDimensionEntryClicked(buttonComp);
670 }
671
672 //------------------------------------------------------------------------------------------------
675 {
677 {
678 m_SelectedColorButton.ColorizeBackground();
679 }
680
681 component.ColorizeBackground(); // this will color the button to hover color for KBM
682 m_SelectedColorButton = component;
683 m_iSelectedColorID = m_mColorIDs.Get(component);
684
686 }
687
688 //------------------------------------------------------------------------------------------------
690 protected void OnColorEntryFocused(Widget rootW)
691 {
692 if (GetGame().GetInputManager().IsUsingMouseAndKeyboard())
693 return;
694
695 SCR_ButtonBaseComponent buttonComp = SCR_ButtonBaseComponent.Cast(rootW.FindHandler(SCR_ButtonBaseComponent));
696 if (buttonComp)
697 OnColorEntryClicked(buttonComp);
698 }
699
700 //------------------------------------------------------------------------------------------------
702 protected void OnIconEntryClicked(notnull SCR_ButtonBaseComponent component)
703 {
705 {
706 m_SelectedIconButton.ColorizeBackground();
707 }
708
709 component.ColorizeBackground(); // this will color the button to hover color for KBM
710 m_SelectedIconButton = component;
711 m_iSelectedIconID = m_mIconIDs.Get(component);
712
713 ResourceName imageset, imagesetGlow;
714 string quad;
715 m_PlacedMarkerConfig.GetIconEntry(m_iSelectedIconID, imageset, imagesetGlow, quad);
716
717 m_wMarkerPreview.LoadImageFromSet(0, imageset, quad);
718 m_wMarkerPreviewGlow.LoadImageFromSet(0, imagesetGlow, quad);
719 }
720
721 //------------------------------------------------------------------------------------------------
723 protected void OnIconEntryFocused(Widget rootW)
724 {
725 if (GetGame().GetInputManager().IsUsingMouseAndKeyboard())
726 return;
727
728 SCR_ButtonBaseComponent buttonComp = SCR_ButtonBaseComponent.Cast(rootW.FindHandler(SCR_ButtonBaseComponent));
729 if (buttonComp)
730 OnIconEntryClicked(buttonComp);
731 }
732
733 //------------------------------------------------------------------------------------------------
735 protected void OnEditBoxTextChanged(string text)
736 {
737 m_wMarkerPreviewText.SetText(text);
738 }
739
740 //------------------------------------------------------------------------------------------------
742 protected void OnSliderChanged(SCR_SliderComponent slider, float value)
743 {
744 m_wMarkerPreview.SetRotation(value);
745 m_wMarkerPreviewGlow.SetRotation(value);
746 m_fRotation = value;
747 }
748
749 //------------------------------------------------------------------------------------------------
751 protected void OnComboBoxChangedA(SCR_ComboBoxComponent comp, int value)
752 {
753 m_eMilitaryTypeA = SCR_MarkerMilitaryType.Cast(comp.GetItemData(value));
756 else
758
761 }
762
763 //------------------------------------------------------------------------------------------------
765 protected void OnComboBoxChangedB(SCR_ComboBoxComponent comp, int value)
766 {
767 m_eMilitaryTypeB = SCR_MarkerMilitaryType.Cast(comp.GetItemData(value));
770 else
772
775 }
776
777 //------------------------------------------------------------------------------------------------
779 protected void OnTimestampSpinBoxChanged(SCR_SpinBoxComponent comp, int selectedItem)
780 {
781 m_bIsTimestampVisible = selectedItem == SPIN_BOX_YES;
782 }
783
784 //------------------------------------------------------------------------------------------------
787 {
788 if (m_EditedMarker)
789 {
791 m_EditedMarker = null;
792 }
793
794 OnInsertMarker(false);
795 }
796
797 //------------------------------------------------------------------------------------------------
800 {
801 OnInsertMarker(true);
802 }
803
804 //------------------------------------------------------------------------------------------------
807 {
808 if (m_EditedMarker)
809 {
810 m_EditedMarker.SetVisible(true);
811 m_EditedMarker = null;
812 }
813
815 }
816
817 //------------------------------------------------------------------------------------------------
818 protected void OnInsertMarker(bool isLocal)
819 {
820 float wX, wY;
821 m_MapEntity.GetMapCenterWorldPosition(wX, wY);
822
824
826 {
827 marker.SetType(SCR_EMapMarkerType.PLACED_MILITARY);
829 marker.SetMarkerConfigID(m_iSelectedDimensionID * 100 + m_iSelectedFactionID); // combination of faction and dimension id
830 }
831 else
832 {
833 marker.SetType(SCR_EMapMarkerType.PLACED_CUSTOM);
834 marker.SetRotation(m_fRotation);
837 }
838
839 marker.SetCustomText(m_EditBoxComp.GetValue());
840 marker.SetWorldPos(wX, wY);
842
843 ChimeraWorld world = GetGame().GetWorld();
844 if (world)
845 marker.SetTimestamp(world.GetServerTimestamp());
846
847 if (!isLocal)
848 {
849 FactionManager factionManager = GetGame().GetFactionManager();
850 if (factionManager)
851 {
852 Faction markerOwnerFaction = SCR_FactionManager.SGetPlayerFaction(GetGame().GetPlayerController().GetPlayerId());
853 if (markerOwnerFaction)
854 marker.AddMarkerFactionFlags(factionManager.GetFactionIndex(markerOwnerFaction));
855 }
856 }
857
858 m_MarkerMgr.InsertStaticMarker(marker, isLocal);
859 m_OnCustomMarkerPlaced.Invoke(wX, wY, isLocal);
860
862 }
863
864 //------------------------------------------------------------------------------------------------
866 protected void OnRadialMenuInit()
867 {
868 SCR_MapMarkerConfig markerConfig = m_MarkerMgr.GetMarkerConfig();
869 if (!markerConfig)
870 return;
871
872 SCR_MapRadialUI radialUI = SCR_MapRadialUI.Cast(m_MapEntity.GetMapUIComponent(SCR_MapRadialUI));
873
876
877 array<ref SCR_MapMarkerEntryConfig> entryConfigs = markerConfig.GetMarkerEntryConfigs();
878
879 foreach (SCR_MapMarkerEntryConfig entry : entryConfigs) // menu entries
880 {
881 if (entry.GetMarkerType() == SCR_EMapMarkerType.PLACED_MILITARY)
882 {
884
886 menuEntry.SetMarkerType(SCR_EMapMarkerType.PLACED_MILITARY);
887 menuEntry.SetName(entryMil.GetMenuDescription());
888 menuEntry.GetOnPerform().Insert(OnEntryPerformed);
889 menuEntry.SetIcon(entryMil.GetMenuImageset(), entryMil.GetMenuIcon());
890
891 radialUI.InsertCustomRadialEntry(menuEntry, m_RootCategoryEntry);
892 }
893 else if (entry.GetMarkerType() == SCR_EMapMarkerType.PLACED_CUSTOM)
894 {
895 SCR_MapMarkerEntryPlaced entryPlaced = SCR_MapMarkerEntryPlaced.Cast(entry);
896
898 menuEntry.SetMarkerType(SCR_EMapMarkerType.PLACED_CUSTOM);
899 menuEntry.SetName(entryPlaced.GetMenuDescription());
900 menuEntry.GetOnPerform().Insert(OnEntryPerformed);
901 menuEntry.SetIcon(entryPlaced.GetMenuImageset(), entryPlaced.GetMenuIcon());
902
903 radialUI.InsertCustomRadialEntry(menuEntry, m_RootCategoryEntry);
904 }
905 else if (entry.GetMarkerType() == SCR_EMapMarkerType.PLACED_RECON)
906 {
907 SCR_MapMarkerEntryRecon entryRecon = SCR_MapMarkerEntryRecon.Cast(entry);
909 m_ReconCategoryEntry.SetName(entryRecon.GetMenuDescription());
910 m_ReconCategoryEntry.SetIcon(entryRecon.GetMenuImageset(), entryRecon.GetMenuIcon());
911
912 entryRecon.CreateEntries(radialUI, m_ReconCategoryEntry);
913
914 // radial category is deleted if nothing is added to the entry
915 if (m_ReconCategoryEntry.GetEntries().IsEmpty())
916 {
918 }
919 }
920 }
921 }
922
923 //------------------------------------------------------------------------------------------------
925 protected void OnRadialMenuOpen(SCR_RadialMenuController controller, bool hasControl)
926 {
927 SCR_MapRadialUI radialUI = SCR_MapRadialUI.Cast(m_MapEntity.GetMapUIComponent(SCR_MapRadialUI));
929 {
931 m_RemovableMarker = null;
932 }
933
934 // delete marker button
935 array<Widget> widgets = SCR_MapCursorModule.GetMapWidgetsUnderCursor();
936
938 foreach ( Widget widget : widgets )
939 {
940 markerComp = SCR_MapMarkerWidgetComponent.Cast(widget.FindHandler(SCR_MapMarkerWidgetComponent));
941 if (!markerComp)
942 continue;
943
944 SCR_MapMarkerBase marker = m_MarkerMgr.GetMarkerByWidget(widget);
945 if (marker)
946 {
947 if (!marker.CanBeRemovedByOwner() || (marker.GetType() != SCR_EMapMarkerType.PLACED_CUSTOM && marker.GetType() != SCR_EMapMarkerType.PLACED_MILITARY))
948 continue;
949
950 m_MarkerRemoveEntry = radialUI.AddRadialEntry("#AR-MapMarker_DeleteHint");
952 m_MarkerRemoveEntry.GetOnPerform().Insert(RemoveMarkerMenu);
953
954 m_RemovableMarker = marker;
955
956 return;
957 }
958 }
959 }
960
961 //------------------------------------------------------------------------------------------------
964 {
965 SCR_MapMarkerMenuEntry markerEntry = SCR_MapMarkerMenuEntry.Cast(entry);
966
967 if (markerEntry.GetMarkerType() == SCR_EMapMarkerType.PLACED_CUSTOM)
968 {
970 {
971 SCR_MapMarkerConfig markerConfig = m_MarkerMgr.GetMarkerConfig();
972 if (!markerConfig)
973 return;
974
975 m_PlacedMarkerConfig = SCR_MapMarkerEntryPlaced.Cast(markerConfig.GetMarkerEntryConfigByType(markerEntry.GetMarkerType()));
977 return;
978 }
979
981 }
982 else if (markerEntry.GetMarkerType() == SCR_EMapMarkerType.PLACED_MILITARY)
983 {
985 {
986 SCR_MapMarkerConfig markerConfig = m_MarkerMgr.GetMarkerConfig();
987 if (!markerConfig)
988 return;
989
990 m_MilitaryMarkerConfig = SCR_MapMarkerEntryMilitary.Cast(markerConfig.GetMarkerEntryConfigByType(markerEntry.GetMarkerType()));
992 return;
993 }
994
996 }
997 }
998
999 //------------------------------------------------------------------------------------------------
1001 protected void OnInputQuickMarkerMenu(float value, EActionTrigger reason)
1002 {
1004 if (!mapRadial)
1005 return;
1006
1007 Widget focusedWidget = GetGame().GetWorkspace().GetFocusedWidget();
1008 if (focusedWidget)
1009 return;
1010
1011 mapRadial.GetRadialController().OnInputOpen();
1012
1013 // Callqueue fixes selecting in the radial
1014 GetGame().GetCallqueue().Call(DelayedQuickMarkerMenu);
1015 }
1016
1017 //------------------------------------------------------------------------------------------------
1018 protected void DelayedQuickMarkerMenu()
1019 {
1021 if (!mapRadial)
1022 return;
1023
1024 if (m_ReconCategoryEntry && m_ReconCategoryEntry.IsEnabled())
1025 mapRadial.GetRadialController().GetRadialMenu().PerformEntry(m_ReconCategoryEntry);
1026 else
1027 mapRadial.GetRadialController().GetRadialMenu().PerformEntry(m_RootCategoryEntry);
1028 }
1029
1030 //------------------------------------------------------------------------------------------------
1032 protected void OnInputMarkerDelete(float value, EActionTrigger reason)
1033 {
1034 array<Widget> widgets = SCR_MapCursorModule.GetMapWidgetsUnderCursor();
1035
1037 foreach ( Widget widget : widgets )
1038 {
1039 markerComp = SCR_MapMarkerWidgetComponent.Cast(widget.FindHandler(SCR_MapMarkerWidgetComponent));
1040 if (!markerComp)
1041 continue;
1042
1043 SCR_MapMarkerBase marker = m_MarkerMgr.GetMarkerByWidget(widget);
1044 if (marker)
1045 {
1046 if (marker.GetType() != SCR_EMapMarkerType.PLACED_CUSTOM && marker.GetType() != SCR_EMapMarkerType.PLACED_MILITARY)
1047 continue;
1048
1049 if (!marker.CanBeRemovedByOwner())
1050 continue;
1051
1052 RemoveOwnedMarker(marker);
1053 }
1054 }
1055 }
1056
1057 //------------------------------------------------------------------------------------------------
1059 protected void OnInputMapSelect(float value, EActionTrigger reason)
1060 {
1061 if ((m_CursorModule.GetCursorState() & SCR_MapCursorModule.STATE_POPUP_RESTRICTED) != 0)
1062 return;
1063
1064 array<Widget> widgets = SCR_MapCursorModule.GetMapWidgetsUnderCursor();
1065
1067 foreach ( Widget widget : widgets )
1068 {
1069 markerComp = SCR_MapMarkerWidgetComponent.Cast(widget.FindHandler(SCR_MapMarkerWidgetComponent));
1070 if (!markerComp)
1071 continue;
1072
1073 SCR_MapMarkerBase marker = m_MarkerMgr.GetMarkerByWidget(widget);
1074 if (!marker)
1075 continue;
1076
1077 m_EditedMarker = marker;
1078 SCR_EMapMarkerType type = marker.GetType();
1079
1080 if (IsOwnedMarker(marker) && (type == SCR_EMapMarkerType.PLACED_CUSTOM || type == SCR_EMapMarkerType.PLACED_MILITARY))
1081 {
1082 int wPos[2];
1083 float screenX, screenY;
1084 marker.GetWorldPos(wPos);
1085 m_MapEntity.WorldToScreen(wPos[0], wPos[1], screenX, screenY);
1086 m_MapEntity.PanSmooth(screenX, screenY, 0.1);
1087
1088 if (type == SCR_EMapMarkerType.PLACED_CUSTOM )
1089 {
1091 return;
1092
1093 CreateMarkerEditDialog(true, m_PlacedMarkerConfig.GetIconCategoryID(marker.GetIconEntry()), marker.GetIconEntry(), marker.GetColorEntry());
1094
1096 m_SliderComp.SetValue(marker.GetRotation());
1097 m_EditBoxComp.SetValue(marker.GetCustomText());
1098 }
1099 else
1100 {
1102 return;
1103
1106 m_EditBoxComp.SetValue(marker.GetCustomText());
1107
1108 int markerFlags = marker.GetFlags();
1109 bool secondType;
1110
1111 array<ref SCR_MarkerMilitaryType> milTypes = m_MilitaryMarkerConfig.GetMilitaryTypes();
1112 foreach (int i, SCR_MarkerMilitaryType milType : milTypes)
1113 {
1114 if (markerFlags & milType.GetType())
1115 {
1116 if (secondType)
1117 {
1118 m_ComboBoxComp2.SetCurrentItem(i+1); // +1 is here and below since we add a NONE entry to the combo boxes during creation
1120 break;
1121 }
1122 else
1123 {
1124 m_ComboBoxComp1.SetCurrentItem(i+1);
1126 if (markerFlags == milType.GetType()) // return if singular flag
1127 break;
1128
1129 secondType = true;
1130 }
1131 }
1132 }
1133
1135 {
1136 bool showTimestamp = marker.IsTimestampVisible();
1137 m_TimestampSpinBox.SetCurrentItem(showTimestamp, false, false);
1139 }
1140 }
1141
1142 marker.SetVisible(false);
1143
1144 break;
1145 }
1146 }
1147 }
1148
1149 //------------------------------------------------------------------------------------------------
1151 protected void OnInputMenuConfirm(float value, EActionTrigger reason)
1152 {
1153 if (!m_bIsDelayed)
1154 return;
1155
1156 Widget focused = GetGame().GetWorkspace().GetFocusedWidget();
1157 if (!focused || focused.GetUserID() == USERID_EDITBOX || focused.GetUserID() == USERID_EDITBOX_MIL)
1158 return;
1159
1160 if (m_ComboBoxComp1 && (m_ComboBoxComp1.IsOpened() || m_ComboBoxComp1.GetRootWidget().FindAnyWidget("ComboButton") == focused))
1161 return;
1162
1163 if (m_ComboBoxComp2 && (m_ComboBoxComp2.IsOpened() || m_ComboBoxComp2.GetRootWidget().FindAnyWidget("ComboButton") == focused))
1164 return;
1165
1166 if (m_MarkerEditRoot)
1168 }
1169
1170 //------------------------------------------------------------------------------------------------
1172 protected void OnInputMenuConfirmAlter(float value, EActionTrigger reason)
1173 {
1174 if (m_MarkerEditRoot)
1176 }
1177
1178 //------------------------------------------------------------------------------------------------
1180 protected void OnInputMenuBack(float value, EActionTrigger reason)
1181 {
1182 if (m_MarkerEditRoot)
1183 OnEditCancelled(null);
1184 }
1185
1186 //------------------------------------------------------------------------------------------------
1187 protected void OnInputMenuDown(float value, EActionTrigger reason)
1188 {
1189 string name;
1190
1191 Widget focused = GetGame().GetWorkspace().GetFocusedWidget();
1192 if (focused)
1193 name = focused.GetName();
1194
1195 if (name.Contains(ICON_ENTRY))
1196 FocusWidget(m_SelectedColorButton.GetRootWidget());
1197 else if (name.Contains("FactionEntry"))
1198 FocusWidget(m_SelectedDimensionButton.GetRootWidget());
1199 }
1200
1201 //------------------------------------------------------------------------------------------------
1202 protected void OnInputMenuUp(float value, EActionTrigger reason)
1203 {
1204 string name;
1205
1206 Widget focused = GetGame().GetWorkspace().GetFocusedWidget();
1207 if (!focused)
1208 return;
1209
1210 name = focused.GetName();
1211
1212 if (name.Contains(COLOR_ENTRY))
1213 FocusWidget(m_SelectedIconButton.GetRootWidget());
1214 else if (focused.GetUserID() == USERID_EDITBOX)
1215 FocusWidget(m_SelectedColorButton.GetRootWidget());
1216 else if (focused.GetUserID() == USERID_EDITBOX_MIL)
1217 FocusWidget(m_ComboBoxComp2.GetRootWidget());
1218 else if (name.Contains("DimensionEntry"))
1219 FocusWidget(m_SelectedFactionButton.GetRootWidget());
1220 else if (name.Contains("ComboButton"))
1221 {
1222 while (focused.GetParent() != null)
1223 {
1224 focused = focused.GetParent();
1225 if (focused.GetName().Contains("ComboBox1"))
1226 {
1227 FocusWidget(m_SelectedDimensionButton.GetRootWidget());
1228 break;
1229 }
1230 }
1231 }
1232 }
1233
1234 //------------------------------------------------------------------------------------------------
1235 protected void OnInputMenuLeft(float value, EActionTrigger reason)
1236 {
1237 string name;
1238
1239 Widget focused = GetGame().GetWorkspace().GetFocusedWidget();
1240 if (focused)
1241 name = focused.GetName();
1242
1243 if (!name.Contains(ICON_ENTRY))
1244 return;
1245
1246 int pos = name.ToInt(offset: 9);
1247 int target = pos - 1;
1248
1249 if (target < 1)
1250 target = m_iIconEntryCount;
1251
1252 Widget w = m_IconSelector.FindAnyWidget(ICON_ENTRY + target);
1253 if (w)
1254 FocusWidget(w);
1255 }
1256
1257 //------------------------------------------------------------------------------------------------
1258 protected void OnInputMenuRight(float value, EActionTrigger reason)
1259 {
1260 string name;
1261
1262 Widget focused = GetGame().GetWorkspace().GetFocusedWidget();
1263 if (focused)
1264 name = focused.GetName();
1265
1266 if (!name.Contains(ICON_ENTRY))
1267 return;
1268
1269 int pos = name.ToInt(offset: 9);
1270 int target = pos + 1;
1271
1272 if (target > m_iIconEntryCount)
1273 target = 1;
1274
1275 Widget w = m_IconSelector.FindAnyWidget(ICON_ENTRY + target);
1276 if (w)
1277 FocusWidget(w);
1278 }
1279
1280 //------------------------------------------------------------------------------------------------
1282 protected void OnDragWidget(Widget widget)
1283 {
1284 SCR_MapMarkerBase marker = m_MarkerMgr.GetMarkerByWidget(widget);
1285 if (marker)
1286 {
1287 if (!IsOwnedMarker(marker) || (marker.GetType() != SCR_EMapMarkerType.PLACED_CUSTOM && marker.GetType() != SCR_EMapMarkerType.PLACED_MILITARY) )
1288 return;
1289
1290 marker.SetDragged(true);
1291 }
1292 }
1293
1294 //------------------------------------------------------------------------------------------------
1296 protected void OnDragEnd(Widget widget, bool wasDragged)
1297 {
1298 SCR_MapMarkerBase marker = m_MarkerMgr.GetMarkerByWidget(widget);
1299 if (marker)
1300 {
1301 SCR_EMapMarkerType type = marker.GetType();
1302
1303 if (!IsOwnedMarker(marker) || (type != SCR_EMapMarkerType.PLACED_CUSTOM && type != SCR_EMapMarkerType.PLACED_MILITARY))
1304 return;
1305
1306 marker.SetDragged(false);
1307
1308 if (!wasDragged)
1309 return;
1310
1311 vector pos = FrameSlot.GetPos(widget);
1312
1313 float wX, wY;
1314 m_MapEntity.ScreenToWorld(GetGame().GetWorkspace().DPIScale(pos[0]), GetGame().GetWorkspace().DPIScale(pos[1]), wX, wY);
1315
1316 marker.SetWorldPos(wX, wY); // set the old marker pos here as well because of the delay it takes between client and server to delete it
1317
1318 SCR_MapMarkerBase markerNew = new SCR_MapMarkerBase();
1319 markerNew.SetType(marker.GetType());
1320 markerNew.SetWorldPos(wX, wY);
1321 markerNew.SetCustomText(marker.GetCustomText());
1322 markerNew.SetMarkerFactionFlags(marker.GetMarkerFactionFlags());
1323 markerNew.SetTimestampVisibility(marker.IsTimestampVisible());
1324
1325 ChimeraWorld world = GetGame().GetWorld();
1326 if (world)
1327 markerNew.SetTimestamp(world.GetServerTimestamp());
1328
1329 if (type == SCR_EMapMarkerType.PLACED_CUSTOM)
1330 {
1331 markerNew.SetColorEntry(marker.GetColorEntry());
1332 markerNew.SetIconEntry(marker.GetIconEntry());
1333 markerNew.SetRotation(marker.GetRotation());
1334 }
1335 else
1336 {
1337 markerNew.SetFlags(marker.GetFlags());
1338 markerNew.SetMarkerConfigID(marker.GetMarkerConfigID()); // combination of faction and dimension id
1339 }
1340
1341 int markerID = marker.GetMarkerID();
1342 RemoveOwnedMarker(marker);
1343
1344 bool isLocal = markerID == -1;
1345 m_MarkerMgr.InsertStaticMarker(markerNew, isLocal);
1346
1347 m_OnCustomMarkerPlaced.Invoke(wX, wY, isLocal);
1348 }
1349 }
1350
1351 //------------------------------------------------------------------------------------------------
1352 // OVERRIDES
1353 //------------------------------------------------------------------------------------------------
1354 override void OnMapOpen(MapConfiguration config)
1355 {
1356 super.OnMapOpen(config);
1357
1360
1361 m_MarkerMgr.EnableUpdate(true); // run frame update manager side
1362
1363 GetGame().GetInputManager().AddActionListener("MapQuickMarkerMenu", EActionTrigger.DOWN, OnInputQuickMarkerMenu);
1364 GetGame().GetInputManager().AddActionListener("MapMarkerDelete", EActionTrigger.DOWN, OnInputMarkerDelete);
1365 GetGame().GetInputManager().AddActionListener("MapSelect", EActionTrigger.DOWN, OnInputMapSelect);
1366 GetGame().GetInputManager().AddActionListener(UIConstants.MENU_ACTION_SELECT, EActionTrigger.DOWN, OnInputMenuConfirm);
1367 GetGame().GetInputManager().AddActionListener("MenuRefresh", EActionTrigger.DOWN, OnInputMenuConfirmAlter);
1368 GetGame().GetInputManager().AddActionListener(UIConstants.MENU_ACTION_BACK, EActionTrigger.DOWN, OnInputMenuBack);
1369 GetGame().GetInputManager().AddActionListener(UIConstants.MENU_ACTION_DOWN, EActionTrigger.DOWN, OnInputMenuDown);
1370 GetGame().GetInputManager().AddActionListener(UIConstants.MENU_ACTION_UP, EActionTrigger.DOWN, OnInputMenuUp);
1371 GetGame().GetInputManager().AddActionListener(UIConstants.MENU_ACTION_RIGHT, EActionTrigger.DOWN, OnInputMenuRight);
1372 GetGame().GetInputManager().AddActionListener(UIConstants.MENU_ACTION_LEFT, EActionTrigger.DOWN, OnInputMenuLeft);
1373
1374 if ( SCR_MapToolInteractionUI.Cast(m_MapEntity.GetMapUIComponent(SCR_MapToolInteractionUI)) ) // if dragging available, add callback
1375 {
1376 SCR_MapToolInteractionUI.GetOnDragWidgetInvoker().Insert(OnDragWidget);
1377 SCR_MapToolInteractionUI.GetOnDragEndInvoker().Insert(OnDragEnd);
1378 }
1379
1380 SCR_MapMarkerConfig markerConfig = m_MarkerMgr.GetMarkerConfig();
1381 if (markerConfig)
1382 {
1383 foreach (SCR_MapMarkerEntryConfig entryType : markerConfig.GetMarkerEntryConfigs())
1384 {
1385 entryType.OnMapOpen(m_MapEntity, this);
1386 }
1387 }
1388 }
1389
1390 //------------------------------------------------------------------------------------------------
1391 override void OnMapClose(MapConfiguration config)
1392 {
1393 SCR_MapMarkerConfig markerConfig = m_MarkerMgr.GetMarkerConfig();
1394 if (!markerConfig)
1395 return;
1396
1397 foreach (SCR_MapMarkerEntryConfig entryType : markerConfig.GetMarkerEntryConfigs())
1398 {
1399 entryType.OnMapClose(m_MapEntity, this);
1400 }
1401
1403 GetGame().GetInputManager().RemoveActionListener("MapQuickMarkerMenu", EActionTrigger.DOWN, OnInputQuickMarkerMenu);
1404 GetGame().GetInputManager().RemoveActionListener("MapMarkerDelete", EActionTrigger.DOWN, OnInputMarkerDelete);
1405 GetGame().GetInputManager().RemoveActionListener("MapSelect", EActionTrigger.DOWN, OnInputMapSelect);
1406 GetGame().GetInputManager().RemoveActionListener(UIConstants.MENU_ACTION_SELECT, EActionTrigger.DOWN, OnInputMenuConfirm);
1407 GetGame().GetInputManager().RemoveActionListener("MenuRefresh", EActionTrigger.DOWN, OnInputMenuConfirmAlter);
1408 GetGame().GetInputManager().RemoveActionListener(UIConstants.MENU_ACTION_BACK, EActionTrigger.DOWN, OnInputMenuBack);
1409 GetGame().GetInputManager().RemoveActionListener(UIConstants.MENU_ACTION_DOWN, EActionTrigger.DOWN, OnInputMenuDown);
1410 GetGame().GetInputManager().RemoveActionListener(UIConstants.MENU_ACTION_UP, EActionTrigger.DOWN, OnInputMenuUp);
1411 GetGame().GetInputManager().RemoveActionListener(UIConstants.MENU_ACTION_RIGHT, EActionTrigger.DOWN, OnInputMenuRight);
1412 GetGame().GetInputManager().RemoveActionListener(UIConstants.MENU_ACTION_LEFT, EActionTrigger.DOWN, OnInputMenuLeft);
1413
1414 m_MarkerMgr.EnableUpdate(false);
1415 super.OnMapClose(config);
1416 }
1417
1418 //------------------------------------------------------------------------------------------------
1419 override void Init()
1420 {
1421 SCR_MapRadialUI radialMenu = SCR_MapRadialUI.Cast(m_MapEntity.GetMapUIComponent(SCR_MapRadialUI));
1422 if (radialMenu)
1423 {
1424 radialMenu.GetOnMenuInitInvoker().Insert(OnRadialMenuInit);
1426 }
1427
1428 m_CursorModule = SCR_MapCursorModule.Cast(m_MapEntity.GetMapModule(SCR_MapCursorModule));
1429
1430 m_MarkerMgr = SCR_MapMarkerManagerComponent.Cast(GetGame().GetGameMode().FindComponent(SCR_MapMarkerManagerComponent));
1431 SCR_MapMarkerConfig markerConfig = m_MarkerMgr.GetMarkerConfig();
1432 if (!markerConfig)
1433 return;
1434
1435 m_PlacedMarkerConfig = SCR_MapMarkerEntryPlaced.Cast(markerConfig.GetMarkerEntryConfigByType(SCR_EMapMarkerType.PLACED_CUSTOM));
1436 m_MilitaryMarkerConfig = SCR_MapMarkerEntryMilitary.Cast(markerConfig.GetMarkerEntryConfigByType(SCR_EMapMarkerType.PLACED_MILITARY));
1437
1438 array<ref SCR_MapMarkerEntryConfig> entryConfigs = markerConfig.GetMarkerEntryConfigs();
1439
1440 foreach (SCR_MapMarkerEntryConfig entryType : entryConfigs)
1441 {
1442 entryType.OnMapInit(m_MapEntity, this);
1443 }
1444 }
1445
1446 //------------------------------------------------------------------------------------------------
1447 override void Update(float timeSlice)
1448 {
1449 if (m_MarkerEditRoot)
1450 {
1451 if (!m_bIsDelayed)
1452 {
1453 m_bIsDelayed = true;
1454 return;
1455 }
1456
1457 GetGame().GetInputManager().ActivateContext("MapMarkerEditContext");
1458 }
1459 }
1460}
EMilitarySymbolIdentity
EMilitarySymbolDimension
EMilitarySymbolIcon
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_BaseGameMode GetGameMode()
InputManager GetInputManager()
EDamageType type
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
void SCR_FactionManager(IEntitySource src, IEntity parent)
SCR_EMapMarkerType
func MarkerPlacedInvoker
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition Color.c:13
Main replication API.
Definition Replication.c:14
Base class for any button, regardless its own content.
void ColorizeBackground(bool animate=true)
void SetLabel(string label)
PUBLIC API\.
override void SetEnabled(bool enabled, bool animate=true)
void SetDragged(bool state)
Set dragged state.
void SetRotation(int angle)
void SetColorEntry(int colorEntry)
void AddMarkerFactionFlags(int flags)
Add faction index to flags which you can acquire by calling GetFactionIndex().
void SetVisible(bool state)
Used for temporary reasons such as hiding original marker during edit, not for filtering visiblity.
void SetMarkerFactionFlags(int flags)
Set faction flags directly without converting the faction indices.
void SetIconEntry(int iconEntry)
void SetFlags(int flags)
SCR_EMapMarkerType GetType()
void SetTimestamp(WorldTimestamp timestamp)
void SetMarkerConfigID(int id)
void SetCustomText(string text)
void GetWorldPos(out int pos[2])
void SetType(SCR_EMapMarkerType type)
void SetWorldPos(int posX, int posY)
void SetTimestampVisibility(bool isVisible)
int GetMarkerFactionFlags()
Get faction flags representing indices of factions within FactionManager prefab.
Base entry config.
Marker military symbol entry.
ResourceName GetMenuImageset()
const float DIMENSION_DETERMINATOR
string GetMenuDescription()
const int FACTION_DETERMINATOR
string GetMenuIcon()
Marker entry which can be placed through map.
string GetMenuIcon()
ResourceName GetMenuImageset()
string GetMenuDescription()
Marker recon symbol entry - combination of military and custom symbols.
ResourceName GetMenuImageset()
string GetMenuDescription()
string GetMenuIcon()
void CreateEntries(notnull SCR_MapRadialUI radialUI, notnull SCR_SelectionMenuCategoryEntry parent=null)
Base entry for marker selection menu.
void SetMarkerType(SCR_EMapMarkerType type)
SCR_EMapMarkerType GetMarkerType()
Markers UI map component.
void OnInputMapSelect(float value, EActionTrigger reason)
Marker select.
EMilitarySymbolIcon m_eMilitaryTypeAIcon
void OnPlaceMarkerConfirmed(SCR_InputButtonComponent button)
SCR_ButtonTextComponent event.
void OnIconEntryClicked(notnull SCR_ButtonBaseComponent component)
SCR_ButtonImageComponent event.
void CreateMilitaryMarkerEditDialog(bool isEditing=false, int selectedFactionEntry=-1, int selectedDimensionEntry=-1)
SCR_ComboBoxComponent m_ComboBoxComp1
TextWidget m_wFactionSelectionText
OverlayWidget m_wMarkerPreviewMilitary
void CreateMarkerEditDialog(bool isEditing=false, int tabID=0, int selectedIconEntry=-1, int selectedColorEntry=-1)
void OnRadialMenuInit()
SCR_MapRadialUI event.
EMilitarySymbolIcon m_eMilitaryTypeBIcon
void OnDragEnd(Widget widget, bool wasDragged)
SCR_MapToolInteractionUI event.
SCR_ButtonBaseComponent m_SelectedIconButton
ref map< SCR_ButtonBaseComponent, int > m_mFactionIDs
SCR_ButtonBaseComponent m_SelectedDimensionButton
SCR_MilitarySymbolUIComponent m_MarkerPreviewMilitaryComp
ResourceName m_sEditBoxLayout
void OnSliderChanged(SCR_SliderComponent slider, float value)
SCR_SliderComponent event.
SCR_MapMarkerEntryPlaced m_PlacedMarkerConfig
void OnInputMenuConfirmAlter(float value, EActionTrigger reason)
Menu alternative confirm bind.
ref Color BACKGROUND_DEFAULT
void OnFactionEntryClicked(SCR_ButtonBaseComponent component)
SCR_ButtonImageComponent event.
SCR_EditBoxComponent m_EditBoxComp
ResourceName m_sSelectorDimensionEntry
SCR_MarkerMilitaryType m_eMilitaryTypeA
void OnInputMenuConfirm(float value, EActionTrigger reason)
Menu select/confirm bind.
SCR_MapCursorModule m_CursorModule
SCR_SpinBoxComponent m_TimestampSpinBox
void OnColorEntryFocused(Widget rootW)
SCR_ButtonImageComponent event.
void CleanupMarkerEditWidget()
Marker edit widget removal.
void InitDimensionIcons()
Init dimension icons.
ScriptInvokerBase< MarkerPlacedInvoker > GetOnCustomMarkerPlaced()
void OnPlaceMarkerConfirmedPrivate(SCR_InputButtonComponent button)
SCR_ButtonTextComponent event.
void OnInputMenuBack(float value, EActionTrigger reason)
Menu back/escape bind.
void OnInputQuickMarkerMenu(float value, EActionTrigger reason)
Quick open input for marker category.
void CreateStaticMarkers()
Create static markers.
static bool IsOwnedMarker(notnull SCR_MapMarkerBase marker)
Check whether the marker is owned by the local player.
ResourceName m_sIconImageset
const string ICON_SELECTOR
SCR_SelectionMenuEntry m_MarkerRemoveEntry
void OnInputMenuLeft(float value, EActionTrigger reason)
const ResourceName SELECTOR_LINE
void OnComboBoxChangedB(SCR_ComboBoxComponent comp, int value)
SCR_ComboBoxComponent event.
override void Update(float timeSlice)
void OnInputMenuRight(float value, EActionTrigger reason)
void OnColorEntryClicked(SCR_ButtonBaseComponent component)
SCR_ButtonImageComponent event.
void OnRadialMenuOpen(SCR_RadialMenuController controller, bool hasControl)
SCR_RadialMenuController event.
void OnDragWidget(Widget widget)
SCR_MapToolInteractionUI event.
ResourceName m_sSelectorIconEntry
override void Init()
ref ScriptInvokerBase< MarkerPlacedInvoker > m_OnCustomMarkerPlaced
ref map< SCR_ButtonBaseComponent, int > m_mDimensionIDs
SCR_SelectionMenuCategoryEntry m_ReconCategoryEntry
void OnInputMenuUp(float value, EActionTrigger reason)
ref Color BACKGROUND_SELECTED
SCR_ButtonBaseComponent m_SelectedColorButton
void OnIconEntryFocused(Widget rootW)
SCR_ButtonImageComponent event.
const string COLOR_SELECTOR
void OnInsertMarker(bool isLocal)
TextWidget m_wDimensionSelectionText
void InitFactionIcons(int selectedFactionEntry)
Init faction icons.
void OnInputMarkerDelete(float value, EActionTrigger reason)
Marker delete quickbind.
ImageWidget m_wMarkerPreviewGlow
void CreateDynamicMarkers()
Create dynamic markers.
void OnFactionEntryFocused(Widget rootW)
SCR_ButtonImageComponent event.
void OnInputMenuDown(float value, EActionTrigger reason)
SCR_MapMarkerManagerComponent m_MarkerMgr
SocialComponent GetSocialComponent()
void OnComboBoxChangedA(SCR_ComboBoxComponent comp, int value)
SCR_ComboBoxComponent event.
void FocusWidget(Widget widget)
void InitCategoryIcons(SCR_TabViewContent tabContent)
Init icons by category.
void OnDimensionEntryFocused(Widget rootW)
SCR_ButtonImageComponent event.
void InitColorIcons(int selectedColorEntry)
Init color icons.
TextWidget m_wMarkerPreviewText
SCR_MapMarkerBase m_RemovableMarker
ref map< SCR_ButtonBaseComponent, int > m_mColorIDs
SCR_MapMarkerBase m_EditedMarker
SCR_SliderComponent m_SliderComp
void OnEditBoxTextChanged(string text)
SCR_EditBoxComponent event.
void RemoveOwnedMarker(SCR_MapMarkerBase marker)
Attemt to remove marker, only works if owned.
ref SCR_MilitarySymbol m_MilSymbolPreview
override void OnMapClose(MapConfiguration config)
SCR_MarkerMilitaryType m_eMilitaryTypeB
ref map< SCR_ButtonBaseComponent, int > m_mIconIDs
ImageWidget m_wMarkerPreview
SCR_TabViewComponent m_TabComponent
SCR_SelectionMenuCategoryEntry m_RootCategoryEntry
override void OnMapOpen(MapConfiguration config)
const int USERID_EDITBOX_MIL
void OnDimensionEntryClicked(SCR_ButtonBaseComponent component)
SCR_ButtonImageComponent event.
void OnTimestampSpinBoxChanged(SCR_SpinBoxComponent comp, int selectedItem)
SCR_SpinBoxComponent event.
const string ICON_ENTRY
ResourceName m_sMilitaryEditBoxLayout
const string COLOR_ENTRY
void OnEntryPerformed(SCR_SelectionMenuEntry entry)
SCR_MapMarkerMenuEntry event.
SCR_MapMarkerEntryMilitary m_MilitaryMarkerConfig
void OnTabChanged(SCR_TabViewComponent tabView, Widget widget, int index)
SCR_TabViewComponent event.
SCR_ButtonBaseComponent m_SelectedFactionButton
ResourceName m_sSelectorColorEntry
SCR_ComboBoxComponent m_ComboBoxComp2
void OnEditCancelled(SCR_InputButtonComponent button)
SCR_ButtonTextComponent event.
2D map radial menu UI
ScriptInvokerVoid GetOnMenuInitInvoker()
void RemoveRadialEntry(SCR_SelectionMenuEntry entry)
SCR_SelectionMenuEntry AddRadialEntry(string name, SCR_SelectionMenuCategoryEntry category=null)
SCR_SelectionMenuCategoryEntry AddRadialCategory(string name, SCR_SelectionMenuCategoryEntry parent=null)
static SCR_MapRadialUI GetInstance()
SCR_RadialMenuController GetRadialController()
void InsertCustomRadialEntry(SCR_SelectionMenuEntry entry, SCR_SelectionMenuCategoryEntry category=null)
Placed marker icon category.
void SetDimension(EMilitarySymbolDimension dimension)
void SetIdentity(EMilitarySymbolIdentity identity)
void Update(notnull SCR_MilitarySymbol symbol, SCR_MilitarySymbolConfig config=null)
ScriptInvoker_ControlledRadialMenuEvent GetOnInputOpen()
SCR_TabViewContent GetEntryContent(int index)
Definition Types.c:486
SCR_FieldOfViewSettings Attribute
proto external PlayerController GetPlayerController()
EActionTrigger
EUserInteraction
Interaction type between two players.
proto external int GetPlayerId()