Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
DialogUI.c
Go to the documentation of this file.
2 {
3  protected SCR_DialogDataComponent m_DialogData;
4 
5  protected Widget m_wCancelButton;
6  protected Widget m_wConfirmButton;
7  protected SCR_InputButtonComponent m_Cancel;
8  protected SCR_InputButtonComponent m_Confirm;
9 
10  protected ImageWidget m_wImgTopLine;
11  protected ImageWidget m_wImgTitleIcon;
12 
13  protected TextWidget m_wTitle;
14  protected TextWidget m_wContent;
15  ref ScriptInvoker m_OnConfirm = new ScriptInvoker();
16  ref ScriptInvoker m_OnCancel = new ScriptInvoker();
17  protected float m_fAnimationRate = UIConstants.FADE_RATE_FAST;
18 
19  protected EDialogType m_iDialogType;
20 
21  protected SCR_DynamicFooterComponent m_DynamicFooter;
22 
23  //------------------------------------------------------------------------------------------------
24  override void OnMenuOpen()
25  {
26  super.OnMenuOpen();
27 
28  Widget w = GetRootWidget();
29 
30  // Cancel button
31  m_wCancelButton = w.FindAnyWidget("Cancel");
32  if(m_wCancelButton)
33  {
34  m_Cancel = SCR_InputButtonComponent.FindComponent(m_wCancelButton);
35  if (m_Cancel)
36  m_Cancel.m_OnActivated.Insert(OnCancel);
37  }
38 
39  // Confirm button
40  m_wConfirmButton = w.FindAnyWidget("Confirm");
41  if(m_wConfirmButton)
42  {
43  m_Confirm = SCR_InputButtonComponent.FindComponent(m_wConfirmButton);
44  if (m_Confirm)
45  m_Confirm.m_OnActivated.Insert(OnConfirm);
46  }
47 
48  // Images
49  m_wImgTopLine = ImageWidget.Cast(w.FindAnyWidget("Separator"));
50  m_wImgTitleIcon = ImageWidget.Cast(w.FindAnyWidget("ImgTitleIcon"));
51 
52  // Texts
53  m_wTitle = TextWidget.Cast(w.FindAnyWidget("Title"));
54  m_wContent = TextWidget.Cast(w.FindAnyWidget("Message"));
55 
56  // Find dialog component
57  m_DialogData = SCR_DialogDataComponent.Cast( w.FindHandler(SCR_DialogDataComponent));
58 
59  // Set dialog type
60  if (m_DialogData)
61  SetDialogType(m_DialogData.m_iDialogType);
62 
63  SCR_MenuHelper.OnDialogOpen(this);
64  }
65 
66  //------------------------------------------------------------------------------------------------
67  override void OnMenuInit()
68  {
69  super.OnMenuInit();
70 
71  m_DynamicFooter = SCR_DynamicFooterComponent.FindComponentInHierarchy(GetRootWidget());
72  }
73 
74  //------------------------------------------------------------------------------------------------
75  override void OnMenuClose()
76  {
77  super.OnMenuClose();
78  SCR_MenuHelper.OnDialogClose(this);
79  }
80 
81  //------------------------------------------------------------------------------------------------
82  override void OnMenuUpdate(float tDelta)
83  {
84  super.OnMenuUpdate(tDelta);
85 
86  GetGame().GetInputManager().ActivateContext("DialogContext");
87  }
88 
89  //------------------------------------------------------------------------------------------------
90  protected void OnConfirm()
91  {
92  m_OnConfirm.Invoke();
93  //CloseAnimated();
94  Close();
95  }
96 
97  //------------------------------------------------------------------------------------------------
98  protected void OnCancel()
99  {
100  m_OnCancel.Invoke();
101  Close();
102  }
103 
104 
105  //------------------------------------------------------------------------------------------------
107  protected void SetDialogType(EDialogType type)
108  {
109  m_iDialogType = type;
110 
111  // Check widgets
112  if (!m_wImgTopLine || !m_wImgTitleIcon)
113  return;
114 
115  // Select color
116  Color color = Color.FromInt(Color.WHITE);
117 
118  switch (m_iDialogType)
119  {
120  case EDialogType.ACTION:
121  color = Color.FromInt(UIColors.CONTRAST_CLICKED_HOVERED.PackToInt());
122  break;
123 
124  case EDialogType.WARNING:
125  color = Color.FromInt(UIColors.WARNING.PackToInt());
126  break;
127 
128  case EDialogType.POSITIVE:
129  color = Color.FromInt(UIColors.CONFIRM.PackToInt());
130  break;
131 
132  case EDialogType.ONLINE:
133  color = Color.FromInt(UIColors.ONLINE.PackToInt());
134  break;
135  }
136 
137  // Set colors
138  m_wImgTopLine.SetColor(color);
139  m_wImgTitleIcon.SetColor(color);
140  }
141 
142  //------------------------------------------------------------------------------------------------
143  void SetTitle(string text)
144  {
145  if (m_wTitle)
146  m_wTitle.SetText(text);
147  }
148 
149  //------------------------------------------------------------------------------------------------
150  string GetTitle()
151  {
152  if (!m_wTitle)
153  return string.Empty;
154 
155  return m_wTitle.GetText();
156  }
157 
158  //------------------------------------------------------------------------------------------------
159  void SetMessage(string text)
160  {
161  if (m_wContent)
162  m_wContent.SetText(text);
163  }
164 
165  //------------------------------------------------------------------------------------------------
166  string GetMessage()
167  {
168  if (!m_wContent)
169  return string.Empty;
170 
171  return m_wContent.GetText();
172  }
173 
174  //------------------------------------------------------------------------------------------------
175  void SetConfirmText(string text)
176  {
177  if (m_Confirm)
178  m_Confirm.SetLabel(text);
179  }
180 
181  //------------------------------------------------------------------------------------------------
182  void SetCancelText(string text)
183  {
184  if (m_Cancel)
185  m_Cancel.SetLabel(text);
186  }
187 
188  //------------------------------------------------------------------------------------------------
189  void SetType(EDialogType type)
190  {
191  m_iDialogType = type;
192  }
193 
194  //------------------------------------------------------------------------------------------------
196  void SetTitleIcon(ResourceName image, string imageName)
197  {
198  if (!m_wImgTitleIcon)
199  return;
200 
201  // Set image by input
202  if (image.EndsWith("imageset"))
203  m_wImgTitleIcon.LoadImageFromSet(0, image, imageName);
204  else
205  m_wImgTitleIcon.LoadImageTexture(0, image);
206  }
207 
208  //------------------------------------------------------------------------------------------------
210  void SetTitleIcon(string imageName)
211  {
212  if (!m_DialogData)
213  return;
214 
215  m_wImgTitleIcon.LoadImageFromSet(0, m_DialogData.m_sIconSet, imageName);
216  }
217 
218  //------------------------------------------------------------------------------------------------
220  void CloseAnimated()
221  {
222  AnimateWidget.Opacity(GetRootWidget(), 0, m_fAnimationRate);
223  int delay;
224  if (m_fAnimationRate > 0)
225  delay = 1 / m_fAnimationRate * 1000;
226  GetGame().GetCallqueue().CallLater(Close, delay);
227  }
228 
229  //------------------------------------------------------------------------------------------------
230  SCR_DynamicFooterComponent GetFooterComponent()
231  {
232  return m_DynamicFooter;
233  }
234 };
235 
237 {
243 };
ChimeraMenuBase
Constant variables used in various menus.
Definition: ChimeraMenuBase.c:70
EDialogType
EDialogType
Definition: DialogUI.c:236
UIConstants
Definition: Constants.c:130
POSITIVE
@ POSITIVE
Definition: DialogUI.c:241
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
MESSAGE
@ MESSAGE
Definition: DialogUI.c:238
GetRootWidget
Widget GetRootWidget()
Definition: SCR_UITaskManagerComponent.c:160
SCR_DialogDataComponent
Definition: SCR_MenuDialogComponent.c:6
WARNING
@ WARNING
Definition: DialogUI.c:240
m_wContent
protected Widget m_wContent
Definition: SCR_InfoDisplay.c:64
UIColors
Definition: Constants.c:16
ONLINE
@ ONLINE
Definition: DialogUI.c:242
ACTION
@ ACTION
Definition: DialogUI.c:239
DialogUI
Definition: DialogUI.c:1
SCR_MenuHelper
Definition: SCR_MenuHelper.c:15
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
SCR_InputButtonComponent
Definition: SCR_InputButtonComponent.c:1