Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_WelcomeScreenComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/GameMode/Components", description: "Welcome screen shown in respawn menu.")]
5
7class SCR_WelcomeScreenComponent : SCR_DeployMenuBaseScreenComponent
8{
9};
15 [Attribute(defvalue: "{16B14338A8911683}UI/layouts/Menus/DeployMenu/WelcomeScreenThreeHorizontalColumns.layout")]
17
19 protected ref SCR_WelcomeScreenBaseContent m_LeftColumn;
21 [Attribute()]
22 protected ref SCR_WelcomeScreenBaseContent m_MiddleColumn;
24 [Attribute()]
25 protected ref SCR_WelcomeScreenBaseContent m_RightColumn;
26
27 protected const string WELCOME_CONTENT = "WelcomeContent";
28
29 protected const string LEFT_COLUMN = "LeftColumn";
30 protected const string MIDDLE_COLUMN = "MiddleColumn";
31 protected const string RIGHT_COLUMN = "RightColumn";
32
33 protected const string LEFT_COLUMN_BUTTON = "LeftColumnButton";
34 protected const string MIDDLE_COLUMN_BUTTON = "MiddleColumnButton";
35 protected const string RIGHT_COLUMN_BUTTON = "RightColumnButton";
36
37 //------------------------------------------------------------------------------------------------
39 {
40 Widget targetColumn = menu.GetRootWidget().FindAnyWidget(WELCOME_CONTENT);
41 if (!targetColumn)
42 return;
43
44 Widget threeHorizontalColumns = GetGame().GetWorkspace().CreateWidgets(m_sThreeHorizontalColumnsLayout, targetColumn);
45
46 if (m_LeftColumn)
47 {
50 }
51
53 {
56 }
57
58 if (m_RightColumn)
59 {
62 }
63 }
64}
65
68class SCR_WelcomeScreenBaseContent : ScriptAndConfig
69{
70 [Attribute()]
71 protected bool m_bIsInteractible;
72
73 protected string m_sContentName;
74
75 //------------------------------------------------------------------------------------------------
80 void InitContent(SCR_WelcomeScreenMenu menu, string column, string columnButton)
81 {
82 m_sContentName = column;
83 }
84
85 //------------------------------------------------------------------------------------------------
88 void ToggleInteractions(bool enabled);
89
90 //------------------------------------------------------------------------------------------------
92 string GetContentName()
93 {
94 return m_sContentName;
95 }
96
97 //------------------------------------------------------------------------------------------------
100 bool GetIsInteractible()
101 {
102 return m_bIsInteractible;
103 }
104}
105
108class SCR_WelcomeScreenMissionObjectivesContent : SCR_WelcomeScreenBaseContent
109{
110 [Attribute()]
111 protected string m_sTitleText;
112
113 [Attribute()]
114 protected ref array<ref SCR_WelcomeScreenMissionObjectives> m_aMissionObjectives;
115
116 [Attribute()]
117 protected string m_sBottomTitleText;
118
119 protected Widget m_wMissionObjectivesWidget;
120 protected int m_iObjectivesCount;
121
122 [Attribute(defvalue: "{ECDF3386111C93B6}UI/layouts/Menus/DeployMenu/WelcomeScreenMissionObjectivesColumn.layout")]
123 protected ResourceName m_sMissionObjectivesColumnLayout;
124
125 [Attribute(defvalue: "{B03D5FCC04D25B95}UI/layouts/Menus/DeployMenu/WelcomeScreenMissionObjective.layout")]
126 protected ResourceName m_sMissionObjectiveLayout;
127
128 //------------------------------------------------------------------------------------------------
129 override void InitContent(SCR_WelcomeScreenMenu menu, string column, string columnButton)
130 {
131 m_sContentName = column;
132
133 if (!m_aMissionObjectives)
134 return;
135
136 m_iObjectivesCount = m_aMissionObjectives.Count();
137 Widget targetColumn = menu.GetRootWidget().FindAnyWidget(column);
138 if (!targetColumn)
139 return;
140
141 m_wMissionObjectivesWidget = GetGame().GetWorkspace().CreateWidgets(m_sMissionObjectivesColumnLayout, targetColumn);
142 if (!m_wMissionObjectivesWidget)
143 return;
144
145 Widget missionObjectivesContent = m_wMissionObjectivesWidget.FindAnyWidget("MiddleContentVertical");
146 if (!missionObjectivesContent)
147 return;
148
149 FillMissionObjectivesWidget(missionObjectivesContent)
150 }
151
152 //------------------------------------------------------------------------------------------------
155 protected void FillMissionObjectivesWidget(Widget content)
156 {
157 RichTextWidget titleText = RichTextWidget.Cast(m_wMissionObjectivesWidget.FindAnyWidget("TitleText"));
158 if (titleText)
159 titleText.SetText(GetTitleText());
160
161 array<ref SCR_WelcomeScreenMissionObjectives> objectives = {};
162 SCR_WelcomeScreenMissionObjectives objective;
163 int objectivesCount;
164 objectivesCount = GetMissionObjectives(objectives);
165
166 int cycleCount;
167 if (objectivesCount < 11)
168 cycleCount = objectivesCount;
169 else
170 cycleCount = 10;
171
172 //Mission objectives are capped for 10 at the time
173 for (int i = 0; i < cycleCount; ++i)
174 {
175 objective = objectives[i];
176 objectivesCount--;
177 Widget cond = GetGame().GetWorkspace().CreateWidgets(m_sMissionObjectiveLayout, content);
178 if (!cond)
179 break;
180
181 RichTextWidget name = RichTextWidget.Cast(cond.FindAnyWidget("ObjectiveText"));
182 if (name)
183 name.SetText(objective.GetDescription());
184
185 ImageWidget icon = ImageWidget.Cast(cond.FindAnyWidget("Icon"));
186 if (icon)
187 icon.LoadImageFromSet(0, objective.GetImageSet(), objective.GetObjectiveQuadName(), false);
188 }
189
190 RichTextWidget bottomTitleText = RichTextWidget.Cast(m_wMissionObjectivesWidget.FindAnyWidget("BottomTitleText"));
191 if (!bottomTitleText)
192 return;
193
194 if (objectivesCount < 1)
195 bottomTitleText.SetOpacity(0);
196 else
197 bottomTitleText.SetTextFormat(GetBottomTitleText(), objectivesCount);
198 }
199
200 //------------------------------------------------------------------------------------------------
204 int GetMissionObjectives(out array<ref SCR_WelcomeScreenMissionObjectives> missionObjectives)
205 {
206 missionObjectives = m_aMissionObjectives;
207
208 return m_aMissionObjectives.Count();
209 }
210
211 //------------------------------------------------------------------------------------------------
213 string GetTitleText()
214 {
215 return m_sTitleText;
216 }
217
218 //------------------------------------------------------------------------------------------------
220 string GetBottomTitleText()
221 {
222 return m_sBottomTitleText;
223 }
224}
225
228class SCR_WelcomeScreenMissionObjectives
229{
230 [Attribute("{88966C7AB9720818}UI/Textures/DeployMenu/Objectives-Briefing/Objectives-briefing.imageset", UIWidgets.ResourcePickerThumbnail, "Image set for the icons", params: "edds")]
231 protected ResourceName m_sObjectiveImageSet;
232
233 [Attribute("faction")]
234 protected string m_sObjectiveQuadName;
235
236 [Attribute()]
237 protected string m_sDescription;
238
239 //------------------------------------------------------------------------------------------------
241 ResourceName GetImageSet()
242 {
243 return m_sObjectiveImageSet;
244 }
245
246 //------------------------------------------------------------------------------------------------
248 string GetObjectiveQuadName()
249 {
250 return m_sObjectiveQuadName;
251 }
252
253 //------------------------------------------------------------------------------------------------
255 string GetDescription()
256 {
257 return m_sDescription;
258 }
259}
260
263//[BaseContainerProps(), SCR_ContainerActionTitle()]
264class SCR_WelcomeScreenDynamicObjectivesContent : SCR_WelcomeScreenBaseContent
265{
266 [Attribute()]
267 protected string m_sTitleText;
268
269 [Attribute()]
270 protected ref array<ref SCR_WelcomeScreenDynamicTaskFaction> m_aFactions;
271
272 [Attribute(defvalue: "{0B7DDF77E24F0C63}UI/layouts/Menus/DeployMenu/WelcomeScreenDynamicObjectivesColumn.layout")]
273 protected ResourceName m_sFinishedObjectivesTileLayout;
274
275 [Attribute(defvalue: "{B03D5FCC04D25B95}UI/layouts/Menus/DeployMenu/WelcomeScreenMissionObjective.layout")]
276 protected ResourceName m_sFinishedObjectivesLayout;
277
278 protected Widget m_wFinishedObjectivesWidget;
279 protected Widget m_wPaginationWidget;
280 protected ButtonWidget m_wColumnButton;
281 protected ref array<SCR_Task> m_aObjectivesToDisplay = {};
282 protected ref array<Widget> m_aDynamicObjectivesWidgets = {};
283 protected int m_iCurrentPage;
284 protected int m_iDynamicObjectivesCount;
286
287 //------------------------------------------------------------------------------------------------
288 override void InitContent(SCR_WelcomeScreenMenu menu, string column, string columnButton)
289 {
290 m_sContentName = column;
291
292 Widget targetTile = menu.GetRootWidget().FindAnyWidget(column);
293 if (!targetTile)
294 return;
295
296 m_wFinishedObjectivesWidget = GetGame().GetWorkspace().CreateWidgets(m_sFinishedObjectivesTileLayout, targetTile);
297 if (!m_wFinishedObjectivesWidget)
298 return;
299
300 Widget finishedObjectivesContent = m_wFinishedObjectivesWidget.FindAnyWidget("FinishedObjectivesLayout");
301 if (!finishedObjectivesContent)
302 return;
303
304 m_wColumnButton = ButtonWidget.Cast(menu.GetRootWidget().FindAnyWidget(columnButton));
305 if (!m_wColumnButton)
306 return;
307
308 FillDynamicObjectivesWidget(finishedObjectivesContent);
309 InitPagination();
310 HandlePagination();
311 }
312
313 //------------------------------------------------------------------------------------------------
314 override void ToggleInteractions(bool enabled)
315 {
316 HandlePagination(enabled);
317 }
318
319 //------------------------------------------------------------------------------------------------
322 void FillDynamicObjectivesWidget(Widget content)
323 {
324 RichTextWidget titleText = RichTextWidget.Cast(m_wFinishedObjectivesWidget.FindAnyWidget("TitleText"));
325 titleText.SetText(GetTitleText());
326
327 SCR_TaskSystem taskSystem = SCR_TaskSystem.GetInstance();
328 if (!taskSystem)
329 return;
330
331 m_FactionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
332 if (!m_FactionManager)
333 return;
334
335 m_aObjectivesToDisplay.Clear();
336 taskSystem.GetTasks(m_aObjectivesToDisplay);
337 m_iDynamicObjectivesCount = m_aObjectivesToDisplay.Count();
338
339 foreach (SCR_WelcomeScreenDynamicTaskFaction faction : m_aFactions)
340 {
341 string factionKey = faction.GetFactionKey();
342 foreach (SCR_Task task : m_aObjectivesToDisplay)
343 {
344 if (!task.GetOwnerFactionKeys().Contains(factionKey))
345 continue;
346
347 faction.AddFactionTask(task);
348 }
349 }
350
351 //Statistics are capped for 10 at the time
352 m_aDynamicObjectivesWidgets.Clear();
353 for (int i = 0; i < 10; ++i)
354 {
355 Widget objective = GetGame().GetWorkspace().CreateWidgets(m_sFinishedObjectivesLayout, content);
356 m_aDynamicObjectivesWidgets.Insert(objective);
357 }
358
359 //SCR_BaseTaskManager.s_OnTaskCreated.Insert(AddTask);
360
361 //SCR_BaseTaskManager.s_OnTaskFinished.Insert(RemoveTask);
362 //SCR_BaseTaskManager.s_OnTaskCancelled.Insert(RemoveTask);
363 //SCR_BaseTaskManager.s_OnTaskFailed.Insert(RemoveTask);
364
365 FlipPage(GetCurrentPage());
366
367 m_wPaginationWidget = m_wFinishedObjectivesWidget.FindAnyWidget("BottomTitleSizeLayout");
368 if (!m_wPaginationWidget)
369 return;
370
371 if (m_iDynamicObjectivesCount < 11)
372 {
373 m_wPaginationWidget.SetOpacity(0);
374 }
375 else
376 {
377 Widget pages = m_wFinishedObjectivesWidget.FindAnyWidget("Pages");
378 if (!pages)
379 return;
380
381 SCR_SelectionHintComponent pagesVisualised = SCR_SelectionHintComponent.Cast(pages.FindHandler(SCR_SelectionHintComponent));
382 if (!pagesVisualised)
383 return;
384
385 pagesVisualised.SetItemCount(m_iDynamicObjectivesCount/10);
386 }
387 }
388
389 //------------------------------------------------------------------------------------------------
392 protected void AddTask(notnull SCR_Task task)
393 {
394 //Since this is called right after task creation, the task itself might not have the
395 //Title, faction or other properties set just yet. By introducing slight delay, we mitigate it in most cases
396 GetGame().GetCallqueue().CallLater(AddTaskCalledLater, 1000, false, task);
397 }
398
399 //------------------------------------------------------------------------------------------------
402 protected void AddTaskCalledLater(notnull SCR_Task task)
403 {
404 foreach (SCR_WelcomeScreenDynamicTaskFaction faction : m_aFactions)
405 {
406 if (!task.GetOwnerFactionKeys().Contains(faction.GetFactionKey()))
407 continue;
408
409 faction.AddFactionTask(task);
410 break;
411 }
412
413 m_aObjectivesToDisplay.Clear();
414 foreach (SCR_WelcomeScreenDynamicTaskFaction faction : m_aFactions)
415 {
416 m_aObjectivesToDisplay.InsertAll(faction.GetFactionTasks());
417 }
418
419 m_iDynamicObjectivesCount = m_aObjectivesToDisplay.Count();
420
421 FlipPage(GetCurrentPage());
422 }
423
424 //------------------------------------------------------------------------------------------------
427 protected void RemoveTask(notnull SCR_Task task)
428 {
429 foreach (SCR_WelcomeScreenDynamicTaskFaction faction : m_aFactions)
430 {
431 if (!task.GetOwnerFactionKeys().Contains(faction.GetFactionKey()))
432 continue;
433
434 faction.RemoveFactionTask(task);
435 break;
436 }
437
438 m_aObjectivesToDisplay.Clear();
439 foreach (SCR_WelcomeScreenDynamicTaskFaction faction : m_aFactions)
440 {
441 m_aObjectivesToDisplay.InsertAll(faction.GetFactionTasks());
442 }
443
444 m_iDynamicObjectivesCount = m_aObjectivesToDisplay.Count();
445
446 FlipPage(GetCurrentPage());
447 }
448
449 //------------------------------------------------------------------------------------------------
451 protected void InitPagination()
452 {
453 Widget previousButtonWidget = m_wFinishedObjectivesWidget.FindAnyWidget("PrevButton");
454 if (!previousButtonWidget)
455 return;
456
457 SCR_PagingButtonComponent previousButton = SCR_PagingButtonComponent.Cast(previousButtonWidget.FindHandler(SCR_PagingButtonComponent));
458 if (previousButton)
459 previousButton.m_OnClicked.Insert(ButtonClicked);
460
461 Widget nextButtonWidget = m_wFinishedObjectivesWidget.FindAnyWidget("NextButton");
462 if (!nextButtonWidget)
463 return;
464
465 SCR_PagingButtonComponent nextButton = SCR_PagingButtonComponent.Cast(nextButtonWidget.FindHandler(SCR_PagingButtonComponent));
466 if (nextButton)
467 nextButton.m_OnClicked.Insert(ButtonClicked);
468 }
469
470 //------------------------------------------------------------------------------------------------
472 protected void ButtonClicked()
473 {
474 GetGame().GetWorkspace().SetFocusedWidget(m_wColumnButton);
475 }
476
477 //------------------------------------------------------------------------------------------------
480 protected void HandlePagination(bool enabled = false)
481 {
482 Widget previousButtonWidget = m_wFinishedObjectivesWidget.FindAnyWidget("PrevButton");
483 if (!previousButtonWidget)
484 return;
485
486 SCR_PagingButtonComponent previousButton = SCR_PagingButtonComponent.Cast(previousButtonWidget.FindHandler(SCR_PagingButtonComponent));
487 if (!previousButton)
488 return;
489
490 if (enabled)
491 previousButton.m_OnActivated.Insert(PreviousButtonActivated);
492 else
493 previousButton.m_OnActivated.Remove(PreviousButtonActivated);
494
495 Widget nextButtonWidget = m_wFinishedObjectivesWidget.FindAnyWidget("NextButton");
496 if (!nextButtonWidget)
497 return;
498
499 SCR_PagingButtonComponent nextButton = SCR_PagingButtonComponent.Cast(nextButtonWidget.FindHandler(SCR_PagingButtonComponent));
500 if (!nextButton)
501 return;
502
503 if (enabled)
504 nextButton.m_OnActivated.Insert(NextButtonActivated);
505 else
506 nextButton.m_OnActivated.Remove(NextButtonActivated);
507 }
508
509 //------------------------------------------------------------------------------------------------
511 protected void PreviousButtonActivated()
512 {
513 int currentPage = GetCurrentPage();
514 currentPage--;
515 if (currentPage < 0)
516 return;
517
518 FlipPage(currentPage);
519 }
520
521 //------------------------------------------------------------------------------------------------
523 protected void NextButtonActivated()
524 {
525 int currentPage = GetCurrentPage();
526 currentPage++;
527 if (currentPage == Math.Ceil(m_iDynamicObjectivesCount/10))
528 return;
529
530 FlipPage(currentPage);
531 }
532
533 //------------------------------------------------------------------------------------------------
536 protected void FlipPage(int currentPage)
537 {
538 for (int i = 0; i < 10; ++i)
539 {
540 if (!m_aDynamicObjectivesWidgets[i])
541 continue;
542
543 m_aDynamicObjectivesWidgets[i].SetOpacity(1);
544 if (currentPage == 0)
545 {
546 if (i < m_iDynamicObjectivesCount)
547 {
548 RichTextWidget name = RichTextWidget.Cast(m_aDynamicObjectivesWidgets[i].FindAnyWidget("ObjectiveText"));
549 SCR_EditorTask editorTask = SCR_EditorTask.Cast(m_aObjectivesToDisplay[i]);
550 SCR_CampaignMilitaryBaseTaskEntity campaignTask = SCR_CampaignMilitaryBaseTaskEntity.Cast(m_aObjectivesToDisplay[i]);
551 if (editorTask)
552 name.SetTextFormat(editorTask.GetTaskName(), editorTask.GetLocationName());
553 else if (campaignTask)
554 name.SetTextFormat(campaignTask.GetTaskName(), campaignTask.GetMilitaryBase().GetCallsign());
555 else
556 name.SetText(m_aObjectivesToDisplay[i].GetTaskName());
557
558 ImageWidget image = ImageWidget.Cast(m_aDynamicObjectivesWidgets[i].FindAnyWidget("Background"));
559 image.SetColor(m_FactionManager.GetFactionByKey(m_aObjectivesToDisplay[i].GetOwnerFactionKeys()[0]).GetFactionColor());
560 }
561 else
562 {
563 m_aDynamicObjectivesWidgets[i].SetOpacity(0);
564 }
565 }
566 else
567 {
568 if ((currentPage * 10) + i < m_iDynamicObjectivesCount)
569 {
570 RichTextWidget name = RichTextWidget.Cast(m_aDynamicObjectivesWidgets[i].FindAnyWidget("ObjectiveText"));
571 SCR_EditorTask editorTask = SCR_EditorTask.Cast(m_aObjectivesToDisplay[(currentPage * 10) + i]);
572 SCR_CampaignMilitaryBaseTaskEntity campaignTask = SCR_CampaignMilitaryBaseTaskEntity.Cast(m_aObjectivesToDisplay[(currentPage * 10) + i]);
573 if (editorTask)
574 name.SetTextFormat(editorTask.GetTaskName(), editorTask.GetLocationName());
575 else if (campaignTask)
576 name.SetTextFormat(campaignTask.GetTaskName(), campaignTask.GetMilitaryBase().GetCallsign());
577 else
578 name.SetText(m_aObjectivesToDisplay[(currentPage * 10) + i].GetTaskName());
579
580 ImageWidget image = ImageWidget.Cast(m_aDynamicObjectivesWidgets[i].FindAnyWidget("Background"));
581 image.SetColor(m_FactionManager.GetFactionByKey(m_aObjectivesToDisplay[(currentPage * 10) + i].GetOwnerFactionKeys()[0]).GetFactionColor());
582 }
583 else
584 {
585 m_aDynamicObjectivesWidgets[i].SetOpacity(0);
586 }
587 }
588 }
589
590 SetCurrentPage(currentPage);
591
592 if (m_wPaginationWidget)
593 {
594 if (m_iDynamicObjectivesCount < 11)
595 m_wPaginationWidget.SetOpacity(0);
596 else
597 m_wPaginationWidget.SetOpacity(1);
598
599 Widget pages = m_wFinishedObjectivesWidget.FindAnyWidget("Pages");
600 if (!pages)
601 return;
602
603 SCR_SelectionHintComponent pagesVisualised = SCR_SelectionHintComponent.Cast(pages.FindHandler(SCR_SelectionHintComponent));
604 if (!pagesVisualised)
605 return;
606
607 pagesVisualised.SetItemCount(m_iDynamicObjectivesCount/10);
608 pagesVisualised.SetCurrentItem(currentPage);
609 }
610 }
611
612 //------------------------------------------------------------------------------------------------
614 int GetCurrentPage()
615 {
616 return m_iCurrentPage;
617 }
618
619 //------------------------------------------------------------------------------------------------
623 void SetCurrentPage(int page)
624 {
625 m_iCurrentPage = page;
626 }
627
628 //------------------------------------------------------------------------------------------------
630 string GetTitleText()
631 {
632 return m_sTitleText;
633 }
634}
635
638class SCR_WelcomeScreenDynamicTaskFaction
639{
640 [Attribute()]
641 protected string m_sFactionKey;
642
643 [Attribute()]
644 protected ref array<SCR_Task> m_aFactionTasks = {};
645
646 //------------------------------------------------------------------------------------------------
648 array<SCR_Task> GetFactionTasks()
649 {
650 return m_aFactionTasks;
651 }
652
653 //------------------------------------------------------------------------------------------------
655 string GetFactionKey()
656 {
657 return m_sFactionKey;
658 }
659
660 //------------------------------------------------------------------------------------------------
663 void AddFactionTask(notnull SCR_Task task)
664 {
665 if (!m_aFactionTasks.Contains(task))
666 m_aFactionTasks.Insert(task);
667 }
668
669 //------------------------------------------------------------------------------------------------
672 void RemoveFactionTask(notnull SCR_Task task)
673 {
674 m_aFactionTasks.RemoveItem(task);
675 }
676}
677
680class SCR_WelcomeScreenIntroductionContent : SCR_WelcomeScreenBaseContent
681{
682 [Attribute()]
683 protected string m_sTitleText;
684
685 [Attribute()]
686 protected ref array<ref SCR_WelcomeScreenIntroduction> m_aIntroduction;
687
688 protected int m_iCurrentPage;
689 protected int m_iIntroductionCount;
690
691 [Attribute(defvalue: "{49EEED554D68F43A}UI/layouts/Menus/DeployMenu/WelcomeScreenIntroductionColumn.layout")]
692 protected ResourceName m_sIntroductionColumnLayout;
693
694 protected Widget m_wIntroductionContentWidget;
695 protected ButtonWidget m_wColumnButton;
696
697 //------------------------------------------------------------------------------------------------
698 override void InitContent(SCR_WelcomeScreenMenu menu, string column, string columnButton)
699 {
700 m_sContentName = column;
701
702 if (!m_aIntroduction)
703 return;
704
705 m_iIntroductionCount = m_aIntroduction.Count();
706 Widget targetColumn = menu.GetRootWidget().FindAnyWidget(column);
707 if (!targetColumn)
708 return;
709
710 m_wColumnButton = ButtonWidget.Cast(menu.GetRootWidget().FindAnyWidget(columnButton));
711 if (!m_wColumnButton)
712 return;
713
714 m_wIntroductionContentWidget = GetGame().GetWorkspace().CreateWidgets(m_sIntroductionColumnLayout, targetColumn);
715 if (!m_wIntroductionContentWidget)
716 return;
717
718 FillIntroductionWidget(targetColumn);
719 }
720
721 //------------------------------------------------------------------------------------------------
722 override void ToggleInteractions(bool enabled)
723 {
724 HandlePagination(enabled);
725 }
726
727 //------------------------------------------------------------------------------------------------
730 protected void FillIntroductionWidget(Widget column)
731 {
732 RichTextWidget titleTextContent = RichTextWidget.Cast(column.FindAnyWidget("TitleText"));
733 if (titleTextContent)
734 titleTextContent.SetText(GetTitleText());
735
736 array<ref SCR_WelcomeScreenIntroduction> introductionPages = {};
737 int introductionCount = GetIntroduction(introductionPages);
738 if (introductionCount == 0)
739 return;
740
741 Widget contentVertical = m_wIntroductionContentWidget.FindAnyWidget("ContentVertical");
742 if (!contentVertical)
743 return;
744
745 ImageWidget imageWidget = ImageWidget.Cast(contentVertical.FindAnyWidget("ImageWidget"));
746 if (imageWidget && introductionPages[0].GetImage())
747 imageWidget.LoadImageTexture(0, introductionPages[0].GetImage(), false, false);
748
749 RichTextWidget titleText = RichTextWidget.Cast(contentVertical.FindAnyWidget("TitleText"));
750 if (titleText)
751 titleText.SetText(introductionPages[0].GetTitleText());
752
753 RichTextWidget descriptionText = RichTextWidget.Cast(contentVertical.FindAnyWidget("DescriptionText"));
754 if (descriptionText)
755 descriptionText.SetText(introductionPages[0].GetDescriptionText());
756
757 Widget pages = m_wIntroductionContentWidget.FindAnyWidget("Pages");
758 if (!pages)
759 return;
760
761 SCR_SelectionHintComponent pagesVisualised = SCR_SelectionHintComponent.Cast(pages.FindHandler(SCR_SelectionHintComponent));
762 if (!pagesVisualised)
763 return;
764
765 Widget pagination = m_wIntroductionContentWidget.FindAnyWidget("Pagination");
766 if (!pagination)
767 return;
768
769 if (introductionCount == 1)
770 {
771 pagination.SetOpacity(0);
772 }
773 else
774 {
775 pagesVisualised.SetItemCount(introductionCount);
776 InitPagination();
777 HandlePagination();
778 }
779 }
780
781 //------------------------------------------------------------------------------------------------
783 protected void InitPagination()
784 {
785 Widget previousButtonWidget = m_wIntroductionContentWidget.FindAnyWidget("PrevButton");
786 if (!previousButtonWidget)
787 return;
788
789 SCR_PagingButtonComponent previousButton = SCR_PagingButtonComponent.Cast(previousButtonWidget.FindHandler(SCR_PagingButtonComponent));
790 if (previousButton)
791 previousButton.m_OnClicked.Insert(ButtonClicked);
792
793 Widget nextButtonWidget = m_wIntroductionContentWidget.FindAnyWidget("NextButton");
794 if (!nextButtonWidget)
795 return;
796
797 SCR_PagingButtonComponent nextButton = SCR_PagingButtonComponent.Cast(nextButtonWidget.FindHandler(SCR_PagingButtonComponent));
798 if (nextButton)
799 nextButton.m_OnClicked.Insert(ButtonClicked);
800 }
801
802 //------------------------------------------------------------------------------------------------
804 protected void ButtonClicked()
805 {
806 GetGame().GetWorkspace().SetFocusedWidget(m_wColumnButton);
807 }
808
809 //------------------------------------------------------------------------------------------------
812 protected void HandlePagination(bool enabled = false)
813 {
814 Widget previousButtonWidget = m_wIntroductionContentWidget.FindAnyWidget("PrevButton");
815 if (!previousButtonWidget)
816 return;
817
818 SCR_PagingButtonComponent previousButton = SCR_PagingButtonComponent.Cast(previousButtonWidget.FindHandler(SCR_PagingButtonComponent));
819 if (!previousButton)
820 return;
821
822 if (enabled)
823 previousButton.m_OnActivated.Insert(PreviousButtonActivated);
824 else
825 previousButton.m_OnActivated.Remove(PreviousButtonActivated);
826
827 Widget nextButtonWidget = m_wIntroductionContentWidget.FindAnyWidget("NextButton");
828 if (!nextButtonWidget)
829 return;
830
831 SCR_PagingButtonComponent nextButton = SCR_PagingButtonComponent.Cast(nextButtonWidget.FindHandler(SCR_PagingButtonComponent));
832 if (!nextButton)
833 return;
834
835 if (enabled)
836 nextButton.m_OnActivated.Insert(NextButtonActivated);
837 else
838 nextButton.m_OnActivated.Remove(NextButtonActivated);
839 }
840
841 //------------------------------------------------------------------------------------------------
843 protected void PreviousButtonActivated()
844 {
845 int currentPage = GetCurrentPage();
846 currentPage--;
847 if (currentPage < 0)
848 return;
849
850 FlipPage(currentPage)
851 }
852
853 //------------------------------------------------------------------------------------------------
855 protected void NextButtonActivated()
856 {
857 int currentPage = GetCurrentPage();
858 currentPage++;
859 if (currentPage == m_iIntroductionCount)
860 return;
861
862 FlipPage(currentPage)
863 }
864
865 //------------------------------------------------------------------------------------------------
868 protected void FlipPage(int currentPage)
869 {
870 Widget contentVertical = m_wIntroductionContentWidget.FindAnyWidget("ContentVertical");
871 if (!contentVertical)
872 return;
873
874 SetCurrentPage(currentPage);
875 SCR_WelcomeScreenIntroduction targetIntroduction = m_aIntroduction[currentPage];
876 if (!targetIntroduction)
877 return;
878
879 ImageWidget imageWidget = ImageWidget.Cast(contentVertical.FindAnyWidget("ImageWidget"));
880 if (imageWidget && targetIntroduction.GetImage())
881 imageWidget.LoadImageTexture(0, targetIntroduction.GetImage(), false, false);
882
883 RichTextWidget titleText = RichTextWidget.Cast(contentVertical.FindAnyWidget("TitleText"));
884 if (titleText)
885 titleText.SetText(targetIntroduction.GetTitleText());
886
887 RichTextWidget descriptionText = RichTextWidget.Cast(contentVertical.FindAnyWidget("DescriptionText"));
888 if (descriptionText)
889 descriptionText.SetText(targetIntroduction.GetDescriptionText());
890
891 Widget pages = m_wIntroductionContentWidget.FindAnyWidget("Pages");
892 if (!pages)
893 return;
894
895 SCR_SelectionHintComponent pagesVisualised = SCR_SelectionHintComponent.Cast(pages.FindHandler(SCR_SelectionHintComponent));
896 if (!pagesVisualised)
897 return;
898
899 pagesVisualised.SetCurrentItem(currentPage);
900 }
901
902 //------------------------------------------------------------------------------------------------
906 int GetIntroduction(out array<ref SCR_WelcomeScreenIntroduction> introduction)
907 {
908 introduction = m_aIntroduction;
909
910 return m_aIntroduction.Count();
911 }
912
913 //------------------------------------------------------------------------------------------------
915 string GetTitleText()
916 {
917 return m_sTitleText;
918 }
919
920 //------------------------------------------------------------------------------------------------
922 int GetCurrentPage()
923 {
924 return m_iCurrentPage;
925 }
926
927 //------------------------------------------------------------------------------------------------
931 void SetCurrentPage(int page)
932 {
933 m_iCurrentPage = page;
934 }
935}
936
939class SCR_WelcomeScreenIntroduction
940{
941 [Attribute("", UIWidgets.ResourcePickerThumbnail, "Flag icon of this particular faction.", params: "edds")]
942 protected ResourceName m_sContentImage;
943
944 [Attribute()]
945 protected string m_sContentTitleText;
946
947 [Attribute()]
948 protected string m_sContentDescriptionText;
949
950 //------------------------------------------------------------------------------------------------
952 ResourceName GetImage()
953 {
954 return m_sContentImage;
955 }
956
957 //------------------------------------------------------------------------------------------------
959 string GetTitleText()
960 {
961 return m_sContentTitleText;
962 }
963
964 //------------------------------------------------------------------------------------------------
966 string GetDescriptionText()
967 {
968 return m_sContentDescriptionText;
969 }
970}
971
974class SCR_WelcomeScreenFactionContent : SCR_WelcomeScreenBaseContent
975{
976 [Attribute()]
977 protected string m_sTitleText;
978
979 [Attribute()]
980 protected string m_sBottomTitleText;
981
982 [Attribute(defvalue: "{4C4460227BBC5134}UI/layouts/Menus/DeployMenu/WelcomeScreenFactionColumn.layout")]
983 protected ResourceName m_sFactionColumnLayout;
984
985 [Attribute(defvalue: "{68CCF1BD8F7AF86C}UI/layouts/Menus/DeployMenu/WelcomeScreenFaction.layout")]
986 protected ResourceName m_sFactionLayout;
987
988 [Attribute(defvalue: "{1228936E5DB30403}UI/Textures/GroupManagement/FlagIcons/GroupFlagsBlufor.imageset")]
989 protected ResourceName m_sBluforLayout;
990
991 [Attribute(defvalue: "{7CD99D22C7AE8195}UI/Textures/GroupManagement/FlagIcons/GroupFlagsOpfor.imageset")]
992 protected ResourceName m_sOpforLayout;
993
994 [Attribute(defvalue: "{301FC1A2A46D3E0D}UI/Textures/GroupManagement/FlagIcons/GroupFlagsIndfor.imageset")]
995 protected ResourceName m_sIndforLayout;
996
997 [Attribute("US")]
998 protected string m_sUSFaction;
999
1000 [Attribute("USSR")]
1001 protected string m_sUSSRFaction;
1002
1003 [Attribute("FIA")]
1004 protected string m_sFIAFaction;
1005
1006 protected Widget m_wFactionContentWidget;
1007 protected ref array<Widget> m_aFactionWidgets = {};
1008 protected ref SCR_SortedArray<SCR_Faction> m_SortedFactions = new SCR_SortedArray<SCR_Faction>();
1009
1010 //------------------------------------------------------------------------------------------------
1011 override void InitContent(SCR_WelcomeScreenMenu menu, string column, string columnButton)
1012 {
1013 m_sContentName = column;
1014
1015 Widget targetColumn = menu.GetRootWidget().FindAnyWidget(column);
1016 if (!targetColumn)
1017 return;
1018
1019 m_wFactionContentWidget = GetGame().GetWorkspace().CreateWidgets(m_sFactionColumnLayout, targetColumn);
1020 if (!m_wFactionContentWidget)
1021 return;
1022
1023 AddFactionWidget();
1024 }
1025
1026 //------------------------------------------------------------------------------------------------
1028 protected void AddFactionWidget()
1029 {
1030 RichTextWidget titleTextContent = RichTextWidget.Cast(m_wFactionContentWidget.FindAnyWidget("TitleText"));
1031 if (titleTextContent)
1032 titleTextContent.SetText(GetTitleText());
1033
1034 //This part is WIP and prepared for sorting factions by their sides
1035 Widget blueforContent = m_wFactionContentWidget.FindAnyWidget("Bluefor"); //#22c4f4
1036 Widget opforContent = m_wFactionContentWidget.FindAnyWidget("Opfor"); //#ee312f
1037 Widget independentContent = m_wFactionContentWidget.FindAnyWidget("Independent"); //#00b14f
1038 Widget civilianContent = m_wFactionContentWidget.FindAnyWidget("Civilian"); //WIP
1039
1040 if (!blueforContent)
1041 return;
1042
1043 SCR_FactionManager factionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
1044 if (!factionManager)
1045 return;
1046
1047 factionManager.GetOnPlayerFactionCountChanged().Insert(UpdateFactionPlayerCount);
1048
1049 int factionCount = factionManager.GetSortedFactionsList(m_SortedFactions);
1050
1051 for (int i = 0; i < factionCount; i++)
1052 {
1053 m_SortedFactions[i].GetOnFactionPlayableChanged().Insert(UpdateFactionPlayability);
1054 }
1055 //Color blueforColor = new Color(4.0, 141.0, 231.0, 255.0);
1056
1057 int cycleCount;
1058 if (factionCount < 7)
1059 cycleCount = factionCount;
1060 else
1061 cycleCount = 6;
1062
1063 //Factions are capped for 6 at the time
1064 for (int i = 0; i < cycleCount; i++)
1065 {
1066 factionCount--;
1067 Color factionColor = m_SortedFactions[i].GetFactionColor();
1068 FillFactionWidget(m_SortedFactions[i], blueforContent, factionColor);
1069 }
1070
1071 RichTextWidget bottomTitleText = RichTextWidget.Cast(m_wFactionContentWidget.FindAnyWidget("BottomTitleText"));
1072 if (!bottomTitleText)
1073 return;
1074
1075 if (factionCount < 1)
1076 bottomTitleText.SetOpacity(0);
1077 else
1078 bottomTitleText.SetTextFormat(GetBottomTitleText(), factionCount);
1079 }
1080
1081 //------------------------------------------------------------------------------------------------
1086 protected void FillFactionWidget(notnull SCR_Faction faction, notnull Widget content, Color color)
1087 {
1088 EOverrideWelcomeScreenFactionDisplay displayOverride = faction.ShowInWelcomeScreenOverride();
1089
1090 if (displayOverride == EOverrideWelcomeScreenFactionDisplay.NEVERSHOW || (!faction.IsPlayable() && displayOverride == EOverrideWelcomeScreenFactionDisplay.NONE))
1091 return;
1092
1093 Widget factionWidget = GetGame().GetWorkspace().CreateWidgets(m_sFactionLayout, content);
1094 if (!factionWidget)
1095 return;
1096
1097 m_aFactionWidgets.Insert(factionWidget);
1098
1099 ImageWidget flag = ImageWidget.Cast(factionWidget.FindAnyWidget("FlagImage"));
1100 if (flag)
1101 flag.LoadImageTexture(0, faction.GetFactionFlag(), false, false);
1102
1103 ImageWidget side = ImageWidget.Cast(factionWidget.FindAnyWidget("SideImage"));
1104 if (side)
1105 {
1106 ResourceName ImageSetResource;
1107
1108 if (faction.GetFactionKey() == m_sUSFaction)
1109 ImageSetResource = m_sBluforLayout;
1110
1111 else if (faction.GetFactionKey() == m_sUSSRFaction)
1112 ImageSetResource = m_sOpforLayout;
1113
1114 else if (faction.GetFactionKey() == m_sFIAFaction)
1115 ImageSetResource = m_sIndforLayout;
1116
1117 else
1118 {
1119 side.SetEnabled(false);
1120 side.SetVisible(false);
1121 return;
1122 }
1123
1124 side.LoadImageFromSet(0, ImageSetResource, "undefined");
1125 side.SetColor(faction.GetFactionColor());
1126 }
1127
1128 RichTextWidget name = RichTextWidget.Cast(factionWidget.FindAnyWidget("FactionNameText"));
1129 if (name)
1130 name.SetText(faction.GetFactionName());
1131
1132 ImageWidget bar = ImageWidget.Cast(factionWidget.FindAnyWidget("Bar"));
1133 if (bar)
1134 bar.SetVisible(false);
1135
1136 RichTextWidget playerCount = RichTextWidget.Cast(factionWidget.FindAnyWidget("FactionPlayerCount"));
1137 if (!playerCount)
1138 return;
1139
1140 int playerLimit = faction.GetPlayerLimit();
1141 ImageWidget playerIcon = ImageWidget.Cast(factionWidget.FindAnyWidget("PlayerIcon"));
1142 if (playerLimit != 0 && faction.IsPlayable())
1143 {
1144 if (playerLimit > 0)
1145 playerCount.SetTextFormat("#AR-SupportStation_ActionFormat_ItemAmount", faction.GetPlayerCount(), playerLimit);
1146 else
1147 playerCount.SetText(faction.GetPlayerCount().ToString());
1148 }
1149 else
1150 {
1151 if (playerIcon)
1152 playerIcon.SetVisible(false);
1153
1154 playerCount.SetText("#AR-DeployScreen_NonPlayableFaction");
1155 }
1156 }
1157
1158 //------------------------------------------------------------------------------------------------
1162 protected void UpdateFactionPlayerCount(Faction faction, int playerCountParam)
1163 {
1164 SCR_Faction factionScripted = SCR_Faction.Cast(faction);
1165 if (!factionScripted)
1166 return;
1167
1168 // both sortedfactions and faction widgets needs to contain it
1169 if (!m_SortedFactions.Contains(factionScripted) || m_aFactionWidgets.Count() - 1 < m_SortedFactions.Find(factionScripted))
1170 return;
1171
1172 Widget factionWidget = m_aFactionWidgets[m_SortedFactions.Find(factionScripted)];
1173 if (!factionWidget)
1174 return;
1175
1176 RichTextWidget playerCount = RichTextWidget.Cast(factionWidget.FindAnyWidget("FactionPlayerCount"));
1177 if (!playerCount)
1178 return;
1179
1180 int playerLimit = factionScripted.GetPlayerLimit();
1181 if (playerLimit > 0)
1182 playerCount.SetTextFormat("#AR-SupportStation_ActionFormat_ItemAmount", playerCountParam, playerLimit);
1183 else
1184 playerCount.SetText(playerCountParam.ToString());
1185 }
1186
1187 //------------------------------------------------------------------------------------------------
1191 protected void UpdateFactionPlayability(Faction faction, bool playable)
1192 {
1193 SCR_Faction factionScripted = SCR_Faction.Cast(faction);
1194 if (!factionScripted)
1195 return;
1196
1197 Widget factionWidget = m_aFactionWidgets[m_SortedFactions.Find(factionScripted)];
1198 if (!factionWidget)
1199 return;
1200
1201 RichTextWidget playerCount = RichTextWidget.Cast(factionWidget.FindAnyWidget("FactionPlayerCount"));
1202 if (!playerCount)
1203 return;
1204
1205 ImageWidget playerIcon = ImageWidget.Cast(factionWidget.FindAnyWidget("PlayerIcon"));
1206 int playerLimit = factionScripted.GetPlayerLimit();
1207 if (factionScripted.IsPlayable())
1208 {
1209 if (playerIcon)
1210 playerIcon.SetVisible(true);
1211
1212 if (playerLimit >= 0)
1213 playerCount.SetTextFormat("#AR-SupportStation_ActionFormat_ItemAmount", factionScripted.GetPlayerCount(), playerLimit);
1214 else
1215 playerCount.SetText((factionScripted.GetPlayerCount()).ToString());
1216 }
1217 else
1218 {
1219 if (playerIcon)
1220 playerIcon.SetVisible(false);
1221
1222 playerCount.SetText("#AR-DeployScreen_NonPlayableFaction");
1223 }
1224 }
1225
1226 //------------------------------------------------------------------------------------------------
1228 string GetTitleText()
1229 {
1230 return m_sTitleText;
1231 }
1232
1233 //------------------------------------------------------------------------------------------------
1235 string GetBottomTitleText()
1236 {
1237 return m_sBottomTitleText;
1238 }
1239}
class RestAPIHelper< JsonApiStruct T > content
ArmaReforgerScripted GetGame()
Definition game.c:1398
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
Get all prefabs that have the spawner the given labels and are valid in the editor mode param catalogType Type to catalog to get prefabs from param editorMode Editor mode to get valid entries from param faction Faction(Optional)
EOverrideWelcomeScreenFactionDisplay
void SCR_FactionManager(IEntitySource src, IEntity parent)
string m_sDescription
string GetImageSet()
SCR_FactionManager m_FactionManager
FactionKey m_sFactionKey
FactionKey GetFactionKey()
void SCR_Task(IEntitySource src, IEntity parent)
Definition SCR_Task.c:1938
string GetTaskName(SCR_Task task)
override void InitContent(SCR_WelcomeScreenMenu menu)
SCR_WelcomeScreenThreeHorizontalColumns SCR_DeployMenuBaseScreenLayout BaseContainerProps()
Base class for screen contents.
SCR_WelcomeScreenComponentClass SCR_DeployMenuBaseScreenComponent
Welcome screen component intended to be added to the GameMode.
Base class for Deploy menu layouts.
ref array< ref SCR_WelcomeScreenBaseContent > m_aScreenBaseContents
int GetPlayerLimit()
bool IsPlayable()
int GetPlayerCount()
void SetCurrentItem(int index, bool animate=true)
void SetItemCount(int count, bool animate=true)
Class that handles Welcome screen menu.
Class handling layout for ThreeHorizontalColumns.
ref SCR_WelcomeScreenBaseContent m_RightColumn
ref SCR_WelcomeScreenBaseContent m_LeftColumn
override void InitContent(SCR_WelcomeScreenMenu menu)
ref SCR_WelcomeScreenBaseContent m_MiddleColumn
SCR_FieldOfViewSettings Attribute