Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
DialogUI.c
Go to the documentation of this file.
2{
4
9
12
17 protected float m_fAnimationRate = UIConstants.FADE_RATE_FAST;
18
20
22
23 //------------------------------------------------------------------------------------------------
24 override void OnMenuOpen()
25 {
26 super.OnMenuOpen();
27
29
30 // Cancel button
31 m_wCancelButton = w.FindAnyWidget("Cancel");
33 {
35 if (m_Cancel)
36 m_Cancel.m_OnActivated.Insert(OnCancel);
37 }
38
39 // Confirm button
40 m_wConfirmButton = w.FindAnyWidget("Confirm");
42 {
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
58
59 // Set dialog type
60 if (m_DialogData)
61 SetDialogType(m_DialogData.m_iDialogType);
62
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();
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 //------------------------------------------------------------------------------------------------
108 {
110
111 // Check widgets
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 //------------------------------------------------------------------------------------------------
190 {
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 //------------------------------------------------------------------------------------------------
221 {
223 int delay;
224 if (m_fAnimationRate > 0)
225 delay = 1 / m_fAnimationRate * 1000;
226 GetGame().GetCallqueue().CallLater(Close, delay);
227 }
228
229 //------------------------------------------------------------------------------------------------
234};
235
EDialogType
Definition DialogUI.c:237
@ MESSAGE
Definition DialogUI.c:238
@ POSITIVE
ArmaReforgerScripted GetGame()
Definition game.c:1398
@ ACTION
EDamageType type
Widget GetRootWidget()
enum SCR_EServicePointType ONLINE
proto native void Close()
static WidgetAnimationOpacity Opacity(Widget widget, float targetValue, float speed, bool toggleVisibility=false)
Constant variables used in various menus.
Definition Color.c:13
Widget m_wCancelButton
Definition DialogUI.c:5
override void OnMenuClose()
Definition DialogUI.c:75
void SetMessage(string text)
Definition DialogUI.c:159
SCR_DynamicFooterComponent GetFooterComponent()
Definition DialogUI.c:230
void SetTitleIcon(string imageName)
Set title icon by image name from image set in dialog data.
Definition DialogUI.c:210
ImageWidget m_wImgTopLine
Definition DialogUI.c:10
void CloseAnimated()
animates dialog closure
Definition DialogUI.c:220
override void OnMenuUpdate(float tDelta)
Definition DialogUI.c:82
ref ScriptInvoker m_OnConfirm
Definition DialogUI.c:15
ImageWidget m_wImgTitleIcon
Definition DialogUI.c:11
void SetTitle(string text)
Definition DialogUI.c:143
SCR_InputButtonComponent m_Cancel
Definition DialogUI.c:7
SCR_DialogDataComponent m_DialogData
Definition DialogUI.c:3
ref ScriptInvoker m_OnCancel
Definition DialogUI.c:16
Widget m_wConfirmButton
Definition DialogUI.c:6
SCR_DynamicFooterComponent m_DynamicFooter
Definition DialogUI.c:21
string GetTitle()
Definition DialogUI.c:150
void SetCancelText(string text)
Definition DialogUI.c:182
float m_fAnimationRate
Definition DialogUI.c:17
void OnConfirm()
Definition DialogUI.c:90
void SetTitleIcon(ResourceName image, string imageName)
Set title icons with custom image.
Definition DialogUI.c:196
EDialogType m_iDialogType
Definition DialogUI.c:19
override void OnMenuInit()
Definition DialogUI.c:67
override void OnMenuOpen()
Definition DialogUI.c:24
SCR_InputButtonComponent m_Confirm
Definition DialogUI.c:8
void OnCancel()
Definition DialogUI.c:98
void SetConfirmText(string text)
Definition DialogUI.c:175
TextWidget m_wContent
Definition DialogUI.c:14
TextWidget m_wTitle
Definition DialogUI.c:13
void SetDialogType(EDialogType type)
Set color based on dialog type.
Definition DialogUI.c:107
string GetMessage()
Definition DialogUI.c:166
void SetType(EDialogType type)
Definition DialogUI.c:189
static SCR_InputButtonComponent FindComponent(notnull Widget w)
static void OnDialogClose(DialogUI dialog)
Called by DialogUI.
static void OnDialogOpen(DialogUI dialog)
@ WARNING
Definition LogLevel.c:19
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134