Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_GroupTileButton.c
Go to the documentation of this file.
2 {
3  protected SCR_ComboBoxComponent m_OptionsCombo;
4  protected int m_iPlayerId;
5  protected SCR_ChimeraCharacter m_AICharacter;
6 
7  protected ref ScriptInvokerInt m_OnTileFocus;
8  protected ref ScriptInvokerInt m_OnTileFocusLost;
9 
10  //------------------------------------------------------------------------------------------------
11  override bool OnClick(Widget w, int x, int y, int button)
12  {
13  // TODO: on self, this combo box is empty and invisible. On others allows inviting to your group
14  m_OptionsCombo.OpenList();
15  return super.OnClick(w, x, y, button);
16  }
17 
18  //------------------------------------------------------------------------------------------------
19  override bool OnFocus(Widget w, int x, int y)
20  {
21  if (m_OnTileFocus)
22  m_OnTileFocus.Invoke(m_iPlayerId);
23 
24  return super.OnFocus(w, x, y);
25  }
26 
27  //------------------------------------------------------------------------------------------------
28  override bool OnFocusLost(Widget w, int x, int y)
29  {
30  if (m_OnTileFocusLost)
31  m_OnTileFocusLost.Invoke(m_iPlayerId);
32 
33  return super.OnFocusLost(w, x, y);
34  }
35 
36  //------------------------------------------------------------------------------------------------
37  ScriptInvokerInt GetOnTileFocus()
38  {
39  if (!m_OnTileFocus)
40  m_OnTileFocus = new ScriptInvokerInt();
41 
42  return m_OnTileFocus;
43  }
44 
45  //------------------------------------------------------------------------------------------------
46  ScriptInvokerInt GetOnTileFocusLost()
47  {
48  if (!m_OnTileFocusLost)
49  m_OnTileFocusLost = new ScriptInvokerInt();
50 
51  return m_OnTileFocusLost;
52  }
53 
54  //------------------------------------------------------------------------------------------------
55  int GetTilePlayerID()
56  {
57  return m_iPlayerId;
58  }
59 
60  //------------------------------------------------------------------------------------------------
61  void SetTilePlayerID(int playerID)
62  {
63  m_iPlayerId = playerID;
64  }
65 
66  //------------------------------------------------------------------------------------------------
67  SCR_ChimeraCharacter GetCharacter()
68  {
69  return m_AICharacter;
70  }
71 
72  //------------------------------------------------------------------------------------------------
73  void SetCharacter(SCR_ChimeraCharacter character)
74  {
75  m_AICharacter = character;
76  }
77 
78  //------------------------------------------------------------------------------------------------
79  SCR_ComboBoxComponent GetOptionsComboComponent()
80  {
81  return m_OptionsCombo;
82  }
83 
84  //------------------------------------------------------------------------------------------------
85  void SetOptionsComboBoxComponent(SCR_ComboBoxComponent optionsCombo)
86  {
87  m_OptionsCombo = optionsCombo;
88  }
89 
90  //------------------------------------------------------------------------------------------------
91  void SetOpacity(float opacity)
92  {
93  Widget comboBox = m_OptionsCombo.GetRootWidget();
94  if (!comboBox)
95  return;
96 
97  ImageWidget comboImage = ImageWidget.Cast(comboBox.FindAnyWidget("Image0"));
98  if (!comboImage)
99  return;
100 
101  comboImage.SetOpacity(opacity);
102  }
103 };
104 
105 //------------------------------------------------------------------------------------------------
107 {
108  protected int m_iGroupID;
109  protected Faction m_GroupFaction;
110 
111  [Attribute()]
112  protected ResourceName m_textLayout;
113 
114  [Attribute()]
115  protected ref SCR_UIInfo m_LeaderInfo;
116 
117  protected SCR_GroupsManagerComponent m_GroupManager;
118  protected SCR_BaseTaskManager m_BaseTaskManager;
119  protected SCR_InputButtonComponent m_JoinGroupButton;
120  protected SCR_PlayerControllerGroupComponent m_GroupComponent;
121 
122  [Attribute("0.898 0.541 0.184 1", UIWidgets.ColorPicker)]
123  protected ref Color m_PlayerNameSelfColor;
124 
125  [Attribute("0.898 0.541 0.184 1", UIWidgets.ColorPicker)]
126  protected ref Color m_PlayerNameDeadColor;
127 
128  [Attribute("0.898 0.541 0.184 1", UIWidgets.ColorPicker)]
129  protected ref Color m_GroupFullColor;
130 
131  protected ResourceName m_sIconsImageSet = "{2EFEA2AF1F38E7F0}UI/Textures/Icons/icons_wrapperUI-64.imageset";
132 
133  protected const string OPTIONS_COMBO_INVITE = "#AR-PlayerList_Invite";
134  protected const string OPTIONS_COMBO_KICK = "#AR-DeployMenu_Groups_Kick";
135  protected const string OPTIONS_COMBO_PROMOTE = "#AR-DeployMenu_Groups_Promote";
136  protected const string LOCK_GROUP = "#AR-Player_Groups_Lock";
137  protected const string UNLOCK_GROUP = "#AR-Player_Groups_Unlock";
138  protected const string PRIVATE_GROUP = "#AR-Player_Groups_Private";
139  protected const string PUBLIC_GROUP = "#AR-Player_Groups_Public";
140  protected const string JOIN_GROUP = "#AR-DeployMenu_JoinGroup";
141  protected const string REQUEST_JOIN_GROUP = "#AR-DeployMenu_RequestJoinGroup";
142 
143  protected const ResourceName GROUP_FLAG_SELECTION = "{7340FE3C6872C6D3}UI/layouts/Menus/GroupSlection/GroupFlagSelection.layout";
144 
145  protected ref array<SCR_PlayerTileButtonComponent> m_aPlayerComponentsList = {};
146  protected SCR_PlayerTileButtonComponent m_PlayerTileComponent;
147  protected static ref ScriptInvoker s_OnGroupButtonClicked = new ScriptInvoker();
148 
149  protected static ref ScriptInvokerInt m_OnPlayerTileFocus;
150  protected static ref ScriptInvokerInt m_OnPlayerTileFocusLost;
151 
152  //------------------------------------------------------------------------------------------------
153  override bool OnClick(Widget w, int x, int y, int button)
154  {
155  super.OnClick(w, x, y, button);
156 
157 #ifdef DEBUG_GROUPS
158  SCR_GroupsManagerComponent.GetInstance().UpdateDebugUI();
159 #endif
160  m_GroupComponent.SetSelectedGroupID(m_iGroupID);
161  s_OnGroupButtonClicked.Invoke();
162 
163  return true;
164  }
165 
166  //------------------------------------------------------------------------------------------------
167  void InitiateGroupTile()
168  {
169  m_GroupManager = SCR_GroupsManagerComponent.GetInstance();
170  if (!m_GroupManager)
171  return;
172 
173  m_GroupComponent = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
174  if (!m_GroupComponent)
175  return;
176 
178  if (!playerController)
179  return;
180 
181 
182  SCR_AIGroup group = m_GroupManager.FindGroup(m_iGroupID);
183  if (!group)
184  return;
185 
186  group.GetOnPlayerLeaderChanged().Insert(SetupJoinGroupButton);
187  group.GetOnJoinPrivateGroupRequest().Insert(SetupJoinGroupButton);
188 
189  //workaround for issues with playerControllerGroupsComponent, needs to be reworked with this whole script mess
190  SCR_GroupSubMenu.Init();
191  SCR_GroupSubMenu.GetOnJoingGroupRequestSent().Insert(SetupJoinGroupButton);
192 
193  m_BaseTaskManager = GetTaskManager();
194  if (m_BaseTaskManager)
195  m_BaseTaskManager.s_OnTaskUpdate.Insert(RefreshPlayers);
196 
197  group.GetOnMemberStateChange().Insert(RefreshPlayers);
198 
199  RichTextWidget squadName = RichTextWidget.Cast(GetRootWidget().FindAnyWidget("Callsign"));
200  if (squadName)
201  {
202  string groupName = group.GetCustomNameWithOriginal();
203  string company, platoon, squad, character, format;
204  group.GetCallsigns(company, platoon, squad, character, format);
205 
206  if (groupName.IsEmpty() || group.GetNameAuthorID() != 0 && !playerController.CanViewContentCreatedBy(group.GetNameAuthorID()))
207  {
208  squadName.SetTextFormat(format, company, platoon, squad, character);
209  }
210  else
211  {
212  company = WidgetManager.Translate(company);
213  groupName = group.GetCustomName() + " (" + string.Format(format, company, platoon, squad, character) + ")";
214  squadName.SetText(groupName);
215  }
216  }
217 
218  RichTextWidget frequency = RichTextWidget.Cast(GetRootWidget().FindAnyWidget("Frequency"));
219  if (frequency)
220  frequency.SetText(""+group.GetRadioFrequency()*0.001 + " #AR-VON_FrequencyUnits_MHz");
221 
222  RichTextWidget playerCount = RichTextWidget.Cast(GetRootWidget().FindAnyWidget("PlayerCount"));
223  if (playerCount)
224  playerCount.SetText(group.GetPlayerCount().ToString() + "/" + group.GetMaxMembers());
225 
226  if (group.IsFull())
227  SetGroupInfoColor(m_GroupFullColor);
228 
229  ImageWidget background = ImageWidget.Cast(GetRootWidget().FindAnyWidget("Background"));
230 
231  if (background)
232  background.SetVisible(m_GroupComponent.GetSelectedGroupID() == m_iGroupID);
233 
234  if (group.IsPlayerInGroup(playerController.GetPlayerId()))
235  squadName.SetColor(m_PlayerNameSelfColor);
236 
237  ImageWidget privateIcon = ImageWidget.Cast(GetRootWidget().FindAnyWidget("PrivateIcon"));
238  if (privateIcon)
239  privateIcon.SetVisible(group.IsPrivate());
240 
241  if (!m_ParentSubMenu)
242  FindParentMenu();
243  }
244 
245  //------------------------------------------------------------------------------------------------
246  void SetupSelectGroupFlagButton(SCR_AIGroup group)
247  {
248  if (!m_ParentSubMenu)
249  return;
250 
251  Widget groupImage = m_ParentSubMenu.GetRootWidget().FindAnyWidget("GroupImage");
252  if (!groupImage)
253  return;
254 
255  SCR_GroupFlagImageComponent imageButton = SCR_GroupFlagImageComponent.Cast(groupImage.FindHandler(SCR_GroupFlagImageComponent));
256  if (!imageButton)
257  return;
258 
259  imageButton.m_OnClicked.Insert(OnSelectGroupFlagButtonClicked);
260 
261  SCR_Faction scrFaction = SCR_Faction.Cast(m_GroupFaction);
262  if (!scrFaction)
263  return;
264 
265  ResourceName flag = group.GetGroupFlag();
266 
267  if (flag.IsEmpty())
268  {
269  array<ResourceName> textures = {};
270 
271  scrFaction.GetGroupFlagTextures(textures);
272 
273  if (!scrFaction.GetGroupFlagImageSet().IsEmpty())
274  {
275  array<string> names = {};
276 
277  scrFaction.GetFlagNames(names);
278 
279  imageButton.SetFlagButtonFromImageSet(names[0]);
280  }
281  else if (!textures.IsEmpty())
282  {
283  imageButton.SetImage(textures[0]);
284  }
285  else
286  {
287  array<ResourceName> images = {};
288 
289  scrFaction.GetGroupFlagTextures(images);
290 
291  if (!scrFaction.GetGroupFlagImageSet().IsEmpty())
292  {
293  array<string> names = {};
294 
295  scrFaction.GetFlagNames(names);
296 
297  if (!names.IsEmpty())
298  imageButton.SetFlagButtonFromImageSet(names[0]);
299  }
300  else if (!images.IsEmpty())
301  {
302  imageButton.SetImage(images[0]);
303  }
304  else
305  {
306  imageButton.SetImage(scrFaction.GetFactionFlag());
307  }
308  }
309  }
310  else
311  {
312  if (group.GetFlagIsFromImageSet())
313  {
314  imageButton.SetFlagButtonFromImageSet(flag);
315  }
316  else
317  {
318  imageButton.SetImage(flag);
319  }
320  }
321  }
322 
323  //------------------------------------------------------------------------------------------------
324  void OnSelectGroupFlagButtonClicked()
325  {
326  SCR_PlayerControllerGroupComponent playerComponent = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
327  if (!playerComponent)
328  return;
329 
330  SCR_AIGroup group = m_GroupManager.FindGroup(m_iGroupID);
331  if (!group)
332  return;
333 
334  if (!group.IsPlayerLeader(playerComponent.GetPlayerID()))
335  {
336  SCR_NotificationsComponent.SendLocal(ENotification.GROUPS_PLAYER_IS_NOT_LEADER);
337  return;
338  }
339 
340  SCR_Faction playerFaction = SCR_Faction.Cast(group.GetFaction());
341 
342  array<string> flagNames = {};
343  array<ResourceName> flagTextures = {};
344  playerFaction.GetFlagNames(flagNames);
345  playerFaction.GetGroupFlagTextures(flagTextures);
346 
347 
348  if (!flagNames.IsEmpty() || !flagTextures.IsEmpty())
349  GetGame().GetMenuManager().OpenDialog(ChimeraMenuPreset.GroupFlagDialog, DialogPriority.CRITICAL, 0, true);
350  else
351  SCR_NotificationsComponent.SendLocal(ENotification.GROUPS_NO_FLAGS);
352  }
353 
354  //------------------------------------------------------------------------------------------------
355  void RefreshPlayers()
356  {
357  PlayerManager playerManager = GetGame().GetPlayerManager();
358  if (!m_GroupFaction || !m_GroupManager || !playerManager)
359  return;
360 
362  if (!playerController)
363  return;
364 
365  SCR_AIGroup group = m_GroupManager.FindGroup(m_iGroupID);
366  if (!group)
367  return;
368 
369  SetupSelectGroupFlagButton(group);
370 
371  if (m_ParentSubMenu == null)
372  FindParentMenu();
373 
374  m_aPlayerComponentsList.Clear();
375 
376  VerticalLayoutWidget playerList = VerticalLayoutWidget.Cast(m_ParentSubMenu.GetRootWidget().FindAnyWidget("PlayerList"));
377  if (!playerList)
378  return;
379 
380  VerticalLayoutWidget leaderList = VerticalLayoutWidget.Cast(m_ParentSubMenu.GetRootWidget().FindAnyWidget("Leader"));
381  if (!leaderList)
382  return;
383 
384  RichTextWidget squadName = RichTextWidget.Cast(m_ParentSubMenu.GetRootWidget().FindAnyWidget("GroupDetailCallsign"));
385  if (!squadName)
386  return;
387 
388  RichTextWidget description = RichTextWidget.Cast(m_ParentSubMenu.GetRootWidget().FindAnyWidget("Description"));
389  if (!description)
390  return;
391 
392  RichTextWidget frequency = RichTextWidget.Cast(m_ParentSubMenu.GetRootWidget().FindAnyWidget("GroupDetailFrequency"));
393  if (!frequency)
394  return;
395 
396 
397  SCR_PlayerControllerGroupComponent s_PlayerGroupController = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
398  if (!s_PlayerGroupController)
399  return;
400 
401  if (!s_PlayerGroupController.CanPlayerJoinGroup(playerController.GetPlayerId(), m_GroupManager.FindGroup(m_iGroupID)))
402  m_JoinGroupButton.SetEnabled(false);
403  else
404  m_JoinGroupButton.SetEnabled(true);
405 
406  string groupName = group.GetCustomName();
407  string company, platoon, squad, character, format;
408  group.GetCallsigns(company, platoon, squad, character, format);
409 
410  if (groupName.IsEmpty() || group.GetNameAuthorID() != 0 && !playerController.CanViewContentCreatedBy(group.GetNameAuthorID()))
411  {
412  squadName.SetTextFormat(format, company, platoon, squad, character);
413  }
414  else
415  {
416  company = WidgetManager.Translate(company);
417  groupName = group.GetCustomName() + " (" + string.Format(format, company, platoon, squad, character) + ")";
418  squadName.SetText(groupName);
419  }
420 
421  if (!group.GetCustomDescription().IsEmpty())
422  description.SetText(group.GetCustomDescription());
423  else
424  description.SetText(string.Empty);
425 
426  CheckLeaderOptions();
427 
428  frequency.SetText(""+group.GetRadioFrequency()*0.001 + " #AR-VON_FrequencyUnits_MHz");
429 
430  Widget children = playerList.GetChildren();
431  while (children)
432  {
433  playerList.RemoveChild(children);
434  children = playerList.GetChildren();
435  }
436 
437  children = leaderList.GetChildren();
438  while (children)
439  {
440  leaderList.RemoveChild(children);
441  children = leaderList.GetChildren();
442  }
443 
444  array<int> playerIDs = group.GetPlayerIDs();
445  Widget playerTile;
446 
447  int leaderID = group.GetLeaderID();
448  if (leaderID >= 0)
449  {
450  playerTile = Widget.Cast(GetGame().GetWorkspace().CreateWidgets(m_textLayout, leaderList));
451  SetupPlayerTile(playerTile, leaderID);
452  }
453 
454  foreach (int playerID : playerIDs)
455  {
456  if (playerID == leaderID)
457  continue;
458 
459  playerTile = Widget.Cast(GetGame().GetWorkspace().CreateWidgets(m_textLayout, playerList));
460  SetupPlayerTile(playerTile, playerID);
461  }
462 
463  ShowAIsInGroup();
464 
465  SetupJoinGroupButton();
466 
467  GetGame().GetWorkspace().SetFocusedWidget(GetRootWidget());
468  }
469 
470  //------------------------------------------------------------------------------------------------
471  void SetupJoinGroupButton()
472  {
473  SCR_PlayerControllerGroupComponent playerGroupController = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
474  if (!playerGroupController)
475  return;
476 
477  SCR_AIGroup group;
478  if (playerGroupController.GetSelectedGroupID() == -1)
479  {
480  group = m_GroupManager.FindGroup(m_iGroupID);
481  }
482  else
483  {
484  group = m_GroupManager.FindGroup(playerGroupController.GetSelectedGroupID());
485  }
486 
487  if (!group)
488  return;
489 
490  m_JoinGroupButton.m_OnActivated.Clear();
491 
492  if (group.IsPrivate())
493  {
494  m_JoinGroupButton.SetLabel(REQUEST_JOIN_GROUP);
495  m_JoinGroupButton.m_OnActivated.Insert(SCR_GroupSubMenu.RequestJoinPrivateGroup);
496  }
497  else
498  {
499  m_JoinGroupButton.SetLabel(JOIN_GROUP);
500  m_JoinGroupButton.m_OnActivated.Insert(SCR_GroupSubMenu.JoinSelectedGroup);
501  }
502 
503  array<int> denied = {};
504  group.GetDeniedRequesters(denied);
505  array<int> requesters = {};
506  group.GetRequesterIDs(requesters);
507 
508  bool requesterDenied = denied.Contains(playerGroupController.GetPlayerID());
509  bool requestSent = requesters.Contains(playerGroupController.GetPlayerID());
510 
511  if (
512  requesterDenied ||
513  requestSent ||
514  !m_GroupManager.FindGroup(m_iGroupID) ||
515  !playerGroupController.CanPlayerJoinGroup( SCR_PlayerController.GetLocalPlayerId() ,m_GroupManager.FindGroup(m_iGroupID)))
516  m_JoinGroupButton.SetEnabled(false);
517  else
518  m_JoinGroupButton.SetEnabled(true);
519  }
520 
521  //------------------------------------------------------------------------------------------------
522  //TODO: setup should be taken care of by the player tile component
523  void SetupPlayerTile(Widget playerTile, int playerID)
524  {
525  PlayerManager playerManager = GetGame().GetPlayerManager();
526  if (!m_GroupFaction || !m_GroupManager || !playerManager)
527  return;
528 
529  SCR_AIGroup group = m_GroupManager.FindGroup(m_iGroupID);
530  if (!group)
531  return;
532 
533  SCR_GadgetManagerComponent gadgetManager;
534  TextWidget playerName, playerFrequency;
535  ImageWidget taskIcon, muteIcon, background, loadoutIcon;
536  ButtonWidget playerButton;
537  SCR_BaseTaskExecutor taskExecutor;
538  SCR_BasePlayerLoadout playerLoadout;
539  Resource res;
540  IEntityComponentSource source;
541  BaseContainer container;
543  set<int> frequencies = new set<int>();
544  playerName = TextWidget.Cast(playerTile.FindAnyWidget("PlayerName"));
545  playerFrequency = TextWidget.Cast(playerTile.FindAnyWidget("Frequency"));
546  taskIcon = ImageWidget.Cast(playerTile.FindAnyWidget("TaskIcon"));
547  muteIcon = ImageWidget.Cast(playerTile.FindAnyWidget("MuteIcon"));
548  background = ImageWidget.Cast(playerTile.FindAnyWidget("Background"));
549  loadoutIcon = ImageWidget.Cast(playerTile.FindAnyWidget("LoadoutIcon"));
550 
551  playerButton = ButtonWidget.Cast(playerTile.FindAnyWidget("PlayerButton"));
552  if (!playerButton)
553  return;
554 
555  m_PlayerTileComponent = SCR_PlayerTileButtonComponent.Cast(playerButton.FindHandler(SCR_PlayerTileButtonComponent));
556  m_PlayerTileComponent.SetTilePlayerID(playerID);
557 
558  SetupOptionsCombo(playerTile);
559 
560  playerName.SetText(GetGame().GetPlayerManager().GetPlayerName(playerID));
561 
562  ChimeraCharacter controlledEntity = ChimeraCharacter.Cast(playerManager.GetPlayerControlledEntity(playerID));
563  if (controlledEntity)
564  {
565  gadgetManager = SCR_GadgetManagerComponent.Cast(controlledEntity.FindComponent(SCR_GadgetManagerComponent));
566  SCR_Global.GetFrequencies(gadgetManager, frequencies);
567  if (!frequencies.IsEmpty())
568  {
569  playerFrequency.SetText(SCR_FormatHelper.FormatFrequencies(frequencies));
570  background.SetOpacity(0.85);
571  }
572  }
573 
574  if (playerID == GetGame().GetPlayerController().GetPlayerId())
575  playerName.SetColor(m_PlayerNameSelfColor);
576 
577  //check for task and adjust the icon visibility
578  taskExecutor = SCR_BaseTaskExecutor.FindTaskExecutorByID(playerID);
579  SCR_BaseTask task;
580  if (taskExecutor)
581  task = taskExecutor.GetAssignedTask();
582 
583  if (m_BaseTaskManager && task)
584  {
585  taskIcon.SetOpacity(1);
586  RichTextWidget taskName = RichTextWidget.Cast(playerTile.FindAnyWidget("TaskName"));
587  if (taskName)
588  {
589  taskName.SetOpacity(1);
590  task.SetTitleWidgetText(taskName, task.GetTaskListTaskTitle());
591  }
592  }
593 
594  //set the state of mute
595  if (muteIcon && GetGame().GetPlayerController().GetPlayerMutedState(playerID) == PermissionState.DISALLOWED)
596  {
597  muteIcon.SetColor(m_PlayerNameSelfColor);
598  muteIcon.LoadImageFromSet(0, m_sIconsImageSet, "sound-off");
599  }
600 
601  //look for loadout and set the appropriate icon
602  if (loadoutIcon)
603  {
604  SCR_LoadoutManager loadoutManager = GetGame().GetLoadoutManager();
605  if (loadoutManager)
606  playerLoadout = loadoutManager.GetPlayerLoadout(playerID);
607 
608  if (playerLoadout)
609  {
610  res = Resource.Load(playerLoadout.GetLoadoutResource());
611  source = SCR_BaseContainerTools.FindComponentSource(res, "SCR_EditableCharacterComponent");
612  if (source)
613  {
614  container = source.GetObject("m_UIInfo");
615  info = SCR_EditableEntityUIInfo.Cast(BaseContainerTools.CreateInstanceFromContainer(container));
616  info.SetIconTo(loadoutIcon);
617  }
618  }
619 
620  //set leader icon if given player is a leader
621  if (group.IsPlayerLeader(playerID))
622  {
623  m_LeaderInfo.SetIconTo(loadoutIcon);
624  loadoutIcon.SetColor(m_PlayerNameSelfColor);
625  }
626 
627  //set badge color
628  Widget badge = playerTile.FindAnyWidget("PlayerBadge");
629  if (badge)
630  {
631  Color badgeColor = m_GroupFaction.GetFactionColor();
632  if (group.IsPlayerLeader(playerID))
633  badgeColor = (m_PlayerNameSelfColor);
634 
635  SetBadgeColor(badge, badgeColor);
636  }
637  }
638 
639  m_PlayerTileComponent.GetOnTileFocus().Insert(OnPlayerTileFocus);
640  m_PlayerTileComponent.GetOnTileFocusLost().Insert(OnPlayerTileFocusLost);
641 
642  m_aPlayerComponentsList.Insert(m_PlayerTileComponent);
643  }
644 
645  //------------------------------------------------------------------------------------------------
646  protected void OnPlayerTileFocus(int id)
647  {
648  if (m_OnPlayerTileFocus)
649  m_OnPlayerTileFocus.Invoke(id);
650 
651  DisableConfirmButton();
652  }
653 
654  //------------------------------------------------------------------------------------------------
655  protected void OnPlayerTileFocusLost(int id)
656  {
657  if (m_OnPlayerTileFocusLost)
658  m_OnPlayerTileFocusLost.Invoke(id);
659 
660  EnableConfirmButton();
661  }
662 
663  //------------------------------------------------------------------------------------------------
664  void SetGroupInfoColor(Color groupColor)
665  {
666  ImageWidget frequencyImage = ImageWidget.Cast(GetRootWidget().FindAnyWidget("FrequencyImage"));
667  ImageWidget playerIcon = ImageWidget.Cast(GetRootWidget().FindAnyWidget("PlayerIcon"));
668  TextWidget callsign = TextWidget.Cast(GetRootWidget().FindAnyWidget("Callsign"));
669  TextWidget frequency = TextWidget.Cast(GetRootWidget().FindAnyWidget("Frequency"));
670  TextWidget playerCount = TextWidget.Cast(GetRootWidget().FindAnyWidget("PlayerCount"));
671  if (!frequencyImage || !playerIcon || !callsign || !frequency || !playerCount)
672  return;
673 
674  frequencyImage.SetColor(groupColor);
675  playerIcon.SetColor(groupColor);
676  callsign.SetColor(groupColor);
677  frequency.SetColor(groupColor);
678  playerCount.SetColor(groupColor);
679  }
680 
681  //------------------------------------------------------------------------------------------------
682  int GetGroupID()
683  {
684  return m_iGroupID;
685  }
686 
687  //------------------------------------------------------------------------------------------------
688  override bool OnFocus(Widget w, int x, int y)
689  {
690  super.OnFocus(w, x, y);
691  if (m_GroupComponent.GetSelectedGroupID() == -1)
692  m_GroupComponent.SetSelectedGroupID(m_iGroupID);
693  EInputDeviceType deviceType = GetGame().GetInputManager().GetLastUsedInputDevice();
694  if (deviceType == EInputDeviceType.GAMEPAD || deviceType == EInputDeviceType.KEYBOARD)
695  {
696  RefreshPlayers();
697  m_GroupComponent.SetSelectedGroupID(m_iGroupID);
698  }
699  return false;
700  }
701 
702  //------------------------------------------------------------------------------------------------
703  void SetGroupID(int id)
704  {
705  m_iGroupID = id;
706  }
707 
708  //------------------------------------------------------------------------------------------------
709  Faction GetGroupFaction()
710  {
711  return m_GroupFaction;
712  }
713 
714  //------------------------------------------------------------------------------------------------
715  void SetGroupFaction(Faction groupFaction)
716  {
717  m_GroupFaction = groupFaction;
718  }
719 
720  //------------------------------------------------------------------------------------------------
721  void SetJoinGroupButton(SCR_InputButtonComponent joinGroupButton)
722  {
723  m_JoinGroupButton = joinGroupButton;
724  }
725 
726  //------------------------------------------------------------------------------------------------
727  void SetupOptionsCombo(Widget playerTile)
728  {
729  ButtonWidget playerOptionsButton = ButtonWidget.Cast(playerTile.FindAnyWidget("PlayerOptions"));
730  if (!playerOptionsButton)
731  return;
732 
733  SCR_ComboBoxComponent playerOptionsCombo = SCR_ComboBoxComponent.Cast(playerOptionsButton.FindHandler(SCR_ComboBoxComponent));
734  if (!playerOptionsCombo)
735  return;
736 
737  m_PlayerTileComponent.SetOptionsComboBoxComponent(playerOptionsCombo);
738 
739  int playerID = GetGame().GetPlayerController().GetPlayerId();
740  SCR_AIGroup group = m_GroupManager.GetPlayerGroup(playerID);
741 
742  if (group && m_iGroupID != group.GetGroupID() && m_PlayerTileComponent.GetTilePlayerID() != -1)
743  m_PlayerTileComponent.GetOptionsComboComponent().AddItem(OPTIONS_COMBO_INVITE);
744 
745 
746  group = m_GroupManager.FindGroup(m_iGroupID);
747  if (!group)
748  return;
749 
750  if (group.IsPlayerLeader(playerID) && playerID != m_PlayerTileComponent.GetTilePlayerID() && m_PlayerTileComponent.GetTilePlayerID() != -1)
751  {
752  m_PlayerTileComponent.GetOptionsComboComponent().AddItem(OPTIONS_COMBO_KICK);
753  m_PlayerTileComponent.GetOptionsComboComponent().AddItem(OPTIONS_COMBO_PROMOTE);
754  }
755 
756  if (m_PlayerTileComponent.GetOptionsComboComponent().GetNumItems() == 0)
757  m_PlayerTileComponent.SetOpacity(0.3);
758 
759  m_PlayerTileComponent.GetOptionsComboComponent().m_OnOpened.Insert(DisableConfirmButton);
760  m_PlayerTileComponent.GetOptionsComboComponent().m_OnClosed.Insert(EnableConfirmButton);
761 
762  m_PlayerTileComponent.GetOptionsComboComponent().m_OnChanged.Insert(OnComboBoxConfirm);
763  }
764 
765  //------------------------------------------------------------------------------------------------
766  protected void OnComboBoxConfirm(SCR_ComboBoxComponent combo, int index)
767  {
768  SCR_PlayerControllerGroupComponent playerGroupController = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
769 
770  if (!playerGroupController)
771  return;
772 
773  int playerID;
774  for (int i = m_aPlayerComponentsList.Count()-1; i >= 0; i--)
775  {
776  if (m_aPlayerComponentsList[i].GetOptionsComboComponent() == combo)
777  playerID = m_aPlayerComponentsList[i].GetTilePlayerID();
778  }
779 
780  switch (combo.GetItemName(index))
781  {
782  case OPTIONS_COMBO_INVITE:
783  {
784  playerGroupController.InvitePlayer(playerID);
785  break;
786  }
787  case OPTIONS_COMBO_KICK:
788  {
789  playerGroupController.RequestKickPlayer(playerID);
790  break;
791  }
792  case OPTIONS_COMBO_PROMOTE:
793  {
794  playerGroupController.RequestPromoteLeader(playerID);
795  break;
796  }
797  }
798 
799  combo.SetCurrentItem(-1, false, false);
800  }
801 
802  //------------------------------------------------------------------------------------------------
803  protected string GetGroupNameFormated(SCR_AIGroup group)
804  {
805  string groupName = group.GetCustomNameWithOriginal();
806  if (groupName.IsEmpty())
807  {
808  string company, platoon, squad, character, format;
809  group.GetCallsigns(company, platoon, squad, character, format);
810  groupName = string.Format(format, company, platoon, squad, character);
811  }
812  return groupName;
813  }
814 
815  //------------------------------------------------------------------------------------------------
816  protected void CheckLeaderOptions()
817  {
818  SCR_AIGroup group = m_GroupManager.FindGroup(m_iGroupID);
819  if (!group)
820  return;
821 
822  Widget privateChecker = m_ParentSubMenu.GetRootWidget().FindAnyWidget("PrivateCheckLayout");
823  if (!privateChecker)
824  return;
825 
826  Widget privateCheckerButton = m_ParentSubMenu.GetRootWidget().FindAnyWidget("PrivateChecker");
827  if (!privateCheckerButton)
828  return;
829 
830  SCR_ButtonCheckerComponent checkerComp = SCR_ButtonCheckerComponent.Cast(privateCheckerButton.FindHandler(SCR_ButtonCheckerComponent));
831  if (!checkerComp)
832  return;
833 
834  ButtonWidget nameChangeButton = ButtonWidget.Cast(m_ParentSubMenu.GetRootWidget().FindAnyWidget("ChangeNameButton"));
835  if (!nameChangeButton)
836  return;
837 
838  if (!group.IsPlayerLeader(GetGame().GetPlayerController().GetPlayerId()) || !m_GroupManager.CanPlayersChangeAttributes())
839  {
840  privateChecker.SetOpacity(0);
841  privateChecker.SetEnabled(false);
842  nameChangeButton.SetOpacity(0);
843  nameChangeButton.SetEnabled(false);
844  return;
845  }
846 
847  checkerComp.SetToggled(group.IsPrivate());
848  if (group.IsPrivate())
849  checkerComp.SetText(PRIVATE_GROUP);
850  else
851  checkerComp.SetText(PUBLIC_GROUP);
852 
853  privateChecker.SetOpacity(1);
854  privateChecker.SetEnabled(true);
855  nameChangeButton.SetOpacity(1);
856  nameChangeButton.SetEnabled(true);
857  }
858 
859  //------------------------------------------------------------------------------------------------
860  static ScriptInvoker GetOnGroupTileClicked()
861  {
862  return s_OnGroupButtonClicked;
863  }
864 
865  //------------------------------------------------------------------------------------------------
866  static ScriptInvokerInt GetOnPlayerTileFocus()
867  {
868  if (!m_OnPlayerTileFocus)
869  m_OnPlayerTileFocus = new ScriptInvokerInt();
870 
871  return m_OnPlayerTileFocus;
872  }
873 
874  //------------------------------------------------------------------------------------------------
875  static ScriptInvokerInt GetOnPlayerTileFocusLost()
876  {
877  if (!m_OnPlayerTileFocusLost)
878  m_OnPlayerTileFocusLost = new ScriptInvokerInt();
879 
880  return m_OnPlayerTileFocusLost;
881  }
882 
883  //------------------------------------------------------------------------------------------------
884  void EnableConfirmButton()
885  {
886  SetConfirmButtonStatus(true);
887  }
888 
889  //------------------------------------------------------------------------------------------------
890  void DisableConfirmButton()
891  {
892  InputManager inputManager = GetGame().GetInputManager();
893  if (inputManager && inputManager.GetLastUsedInputDevice() == EInputDeviceType.GAMEPAD)
894  SetConfirmButtonStatus(false);
895  }
896 
897  //------------------------------------------------------------------------------------------------
898  void SetConfirmButtonStatus(bool status)
899  {
900 // SCR_RespawnSubMenuBase subMenu = SCR_RespawnSubMenuBase.Cast(m_ParentSubMenu);
901 // if (!subMenu)
902 // return;
903 
904 // subMenu.SetConfirmButtonEnabled(status);
905  }
906 
907  //------------------------------------------------------------------------------------------------
908  void SetBadgeColor(Widget badge, Color color)
909  {
910  if (!badge)
911  return;
912 
913  ImageWidget badgeTop, badgeMiddle, badgeBottom;
914 
915  badgeTop = ImageWidget.Cast(badge.FindAnyWidget("BadgeTop"));
916  badgeMiddle = ImageWidget.Cast(badge.FindAnyWidget("BadgeMiddle"));
917  badgeBottom = ImageWidget.Cast(badge.FindAnyWidget("BadgeBottom"));
918 
919  if (!badgeMiddle || !badgeTop || !badgeBottom)
920  return;
921 
922  badgeTop.SetColor(color);
923  badgeMiddle.SetColor(color);
924  badgeBottom.SetColor(color);
925  }
926 
927  //------------------------------------------------------------------------------------------------
928  void ShowAIsInGroup()
929  {
930  SCR_AIGroup group = m_GroupManager.FindGroup(m_iGroupID);
931  if (!group)
932  return;
933 
934  VerticalLayoutWidget playerList = VerticalLayoutWidget.Cast(m_ParentSubMenu.GetRootWidget().FindAnyWidget("PlayerList"));
935  if (!playerList)
936  return;
937 
938  Widget playerTile;
939  TextWidget playerName;
940  ButtonWidget playerButton;
941 
942  SCR_AIGroup slaveGroup = group.GetSlave();
943  if (!slaveGroup)
944  return;
945 
946  array<SCR_ChimeraCharacter> aiMembers = slaveGroup.GetAIMembers();
947  SCR_CharacterIdentityComponent identityComponent;
948 
949  foreach (SCR_ChimeraCharacter AIcharacter : aiMembers)
950  {
951  playerTile = Widget.Cast(GetGame().GetWorkspace().CreateWidgets(m_textLayout, playerList));
952  playerName = TextWidget.Cast(playerTile.FindAnyWidget("PlayerName"));
953 
954  identityComponent = SCR_CharacterIdentityComponent .Cast(AIcharacter.FindComponent(SCR_CharacterIdentityComponent));
955  if (!identityComponent)
956  return;
957  string name;
958  array<string> nameParams = {};
959  identityComponent.GetFormattedFullName(name, nameParams);
960  playerName.SetTextFormat(name, nameParams[0], nameParams[1], nameParams[2]);
961 
962  playerButton = ButtonWidget.Cast(playerTile.FindAnyWidget("PlayerButton"));
963  if (!playerButton)
964  return;
965 
966  m_PlayerTileComponent = SCR_PlayerTileButtonComponent.Cast(playerButton.FindHandler(SCR_PlayerTileButtonComponent));
967  if (!m_PlayerTileComponent)
968  return;
969 
970  m_PlayerTileComponent.SetTilePlayerID(-1);
971 
972  m_PlayerTileComponent.SetCharacter(AIcharacter);
973 
974  //set badge color
975  Widget badge = playerTile.FindAnyWidget("PlayerBadge");
976 
977  if (badge)
978  SetBadgeColor(badge, m_GroupFaction.GetFactionColor());
979 
980  SetupOptionsCombo(playerTile);
981  }
982  }
983 };
SCR_ComboBoxComponent
Definition: SCR_ComboBoxComponent.c:1
SCR_PlayerController
Definition: SCR_PlayerController.c:31
SCR_GroupFlagImageComponent
Definition: SCR_GroupFlagImageComponent.c:1
SCR_FormatHelper
Definition: SCR_FormatHelper.c:1
ScriptInvokerInt
ScriptInvokerBase< ScriptInvokerIntMethod > ScriptInvokerInt
Definition: SCR_ScriptInvokerHelper.c:24
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_GadgetManagerComponent
Definition: SCR_GadgetManagerComponent.c:138
SCR_EditableEntityUIInfo
Definition: SCR_EditableEntityUIInfo.c:2
PermissionState
PermissionState
Definition: PermissionState.c:12
SCR_LoadoutManager
void SCR_LoadoutManager(IEntitySource src, IEntity parent)
Definition: SCR_LoadoutManager.c:500
SCR_BaseTask
A base class for tasks.
Definition: SCR_BaseTask.c:8
GetPlayerController
proto external PlayerController GetPlayerController()
Definition: SCR_PlayerDeployMenuHandlerComponent.c:307
GetRootWidget
Widget GetRootWidget()
Definition: SCR_UITaskManagerComponent.c:160
ENotification
ENotification
Definition: ENotification.c:4
SCR_GroupSubMenu
Definition: SCR_GroupSubMenu.c:1
Attribute
typedef Attribute
Post-process effect of scripted camera.
GetTaskManager
SCR_BaseTaskManager GetTaskManager()
Definition: SCR_BaseTaskManager.c:7
SCR_BaseTaskManager
Definition: SCR_BaseTaskManager.c:25
SCR_ButtonBaseComponent
Base class for any button, regardless its own content.
Definition: SCR_ButtonBaseComponent.c:3
SCR_PlayerTileButtonComponent
Definition: SCR_GroupTileButton.c:1
m_iPlayerId
protected int m_iPlayerId
Definition: SCR_CallsignCharacterComponent.c:14
GetPlayerMutedState
proto external PermissionState GetPlayerMutedState(int playerId)
SCR_UIInfo
Definition: SCR_UIInfo.c:7
m_iGroupID
SCR_PlayerControllerGroupComponentClass m_iGroupID
SCR_BaseContainerTools
Definition: SCR_BaseContainerTools.c:3
Faction
Definition: Faction.c:12
SCR_GroupsManagerComponent
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_GroupsManagerComponent.c:1320
SCR_BaseTaskExecutor
Definition: SCR_BaseTaskExecutor.c:7
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
SCR_ButtonCheckerComponent
Definition: SCR_ButtonCheckerComponent.c:2
SCR_Global
Definition: Functions.c:6
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition: ChimeraMenuBase.c:3
SCR_AIGroup
Definition: SCR_AIGroup.c:68
SCR_ScriptedWidgetComponent
Definition: SCR_ScriptedWidgetComponent.c:7
SCR_BasePlayerLoadout
Definition: SCR_BasePlayerLoadout.c:2
PlayerManager
Definition: PlayerManager.c:12
SCR_Faction
Definition: SCR_Faction.c:6
SCR_GroupTileButton
Definition: SCR_GroupTileButton.c:106
SCR_InputButtonComponent
Definition: SCR_InputButtonComponent.c:1
GetPlayerId
proto external int GetPlayerId()
Definition: SCR_SpawnRequestComponent.c:39