8 [
Attribute(
"#AR-MapMarker_ParentCategory", UIWidgets.Auto,
"Menu category name" )]
9 protected string m_sCategoryName;
11 [
Attribute(
"{3262679C50EF4F01}UI/Textures/Icons/icons_wrapperUI.imageset", UIWidgets.ResourceNamePicker,
desc:
"Icons imageset",
params:
"imageset" )]
12 protected ResourceName m_sIconImageset;
14 [
Attribute(
"scenarios", UIWidgets.Auto,
"Category icon quad" )]
15 protected string m_sCategoryIconName;
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;
20 [
Attribute(
"{DEA2D3B788CDCB4F}UI/layouts/Map/MapIconSelectorEntry.layout", UIWidgets.ResourceNamePicker,
desc:
"Icon selection entry layout",
params:
"layout" )]
21 protected ResourceName m_sSelectorIconEntry;
23 [
Attribute(
"{8A5D43FC8AC6C171}UI/layouts/Map/MapColorSelectorEntry.layout", UIWidgets.ResourceNamePicker,
desc:
"Color selection entry layout",
params:
"layout" )]
24 protected ResourceName m_sSelectorColorEntry;
26 [
Attribute(
"{4B6A50B3D8200779}UI/layouts/Map/MapDimensionSelectorEntry.layout", UIWidgets.ResourceNamePicker,
desc:
"Dimension selection entry layout",
params:
"layout" )]
27 protected ResourceName m_sSelectorDimensionEntry;
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;
32 [
Attribute(
"cancel", UIWidgets.Auto,
"Delete icon quad" )]
33 protected string m_sDeleteIconName;
35 [
Attribute(
"20", UIWidgets.Auto,
"Icon selector entries per line" )]
36 protected int m_iIconsPerLine;
38 protected const int USERID_EDITBOX = 1000;
39 protected const int USERID_EDITBOX_MIL = 1001;
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";
46 protected ref Color BACKGROUND_DEFAULT =
new Color(4,4,4,255);
47 protected ref Color BACKGROUND_SELECTED =
new Color(16,16,16,255);
49 protected bool m_bIsMilitaryMarker;
50 protected int m_bIsDelayed;
51 protected int m_iIconEntryCount;
52 protected int m_iIconLines;
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;
66 protected TextWidget m_wFactionSelectionText;
67 protected TextWidget m_wDimensionSelectionText;
72 protected int m_iWantedIconEntry;
73 protected int m_iSelectedIconID;
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;
88 protected SCR_MapMarkerManagerComponent m_MarkerMgr;
95 protected ref ScriptInvokerBase<MarkerPlacedInvoker> m_OnCustomMarkerPlaced =
new ScriptInvokerBase<MarkerPlacedInvoker>();
97 protected ref map<SCR_ButtonBaseComponent, int> m_mIconIDs =
new map<SCR_ButtonBaseComponent, int>();
98 protected ref map<SCR_ButtonBaseComponent, int> m_mColorIDs =
new map<SCR_ButtonBaseComponent, int>();
99 protected ref map<SCR_ButtonBaseComponent, int> m_mFactionIDs =
new map<SCR_ButtonBaseComponent, int>();
100 protected ref map<SCR_ButtonBaseComponent, int> m_mDimensionIDs =
new map<SCR_ButtonBaseComponent, int>();
103 ScriptInvokerBase<MarkerPlacedInvoker> GetOnCustomMarkerPlaced()
105 return m_OnCustomMarkerPlaced;
112 PlayerController localController =
GetGame().GetPlayerController();
115 if (marker.GetMarkerOwnerID() == localController.GetPlayerId())
126 protected void CreateMarkerEditDialog(
bool isEditing =
false,
int tabID = 0,
int selectedIconEntry = -1,
int selectedColorEntry = -1)
128 m_bIsMilitaryMarker =
false;
130 if (m_MarkerEditRoot)
131 CleanupMarkerEditWidget();
133 m_iWantedIconEntry = selectedIconEntry;
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));
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"));
145 InitColorIcons(selectedColorEntry);
147 Widget sliderRotation = m_MarkerEditRoot.FindAnyWidget(
"SliderRoot");
149 m_SliderComp.m_OnChanged.Insert(OnSliderChanged);
151 Widget categoryTab = m_MarkerEditRoot.FindAnyWidget(
"MarkerEditTab");
154 array<ref SCR_MarkerIconCategory> categoriesArr = m_PlacedMarkerConfig.GetIconCategories();
157 m_TabComponent.AddTab(
string.Empty,
category.m_sName, identifier:
category.m_sIdentifier);
160 m_TabComponent.GetOnChanged().Insert(OnTabChanged);
161 m_TabComponent.ShowTab(tabID,
true,
false);
163 Widget editBoxRoot = m_MarkerEditRoot.FindAnyWidget(
"EditBoxRoot");
164 editBoxRoot.FindAnyWidget(
"EditBox").SetUserID(USERID_EDITBOX);
166 m_EditBoxComp.m_OnTextChange.Insert(OnEditBoxTextChanged);
167 m_EditBoxComp.SetValue(
string.Empty);
170 confirmComp.m_OnClicked.Insert(OnPlaceMarkerConfirmed);
174 confirmComp.SetLabel(
"#AR-ServerHosting_Edit");
176 m_MarkerEditRoot.FindAnyWidget(
"ButtonPrivate").SetVisible(
false);
177 m_MarkerEditRoot.FindAnyWidget(
"ButtonPrivate").SetEnabled(
false);
181 confirmComp.SetLabel(
"#AR-MapMarker_PlacePublic");
184 confirmComp.m_OnClicked.Insert(OnPlaceMarkerConfirmedPrivate);
188 confirmComp.m_OnClicked.Insert(OnEditCancelled);
190 FocusWidget(m_SelectedIconButton.GetRootWidget());
196 protected void CreateMilitaryMarkerEditDialog(
bool isEditing =
false,
int selectedFactionEntry = -1,
int selectedDimensionEntry = -1)
198 m_bIsMilitaryMarker =
true;
199 m_iWantedDimensionEntry = selectedDimensionEntry;
201 m_MarkerEditRoot =
GetGame().GetWorkspace().CreateWidgets(m_sMilitaryEditBoxLayout,
m_RootWidget);
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));
207 m_wMarkerPreviewMilitary = OverlayWidget.Cast(m_MarkerEditRoot.FindAnyWidget(
"SymbolOverlay"));
209 m_wMarkerPreviewText = TextWidget.Cast(m_MarkerEditRoot.FindAnyWidget(
"MarkerText"));
215 InitFactionIcons(selectedFactionEntry);
218 m_ComboBoxComp1.m_OnChanged.Insert(OnComboBoxChangedA);
221 m_ComboBoxComp2.m_OnChanged.Insert(OnComboBoxChangedB);
223 m_ComboBoxComp1.AddItem(
"");
224 m_ComboBoxComp2.AddItem(
"");
226 array<ref SCR_MarkerMilitaryType> types = m_MilitaryMarkerConfig.GetMilitaryTypes();
227 foreach (
int i, SCR_MarkerMilitaryType markerType : types)
229 m_ComboBoxComp1.AddItem(markerType.GetTranslation(),
false, markerType);
230 m_ComboBoxComp2.AddItem(markerType.GetTranslation(),
false, markerType);
233 m_ComboBoxComp1.SetCurrentItem(0);
234 OnComboBoxChangedA(m_ComboBoxComp1, -1);
236 m_ComboBoxComp2.SetCurrentItem(0);
237 OnComboBoxChangedB(m_ComboBoxComp2, -1);
239 Widget editBoxRoot = m_MarkerEditRoot.FindAnyWidget(
"EditBoxRoot");
240 editBoxRoot.FindAnyWidget(
"EditBox").SetUserID(USERID_EDITBOX_MIL);
242 m_EditBoxComp.m_OnTextChange.Insert(OnEditBoxTextChanged);
243 m_EditBoxComp.SetValue(
string.Empty);
246 confirmComp.m_OnClicked.Insert(OnPlaceMarkerConfirmed);
249 confirmComp.SetLabel(
"#AR-ServerHosting_Edit");
251 confirmComp.SetLabel(
"#AR-MapMarker_PlacePublic");
254 confirmComp.m_OnClicked.Insert(OnEditCancelled);
256 FocusWidget(m_SelectedFactionButton.GetRootWidget());
262 protected void FocusWidget(Widget widget)
264 GetGame().GetWorkspace().SetFocusedWidget(widget);
269 protected void InitFactionIcons(
int selectedFactionEntry)
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"));
277 m_mFactionIDs.Clear();
278 m_SelectedFactionButton =
null;
280 string imageset, quad;
282 foreach (
int i, SCR_MarkerMilitaryFactionEntry factionEntry : factionsArr)
284 Widget button =
GetGame().GetWorkspace().CreateWidgets(m_sSelectorIconEntry, factionSelectorLine);
285 button.SetName(
"FactionEntry" + i.ToString());
287 buttonComp.GetImageWidget().SetColor(factionEntry.GetColor());
288 factionEntry.GetIconResource(imageset, quad);
289 buttonComp.SetImage(imageset, quad);
291 buttonComp.m_OnClicked.Insert(OnFactionEntryClicked);
292 buttonComp.m_OnFocus.Insert(OnFactionEntryFocused);
294 m_mFactionIDs.Insert(buttonComp, i);
296 if (!firstFactionEntry)
297 firstFactionEntry = buttonComp;
300 if (selectedFactionEntry == -1)
302 OnFactionEntryClicked(firstFactionEntry);
308 OnFactionEntryClicked(buttonComp);
310 OnFactionEntryClicked(firstFactionEntry);
316 protected void InitDimensionIcons()
318 SCR_MarkerMilitaryFactionEntry factionEntry = m_MilitaryMarkerConfig.GetFactionEntry(m_iSelectedFactionID);
319 array<ref SCR_MarkerMilitaryDimension> dimensionsArr = m_MilitaryMarkerConfig.GetMilitaryDimensions();
320 if (!factionEntry || dimensionsArr.IsEmpty())
323 Widget dimensionSelector = m_MarkerEditRoot.FindAnyWidget(
"DimensionSelector");
324 Widget dimensionSelectorLine = dimensionSelector.FindAnyWidget(
"DimensionSelectorLine");
325 m_wDimensionSelectionText = TextWidget.Cast(dimensionSelector.FindAnyWidget(
"TextSelection"));
328 m_mDimensionIDs.Clear();
329 m_SelectedDimensionButton =
null;
331 Widget child = dimensionSelectorLine.GetChildren();
334 child.RemoveFromHierarchy();
335 child = dimensionSelectorLine.GetChildren();
338 string imageset, quad;
340 foreach (
int i, SCR_MarkerMilitaryDimension dimensionEntry : dimensionsArr)
342 Widget button =
GetGame().GetWorkspace().CreateWidgets(m_sSelectorDimensionEntry, dimensionSelectorLine);
343 button.SetName(
"DimensionEntry" + i.ToString());
346 milSymbol.SetIdentity(factionEntry.GetFactionIdentity());
347 milSymbol.SetDimension(dimensionEntry.GetDimension());
349 Widget overlay = button.FindAnyWidget(
"OverlaySymbol");
350 overlay.SetColor(factionEntry.GetColor());
353 symbolComp.Update(milSymbol);
356 buttonComp.m_OnClicked.Insert(OnDimensionEntryClicked);
357 buttonComp.m_OnFocus.Insert(OnDimensionEntryFocused);
359 m_mDimensionIDs.Insert(buttonComp, i);
361 if (!firstDimensionEntry)
362 firstDimensionEntry = buttonComp;
365 if (m_iWantedDimensionEntry == -1)
367 OnDimensionEntryClicked(firstDimensionEntry);
373 OnDimensionEntryClicked(buttonComp);
375 OnDimensionEntryClicked(firstDimensionEntry);
381 protected void InitColorIcons(
int selectedColorEntry)
383 array<ref SCR_MarkerColorEntry> colorsArr = m_PlacedMarkerConfig.GetColorEntries();
384 Widget colorSelector = m_MarkerEditRoot.FindAnyWidget(COLOR_SELECTOR);
385 Widget colorSelectorLine = colorSelector.FindAnyWidget(
"ColorSelectorLine");
389 m_SelectedColorButton =
null;
391 foreach (
int i, SCR_MarkerColorEntry colorEntry : colorsArr)
393 Widget button =
GetGame().GetWorkspace().CreateWidgets(m_sSelectorColorEntry, colorSelectorLine);
394 button.SetName(COLOR_ENTRY + i.ToString());
396 buttonComp.GetImageWidget().SetColor(colorEntry.GetColor());
397 buttonComp.m_OnClicked.Insert(OnColorEntryClicked);
398 buttonComp.m_OnFocus.Insert(OnColorEntryFocused);
400 m_mColorIDs.Insert(buttonComp, i);
402 if (!firstColorEntry)
403 firstColorEntry = buttonComp;
406 if (selectedColorEntry == -1)
408 OnColorEntryClicked(firstColorEntry);
414 OnColorEntryClicked(buttonComp);
416 OnColorEntryClicked(firstColorEntry);
422 protected void InitCategoryIcons(SCR_TabViewContent tabContent)
425 m_SelectedIconButton =
null;
427 string imageset, imagesetGlow, quad;
429 m_IconSelector = m_MarkerEditRoot.FindAnyWidget(ICON_SELECTOR);
430 array<ref SCR_MarkerIconEntry> iconsArr = m_PlacedMarkerConfig.GetIconEntries();
432 Widget child = m_IconSelector.GetChildren();
435 child.RemoveFromHierarchy();
436 child = m_IconSelector.GetChildren();
439 Widget iconSelectorLine =
GetGame().GetWorkspace().CreateWidgets(SELECTOR_LINE, m_IconSelector);
440 m_iIconEntryCount = 0;
445 foreach (
int i, SCR_MarkerIconEntry iconEntry : iconsArr)
447 if (iconEntry.m_sCategoryIdentifier != tabContent.m_sTabIdentifier)
451 if (m_iIconEntryCount > m_iIconsPerLine * m_iIconLines)
453 iconSelectorLine =
GetGame().GetWorkspace().CreateWidgets(SELECTOR_LINE, m_IconSelector);
457 Widget button =
GetGame().GetWorkspace().CreateWidgets(m_sSelectorIconEntry, iconSelectorLine);
458 button.SetName(ICON_ENTRY + m_iIconEntryCount.ToString());
460 m_mIconIDs.Insert(buttonComp, i);
462 firstEntry = buttonComp;
464 iconEntry.GetIconResource(imageset, imagesetGlow, quad);
465 buttonComp.SetImage(imageset, quad);
466 buttonComp.m_OnClicked.Insert(OnIconEntryClicked);
467 buttonComp.m_OnFocus.Insert(OnIconEntryFocused);
470 if (m_iWantedIconEntry == -1)
472 OnIconEntryClicked(firstEntry);
478 OnIconEntryClicked(buttonComp);
480 OnIconEntryClicked(firstEntry);
486 protected void CreateStaticMarkers()
488 array<ref SCR_MapMarkerBase> markersSimple = m_MarkerMgr.GetStaticMarkers();
489 FactionManager factionManager =
GetGame().GetFactionManager();
491 int count = markersSimple.Count();
492 for (
int i; i < count; i++)
494 if (!markersSimple.IsIndexValid(i))
498 if (marker.GetMarkerFactionFlags() == 0 || !factionManager)
500 marker.OnCreateMarker();
505 bool isMyFaction = marker.IsFaction(factionManager.GetFactionIndex(localFaction));
507 if (!isMyFaction || !localFaction)
509 if (Replication.IsServer())
510 marker.SetServerDisabled(
true);
513 markersSimple.RemoveItem(marker);
520 marker.OnCreateMarker();
526 protected void CreateDynamicMarkers()
528 array<SCR_MapMarkerEntity> markersDynamic = m_MarkerMgr.GetDynamicMarkers();
531 marker.OnCreateMarker();
537 protected void RemoveMarkerMenu()
539 RemoveOwnedMarker(m_RemovableMarker);
547 m_MarkerMgr.RemoveStaticMarker(marker);
552 protected void CleanupMarkerEditWidget()
554 if (m_MarkerEditRoot)
555 m_MarkerEditRoot.RemoveFromHierarchy();
557 m_bIsDelayed =
false;
568 SCR_TabViewContent tab = tabView.GetEntryContent(
index);
570 InitCategoryIcons(tab);
571 m_SliderComp.SetValue(0);
578 if (m_SelectedFactionButton)
580 m_SelectedFactionButton.SetBackgroundColors(BACKGROUND_DEFAULT);
581 m_SelectedFactionButton.ColorizeBackground(
false);
584 component.SetBackgroundColors(BACKGROUND_SELECTED);
585 component.ColorizeBackground(
false);
586 m_SelectedFactionButton = component;
587 m_iSelectedFactionID = m_mFactionIDs.Get(component);
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);
595 InitDimensionIcons();
600 protected void OnFactionEntryFocused(Widget rootW)
607 OnFactionEntryClicked(buttonComp);
614 if (m_SelectedDimensionButton)
616 m_SelectedDimensionButton.SetBackgroundColors(BACKGROUND_DEFAULT);
617 m_SelectedDimensionButton.ColorizeBackground(
false);
620 component.SetBackgroundColors(BACKGROUND_SELECTED);
621 component.ColorizeBackground(
false);
622 m_SelectedDimensionButton = component;
623 m_iSelectedDimensionID = m_mDimensionIDs.Get(component);
624 m_iWantedDimensionEntry = m_iSelectedDimensionID;
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);
634 protected void OnDimensionEntryFocused(Widget rootW)
641 OnDimensionEntryClicked(buttonComp);
648 if (m_SelectedColorButton)
650 m_SelectedColorButton.SetBackgroundColors(BACKGROUND_DEFAULT);
651 m_SelectedColorButton.ColorizeBackground(
false);
654 component.SetBackgroundColors(BACKGROUND_SELECTED);
655 component.ColorizeBackground(
false);
656 m_SelectedColorButton = component;
657 m_iSelectedColorID = m_mColorIDs.Get(component);
659 m_wMarkerPreview.SetColor(m_PlacedMarkerConfig.GetColorEntry(m_iSelectedColorID));
664 protected void OnColorEntryFocused(Widget rootW)
671 OnColorEntryClicked(buttonComp);
678 if (m_SelectedIconButton)
680 m_SelectedIconButton.SetBackgroundColors(BACKGROUND_DEFAULT);
681 m_SelectedIconButton.ColorizeBackground(
false);
684 component.SetBackgroundColors(BACKGROUND_SELECTED);
685 component.ColorizeBackground(
false);
686 m_SelectedIconButton = component;
687 m_iSelectedIconID = m_mIconIDs.Get(component);
689 ResourceName imageset, imagesetGlow;
691 m_PlacedMarkerConfig.GetIconEntry(m_iSelectedIconID, imageset, imagesetGlow, quad);
693 m_wMarkerPreview.LoadImageFromSet(0, imageset, quad);
694 m_wMarkerPreviewGlow.LoadImageFromSet(0, imagesetGlow, quad);
699 protected void OnIconEntryFocused(Widget rootW)
706 OnIconEntryClicked(buttonComp);
711 protected void OnEditBoxTextChanged(
string text)
713 m_wMarkerPreviewText.SetText(text);
720 m_wMarkerPreview.SetRotation(value);
721 m_wMarkerPreviewGlow.SetRotation(value);
729 m_eMilitaryTypeA = SCR_MarkerMilitaryType.Cast(comp.GetItemData(value));
730 if (m_eMilitaryTypeA)
731 m_eMilitaryTypeAIcon = m_eMilitaryTypeA.GetType();
733 m_eMilitaryTypeAIcon = 0;
735 m_MilSymbolPreview.SetIcons(m_eMilitaryTypeAIcon | m_eMilitaryTypeBIcon);
736 m_MarkerPreviewMilitaryComp.Update(m_MilSymbolPreview);
743 m_eMilitaryTypeB = SCR_MarkerMilitaryType.Cast(comp.GetItemData(value));
744 if (m_eMilitaryTypeB)
745 m_eMilitaryTypeBIcon = m_eMilitaryTypeB.GetType();
747 m_eMilitaryTypeBIcon = 0;
749 m_MilSymbolPreview.SetIcons(m_eMilitaryTypeAIcon | m_eMilitaryTypeBIcon);
750 m_MarkerPreviewMilitaryComp.Update(m_MilSymbolPreview);
759 RemoveOwnedMarker(m_EditedMarker);
760 m_EditedMarker =
null;
763 OnInsertMarker(
false);
770 OnInsertMarker(
true);
779 m_EditedMarker.SetVisible(
true);
780 m_EditedMarker =
null;
783 CleanupMarkerEditWidget();
787 protected void OnInsertMarker(
bool isLocal)
794 if (m_bIsMilitaryMarker)
797 marker.SetFlags(m_eMilitaryTypeAIcon | m_eMilitaryTypeBIcon);
798 marker.SetMarkerConfigID(m_iSelectedDimensionID * 100 + m_iSelectedFactionID);
803 marker.SetRotation(m_fRotation);
804 marker.SetColorEntry(m_iSelectedColorID);
805 marker.SetIconEntry(m_iSelectedIconID);
808 marker.SetCustomText(m_EditBoxComp.GetValue());
809 marker.SetWorldPos(wX, wY);
813 FactionManager factionManager =
GetGame().GetFactionManager();
817 if (markerOwnerFaction)
818 marker.AddMarkerFactionFlags(factionManager.GetFactionIndex(markerOwnerFaction));
822 m_MarkerMgr.InsertStaticMarker(marker, isLocal);
823 m_OnCustomMarkerPlaced.Invoke(wX, wY, isLocal);
825 CleanupMarkerEditWidget();
830 protected void OnRadialMenuInit()
832 SCR_MapMarkerConfig markerConfig = m_MarkerMgr.GetMarkerConfig();
838 m_RootCategoryEntry = radialUI.AddRadialCategory(m_sCategoryName);
839 m_RootCategoryEntry.SetIcon(m_sIconImageset, m_sCategoryIconName);
841 array<ref SCR_MapMarkerEntryConfig> entryConfigs = markerConfig.GetMarkerEntryConfigs();
851 menuEntry.SetName(entryMil.GetMenuDescription());
852 menuEntry.GetOnPerform().Insert(OnEntryPerformed);
853 menuEntry.SetIcon(entryMil.GetMenuImageset(), entryMil.GetMenuIcon());
855 radialUI.InsertCustomRadialEntry(menuEntry, m_RootCategoryEntry);
863 menuEntry.SetName(entryPlaced.GetMenuDescription());
864 menuEntry.GetOnPerform().Insert(OnEntryPerformed);
865 menuEntry.SetIcon(entryPlaced.GetMenuImageset(), entryPlaced.GetMenuIcon());
867 radialUI.InsertCustomRadialEntry(menuEntry, m_RootCategoryEntry);
877 if (m_MarkerRemoveEntry)
879 radialUI.RemoveRadialEntry(m_MarkerRemoveEntry);
880 m_RemovableMarker =
null;
887 foreach ( Widget widget : widgets )
899 m_MarkerRemoveEntry = radialUI.AddRadialEntry(
"#AR-MapMarker_DeleteHint");
900 m_MarkerRemoveEntry.SetIcon(m_sIconImageset, m_sDeleteIconName);
901 m_MarkerRemoveEntry.GetOnPerform().Insert(RemoveMarkerMenu);
903 m_RemovableMarker = marker;
918 if (!m_PlacedMarkerConfig)
920 SCR_MapMarkerConfig markerConfig = m_MarkerMgr.GetMarkerConfig();
924 m_PlacedMarkerConfig =
SCR_MapMarkerEntryPlaced.Cast(markerConfig.GetMarkerEntryConfigByType(markerEntry.GetMarkerType()));
925 if (!m_PlacedMarkerConfig)
929 CreateMarkerEditDialog();
933 if (!m_MilitaryMarkerConfig)
935 SCR_MapMarkerConfig markerConfig = m_MarkerMgr.GetMarkerConfig();
939 m_MilitaryMarkerConfig =
SCR_MapMarkerEntryMilitary.Cast(markerConfig.GetMarkerEntryConfigByType(markerEntry.GetMarkerType()));
940 if (!m_MilitaryMarkerConfig)
944 CreateMilitaryMarkerEditDialog();
950 protected void OnInputQuickMarkerMenu(
float value, EActionTrigger reason)
956 mapRadial.GetRadialController().OnInputOpen();
957 mapRadial.GetRadialController().GetRadialMenu().PerformEntry(m_RootCategoryEntry);
963 protected void OnInputMarkerDelete(
float value, EActionTrigger reason)
968 foreach ( Widget widget : widgets )
980 RemoveOwnedMarker(marker);
987 protected void OnInputMapSelect(
float value, EActionTrigger reason)
992 foreach ( Widget widget : widgets )
1002 m_EditedMarker = marker;
1008 float screenX, screenY;
1009 marker.GetWorldPos(wPos);
1010 m_MapEntity.WorldToScreen(wPos[0], wPos[1], screenX, screenY);
1015 if (!m_PlacedMarkerConfig)
1018 CreateMarkerEditDialog(
true, m_PlacedMarkerConfig.GetIconCategoryID(marker.GetIconEntry()), marker.GetIconEntry(), marker.GetColorEntry());
1020 OnEditBoxTextChanged(marker.GetCustomText());
1021 m_SliderComp.SetValue(marker.GetRotation());
1022 m_EditBoxComp.SetValue(marker.GetCustomText());
1026 if (!m_MilitaryMarkerConfig)
1030 OnEditBoxTextChanged(marker.GetCustomText());
1031 m_EditBoxComp.SetValue(marker.GetCustomText());
1033 int markerFlags = marker.GetFlags();
1036 array<ref SCR_MarkerMilitaryType> milTypes = m_MilitaryMarkerConfig.GetMilitaryTypes();
1037 foreach (
int i, SCR_MarkerMilitaryType milType : milTypes)
1039 if (markerFlags & milType.GetType())
1043 m_ComboBoxComp2.SetCurrentItem(i+1);
1044 OnComboBoxChangedB(m_ComboBoxComp2, i+1);
1049 m_ComboBoxComp1.SetCurrentItem(i+1);
1050 OnComboBoxChangedA(m_ComboBoxComp1, i+1);
1051 if (markerFlags == milType.GetType())
1060 marker.SetVisible(
false);
1069 protected void OnInputMenuConfirm(
float value, EActionTrigger reason)
1074 Widget focused =
GetGame().GetWorkspace().GetFocusedWidget();
1075 if (!focused || focused.GetUserID() == USERID_EDITBOX || focused.GetUserID() == USERID_EDITBOX_MIL)
1078 if (m_ComboBoxComp1 && (m_ComboBoxComp1.IsOpened() || m_ComboBoxComp1.GetRootWidget().FindAnyWidget(
"ComboButton") == focused))
1081 if (m_ComboBoxComp2 && (m_ComboBoxComp2.IsOpened() || m_ComboBoxComp2.GetRootWidget().FindAnyWidget(
"ComboButton") == focused))
1084 if (m_MarkerEditRoot)
1085 OnPlaceMarkerConfirmed(
null);
1090 protected void OnInputMenuConfirmAlter(
float value, EActionTrigger reason)
1092 if (m_MarkerEditRoot)
1093 OnPlaceMarkerConfirmedPrivate(
null);
1098 protected void OnInputMenuBack(
float value, EActionTrigger reason)
1100 if (m_MarkerEditRoot)
1101 OnEditCancelled(
null);
1105 protected void OnInputMenuDown(
float value, EActionTrigger reason)
1109 Widget focused =
GetGame().GetWorkspace().GetFocusedWidget();
1111 name = focused.GetName();
1113 if (name.Contains(ICON_ENTRY))
1114 FocusWidget(m_SelectedColorButton.GetRootWidget());
1115 else if (name.Contains(
"FactionEntry"))
1116 FocusWidget(m_SelectedDimensionButton.GetRootWidget());
1120 protected void OnInputMenuUp(
float value, EActionTrigger reason)
1124 Widget focused =
GetGame().GetWorkspace().GetFocusedWidget();
1128 name = focused.GetName();
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"))
1140 while (focused.GetParent() !=
null)
1142 focused = focused.GetParent();
1143 if (focused.GetName().Contains(
"ComboBox1"))
1145 FocusWidget(m_SelectedDimensionButton.GetRootWidget());
1153 protected void OnInputMenuLeft(
float value, EActionTrigger reason)
1157 Widget focused =
GetGame().GetWorkspace().GetFocusedWidget();
1159 name = focused.GetName();
1161 if (!name.Contains(ICON_ENTRY))
1164 int pos = name.ToInt(offset: 9);
1165 int target = pos - 1;
1168 target = m_iIconEntryCount;
1170 Widget w = m_IconSelector.FindAnyWidget(ICON_ENTRY + target);
1176 protected void OnInputMenuRight(
float value, EActionTrigger reason)
1180 Widget focused =
GetGame().GetWorkspace().GetFocusedWidget();
1182 name = focused.GetName();
1184 if (!name.Contains(ICON_ENTRY))
1187 int pos = name.ToInt(offset: 9);
1188 int target = pos + 1;
1190 if (target > m_iIconEntryCount)
1193 Widget w = m_IconSelector.FindAnyWidget(ICON_ENTRY + target);
1200 protected void OnDragWidget(Widget widget)
1208 marker.SetDragged(
true);
1214 protected void OnDragEnd(Widget widget,
bool wasDragged)
1224 marker.SetDragged(
false);
1229 vector pos = FrameSlot.GetPos(widget);
1232 m_MapEntity.ScreenToWorld(
GetGame().GetWorkspace().DPIScale(pos[0]),
GetGame().GetWorkspace().DPIScale(pos[1]), wX, wY);
1234 marker.SetWorldPos(wX, wY);
1237 markerNew.SetType(marker.GetType());
1238 markerNew.SetWorldPos(wX, wY);
1239 markerNew.SetCustomText(marker.GetCustomText());
1240 markerNew.SetMarkerFactionFlags(marker.GetMarkerFactionFlags());
1244 markerNew.SetColorEntry(marker.GetColorEntry());
1245 markerNew.SetIconEntry(marker.GetIconEntry());
1246 markerNew.SetRotation(marker.GetRotation());
1250 markerNew.SetFlags(marker.GetFlags());
1251 markerNew.SetMarkerConfigID(marker.GetMarkerConfigID());
1254 int markerID = marker.GetMarkerID();
1255 RemoveOwnedMarker(marker);
1257 bool isLocal = markerID == -1;
1258 m_MarkerMgr.InsertStaticMarker(markerNew, isLocal);
1260 m_OnCustomMarkerPlaced.Invoke(wX, wY, isLocal);
1267 override void OnMapOpen(MapConfiguration config)
1269 super.OnMapOpen(config);
1271 CreateStaticMarkers();
1272 CreateDynamicMarkers();
1274 m_MarkerMgr.EnableUpdate(
true);
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);
1287 if ( SCR_MapToolInteractionUI.Cast(
m_MapEntity.GetMapUIComponent(SCR_MapToolInteractionUI)) )
1289 SCR_MapToolInteractionUI.GetOnDragWidgetInvoker().Insert(OnDragWidget);
1290 SCR_MapToolInteractionUI.GetOnDragEndInvoker().Insert(OnDragEnd);
1293 SCR_MapMarkerConfig markerConfig = m_MarkerMgr.GetMarkerConfig();
1304 override void OnMapClose(MapConfiguration config)
1306 SCR_MapMarkerConfig markerConfig = m_MarkerMgr.GetMarkerConfig();
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);
1327 m_MarkerMgr.EnableUpdate(
false);
1328 super.OnMapClose(config);
1332 override void Init()
1337 radialMenu.GetOnMenuInitInvoker().Insert(OnRadialMenuInit);
1338 radialMenu.GetRadialController().GetOnInputOpen().Insert(OnRadialMenuOpen);
1343 m_MarkerMgr = SCR_MapMarkerManagerComponent.Cast(
GetGame().
GetGameMode().FindComponent(SCR_MapMarkerManagerComponent));
1344 SCR_MapMarkerConfig markerConfig = m_MarkerMgr.GetMarkerConfig();
1351 array<ref SCR_MapMarkerEntryConfig> entryConfigs = markerConfig.GetMarkerEntryConfigs();
1360 override void Update(
float timeSlice)
1362 if (m_MarkerEditRoot)
1366 m_bIsDelayed =
true;
1370 GetGame().GetInputManager().ActivateContext(
"MapMarkerEditContext");