Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ServerFullDialog.c
Go to the documentation of this file.
1/*
2 Dialog to provide feedback for attempting to join a full server.
3 Supports
4 - Enqueued
5 - Server full, queue full
6 - Server full, queue disabled
7*/
8
10{
11 protected const string WIDGET_BACKGROUND_IMAGE = "BackgroundImageBackend";
12 protected const string WIDGET_SIDE_SPINNER = "SideSpinner";
13
14 protected const string INPUT_BUTTON_FIELD_MANUAL = "FieldManual";
15 protected const string INPUT_BUTTON_FAVORITES = "Favorites";
16 protected const string MOUSE_BUTTON_FAVORITES = "FavoriteButton";
17
18 protected const int ENQUEUED_TIME_UPDATE_FREQUENCY = 1000;
19
20 // Messages
21 protected const string MESSAGE_SERVER_FULL = "#AR-ServerBrowser_FullServer";
22 protected const string MESSAGE_SERVER_POPULATION = "#AR-Scenario_Players";
23 protected const string MESSAGE_QUEUE_FULL = "#AR-ServerQueue_QueueFull_Header";
24 protected const string MESSAGE_QUEUE_DISABLED = "#AR-ServerQueue_QueueDisabled_Header";
25 protected const string MESSAGE_QUEUE_POPULATION = "#AR-ServerQueue_PlayersInQueue";
26 protected const string MESSAGE_QUEUE_MAX_SIZE = "#AR-ServerQueue_MaxSize";
27 protected const string MESSAGE_ENQUEUED = "#AR-ServerQueue_Enqueued_Header";
28 protected const string MESSAGE_ENQUEUED_POSITION = "#AR-ServerQueue_CurrentPosition";
29 protected const string MESSAGE_QUEUE_WAIT_TIME = "#AR-ServerQueue_AvgWaitTime";
30 protected const string MESSAGE_QUEUE_EXPLANATION = "#AR-ServerQueue_Enqueued_Message";
31 protected const string MESSAGE_QUEUE_EXPLANATION_TIME = "#AR-ServerQueue_Enqueued_Message_Time";
32
33 protected const string LABEL_LEAVE_QUEUE = "#AR-ServerQueue_LeaveQueue_Button";
34 protected const string LABEL_CANCEL = "#AR-Workshop_ButtonCancel";
35
37
42 protected SCR_ModularButtonComponent m_BtnFavorites;
45
46 protected Room m_Room;
48
52
53 // --- Override ---
54 //------------------------------------------------------------------------------------------------
56 {
57 super.OnMenuOpen(preset);
58
60
63
66 m_NavFieldManual.m_OnActivated.Insert(OnFieldManual);
67
70 m_NavFavorites.m_OnActivated.Insert(OnFavorite);
71
72 Widget mouseFavorites = m_wRoot.FindAnyWidget(MOUSE_BUTTON_FAVORITES);
73 if (mouseFavorites)
74 {
75 m_BtnFavorites = SCR_ModularButtonComponent.FindComponent(mouseFavorites);
77 m_BtnFavorites.m_OnClicked.Insert(OnFavorite);
78 }
79
80 m_Widgets.m_IPAddressButtonComponent.m_OnClicked.Insert(OnCopyIPAddress);
81
82 Widget backgroundImageBackend = GetRootWidget().FindAnyWidget(WIDGET_BACKGROUND_IMAGE);
83 if (backgroundImageBackend)
85
87 }
88
89 //------------------------------------------------------------------------------------------------
90 override void OnMenuClose()
91 {
92 super.OnMenuClose();
93
94 GetGame().GetCallqueue().Remove(UpdateEnqueuedTimeDisplay);
95 }
96
97 //------------------------------------------------------------------------------------------------
98 override void OnConfirm()
99 {
100 super.OnConfirm();
101
102 if (m_OnRetryFullServerJoin && (m_eMode == SCR_EJoinFailUI.SERVER_FULL_QUEUE_FULL || m_eMode == SCR_EJoinFailUI.SERVER_FULL_QUEUE_DISABLED))
104 }
105
106 //------------------------------------------------------------------------------------------------
107 override void OnCancel()
108 {
109 super.OnCancel();
110
112 m_OnLeaveQueueRequest.Invoke();
113 }
114
115 // --- Protected ---
116 //------------------------------------------------------------------------------------------------
117 protected void OnFavorite()
118 {
119 if ((m_eMode == SCR_EJoinFailUI.SERVER_FULL_QUEUE_FULL || m_eMode == SCR_EJoinFailUI.SERVER_FULL_QUEUE_DISABLED) && m_OnFavorite)
120 m_OnFavorite.Invoke();
121 }
122
123 //------------------------------------------------------------------------------------------------
124 protected void OnFieldManual()
125 {
126 SCR_FieldManualUI fieldmenu = SCR_FieldManualUI.Cast(GetGame().GetMenuManager().OpenDialog(ChimeraMenuPreset.FieldManualDialog));
127 if (fieldmenu)
128 fieldmenu.ShowQueueMessage();
129 }
130
131 //------------------------------------------------------------------------------------------------
132 protected void DisplayFavoriteAction(bool isFavorite)
133 {
134 if (m_NavFavorites && m_NavFavorites.IsVisible())
135 m_NavFavorites.SetLabel(UIConstants.GetFavoriteLabel(isFavorite));
136
137 // Star Button
138 if (m_BtnFavorites)
139 m_BtnFavorites.SetToggled(isFavorite, false);
140 }
141
142 //------------------------------------------------------------------------------------------------
144 {
145 DisplayFavoriteAction(m_Room.IsFavorite());
146 }
147
148 //------------------------------------------------------------------------------------------------
149 protected void OnCopyIPAddress()
150 {
151 System.ExportToClipboard(m_Room.HostAddress());
152 }
153
154 //------------------------------------------------------------------------------------------------
155 protected void SetIPAddressText(string text)
156 {
157 m_Widgets.m_wIPAddressText.SetText(text);
158 }
159
160 //------------------------------------------------------------------------------------------------
161 protected void SetDiscordText(string text)
162 {
163 m_Widgets.m_wDiscordText.SetText(text);
164 }
165
166 //------------------------------------------------------------------------------------------------
167 protected void UpdateDetailIcons()
168 {
169 if (!m_Room)
170 return;
171
172 m_Widgets.m_wDetailIcon_PasswordProtected.SetVisible(m_Room.PasswordProtected());
173 m_Widgets.m_wDetailIcon_CrossPlatform.SetVisible(m_Room.IsCrossPlatform());
174 m_Widgets.m_wDetailIcon_Modded.SetVisible(m_Room.IsModded());
175 }
176
177 //------------------------------------------------------------------------------------------------
178 protected void SetFavoritesButtonsEnabled(bool enabled)
179 {
180 // Input button
181 if (m_NavFavorites)
182 m_NavFavorites.SetVisible(enabled, false);
183
184 // Star mouse button
185 if (!m_BtnFavorites)
186 return;
187
188 Widget widget = m_BtnFavorites.GetRootWidget();
189 if (!widget)
190 return;
191
192 WidgetFlags flags = widget.GetFlags();
193 if (enabled)
194 widget.SetFlags(SCR_Enum.RemoveFlag(flags, WidgetFlags.IGNORE_CURSOR));
195 else
196 widget.SetFlags(SCR_Enum.SetFlag(flags, WidgetFlags.IGNORE_CURSOR));
197 }
198
199 // --- Displayed info changes based on mode ---
200 //------------------------------------------------------------------------------------------------
201 // Display information about the queue and the player's position in it
202 protected void UpdateInfo_Enqueued()
203 {
204 // --- Queue position
205 int count = m_Room.GetQueueUserPosition() + 1; // backend value starts from 0
206 int limit = m_Room.GetQueueMaxSize();
207 bool showPosition = count > 0;
208
209 m_Widgets.m_wQueueState.SetVisible(showPosition);
210 if (showPosition)
211 m_Widgets.m_wQueueState.SetTextFormat(MESSAGE_ENQUEUED_POSITION, SCR_RichTextTags.TagColor(count.ToString(), UIColors.CopyColor(UIColors.CONTRAST_COLOR)));
212
213 // --- Queue max size
214 m_Widgets.m_wQueueMaxSizeOverlay.SetVisible(showPosition);
215 if (showPosition)
216 m_Widgets.m_wQueueMaxSize.SetTextFormat(MESSAGE_QUEUE_MAX_SIZE, limit);
217
218 // --- Wait time
219 /*
220 int waitTime = m_Room.GetQueueAvgWaitTime();
221 bool showWaitTime = showPosition && waitTime > 0;
222
223 m_Widgets.m_wQueueWaitTimeOverlay.SetVisible(showWaitTime);
224 if (showWaitTime)
225 m_Widgets.m_wQueueWaitTime.SetTextFormat(MESSAGE_QUEUE_WAIT_TIME, UIConstants.FormatSeconds(waitTime * count));
226 */
227 }
228
229 //------------------------------------------------------------------------------------------------
230 // Display a warning about the queue being full, or if it isn't anymore, display it's size and allow rejoining
231 protected void UpdateInfo_QueueFull()
232 {
233 // --- Queue position
234 int count = m_Room.GetQueueSize();
235 int limit = m_Room.GetQueueMaxSize();
236 bool fullQueue = count == limit;
237 bool emptyQueue = count <= 0;
238
239 if (fullQueue)
240 {
241 m_Widgets.m_wQueueState.SetText(MESSAGE_QUEUE_FULL);
242 m_Widgets.m_wQueueState.SetColor(UIColors.CopyColor(UIColors.NEUTRAL_ACTIVE_STANDBY));
243 }
244 else
245 {
246 m_Widgets.m_wQueueState.SetTextFormat(MESSAGE_QUEUE_POPULATION, count);
247 m_Widgets.m_wQueueState.SetColor(UIColors.CopyColor(UIColors.NEUTRAL_INFORMATION));
248 }
249
250 // --- Queue max size
251 m_Widgets.m_wQueueMaxSize.SetTextFormat(MESSAGE_QUEUE_MAX_SIZE, limit);
252
253 // --- State message
254 count = m_Room.PlayerCount();
255 limit = m_Room.PlayerLimit();
256 bool fullServer = count == limit || !emptyQueue;
257
258 if (fullServer)
259 {
260 m_Widgets.m_wCurrentState.SetText(MESSAGE_SERVER_FULL);
261 m_Widgets.m_wCurrentState.SetColor(UIColors.CopyColor(UIColors.WARNING));
262 }
263 else
264 {
265 m_Widgets.m_wCurrentState.SetTextFormat(MESSAGE_SERVER_POPULATION, UIConstants.FormatValueOutOf(count, limit, false));
266 m_Widgets.m_wCurrentState.SetColor(UIColors.CopyColor(UIColors.NEUTRAL_INFORMATION));
267 }
268
269 // --- Wait time
270 /*
271 int waitTime = m_Room.GetQueueAvgWaitTime();
272 bool showWaitTime = !emptyQueue && waitTime > 0;
273
274 m_Widgets.m_wQueueWaitTimeOverlay.SetVisible(showWaitTime);
275 if (showWaitTime)
276 m_Widgets.m_wQueueWaitTime.SetTextFormat(MESSAGE_QUEUE_WAIT_TIME, UIConstants.FormatSeconds(waitTime * m_Room.GetQueueSize()));
277 */
278
279 // --- Confirm button
280 if (m_NavConfirm)
281 m_NavConfirm.SetEnabled(!fullServer || !fullQueue, false);
282 }
283
284 //------------------------------------------------------------------------------------------------
285 // Display a warning about the server being full without the ability to queue, or if it isn't anymore, display it's population and allow rejoining
287 {
288 // --- Queue position
289 m_Widgets.m_wQueueState.SetText(MESSAGE_QUEUE_DISABLED);
290 m_Widgets.m_wQueueState.SetColor(UIColors.CopyColor(UIColors.NEUTRAL_ACTIVE_STANDBY));
291
292 // --- State message
293 int count = m_Room.PlayerCount();
294 int limit = m_Room.PlayerLimit();
295 bool fullServer = count == limit;
296
297 if (fullServer)
298 {
299 m_Widgets.m_wCurrentState.SetText(MESSAGE_SERVER_FULL);
300 m_Widgets.m_wCurrentState.SetColor(UIColors.CopyColor(UIColors.WARNING));
301 }
302 else
303 {
304 m_Widgets.m_wCurrentState.SetTextFormat(MESSAGE_SERVER_POPULATION, UIConstants.FormatValueOutOf(count, limit, false));
305 m_Widgets.m_wCurrentState.SetColor(UIColors.CopyColor(UIColors.NEUTRAL_INFORMATION));
306 }
307
308 // --- Confirm button
309 if (m_NavConfirm)
310 m_NavConfirm.SetEnabled(!fullServer, false);
311 }
312
313 //------------------------------------------------------------------------------------------------
314 // Time since joining queue
316 {
317 if (!m_Room || m_Room.GetQueueJoinTime() <= 0)
318 {
319 m_Widgets.m_wTimeSinceJoiningQueue.SetText(MESSAGE_QUEUE_EXPLANATION);
320 return;
321 }
322
323 // --- Time since join
324 string time = SCR_RichTextTags.TagColor(UIConstants.FormatSeconds(m_Room.GetQueueJoinTime()), UIColors.CopyColor(UIColors.CONTRAST_COLOR));
325 m_Widgets.m_wTimeSinceJoiningQueue.SetTextFormat(MESSAGE_QUEUE_EXPLANATION_TIME, time);
326 }
327
328 // --- Public ---
329 //------------------------------------------------------------------------------------------------
330 void Init(Room room, SCR_EJoinFailUI mode, MissionWorkshopItem scenario, ScriptInvokerVoid onFavoritesResponse = null)
331 {
332 m_Room = room;
333 m_eMode = mode;
334
335 SetTitle(room.Name());
336 SetScenarioImage(scenario);
337 SetIPAddressText(SCR_WorkshopUiCommon.LABEL_IP_ADDRESS + " " + room.HostAddress());
338 DisplayFavoriteAction(m_Room.IsFavorite());
340
341 UpdateInfo();
342
343 if (onFavoritesResponse)
344 onFavoritesResponse.Insert(OnRoomSetFavoriteResponseDialog);
345
346 // --- Static widgets
347 switch (m_eMode)
348 {
349 case SCR_EJoinFailUI.ENQUEUED:
350 {
351 m_Widgets.m_wCurrentState.SetText(MESSAGE_ENQUEUED);
352 m_Widgets.m_wCurrentState.SetColor(UIColors.CopyColor(UIColors.CONTRAST_COLOR));
353
354 m_Widgets.m_wQueueState.SetColor(UIColors.CopyColor(UIColors.NEUTRAL_INFORMATION));
355
356 m_Widgets.m_wExplanationEnqueuedWrapper.SetVisible(true);
357 m_Widgets.m_wExplanationFull.SetVisible(false);
358
360 GetGame().GetCallqueue().CallLater(UpdateEnqueuedTimeDisplay, ENQUEUED_TIME_UPDATE_FREQUENCY, true);
361
362 break;
363 }
364 case SCR_EJoinFailUI.SERVER_FULL_QUEUE_FULL:
365 {
366 m_Widgets.m_wQueueState.SetVisible(true);
367 m_Widgets.m_wQueueMaxSizeOverlay.SetVisible(true);
368
369 m_Widgets.m_wExplanationEnqueuedWrapper.SetVisible(false);
370 m_Widgets.m_wExplanationFull.SetVisible(true);
371
372 break;
373 }
374 case SCR_EJoinFailUI.SERVER_FULL_QUEUE_DISABLED:
375 {
376 m_Widgets.m_wQueueState.SetVisible(true);
377 m_Widgets.m_wQueueMaxSizeOverlay.SetVisible(false);
378
379 m_Widgets.m_wExplanationEnqueuedWrapper.SetVisible(false);
380 m_Widgets.m_wExplanationFull.SetVisible(true);
381
382 m_Widgets.m_wQueueWaitTimeOverlay.SetVisible(false);
383
384 break;
385 }
386 }
387
388 // --- Favorites buttons
389 SetFavoritesButtonsEnabled(m_eMode == SCR_EJoinFailUI.SERVER_FULL_QUEUE_FULL || m_eMode == SCR_EJoinFailUI.SERVER_FULL_QUEUE_DISABLED);
390
391 // --- Confirm button
392 if (m_NavConfirm)
393 m_NavConfirm.SetVisible(m_eMode == SCR_EJoinFailUI.SERVER_FULL_QUEUE_FULL || m_eMode == SCR_EJoinFailUI.SERVER_FULL_QUEUE_DISABLED, false);
394
395 // --- Cancel button
396 if (m_NavCancel)
397 {
398 string label = LABEL_CANCEL;
399 if (m_eMode == SCR_EJoinFailUI.ENQUEUED)
400 label = LABEL_LEAVE_QUEUE;
401
402 m_NavCancel.SetLabel(label);
403 }
404
405 // --- Field Manual button
407 m_NavFieldManual.SetVisible(m_eMode == SCR_EJoinFailUI.ENQUEUED, false);
408
409 // --- SideSpinner
410 if (m_wSideSpinner)
411 m_wSideSpinner.SetVisible(m_eMode == SCR_EJoinFailUI.ENQUEUED);
412 }
413
414 //------------------------------------------------------------------------------------------------
416 {
417 if (!m_Room)
418 return;
419
420 switch (m_eMode)
421 {
422 case SCR_EJoinFailUI.ENQUEUED:
423 {
425 break;
426 }
427 case SCR_EJoinFailUI.SERVER_FULL_QUEUE_FULL:
428 {
430 break;
431 }
432 case SCR_EJoinFailUI.SERVER_FULL_QUEUE_DISABLED:
433 {
435 break;
436 }
437 }
438 }
439
440 //------------------------------------------------------------------------------------------------
442 {
444 return;
445
446 if (scenario)
447 m_BackendImageComp.SetImage(scenario.Thumbnail());
448 else
449 m_BackendImageComp.SetImage(null);
450 }
451
452 //------------------------------------------------------------------------------------------------
460
461 //------------------------------------------------------------------------------------------------
469
470 //------------------------------------------------------------------------------------------------
472 {
473 if (!m_OnFavorite)
475
476 return m_OnFavorite;
477 }
478}
SCR_EAIThreatSectorFlags flags
ChimeraMenuPreset
Menu presets.
ArmaReforgerScripted GetGame()
Definition game.c:1398
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
ScriptInvokerBase< ScriptInvokerRoomMethod > ScriptInvokerRoom
Definition Room.c:13
Widget GetContentLayoutRoot()
Returns the root of the content layout.
SCR_InputButtonComponent FindButton(string tag)
Returns a button with given tag.
void ShowQueueMessage()
Show the Server Queue.
Same as SCR_BackendImageComponent, but implements default image based on scenario.
const string MESSAGE_QUEUE_WAIT_TIME
void SetDiscordText(string text)
ScriptInvokerRoom GetOnRetryFullServerJoin()
const string MESSAGE_ENQUEUED_POSITION
void Init(Room room, SCR_EJoinFailUI mode, MissionWorkshopItem scenario, ScriptInvokerVoid onFavoritesResponse=null)
ScriptInvokerVoid GetOnLeaveQueueRequest()
SCR_InputButtonComponent m_NavFavorites
const string MESSAGE_QUEUE_DISABLED
const string INPUT_BUTTON_FAVORITES
ref ScriptInvokerVoid m_OnFavorite
SCR_InputButtonComponent m_NavConfirm
void SetScenarioImage(MissionWorkshopItem scenario)
ScriptInvokerVoid GetOnFavorite()
const string MESSAGE_QUEUE_POPULATION
const string MESSAGE_SERVER_POPULATION
SCR_InputButtonComponent m_NavCancel
const string MESSAGE_QUEUE_EXPLANATION
const string INPUT_BUTTON_FIELD_MANUAL
void DisplayFavoriteAction(bool isFavorite)
const string MOUSE_BUTTON_FAVORITES
ref ScriptInvokerVoid m_OnLeaveQueueRequest
void SetFavoritesButtonsEnabled(bool enabled)
SCR_InputButtonComponent m_NavFieldManual
const string WIDGET_BACKGROUND_IMAGE
ref ScriptInvokerRoom m_OnRetryFullServerJoin
SCR_ScenarioBackendImageComponent m_BackendImageComp
const string MESSAGE_QUEUE_EXPLANATION_TIME
void SetIPAddressText(string text)
override void OnMenuOpen(SCR_ConfigurableDialogUiPreset preset)
SCR_ModularButtonComponent m_BtnFavorites
ref SCR_ServerFullDialogContentWidgets m_Widgets
const string MESSAGE_QUEUE_MAX_SIZE
WidgetFlags
Widget flags. See enf::Widget::SetFlags().
Definition WidgetFlags.c:14