Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
CreateGroupSettingsDialogUI.c
Go to the documentation of this file.
1
class
CreateGroupSettingsDialogUI
:
DialogUI
2
{
3
protected
Widget
m_RulesDescriptionSize
;
4
protected
SCR_EditBoxComponent
m_Description
;
5
protected
SCR_ComboBoxComponent
m_GroupStatus
;
6
protected
SCR_ComboBoxComponent
m_GroupRole
;
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
protected
SCR_Faction
m_LocalFaction
;
18
19
//------------------------------------------------------------------------------------------------
20
override
void
OnMenuOpen
()
21
{
22
super.OnMenuOpen();
23
24
m_LocalFaction
=
SCR_Faction
.Cast(
SCR_FactionManager
.SGetLocalPlayerFaction());
25
26
m_PlayerComponent
= SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
27
if
(!
m_PlayerComponent
)
28
return
;
29
30
m_CallbackGetPrivilege
=
new
SCR_ScriptPlatformRequestCallback
();
31
m_CallbackGetPrivilege
.m_OnResult.Insert(
OnPrivilegeCallback
);
32
SocialComponent.RequestSocialPrivilege(
EUserInteraction
.UserGeneratedContent,
m_CallbackGetPrivilege
);
33
}
34
35
//------------------------------------------------------------------------------------------------
36
protected
void
OnPrivilegeCallback
(
UserPrivilege
privilege,
UserPrivilegeResult
result)
37
{
38
m_GroupsManager
=
SCR_GroupsManagerComponent
.GetInstance();
39
if
(!
m_GroupsManager
)
40
return
;
41
42
Widget
w =
GetRootWidget
();
43
if
(!w)
44
return
;
45
46
m_RulesDescriptionSize
= w.FindAnyWidget(
"RulesDescriptionSize"
);
47
if
(!
m_RulesDescriptionSize
)
48
return
;
49
50
m_RulesDescriptionSize
.SetVisible(!SCR_FactionCommanderPlayerComponent.IsLocalPlayerCommander());
51
52
m_GroupStatus
=
SCR_ComboBoxComponent
.GetComboBoxComponent(
"Type"
, w);
53
if
(!
m_GroupStatus
)
54
return
;
55
56
m_GroupRole
=
SCR_ComboBoxComponent
.GetComboBoxComponent(
"SquadRole"
, w);
57
if
(!
m_GroupRole
)
58
return
;
59
60
m_GroupName
=
SCR_EditBoxComponent
.
GetEditBoxComponent
(
"Name"
, w);
61
if
(!
m_GroupName
)
62
return
;
63
64
m_GroupDescription
=
SCR_EditBoxComponent
.
GetEditBoxComponent
(
"Description"
, w);
65
if
(!
m_GroupDescription
)
66
return
;
67
68
m_bHasPrivilege
= result ==
UserPrivilegeResult
.ALLOWED;
69
bool
canEdit =
m_bHasPrivilege
&& !SCR_FactionCommanderPlayerComponent.IsLocalPlayerCommander();
70
string
unavailable =
WidgetManager
.Translate(
"#AR-UserActionUnavailable"
);
// Translate is used because to change language the CreateGroupSettingsDialogUI has to be closed and then opened so it will renew.
71
72
m_GroupName
.SetEnabled(canEdit);
73
m_GroupDescription
.SetEnabled(canEdit);
74
75
if
(canEdit)
76
{
77
m_GroupName
.SetValue(
""
);
78
m_GroupDescription
.SetValue(
""
);
79
}
80
else
81
{
82
m_GroupName
.SetValue(unavailable);
83
m_GroupDescription
.SetValue(unavailable);
84
}
85
86
SetupGroupStatusCombo
();
87
SetupGroupRoleCombo
();
88
UpdateConfirmButton
();
89
}
90
91
//------------------------------------------------------------------------------------------------
92
override
void
OnMenuUpdate
(
float
tDelta)
93
{
94
super.OnMenuUpdate(tDelta);
95
96
GetGame
().GetInputManager().ActivateContext(
"InteractableDialogContext"
);
97
}
98
99
//------------------------------------------------------------------------------------------------
100
override
protected
void
OnConfirm
()
101
{
102
array<SCR_EGroupRole> availableGroupRoles =
m_GroupsManager
.GetAvailableGroupRoles(
m_LocalFaction
,
SCR_PlayerController
.
GetLocalPlayerId
());
103
if
(availableGroupRoles.IsEmpty())
104
return
;
105
106
SCR_PlayerControllerGroupComponent groupController = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
107
if
(!groupController)
108
return
;
109
110
if
(
m_bHasPrivilege
)
111
{
112
bool
isPrivate =
m_GroupStatus
.GetCurrentIndex() ==
SCR_EGroupPrivacy
.PRIVATE;
113
114
array<SCR_EGroupRole> configuredGroupRoles =
m_GroupsManager
.GetConfiguredGroupRoles(
m_LocalFaction
,
true
);
115
116
int
currentIndex =
m_GroupRole
.GetCurrentIndex();
117
if
(configuredGroupRoles.IsIndexValid(currentIndex) && availableGroupRoles.Contains(configuredGroupRoles[currentIndex]))
118
{
119
bool
joinGroup = !SCR_FactionCommanderPlayerComponent.IsLocalPlayerCommander();
120
121
string
groupName =
string
.Empty;
122
if
(
m_GroupName
.IsEnabled())
123
groupName =
m_GroupName
.GetValue();
124
125
string
groupDescription =
string
.Empty;
126
if
(
m_GroupDescription
.IsEnabled())
127
groupDescription =
m_GroupDescription
.GetValue();
128
129
groupController.RequestCreateGroupWithData(configuredGroupRoles[currentIndex], isPrivate, groupName, groupDescription, joinGroup,
true
);
130
}
131
else
132
{
133
Print
(
"Cannot create group because is not available"
,
LogLevel
.WARNING);
134
}
135
}
136
137
Close
();
138
}
139
140
//------------------------------------------------------------------------------------------------
141
protected
void
SetupGroupStatusCombo
()
142
{
143
m_GroupStatus
.AddItem(
"#AR-Player_Groups_Public"
);
144
m_GroupStatus
.AddItem(
"#AR-Player_Groups_Private"
);
145
146
m_GroupStatus
.SetCurrentItem(
SCR_EGroupPrivacy
.PUBLIC);
// default value
147
148
if
(SCR_FactionCommanderPlayerComponent.IsLocalPlayerCommander())
149
m_GroupStatus
.SetEnabled(
false
);
150
}
151
152
//------------------------------------------------------------------------------------------------
153
protected
void
SetupGroupRoleCombo
()
154
{
155
m_GroupRole
.m_OnOpened.Insert(
OnGroupRoleComboOpened
);
156
157
// set available role to combobox
158
array<SCR_EGroupRole> availableGroupRoles =
m_GroupsManager
.GetAvailableGroupRoles(
m_LocalFaction
,
SCR_PlayerController
.
GetLocalPlayerId
());
159
bool
selectAvailableGroupRole = !availableGroupRoles.IsEmpty();
160
161
array<SCR_GroupRolePresetConfig> groupRolePresetConfigs = {};
162
m_LocalFaction
.GetGroupRolePresetConfigs(groupRolePresetConfigs);
163
164
SCR_GroupRolePresetConfig
preset;
165
string
groupRoleName;
166
int
count = groupRolePresetConfigs.Count();
167
for
(
int
i = 0; i < count; i++)
168
{
169
preset = groupRolePresetConfigs[i];
170
171
if
(!preset.
CanBeCreatedByPlayer
())
172
continue
;
173
174
if
(preset.
GetGroupRoleName
().IsEmpty())
175
groupRoleName =
SCR_Enum
.GetEnumName(
SCR_EGroupRole
, preset.GetGroupRole());
176
else
177
groupRoleName = preset.
GetGroupRoleName
();
178
179
m_GroupRole
.AddItem(groupRoleName, i == count-1);
180
181
if
(selectAvailableGroupRole && preset.GetGroupRole() == availableGroupRoles[0])
182
{
183
m_GroupRole
.SetCurrentItem(i);
184
selectAvailableGroupRole =
false
;
185
}
186
}
187
}
188
//------------------------------------------------------------------------------------------------
189
protected
void
OnGroupRoleComboOpened
()
190
{
191
array<SCR_EGroupRole> configuredGroupRoles =
m_GroupsManager
.GetConfiguredGroupRoles(
m_LocalFaction
,
true
);
192
array<SCR_EGroupRole> availableGroupRoles =
m_GroupsManager
.GetAvailableGroupRoles(
m_LocalFaction
,
SCR_PlayerController
.
GetLocalPlayerId
());
193
194
array<Widget> comboBoxWidgets = {};
195
int
itemsCount =
m_GroupRole
.GetElementWidgets(comboBoxWidgets);
196
197
SCR_SquadRoleComboBoxElement
squadRoleComboBoxElement;
198
bool
isAvailable =
false
;
199
bool
isPlayerCommander = SCR_FactionCommanderPlayerComponent.IsLocalPlayerCommander();
200
201
// set element availability in combobox
202
for
(
int
i = 0; i < itemsCount; i++)
203
{
204
SCR_EGroupRole
configuredGroupRole = configuredGroupRoles[i];
205
if
(configuredGroupRoles.IsIndexValid(i))
206
isAvailable = availableGroupRoles.Contains(configuredGroupRole);
207
else
208
isAvailable =
false
;
209
210
m_GroupRole
.SetElementWidgetEnabled(i, isAvailable,
false
);
211
212
squadRoleComboBoxElement =
SCR_SquadRoleComboBoxElement
.Cast(comboBoxWidgets[i].FindHandler(
SCR_SquadRoleComboBoxElement
));
213
if
(!squadRoleComboBoxElement)
214
continue
;
215
216
bool
isRequiredRankVisible = !isPlayerCommander && !
m_GroupsManager
.CanCreateGroupWithLocalPlayerRank(configuredGroupRole,
m_LocalFaction
);
217
squadRoleComboBoxElement.
SetVisibleInsufficientRank
(isRequiredRankVisible);
218
if
(isRequiredRankVisible)
219
{
220
SCR_ECharacterRank requiredRank =
m_GroupsManager
.GetRequiredRank(configuredGroupRole,
m_LocalFaction
);
221
squadRoleComboBoxElement.
SetRankImage
(
m_LocalFaction
.GetRanks().GetRankInsignia(requiredRank));
222
}
223
224
bool
isNotEnoughFullGroupVisible = !isPlayerCommander && !
m_GroupsManager
.AreAllGroupsMajorityFull(configuredGroupRole,
m_LocalFaction
);
225
squadRoleComboBoxElement.
SetVisibleNotEnoughFullGroup
(isNotEnoughFullGroupVisible);
226
}
227
}
228
229
//------------------------------------------------------------------------------------------------
230
protected
void
UpdateConfirmButton
()
231
{
232
array<SCR_EGroupRole> availableGroupRoles =
m_GroupsManager
.GetAvailableGroupRoles(
m_LocalFaction
,
SCR_PlayerController
.
GetLocalPlayerId
());
233
bool
isAnyAvailable = availableGroupRoles.Count() > 0;
234
m_Confirm
.SetVisible(isAnyAvailable);
235
}
236
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
SCR_EGroupPrivacy
SCR_EGroupPrivacy
Group privacy.
Definition
SCR_EGroupPrivacy.c:3
SCR_EGroupRole
SCR_EGroupRole
Group roles.
Definition
SCR_EGroupRole.c:3
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition
SCR_FactionManager.c:498
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
CreateGroupSettingsDialogUI
Definition
CreateGroupSettingsDialogUI.c:2
CreateGroupSettingsDialogUI::OnMenuUpdate
override void OnMenuUpdate(float tDelta)
Definition
CreateGroupSettingsDialogUI.c:92
CreateGroupSettingsDialogUI::m_RulesDescriptionSize
Widget m_RulesDescriptionSize
Definition
CreateGroupSettingsDialogUI.c:3
CreateGroupSettingsDialogUI::OnConfirm
void OnConfirm()
Definition
CreateGroupSettingsDialogUI.c:100
CreateGroupSettingsDialogUI::m_bHasPrivilege
bool m_bHasPrivilege
Definition
CreateGroupSettingsDialogUI.c:16
CreateGroupSettingsDialogUI::OnPrivilegeCallback
void OnPrivilegeCallback(UserPrivilege privilege, UserPrivilegeResult result)
Definition
CreateGroupSettingsDialogUI.c:36
CreateGroupSettingsDialogUI::m_GroupStatus
SCR_ComboBoxComponent m_GroupStatus
Definition
CreateGroupSettingsDialogUI.c:5
CreateGroupSettingsDialogUI::m_PlayerComponent
SCR_PlayerControllerGroupComponent m_PlayerComponent
Definition
CreateGroupSettingsDialogUI.c:12
CreateGroupSettingsDialogUI::m_LocalFaction
SCR_Faction m_LocalFaction
Definition
CreateGroupSettingsDialogUI.c:17
CreateGroupSettingsDialogUI::m_Description
SCR_EditBoxComponent m_Description
Definition
CreateGroupSettingsDialogUI.c:4
CreateGroupSettingsDialogUI::SetupGroupStatusCombo
void SetupGroupStatusCombo()
Definition
CreateGroupSettingsDialogUI.c:141
CreateGroupSettingsDialogUI::m_GroupRole
SCR_ComboBoxComponent m_GroupRole
Definition
CreateGroupSettingsDialogUI.c:6
CreateGroupSettingsDialogUI::SetupGroupRoleCombo
void SetupGroupRoleCombo()
Definition
CreateGroupSettingsDialogUI.c:153
CreateGroupSettingsDialogUI::m_GroupsManager
SCR_GroupsManagerComponent m_GroupsManager
Definition
CreateGroupSettingsDialogUI.c:13
CreateGroupSettingsDialogUI::OnGroupRoleComboOpened
void OnGroupRoleComboOpened()
Definition
CreateGroupSettingsDialogUI.c:189
CreateGroupSettingsDialogUI::m_GroupDescription
SCR_EditBoxComponent m_GroupDescription
Definition
CreateGroupSettingsDialogUI.c:8
CreateGroupSettingsDialogUI::OnMenuOpen
override void OnMenuOpen()
Definition
CreateGroupSettingsDialogUI.c:20
CreateGroupSettingsDialogUI::UpdateConfirmButton
void UpdateConfirmButton()
Definition
CreateGroupSettingsDialogUI.c:230
CreateGroupSettingsDialogUI::m_PlayerGroup
SCR_AIGroup m_PlayerGroup
Definition
CreateGroupSettingsDialogUI.c:14
CreateGroupSettingsDialogUI::m_GroupName
SCR_EditBoxComponent m_GroupName
Definition
CreateGroupSettingsDialogUI.c:7
CreateGroupSettingsDialogUI::m_CallbackGetPrivilege
ref SCR_ScriptPlatformRequestCallback m_CallbackGetPrivilege
Definition
CreateGroupSettingsDialogUI.c:10
DialogUI
Definition
DialogUI.c:2
DialogUI::m_Confirm
SCR_InputButtonComponent m_Confirm
Definition
DialogUI.c:8
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_Enum
Definition
SCR_Enum.c:2
SCR_Faction
Definition
SCR_Faction.c:6
SCR_GroupRolePresetConfig
Definition
SCR_GroupRolePresetConfig.c:3
SCR_GroupRolePresetConfig::CanBeCreatedByPlayer
bool CanBeCreatedByPlayer()
Definition
SCR_GroupRolePresetConfig.c:34
SCR_GroupRolePresetConfig::GetGroupRoleName
LocalizedString GetGroupRoleName()
Definition
SCR_GroupRolePresetConfig.c:18
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
SCR_SquadRoleComboBoxElement
Definition
SCR_SquadRoleComboBoxElement.c:2
SCR_SquadRoleComboBoxElement::SetVisibleNotEnoughFullGroup
void SetVisibleNotEnoughFullGroup(bool show)
Definition
SCR_SquadRoleComboBoxElement.c:25
SCR_SquadRoleComboBoxElement::SetVisibleInsufficientRank
void SetVisibleInsufficientRank(bool show)
Definition
SCR_SquadRoleComboBoxElement.c:19
SCR_SquadRoleComboBoxElement::SetRankImage
void SetRankImage(string rankIconName)
Definition
SCR_SquadRoleComboBoxElement.c:13
Widget
Definition
Widget.c:13
WidgetManager
Definition
WidgetManager.c:16
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
LogLevel
Enum with severity of the logging message.
Definition
LogLevel.c:14
EUserInteraction
EUserInteraction
Interaction type between two players.
Definition
EUserInteraction.c:14
scripts
Game
UI
Menu
CreateGroupSettingsDialogUI.c
Generated by
1.17.0