Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
GroupSettingsDialogUI.c
Go to the documentation of this file.
1
//------------------------------------------------------------------------------------------------
2
class
GroupSettingsDialogUI
:
DialogUI
3
{
4
protected
SCR_ComboBoxComponent
m_GroupLeader
;
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
protected
SCR_PlayerControllerGroupComponent
m_PlayerComponent
;
10
protected
SCR_GroupsManagerComponent
m_GroupsManager
;
11
protected
SCR_AIGroup
m_PlayerGroup
;
12
protected
bool
m_bHasPrivilege
;
13
14
protected
static
ref
SCR_ScriptPlatformRequestCallback
m_CallbackGetPrivilege
;
15
16
//------------------------------------------------------------------------------------------------
17
override
void
OnMenuOpen
()
18
{
19
super.OnMenuOpen();
20
21
m_PlayerComponent
= SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
22
if
(!
m_PlayerComponent
)
23
return
;
24
25
if
(
m_PlayerComponent
.GetSelectedGroupID() == -1)
26
{
27
Close
();
28
return
;
29
}
30
if
(!
m_CallbackGetPrivilege
)
31
m_CallbackGetPrivilege
=
new
SCR_ScriptPlatformRequestCallback
();
32
33
m_CallbackGetPrivilege
.m_OnResult.Insert(
OnPrivilegeCallback
);
34
SocialComponent.RequestSocialPrivilege(
EUserInteraction
.UserGeneratedContent,
m_CallbackGetPrivilege
);
35
}
36
37
//------------------------------------------------------------------------------------------------
38
override
void
OnMenuClose
()
39
{
40
super.OnMenuClose();
41
42
if
(
m_CallbackGetPrivilege
)
43
m_CallbackGetPrivilege
.m_OnResult.Remove(
OnPrivilegeCallback
);
44
45
if
(
m_PlayerGroup
)
46
{
47
m_PlayerGroup
.GetOnPlayerAdded().Remove(
SetupGroupLeaderCombo
);
48
m_PlayerGroup
.GetOnPlayerRemoved().Remove(
SetupGroupLeaderCombo
);
49
m_PlayerGroup
.GetOnPlayerLeaderChanged().Remove(
OnGroupLeaderChanged
);
50
}
51
}
52
53
//------------------------------------------------------------------------------------------------
54
void
OnPrivilegeCallback
(
UserPrivilege
privilege,
UserPrivilegeResult
result)
55
{
56
57
m_GroupsManager
=
SCR_GroupsManagerComponent
.GetInstance();
58
if
(!
m_GroupsManager
)
59
return
;
60
61
m_PlayerGroup
=
m_GroupsManager
.FindGroup(
m_PlayerComponent
.GetGroupID());
62
if
(!
m_PlayerGroup
)
63
return
;
64
65
m_PlayerGroup
.GetOnPlayerAdded().Insert(
SetupGroupLeaderCombo
);
66
m_PlayerGroup
.GetOnPlayerRemoved().Insert(
SetupGroupLeaderCombo
);
67
m_PlayerGroup
.GetOnPlayerLeaderChanged().Insert(
OnGroupLeaderChanged
);
68
69
Widget
w =
GetRootWidget
();
70
if
(!w)
71
return
;
72
73
m_GroupLeader
=
SCR_ComboBoxComponent
.GetComboBoxComponent(
"GroupLeader"
, w);
74
if
(!
m_GroupLeader
)
75
return
;
76
77
m_GroupStatus
=
SCR_ComboBoxComponent
.GetComboBoxComponent(
"Type"
, w);
78
if
(!
m_GroupStatus
)
79
return
;
80
81
m_GroupName
=
SCR_EditBoxComponent
.
GetEditBoxComponent
(
"Name"
, w);
82
if
(!
m_GroupName
)
83
return
;
84
85
m_GroupDescription
=
SCR_EditBoxComponent
.
GetEditBoxComponent
(
"Description"
, w);
86
if
(!
m_GroupDescription
)
87
return
;
88
89
if
(result ==
UserPrivilegeResult
.ALLOWED)
90
{
91
m_GroupName
.SetEnabled(
true
);
92
m_GroupName
.SetValue(
m_PlayerGroup
.GetCustomName());
93
94
m_GroupDescription
.SetEnabled(
true
);
95
m_GroupDescription
.SetValue(
m_PlayerGroup
.GetCustomDescription());
96
m_bHasPrivilege
=
true
;
97
}
98
else
99
{
100
m_GroupName
.SetEnabled(
false
);
101
m_GroupName
.SetValue(
WidgetManager
.Translate(
"#AR-UserActionUnavailable"
));
102
m_GroupDescription
.SetEnabled(
false
);
103
m_GroupDescription
.SetValue(
WidgetManager
.Translate(
"#AR-UserActionUnavailable"
));
104
m_bHasPrivilege
=
false
;
105
}
106
107
SetupGroupStatusCombo
();
108
SetupGroupLeaderCombo
();
109
}
110
111
//------------------------------------------------------------------------------------------------
112
override
void
OnMenuUpdate
(
float
tDelta)
113
{
114
super.OnMenuUpdate(tDelta);
115
116
GetGame
().GetInputManager().ActivateContext(
"InteractableDialogContext"
);
117
}
118
119
//------------------------------------------------------------------------------------------------
120
override
protected
void
OnConfirm
()
121
{
122
SCR_PlayerControllerGroupComponent groupController = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
123
if
(!groupController)
124
return
;
125
126
if
(
m_bHasPrivilege
)
127
{
128
int
newGroupLeaderId =
GetPlayerIdFromName
(
m_GroupLeader
.GetCurrentItem());
129
if
(newGroupLeaderId > 0 &&
m_PlayerGroup
.GetLeaderID() != newGroupLeaderId)
130
{
131
// Appoint a new group leader
132
groupController.SetGroupLeader(newGroupLeaderId);
133
}
134
else
135
{
136
// Change name and description
137
int
groupID =
m_PlayerGroup
.GetGroupID();
138
139
groupController.RequestSetCustomGroupDescription(groupID,
m_GroupDescription
.GetValue());
140
groupController.RequestSetCustomGroupName(groupID,
m_GroupName
.GetValue());
141
}
142
}
143
144
Close
();
145
}
146
147
//------------------------------------------------------------------------------------------------
148
protected
void
SetupGroupStatusCombo
()
149
{
150
m_GroupStatus
.AddItem(
"#AR-Player_Groups_Public"
);
151
m_GroupStatus
.AddItem(
"#AR-Player_Groups_Private"
);
152
153
m_GroupStatus
.SetCurrentItem(
m_PlayerGroup
.IsPrivate());
154
m_GroupStatus
.m_OnChanged.Insert(
OnStatusChanged
);
155
156
if
(
m_PlayerGroup
)
157
m_GroupStatus
.SetEnabled(
m_PlayerGroup
.IsPrivacyChangeable());
158
}
159
160
//------------------------------------------------------------------------------------------------
161
void
OnStatusChanged
(
SCR_ComboBoxComponent
combo,
int
index
)
162
{
163
if
(!
m_PlayerComponent
)
164
return
;
165
166
m_PlayerComponent
.RequestPrivateGroupChange(
m_PlayerComponent
.GetPlayerID() ,
index
);
167
}
168
169
//------------------------------------------------------------------------------------------------
170
protected
void
SetupGroupLeaderCombo
()
171
{
172
if
(!
m_PlayerGroup
)
173
return
;
174
175
int
localPlayerId =
SCR_PlayerController
.
GetLocalPlayerId
();
176
if
(
m_PlayerGroup
.GetLeaderID() != localPlayerId)
177
{
178
m_GroupLeader
.SetEnabled(
false
);
179
return
;
180
}
181
182
int
selectedIndex;
183
m_GroupLeader
.ClearAll();
184
185
PlayerManager
playerManager =
GetGame
().GetPlayerManager();
186
array<int> playerIds =
m_PlayerGroup
.GetPlayerIDs();
187
188
// Populate the combo box with names of players in group
189
foreach
(
int
index
,
int
playerId : playerIds)
190
{
191
m_GroupLeader
.AddItem(playerManager.GetPlayerName(playerId));
192
193
if
(playerId == localPlayerId)
194
selectedIndex =
index
;
195
}
196
197
// Select current leader by default
198
m_GroupLeader
.SetCurrentItem(selectedIndex);
199
m_GroupLeader
.SetEnabled(
true
);
200
}
201
202
//------------------------------------------------------------------------------------------------
206
protected
void
OnGroupLeaderChanged
(
int
groupId,
int
playerId)
207
{
208
if
(groupId !=
m_PlayerGroup
.GetGroupID())
209
return
;
210
211
if
(
m_PlayerComponent
.GetPlayerID() == playerId)
212
return
;
213
214
m_PlayerGroup
.GetOnPlayerAdded().Remove(
SetupGroupLeaderCombo
);
215
m_PlayerGroup
.GetOnPlayerRemoved().Remove(
SetupGroupLeaderCombo
);
216
m_PlayerGroup
.GetOnPlayerLeaderChanged().Remove(
OnGroupLeaderChanged
);
217
218
Close
();
219
}
220
221
//------------------------------------------------------------------------------------------------
225
protected
int
GetPlayerIdFromName
(
string
name)
226
{
227
array<int> playerIds =
m_PlayerGroup
.GetPlayerIDs();
228
foreach
(
int
playerId : playerIds)
229
{
230
if
(
GetGame
().GetPlayerManager().GetPlayerName(playerId) == name)
231
return
playerId;
232
}
233
234
return
0;
235
}
236
237
};
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition
SCR_DestructionSynchronizationComponent.c:17
SCR_GroupsManagerComponent
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition
SCR_GroupsManagerComponent.c:1747
GetRootWidget
Widget GetRootWidget()
Definition
SCR_ModularButtonComponent.c:189
Close
proto native void Close()
Definition
SCR_WorkshopDialogs.c:77
UserPrivilege
UserPrivilege
Definition
UserPrivilege.c:8
UserPrivilegeResult
UserPrivilegeResult
Definition
UserPrivilegeResult.c:8
DialogUI
Definition
DialogUI.c:2
GroupSettingsDialogUI
Definition
GroupSettingsDialogUI.c:3
GroupSettingsDialogUI::OnPrivilegeCallback
void OnPrivilegeCallback(UserPrivilege privilege, UserPrivilegeResult result)
Definition
GroupSettingsDialogUI.c:54
GroupSettingsDialogUI::OnMenuUpdate
override void OnMenuUpdate(float tDelta)
Definition
GroupSettingsDialogUI.c:112
GroupSettingsDialogUI::m_CallbackGetPrivilege
static ref SCR_ScriptPlatformRequestCallback m_CallbackGetPrivilege
Definition
GroupSettingsDialogUI.c:14
GroupSettingsDialogUI::OnGroupLeaderChanged
void OnGroupLeaderChanged(int groupId, int playerId)
Definition
GroupSettingsDialogUI.c:206
GroupSettingsDialogUI::SetupGroupLeaderCombo
void SetupGroupLeaderCombo()
Definition
GroupSettingsDialogUI.c:170
GroupSettingsDialogUI::m_PlayerComponent
SCR_PlayerControllerGroupComponent m_PlayerComponent
Definition
GroupSettingsDialogUI.c:9
GroupSettingsDialogUI::m_GroupLeader
SCR_ComboBoxComponent m_GroupLeader
Definition
GroupSettingsDialogUI.c:4
GroupSettingsDialogUI::m_GroupsManager
SCR_GroupsManagerComponent m_GroupsManager
Definition
GroupSettingsDialogUI.c:10
GroupSettingsDialogUI::GetPlayerIdFromName
int GetPlayerIdFromName(string name)
Definition
GroupSettingsDialogUI.c:225
GroupSettingsDialogUI::OnMenuOpen
override void OnMenuOpen()
Definition
GroupSettingsDialogUI.c:17
GroupSettingsDialogUI::m_Description
SCR_EditBoxComponent m_Description
Definition
GroupSettingsDialogUI.c:5
GroupSettingsDialogUI::m_GroupDescription
SCR_EditBoxComponent m_GroupDescription
Definition
GroupSettingsDialogUI.c:8
GroupSettingsDialogUI::m_GroupStatus
SCR_ComboBoxComponent m_GroupStatus
Definition
GroupSettingsDialogUI.c:6
GroupSettingsDialogUI::m_GroupName
SCR_EditBoxComponent m_GroupName
Definition
GroupSettingsDialogUI.c:7
GroupSettingsDialogUI::m_bHasPrivilege
bool m_bHasPrivilege
Definition
GroupSettingsDialogUI.c:12
GroupSettingsDialogUI::OnStatusChanged
void OnStatusChanged(SCR_ComboBoxComponent combo, int index)
Definition
GroupSettingsDialogUI.c:161
GroupSettingsDialogUI::OnMenuClose
override void OnMenuClose()
Definition
GroupSettingsDialogUI.c:38
GroupSettingsDialogUI::OnConfirm
void OnConfirm()
Definition
GroupSettingsDialogUI.c:120
GroupSettingsDialogUI::SetupGroupStatusCombo
void SetupGroupStatusCombo()
Definition
GroupSettingsDialogUI.c:148
GroupSettingsDialogUI::m_PlayerGroup
SCR_AIGroup m_PlayerGroup
Definition
GroupSettingsDialogUI.c:11
PlayerManager
Definition
PlayerManager.c:13
SCR_AIGroup
Definition
SCR_AIGroup.c:75
SCR_ComboBoxComponent
Definition
SCR_ComboBoxComponent.c:2
SCR_EditBoxComponent
Definition
SCR_EditBoxComponent.c:9
SCR_EditBoxComponent::GetEditBoxComponent
static SCR_EditBoxComponent GetEditBoxComponent(string name, Widget parent, bool searchAllChildren=true)
Definition
SCR_EditBoxComponent.c:382
SCR_PlayerController
Definition
SCR_PlayerController.c:31
SCR_PlayerController::GetLocalPlayerId
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
Definition
SCR_PlayerController.c:481
SCR_ScriptPlatformRequestCallback
Definition
SCR_OnlineServiceWorkshop.c:3
Widget
Definition
Widget.c:13
WidgetManager
Definition
WidgetManager.c:16
EUserInteraction
EUserInteraction
Interaction type between two players.
Definition
EUserInteraction.c:14
scripts
Game
UI
Menu
GroupSettingsDialogUI.c
Generated by
1.17.0