Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_WelcomeScreenComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/GameMode/Components", description: "Welcome screen shown in respawn menu.")]
3 {
4 }
5 
7 class SCR_WelcomeScreenComponent : SCR_DeployMenuBaseScreenComponent
8 {
9 };
10 
14 {
15  [Attribute(defvalue: "{16B14338A8911683}UI/layouts/Menus/DeployMenu/WelcomeScreenThreeHorizontalColumns.layout")]
16  protected ResourceName m_sThreeHorizontalColumnsLayout;
17 
19  protected ref SCR_WelcomeScreenBaseContent m_LeftColumn;
20 
22  protected ref SCR_WelcomeScreenBaseContent m_MiddleColumn;
23 
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  //------------------------------------------------------------------------------------------------
38  override void InitContent(SCR_WelcomeScreenMenu menu)
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  {
48  m_aScreenBaseContents.Insert(m_LeftColumn);
49  m_LeftColumn.InitContent(menu, LEFT_COLUMN, LEFT_COLUMN_BUTTON);
50  }
51 
52  if (m_MiddleColumn)
53  {
54  m_aScreenBaseContents.Insert(m_MiddleColumn);
56  }
57 
58  if (m_RightColumn)
59  {
60  m_aScreenBaseContents.Insert(m_RightColumn);
62  }
63  }
64 }
65 
68 class 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 
108 class 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 
228 class 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()]
264 class 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_BaseTask> 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_BaseTaskManager taskManager = GetTaskManager();
328  if (!taskManager)
329  return;
330 
331  m_FactionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
332  if (!m_FactionManager)
333  return;
334 
335  m_aObjectivesToDisplay.Clear();
336  taskManager.GetTasks(m_aObjectivesToDisplay);
337  m_iDynamicObjectivesCount = m_aObjectivesToDisplay.Count();
338 
339  foreach (SCR_WelcomeScreenDynamicTaskFaction faction : m_aFactions)
340  {
341  foreach (SCR_BaseTask task : m_aObjectivesToDisplay)
342  {
343  if (task.GetTargetFaction() != m_FactionManager.GetFactionByKey(faction.GetFactionKey()))
344  continue;
345 
346  faction.AddFactionTask(task);
347  }
348  }
349 
350  //Statistics are capped for 10 at the time
351  m_aDynamicObjectivesWidgets.Clear();
352  for (int i = 0; i < 10; ++i)
353  {
354  Widget objective = GetGame().GetWorkspace().CreateWidgets(m_sFinishedObjectivesLayout, content);
355  m_aDynamicObjectivesWidgets.Insert(objective);
356  }
357 
358  SCR_BaseTaskManager.s_OnTaskCreated.Insert(AddTask);
359 
360  SCR_BaseTaskManager.s_OnTaskFinished.Insert(RemoveTask);
361  SCR_BaseTaskManager.s_OnTaskCancelled.Insert(RemoveTask);
362  SCR_BaseTaskManager.s_OnTaskFailed.Insert(RemoveTask);
363 
364  FlipPage(GetCurrentPage());
365 
366  m_wPaginationWidget = m_wFinishedObjectivesWidget.FindAnyWidget("BottomTitleSizeLayout");
367  if (!m_wPaginationWidget)
368  return;
369 
370  if (m_iDynamicObjectivesCount < 11)
371  {
372  m_wPaginationWidget.SetOpacity(0);
373  }
374  else
375  {
376  Widget pages = m_wFinishedObjectivesWidget.FindAnyWidget("Pages");
377  if (!pages)
378  return;
379 
380  SCR_SelectionHintComponent pagesVisualised = SCR_SelectionHintComponent.Cast(pages.FindHandler(SCR_SelectionHintComponent));
381  if (!pagesVisualised)
382  return;
383 
384  pagesVisualised.SetItemCount(m_iDynamicObjectivesCount/10);
385  }
386  }
387 
388  //------------------------------------------------------------------------------------------------
391  protected void AddTask(SCR_BaseTask task)
392  {
393  //Since this is called right after task creation, the task itself might not have the
394  //Title, faction or other properties set just yet. By introducing slight delay, we mitigate it in most cases
395  GetGame().GetCallqueue().CallLater(AddTaskCalledLater, 1000, false, task);
396  }
397 
398  //------------------------------------------------------------------------------------------------
401  protected void AddTaskCalledLater(SCR_BaseTask task)
402  {
403  foreach (SCR_WelcomeScreenDynamicTaskFaction faction : m_aFactions)
404  {
405  if (task.GetTargetFaction() != m_FactionManager.GetFactionByKey(faction.GetFactionKey()))
406  continue;
407 
408  faction.AddFactionTask(task);
409  break;
410  }
411 
412  m_aObjectivesToDisplay.Clear();
413  foreach (SCR_WelcomeScreenDynamicTaskFaction faction : m_aFactions)
414  {
415  m_aObjectivesToDisplay.InsertAll(faction.GetFactionTasks());
416  }
417 
418  m_iDynamicObjectivesCount = m_aObjectivesToDisplay.Count();
419 
420  FlipPage(GetCurrentPage());
421  }
422 
423  //------------------------------------------------------------------------------------------------
426  protected void RemoveTask(SCR_BaseTask task)
427  {
428  foreach (SCR_WelcomeScreenDynamicTaskFaction faction : m_aFactions)
429  {
430  if (task.GetTargetFaction() != m_FactionManager.GetFactionByKey(faction.GetFactionKey()))
431  continue;
432 
433  faction.RemoveFactionTask(task);
434  break;
435  }
436 
437  m_aObjectivesToDisplay.Clear();
438  foreach (SCR_WelcomeScreenDynamicTaskFaction faction : m_aFactions)
439  {
440  m_aObjectivesToDisplay.InsertAll(faction.GetFactionTasks());
441  }
442 
443  m_iDynamicObjectivesCount = m_aObjectivesToDisplay.Count();
444 
445  FlipPage(GetCurrentPage());
446  }
447 
448  //------------------------------------------------------------------------------------------------
450  protected void InitPagination()
451  {
452  Widget previousButtonWidget = m_wFinishedObjectivesWidget.FindAnyWidget("PrevButton");
453  if (!previousButtonWidget)
454  return;
455 
456  SCR_PagingButtonComponent previousButton = SCR_PagingButtonComponent.Cast(previousButtonWidget.FindHandler(SCR_PagingButtonComponent));
457  if (previousButton)
458  previousButton.m_OnClicked.Insert(ButtonClicked);
459 
460  Widget nextButtonWidget = m_wFinishedObjectivesWidget.FindAnyWidget("NextButton");
461  if (!nextButtonWidget)
462  return;
463 
464  SCR_PagingButtonComponent nextButton = SCR_PagingButtonComponent.Cast(nextButtonWidget.FindHandler(SCR_PagingButtonComponent));
465  if (nextButton)
466  nextButton.m_OnClicked.Insert(ButtonClicked);
467  }
468 
469  //------------------------------------------------------------------------------------------------
471  protected void ButtonClicked()
472  {
473  GetGame().GetWorkspace().SetFocusedWidget(m_wColumnButton);
474  }
475 
476  //------------------------------------------------------------------------------------------------
479  protected void HandlePagination(bool enabled = false)
480  {
481  Widget previousButtonWidget = m_wFinishedObjectivesWidget.FindAnyWidget("PrevButton");
482  if (!previousButtonWidget)
483  return;
484 
485  SCR_PagingButtonComponent previousButton = SCR_PagingButtonComponent.Cast(previousButtonWidget.FindHandler(SCR_PagingButtonComponent));
486  if (!previousButton)
487  return;
488 
489  if (enabled)
490  previousButton.m_OnActivated.Insert(PreviousButtonActivated);
491  else
492  previousButton.m_OnActivated.Remove(PreviousButtonActivated);
493 
494  Widget nextButtonWidget = m_wFinishedObjectivesWidget.FindAnyWidget("NextButton");
495  if (!nextButtonWidget)
496  return;
497 
498  SCR_PagingButtonComponent nextButton = SCR_PagingButtonComponent.Cast(nextButtonWidget.FindHandler(SCR_PagingButtonComponent));
499  if (!nextButton)
500  return;
501 
502  if (enabled)
503  nextButton.m_OnActivated.Insert(NextButtonActivated);
504  else
505  nextButton.m_OnActivated.Remove(NextButtonActivated);
506  }
507 
508  //------------------------------------------------------------------------------------------------
510  protected void PreviousButtonActivated()
511  {
512  int currentPage = GetCurrentPage();
513  currentPage--;
514  if (currentPage < 0)
515  return;
516 
517  FlipPage(currentPage);
518  }
519 
520  //------------------------------------------------------------------------------------------------
522  protected void NextButtonActivated()
523  {
524  int currentPage = GetCurrentPage();
525  currentPage++;
526  if (currentPage == Math.Ceil(m_iDynamicObjectivesCount/10))
527  return;
528 
529  FlipPage(currentPage);
530  }
531 
532  //------------------------------------------------------------------------------------------------
535  protected void FlipPage(int currentPage)
536  {
537  for (int i = 0; i < 10; ++i)
538  {
539  if (!m_aDynamicObjectivesWidgets[i])
540  continue;
541 
542  m_aDynamicObjectivesWidgets[i].SetOpacity(1);
543  if (currentPage == 0)
544  {
545  if (i < m_iDynamicObjectivesCount)
546  {
547  RichTextWidget name = RichTextWidget.Cast(m_aDynamicObjectivesWidgets[i].FindAnyWidget("ObjectiveText"));
548  SCR_EditorTask editorTask = SCR_EditorTask.Cast(m_aObjectivesToDisplay[i]);
549  SCR_CampaignTask campaignTask = SCR_CampaignTask.Cast(m_aObjectivesToDisplay[i]);
550  if (editorTask)
551  name.SetTextFormat(editorTask.GetTitle(), editorTask.GetLocationName());
552  else if (campaignTask)
553  name.SetTextFormat(campaignTask.GetTitle(), campaignTask.GetBaseNameWithCallsign());
554  else
555  name.SetText(m_aObjectivesToDisplay[i].GetTitle());
556 
557  ImageWidget image = ImageWidget.Cast(m_aDynamicObjectivesWidgets[i].FindAnyWidget("Background"));
558  image.SetColor(m_aObjectivesToDisplay[i].GetTargetFaction().GetFactionColor());
559  }
560  else
561  {
562  m_aDynamicObjectivesWidgets[i].SetOpacity(0);
563  }
564  }
565  else
566  {
567  if ((currentPage * 10) + i < m_iDynamicObjectivesCount)
568  {
569  RichTextWidget name = RichTextWidget.Cast(m_aDynamicObjectivesWidgets[i].FindAnyWidget("ObjectiveText"));
570  SCR_EditorTask editorTask = SCR_EditorTask.Cast(m_aObjectivesToDisplay[(currentPage * 10) + i]);
571  SCR_CampaignTask campaignTask = SCR_CampaignTask.Cast(m_aObjectivesToDisplay[(currentPage * 10) + i]);
572  if (editorTask)
573  name.SetTextFormat(editorTask.GetTitle(), editorTask.GetLocationName());
574  else if (campaignTask)
575  name.SetTextFormat(campaignTask.GetTitle(), campaignTask.GetBaseNameWithCallsign());
576  else
577  name.SetText(m_aObjectivesToDisplay[(currentPage * 10) + i].GetTitle());
578 
579  ImageWidget image = ImageWidget.Cast(m_aDynamicObjectivesWidgets[i].FindAnyWidget("Background"));
580  image.SetColor(m_aObjectivesToDisplay[(currentPage * 10) + i].GetTargetFaction().GetFactionColor());
581  }
582  else
583  {
584  m_aDynamicObjectivesWidgets[i].SetOpacity(0);
585  }
586  }
587  }
588 
589  SetCurrentPage(currentPage);
590 
591  if (m_wPaginationWidget)
592  {
593  if (m_iDynamicObjectivesCount < 11)
594  m_wPaginationWidget.SetOpacity(0);
595  else
596  m_wPaginationWidget.SetOpacity(1);
597 
598  Widget pages = m_wFinishedObjectivesWidget.FindAnyWidget("Pages");
599  if (!pages)
600  return;
601 
602  SCR_SelectionHintComponent pagesVisualised = SCR_SelectionHintComponent.Cast(pages.FindHandler(SCR_SelectionHintComponent));
603  if (!pagesVisualised)
604  return;
605 
606  pagesVisualised.SetItemCount(m_iDynamicObjectivesCount/10);
607  pagesVisualised.SetCurrentItem(currentPage);
608  }
609  }
610 
611  //------------------------------------------------------------------------------------------------
613  int GetCurrentPage()
614  {
615  return m_iCurrentPage;
616  }
617 
618  //------------------------------------------------------------------------------------------------
622  void SetCurrentPage(int page)
623  {
624  m_iCurrentPage = page;
625  }
626 
627  //------------------------------------------------------------------------------------------------
629  string GetTitleText()
630  {
631  return m_sTitleText;
632  }
633 }
634 
637 class SCR_WelcomeScreenDynamicTaskFaction
638 {
639  [Attribute()]
640  protected string m_sFactionKey;
641 
642  [Attribute()]
643  protected ref array<SCR_BaseTask> m_aFactionTasks = {};
644 
645  //------------------------------------------------------------------------------------------------
647  array<SCR_BaseTask> GetFactionTasks()
648  {
649  return m_aFactionTasks;
650  }
651 
652  //------------------------------------------------------------------------------------------------
654  string GetFactionKey()
655  {
656  return m_sFactionKey;
657  }
658 
659  //------------------------------------------------------------------------------------------------
662  void AddFactionTask(SCR_BaseTask task)
663  {
664  if (!m_aFactionTasks.Contains(task))
665  m_aFactionTasks.Insert(task);
666  }
667 
668  //------------------------------------------------------------------------------------------------
671  void RemoveFactionTask(SCR_BaseTask task)
672  {
673  m_aFactionTasks.RemoveItem(task);
674  }
675 }
676 
679 class SCR_WelcomeScreenIntroductionContent : SCR_WelcomeScreenBaseContent
680 {
681  [Attribute()]
682  protected string m_sTitleText;
683 
684  [Attribute()]
685  protected ref array<ref SCR_WelcomeScreenIntroduction> m_aIntroduction;
686 
687  protected int m_iCurrentPage;
688  protected int m_iIntroductionCount;
689 
690  [Attribute(defvalue: "{49EEED554D68F43A}UI/layouts/Menus/DeployMenu/WelcomeScreenIntroductionColumn.layout")]
691  protected ResourceName m_sIntroductionColumnLayout;
692 
693  protected Widget m_wIntroductionContentWidget;
694  protected ButtonWidget m_wColumnButton;
695 
696  //------------------------------------------------------------------------------------------------
697  override void InitContent(SCR_WelcomeScreenMenu menu, string column, string columnButton)
698  {
699  m_sContentName = column;
700 
701  if (!m_aIntroduction)
702  return;
703 
704  m_iIntroductionCount = m_aIntroduction.Count();
705  Widget targetColumn = menu.GetRootWidget().FindAnyWidget(column);
706  if (!targetColumn)
707  return;
708 
709  m_wColumnButton = ButtonWidget.Cast(menu.GetRootWidget().FindAnyWidget(columnButton));
710  if (!m_wColumnButton)
711  return;
712 
713  m_wIntroductionContentWidget = GetGame().GetWorkspace().CreateWidgets(m_sIntroductionColumnLayout, targetColumn);
714  if (!m_wIntroductionContentWidget)
715  return;
716 
717  FillIntroductionWidget(targetColumn);
718  }
719 
720  //------------------------------------------------------------------------------------------------
721  override void ToggleInteractions(bool enabled)
722  {
723  HandlePagination(enabled);
724  }
725 
726  //------------------------------------------------------------------------------------------------
729  protected void FillIntroductionWidget(Widget column)
730  {
731  RichTextWidget titleTextContent = RichTextWidget.Cast(column.FindAnyWidget("TitleText"));
732  if (titleTextContent)
733  titleTextContent.SetText(GetTitleText());
734 
735  array<ref SCR_WelcomeScreenIntroduction> introductionPages = {};
736  int introductionCount = GetIntroduction(introductionPages);
737  if (introductionCount == 0)
738  return;
739 
740  Widget contentVertical = m_wIntroductionContentWidget.FindAnyWidget("ContentVertical");
741  if (!contentVertical)
742  return;
743 
744  ImageWidget imageWidget = ImageWidget.Cast(contentVertical.FindAnyWidget("ImageWidget"));
745  if (imageWidget && introductionPages[0].GetImage())
746  imageWidget.LoadImageTexture(0, introductionPages[0].GetImage(), false, false);
747 
748  RichTextWidget titleText = RichTextWidget.Cast(contentVertical.FindAnyWidget("TitleText"));
749  if (titleText)
750  titleText.SetText(introductionPages[0].GetTitleText());
751 
752  RichTextWidget descriptionText = RichTextWidget.Cast(contentVertical.FindAnyWidget("DescriptionText"));
753  if (descriptionText)
754  descriptionText.SetText(introductionPages[0].GetDescriptionText());
755 
756  Widget pages = m_wIntroductionContentWidget.FindAnyWidget("Pages");
757  if (!pages)
758  return;
759 
760  SCR_SelectionHintComponent pagesVisualised = SCR_SelectionHintComponent.Cast(pages.FindHandler(SCR_SelectionHintComponent));
761  if (!pagesVisualised)
762  return;
763 
764  Widget pagination = m_wIntroductionContentWidget.FindAnyWidget("Pagination");
765  if (!pagination)
766  return;
767 
768  if (introductionCount == 1)
769  {
770  pagination.SetOpacity(0);
771  }
772  else
773  {
774  pagesVisualised.SetItemCount(introductionCount);
775  InitPagination();
776  HandlePagination();
777  }
778  }
779 
780  //------------------------------------------------------------------------------------------------
782  protected void InitPagination()
783  {
784  Widget previousButtonWidget = m_wIntroductionContentWidget.FindAnyWidget("PrevButton");
785  if (!previousButtonWidget)
786  return;
787 
788  SCR_PagingButtonComponent previousButton = SCR_PagingButtonComponent.Cast(previousButtonWidget.FindHandler(SCR_PagingButtonComponent));
789  if (previousButton)
790  previousButton.m_OnClicked.Insert(ButtonClicked);
791 
792  Widget nextButtonWidget = m_wIntroductionContentWidget.FindAnyWidget("NextButton");
793  if (!nextButtonWidget)
794  return;
795 
796  SCR_PagingButtonComponent nextButton = SCR_PagingButtonComponent.Cast(nextButtonWidget.FindHandler(SCR_PagingButtonComponent));
797  if (nextButton)
798  nextButton.m_OnClicked.Insert(ButtonClicked);
799  }
800 
801  //------------------------------------------------------------------------------------------------
803  protected void ButtonClicked()
804  {
805  GetGame().GetWorkspace().SetFocusedWidget(m_wColumnButton);
806  }
807 
808  //------------------------------------------------------------------------------------------------
811  protected void HandlePagination(bool enabled = false)
812  {
813  Widget previousButtonWidget = m_wIntroductionContentWidget.FindAnyWidget("PrevButton");
814  if (!previousButtonWidget)
815  return;
816 
817  SCR_PagingButtonComponent previousButton = SCR_PagingButtonComponent.Cast(previousButtonWidget.FindHandler(SCR_PagingButtonComponent));
818  if (!previousButton)
819  return;
820 
821  if (enabled)
822  previousButton.m_OnActivated.Insert(PreviousButtonActivated);
823  else
824  previousButton.m_OnActivated.Remove(PreviousButtonActivated);
825 
826  Widget nextButtonWidget = m_wIntroductionContentWidget.FindAnyWidget("NextButton");
827  if (!nextButtonWidget)
828  return;
829 
830  SCR_PagingButtonComponent nextButton = SCR_PagingButtonComponent.Cast(nextButtonWidget.FindHandler(SCR_PagingButtonComponent));
831  if (!nextButton)
832  return;
833 
834  if (enabled)
835  nextButton.m_OnActivated.Insert(NextButtonActivated);
836  else
837  nextButton.m_OnActivated.Remove(NextButtonActivated);
838  }
839 
840  //------------------------------------------------------------------------------------------------
842  protected void PreviousButtonActivated()
843  {
844  int currentPage = GetCurrentPage();
845  currentPage--;
846  if (currentPage < 0)
847  return;
848 
849  FlipPage(currentPage)
850  }
851 
852  //------------------------------------------------------------------------------------------------
854  protected void NextButtonActivated()
855  {
856  int currentPage = GetCurrentPage();
857  currentPage++;
858  if (currentPage == m_iIntroductionCount)
859  return;
860 
861  FlipPage(currentPage)
862  }
863 
864  //------------------------------------------------------------------------------------------------
867  protected void FlipPage(int currentPage)
868  {
869  Widget contentVertical = m_wIntroductionContentWidget.FindAnyWidget("ContentVertical");
870  if (!contentVertical)
871  return;
872 
873  SetCurrentPage(currentPage);
874  SCR_WelcomeScreenIntroduction targetIntroduction = m_aIntroduction[currentPage];
875  if (!targetIntroduction)
876  return;
877 
878  ImageWidget imageWidget = ImageWidget.Cast(contentVertical.FindAnyWidget("ImageWidget"));
879  if (imageWidget && targetIntroduction.GetImage())
880  imageWidget.LoadImageTexture(0, targetIntroduction.GetImage(), false, false);
881 
882  RichTextWidget titleText = RichTextWidget.Cast(contentVertical.FindAnyWidget("TitleText"));
883  if (titleText)
884  titleText.SetText(targetIntroduction.GetTitleText());
885 
886  RichTextWidget descriptionText = RichTextWidget.Cast(contentVertical.FindAnyWidget("DescriptionText"));
887  if (descriptionText)
888  descriptionText.SetText(targetIntroduction.GetDescriptionText());
889 
890  Widget pages = m_wIntroductionContentWidget.FindAnyWidget("Pages");
891  if (!pages)
892  return;
893 
894  SCR_SelectionHintComponent pagesVisualised = SCR_SelectionHintComponent.Cast(pages.FindHandler(SCR_SelectionHintComponent));
895  if (!pagesVisualised)
896  return;
897 
898  pagesVisualised.SetCurrentItem(currentPage);
899  }
900 
901  //------------------------------------------------------------------------------------------------
905  int GetIntroduction(out array<ref SCR_WelcomeScreenIntroduction> introduction)
906  {
907  introduction = m_aIntroduction;
908 
909  return m_aIntroduction.Count();
910  }
911 
912  //------------------------------------------------------------------------------------------------
914  string GetTitleText()
915  {
916  return m_sTitleText;
917  }
918 
919  //------------------------------------------------------------------------------------------------
921  int GetCurrentPage()
922  {
923  return m_iCurrentPage;
924  }
925 
926  //------------------------------------------------------------------------------------------------
930  void SetCurrentPage(int page)
931  {
932  m_iCurrentPage = page;
933  }
934 }
935 
938 class SCR_WelcomeScreenIntroduction
939 {
940  [Attribute("", UIWidgets.ResourcePickerThumbnail, "Flag icon of this particular faction.", params: "edds")]
941  protected ResourceName m_sContentImage;
942 
943  [Attribute()]
944  protected string m_sContentTitleText;
945 
946  [Attribute()]
947  protected string m_sContentDescriptionText;
948 
949  //------------------------------------------------------------------------------------------------
951  ResourceName GetImage()
952  {
953  return m_sContentImage;
954  }
955 
956  //------------------------------------------------------------------------------------------------
958  string GetTitleText()
959  {
960  return m_sContentTitleText;
961  }
962 
963  //------------------------------------------------------------------------------------------------
965  string GetDescriptionText()
966  {
967  return m_sContentDescriptionText;
968  }
969 }
970 
973 class SCR_WelcomeScreenFactionContent : SCR_WelcomeScreenBaseContent
974 {
975  [Attribute()]
976  protected string m_sTitleText;
977 
978  [Attribute()]
979  protected string m_sBottomTitleText;
980 
981  [Attribute(defvalue: "{4C4460227BBC5134}UI/layouts/Menus/DeployMenu/WelcomeScreenFactionColumn.layout")]
982  protected ResourceName m_sFactionColumnLayout;
983 
984  [Attribute(defvalue: "{68CCF1BD8F7AF86C}UI/layouts/Menus/DeployMenu/WelcomeScreenFaction.layout")]
985  protected ResourceName m_sFactionLayout;
986 
987  protected Widget m_wFactionContentWidget;
988  protected ref array<Widget> m_aFactionWidgets = {};
989  protected ref SCR_SortedArray<SCR_Faction> m_SortedFactions = new SCR_SortedArray<SCR_Faction>();
990 
991  //------------------------------------------------------------------------------------------------
992  override void InitContent(SCR_WelcomeScreenMenu menu, string column, string columnButton)
993  {
994  m_sContentName = column;
995 
996  Widget targetColumn = menu.GetRootWidget().FindAnyWidget(column);
997  if (!targetColumn)
998  return;
999 
1000  m_wFactionContentWidget = GetGame().GetWorkspace().CreateWidgets(m_sFactionColumnLayout, targetColumn);
1001  if (!m_wFactionContentWidget)
1002  return;
1003 
1004  AddFactionWidget();
1005  }
1006 
1007  //------------------------------------------------------------------------------------------------
1009  protected void AddFactionWidget()
1010  {
1011  RichTextWidget titleTextContent = RichTextWidget.Cast(m_wFactionContentWidget.FindAnyWidget("TitleText"));
1012  if (titleTextContent)
1013  titleTextContent.SetText(GetTitleText());
1014 
1015  //This part is WIP and prepared for sorting factions by their sides
1016  Widget blueforContent = m_wFactionContentWidget.FindAnyWidget("Bluefor"); //#22c4f4
1017  Widget opforContent = m_wFactionContentWidget.FindAnyWidget("Opfor"); //#ee312f
1018  Widget independentContent = m_wFactionContentWidget.FindAnyWidget("Independent"); //#00b14f
1019  Widget civilianContent = m_wFactionContentWidget.FindAnyWidget("Civilian"); //WIP
1020 
1021  if (!blueforContent)
1022  return;
1023 
1024  SCR_FactionManager factionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
1025  if (!factionManager)
1026  return;
1027 
1028  factionManager.GetOnPlayerFactionCountChanged().Insert(UpdateFactionPlayerCount);
1029 
1030  int factionCount = factionManager.GetSortedFactionsList(m_SortedFactions);
1031 
1032  for (int i = 0; i < factionCount; i++)
1033  {
1034  m_SortedFactions[i].GetOnFactionPlayableChanged().Insert(UpdateFactionPlayability);
1035  }
1036  //Color blueforColor = new Color(4.0, 141.0, 231.0, 255.0);
1037 
1038  int cycleCount;
1039  if (factionCount < 7)
1040  cycleCount = factionCount;
1041  else
1042  cycleCount = 6;
1043 
1044  //Factions are capped for 6 at the time
1045  for (int i = 0; i < cycleCount; i++)
1046  {
1047  factionCount--;
1048  Color factionColor = m_SortedFactions[i].GetFactionColor();
1049  FillFactionWidget(SCR_Faction.Cast(m_SortedFactions[i]), blueforContent, factionColor);
1050  }
1051 
1052  RichTextWidget bottomTitleText = RichTextWidget.Cast(m_wFactionContentWidget.FindAnyWidget("BottomTitleText"));
1053  if (!bottomTitleText)
1054  return;
1055 
1056  if (factionCount < 1)
1057  bottomTitleText.SetOpacity(0);
1058  else
1059  bottomTitleText.SetTextFormat(GetBottomTitleText(), factionCount);
1060  }
1061 
1062  //------------------------------------------------------------------------------------------------
1067  protected void FillFactionWidget(notnull SCR_Faction faction, notnull Widget content, Color color)
1068  {
1069  Widget factionWidget = GetGame().GetWorkspace().CreateWidgets(m_sFactionLayout, content);
1070  if (!factionWidget)
1071  return;
1072 
1073  m_aFactionWidgets.Insert(factionWidget);
1074 
1075  ImageWidget flag = ImageWidget.Cast(factionWidget.FindAnyWidget("FlagImage"));
1076  if (flag)
1077  flag.LoadImageTexture(0, faction.GetFactionFlag(), false, false);
1078 
1079  ImageWidget side = ImageWidget.Cast(factionWidget.FindAnyWidget("SideImage"));
1080  if (side)
1081  side.SetColor(color);
1082 
1083  RichTextWidget name = RichTextWidget.Cast(factionWidget.FindAnyWidget("FactionNameText"));
1084  if (name)
1085  name.SetText(faction.GetFactionName());
1086 
1087  ImageWidget bar = ImageWidget.Cast(factionWidget.FindAnyWidget("Bar"));
1088  if (bar)
1089  bar.SetVisible(false);
1090 
1091  RichTextWidget playerCount = RichTextWidget.Cast(factionWidget.FindAnyWidget("FactionPlayerCount"));
1092  if (!playerCount)
1093  return;
1094 
1095  ImageWidget playerIcon = ImageWidget.Cast(factionWidget.FindAnyWidget("PlayerIcon"));
1096  if (faction.IsPlayable())
1097  {
1098  playerCount.SetText((faction.GetPlayerCount()).ToString());
1099  }
1100  else
1101  {
1102  if (playerIcon)
1103  playerIcon.SetVisible(false);
1104 
1105  playerCount.SetText("#AR-DeployScreen_NonPlayableFaction");
1106  }
1107  }
1108 
1109  //------------------------------------------------------------------------------------------------
1113  protected void UpdateFactionPlayerCount(Faction faction, int playerCountParam)
1114  {
1115  SCR_Faction factionScripted = SCR_Faction.Cast(faction);
1116  if (!factionScripted)
1117  return;
1118 
1119  Widget factionWidget = m_aFactionWidgets[m_SortedFactions.Find(factionScripted)];
1120  if (!factionWidget)
1121  return;
1122 
1123  RichTextWidget playerCount = RichTextWidget.Cast(factionWidget.FindAnyWidget("FactionPlayerCount"));
1124  if (!playerCount)
1125  return;
1126 
1127  playerCount.SetText((playerCountParam).ToString());
1128  }
1129 
1130  //------------------------------------------------------------------------------------------------
1134  protected void UpdateFactionPlayability(Faction faction, bool playable)
1135  {
1136  SCR_Faction factionScripted = SCR_Faction.Cast(faction);
1137  if (!factionScripted)
1138  return;
1139 
1140  Widget factionWidget = m_aFactionWidgets[m_SortedFactions.Find(factionScripted)];
1141  if (!factionWidget)
1142  return;
1143 
1144  RichTextWidget playerCount = RichTextWidget.Cast(factionWidget.FindAnyWidget("FactionPlayerCount"));
1145  if (!playerCount)
1146  return;
1147 
1148  ImageWidget playerIcon = ImageWidget.Cast(factionWidget.FindAnyWidget("PlayerIcon"));
1149  if (factionScripted.IsPlayable())
1150  {
1151  if (playerIcon)
1152  playerIcon.SetVisible(true);
1153 
1154  playerCount.SetText((factionScripted.GetPlayerCount()).ToString());
1155  }
1156  else
1157  {
1158  if (playerIcon)
1159  playerIcon.SetVisible(false);
1160 
1161  playerCount.SetText("#AR-DeployScreen_NonPlayableFaction");
1162  }
1163  }
1164 
1165  //------------------------------------------------------------------------------------------------
1167  string GetTitleText()
1168  {
1169  return m_sTitleText;
1170  }
1171 
1172  //------------------------------------------------------------------------------------------------
1174  string GetBottomTitleText()
1175  {
1176  return m_sBottomTitleText;
1177  }
1178 }
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
m_iCurrentPage
protected int m_iCurrentPage
Definition: SCR_ContentBrowser_AddonsSubMenu.c:75
SCR_DeployMenuBaseScreenLayout
Base class for Deploy menu layouts.
Definition: SCR_DeployMenuBaseScreenComponent.c:43
BaseContainerProps
SCR_WelcomeScreenThreeHorizontalColumns SCR_DeployMenuBaseScreenLayout BaseContainerProps()
Base class for screen contents.
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_RightColumn
protected ref SCR_WelcomeScreenBaseContent m_RightColumn
Definition: SCR_WelcomeScreenComponent.c:12
MIDDLE_COLUMN_BUTTON
const protected string MIDDLE_COLUMN_BUTTON
Definition: SCR_WelcomeScreenComponent.c:21
m_sThreeHorizontalColumnsLayout
protected ResourceName m_sThreeHorizontalColumnsLayout
Definition: SCR_WelcomeScreenComponent.c:3
MIDDLE_COLUMN
const protected string MIDDLE_COLUMN
Definition: SCR_WelcomeScreenComponent.c:17
RIGHT_COLUMN_BUTTON
const protected string RIGHT_COLUMN_BUTTON
Definition: SCR_WelcomeScreenComponent.c:22
SCR_WelcomeScreenThreeHorizontalColumns
Class handling layout for ThreeHorizontalColumns.
Definition: SCR_WelcomeScreenComponent.c:13
SCR_BaseTask
A base class for tasks.
Definition: SCR_BaseTask.c:8
m_sFactionKey
protected FactionKey m_sFactionKey
Definition: SCR_ScenarioFrameworkLayerBase.c:25
SCR_CampaignTask
Definition: SCR_CampaignTask.c:7
SCR_PagingButtonComponent
Definition: SCR_PagingButtonComponent.c:2
m_FactionManager
protected SCR_FactionManager m_FactionManager
Definition: SCR_NotificationSenderComponent.c:28
SCR_DeployMenuBaseScreenComponentClass
Definition: SCR_DeployMenuBaseScreenComponent.c:2
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_ContainerActionTitle
SCR_ContainerActionTitle BaseContainerCustomTitle SCR_ContainerActionTitle()] class SCR_ScenarioFrameworkActionBase
Definition: SCR_ScenarioFrameworkActions.c:43
m_sDescription
string m_sDescription
Definition: SCR_FlashlightComponent.c:3
GetTaskManager
SCR_BaseTaskManager GetTaskManager()
Definition: SCR_BaseTaskManager.c:7
WELCOME_CONTENT
const protected string WELCOME_CONTENT
Definition: SCR_WelcomeScreenComponent.c:14
SCR_BaseTaskManager
Definition: SCR_BaseTaskManager.c:25
RIGHT_COLUMN
const protected string RIGHT_COLUMN
Definition: SCR_WelcomeScreenComponent.c:18
SCR_EditorTask
Definition: SCR_EditorTask.c:7
InitContent
override void InitContent(SCR_WelcomeScreenMenu menu)
Definition: SCR_WelcomeScreenComponent.c:25
SCR_WelcomeScreenComponentClass
Definition: SCR_WelcomeScreenComponent.c:2
GetFactionKey
protected FactionKey GetFactionKey()
Definition: SCR_ScenarioFrameworkLayerBase.c:248
Faction
Definition: Faction.c:12
SCR_SelectionHintComponent
Definition: SCR_SelectionHintComponent.c:2
LEFT_COLUMN_BUTTON
const protected string LEFT_COLUMN_BUTTON
Definition: SCR_WelcomeScreenComponent.c:20
LEFT_COLUMN
const protected string LEFT_COLUMN
Definition: SCR_WelcomeScreenComponent.c:16
SCR_WelcomeScreenMenu
Class that handles Welcome screen menu.
Definition: SCR_WelcomeScreenMenu.c:3
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
m_LeftColumn
protected ref SCR_WelcomeScreenBaseContent m_LeftColumn
Definition: SCR_WelcomeScreenComponent.c:6
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition: SCR_FactionManager.c:461
SCR_DeployMenuBaseScreenComponent
SCR_WelcomeScreenComponentClass SCR_DeployMenuBaseScreenComponent
Welcome screen component intended to be added to the GameMode.
SCR_Faction
Definition: SCR_Faction.c:6
GetImageSet
string GetImageSet()
Definition: SCR_MapToolMenuUI.c:106
m_MiddleColumn
protected ref SCR_WelcomeScreenBaseContent m_MiddleColumn
Definition: SCR_WelcomeScreenComponent.c:9
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180