Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_DeployMenuBase.c
Go to the documentation of this file.
3typedef ScriptInvokerBase<OnSpawnPointRplIdSet> OnSpawnPointRplIdSetInvoker;
4//------------------------------------------------------------------------------------------------
7{
11
14
16
17 //------------------------------------------------------------------------------------------------
18 override void OnMenuOpen()
19 {
20 if (s_OnMenuOpen)
21 s_OnMenuOpen.Invoke();
22
25 {
27 if (editor)
28 {
29 m_GameMasterButton.SetVisible(!editor.IsLimitedInstance());
30 editor.GetOnLimitedChange().Insert(OnEditorLimitedChanged);
31 }
32 }
33
34 super.OnMenuOpen();
35 }
36
37 //------------------------------------------------------------------------------------------------
38 override void OnMenuOpened()
39 {
40 // Mute sounds
41 // If menu is opened before loading screen is closed, wait for closing
42 if (ArmaReforgerLoadingAnim.IsOpen())
44 else
45 MuteSounds();
46 }
47
48 //------------------------------------------------------------------------------------------------
49 override void OnMenuClose()
50 {
51 MuteSounds(false);
52 if (m_MapEntity && m_MapEntity.IsOpen())
53 m_MapEntity.CloseMap();
54
55 super.OnMenuClose();
56 }
57
58 //------------------------------------------------------------------------------------------------
59 override void OnMenuHide()
60 {
61 MuteSounds(false);
62 if (m_MapEntity && m_MapEntity.IsOpen())
63 m_MapEntity.CloseMap();
64 }
65
66 //------------------------------------------------------------------------------------------------
67 protected void OpenPlayerList()
68 {
69 GetGame().GetMenuManager().OpenDialog(ChimeraMenuPreset.PlayerListMenu);
70 }
71
72 //------------------------------------------------------------------------------------------------
75 void MuteSounds(bool mute = true)
76 {
77 if (!IsOpen())
78 return;
79
80 AudioSystem.SetMasterVolume(AudioSystem.SFX, !mute);
81 AudioSystem.SetMasterVolume(AudioSystem.VoiceChat, !mute);
82 AudioSystem.SetMasterVolume(AudioSystem.Dialog, !mute);
83
85 }
86
88 protected void OnEditorLimitedChanged(bool limited)
89 {
90 m_GameMasterButton.SetVisible(!limited);
91 }
92
93 //------------------------------------------------------------------------------------------------
103}
104
105//------------------------------------------------------------------------------------------------
107class SCR_DeployMenuMain : SCR_DeployMenuBase
108{
110
114
117
120 protected RplId m_iSelectedSpawnPointId = RplId.Invalid();
121 protected SCR_PlayerDeployMenuHandlerComponent m_PlayerMenuHandler;
122
125
126 protected FactionManager m_FactionManager;
128
130
133
135
138 protected SCR_TimedSpawnPointComponent m_TimedSpawnPointTimer;
139 protected int m_iPreviousTime = 0;
140 protected bool m_bRespawnRequested = false;
141 protected bool m_bSuppliesEnabled;
142 protected SCR_RespawnSystemComponent m_RespawnSystemComp;
144
145 protected int m_iPlayerId;
146
147 protected bool m_bMapContextAllowed = true;
148 protected bool m_bInitialSpawnPointSet = false;
150
152 protected bool m_bDisplayTime;
153
155 protected const float CHECK_CAN_SPAWN_SPAWNPOINT_TIME = 1; //~ Time (in seconds) when the system should request if the player can spawn. Note this request is send to server
156 protected const string FALLBACK_DEPLOY_STRING = "#AR-ButtonSelectDeploy"; //~ Time (in seconds) when the system should request if the player can spawn. Note this request is send to server
157
159
160 //~ A timer that disables the respawn button for x seconds after it has been pressed to prevent players from sending multiple spawn requests
161 protected float m_fCurrentDeployTimeOut;
162 protected const float DEPLOY_TIME_OUT = 0.5;
163
165
166 //------------------------------------------------------------------------------------------------
170 //----------------------------------------------------------------------------------------------
172 {
173 int cost;
174
175 SCR_EntityCatalogManagerComponent entityCatalogManager = SCR_EntityCatalogManagerComponent.GetInstance();
176 if (!entityCatalogManager)
177 return 0;
178
179 SCR_Faction faction = SCR_Faction.Cast(m_PlyFactionAffilComp.GetAffiliatedFaction());
180 if (!faction)
181 return 0;
182
183 SCR_BasePlayerLoadout playerLoadout = component.GetLoadout();
184 if (!playerLoadout)
185 return 0;
186
187 ResourceName loadoutResource = playerLoadout.GetLoadoutResource();
188 if (!loadoutResource)
189 return 0;
190
191 Resource resource = Resource.Load(loadoutResource);
192 if (!resource)
193 return 0;
194
195 SCR_EntityCatalogEntry entry = entityCatalogManager.GetEntryWithPrefabFromFactionCatalog(EEntityCatalogType.CHARACTER, resource.GetResource().GetResourceName(), faction);
196 if (!entry)
197 return 0;
198
200 if (!data)
201 return 0;
202
203 cost = data.GetSupplyCost();
204
205 return cost;
206 }
207
208
209 //------------------------------------------------------------------------------------------------
211 void AllowMapContext(bool allow)
212 {
213 m_bMapContextAllowed = allow;
214 }
215
216 //------------------------------------------------------------------------------------------------
220 {
222 }
223
224 //------------------------------------------------------------------------------------------------
225 override void OnMenuOpen()
226 {
227 super.OnMenuOpen();
229
230 m_wMenuFrame = GetRootWidget().FindAnyWidget("MenuFrame");
231
234 m_RespawnSystemComp = SCR_RespawnSystemComponent.GetInstance();
237 m_RespawnComponent.GetOnCanRespawnResponseInvoker_O().Insert(OnCanRespawnRequestResponse);
238
240
241 if (!m_MapEntity)
242 {
243 Debug.Error("Map entity is missing in the world! Deploy menu won't work correctly.");
244 }
245
247
248 m_wRespawnButton = GetRootWidget().FindAnyWidget("RespawnButton");
249
251 if (m_RespawnButton)
252 {
253 //~ Set enabled false so players cannot press the button right after init
254 m_RespawnButton.SetEnabled(false);
255 m_RespawnButton.m_OnActivated.Insert(RequestRespawn);
256 }
257
258 Widget spinnerRoot = GetRootWidget().FindAnyWidget("LoadingSpinner");
259 m_wLoadingSpinner = spinnerRoot.FindAnyWidget("Spinner");
262
263 m_FactionManager = GetGame().GetFactionManager();
264 if (!m_FactionManager)
265 {
266 Print("Cannot find faction manager, respawn menu functionality will be broken.", LogLevel.ERROR);
267 }
268
270 m_TimedSpawnPointTimer = SCR_TimedSpawnPointComponent.Cast(m_GameMode.FindComponent(SCR_TimedSpawnPointComponent));
272
273 PlayerController pc = GetGame().GetPlayerController();
274 m_iPlayerId = pc.GetPlayerId();
275
278 {
279 Print("Cannot find player faction affiliation component!", LogLevel.ERROR);
280 }
281
283 if (!m_PlyLoadoutComp)
284 {
285 Print("Cannot find player loadout component!", LogLevel.ERROR);
286 }
287
288 m_SpawnRequestManager = SCR_RespawnComponent.Cast(pc.GetRespawnComponent());
289 m_PlayerMenuHandler = SCR_PlayerDeployMenuHandlerComponent.Cast(pc.FindComponent(SCR_PlayerDeployMenuHandlerComponent));
290
291 Widget chat = GetRootWidget().FindAnyWidget("ChatPanel");
292 if (chat)
293 m_ChatPanel = SCR_ChatPanel.Cast(chat.FindHandler(SCR_ChatPanel));
294
295 m_ChatButton = SCR_InputButtonComponent.GetInputButtonComponent("ChatButton", GetRootWidget());
296 if (m_ChatButton)
297 m_ChatButton.m_OnActivated.Insert(OnChatToggle);
298
299 m_PauseButton = SCR_InputButtonComponent.GetInputButtonComponent("PauseButton", GetRootWidget());
300 if (m_PauseButton)
301 m_PauseButton.m_OnActivated.Insert(OnPauseMenu);
302
304 if (groupsManager && groupsManager.IsGroupMenuAllowed())
305 {
308 {
309 m_GroupOpenButton.SetVisible(true);
310 m_GroupOpenButton.m_OnActivated.Insert(OpenGroupMenu);
311 }
312 }
313
314 HookEvents();
316
317 bool pause = m_ActiveRespawnTimer == null;
319 if (!gameMode)
320 return;
321
322 gameMode.PauseGame(pause, SCR_EPauseReason.MENU);
323
324 SCR_MenuSpawnLogic logic = SCR_MenuSpawnLogic.Cast(m_RespawnSystemComp.GetSpawnLogic());
325 if (logic.GetUseFadeEffect())
326 {
327 Widget fade = GetRootWidget().FindAnyWidget("FadeEffect");
328 fade.SetVisible(true);
329 }
330 }
331
332 //------------------------------------------------------------------------------------------------
333 override void OnMenuHide()
334 {
335 super.OnMenuHide();
336
337 if (m_MapEntity && m_MapEntity.IsOpen())
338 m_MapEntity.CloseMap();
339
341 m_RespawnComponent.GetOnCanRespawnResponseInvoker_O().Remove(OnCanRespawnRequestResponse);
342 }
343
344 //------------------------------------------------------------------------------------------------
345 override void OnMenuFocusLost()
346 {
347 GetGame().GetInputManager().RemoveActionListener("ShowScoreboard", EActionTrigger.DOWN, OpenPlayerList);
348 GetGame().GetInputManager().RemoveActionListener("DeployMenuSelect", EActionTrigger.DOWN, RequestRespawn);
349
350 GetGame().GetInputManager().RemoveActionListener("SpawnPointNext", EActionTrigger.DOWN, NextSpawn);
351 GetGame().GetInputManager().RemoveActionListener("SpawnPointPrev", EActionTrigger.DOWN, PrevSpawn);
352
353 super.OnMenuFocusLost();
354 }
355
356 //------------------------------------------------------------------------------------------------
357 override void OnMenuFocusGained()
358 {
359 SCR_EditorManagerEntity editorManager = SCR_EditorManagerEntity.GetInstance();
360 if (editorManager)
361 editorManager.AutoInit();
362
363 GetGame().GetInputManager().AddActionListener("ShowScoreboard", EActionTrigger.DOWN, OpenPlayerList);
364 GetGame().GetInputManager().AddActionListener("DeployMenuSelect", EActionTrigger.DOWN, RequestRespawn);
365
366 GetGame().GetInputManager().AddActionListener("SpawnPointNext", EActionTrigger.DOWN, NextSpawn);
367 GetGame().GetInputManager().AddActionListener("SpawnPointPrev", EActionTrigger.DOWN, PrevSpawn);
368
369 super.OnMenuFocusGained();
370 }
371
373 protected void NextSpawn()
374 {
375 if (!m_bRespawnRequested && !m_LoadoutRequestUIHandler.IsSelectorFocused() && !m_SpawnPointRequestUIHandler.IsSelectorFocused())
376 m_SpawnPointRequestUIHandler.CycleSpawnPoints();
377 }
378
380 protected void PrevSpawn()
381 {
382 if (!m_bRespawnRequested && !m_LoadoutRequestUIHandler.IsSelectorFocused() && !m_SpawnPointRequestUIHandler.IsSelectorFocused())
383 m_SpawnPointRequestUIHandler.CycleSpawnPoints(false);
384 }
385
386 //------------------------------------------------------------------------------------------------
387 override void OnMenuOpened()
388 {
389 super.OnMenuOpened();
390 Faction plyFaction = m_PlyFactionAffilComp.GetAffiliatedFaction();
391
392 m_LoadoutRequestUIHandler.ShowAvailableLoadouts(plyFaction);
393 m_GroupRequestUIHandler.ShowAvailableGroups(plyFaction);
394 if (!m_GroupRequestUIHandler.GetPlayerGroup())
395 m_GroupRequestUIHandler.JoinGroupAutomatically();
396 m_SpawnPointRequestUIHandler.ShowAvailableSpawnPoints(plyFaction);
397 }
398
399 //------------------------------------------------------------------------------------------------
400 override void OnMenuClose()
401 {
402 super.OnMenuClose();
403
404 if (m_MapEntity && m_MapEntity.IsOpen())
405 m_MapEntity.CloseMap();
406
408
409 // Unpause
411 if (!gameMode)
412 return;
413
414 gameMode.PauseGame(false, SCR_EPauseReason.MENU);
415 }
416 //---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
417 //------------------------------------------------------------------------------------------------
418 override void OnMenuUpdate(float tDelta)
419 {
420 m_RespawnButton.SetSuppliesEnabled(m_bSuppliesEnabled);
421 GetGame().GetInputManager().ActivateContext("DeployMenuContext");
422 GetGame().GetInputManager().ActivateContext("DeployMenuMapContext");
423
425 GetGame().GetInputManager().ActivateContext("MapContext");
426
427 if (m_LoadingSpinner && m_wLoadingSpinner.IsVisible())
428 {
429 m_LoadingSpinner.Update(tDelta);
430 m_RespawnButton.UpdateSpinner(tDelta);
431 }
432
433 if (m_ChatPanel)
434 m_ChatPanel.OnUpdateChat(tDelta);
435
436 //~ Update if player can spawn
439 {
441
442 //~ Only check if can spawn if spawn is requested
443 if (!m_bRespawnRequested && m_LoadoutRequestUIHandler.GetPlayerLoadout())
444 m_RespawnComponent.CanSpawn(new SCR_SpawnPointSpawnData(m_LoadoutRequestUIHandler.GetPlayerLoadout().GetLoadoutResource(), m_iSelectedSpawnPointId));
445 }
446
448 m_fCurrentDeployTimeOut -= tDelta;
449
450 //~ If can respawn
451 int remainingTime = -1;
452
453 //~ Timer calculation and sound event
455 {
456 float spawnPointTime = 0;
459 remainingTime = m_ActiveRespawnTimer.GetPlayerRemainingTime(m_iPlayerId, spawnPointTime);
460
461 if (remainingTime > 0)
462 {
463 if (remainingTime != m_iPreviousTime)
464 {
465 if (m_bDisplayTime)
466 {
467 SCR_UISoundEntity.SetSignalValueStr("countdownValue", remainingTime);
468 SCR_UISoundEntity.SetSignalValueStr("maxCountdownValue", m_ActiveRespawnTimer.GetRespawnTime());
469 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_RESPAWN_COUNTDOWN);
470 }
471
472 m_iPreviousTime = remainingTime;
473 }
474
475 if (m_bDisplayTime)
476 {
478 m_RespawnButton.SetText(m_bCanRespawnAtSpawnPoint, m_UIInfoSpawnRequestResult.GetNameWithTimer(), remainingTime);
479 else
481 }
482 else
483 {
486 else
488 }
489 }
490 else
491 {
492 if (m_iPreviousTime > 0)
493 {
494 if (m_bDisplayTime)
495 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_RESPAWN_COUNTDOWN_END);
496
497 m_iPreviousTime = remainingTime;
498 }
499
502 else
504 }
505 }
506
508 }
509 //---- REFACTOR NOTE END ----
510
511 //------------------------------------------------------------------------------------------------
512 protected void ResetRespawnResultVars()
513 {
514 m_bDisplayTime = false;
516 m_fCurrentCanSpawnUpdateTime = CHECK_CAN_SPAWN_SPAWNPOINT_TIME; //~ Makes sure to send a request if spawnpoint can be spawned at
517 }
518
519 //------------------------------------------------------------------------------------------------
520 //~ Response from server when player sends a request to spawn
521 protected void OnCanRespawnRequestResponse(SCR_SpawnRequestComponent requestComponent, SCR_ESpawnResult response, SCR_SpawnData data)
522 {
524 SCR_BaseSpawnPointRequestResultInfo spawnPointResultInfo = m_RespawnSystemComp.GetSpawnPointRequestResultInfo(requestComponent, response, data);
525
526 if (!spawnPointResultInfo)
527 {
530
531 return;
532 }
533
534 m_UIInfoSpawnRequestResult = spawnPointResultInfo.GetUIInfo();
535 m_bDisplayTime = spawnPointResultInfo.ShowRespawnTime();
536
538
539 m_bSuppliesEnabled = false;
540
542
543 if (!spawnPoint)
544 return;
545
546 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(spawnPoint);
547
548 if (resourceComponent)
549 m_bSuppliesEnabled = true;
550 else
551 {
552 IEntity parentEntity = spawnPoint.GetParent();
553
554 if (parentEntity)
555 {
556 resourceComponent = SCR_ResourceComponent.FindResourceComponent(parentEntity);
557
558 if (resourceComponent)
559 m_bSuppliesEnabled = true;
560 }
561 }
562
563 m_RespawnButton.SetSuppliesEnabled(m_bSuppliesEnabled);
564
565 //~ Timer calculation and sound event
567 {
568 int remainingTime = m_ActiveRespawnTimer.GetPlayerRemainingTime(m_iPlayerId);
569
570 if (remainingTime > 0)
571 {
573 m_RespawnButton.SetText(m_bCanRespawnAtSpawnPoint, m_UIInfoSpawnRequestResult.GetNameWithTimer(), remainingTime);
574 else
576
578 return;
579 }
580 }
581
584 else
586
588 }
589
590 //------------------------------------------------------------------------------------------------
592 protected void FindRequestHandlers()
593 {
594 m_LoadoutRequestUIHandler = m_MenuHandler.GetLoadoutRequestHandler();
596 {
597 Print("Failed to find SCR_LoadoutRequestUIComponent!", LogLevel.ERROR);
598 }
599 else
600 {
601 m_LoadoutRequestUIHandler.RegisterOnSpawnPointInvoker(GetOnSpawnPointRplIdSet());
602 }
603
604 m_GroupRequestUIHandler = m_MenuHandler.GetGroupRequestHandler();
606 {
607 Print("Failed to find SCR_GroupRequestUIComponent!", LogLevel.ERROR);
608 }
609
610 m_SpawnPointRequestUIHandler = m_MenuHandler.GetSpawnPointRequestHandler();
612 {
613 Print("Failed to find SCR_SpawnPointRequestUIComponent!", LogLevel.ERROR);
614 }
615 }
616
618 protected void HookEvents()
619 {
620 m_PlyFactionAffilComp.GetOnPlayerFactionRequestInvoker_O().Insert(OnPlayerFactionRequest);
621 m_PlyFactionAffilComp.GetOnPlayerFactionResponseInvoker_O().Insert(OnPlayerFactionResponse);
622
623 m_PlyLoadoutComp.GetOnPlayerLoadoutRequestInvoker_O().Insert(OnPlayerLoadoutRequest);
624 m_PlyLoadoutComp.GetOnPlayerLoadoutResponseInvoker_O().Insert(OnPlayerLoadoutResponse);
625
626 m_SpawnRequestManager.GetOnRespawnRequestInvoker_O().Insert(OnRespawnRequest);
627 m_SpawnRequestManager.GetOnRespawnResponseInvoker_O().Insert(OnRespawnResponse);
628
629 m_SpawnPointRequestUIHandler.GetOnSpawnPointSelected().Insert(OnSpawnPointSelected);
630 m_GroupRequestUIHandler.GetOnLocalPlayerGroupJoined().Insert(OnLocalPlayerGroupJoined);
631 m_MapEntity.GetOnMapOpen().Insert(OnMapOpen);
632
633 m_GameMode.GetOnPreloadFinished().Insert(HideLoading);
634 }
635
636 //---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
637 //------------------------------------------------------------------------------------------------
638 protected void OnMapOpen(MapConfiguration config)
639 {
640 m_MapEntity.SetZoom(1);
641
644 m_UIElementContainer.GetOnSpawnPointSelected().Insert(SetSpawnPointExt);
645
647 if (sp)
648 GetGame().GetCallqueue().CallLater(SetInitialSpawnPoint, 0, false, m_iSelectedSpawnPointId); // called the next frame because of widget init order
649
650 SCR_MenuSpawnLogic logic = SCR_MenuSpawnLogic.Cast(m_RespawnSystemComp.GetSpawnLogic());
651 if (logic.GetUseFadeEffect())
652 {
653 Widget fade = GetRootWidget().FindAnyWidget("FadeEffect");
654 const int timeBeforeFade = 1000;
655 const float fadeTime = 0.3;
656 GetGame().GetCallqueue().CallLater(AnimateWidget.Opacity, timeBeforeFade, false, fade, 0, fadeTime, true);
657 }
658
659 }
660 //---- REFACTOR NOTE END ----
661
664 {
666 m_SpawnPointRequestUIHandler.UpdateRelevantSpawnPoints();
667 }
668
670 protected void InitMapDeploy()
671 {
672 if (!m_MapEntity || m_MapEntity.IsOpen())
673 return;
674
675 SCR_MapConfigComponent configComp = SCR_MapConfigComponent.Cast(m_GameMode.FindComponent(SCR_MapConfigComponent));
676 if (!configComp)
677 return;
678
679 m_MapConfigDeploy = m_MapEntity.SetupMapConfig(EMapEntityMode.SPAWNSCREEN, configComp.GetSpawnMapConfig(), GetRootWidget());
681 }
682
684 protected void SetSpawnPointExt(RplId id)
685 {
686 m_SpawnPointRequestUIHandler.SelectSpawnPointExt(id);
687 }
688
690 protected void SetInitialSpawnPoint(RplId spawnPointId)
691 {
694 SetSpawnPoint(spawnPointId, false);
695 }
696
697 protected void OnSpawnPointSelected(RplId id)
698 {
699 SetSpawnPoint(id); // Handle default args
700 }
701
703 protected void SetSpawnPoint(RplId id, bool smoothPan = true)
704 {
707
709 if (!sp)
710 return;
711
712 FocusOnPoint(sp, smoothPan);
713
715 m_UIElementContainer.OnSpawnPointSelectedExt(id);
716
718 {
719 if (sp.IsTimed())
721 else
723 }
724
727 m_OnSpawnPointSet.Invoke(id);
728 }
729
731 protected void FocusOnPoint(notnull SCR_SpawnPoint spawnPoint, bool smooth = true)
732 {
733 if (!m_bInitialSpawnPointSet || !m_MapEntity || !m_MapEntity.IsOpen())
734 return;
735
736 if (spawnPoint.IsSpawnPointRandom())
737 {
738 m_MapEntity.CenterMap();
739 return;
740 }
741
742 vector o = spawnPoint.GetOrigin();
743
744 float x, y;
745 m_MapEntity.WorldToScreen(o[0], o[2], x, y);
746
747 if (smooth)
748 m_MapEntity.PanSmooth(x, y);
749 else
750 m_MapEntity.PanSmooth(x, y, 0.001); // since SetPan doesn't work correctly in some cases, just PanSmooth super fast
751 }
752
754 protected void HideLoading()
755 {
756 m_wLoadingSpinner.SetVisible(false);
757 }
758
760 protected void RequestRespawn()
761 {
763
764 if (!m_RespawnButton.IsEnabled())
765 return;
766
767 if (!m_iSelectedSpawnPointId.IsValid())
768 {
769 Debug.Error("Selected SpawnPointId is invalid!");
770 return;
771 }
772
773 ResourceName resourcePrefab = ResourceName.Empty;
774 if (m_LoadoutRequestUIHandler.GetPlayerLoadout())
775 resourcePrefab = m_LoadoutRequestUIHandler.GetPlayerLoadout().GetLoadoutResource();
776 else
777 {
778 Debug.Error("No player loadout assigned!");
779 return;
780 }
781
783
786 m_PlayerMenuHandler.SetLastUsedSpawnPointId(rspData.GetRplId());
787 m_SpawnRequestManager.RequestSpawn(rspData);
788 }
789
791 protected void OnPlayerFactionRequest(SCR_PlayerFactionAffiliationComponent component, int factionIndex)
792 {
793 m_wLoadingSpinner.SetVisible(true);
794 }
795
797 protected void OnPlayerFactionResponse(SCR_PlayerFactionAffiliationComponent component, int factionIndex, bool response)
798 {
799 if (response)
800 {
801 Faction assignedFaction = m_FactionManager.GetFactionByIndex(factionIndex);
802 OnPlayerFactionSet(assignedFaction);
803 }
804
805 m_wLoadingSpinner.SetVisible(false);
806 }
807
809 protected void OnPlayerLoadoutRequest(SCR_PlayerLoadoutComponent component, int loadoutIndex)
810 {
811 m_wLoadingSpinner.SetVisible(true);
812 }
813
815 protected void OnPlayerLoadoutResponse(SCR_PlayerLoadoutComponent component, int loadoutIndex, bool response)
816 {
817 if (response)
818 {
819 m_LoadoutRequestUIHandler.RefreshLoadoutPreview();
820 m_RespawnButton.SetEnabled(true);
821 m_RespawnButton.SetSupplyCost(GetLoadoutCost(component));
822 }
823
824 m_wLoadingSpinner.SetVisible(false);
827 }
828
829 //----------------------------------------------------------------------------------------------
830 protected void OnPlayerFactionSet(Faction assignedFaction)
831 {
832 if (!assignedFaction)
833 return;
834
836 m_LoadoutRequestUIHandler.ShowAvailableLoadouts(assignedFaction);
837
839 m_GroupRequestUIHandler.ShowAvailableGroups(assignedFaction);
840
842 m_SpawnPointRequestUIHandler.ShowAvailableSpawnPoints(assignedFaction);
843
844 }
845
847 protected void OnChatToggle()
848 {
849 if (!m_ChatPanel)
850 {
851 Widget chat = GetRootWidget().FindAnyWidget("ChatPanel");
852 if (chat)
853 m_ChatPanel = SCR_ChatPanel.Cast(chat.FindHandler(SCR_ChatPanel));
854 }
855
856 if (!m_ChatPanel || m_ChatPanel.IsOpen())
857 return;
858
860 }
861
863 protected void OnPauseMenu()
864 {
865 MenuBase menu = GetGame().GetMenuManager().OpenMenu(ChimeraMenuPreset.PauseMenu, 0, true, false);
866
867 PauseMenuUI pauseMenu = PauseMenuUI.Cast(menu);
868 if (pauseMenu)
869 {
870 pauseMenu.FadeBackground(true, true);
871 pauseMenu.DisableSettings();
872 }
873 }
874
876 protected void OnRespawnRequest(SCR_SpawnRequestComponent requestComponent)
877 {
878 m_bRespawnRequested = true;
879 GetRootWidget().SetEnabled(false);
880 m_RespawnButton.SetEnabled(false);
881 m_RespawnButton.ShowLoading(false);
882 m_wLoadingSpinner.SetVisible(true);
883
885 }
886
888 protected void OnRespawnResponse(SCR_SpawnRequestComponent requestComponent, SCR_ESpawnResult response)
889 {
890 GetRootWidget().SetEnabled(true);
891 m_wLoadingSpinner.SetVisible(false);
892 if (response != SCR_ESpawnResult.OK)
893 {
894 m_RespawnButton.SetEnabled(true);
895 m_RespawnButton.ShowLoading(true);
896 }
897 m_bRespawnRequested = false;
898 }
899
901 protected void UpdateRespawnButton()
902 {
903 int remainingTime = -1;
904
906 remainingTime = m_ActiveRespawnTimer.GetPlayerRemainingTime(m_iPlayerId);
907
908 bool hasGroup = true;
910 hasGroup = m_GroupRequestUIHandler.GetPlayerGroup();
911 m_RespawnButton.SetEnabled(!m_bRespawnRequested && remainingTime <= 0 && m_fCurrentDeployTimeOut <= 0 && m_bCanRespawnAtSpawnPoint && m_PlyLoadoutComp.GetLoadout() != null && hasGroup);
912 }
913
914 protected void OpenGroupMenu()
915 {
916 SCR_GroupsManagerComponent groupManager = SCR_GroupsManagerComponent.GetInstance();
917 if (!groupManager || !groupManager.IsGroupMenuAllowed())
918 return;
919
920 GetGame().GetMenuManager().OpenDialog(ChimeraMenuPreset.GroupMenu);
921 }
922
923 //------------------------------------------------------------------------------------------------
925 static SCR_DeployMenuMain OpenDeployMenu()
926 {
927 GetGame().GetMenuManager().CloseAllMenus();
928 if (!GetDeployMenu())
929 GetGame().GetMenuManager().OpenMenu(ChimeraMenuPreset.RespawnSuperMenu);
930
931 return GetDeployMenu();
932 }
933
934 //------------------------------------------------------------------------------------------------
936 static void CloseDeployMenu()
937 {
938 GetGame().GetMenuManager().CloseMenuByPreset(ChimeraMenuPreset.RespawnSuperMenu);
939 }
940
941 //------------------------------------------------------------------------------------------------
943 static SCR_DeployMenuMain GetDeployMenu()
944 {
945 return SCR_DeployMenuMain.Cast(GetGame().GetMenuManager().FindMenuByPreset(ChimeraMenuPreset.RespawnSuperMenu));
946 }
947
948 //------------------------------------------------------------------------------------------------
955
956 //------------------------------------------------------------------------------------------------
966};
967
968//------------------------------------------------------------------------------------------------
971{
972 [Attribute("TextHint")]
973 protected string m_sText;
974
975 [Attribute("ShortcutInput")]
976 protected string m_sShortcutName;
977
978 [Attribute("HorizontalLayout1")]
979 protected string m_sTextHolderName;
980
984
985 [Attribute("Spinner")]
986 protected string m_sLoadingSpinner;
987
988 [Attribute("Background")]
989 protected string m_sBackground;
990
997
999
1000 protected int m_iSupplyCost;
1001 protected bool m_bSuppliesEnabled;
1002
1003 //------------------------------------------------------------------------------------------------
1004 override void HandlerAttached(Widget w)
1005 {
1006 super.HandlerAttached(w);
1007
1008 m_wText = TextWidget.Cast(w.FindAnyWidget(m_sText));
1009 m_wShortcut = w.FindAnyWidget(m_sShortcutName);
1010 m_wTextHolder = w.FindAnyWidget(m_sTextHolderName);
1011 m_wLoadingSpinner = w.FindAnyWidget(m_sLoadingSpinner);
1013 m_wSupplies = w.FindAnyWidget("w_Supplies");
1014 m_wBackgroundWidget = w.FindAnyWidget(m_sBackground);
1015
1018
1019 if (m_wSupplies)
1020 m_wSuppliesText = RichTextWidget.Cast(m_wSupplies.FindAnyWidget("SuppliesLoadoutText"));
1021 }
1022
1023 //------------------------------------------------------------------------------------------------
1026 //----------------------------------------------------------------------------------------------
1027 void SetSuppliesEnabled(bool enabled)
1028 {
1029 m_bSuppliesEnabled = enabled;
1030 }
1031
1032 //------------------------------------------------------------------------------------------------
1035 //----------------------------------------------------------------------------------------------
1036 void SetSupplyCost(int cost)
1037 {
1038 m_iSupplyCost = cost;
1039 }
1040
1041 //------------------------------------------------------------------------------------------------
1044 //----------------------------------------------------------------------------------------------
1046 {
1047 return m_iSupplyCost;
1048 }
1049
1050 //------------------------------------------------------------------------------------------------
1052 void SetText(bool deployEnabled, string text, float remainingTime = -1)
1053 {
1054 if (!m_wText)
1055 return;
1056
1057 if (m_wShortcut)
1058 m_wShortcut.SetVisible(deployEnabled && remainingTime <= 0);
1059
1060 if (!text.IsEmpty())
1061 {
1062 if (remainingTime >= 0)
1063 {
1064 string respawnTime = SCR_FormatHelper.GetTimeFormatting(remainingTime, ETimeFormatParam.DAYS | ETimeFormatParam.HOURS, ETimeFormatParam.DAYS | ETimeFormatParam.HOURS | ETimeFormatParam.MINUTES);
1065 m_wText.SetTextFormat(text, respawnTime);
1066 return;
1067 }
1068
1069 m_wText.SetText(text);
1070
1071 if (m_wSupplies)
1072 m_wSupplies.SetVisible(m_iSupplyCost > 0 && m_bSuppliesEnabled);
1073
1074 if (m_wSuppliesText)
1075 m_wSuppliesText.SetText(string.ToString(m_iSupplyCost));
1076 return;
1077 }
1078
1079 //~ Empty string given string
1080 if (remainingTime >= 0)
1081 {
1082 string respawnTime = SCR_FormatHelper.GetTimeFormatting(remainingTime, ETimeFormatParam.DAYS | ETimeFormatParam.HOURS, ETimeFormatParam.DAYS | ETimeFormatParam.HOURS | ETimeFormatParam.MINUTES);
1083 m_wText.SetTextFormat("ERROR %1", respawnTime);
1084 return;
1085 }
1086
1087 m_wText.SetText("ERROR");
1088 }
1089
1090 //------------------------------------------------------------------------------------------------
1092 void UpdateSpinner(float timeSlice)
1093 {
1094 if (m_wLoadingSpinner && m_wLoadingSpinner.IsVisible())
1095 m_LoadingSpinner.Update(timeSlice);
1096 }
1097
1098 //------------------------------------------------------------------------------------------------
1100 void ShowLoading(bool show)
1101 {
1102 m_wTextHolder.SetVisible(show);
1103 m_wLoadingSpinner.SetVisible(!show);
1104 }
1105
1106 //------------------------------------------------------------------------------------------------
1109 {
1110 Color color;
1111 if (!m_wRoot.IsEnabled())
1112 color = m_ActionDisabled;
1113 else
1114 color = m_ActionDefault;
1115
1116 m_wBackgroundWidget.SetColor(color);
1117 }
1118}
AddonBuildInfoTool id
ChimeraMenuPreset
Menu presets.
EEntityCatalogType
SCR_EPauseReason
Definition EPauseReason.c:2
ETimeFormatParam
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_BaseGameMode GetGameMode()
void OnMapOpen(MapConfiguration config)
void NextSpawn()
Select next available spawn point.
void UpdateRespawnButton()
Sets respawn button enabled based on certain conditions.
SCR_SpawnPointRequestUIComponent GetSpawnPointRequestHandler()
SCR_RespawnSystemComponent m_RespawnSystemComp
void SetInitialSpawnPoint(RplId spawnPointId)
Sets initial spawn point when the deploy map is open for the first time.
OnSpawnPointRplIdSetInvoker GetOnSpawnPointRplIdSet()
int m_iPreviousTime
bool m_bRespawnRequested
void OnChatToggle()
Toggle chat.
bool m_bMapContextAllowed
void FocusOnPoint(notnull SCR_SpawnPoint spawnPoint, bool smooth=true)
Centers map to a specific spawn point.
void OnMapOpen(MapConfiguration config)
func OnSpawnPointRplIdSet
void OnPlayerFactionResponse(SCR_PlayerFactionAffiliationComponent component, int factionIndex, bool response)
Callback when faction request receives a response.
bool m_bCanRespawnAtSpawnPoint
ref OnSpawnPointRplIdSetInvoker m_OnSpawnPointSet
SCR_DeployMenuBase m_MenuHandler
Main deploy menu with the map present.
SCR_PlayerDeployMenuHandlerComponent m_PlayerMenuHandler
const float DEPLOY_TIME_OUT
void OnPlayerLoadoutResponse(SCR_PlayerLoadoutComponent component, int loadoutIndex, bool response)
Callback when loadout request receives a response.
SCR_PlayerLoadoutComponent m_PlyLoadoutComp
int GetLoadoutCost(SCR_PlayerLoadoutComponent component)
void PrevSpawn()
Select previous available spawn point.
ScriptInvokerBase< OnSpawnPointRplIdSet > OnSpawnPointRplIdSetInvoker
void AllowMapContext(bool allow)
Sets map context active based on whether or not any of the selectors are focused with a gamepad.
void OnPlayerFactionSet(Faction assignedFaction)
SCR_RespawnTimerComponent m_PlayerRespawnTimer
void InitMapDeploy()
Initializes the map with deploy menu config.
void FindRequestHandlers()
Find all components in the layout that are needed in order for deploy menu to function correctly.
void OnLocalPlayerGroupJoined(SCR_AIGroup group)
Callback when player joins a group.
SCR_TimedSpawnPointComponent m_TimedSpawnPointTimer
void SetSpawnPointExt(RplId id)
Sets spawn point from an external source (ie. by clicking the spawn point icon).
SCR_PlayerFactionAffiliationComponent m_PlyFactionAffilComp
bool GetAllowMapContext()
float m_fCurrentDeployTimeOut
Widget m_wLoadingSpinner
void OnRespawnRequest(SCR_SpawnRequestComponent requestComponent)
Callback when respawn request was sent for the player.
SCR_InputButtonComponent m_GroupOpenButton
SCR_GroupRequestUIComponent m_GroupRequestUIHandler
void HideLoading()
Hides loading spinner widget.
const float CHECK_CAN_SPAWN_SPAWNPOINT_TIME
Widget m_wMenuFrame
SCR_UIInfoSpawnRequestResult m_UIInfoSpawnRequestResult
float m_fCurrentCanSpawnUpdateTime
bool m_bInitialSpawnPointSet
SCR_RespawnComponent m_SpawnRequestManager
void HookEvents()
Initialize necessary callbacks.
SCR_LoadoutRequestUIComponent m_LoadoutRequestUIHandler
void OnRespawnResponse(SCR_SpawnRequestComponent requestComponent, SCR_ESpawnResult response)
Callback when player respawn request received a response.
Widget m_wRespawnButton
void OnSpawnPointSelected(RplId id)
SCR_MapUIElementContainer m_UIElementContainer
bool m_bSuppliesEnabled
void ResetRespawnResultVars()
void OnPlayerLoadoutRequest(SCR_PlayerLoadoutComponent component, int loadoutIndex)
Callback when player requests a loadout.
void OnPauseMenu()
Opens pause menu.
void SetSpawnPoint(RplId id, bool smoothPan=true)
Sets the currently selected spawn point.
SCR_LoadingSpinner m_LoadingSpinner
SCR_SpawnPointRequestUIComponent m_SpawnPointRequestUIHandler
SCR_BaseGameMode m_GameMode
void OnPlayerFactionRequest(SCR_PlayerFactionAffiliationComponent component, int factionIndex)
Callback when player requests a faction.
SCR_RespawnTimerComponent m_ActiveRespawnTimer
bool m_bDisplayTime
ref MapConfiguration m_MapConfigDeploy
SCR_DeployButton m_RespawnButton
void OnCanRespawnRequestResponse(SCR_SpawnRequestComponent requestComponent, SCR_ESpawnResult response, SCR_SpawnData data)
RplId m_iSelectedSpawnPointId
void OpenGroupMenu()
const string FALLBACK_DEPLOY_STRING
SCR_ESpawnResult
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
Get all prefabs that have the spawner data
Widget m_wRoot
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
EMapEntityMode
Mode of the map.
SCR_MapEntity m_MapEntity
Widget GetRootWidget()
SCR_FactionManager m_FactionManager
SCR_PlayerDeployMenuHandlerComponentClass m_RespawnComponent
Component responsible for deploy menu management.
ScriptInvokerBase< OnDeployMenuOpenDelegate > OnDeployMenuOpenInvoker
void RequestRespawn()
Sends a respawn request based on assigned loadout and selected spawn point.
void SCR_RespawnComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
void SCR_RespawnTimerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
proto native bool IsOpen()
static WidgetAnimationOpacity Opacity(Widget widget, float targetValue, float speed, bool toggleVisibility=false)
static ref ScriptInvoker m_onExitLoadingScreen
Constant variables used in various menus.
override void OnMenuFocusGained()
override void OnMenuUpdate(float tDelta)
override void OnMenuFocusLost()
Definition Color.c:13
Definition Debug.c:13
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
Replication item identifier.
Definition RplId.c:14
bool PauseGame(bool pause, SCR_EPauseReason reason=SCR_EPauseReason.SYSTEM)
static SCR_ChatPanelManager GetInstance()
Returns SCR_ChatPanelManager instance.
void ToggleChatPanel(notnull SCR_ChatPanel panel)
Toggles the chat panel: opens if it's closed, closes if it's open.
Component that handles the request respawn button.
void ShowLoading(bool show)
Set loading spinner widget visible.
void UpdateSpinner(float timeSlice)
Update the loading spinner widget.
void SetText(bool deployEnabled, string text, float remainingTime=-1)
Set text of the button.
void SetSupplyCost(int cost)
RichTextWidget m_wSuppliesText
override void HandlerAttached(Widget w)
SCR_LoadingSpinner m_LoadingSpinner
void SetSuppliesEnabled(bool enabled)
void UpdateBackground()
Change color of background depending on if button is enabled.
Base deploy menu class.
override void OnMenuOpen()
override void OnMenuOpened()
void MuteSounds(bool mute=true)
static OnDeployMenuOpenInvoker SGetOnMenuOpen()
SCR_InputButtonComponent m_ChatButton
SCR_InputButtonComponent m_PauseButton
SCR_MapEntity m_MapEntity
override void OnMenuClose()
override void OnMenuHide()
SCR_InputButtonComponent m_GameMasterButton
void OnEditorLimitedChanged(bool limited)
If limited, don't show the game master switch button.
static ref OnDeployMenuOpenInvoker s_OnMenuOpen
SCR_ChatPanel m_ChatPanel
Get prefab entity Data of type Ignores disabled Data s param dataType class of Data type you with to obtain return Entity Data of given type Null if not found *SCR_BaseEntityCatalogData GetEntityDataOfType(typename dataType)
Component responsible for handling group requests and visualization in deploy menu.
static SCR_InputButtonComponent GetInputButtonComponent(string name, notnull Widget parent, bool searchAllChildren=true)
ScriptInvokerVoid GetOnUpdateEnableColor()
Component responsible for requesting and visualization of available loadouts in deploy menu.
static SCR_MapEntity GetMapInstance()
Get map entity instance.
Spawn point entity defines positions on which players can possibly spawn.
static SCR_SpawnPoint GetSpawnPointByRplId(RplId id)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute
EActionTrigger
void RequestRespawn()
Sends a respawn request based on assigned loadout and selected spawn point.
proto external string ToString()
Plain C++ pointer, no weak pointers, no memory management.