Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
GroupSettingsDialogUI.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
3 {
4 
5  protected SCR_EditBoxComponent m_Description;
6  protected SCR_ComboBoxComponent m_GroupStatus;
7  protected SCR_EditBoxComponent m_GroupName;
8  protected SCR_EditBoxComponent m_GroupDescription;
9 
10  protected ref SCR_ScriptPlatformRequestCallback m_CallbackGetPrivilege;
11 
12  protected SCR_PlayerControllerGroupComponent m_PlayerComponent;
13  protected SCR_GroupsManagerComponent m_GroupsManager;
14  protected SCR_AIGroup m_PlayerGroup;
15 
16  protected bool m_bHasPrivilege;
17 
18  //------------------------------------------------------------------------------------------------
19  override void OnMenuOpen()
20  {
21  super.OnMenuOpen();
22 
23  m_PlayerComponent = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
24  if (!m_PlayerComponent)
25  return;
26 
27  if (m_PlayerComponent.GetSelectedGroupID() == -1)
28  {
29  Close();
30  return;
31  }
32 
33  m_CallbackGetPrivilege = new SCR_ScriptPlatformRequestCallback();
34  m_CallbackGetPrivilege.m_OnResult.Insert(OnPrivilegeCallback);
35  GetGame().GetPlatformService().GetPrivilegeAsync(UserPrivilege.USER_GEN_CONTENT, m_CallbackGetPrivilege);
36  }
37 
38  void OnPrivilegeCallback(UserPrivilege privilege, UserPrivilegeResult result)
39  {
40 
41  m_GroupsManager = SCR_GroupsManagerComponent.GetInstance();
42  if (!m_GroupsManager)
43  return;
44 
45  m_PlayerGroup = m_GroupsManager.FindGroup(m_PlayerComponent.GetGroupID());
46  if (!m_PlayerGroup)
47  return;
48 
49  Widget w = GetRootWidget();
50  if (!w)
51  return;
52 
53  m_GroupStatus = SCR_ComboBoxComponent.GetComboBoxComponent("Type", w);
54  if (!m_GroupStatus)
55  return;
56 
57  m_GroupName = SCR_EditBoxComponent.GetEditBoxComponent("Name", w);
58  if (!m_GroupName)
59  return;
60 
61  m_GroupDescription = SCR_EditBoxComponent.GetEditBoxComponent("Description", w);
62  if (!m_GroupDescription)
63  return;
64 
65  if (result == UserPrivilegeResult.ALLOWED)
66  {
67  m_GroupName.SetEnabled(true);
68  m_GroupName.SetValue(m_PlayerGroup.GetCustomName());
69 
70  m_GroupDescription.SetEnabled(true);
71  m_GroupDescription.SetValue(m_PlayerGroup.GetCustomDescription());
72  m_bHasPrivilege = true;
73  }
74  else
75  {
76  m_GroupName.SetEnabled(false);
77  m_GroupName.SetValue(WidgetManager.Translate("#AR-UserActionUnavailable"));
78  m_GroupDescription.SetEnabled(false);
79  m_GroupDescription.SetValue(WidgetManager.Translate("#AR-UserActionUnavailable"));
80  m_bHasPrivilege = false;
81  }
82 
83  SetupGroupStatusCombo();
84  }
85 
86  //------------------------------------------------------------------------------------------------
87  override void OnMenuUpdate(float tDelta)
88  {
89  super.OnMenuUpdate(tDelta);
90 
91  GetGame().GetInputManager().ActivateContext("InteractableDialogContext");
92  }
93 
94  //------------------------------------------------------------------------------------------------
95  override protected void OnConfirm()
96  {
97  SCR_PlayerControllerGroupComponent groupController = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
98  if (!groupController)
99  return;
100 
101  if (m_bHasPrivilege)
102  {
103  string outputName;
104  string outputDesc;
105  GetGame().GetProfanityFilter().ReplaceProfanities(m_GroupDescription.GetValue(), outputDesc);
106  GetGame().GetProfanityFilter().ReplaceProfanities(m_GroupName.GetValue(), outputName);
107 
108  int groupID = m_PlayerGroup.GetGroupID();
109  groupController.RequestSetCustomGroupDescription(groupID, outputDesc);
110  groupController.RequestSetCustomGroupName(groupID, outputName);
111  }
112 
113  Close();
114  }
115 
116  //------------------------------------------------------------------------------------------------
117  protected void SetupGroupStatusCombo()
118  {
119  m_GroupStatus.AddItem("#AR-Player_Groups_Public");
120  m_GroupStatus.AddItem("#AR-Player_Groups_Private");
121 
122  m_GroupStatus.SetCurrentItem(m_PlayerGroup.IsPrivate());
123  m_GroupStatus.m_OnChanged.Insert(OnStatusChanged);
124 
125  }
126 
127  //------------------------------------------------------------------------------------------------
128  void OnStatusChanged(SCR_ComboBoxComponent combo, int index)
129  {
130  if (!m_PlayerComponent)
131  return;
132 
133  m_PlayerComponent.RequestPrivateGroupChange(m_PlayerComponent.GetPlayerID() , index);
134  }
135 };
GroupSettingsDialogUI
Definition: GroupSettingsDialogUI.c:2
SCR_ComboBoxComponent
Definition: SCR_ComboBoxComponent.c:1
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_ScriptPlatformRequestCallback
Definition: SCR_OnlineServiceWorkshop.c:2
GetRootWidget
Widget GetRootWidget()
Definition: SCR_UITaskManagerComponent.c:160
DialogUI
Definition: DialogUI.c:1
SCR_GroupsManagerComponent
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_GroupsManagerComponent.c:1320
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
SCR_AIGroup
Definition: SCR_AIGroup.c:68
SCR_EditBoxComponent
Definition: SCR_EditBoxComponent.c:8