3 protected const int MAX_COLUMNS = 6;
4 protected const float ICONS_SCALE = 0.75;
6 protected const ResourceName BUTTON_IMAGE =
"{6BBBE8F27E385D3B}UI/layouts/WidgetLibrary/Groups/WLib_GroupFlagButtonImage.layout";
9 override void OnMenuOpen()
12 InitGroupFlagSelectionMenu(MAX_COLUMNS, BUTTON_IMAGE);
16 override void OnMenuUpdate(
float tDelta)
18 super.OnMenuUpdate(tDelta);
20 GetGame().GetInputManager().ActivateContext(
"InteractableDialogContext");
24 override void OnConfirm()
36 void InitGroupFlagSelectionMenu(
int maxColumns, ResourceName widget)
53 OverlayWidget con = OverlayWidget.Cast(
GetRootWidget().FindAnyWidget(
"Content"));
55 GridLayoutWidget content = GridLayoutWidget.Cast(con.FindAnyWidget(
"ContentGrid"));
59 ResourceName imageSet = playerFaction.GetGroupFlagImageSet();
60 array<ResourceName> textures = {};
61 playerFaction.GetGroupFlagTextures(textures);
63 if (!textures.IsEmpty())
65 for(
int i = 0, count = textures.Count(); i < count; i++)
67 Widget contentButton =
GetGame().GetWorkspace().CreateWidgets(widget, content);
81 GridSlot.SetRow(contentButton, row);
82 GridSlot.SetColumn(contentButton, col);
84 ResourceName resource = textures[i];
85 if (resource.IsEmpty())
88 imageButton.GetImageWidget().LoadImageTexture(0, textures[i]);
89 imageButton.Resize(ICONS_SCALE);
90 imageButton.m_OnClicked.Insert(SetGroupFlag);
91 imageButton.SetImageID(i);
92 imageButton.SetIsFromImageset(
false);
98 if (!imageSet.IsEmpty())
100 array<string> flagNames = {};
101 playerFaction.GetFlagNames(flagNames);
103 for(
int i = 0; i < flagNames.Count(); i++)
105 Widget contentButton =
GetGame().GetWorkspace().CreateWidgets(widget, content);
113 if (col > maxColumns)
119 GridSlot.SetRow(contentButton, row);
120 GridSlot.SetColumn(contentButton, col);
122 ResourceName resource = playerFaction.GetGroupFlagImageSet();
123 if (resource.IsEmpty())
126 imageButton.GetImageWidget().LoadImageFromSet(0, resource, flagNames[i]);
127 imageButton.Resize(ICONS_SCALE);
128 imageButton.m_OnClicked.Insert(SetGroupFlag);
129 imageButton.SetImageID(i);
130 imageButton.SetImageSet(flagNames[i]);
131 imageButton.SetIsFromImageset(
true);
137 Widget cancelButton =
GetRootWidget().FindAnyWidget(
"Cancel");
140 cancel.m_OnClicked.Insert(CloseDialog);
151 SCR_PlayerControllerGroupComponent playerGroupController = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
152 if (!playerGroupController)
155 SCR_AIGroup group = groupManager.FindGroup(playerGroupController.GetGroupID());
163 bool isFromImageset = imageButton.GetIsFromImageset();
164 playerGroupController.RequestSetGroupFlag(group.GetGroupID(), imageButton.GetImageID(), isFromImageset);