Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_MapMarkersUI.c
Go to the documentation of this file.
1 
2 void 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" )]
12  protected ResourceName m_sIconImageset;
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" )]
18  protected ResourceName m_sEditBoxLayout;
19 
20  [Attribute("{DEA2D3B788CDCB4F}UI/layouts/Map/MapIconSelectorEntry.layout", UIWidgets.ResourceNamePicker, desc: "Icon selection entry layout", params: "layout" )]
21  protected ResourceName m_sSelectorIconEntry;
22 
23  [Attribute("{8A5D43FC8AC6C171}UI/layouts/Map/MapColorSelectorEntry.layout", UIWidgets.ResourceNamePicker, desc: "Color selection entry layout", params: "layout" )]
24  protected ResourceName m_sSelectorColorEntry;
25 
26  [Attribute("{4B6A50B3D8200779}UI/layouts/Map/MapDimensionSelectorEntry.layout", UIWidgets.ResourceNamePicker, desc: "Dimension selection entry layout", params: "layout" )]
27  protected ResourceName m_sSelectorDimensionEntry;
28 
29  [Attribute("{DF5BCE91F8A59977}UI/layouts/Map/MapMilitaryMarkerEditBox.layout", UIWidgets.ResourceNamePicker, desc: "Edit box dialog when placing military symbol marker", params: "layout" )]
30  protected ResourceName m_sMilitaryEditBoxLayout;
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 
46  protected ref Color BACKGROUND_DEFAULT = new Color(4,4,4,255);
47  protected ref Color BACKGROUND_SELECTED = new Color(16,16,16,255);
48 
49  protected bool m_bIsMilitaryMarker; // is custom or military marker
50  protected int m_bIsDelayed; // used to delay input context for marker dialog by one frame so it doesnt trigger inputs used to open it
51  protected int m_iIconEntryCount; // how many icon entries are within the current tab
52  protected int m_iIconLines;
53  protected SCR_MapMarkerEntryPlaced m_PlacedMarkerConfig; // saved entry for custom text placed markers
54  protected SCR_MapMarkerEntryMilitary m_MilitaryMarkerConfig;
55  protected Widget m_MarkerEditRoot;
56  protected Widget m_IconSelector;
57  protected ImageWidget m_wMarkerPreview;
58  protected ImageWidget m_wMarkerPreviewGlow;
59  protected TextWidget m_wMarkerPreviewText;
60  protected OverlayWidget m_wMarkerPreviewMilitary;
61  protected SCR_MilitarySymbolUIComponent m_MarkerPreviewMilitaryComp;
62  protected ref SCR_MilitarySymbol m_MilSymbolPreview;
63  protected SCR_TabViewComponent m_TabComponent;
64  protected SCR_EditBoxComponent m_EditBoxComp;
65  protected SCR_SliderComponent m_SliderComp;
66  protected TextWidget m_wFactionSelectionText;
67  protected TextWidget m_wDimensionSelectionText;
68  protected SCR_ComboBoxComponent m_ComboBoxComp1;
69  protected SCR_ComboBoxComponent m_ComboBoxComp2;
70 
71  // Placed marker attributes
72  protected int m_iWantedIconEntry;
73  protected int m_iSelectedIconID; // used for selecting icon when edit dialog is confirmed
74  protected int m_iSelectedColorID;
75  protected int m_iSelectedFactionID;
76  protected int m_iWantedDimensionEntry;
77  protected int m_iSelectedDimensionID;
78  protected float m_fRotation;
79  protected SCR_MarkerMilitaryType m_eMilitaryTypeA;
80  protected SCR_MarkerMilitaryType m_eMilitaryTypeB;
81  protected EMilitarySymbolIcon m_eMilitaryTypeAIcon;
82  protected EMilitarySymbolIcon m_eMilitaryTypeBIcon;
83  protected SCR_ButtonBaseComponent m_SelectedIconButton; // used for (un)coloring and selecting proper button when navigating on controller
84  protected SCR_ButtonBaseComponent m_SelectedColorButton;
85  protected SCR_ButtonBaseComponent m_SelectedFactionButton;
86  protected SCR_ButtonBaseComponent m_SelectedDimensionButton;
87 
88  protected SCR_MapMarkerManagerComponent m_MarkerMgr;
89  protected SCR_SelectionMenuCategoryEntry m_RootCategoryEntry;
90  protected SCR_SelectionMenuEntry m_MarkerRemoveEntry;
91  protected SCR_MapMarkerBase m_RemovableMarker;
92  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
93  protected SCR_MapCursorModule m_CursorModule;
94 
95  protected ref ScriptInvokerBase<MarkerPlacedInvoker> m_OnCustomMarkerPlaced = new ScriptInvokerBase<MarkerPlacedInvoker>();
96 
97  protected ref map<SCR_ButtonBaseComponent, int> m_mIconIDs = new map<SCR_ButtonBaseComponent, int>(); // marker icon buttons to config ids
98  protected ref map<SCR_ButtonBaseComponent, int> m_mColorIDs = new map<SCR_ButtonBaseComponent, int>(); // marker color buttons to config ids
99  protected ref map<SCR_ButtonBaseComponent, int> m_mFactionIDs = new map<SCR_ButtonBaseComponent, int>();// marker faction buttons to config ids
100  protected ref map<SCR_ButtonBaseComponent, int> m_mDimensionIDs = new map<SCR_ButtonBaseComponent, int>();// marker dimension buttons to config ids
101 
102  //------------------------------------------------------------------------------------------------
103  ScriptInvokerBase<MarkerPlacedInvoker> GetOnCustomMarkerPlaced()
104  {
105  return m_OnCustomMarkerPlaced;
106  }
107 
108  //------------------------------------------------------------------------------------------------
110  static bool IsOwnedMarker(notnull SCR_MapMarkerBase marker)
111  {
112  PlayerController localController = GetGame().GetPlayerController();
113  if (localController)
114  {
115  if (marker.GetMarkerOwnerID() == localController.GetPlayerId())
116  return true;
117  }
118 
119  return false;
120  }
121 
122  //------------------------------------------------------------------------------------------------
126  protected void CreateMarkerEditDialog(bool isEditing = false, int tabID = 0, int selectedIconEntry = -1, int selectedColorEntry = -1)
127  {
128  m_bIsMilitaryMarker = false;
129 
130  if (m_MarkerEditRoot)
131  CleanupMarkerEditWidget();
132 
133  m_iWantedIconEntry = selectedIconEntry;
134 
135  m_MarkerEditRoot = GetGame().GetWorkspace().CreateWidgets(m_sEditBoxLayout, m_RootWidget);
136 
137  float screenX, screenY;
138  m_MapEntity.GetMapWidget().GetScreenSize(screenX, screenY);
139  FrameSlot.SetPos(m_MarkerEditRoot, GetGame().GetWorkspace().DPIUnscale(screenX * 0.5), GetGame().GetWorkspace().DPIUnscale(screenY * 0.5));
140 
141  m_wMarkerPreview = ImageWidget.Cast(m_MarkerEditRoot.FindAnyWidget("MarkerIcon"));
142  m_wMarkerPreviewGlow = ImageWidget.Cast(m_MarkerEditRoot.FindAnyWidget("MarkerIconGlow"));
143  m_wMarkerPreviewText = TextWidget.Cast(m_MarkerEditRoot.FindAnyWidget("MarkerText"));
144 
145  InitColorIcons(selectedColorEntry);
146 
147  Widget sliderRotation = m_MarkerEditRoot.FindAnyWidget("SliderRoot");
148  m_SliderComp = SCR_SliderComponent.Cast(sliderRotation.FindHandler(SCR_SliderComponent));
149  m_SliderComp.m_OnChanged.Insert(OnSliderChanged);
150 
151  Widget categoryTab = m_MarkerEditRoot.FindAnyWidget("MarkerEditTab");
152  m_TabComponent = SCR_TabViewComponent.Cast(categoryTab.FindHandler(SCR_TabViewComponent));
153 
154  array<ref SCR_MarkerIconCategory> categoriesArr = m_PlacedMarkerConfig.GetIconCategories();
155  foreach (SCR_MarkerIconCategory category : categoriesArr)
156  {
157  m_TabComponent.AddTab(string.Empty, category.m_sName, identifier: category.m_sIdentifier);
158  }
159 
160  m_TabComponent.GetOnChanged().Insert(OnTabChanged);
161  m_TabComponent.ShowTab(tabID, true, false);
162 
163  Widget editBoxRoot = m_MarkerEditRoot.FindAnyWidget("EditBoxRoot");
164  editBoxRoot.FindAnyWidget("EditBox").SetUserID(USERID_EDITBOX);
165  m_EditBoxComp = SCR_EditBoxComponent.Cast(editBoxRoot.FindHandler(SCR_EditBoxComponent));
166  m_EditBoxComp.m_OnTextChange.Insert(OnEditBoxTextChanged);
167  m_EditBoxComp.SetValue(string.Empty);
168 
169  SCR_InputButtonComponent confirmComp = SCR_InputButtonComponent.Cast(m_MarkerEditRoot.FindAnyWidget("ButtonPublic").FindHandler(SCR_InputButtonComponent));
170  confirmComp.m_OnClicked.Insert(OnPlaceMarkerConfirmed);
171 
172  if (isEditing)
173  {
174  confirmComp.SetLabel("#AR-ServerHosting_Edit");
175 
176  m_MarkerEditRoot.FindAnyWidget("ButtonPrivate").SetVisible(false);
177  m_MarkerEditRoot.FindAnyWidget("ButtonPrivate").SetEnabled(false);
178  }
179  else
180  {
181  confirmComp.SetLabel("#AR-MapMarker_PlacePublic");
182 
183  confirmComp = SCR_InputButtonComponent.Cast(m_MarkerEditRoot.FindAnyWidget("ButtonPrivate").FindHandler(SCR_InputButtonComponent));
184  confirmComp.m_OnClicked.Insert(OnPlaceMarkerConfirmedPrivate);
185  }
186 
187  confirmComp = SCR_InputButtonComponent.Cast(m_MarkerEditRoot.FindAnyWidget("ButtonCancel").FindHandler(SCR_InputButtonComponent));
188  confirmComp.m_OnClicked.Insert(OnEditCancelled);
189 
190  FocusWidget(m_SelectedIconButton.GetRootWidget());
191 
192  m_CursorModule.HandleDialog(true);
193  }
194 
195  //------------------------------------------------------------------------------------------------
196  protected void CreateMilitaryMarkerEditDialog(bool isEditing = false, int selectedFactionEntry = -1, int selectedDimensionEntry = -1)
197  {
198  m_bIsMilitaryMarker = true;
199  m_iWantedDimensionEntry = selectedDimensionEntry;
200 
201  m_MarkerEditRoot = GetGame().GetWorkspace().CreateWidgets(m_sMilitaryEditBoxLayout, m_RootWidget);
202 
203  float screenX, screenY;
204  m_MapEntity.GetMapWidget().GetScreenSize(screenX, screenY);
205  FrameSlot.SetPos(m_MarkerEditRoot, GetGame().GetWorkspace().DPIUnscale(screenX * 0.5), GetGame().GetWorkspace().DPIUnscale(screenY * 0.5));
206 
207  m_wMarkerPreviewMilitary = OverlayWidget.Cast(m_MarkerEditRoot.FindAnyWidget("SymbolOverlay"));
208  m_MarkerPreviewMilitaryComp = SCR_MilitarySymbolUIComponent.Cast(m_wMarkerPreviewMilitary.FindHandler(SCR_MilitarySymbolUIComponent));
209  m_wMarkerPreviewText = TextWidget.Cast(m_MarkerEditRoot.FindAnyWidget("MarkerText"));
210 
211  m_MilSymbolPreview = new SCR_MilitarySymbol();
212  m_MilSymbolPreview.SetIdentity(EMilitarySymbolIdentity.BLUFOR);
213  m_MilSymbolPreview.SetDimension(EMilitarySymbolDimension.LAND);
214 
215  InitFactionIcons(selectedFactionEntry);
216 
217  m_ComboBoxComp1 = SCR_ComboBoxComponent.Cast(m_MarkerEditRoot.FindAnyWidget("ComboBox1").FindHandler(SCR_ComboBoxComponent));
218  m_ComboBoxComp1.m_OnChanged.Insert(OnComboBoxChangedA);
219 
220  m_ComboBoxComp2 = SCR_ComboBoxComponent.Cast(m_MarkerEditRoot.FindAnyWidget("ComboBox2").FindHandler(SCR_ComboBoxComponent));
221  m_ComboBoxComp2.m_OnChanged.Insert(OnComboBoxChangedB);
222 
223  m_ComboBoxComp1.AddItem("");
224  m_ComboBoxComp2.AddItem("");
225 
226  array<ref SCR_MarkerMilitaryType> types = m_MilitaryMarkerConfig.GetMilitaryTypes();
227  foreach (int i, SCR_MarkerMilitaryType markerType : types)
228  {
229  m_ComboBoxComp1.AddItem(markerType.GetTranslation(), false, markerType);
230  m_ComboBoxComp2.AddItem(markerType.GetTranslation(), false, markerType);
231  }
232 
233  m_ComboBoxComp1.SetCurrentItem(0);
234  OnComboBoxChangedA(m_ComboBoxComp1, -1);
235 
236  m_ComboBoxComp2.SetCurrentItem(0);
237  OnComboBoxChangedB(m_ComboBoxComp2, -1);
238 
239  Widget editBoxRoot = m_MarkerEditRoot.FindAnyWidget("EditBoxRoot");
240  editBoxRoot.FindAnyWidget("EditBox").SetUserID(USERID_EDITBOX_MIL);
241  m_EditBoxComp = SCR_EditBoxComponent.Cast(editBoxRoot.FindHandler(SCR_EditBoxComponent));
242  m_EditBoxComp.m_OnTextChange.Insert(OnEditBoxTextChanged);
243  m_EditBoxComp.SetValue(string.Empty);
244 
245  SCR_InputButtonComponent confirmComp = SCR_InputButtonComponent.Cast(m_MarkerEditRoot.FindAnyWidget("ButtonPublic").FindHandler(SCR_InputButtonComponent));
246  confirmComp.m_OnClicked.Insert(OnPlaceMarkerConfirmed);
247 
248  if (isEditing)
249  confirmComp.SetLabel("#AR-ServerHosting_Edit");
250  else
251  confirmComp.SetLabel("#AR-MapMarker_PlacePublic");
252 
253  confirmComp = SCR_InputButtonComponent.Cast(m_MarkerEditRoot.FindAnyWidget("ButtonCancel").FindHandler(SCR_InputButtonComponent));
254  confirmComp.m_OnClicked.Insert(OnEditCancelled);
255 
256  FocusWidget(m_SelectedFactionButton.GetRootWidget());
257 
258  m_CursorModule.HandleDialog(true);
259  }
260 
261  //------------------------------------------------------------------------------------------------
262  protected void FocusWidget(Widget widget)
263  {
264  GetGame().GetWorkspace().SetFocusedWidget(widget);
265  }
266 
267  //------------------------------------------------------------------------------------------------
269  protected void InitFactionIcons(int selectedFactionEntry)
270  {
271  array<ref SCR_MarkerMilitaryFactionEntry> factionsArr = m_MilitaryMarkerConfig.GetMilitaryFactionEntries();
272  Widget factionSelector = m_MarkerEditRoot.FindAnyWidget("FactionSelector");
273  Widget factionSelectorLine = factionSelector.FindAnyWidget("FactionSelectorLine");
274  m_wFactionSelectionText = TextWidget.Cast(factionSelector.FindAnyWidget("TextSelection"));
275  SCR_ButtonImageComponent firstFactionEntry;
276 
277  m_mFactionIDs.Clear();
278  m_SelectedFactionButton = null;
279 
280  string imageset, quad;
281 
282  foreach (int i, SCR_MarkerMilitaryFactionEntry factionEntry : factionsArr)
283  {
284  Widget button = GetGame().GetWorkspace().CreateWidgets(m_sSelectorIconEntry, factionSelectorLine);
285  button.SetName("FactionEntry" + i.ToString());
286  SCR_ButtonImageComponent buttonComp = SCR_ButtonImageComponent.Cast(button.FindHandler(SCR_ButtonImageComponent));
287  buttonComp.GetImageWidget().SetColor(factionEntry.GetColor());
288  factionEntry.GetIconResource(imageset, quad);
289  buttonComp.SetImage(imageset, quad);
290 
291  buttonComp.m_OnClicked.Insert(OnFactionEntryClicked);
292  buttonComp.m_OnFocus.Insert(OnFactionEntryFocused);
293 
294  m_mFactionIDs.Insert(buttonComp, i);
295 
296  if (!firstFactionEntry)
297  firstFactionEntry = buttonComp;
298  }
299 
300  if (selectedFactionEntry == -1)
301  {
302  OnFactionEntryClicked(firstFactionEntry);
303  }
304  else
305  {
306  SCR_ButtonBaseComponent buttonComp = m_mFactionIDs.GetKeyByValue(selectedFactionEntry);
307  if (buttonComp)
308  OnFactionEntryClicked(buttonComp);
309  else
310  OnFactionEntryClicked(firstFactionEntry);
311  }
312  }
313 
314  //------------------------------------------------------------------------------------------------
316  protected void InitDimensionIcons()
317  {
318  SCR_MarkerMilitaryFactionEntry factionEntry = m_MilitaryMarkerConfig.GetFactionEntry(m_iSelectedFactionID);
319  array<ref SCR_MarkerMilitaryDimension> dimensionsArr = m_MilitaryMarkerConfig.GetMilitaryDimensions();
320  if (!factionEntry || dimensionsArr.IsEmpty())
321  return;
322 
323  Widget dimensionSelector = m_MarkerEditRoot.FindAnyWidget("DimensionSelector");
324  Widget dimensionSelectorLine = dimensionSelector.FindAnyWidget("DimensionSelectorLine");
325  m_wDimensionSelectionText = TextWidget.Cast(dimensionSelector.FindAnyWidget("TextSelection"));
326  SCR_ButtonImageComponent firstDimensionEntry;
327 
328  m_mDimensionIDs.Clear();
329  m_SelectedDimensionButton = null;
330 
331  Widget child = dimensionSelectorLine.GetChildren();
332  while (child)
333  {
334  child.RemoveFromHierarchy();
335  child = dimensionSelectorLine.GetChildren();
336  }
337 
338  string imageset, quad;
339 
340  foreach (int i, SCR_MarkerMilitaryDimension dimensionEntry : dimensionsArr)
341  {
342  Widget button = GetGame().GetWorkspace().CreateWidgets(m_sSelectorDimensionEntry, dimensionSelectorLine);
343  button.SetName("DimensionEntry" + i.ToString());
344 
345  SCR_MilitarySymbol milSymbol = new SCR_MilitarySymbol();
346  milSymbol.SetIdentity(factionEntry.GetFactionIdentity());
347  milSymbol.SetDimension(dimensionEntry.GetDimension());
348 
349  Widget overlay = button.FindAnyWidget("OverlaySymbol");
350  overlay.SetColor(factionEntry.GetColor());
351 
353  symbolComp.Update(milSymbol);
354 
355  SCR_ButtonImageComponent buttonComp = SCR_ButtonImageComponent.Cast(button.FindHandler(SCR_ButtonImageComponent));
356  buttonComp.m_OnClicked.Insert(OnDimensionEntryClicked);
357  buttonComp.m_OnFocus.Insert(OnDimensionEntryFocused);
358 
359  m_mDimensionIDs.Insert(buttonComp, i);
360 
361  if (!firstDimensionEntry)
362  firstDimensionEntry = buttonComp;
363  }
364 
365  if (m_iWantedDimensionEntry == -1)
366  {
367  OnDimensionEntryClicked(firstDimensionEntry);
368  }
369  else
370  {
371  SCR_ButtonBaseComponent buttonComp = m_mDimensionIDs.GetKeyByValue(m_iWantedDimensionEntry);
372  if (buttonComp)
373  OnDimensionEntryClicked(buttonComp);
374  else
375  OnDimensionEntryClicked(firstDimensionEntry);
376  }
377  }
378 
379  //------------------------------------------------------------------------------------------------
381  protected void InitColorIcons(int selectedColorEntry)
382  {
383  array<ref SCR_MarkerColorEntry> colorsArr = m_PlacedMarkerConfig.GetColorEntries();
384  Widget colorSelector = m_MarkerEditRoot.FindAnyWidget(COLOR_SELECTOR);
385  Widget colorSelectorLine = colorSelector.FindAnyWidget("ColorSelectorLine");
386  SCR_ButtonImageComponent firstColorEntry;
387 
388  m_mColorIDs.Clear();
389  m_SelectedColorButton = null;
390 
391  foreach (int i, SCR_MarkerColorEntry colorEntry : colorsArr)
392  {
393  Widget button = GetGame().GetWorkspace().CreateWidgets(m_sSelectorColorEntry, colorSelectorLine);
394  button.SetName(COLOR_ENTRY + i.ToString());
395  SCR_ButtonImageComponent buttonComp = SCR_ButtonImageComponent.Cast(button.FindHandler(SCR_ButtonImageComponent));
396  buttonComp.GetImageWidget().SetColor(colorEntry.GetColor());
397  buttonComp.m_OnClicked.Insert(OnColorEntryClicked);
398  buttonComp.m_OnFocus.Insert(OnColorEntryFocused);
399 
400  m_mColorIDs.Insert(buttonComp, i);
401 
402  if (!firstColorEntry)
403  firstColorEntry = buttonComp;
404  }
405 
406  if (selectedColorEntry == -1)
407  {
408  OnColorEntryClicked(firstColorEntry);
409  }
410  else
411  {
412  SCR_ButtonBaseComponent buttonComp = m_mColorIDs.GetKeyByValue(selectedColorEntry);
413  if (buttonComp)
414  OnColorEntryClicked(buttonComp);
415  else
416  OnColorEntryClicked(firstColorEntry);
417  }
418  }
419 
420  //------------------------------------------------------------------------------------------------
422  protected void InitCategoryIcons(SCR_TabViewContent tabContent)
423  {
424  m_mIconIDs.Clear();
425  m_SelectedIconButton = null;
426 
427  string imageset, imagesetGlow, quad;
428 
429  m_IconSelector = m_MarkerEditRoot.FindAnyWidget(ICON_SELECTOR);
430  array<ref SCR_MarkerIconEntry> iconsArr = m_PlacedMarkerConfig.GetIconEntries();
431 
432  Widget child = m_IconSelector.GetChildren();
433  while (child)
434  {
435  child.RemoveFromHierarchy();
436  child = m_IconSelector.GetChildren();
437  }
438 
439  Widget iconSelectorLine = GetGame().GetWorkspace().CreateWidgets(SELECTOR_LINE, m_IconSelector);
440  m_iIconEntryCount = 0;
441  m_iIconLines = 1;
442 
443  SCR_ButtonImageComponent firstEntry;
444 
445  foreach (int i, SCR_MarkerIconEntry iconEntry : iconsArr)
446  {
447  if (iconEntry.m_sCategoryIdentifier != tabContent.m_sTabIdentifier)
448  continue;
449 
450  m_iIconEntryCount++;
451  if (m_iIconEntryCount > m_iIconsPerLine * m_iIconLines)
452  {
453  iconSelectorLine = GetGame().GetWorkspace().CreateWidgets(SELECTOR_LINE, m_IconSelector);
454  m_iIconLines++;
455  }
456 
457  Widget button = GetGame().GetWorkspace().CreateWidgets(m_sSelectorIconEntry, iconSelectorLine);
458  button.SetName(ICON_ENTRY + m_iIconEntryCount.ToString());
459  SCR_ButtonImageComponent buttonComp = SCR_ButtonImageComponent.Cast(button.FindHandler(SCR_ButtonImageComponent));
460  m_mIconIDs.Insert(buttonComp, i);
461  if (!firstEntry)
462  firstEntry = buttonComp;
463 
464  iconEntry.GetIconResource(imageset, imagesetGlow, quad);
465  buttonComp.SetImage(imageset, quad);
466  buttonComp.m_OnClicked.Insert(OnIconEntryClicked);
467  buttonComp.m_OnFocus.Insert(OnIconEntryFocused);
468  }
469 
470  if (m_iWantedIconEntry == -1)
471  {
472  OnIconEntryClicked(firstEntry);
473  }
474  else
475  {
476  SCR_ButtonBaseComponent buttonComp = m_mIconIDs.GetKeyByValue(m_iWantedIconEntry);
477  if (buttonComp)
478  OnIconEntryClicked(buttonComp);
479  else
480  OnIconEntryClicked(firstEntry);
481  }
482  }
483 
484  //------------------------------------------------------------------------------------------------
486  protected void CreateStaticMarkers()
487  {
488  array<ref SCR_MapMarkerBase> markersSimple = m_MarkerMgr.GetStaticMarkers();
489  FactionManager factionManager = GetGame().GetFactionManager();
490 
491  int count = markersSimple.Count();
492  for (int i; i < count; i++)
493  {
494  if (!markersSimple.IsIndexValid(i))
495  continue;
496 
497  SCR_MapMarkerBase marker = markersSimple[i];
498  if (marker.GetMarkerFactionFlags() == 0 || !factionManager)
499  {
500  marker.OnCreateMarker();
501  continue;
502  }
503 
504  Faction localFaction = SCR_FactionManager.SGetLocalPlayerFaction();
505  bool isMyFaction = marker.IsFaction(factionManager.GetFactionIndex(localFaction));
506 
507  if (!isMyFaction || !localFaction)
508  {
509  if (Replication.IsServer()) // if server, enemy markers have to be kept for sync but are disabled
510  marker.SetServerDisabled(true);
511  else // if client, enemy marker can be safely removed
512  {
513  markersSimple.RemoveItem(marker);
514  i--;
515  count--;
516  continue;
517  }
518  }
519 
520  marker.OnCreateMarker();
521  }
522  }
523 
524  //------------------------------------------------------------------------------------------------
526  protected void CreateDynamicMarkers()
527  {
528  array<SCR_MapMarkerEntity> markersDynamic = m_MarkerMgr.GetDynamicMarkers();
529  foreach (SCR_MapMarkerEntity marker : markersDynamic)
530  {
531  marker.OnCreateMarker();
532  }
533  }
534 
535  //------------------------------------------------------------------------------------------------
536  // Remove callback from radial menu
537  protected void RemoveMarkerMenu()
538  {
539  RemoveOwnedMarker(m_RemovableMarker);
540  }
541 
542  //------------------------------------------------------------------------------------------------
544  protected void RemoveOwnedMarker(SCR_MapMarkerBase marker)
545  {
546  if (marker)
547  m_MarkerMgr.RemoveStaticMarker(marker);
548  }
549 
550  //------------------------------------------------------------------------------------------------
552  protected void CleanupMarkerEditWidget()
553  {
554  if (m_MarkerEditRoot)
555  m_MarkerEditRoot.RemoveFromHierarchy();
556 
557  m_bIsDelayed = false;
558 
559  m_CursorModule.HandleDialog(false);
560  }
561 
562  //------------------------------------------------------------------------------------------------
563  // EVENTS
564  //------------------------------------------------------------------------------------------------
566  protected void OnTabChanged(SCR_TabViewComponent tabView, Widget widget, int index)
567  {
568  SCR_TabViewContent tab = tabView.GetEntryContent(index);
569 
570  InitCategoryIcons(tab);
571  m_SliderComp.SetValue(0);
572  }
573 
574  //------------------------------------------------------------------------------------------------
576  protected void OnFactionEntryClicked(SCR_ButtonBaseComponent component)
577  {
578  if (m_SelectedFactionButton)
579  {
580  m_SelectedFactionButton.SetBackgroundColors(BACKGROUND_DEFAULT);
581  m_SelectedFactionButton.ColorizeBackground(false);
582  }
583 
584  component.SetBackgroundColors(BACKGROUND_SELECTED);
585  component.ColorizeBackground(false); // this will color the button to hover color for KBM
586  m_SelectedFactionButton = component;
587  m_iSelectedFactionID = m_mFactionIDs.Get(component);
588 
589  SCR_MarkerMilitaryFactionEntry entry = m_MilitaryMarkerConfig.GetFactionEntry(m_iSelectedFactionID);
590  m_wFactionSelectionText.SetText(entry.GetTranslation());
591  m_wMarkerPreviewMilitary.SetColor(entry.GetColor());
592  m_MilSymbolPreview.SetIdentity(entry.GetFactionIdentity());
593  m_MarkerPreviewMilitaryComp.Update(m_MilSymbolPreview);
594 
595  InitDimensionIcons();
596  }
597 
598  //------------------------------------------------------------------------------------------------
600  protected void OnFactionEntryFocused(Widget rootW)
601  {
602  if (GetGame().GetInputManager().IsUsingMouseAndKeyboard())
603  return;
604 
605  SCR_ButtonBaseComponent buttonComp = SCR_ButtonBaseComponent.Cast(rootW.FindHandler(SCR_ButtonBaseComponent));
606  if (buttonComp)
607  OnFactionEntryClicked(buttonComp);
608  }
609 
610  //------------------------------------------------------------------------------------------------
612  protected void OnDimensionEntryClicked(SCR_ButtonBaseComponent component)
613  {
614  if (m_SelectedDimensionButton)
615  {
616  m_SelectedDimensionButton.SetBackgroundColors(BACKGROUND_DEFAULT);
617  m_SelectedDimensionButton.ColorizeBackground(false);
618  }
619 
620  component.SetBackgroundColors(BACKGROUND_SELECTED);
621  component.ColorizeBackground(false); // this will color the button to hover color for KBM
622  m_SelectedDimensionButton = component;
623  m_iSelectedDimensionID = m_mDimensionIDs.Get(component);
624  m_iWantedDimensionEntry = m_iSelectedDimensionID;
625 
626  SCR_MarkerMilitaryDimension entry = m_MilitaryMarkerConfig.GetDimensionEntry(m_iSelectedDimensionID);
627  m_wDimensionSelectionText.SetText(entry.GetTranslation());
628  m_MilSymbolPreview.SetDimension(entry.GetDimension());
629  m_MarkerPreviewMilitaryComp.Update(m_MilSymbolPreview);
630  }
631 
632  //------------------------------------------------------------------------------------------------
634  protected void OnDimensionEntryFocused(Widget rootW)
635  {
636  if (GetGame().GetInputManager().IsUsingMouseAndKeyboard())
637  return;
638 
639  SCR_ButtonBaseComponent buttonComp = SCR_ButtonBaseComponent.Cast(rootW.FindHandler(SCR_ButtonBaseComponent));
640  if (buttonComp)
641  OnDimensionEntryClicked(buttonComp);
642  }
643 
644  //------------------------------------------------------------------------------------------------
646  protected void OnColorEntryClicked(SCR_ButtonBaseComponent component)
647  {
648  if (m_SelectedColorButton)
649  {
650  m_SelectedColorButton.SetBackgroundColors(BACKGROUND_DEFAULT);
651  m_SelectedColorButton.ColorizeBackground(false);
652  }
653 
654  component.SetBackgroundColors(BACKGROUND_SELECTED);
655  component.ColorizeBackground(false); // this will color the button to hover color for KBM
656  m_SelectedColorButton = component;
657  m_iSelectedColorID = m_mColorIDs.Get(component);
658 
659  m_wMarkerPreview.SetColor(m_PlacedMarkerConfig.GetColorEntry(m_iSelectedColorID));
660  }
661 
662  //------------------------------------------------------------------------------------------------
664  protected void OnColorEntryFocused(Widget rootW)
665  {
666  if (GetGame().GetInputManager().IsUsingMouseAndKeyboard())
667  return;
668 
669  SCR_ButtonBaseComponent buttonComp = SCR_ButtonBaseComponent.Cast(rootW.FindHandler(SCR_ButtonBaseComponent));
670  if (buttonComp)
671  OnColorEntryClicked(buttonComp);
672  }
673 
674  //------------------------------------------------------------------------------------------------
676  protected void OnIconEntryClicked(notnull SCR_ButtonBaseComponent component)
677  {
678  if (m_SelectedIconButton)
679  {
680  m_SelectedIconButton.SetBackgroundColors(BACKGROUND_DEFAULT);
681  m_SelectedIconButton.ColorizeBackground(false);
682  }
683 
684  component.SetBackgroundColors(BACKGROUND_SELECTED);
685  component.ColorizeBackground(false); // this will color the button to hover color for KBM
686  m_SelectedIconButton = component;
687  m_iSelectedIconID = m_mIconIDs.Get(component);
688 
689  ResourceName imageset, imagesetGlow;
690  string quad;
691  m_PlacedMarkerConfig.GetIconEntry(m_iSelectedIconID, imageset, imagesetGlow, quad);
692 
693  m_wMarkerPreview.LoadImageFromSet(0, imageset, quad);
694  m_wMarkerPreviewGlow.LoadImageFromSet(0, imagesetGlow, quad);
695  }
696 
697  //------------------------------------------------------------------------------------------------
699  protected void OnIconEntryFocused(Widget rootW)
700  {
701  if (GetGame().GetInputManager().IsUsingMouseAndKeyboard())
702  return;
703 
704  SCR_ButtonBaseComponent buttonComp = SCR_ButtonBaseComponent.Cast(rootW.FindHandler(SCR_ButtonBaseComponent));
705  if (buttonComp)
706  OnIconEntryClicked(buttonComp);
707  }
708 
709  //------------------------------------------------------------------------------------------------
711  protected void OnEditBoxTextChanged(string text)
712  {
713  m_wMarkerPreviewText.SetText(text);
714  }
715 
716  //------------------------------------------------------------------------------------------------
718  protected void OnSliderChanged(SCR_SliderComponent slider, float value)
719  {
720  m_wMarkerPreview.SetRotation(value);
721  m_wMarkerPreviewGlow.SetRotation(value);
722  m_fRotation = value;
723  }
724 
725  //------------------------------------------------------------------------------------------------
727  protected void OnComboBoxChangedA(SCR_ComboBoxComponent comp, int value)
728  {
729  m_eMilitaryTypeA = SCR_MarkerMilitaryType.Cast(comp.GetItemData(value));
730  if (m_eMilitaryTypeA)
731  m_eMilitaryTypeAIcon = m_eMilitaryTypeA.GetType();
732  else
733  m_eMilitaryTypeAIcon = 0;
734 
735  m_MilSymbolPreview.SetIcons(m_eMilitaryTypeAIcon | m_eMilitaryTypeBIcon);
736  m_MarkerPreviewMilitaryComp.Update(m_MilSymbolPreview);
737  }
738 
739  //------------------------------------------------------------------------------------------------
741  protected void OnComboBoxChangedB(SCR_ComboBoxComponent comp, int value)
742  {
743  m_eMilitaryTypeB = SCR_MarkerMilitaryType.Cast(comp.GetItemData(value));
744  if (m_eMilitaryTypeB)
745  m_eMilitaryTypeBIcon = m_eMilitaryTypeB.GetType();
746  else
747  m_eMilitaryTypeBIcon = 0;
748 
749  m_MilSymbolPreview.SetIcons(m_eMilitaryTypeAIcon | m_eMilitaryTypeBIcon);
750  m_MarkerPreviewMilitaryComp.Update(m_MilSymbolPreview);
751  }
752 
753  //------------------------------------------------------------------------------------------------
755  protected void OnPlaceMarkerConfirmed(SCR_InputButtonComponent button)
756  {
757  if (m_EditedMarker)
758  {
759  RemoveOwnedMarker(m_EditedMarker);
760  m_EditedMarker = null;
761  }
762 
763  OnInsertMarker(false);
764  }
765 
766  //------------------------------------------------------------------------------------------------
768  protected void OnPlaceMarkerConfirmedPrivate(SCR_InputButtonComponent button)
769  {
770  OnInsertMarker(true);
771  }
772 
773  //------------------------------------------------------------------------------------------------
775  protected void OnEditCancelled(SCR_InputButtonComponent button)
776  {
777  if (m_EditedMarker)
778  {
779  m_EditedMarker.SetVisible(true);
780  m_EditedMarker = null;
781  }
782 
783  CleanupMarkerEditWidget();
784  }
785 
786  //------------------------------------------------------------------------------------------------
787  protected void OnInsertMarker(bool isLocal)
788  {
789  float wX, wY;
790  m_MapEntity.GetMapCenterWorldPosition(wX, wY);
791 
792  SCR_MapMarkerBase marker = new SCR_MapMarkerBase();
793 
794  if (m_bIsMilitaryMarker)
795  {
796  marker.SetType(SCR_EMapMarkerType.PLACED_MILITARY);
797  marker.SetFlags(m_eMilitaryTypeAIcon | m_eMilitaryTypeBIcon);
798  marker.SetMarkerConfigID(m_iSelectedDimensionID * 100 + m_iSelectedFactionID); // combination of faction and dimension id
799  }
800  else
801  {
802  marker.SetType(SCR_EMapMarkerType.PLACED_CUSTOM);
803  marker.SetRotation(m_fRotation);
804  marker.SetColorEntry(m_iSelectedColorID);
805  marker.SetIconEntry(m_iSelectedIconID);
806  }
807 
808  marker.SetCustomText(m_EditBoxComp.GetValue());
809  marker.SetWorldPos(wX, wY);
810 
811  if (!isLocal)
812  {
813  FactionManager factionManager = GetGame().GetFactionManager();
814  if (factionManager)
815  {
816  Faction markerOwnerFaction = SCR_FactionManager.SGetPlayerFaction(GetGame().GetPlayerController().GetPlayerId());
817  if (markerOwnerFaction)
818  marker.AddMarkerFactionFlags(factionManager.GetFactionIndex(markerOwnerFaction));
819  }
820  }
821 
822  m_MarkerMgr.InsertStaticMarker(marker, isLocal);
823  m_OnCustomMarkerPlaced.Invoke(wX, wY, isLocal);
824 
825  CleanupMarkerEditWidget();
826  }
827 
828  //------------------------------------------------------------------------------------------------
830  protected void OnRadialMenuInit()
831  {
832  SCR_MapMarkerConfig markerConfig = m_MarkerMgr.GetMarkerConfig();
833  if (!markerConfig)
834  return;
835 
836  SCR_MapRadialUI radialUI = SCR_MapRadialUI.Cast(m_MapEntity.GetMapUIComponent(SCR_MapRadialUI));
837 
838  m_RootCategoryEntry = radialUI.AddRadialCategory(m_sCategoryName);
839  m_RootCategoryEntry.SetIcon(m_sIconImageset, m_sCategoryIconName);
840 
841  array<ref SCR_MapMarkerEntryConfig> entryConfigs = markerConfig.GetMarkerEntryConfigs();
842 
843  foreach (SCR_MapMarkerEntryConfig entry : entryConfigs) // menu entries
844  {
845  if (entry.GetMarkerType() == SCR_EMapMarkerType.PLACED_MILITARY)
846  {
848 
850  menuEntry.SetMarkerType(SCR_EMapMarkerType.PLACED_MILITARY);
851  menuEntry.SetName(entryMil.GetMenuDescription());
852  menuEntry.GetOnPerform().Insert(OnEntryPerformed);
853  menuEntry.SetIcon(entryMil.GetMenuImageset(), entryMil.GetMenuIcon());
854 
855  radialUI.InsertCustomRadialEntry(menuEntry, m_RootCategoryEntry);
856  }
857  else if (entry.GetMarkerType() == SCR_EMapMarkerType.PLACED_CUSTOM)
858  {
859  SCR_MapMarkerEntryPlaced entryPlaced = SCR_MapMarkerEntryPlaced.Cast(entry);
860 
862  menuEntry.SetMarkerType(SCR_EMapMarkerType.PLACED_CUSTOM);
863  menuEntry.SetName(entryPlaced.GetMenuDescription());
864  menuEntry.GetOnPerform().Insert(OnEntryPerformed);
865  menuEntry.SetIcon(entryPlaced.GetMenuImageset(), entryPlaced.GetMenuIcon());
866 
867  radialUI.InsertCustomRadialEntry(menuEntry, m_RootCategoryEntry);
868  }
869  }
870  }
871 
872  //------------------------------------------------------------------------------------------------
874  protected void OnRadialMenuOpen(SCR_RadialMenuController controller)
875  {
876  SCR_MapRadialUI radialUI = SCR_MapRadialUI.Cast(m_MapEntity.GetMapUIComponent(SCR_MapRadialUI));
877  if (m_MarkerRemoveEntry)
878  {
879  radialUI.RemoveRadialEntry(m_MarkerRemoveEntry);
880  m_RemovableMarker = null;
881  }
882 
883  // delete marker button
884  array<Widget> widgets = SCR_MapCursorModule.GetMapWidgetsUnderCursor();
885 
886  SCR_MapMarkerWidgetComponent markerComp;
887  foreach ( Widget widget : widgets )
888  {
889  markerComp = SCR_MapMarkerWidgetComponent.Cast(widget.FindHandler(SCR_MapMarkerWidgetComponent));
890  if (!markerComp)
891  continue;
892 
893  SCR_MapMarkerBase marker = m_MarkerMgr.GetMarkerByWidget(widget);
894  if (marker)
895  {
896  if (marker.GetType() != SCR_EMapMarkerType.PLACED_CUSTOM && marker.GetType() != SCR_EMapMarkerType.PLACED_MILITARY)
897  continue;
898 
899  m_MarkerRemoveEntry = radialUI.AddRadialEntry("#AR-MapMarker_DeleteHint");
900  m_MarkerRemoveEntry.SetIcon(m_sIconImageset, m_sDeleteIconName);
901  m_MarkerRemoveEntry.GetOnPerform().Insert(RemoveMarkerMenu);
902 
903  m_RemovableMarker = marker;
904 
905  return;
906  }
907  }
908  }
909 
910  //------------------------------------------------------------------------------------------------
912  protected void OnEntryPerformed(SCR_SelectionMenuEntry entry)
913  {
914  SCR_MapMarkerMenuEntry markerEntry = SCR_MapMarkerMenuEntry.Cast(entry);
915 
916  if (markerEntry.GetMarkerType() == SCR_EMapMarkerType.PLACED_CUSTOM)
917  {
918  if (!m_PlacedMarkerConfig)
919  {
920  SCR_MapMarkerConfig markerConfig = m_MarkerMgr.GetMarkerConfig();
921  if (!markerConfig)
922  return;
923 
924  m_PlacedMarkerConfig = SCR_MapMarkerEntryPlaced.Cast(markerConfig.GetMarkerEntryConfigByType(markerEntry.GetMarkerType()));
925  if (!m_PlacedMarkerConfig)
926  return;
927  }
928 
929  CreateMarkerEditDialog();
930  }
931  else if (markerEntry.GetMarkerType() == SCR_EMapMarkerType.PLACED_MILITARY)
932  {
933  if (!m_MilitaryMarkerConfig)
934  {
935  SCR_MapMarkerConfig markerConfig = m_MarkerMgr.GetMarkerConfig();
936  if (!markerConfig)
937  return;
938 
939  m_MilitaryMarkerConfig = SCR_MapMarkerEntryMilitary.Cast(markerConfig.GetMarkerEntryConfigByType(markerEntry.GetMarkerType()));
940  if (!m_MilitaryMarkerConfig)
941  return;
942  }
943 
944  CreateMilitaryMarkerEditDialog();
945  }
946  }
947 
948  //------------------------------------------------------------------------------------------------
950  protected void OnInputQuickMarkerMenu(float value, EActionTrigger reason)
951  {
952  SCR_MapRadialUI mapRadial = SCR_MapRadialUI.GetInstance();
953  if (!mapRadial)
954  return;
955 
956  mapRadial.GetRadialController().OnInputOpen();
957  mapRadial.GetRadialController().GetRadialMenu().PerformEntry(m_RootCategoryEntry);
958 
959  }
960 
961  //------------------------------------------------------------------------------------------------
963  protected void OnInputMarkerDelete(float value, EActionTrigger reason)
964  {
965  array<Widget> widgets = SCR_MapCursorModule.GetMapWidgetsUnderCursor();
966 
967  SCR_MapMarkerWidgetComponent markerComp;
968  foreach ( Widget widget : widgets )
969  {
970  markerComp = SCR_MapMarkerWidgetComponent.Cast(widget.FindHandler(SCR_MapMarkerWidgetComponent));
971  if (!markerComp)
972  continue;
973 
974  SCR_MapMarkerBase marker = m_MarkerMgr.GetMarkerByWidget(widget);
975  if (marker)
976  {
977  if (marker.GetType() != SCR_EMapMarkerType.PLACED_CUSTOM && marker.GetType() != SCR_EMapMarkerType.PLACED_MILITARY)
978  continue;
979 
980  RemoveOwnedMarker(marker);
981  }
982  }
983  }
984 
985  //------------------------------------------------------------------------------------------------
987  protected void OnInputMapSelect(float value, EActionTrigger reason)
988  {
989  array<Widget> widgets = SCR_MapCursorModule.GetMapWidgetsUnderCursor();
990 
991  SCR_MapMarkerWidgetComponent markerComp;
992  foreach ( Widget widget : widgets )
993  {
994  markerComp = SCR_MapMarkerWidgetComponent.Cast(widget.FindHandler(SCR_MapMarkerWidgetComponent));
995  if (!markerComp)
996  continue;
997 
998  SCR_MapMarkerBase marker = m_MarkerMgr.GetMarkerByWidget(widget);
999  if (!marker)
1000  continue;
1001 
1002  m_EditedMarker = marker;
1003  SCR_EMapMarkerType type = marker.GetType();
1004 
1005  if (IsOwnedMarker(marker) && (type == SCR_EMapMarkerType.PLACED_CUSTOM || type == SCR_EMapMarkerType.PLACED_MILITARY))
1006  {
1007  int wPos[2];
1008  float screenX, screenY;
1009  marker.GetWorldPos(wPos);
1010  m_MapEntity.WorldToScreen(wPos[0], wPos[1], screenX, screenY);
1011  m_MapEntity.PanSmooth(screenX, screenY, 0.1);
1012 
1013  if (type == SCR_EMapMarkerType.PLACED_CUSTOM )
1014  {
1015  if (!m_PlacedMarkerConfig)
1016  return;
1017 
1018  CreateMarkerEditDialog(true, m_PlacedMarkerConfig.GetIconCategoryID(marker.GetIconEntry()), marker.GetIconEntry(), marker.GetColorEntry());
1019 
1020  OnEditBoxTextChanged(marker.GetCustomText());
1021  m_SliderComp.SetValue(marker.GetRotation());
1022  m_EditBoxComp.SetValue(marker.GetCustomText());
1023  }
1024  else
1025  {
1026  if (!m_MilitaryMarkerConfig)
1027  return;
1028 
1029  CreateMilitaryMarkerEditDialog(true, marker.GetMarkerConfigID() % SCR_MapMarkerEntryMilitary.FACTION_DETERMINATOR, marker.GetMarkerConfigID() * SCR_MapMarkerEntryMilitary.DIMENSION_DETERMINATOR);
1030  OnEditBoxTextChanged(marker.GetCustomText());
1031  m_EditBoxComp.SetValue(marker.GetCustomText());
1032 
1033  int markerFlags = marker.GetFlags();
1034  bool secondType;
1035 
1036  array<ref SCR_MarkerMilitaryType> milTypes = m_MilitaryMarkerConfig.GetMilitaryTypes();
1037  foreach (int i, SCR_MarkerMilitaryType milType : milTypes)
1038  {
1039  if (markerFlags & milType.GetType())
1040  {
1041  if (secondType)
1042  {
1043  m_ComboBoxComp2.SetCurrentItem(i+1); // +1 is here and below since we add a NONE entry to the combo boxes during creation
1044  OnComboBoxChangedB(m_ComboBoxComp2, i+1);
1045  break;
1046  }
1047  else
1048  {
1049  m_ComboBoxComp1.SetCurrentItem(i+1);
1050  OnComboBoxChangedA(m_ComboBoxComp1, i+1);
1051  if (markerFlags == milType.GetType()) // return if singular flag
1052  break;
1053 
1054  secondType = true;
1055  }
1056  }
1057  }
1058  }
1059 
1060  marker.SetVisible(false);
1061 
1062  break;
1063  }
1064  }
1065  }
1066 
1067  //------------------------------------------------------------------------------------------------
1069  protected void OnInputMenuConfirm(float value, EActionTrigger reason)
1070  {
1071  if (!m_bIsDelayed)
1072  return;
1073 
1074  Widget focused = GetGame().GetWorkspace().GetFocusedWidget();
1075  if (!focused || focused.GetUserID() == USERID_EDITBOX || focused.GetUserID() == USERID_EDITBOX_MIL)
1076  return;
1077 
1078  if (m_ComboBoxComp1 && (m_ComboBoxComp1.IsOpened() || m_ComboBoxComp1.GetRootWidget().FindAnyWidget("ComboButton") == focused))
1079  return;
1080 
1081  if (m_ComboBoxComp2 && (m_ComboBoxComp2.IsOpened() || m_ComboBoxComp2.GetRootWidget().FindAnyWidget("ComboButton") == focused))
1082  return;
1083 
1084  if (m_MarkerEditRoot)
1085  OnPlaceMarkerConfirmed(null);
1086  }
1087 
1088  //------------------------------------------------------------------------------------------------
1090  protected void OnInputMenuConfirmAlter(float value, EActionTrigger reason)
1091  {
1092  if (m_MarkerEditRoot)
1093  OnPlaceMarkerConfirmedPrivate(null);
1094  }
1095 
1096  //------------------------------------------------------------------------------------------------
1098  protected void OnInputMenuBack(float value, EActionTrigger reason)
1099  {
1100  if (m_MarkerEditRoot)
1101  OnEditCancelled(null);
1102  }
1103 
1104  //------------------------------------------------------------------------------------------------
1105  protected void OnInputMenuDown(float value, EActionTrigger reason)
1106  {
1107  string name;
1108 
1109  Widget focused = GetGame().GetWorkspace().GetFocusedWidget();
1110  if (focused)
1111  name = focused.GetName();
1112 
1113  if (name.Contains(ICON_ENTRY))
1114  FocusWidget(m_SelectedColorButton.GetRootWidget());
1115  else if (name.Contains("FactionEntry"))
1116  FocusWidget(m_SelectedDimensionButton.GetRootWidget());
1117  }
1118 
1119  //------------------------------------------------------------------------------------------------
1120  protected void OnInputMenuUp(float value, EActionTrigger reason)
1121  {
1122  string name;
1123 
1124  Widget focused = GetGame().GetWorkspace().GetFocusedWidget();
1125  if (!focused)
1126  return;
1127 
1128  name = focused.GetName();
1129 
1130  if (name.Contains(COLOR_ENTRY))
1131  FocusWidget(m_SelectedIconButton.GetRootWidget());
1132  else if (focused.GetUserID() == USERID_EDITBOX)
1133  FocusWidget(m_SelectedColorButton.GetRootWidget());
1134  else if (focused.GetUserID() == USERID_EDITBOX_MIL)
1135  FocusWidget(m_ComboBoxComp2.GetRootWidget());
1136  else if (name.Contains("DimensionEntry"))
1137  FocusWidget(m_SelectedFactionButton.GetRootWidget());
1138  else if (name.Contains("ComboButton"))
1139  {
1140  while (focused.GetParent() != null)
1141  {
1142  focused = focused.GetParent();
1143  if (focused.GetName().Contains("ComboBox1"))
1144  {
1145  FocusWidget(m_SelectedDimensionButton.GetRootWidget());
1146  break;
1147  }
1148  }
1149  }
1150  }
1151 
1152  //------------------------------------------------------------------------------------------------
1153  protected void OnInputMenuLeft(float value, EActionTrigger reason)
1154  {
1155  string name;
1156 
1157  Widget focused = GetGame().GetWorkspace().GetFocusedWidget();
1158  if (focused)
1159  name = focused.GetName();
1160 
1161  if (!name.Contains(ICON_ENTRY))
1162  return;
1163 
1164  int pos = name.ToInt(offset: 9);
1165  int target = pos - 1;
1166 
1167  if (target < 1)
1168  target = m_iIconEntryCount;
1169 
1170  Widget w = m_IconSelector.FindAnyWidget(ICON_ENTRY + target);
1171  if (w)
1172  FocusWidget(w);
1173  }
1174 
1175  //------------------------------------------------------------------------------------------------
1176  protected void OnInputMenuRight(float value, EActionTrigger reason)
1177  {
1178  string name;
1179 
1180  Widget focused = GetGame().GetWorkspace().GetFocusedWidget();
1181  if (focused)
1182  name = focused.GetName();
1183 
1184  if (!name.Contains(ICON_ENTRY))
1185  return;
1186 
1187  int pos = name.ToInt(offset: 9);
1188  int target = pos + 1;
1189 
1190  if (target > m_iIconEntryCount)
1191  target = 1;
1192 
1193  Widget w = m_IconSelector.FindAnyWidget(ICON_ENTRY + target);
1194  if (w)
1195  FocusWidget(w);
1196  }
1197 
1198  //------------------------------------------------------------------------------------------------
1200  protected void OnDragWidget(Widget widget)
1201  {
1202  SCR_MapMarkerBase marker = m_MarkerMgr.GetMarkerByWidget(widget);
1203  if (marker)
1204  {
1205  if (!IsOwnedMarker(marker) || (marker.GetType() != SCR_EMapMarkerType.PLACED_CUSTOM && marker.GetType() != SCR_EMapMarkerType.PLACED_MILITARY) )
1206  return;
1207 
1208  marker.SetDragged(true);
1209  }
1210  }
1211 
1212  //------------------------------------------------------------------------------------------------
1214  protected void OnDragEnd(Widget widget, bool wasDragged)
1215  {
1216  SCR_MapMarkerBase marker = m_MarkerMgr.GetMarkerByWidget(widget);
1217  if (marker)
1218  {
1219  SCR_EMapMarkerType type = marker.GetType();
1220 
1221  if (!IsOwnedMarker(marker) || (type != SCR_EMapMarkerType.PLACED_CUSTOM && type != SCR_EMapMarkerType.PLACED_MILITARY))
1222  return;
1223 
1224  marker.SetDragged(false);
1225 
1226  if (!wasDragged)
1227  return;
1228 
1229  vector pos = FrameSlot.GetPos(widget);
1230 
1231  float wX, wY;
1232  m_MapEntity.ScreenToWorld(GetGame().GetWorkspace().DPIScale(pos[0]), GetGame().GetWorkspace().DPIScale(pos[1]), wX, wY);
1233 
1234  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
1235 
1236  SCR_MapMarkerBase markerNew = new SCR_MapMarkerBase();
1237  markerNew.SetType(marker.GetType());
1238  markerNew.SetWorldPos(wX, wY);
1239  markerNew.SetCustomText(marker.GetCustomText());
1240  markerNew.SetMarkerFactionFlags(marker.GetMarkerFactionFlags());
1241 
1242  if (type == SCR_EMapMarkerType.PLACED_CUSTOM)
1243  {
1244  markerNew.SetColorEntry(marker.GetColorEntry());
1245  markerNew.SetIconEntry(marker.GetIconEntry());
1246  markerNew.SetRotation(marker.GetRotation());
1247  }
1248  else
1249  {
1250  markerNew.SetFlags(marker.GetFlags());
1251  markerNew.SetMarkerConfigID(marker.GetMarkerConfigID()); // combination of faction and dimension id
1252  }
1253 
1254  int markerID = marker.GetMarkerID();
1255  RemoveOwnedMarker(marker);
1256 
1257  bool isLocal = markerID == -1;
1258  m_MarkerMgr.InsertStaticMarker(markerNew, isLocal);
1259 
1260  m_OnCustomMarkerPlaced.Invoke(wX, wY, isLocal);
1261  }
1262  }
1263 
1264  //------------------------------------------------------------------------------------------------
1265  // OVERRIDES
1266  //------------------------------------------------------------------------------------------------
1267  override void OnMapOpen(MapConfiguration config)
1268  {
1269  super.OnMapOpen(config);
1270 
1271  CreateStaticMarkers();
1272  CreateDynamicMarkers();
1273 
1274  m_MarkerMgr.EnableUpdate(true); // run frame update manager side
1275 
1276  GetGame().GetInputManager().AddActionListener("MapQuickMarkerMenu", EActionTrigger.DOWN, OnInputQuickMarkerMenu);
1277  GetGame().GetInputManager().AddActionListener("MapMarkerDelete", EActionTrigger.DOWN, OnInputMarkerDelete);
1278  GetGame().GetInputManager().AddActionListener("MapSelect", EActionTrigger.DOWN, OnInputMapSelect);
1279  GetGame().GetInputManager().AddActionListener("MenuSelect", EActionTrigger.DOWN, OnInputMenuConfirm);
1280  GetGame().GetInputManager().AddActionListener("MenuRefresh", EActionTrigger.DOWN, OnInputMenuConfirmAlter);
1281  GetGame().GetInputManager().AddActionListener("MenuBack", EActionTrigger.DOWN, OnInputMenuBack);
1282  GetGame().GetInputManager().AddActionListener("MenuDown", EActionTrigger.DOWN, OnInputMenuDown);
1283  GetGame().GetInputManager().AddActionListener("MenuUp", EActionTrigger.DOWN, OnInputMenuUp);
1284  GetGame().GetInputManager().AddActionListener("MenuRight", EActionTrigger.DOWN, OnInputMenuRight);
1285  GetGame().GetInputManager().AddActionListener("MenuLeft", EActionTrigger.DOWN, OnInputMenuLeft);
1286 
1287  if ( SCR_MapToolInteractionUI.Cast(m_MapEntity.GetMapUIComponent(SCR_MapToolInteractionUI)) ) // if dragging available, add callback
1288  {
1289  SCR_MapToolInteractionUI.GetOnDragWidgetInvoker().Insert(OnDragWidget);
1290  SCR_MapToolInteractionUI.GetOnDragEndInvoker().Insert(OnDragEnd);
1291  }
1292 
1293  SCR_MapMarkerConfig markerConfig = m_MarkerMgr.GetMarkerConfig();
1294  if (markerConfig)
1295  {
1296  foreach (SCR_MapMarkerEntryConfig entryType : markerConfig.GetMarkerEntryConfigs())
1297  {
1298  entryType.OnMapOpen(m_MapEntity, this);
1299  }
1300  }
1301  }
1302 
1303  //------------------------------------------------------------------------------------------------
1304  override void OnMapClose(MapConfiguration config)
1305  {
1306  SCR_MapMarkerConfig markerConfig = m_MarkerMgr.GetMarkerConfig();
1307  if (!markerConfig)
1308  return;
1309 
1310  foreach (SCR_MapMarkerEntryConfig entryType : markerConfig.GetMarkerEntryConfigs())
1311  {
1312  entryType.OnMapClose(m_MapEntity, this);
1313  }
1314 
1315  CleanupMarkerEditWidget();
1316  GetGame().GetInputManager().RemoveActionListener("MapQuickMarkerMenu", EActionTrigger.DOWN, OnInputQuickMarkerMenu);
1317  GetGame().GetInputManager().RemoveActionListener("MapMarkerDelete", EActionTrigger.DOWN, OnInputMarkerDelete);
1318  GetGame().GetInputManager().RemoveActionListener("MapSelect", EActionTrigger.DOWN, OnInputMapSelect);
1319  GetGame().GetInputManager().RemoveActionListener("MenuSelect", EActionTrigger.DOWN, OnInputMenuConfirm);
1320  GetGame().GetInputManager().RemoveActionListener("MenuRefresh", EActionTrigger.DOWN, OnInputMenuConfirmAlter);
1321  GetGame().GetInputManager().RemoveActionListener("MenuBack", EActionTrigger.DOWN, OnInputMenuBack);
1322  GetGame().GetInputManager().RemoveActionListener("MenuDown", EActionTrigger.DOWN, OnInputMenuDown);
1323  GetGame().GetInputManager().RemoveActionListener("MenuUp", EActionTrigger.DOWN, OnInputMenuUp);
1324  GetGame().GetInputManager().RemoveActionListener("MenuRight", EActionTrigger.DOWN, OnInputMenuRight);
1325  GetGame().GetInputManager().RemoveActionListener("MenuLeft", EActionTrigger.DOWN, OnInputMenuLeft);
1326 
1327  m_MarkerMgr.EnableUpdate(false);
1328  super.OnMapClose(config);
1329  }
1330 
1331  //------------------------------------------------------------------------------------------------
1332  override void Init()
1333  {
1334  SCR_MapRadialUI radialMenu = SCR_MapRadialUI.Cast(m_MapEntity.GetMapUIComponent(SCR_MapRadialUI));
1335  if (radialMenu)
1336  {
1337  radialMenu.GetOnMenuInitInvoker().Insert(OnRadialMenuInit);
1338  radialMenu.GetRadialController().GetOnInputOpen().Insert(OnRadialMenuOpen);
1339  }
1340 
1342 
1343  m_MarkerMgr = SCR_MapMarkerManagerComponent.Cast(GetGame().GetGameMode().FindComponent(SCR_MapMarkerManagerComponent));
1344  SCR_MapMarkerConfig markerConfig = m_MarkerMgr.GetMarkerConfig();
1345  if (!markerConfig)
1346  return;
1347 
1348  m_PlacedMarkerConfig = SCR_MapMarkerEntryPlaced.Cast(markerConfig.GetMarkerEntryConfigByType(SCR_EMapMarkerType.PLACED_CUSTOM));
1349  m_MilitaryMarkerConfig = SCR_MapMarkerEntryMilitary.Cast(markerConfig.GetMarkerEntryConfigByType(SCR_EMapMarkerType.PLACED_MILITARY));
1350 
1351  array<ref SCR_MapMarkerEntryConfig> entryConfigs = markerConfig.GetMarkerEntryConfigs();
1352 
1353  foreach (SCR_MapMarkerEntryConfig entryType : entryConfigs)
1354  {
1355  entryType.OnMapInit(m_MapEntity, this);
1356  }
1357  }
1358 
1359  //------------------------------------------------------------------------------------------------
1360  override void Update(float timeSlice)
1361  {
1362  if (m_MarkerEditRoot)
1363  {
1364  if (!m_bIsDelayed)
1365  {
1366  m_bIsDelayed = true;
1367  return;
1368  }
1369 
1370  GetGame().GetInputManager().ActivateContext("MapMarkerEditContext");
1371  }
1372  }
1373 }
SCR_MapMarkerEntryPlaced
Marker entry which can be placed through map.
Definition: SCR_MapMarkerEntryPlaced.c:4
m_MapEntity
protected SCR_MapEntity m_MapEntity
Definition: SCR_MapGadgetComponent.c:14
m_RootWidget
protected Widget m_RootWidget
Definition: SCR_BinocularsComponent.c:10
SCR_MilitarySymbol
Definition: SCR_MilitarySymbol.c:2
SCR_ComboBoxComponent
Definition: SCR_ComboBoxComponent.c:1
SCR_RadialMenuController
Definition: SCR_RadialMenuController.c:8
SCR_SelectionMenuCategoryEntry
Definition: SCR_SelectionMenuCategory.c:6
SCR_MapRadialUI
2D map radial menu UI
Definition: SCR_MapRadialUI.c:13
SCR_MapMarkerBase
Definition: SCR_MapMarkerBase.c:3
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_MapMarkerEntryConfig
Base entry config.
Definition: SCR_MapMarkerConfig.c:50
func
func
Definition: SCR_AIThreatSystem.c:5
m_CursorModule
protected SCR_MapCursorModule m_CursorModule
Definition: SCR_MapDrawingUI.c:181
GetPlayerController
proto external PlayerController GetPlayerController()
Definition: SCR_PlayerDeployMenuHandlerComponent.c:307
SCR_TabViewComponent
Definition: SCR_TabViewComponent.c:13
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition: SCR_BaseGameModeComponent.c:15
SCR_MapCursorModule
Map cursor behavior and mode setup.
Definition: SCR_MapCursorModule.c:39
SCR_SliderComponent
Definition: SCR_SliderComponent.c:2
EMilitarySymbolIdentity
EMilitarySymbolIdentity
Definition: EMilitarySymbol.c:1
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_MapMarkerEntity
Definition: SCR_MapMarkerEntity.c:10
SCR_EMapMarkerType
SCR_EMapMarkerType
Definition: SCR_MapMarkerConfig.c:5
SCR_ButtonBaseComponent
Base class for any button, regardless its own content.
Definition: SCR_ButtonBaseComponent.c:3
MarkerPlacedInvoker
func MarkerPlacedInvoker
Definition: SCR_MapMarkersUI.c:3
SCR_MapMarkersUI
Markers UI map component.
Definition: SCR_MapMarkersUI.c:6
SCR_MarkerIconCategory
Placed marker icon category.
Definition: SCR_MapMarkerEntryPlaced.c:153
Faction
Definition: Faction.c:12
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
GetInputManager
protected InputManager GetInputManager()
Definition: SCR_BaseManualCameraComponent.c:65
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
SCR_MapMarkerMenuEntry
Base entry for marker selection menu.
Definition: SCR_MapMarkerMenuEntry.c:3
SCR_MapMarkerEntryMilitary
Marker military symbol entry.
Definition: SCR_MapMarkerEntryMilitary.c:4
SCR_EditBoxComponent
Definition: SCR_EditBoxComponent.c:8
EMilitarySymbolDimension
EMilitarySymbolDimension
Definition: EMilitarySymbol.c:14
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
SCR_MapMarkerWidgetComponent
Definition: SCR_MapMarkerWidgetComponent.c:3
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition: SCR_FactionManager.c:461
SCR_SelectionMenuEntry
Definition: SCR_SelectionMenuEntry.c:7
SCR_MilitarySymbolUIComponent
Definition: SCR_MilitarySymbolUIComponent.c:1
SCR_ButtonImageComponent
Definition: SCR_ButtonImageComponent.c:2
SCR_MapUIBaseComponent
Definition: SCR_MapUIBaseComponent.c:3
EMilitarySymbolIcon
EMilitarySymbolIcon
Definition: EMilitarySymbol.c:29
SCR_InputButtonComponent
Definition: SCR_InputButtonComponent.c:1
GetPlayerId
proto external int GetPlayerId()
Definition: SCR_SpawnRequestComponent.c:39
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180