Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
WelcomeDialog.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
3 {
4  protected string m_sHeaderName = "Title";
5  protected string m_sTextName = "Text";
6  protected string m_sSelectionHintName = "SelectionHint";
7  protected string m_sPreviousName = "Previous";
8  protected string m_sNextName = "Next";
9  protected string m_sLinksName = "Links";
10 
11  protected TextWidget m_wText;
12  protected Widget m_wHeader;
13  protected Widget m_wLinks;
14  protected ref array<ref Widget> m_wLinkButtons = new array<ref Widget>;
15  protected Widget m_wLastFocusedLinkButton;
16  protected SCR_SelectionHintComponent m_SelectionHint;
17  protected SCR_InputButtonComponent m_Previous;
18  protected SCR_InputButtonComponent m_Next;
19 
20  protected int m_iCurrentIndex;
21  protected int m_iMaxIndex;
22  protected ref array<string> m_aPageTexts =
23  {
24  "#ar-welcomescreen_text_01",
25  "#ar-welcomescreen_text_02",
26  "#ar-welcomescreen_text_03",
27  "#ar-welcomescreen_text_04",
28  "#ar-welcomescreen_text_05",
29  "#ar-welcomescreen_text_06",
30  "#ar-welcomescreen_text_07"
31  };
32 
33  //------------------------------------------------------------------------------------------------
34  override void OnMenuOpen()
35  {
36  super.OnMenuOpen();
37 
38  m_iMaxIndex = m_aPageTexts.Count() - 1;
39  Widget w = GetRootWidget();
40  m_wText = TextWidget.Cast(w.FindAnyWidget(m_sTextName));
41  m_wHeader = w.FindAnyWidget(m_sHeaderName);
42 
43  m_wLinks = w.FindAnyWidget(m_sLinksName);
44  if(m_wLinks)
45  SCR_WidgetHelper.GetAllChildren(m_wLinks, m_wLinkButtons);
46 
47  if(!m_wLinkButtons.IsEmpty())
48  {
49  SCR_ButtonTextComponent buttonComp;
50  foreach(Widget linkButton : m_wLinkButtons)
51  {
52  buttonComp = SCR_ButtonTextComponent.Cast(linkButton.FindHandler(SCR_ButtonTextComponent));
53  if(!buttonComp)
54  continue;
55 
56  buttonComp.m_OnFocus.Insert(OnLinkButtonFocus);
57  }
58  }
59 
60  m_Previous = SCR_InputButtonComponent.GetInputButtonComponent(m_sPreviousName, w);
61  if (m_Previous)
62  m_Previous.m_OnActivated.Insert(OnPrevious);
63 
64  m_Next = SCR_InputButtonComponent.GetInputButtonComponent(m_sNextName, w);
65  if (m_Next)
66  m_Next.m_OnActivated.Insert(OnNext);
67 
68  Widget hint = w.FindAnyWidget(m_sSelectionHintName);
69  if (hint)
70  {
71  m_SelectionHint = SCR_SelectionHintComponent.Cast(hint.FindHandler(SCR_SelectionHintComponent));
72  if (m_SelectionHint)
73  {
74  m_SelectionHint.SetItemCount(m_aPageTexts.Count(), false);
75  m_SelectionHint.SetCurrentItem(m_iCurrentIndex, false);
76  }
77  }
78 
79  ShowIndex(0);
80  }
81 
82  //------------------------------------------------------------------------------------------------
83  override void OnMenuUpdate(float tDelta)
84  {
85  super.OnMenuUpdate(tDelta);
86 
87  GetGame().GetInputManager().ActivateContext("InteractableDialogContext");
88  }
89 
90  //------------------------------------------------------------------------------------------------
91  override void OnConfirm()
92  {
94  if(!m_wLastFocusedLinkButton || GetGame().GetInputManager().GetLastUsedInputDevice() != EInputDeviceType.MOUSE)
95  return;
96 
97  SCR_BrowserLinkComponent linkComp = SCR_BrowserLinkComponent.Cast(m_wLastFocusedLinkButton.FindHandler(SCR_BrowserLinkComponent));
98  linkComp.OpenBrowser();
99  }
100 
101  //------------------------------------------------------------------------------------------------
102  protected void OnPrevious()
103  {
104  ShowIndex(m_iCurrentIndex - 1);
105  }
106 
107  //------------------------------------------------------------------------------------------------
108  protected void OnNext()
109  {
110  ShowIndex(m_iCurrentIndex + 1);
111  }
112 
113  //------------------------------------------------------------------------------------------------
114  protected void OnLinkButtonFocus(Widget linkButton)
115  {
116  SCR_BrowserLinkComponent linkComp = SCR_BrowserLinkComponent.Cast(linkButton.FindHandler(SCR_BrowserLinkComponent));
117 
118  m_wLastFocusedLinkButton = linkButton;
119  }
120 
121  //------------------------------------------------------------------------------------------------
122  protected void ShowIndex(int index)
123  {
124  if (index < 0 || index > m_iMaxIndex)
125  return;
126 
127  m_iCurrentIndex = index;
128 
129  if (m_wLinks)
130  m_wLinks.SetVisible(index == m_iMaxIndex);
131 
132  if(index == m_iMaxIndex && !m_wLinkButtons.IsEmpty())
133  {
135  if(!m_wLastFocusedLinkButton)
136  m_wLastFocusedLinkButton = m_wLinkButtons[0];
137  GetGame().GetWorkspace().SetFocusedWidget(m_wLastFocusedLinkButton);
138 
139  /*
140  if (m_Confirm)
141  //m_Confirm.SetVisible(true);
142  */
143  }
144  else
145  {
146  /*
147  if (m_Confirm)
148  m_Confirm.SetVisible(false);
149  */
150 
152  GetGame().GetWorkspace().SetFocusedWidget(null);
153  }
154 
155  if (m_Previous)
156  m_Previous.SetEnabled(index != 0);
157 
158  if (m_Next)
159  m_Next.SetEnabled(index != m_iMaxIndex);
160 
161  if (m_wText)
162  m_wText.SetTextFormat(m_aPageTexts[index]);
163 
164  if (m_SelectionHint)
165  m_SelectionHint.SetCurrentItem(index);
166  }
167 
168 };
169 
170 
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
GetRootWidget
Widget GetRootWidget()
Definition: SCR_UITaskManagerComponent.c:160
SCR_WidgetHelper
Definition: SCR_WidgetHelper.c:1
WelcomeDialogUI
Definition: WelcomeDialog.c:2
SCR_ButtonTextComponent
Definition: SCR_ButtonTextComponent.c:2
DialogUI
Definition: DialogUI.c:1
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
SCR_SelectionHintComponent
Definition: SCR_SelectionHintComponent.c:2
GetInputManager
protected InputManager GetInputManager()
Definition: SCR_BaseManualCameraComponent.c:65
SCR_InputButtonComponent
Definition: SCR_InputButtonComponent.c:1