Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_FactionPlayerList.c
Go to the documentation of this file.
1
class
SCR_PlayerList
:
ScriptedWidgetComponent
2
{
3
[
Attribute
(
"Flag"
)]
4
protected
string
m_sFlag
;
5
protected
ImageWidget
m_wFlag
;
6
7
[
Attribute
(
"Name"
)]
8
protected
string
m_sName
;
9
protected
TextWidget
m_wName
;
10
11
[
Attribute
(
"Count"
)]
12
protected
string
m_sPlayerCount
;
13
protected
TextWidget
m_wPlayerCount
;
14
15
[
Attribute
(
"Players"
)]
16
protected
string
m_sPlayerList
;
17
protected
Widget
m_wPlayerList
;
18
19
[
Attribute
(
"{E49B28A2FAEBA264}UI/layouts/Menus/DeployMenu/PlayerName.layout"
)]
20
protected
ResourceName
m_sPlayerName
;
21
22
protected
ref array<SCR_PlayerName>
m_aPlayerNames
= {};
23
protected
Widget
m_wRoot
;
24
25
//------------------------------------------------------------------------------------------------
26
override
void
HandlerAttached
(
Widget
w)
27
{
28
m_wRoot
= w;
29
30
m_wFlag
=
ImageWidget
.Cast(w.FindAnyWidget(
m_sFlag
));
31
m_wName
=
TextWidget
.Cast(w.FindAnyWidget(
m_sName
));
32
m_wPlayerCount
=
TextWidget
.Cast(w.FindAnyWidget(
m_sPlayerCount
));
33
m_wPlayerList
= w.FindAnyWidget(
m_sPlayerList
);
34
}
35
36
//------------------------------------------------------------------------------------------------
37
void
UpdatePlayerList
()
38
{
39
}
40
41
//------------------------------------------------------------------------------------------------
43
void
ShowPlayerList
(
bool
show)
44
{
45
m_wRoot
.SetVisible(show);
46
}
47
48
//------------------------------------------------------------------------------------------------
49
protected
void
CreatePlayerName
(
int
pid)
50
{
51
Widget
player =
GetGame
().GetWorkspace().CreateWidgets(
m_sPlayerName
,
m_wPlayerList
);
52
if
(player)
53
{
54
SCR_PlayerName
playerName =
SCR_PlayerName
.Cast(player.FindHandler(
SCR_PlayerName
));
55
playerName.
SetPlayer
(pid);
56
// playerName.SetIcon(ResourceName.Empty); // todo@lk: set some icon from somewhere
57
m_aPlayerNames
.Insert(playerName);
58
}
59
}
60
};
61
62
class
SCR_FactionPlayerList
:
SCR_PlayerList
63
{
64
protected
SCR_Faction
m_Faction
;
65
protected
SCR_SpinBoxComponent
m_SpinBoxComp
;
66
protected
int
m_iLastPage
;
67
68
[
Attribute
(
"10"
,
params
:
"0 inf"
,
UIWidgets
.EditBox,
"How much entries should be shown in list."
)]
69
protected
int
m_iEntriesPerPage
;
70
71
[
Attribute
(
"SpinBox"
)]
72
protected
string
m_sSpinBoxElementName
;
73
74
[
Attribute
(
"ButtonLeft"
)]
75
protected
string
m_sPagingButtonLeft
;
76
77
[
Attribute
(
"ButtonRight"
)]
78
protected
string
m_sPagingButtonRight
;
79
80
//------------------------------------------------------------------------------------------------
81
override
event
void
HandlerAttached
(
Widget
w)
82
{
83
super.HandlerAttached(w);
84
85
SCR_FactionManager
factionManager =
SCR_FactionManager
.Cast(
GetGame
().GetFactionManager());
86
if
(!factionManager)
87
return
;
88
89
factionManager.GetOnPlayerFactionCountChanged().Insert(
UpdatePagination
);
90
factionManager.GetOnPlayerFactionCountChanged().Insert(
UpdatePlayerList
);
91
92
Widget
spinboxW =
m_wRoot
.FindAnyWidget(
m_sSpinBoxElementName
);
93
if
(!spinboxW)
94
return
;
95
96
m_SpinBoxComp
=
SCR_SpinBoxComponent
.Cast(spinboxW.FindHandler(
SCR_SpinBoxComponent
));
97
if
(!
m_SpinBoxComp
)
98
return
;
99
100
m_SpinBoxComp
.m_OnChanged.Insert(
UpdatePlayerList
);
101
}
102
103
//------------------------------------------------------------------------------------------------
104
void
SetFaction
(
Faction
faction)
105
{
106
SCR_Faction
scrFaction =
SCR_Faction
.Cast(faction);
107
if
(!scrFaction)
108
return
;
109
110
m_Faction
= scrFaction;
111
112
if
(
m_wFlag
&& !scrFaction.
GetFactionFlag
().IsEmpty())
113
m_wFlag
.LoadImageTexture(0, scrFaction.
GetFactionFlag
());
114
115
if
(
m_wName
)
116
m_wName
.SetText(scrFaction.GetFactionName());
117
118
UpdatePagination
(faction);
119
UpdatePlayerList
();
120
121
//Reset last page as faction was changed
122
m_iLastPage
= 0;
123
}
124
125
//------------------------------------------------------------------------------------------------
126
protected
void
UpdatePagination
(
Faction
faction)
127
{
128
if
(faction !=
m_Faction
)
129
return
;
130
131
array<int> players = {};
132
m_Faction
.GetPlayersInFaction(players);
133
134
int
pageCount = players.Count() /
m_iEntriesPerPage
;
135
if
((players.Count() %
m_iEntriesPerPage
) > 0)
136
pageCount++;
137
138
SetLastIndex
();
139
m_SpinBoxComp
.ClearAll();
140
141
for
(
int
i = 0; i < pageCount; i++)
142
{
143
m_SpinBoxComp
.AddItem(
""
, i == pageCount - 1);
144
}
145
146
m_SpinBoxComp
.SetCurrentItem(
m_iLastPage
);
147
148
//Show or disable navigation buttons depending on number of visible pagging entries
149
HandleNavigationButtons
();
150
}
151
152
//------------------------------------------------------------------------------------------------
154
protected
int
GetStartingIndex
()
155
{
156
int
page =
m_SpinBoxComp
.GetCurrentIndex();
157
if
(page < 1)
158
return
0;
159
160
return
page *
m_iEntriesPerPage
;
161
}
162
163
//------------------------------------------------------------------------------------------------
164
protected
void
HandleNavigationButtons
()
165
{
166
if
(!
m_SpinBoxComp
)
167
return
;
168
169
bool
showButtons =
m_SpinBoxComp
.GetNumItems() > 1;
170
171
Widget
button =
m_wRoot
.FindAnyWidget(
m_sPagingButtonLeft
);
172
if
(button)
173
button.SetVisible(showButtons);
174
175
button =
m_wRoot
.FindAnyWidget(
m_sPagingButtonRight
);
176
if
(button)
177
button.SetVisible(showButtons);
178
179
Widget
spinboxW =
m_wRoot
.FindAnyWidget(
m_sSpinBoxElementName
);
180
if
(spinboxW)
181
spinboxW.SetVisible(showButtons);
182
}
183
184
//------------------------------------------------------------------------------------------------
185
protected
void
SetLastIndex
()
186
{
187
m_iLastPage
=
m_SpinBoxComp
.GetCurrentIndex();
188
}
189
190
//------------------------------------------------------------------------------------------------
191
override
void
UpdatePlayerList
()
192
{
193
if
(!
m_Faction
|| !
m_wPlayerList
)
194
return
;
195
196
m_aPlayerNames
.Clear();
197
198
Widget
child =
m_wPlayerList
.GetChildren();
199
while
(child)
200
{
201
Widget
sibling = child.GetSibling();
202
child.RemoveFromHierarchy();
203
child = sibling;
204
}
205
206
array<int> players = {};
207
m_Faction
.GetPlayersInFaction(players);
208
209
int
startIndex =
GetStartingIndex
();
210
if
(players.IsEmpty() || startIndex < 0)
211
{
212
if
(
m_wPlayerCount
)
213
m_wPlayerCount
.SetText(
"0"
);
214
return
;
215
}
216
217
int
maxIndex = startIndex + (
m_iEntriesPerPage
-1);
218
for
(
int
i = startIndex; i <= maxIndex; i++)
219
{
220
if
(i >= players.Count())
221
break
;
222
223
if
(
m_Faction
&& (
SCR_Faction
.Cast(
SCR_FactionManager
.SGetPlayerFaction(players[i])) ==
m_Faction
))
224
CreatePlayerName
(players[i]);
225
}
226
227
if
(
m_wPlayerCount
)
228
m_wPlayerCount
.SetText(players.Count().ToString());
229
}
230
231
override
event
void
HandlerDeattached
(
Widget
w)
232
{
233
super.HandlerDeattached(w);
234
235
SCR_FactionManager
factionManager =
SCR_FactionManager
.Cast(
GetGame
().GetFactionManager());
236
if
(factionManager)
237
{
238
factionManager.GetOnPlayerFactionCountChanged().Remove(
UpdatePagination
);
239
factionManager.GetOnPlayerFactionCountChanged().Remove(
UpdatePlayerList
);
240
}
241
}
242
};
243
244
class
SCR_GroupPlayerList
:
SCR_PlayerList
245
{
246
protected
SCR_AIGroup
m_Group
;
247
248
void
SetGroup
(
SCR_AIGroup
group)
249
{
250
if
(!group)
251
return
;
252
253
m_Group
= group;
254
255
if
(
m_wFlag
&& !group.
GetGroupFlag
().IsEmpty())
256
m_wFlag
.LoadImageTexture(0, group.
GetGroupFlag
());
257
258
if
(
m_wName
)
259
{
260
string
name =
m_Group
.GetCustomName();
261
if
(name.IsEmpty())
262
{
263
string
company, platoon, squad, character, format;
264
m_Group
.GetCallsigns(company, platoon, squad, character, format);
265
name =
string
.Format(
"%1 %2 %3 %4 %5"
, company, platoon, squad, character, format);
266
}
267
268
m_wName
.SetText(name);
269
}
270
271
UpdatePlayerList
();
272
}
273
274
override
void
UpdatePlayerList
()
275
{
276
if
(!
m_Group
|| !
m_wPlayerList
)
277
return
;
278
279
m_aPlayerNames
.Clear();
280
281
Widget
child =
m_wPlayerList
.GetChildren();
282
while
(child)
283
{
284
Widget
sibling = child.GetSibling();
285
child.RemoveFromHierarchy();
286
child = sibling;
287
}
288
289
array<int> players =
m_Group
.GetPlayerIDs();
290
foreach
(
int
pid : players)
291
{
292
CreatePlayerName
(pid);
293
}
294
295
if
(
m_wPlayerCount
)
296
m_wPlayerCount
.SetText(
m_aPlayerNames
.Count().ToString());
297
}
298
};
299
300
class
SCR_PlayerName
:
ScriptedWidgetComponent
301
{
302
[
Attribute
(
"Icon"
)]
303
protected
string
m_sIcon
;
304
protected
ImageWidget
m_wIcon
;
305
306
[
Attribute
(
"Name"
)]
307
protected
string
m_sName
;
308
protected
TextWidget
m_wName
;
309
310
[
Attribute
(
"BadgeWrapper"
)]
311
protected
string
m_sBadgeWrapper
;
312
protected
SizeLayoutWidget
m_wBadgeWrapper
;
313
314
protected
ResourceName
m_sIcons
=
"{D17288006833490F}UI/Textures/Icons/icons_wrapperUI-32.imageset"
;
315
protected
int
m_iPlayerId
;
316
317
318
override
void
HandlerAttached
(
Widget
w)
319
{
320
m_wIcon
=
ImageWidget
.Cast(w.FindAnyWidget(
m_sIcon
));
321
m_wName
=
TextWidget
.Cast(w.FindAnyWidget(
m_sName
));
322
m_wBadgeWrapper
=
SizeLayoutWidget
.Cast(w.FindAnyWidget(
m_sBadgeWrapper
));
323
SetBadgeColor
(
m_wBadgeWrapper
);
324
}
325
326
//------------------------------------------------------------------------------------------------
327
void
SetIcon
(
ResourceName
icon)
328
{
329
if
(!
m_wIcon
)
330
return
;
331
332
if
(
m_wIcon
)
333
m_wIcon
.SetVisible(
m_wIcon
.LoadImageTexture(0, icon));
334
}
335
336
//------------------------------------------------------------------------------------------------
338
void
SetBadgeColor
(
SizeLayoutWidget
badgeWrapper)
339
{
340
SCR_FactionManager
m_FactionManager
=
SCR_FactionManager
.Cast(
GetGame
().GetFactionManager());
341
342
if
(!badgeWrapper || !
m_FactionManager
)
343
return
;
344
345
Faction
faction =
m_FactionManager
.GetLocalPlayerFaction();
346
if
(!faction)
347
return
;
348
349
badgeWrapper.SetColor(faction.GetFactionColor());
350
}
351
352
//------------------------------------------------------------------------------------------------
355
void
SetPlayer
(
int
pid)
356
{
357
m_iPlayerId
= pid;
358
if
(
m_wName
)
359
m_wName
.SetText(
SCR_PlayerNamesFilterCache
.GetInstance().GetPlayerDisplayName(pid));
360
361
SetPlatform
();
362
}
363
364
//------------------------------------------------------------------------------------------------
365
int
GetPlayerId
()
366
{
367
return
m_iPlayerId
;
368
}
369
370
//------------------------------------------------------------------------------------------------
371
protected
void
SetPlatform
()
372
{
373
if
(!
m_wIcon
)
374
return
;
375
376
SCR_PlayerController
playerController =
SCR_PlayerController
.Cast(
GetGame
().
GetPlayerController
());
377
playerController && playerController.SetPlatformImageTo(
m_iPlayerId
,
m_wIcon
, showOnPC:
true
, showOnXbox:
true
)
378
379
// todo@lk: local profile pic
380
}
381
};
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition
SCR_FactionManager.c:498
m_FactionManager
SCR_FactionManager m_FactionManager
Definition
SCR_NotificationSenderComponent.c:34
params
category params
Definition
SCR_SpherePointGeneratorPreviewComponent.c:21
Faction
Definition
Faction.c:13
ImageWidget
Definition
ImageWidget.c:13
ResourceName
Definition
ResourceName.c:13
SCR_AIGroup
Definition
SCR_AIGroup.c:75
SCR_AIGroup::GetGroupFlag
ResourceName GetGroupFlag()
Definition
SCR_AIGroup.c:444
SCR_Faction
Definition
SCR_Faction.c:6
SCR_Faction::GetFactionFlag
ResourceName GetFactionFlag()
Definition
SCR_Faction.c:257
SCR_FactionPlayerList
Definition
SCR_FactionPlayerList.c:63
SCR_FactionPlayerList::m_Faction
SCR_Faction m_Faction
Definition
SCR_FactionPlayerList.c:64
SCR_FactionPlayerList::m_sSpinBoxElementName
string m_sSpinBoxElementName
Definition
SCR_FactionPlayerList.c:72
SCR_FactionPlayerList::HandleNavigationButtons
void HandleNavigationButtons()
Definition
SCR_FactionPlayerList.c:164
SCR_FactionPlayerList::UpdatePagination
void UpdatePagination(Faction faction)
Definition
SCR_FactionPlayerList.c:126
SCR_FactionPlayerList::GetStartingIndex
int GetStartingIndex()
Get index of first entry of current page.
Definition
SCR_FactionPlayerList.c:154
SCR_FactionPlayerList::m_sPagingButtonRight
string m_sPagingButtonRight
Definition
SCR_FactionPlayerList.c:78
SCR_FactionPlayerList::HandlerDeattached
override event void HandlerDeattached(Widget w)
Definition
SCR_FactionPlayerList.c:231
SCR_FactionPlayerList::m_iLastPage
int m_iLastPage
Definition
SCR_FactionPlayerList.c:66
SCR_FactionPlayerList::SetFaction
void SetFaction(Faction faction)
Definition
SCR_FactionPlayerList.c:104
SCR_FactionPlayerList::UpdatePlayerList
override void UpdatePlayerList()
Definition
SCR_FactionPlayerList.c:191
SCR_FactionPlayerList::m_iEntriesPerPage
int m_iEntriesPerPage
Definition
SCR_FactionPlayerList.c:69
SCR_FactionPlayerList::SetLastIndex
void SetLastIndex()
Definition
SCR_FactionPlayerList.c:185
SCR_FactionPlayerList::m_SpinBoxComp
SCR_SpinBoxComponent m_SpinBoxComp
Definition
SCR_FactionPlayerList.c:65
SCR_FactionPlayerList::HandlerAttached
override event void HandlerAttached(Widget w)
Definition
SCR_FactionPlayerList.c:81
SCR_FactionPlayerList::m_sPagingButtonLeft
string m_sPagingButtonLeft
Definition
SCR_FactionPlayerList.c:75
SCR_GroupPlayerList
Definition
SCR_FactionPlayerList.c:245
SCR_GroupPlayerList::UpdatePlayerList
override void UpdatePlayerList()
Definition
SCR_FactionPlayerList.c:274
SCR_GroupPlayerList::m_Group
SCR_AIGroup m_Group
Definition
SCR_FactionPlayerList.c:246
SCR_GroupPlayerList::SetGroup
void SetGroup(SCR_AIGroup group)
Definition
SCR_FactionPlayerList.c:248
SCR_PlayerController
Definition
SCR_PlayerController.c:31
SCR_PlayerList
Definition
SCR_FactionPlayerList.c:2
SCR_PlayerList::m_sName
string m_sName
Definition
SCR_FactionPlayerList.c:8
SCR_PlayerList::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_FactionPlayerList.c:26
SCR_PlayerList::m_wPlayerCount
TextWidget m_wPlayerCount
Definition
SCR_FactionPlayerList.c:13
SCR_PlayerList::m_sPlayerCount
string m_sPlayerCount
Definition
SCR_FactionPlayerList.c:12
SCR_PlayerList::m_wPlayerList
Widget m_wPlayerList
Definition
SCR_FactionPlayerList.c:17
SCR_PlayerList::m_wName
TextWidget m_wName
Definition
SCR_FactionPlayerList.c:9
SCR_PlayerList::m_wFlag
ImageWidget m_wFlag
Definition
SCR_FactionPlayerList.c:5
SCR_PlayerList::m_sPlayerList
string m_sPlayerList
Definition
SCR_FactionPlayerList.c:16
SCR_PlayerList::UpdatePlayerList
void UpdatePlayerList()
Definition
SCR_FactionPlayerList.c:37
SCR_PlayerList::m_aPlayerNames
ref array< SCR_PlayerName > m_aPlayerNames
Definition
SCR_FactionPlayerList.c:22
SCR_PlayerList::m_wRoot
Widget m_wRoot
Definition
SCR_FactionPlayerList.c:23
SCR_PlayerList::m_sFlag
string m_sFlag
Definition
SCR_FactionPlayerList.c:4
SCR_PlayerList::ShowPlayerList
void ShowPlayerList(bool show)
Definition
SCR_FactionPlayerList.c:43
SCR_PlayerList::CreatePlayerName
void CreatePlayerName(int pid)
Definition
SCR_FactionPlayerList.c:49
SCR_PlayerList::m_sPlayerName
ResourceName m_sPlayerName
Definition
SCR_FactionPlayerList.c:20
SCR_PlayerName
Definition
SCR_FactionPlayerList.c:301
SCR_PlayerName::SetBadgeColor
void SetBadgeColor(SizeLayoutWidget badgeWrapper)
Definition
SCR_FactionPlayerList.c:338
SCR_PlayerName::SetPlayer
void SetPlayer(int pid)
Definition
SCR_FactionPlayerList.c:355
SCR_PlayerName::m_wIcon
ImageWidget m_wIcon
Definition
SCR_FactionPlayerList.c:304
SCR_PlayerName::m_wBadgeWrapper
SizeLayoutWidget m_wBadgeWrapper
Definition
SCR_FactionPlayerList.c:312
SCR_PlayerName::SetIcon
void SetIcon(ResourceName icon)
Definition
SCR_FactionPlayerList.c:327
SCR_PlayerName::m_wName
TextWidget m_wName
Definition
SCR_FactionPlayerList.c:308
SCR_PlayerName::m_sIcons
ResourceName m_sIcons
Definition
SCR_FactionPlayerList.c:314
SCR_PlayerName::m_iPlayerId
int m_iPlayerId
Definition
SCR_FactionPlayerList.c:315
SCR_PlayerName::SetPlatform
void SetPlatform()
Definition
SCR_FactionPlayerList.c:371
SCR_PlayerName::GetPlayerId
int GetPlayerId()
Definition
SCR_FactionPlayerList.c:365
SCR_PlayerName::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_FactionPlayerList.c:318
SCR_PlayerName::m_sIcon
string m_sIcon
Definition
SCR_FactionPlayerList.c:303
SCR_PlayerName::m_sName
string m_sName
Definition
SCR_FactionPlayerList.c:307
SCR_PlayerName::m_sBadgeWrapper
string m_sBadgeWrapper
Definition
SCR_FactionPlayerList.c:311
SCR_PlayerNamesFilterCache
Definition
SCR_PlayerNamesFilterCache.c:3
SCR_SpinBoxComponent
Definition
SCR_SpinBoxComponent.c:2
ScriptedWidgetComponent
Definition
ScriptedWidgetComponent.c:13
SizeLayoutWidget
Definition
SizeLayoutWidget.c:16
TextWidget
Definition
TextWidget.c:16
UIWidgets
Definition
attributes.c:40
Widget
Definition
Widget.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
GetPlayerController
proto external PlayerController GetPlayerController()
Definition
SCR_PlayerDeployMenuHandlerComponent.c:307
scripts
Game
UI
Menu
DeployMenu
SCR_FactionPlayerList.c
Generated by
1.17.0