Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_FeedbackDialogUI.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
3{
5 protected string m_sTypeTag;
6 protected string m_sTypeName;
8 protected string m_sCategoryTag;
9 protected string m_sCategoryName;
10
12 protected bool m_bPrivate;
13
15 protected string m_sContent;
16
18 protected string m_sUserName;
19
22 protected string m_sBuildTime;
24 protected string m_sBuildVersion;
25
28 protected string m_sWorldFile;
31 protected string m_sSubmitTime;
32
37
39 protected string m_sMessage;
40
41 //------------------------------------------------------------------------------------------------
43 {
44 const string altsep = "-----------------------------\n";
45 string res = "\n";
46
47 res += string.Format("Type: %1\n", GetFeedbackType());
48 res += string.Format("Category: %1\n", GetFeedbackCategory());
49 res += string.Format("User: %1\n", GetUserName());
50
51 // assembly link to WE
52 res += string.Format("<enfusion://WorldEditor/%1;%2,%3,%4;%5,%6,%7|Enfusion Link>\n",
60
61 res += string.Format("Build Version: %1\n", GetBuildVersion());
62 res += string.Format("Submit Time: %1\n", GetFeedbackSubmitTime());
63 res += string.Format("Build Time: %1\n", GetBuildTime());
64 res += string.Format("World File: %1\n", GetWorldFile());
65
66 // position && message
67 res += string.Format("Position: %1\n", m_vWorldPosition.ToString());
68 res += string.Format("Rotation: %1\n", m_vWorldRotation.ToString());
69
70 res += altsep;
71 res += "FEEDBACK USER DATA:\n";
72 res += m_sContent;
73
74
75 m_sMessage = res;
76
77 return m_sMessage;
78 }
79
80 //------------------------------------------------------------------------------------------------
81 string GetWorldFile()
82 {
83 return m_sWorldFile;
84 }
85
86 //------------------------------------------------------------------------------------------------
87 string GetUserName()
88 {
89 return m_sUserName;
90 }
91
92 //------------------------------------------------------------------------------------------------
93 string GetBuildTime()
94 {
95 return m_sBuildTime;
96 }
97
98 //------------------------------------------------------------------------------------------------
100 {
101 return m_sBuildVersion;
102 }
103
104 //------------------------------------------------------------------------------------------------
106 {
107 return m_sSubmitTime;
108 }
109
110 //------------------------------------------------------------------------------------------------
112 {
113 return m_sTypeName;
114 }
115
116 //------------------------------------------------------------------------------------------------
118 {
119 return m_sCategoryName;
120 }
121
122 //------------------------------------------------------------------------------------------------
124 {
125 return m_bPrivate;
126 }
127
128 //------------------------------------------------------------------------------------------------
130 {
131 return m_sContent;
132 }
133
134 //------------------------------------------------------------------------------------------------
135 protected string GetCurrentTimestamp()
136 {
137 int year, month, day, hour, minute, sec;
138 System.GetYearMonthDay(year, month, day);
139 System.GetHourMinuteSecond(hour, minute, sec);
140 string smonth, sday, shour, sminute, ssec;
141 if (month < 10)
142 smonth = string.Format("0%1", month);
143 else
144 smonth = string.Format("%1", month);
145
146 if (day < 10)
147 sday = string.Format("0%1", day);
148 else
149 sday = string.Format("%1", day);
150
151 if (hour < 10)
152 shour = string.Format("0%1", hour);
153 else
154 shour = string.Format("%1", hour);
155
156 if (minute < 10)
157 sminute = string.Format("0%1", minute);
158 else
159 sminute = string.Format("%1", minute);
160
161 if (sec < 10)
162 ssec = string.Format("0%1", sec);
163 else
164 ssec = string.Format("%1", sec);
165
166 return string.Format("%1-%2-%3 %4:%5:%6", year, smonth, sday, shour, sminute, ssec);
167 }
168
169 //------------------------------------------------------------------------------------------------
170 protected bool FetchCoords()
171 {
172 ArmaReforgerScripted game = GetGame();
173 if (game)
174 {
175 BaseWorld world = game.GetWorld();
176 if (world)
177 {
178 int cameraId = world.GetCurrentCameraId();
179 // get current engine camera transformation
180 vector mat[4];
181 world.GetCamera(cameraId, mat);
182 vector yawPitchRoll = Math3D.MatrixToAngles(mat);
183 m_vWorldPosition = mat[3];
184
185 // yawpitchroll->pitchyawroll
186 m_vWorldRotation[0] = yawPitchRoll[1];
187 m_vWorldRotation[1] = yawPitchRoll[0];
188 m_vWorldRotation[2] = yawPitchRoll[2];
189 return true;
190 }
191 }
192
193 // Plausible defaults
194 m_vWorldPosition = Vector(0, 0, 0);
195 m_vWorldRotation = Vector(0, 0, 0);
196 return false;
197 }
198
199 //------------------------------------------------------------------------------------------------
201 void FeedbackData(string typeTag, string typeName, string catTag, string catName, bool bPrivate, string content)
202 {
203 // ...
204 // data below are structured, send as JSON!
205 RegV("m_sTypeName");
206 RegV("m_sCategoryName");
207 RegV("m_bPrivate");
208 RegV("m_sContent");
209 RegV("m_sUserName");
210
211 RegV("m_sBuildTime");
212 RegV("m_sBuildVersion");
213
214 RegV("m_sWorldFile");
215 RegV("m_sSubmitTime");
216
217 RegV("m_vWorldPosition");
218 RegV("m_vWorldRotation");
219 // ...
220
221
222 m_sTypeTag = typeTag;
223 m_sCategoryTag = catTag;
224
225 m_sTypeName = typeName;
226 m_sCategoryName = catName;
227
228 m_bPrivate = bPrivate;
229
231
232 ArmaReforgerScripted game = GetGame();
233 if (!game)
234 return;
235
236 // TODO: Not sure if the user name should be directly sent. Same goes for platform specific UID
237 m_sUserName = SCR_Global.GetProfileName();
238 m_sBuildTime = game.GetBuildTime();
239 m_sBuildVersion = game.GetBuildVersion();
240
241 m_sWorldFile = game.GetWorldFile();
243
244 // Fetch coords data
245 FetchCoords();
246 }
247
248}
249
250sealed class SCR_FeedbackDialogUI : SCR_ConfigurableDialogUi
251{
253 static const int TYPE_NAMES_COUNT = 2;
254 static const string TYPE_TAGS[TYPE_NAMES_COUNT] =
255 {
256 "feedback",
257 "issue"
258 };
259
260 static const LocalizedString TYPE_NAMES[TYPE_NAMES_COUNT] =
261 {
262 "#AR-MainMenu_Feedback_Name",
263 "#AR-Feedback_Issue"
264 };
265
267 static const int CATEGORY_NAMES_COUNT = 8;
268 static const string CATEGORY_TAGS[CATEGORY_NAMES_COUNT] =
269 {
270 "general",
271 "ui",
272 "editor",
273 "character",
274 "vehicles",
275 "weapons",
276 "multiplayer",
277 "conflict"
278 };
279
280 static const LocalizedString CATEGORY_NAMES[CATEGORY_NAMES_COUNT] =
281 {
282 "#AR-Feedback_General",
283 "#AR-Feedback_UI",
284 "#AR-MainMenu_Editor_Name",
285 "#AR-Feedback_Character",
286 "#AR-Feedback_Vehicles",
287 "#AR-Feedback_Weapons",
288 "#AR-MainMenu_Multiplayer_Name",
289 "#AR-MainMenu_Conflict_Name"
290 };
291
294
297
298 protected const string TOS_BUTTON = "ProfileTOS";
299 protected const string TOS_LINK = "Link_PrivacyPolicy";
300
301 protected static const string FEEDBACK_DIALOG_NAME = "feedback_dialog";
302
303 protected static ref FeedbackData m_LastFeedback;
304 protected static float m_fLastFeedbackTime = -float.MAX;
305 protected static const float FEEDBACK_SEND_TIMEOUT = 5000; // ms
306
308
309 //------------------------------------------------------------------------------------------------
310 override protected void OnConfirm()
311 {
312 if (!m_Widgets.m_FeedbackTypeComponent0 || !m_Widgets.m_FeedbackCategoryComponent0 || !m_Widgets.m_FeedbackEditBoxComponent || !m_Widgets.m_ConsoleFeedbackTopicComponent0)
313 return;
314
315 // Fetch feedback data
316
317 // Selected type (Feedback or issue)
318 int type = m_Widgets.m_FeedbackTypeComponent0.GetCurrentIndex();
319
320 // Selected category (general, ui, editor, etc)
321 int category = m_Widgets.m_FeedbackCategoryComponent0.GetCurrentIndex();
322
323 // User written content from editbox
324 string content = m_Widgets.m_FeedbackEditBoxComponent.GetValue();
325
326 // Selected topic (only availabe on console. string.Empty by default)
327 array<LocalizedString> predefinedAnswers = m_FeedbackSentences.GetSentencesByIndex(category);
328 string console_sentence = predefinedAnswers[m_Widgets.m_ConsoleFeedbackTopicComponent0.GetCurrentIndex()];
329
330 // Put the selected topic in front of the message
331 if (System.GetPlatform() != EPlatform.WINDOWS)
332 content = string.Format("%1 %2", console_sentence, content);
333
334 // Get the state of the AttachLogs button (1 = Log should be attached, 0 = no log will be attached)
335 bool attachLogs;
336 if (m_Widgets.m_AttachLogsButtonComponent)
337 attachLogs = m_Widgets.m_AttachLogsButtonComponent.IsToggled();
338
339 // OnAttachFile() also handles when the button to attach a File is clicked
340
341 // Current implementation of sending Feedback to backend (will probably be changed)
342 SendFeedback(content, type, category, false);
343
344 super.OnConfirm();
345 }
346
347 //------------------------------------------------------------------------------------------------
348 override void OnMenuShow()
349 {
350 if (m_Widgets.m_FeedbackTypeComponent0)
351 GetGame().GetWorkspace().SetFocusedWidget(m_Widgets.m_FeedbackTypeComponent0.GetRootWidget());
352 }
353
354 //------------------------------------------------------------------------------------------------
355 static bool CanSendFeedback()
356 {
357 BaseWorld world = GetGame().GetWorld();
358 if (!world)
359 return false;
360
361 float timeSinceLast = world.GetWorldTime() - m_fLastFeedbackTime;
362 return timeSinceLast > FEEDBACK_SEND_TIMEOUT;
363 }
364
365 //------------------------------------------------------------------------------------------------
366 static void SendFeedback(string content, int type, int category, bool bPrivate)
367 {
368 // Create container for our feedback
369 m_LastFeedback = null;
370 m_LastFeedback = new FeedbackData(TYPE_TAGS[type], TYPE_NAMES[type], CATEGORY_TAGS[category], CATEGORY_NAMES[category], bPrivate, content);
371 string summary = m_LastFeedback.FormatMessage();
372
373 GetGame().GetBackendApi().FeedbackMessage(null, m_LastFeedback, summary);
374 m_fLastFeedbackTime = GetGame().GetWorld().GetWorldTime();
375 }
376
377 //------------------------------------------------------------------------------------------------
378 static void ClearFeedback()
379 {
380 m_LastFeedback = null;
381 }
382
383 //------------------------------------------------------------------------------------------------
384 protected void OnAttachFile()
385 {
386 //TODO:LangePaul Create Screenshot and attach it to feedback
387 }
388
389 //------------------------------------------------------------------------------------------------
390 private void OnTOSButton()
391 {
392 GetGame().GetMenuManager().OpenMenu(ChimeraMenuPreset.PrivacyPolicyMenu);
393 Close();
394 }
395
396 //------------------------------------------------------------------------------------------------
397 override void OnMenuOpen(SCR_ConfigurableDialogUiPreset preset)
398 {
399 super.OnMenuOpen(preset);
400
401 m_FeedbackSentences = new SCR_FeedbackDialogPredefinedSentences();
403
404 m_Widgets = new SCR_FeedbackDialogContentWidgets();
406
407 if (m_Widgets.m_FeedbackTypeComponent0)
408 {
409 for (int i = 0; i < TYPE_NAMES_COUNT; i++)
410 {
411 m_Widgets.m_FeedbackTypeComponent0.AddItem(TYPE_NAMES[i]);
412 }
413 m_Widgets.m_FeedbackTypeComponent0.SetCurrentItem(0);
414 }
415
416 if (m_Widgets.m_ConsoleFeedbackTopicComponent0 && System.GetPlatform() == EPlatform.WINDOWS)
417 m_Widgets.m_ConsoleFeedbackTopicComponent0.SetVisible(false);
418 else if (m_Widgets.m_ConsoleFeedbackTopicComponent0)
419 m_Widgets.m_ConsoleFeedbackTopicComponent0.SetCurrentItem(0);
420
421 if (m_Widgets.m_FeedbackCategoryComponent0)
422 {
423 for (int i = 0; i < CATEGORY_NAMES_COUNT; i++)
424 {
425 m_Widgets.m_FeedbackCategoryComponent0.AddItem(CATEGORY_NAMES[i]);
426 }
427 m_Widgets.m_FeedbackCategoryComponent0.m_OnChanged.Insert(OnCategoryChanged);
428 m_Widgets.m_FeedbackCategoryComponent0.SetCurrentItem(0);
430 }
431
433 if (m_TOSButton)
434 m_TOSButton.m_OnActivated.Insert(OnTOSButton);
435
436 m_ConfirmButton = FindButton(BUTTON_CONFIRM);
437 if (m_ConfirmButton)
438 m_ConfirmButton.SetEnabled(false);
439
440 if (m_Widgets.m_FeedbackEditBoxComponent)
441 {
442 m_Widgets.m_FeedbackEditBoxComponent.m_OnWriteModeLeave.Insert(OnWriteModeLeaveInternal);
443 m_Widgets.m_FeedbackEditBoxComponent.m_OnTextChange.Insert(OnTextChange);
444 }
445
446 if (m_Widgets.m_AttachFileButtonComponent)
447 m_Widgets.m_AttachFileButtonComponent.m_OnClicked.Insert(OnAttachFile);
448
449 // AttachLogs button should not be visible on consoles
450 if (m_Widgets.m_AttachLogsButtonComponent && System.GetPlatform() != EPlatform.WINDOWS)
451 {
452 m_Widgets.m_wAttachFileVertialLayout.SetVisible(false);
453 m_Widgets.m_AttachLogsButtonComponent.SetVisible(false);
454 m_Widgets.m_AttachLogsButtonComponent.SetEnabled(false);
455 m_Widgets.m_AttachFileButtonComponent.SetVisible(false);
456 m_Widgets.m_AttachFileButtonComponent.SetEnabled(false);
457 }
458 }
459
460 //------------------------------------------------------------------------------------------------
461 protected void OnWriteModeLeaveInternal(string text)
462 {
463 OnTextChange(text);
464 }
465
466 //------------------------------------------------------------------------------------------------
467 protected void OnTextChange(string text)
468 {
469 if (m_Widgets.m_FeedbackEditBoxComponent)
470 m_bShouldEnableConfirmButton = m_Widgets.m_FeedbackEditBoxComponent.GetValue() != string.Empty && SCR_FeedbackDialogUI.CanSendFeedback();
471
472 if (m_ConfirmButton)
474 }
475
476 //------------------------------------------------------------------------------------------------
477 protected void OnCategoryChanged(SCR_ComboBoxComponent comp = null, int index = 0)
478 {
479 if (!m_Widgets.m_ConsoleFeedbackTopicComponent0 || !m_Widgets.m_ConsoleFeedbackTopicComponent0.IsVisible())
480 return;
481
482 m_Widgets.m_ConsoleFeedbackTopicComponent0.ClearAll();
483
484 array<LocalizedString> sentences = m_FeedbackSentences.GetSentencesByIndex(index);
485
486 foreach(LocalizedString sentence : sentences)
487 {
488 m_Widgets.m_ConsoleFeedbackTopicComponent0.AddItem(sentence);
489 }
490
491 m_Widgets.m_ConsoleFeedbackTopicComponent0.SetCurrentItem(0);
492 }
493
494 //------------------------------------------------------------------------------------------------
495 static SCR_FeedbackDialogUI OpenFeedbackDialog()
496 {
497 SCR_FeedbackDialogUI dialog = new SCR_FeedbackDialogUI();
498 SCR_ConfigurableDialogUi.CreateFromPreset(SCR_CommonDialogs.DIALOGS_CONFIG, FEEDBACK_DIALOG_NAME, dialog);
499
500 return dialog;
501 }
502}
class RestAPIHelper< JsonApiStruct T > content
ChimeraMenuPreset
Menu presets.
ref DSGameConfig game
Definition DSConfig.c:81
ArmaReforgerScripted GetGame()
Definition game.c:1398
string LocalizedString
void OnTextChange(string text)
If number was inserted into current EditBox, add that number to the string and go to next EditBox....
EDamageType type
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
ref SCR_FeedbackDialogPredefinedSentences m_FeedbackSentences
SCR_InputButtonComponent m_TOSButton
class FeedbackData extends JsonApiStruct TYPE_NAMES_COUNT
Available types of feedback.
bool m_bShouldEnableConfirmButton
void OnAttachFile()
const string TOS_LINK
void OnCategoryChanged(SCR_ComboBoxComponent comp=null, int index=0)
void OnWriteModeLeaveInternal(string text)
const string TOS_BUTTON
ref SCR_HeaderNavigationWidgets m_Widgets
SCR_MotionControlCalibrationPromptDialog m_ConfirmButton
override void OnMenuOpen()
base classes for filtering in server browser
string m_sTypeTag
Type of feedback: issue, feedback..
string m_sUserName
User data.
string m_sContent
User provided content.
string m_sCategoryTag
Category of feedback: character, vehicle, UI..
void FeedbackData(string typeTag, string typeName, string catTag, string catName, bool bPrivate, string content)
Creates feedback data container.
bool m_bPrivate
Visibility of feedback.
string m_sMessage
Message string for Slack (not part of JSON).
string m_sBuildVersion
Game build version.
vector m_vWorldRotation
Current camera orientation taken from camera if any.
vector m_vWorldPosition
Current world position taken from camera if any.
Widget GetContentLayoutRoot()
Returns the root of the content layout.
SCR_InputButtonComponent FindButton(string tag)
Returns a button with given tag.
EPlatform
Definition EPlatform.c:13
proto external string ToString()
Plain C++ pointer, no weak pointers, no memory management.
proto native vector Vector(float x, float y, float z)