Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
ReportDialogUI.c
Go to the documentation of this file.
2 {
3  protected ContentBrowserDetailsMenu m_DetailsMenu;
4 
5  protected SCR_ComboBoxComponent m_ReasonCombo;
6  protected SCR_EditBoxComponent m_InputField;
7 
8  protected Widget m_wDialogWindow;
9 
10  protected SCR_LoadingOverlayDialog m_Overlay;
11 
12  protected bool m_bAcceptInput = true;
13 
14  protected ref SCR_WorkshopItemAction m_ReportAction;
15 
16  protected bool m_bShouldEnableConfirmButton;
17 
18  protected ref ScriptInvokerBool m_OnReportSuccess;
19 
20  //------------------------------------------------------------------------------------------------
21  override void OnMenuOpen()
22  {
23  super.OnMenuOpen();
24  Widget root = GetRootWidget();
25 
26  m_InputField = SCR_EditBoxComponent.GetEditBoxComponent("InputField", root);
27  if (m_InputField)
28  m_InputField.m_OnChanged.Insert(OnFieldChanged);
29 
30  m_ReasonCombo = SCR_ComboBoxComponent.GetComboBoxComponent("ReasonCombo", root);
31  if (m_ReasonCombo)
32  {
33  m_ReasonCombo.ClearAll();
34  string reportTypeStr = SCR_WorkshopUiCommon.GetReportTypeString(0);
35  int i = 1;
36  while (!reportTypeStr.IsEmpty())
37  {
38  m_ReasonCombo.AddItem(reportTypeStr);
39  reportTypeStr = SCR_WorkshopUiCommon.GetReportTypeString(i);
40  i++;
41  }
42  m_ReasonCombo.SetCurrentItem(0);
43  }
44 
45  m_wDialogWindow = root.FindAnyWidget("DialogBase0");
46 
47  // Disable the confirm button initially because text is empty
48  m_Confirm.SetEnabled(false);
49 
50  if(m_InputField)
51  {
52  m_InputField.m_OnWriteModeLeave.Insert(OnWriteModeLeave);
53  m_InputField.m_OnTextChange.Insert(OnTextChange);
54  }
55 
56  SCR_InputButtonComponent tos = SCR_InputButtonComponent.GetInputButtonComponent("ToS", GetRootWidget());
57  if (tos)
58  tos.m_OnActivated.Insert(OnTos);
59  }
60 
61  //------------------------------------------------------------------------------------------------
62  override void OnMenuShow()
63  {
64  super.OnMenuShow();
65  if (m_InputField)
66  GetGame().GetWorkspace().SetFocusedWidget(m_InputField.GetRootWidget());
67  }
68 
69  //------------------------------------------------------------------------------------------------
70  override void OnMenuUpdate(float tDelta)
71  {
72  super.OnMenuUpdate(tDelta);
73 
74  GetGame().GetInputManager().ActivateContext("InteractableDialogContext");
75  }
76 
77  //------------------------------------------------------------------------------------------------
78  override protected void OnConfirm()
79  {
80  if (!m_bAcceptInput)
81  return;
82 
83  m_OnConfirm.Invoke();
84  //super.OnConfirm(); // we don't want to close the dialog
85 
86  // Fetch feedback data
87 
88  int category;
89  int reason;
90  string content = "";
91 
92  if (m_ReasonCombo)
93  {
94  category = m_ReasonCombo.GetCurrentIndex();
95  reason = category;
96  }
97 
98  if (m_InputField)
99  content = m_InputField.GetValue();
100 
101  // Show loading screen
102  m_Overlay = SCR_LoadingOverlayDialog.Create();
103 
104  // Reactivating previous report
105  if (m_ReportAction)
106  {
107  m_ReportAction.Reactivate();
108  return;
109  }
110 
111  // Report
112  m_ReportAction = ContentBrowserDetailsMenu.GetWorkshopItem().Report(reason, content);
113 
114  m_ReportAction.m_OnCompleted.Insert(OnReportSuccess);
115  m_ReportAction.m_OnFailed.Insert(OnReportFailed);
116 
117  m_ReportAction.Activate();
118  }
119 
120  //------------------------------------------------------------------------------------------------
121  protected void OnReportSuccess()
122  {
123  if (m_OnReportSuccess)
124  m_OnReportSuccess.Invoke(false);
125 
126  ContentBrowserDetailsMenu.GetWorkshopItem().DeleteLocally();
127  ContentBrowserDetailsMenu.GetWorkshopItem().SetSubscribed(false);
128 
129  // Cancel download
130  SCR_DownloadManager mgr = SCR_DownloadManager.GetInstance();
131  if (mgr)
132  {
133  SCR_WorkshopItemActionDownload action = mgr.GetActionOfItem(ContentBrowserDetailsMenu.GetWorkshopItem());
134  if (action)
135  action.Cancel();
136  }
137 
138  if (m_Overlay)
139  m_Overlay.Close();
140 
141  Close();
142  }
143 
144  //------------------------------------------------------------------------------------------------
145  protected void OnReportFailed(SCR_WorkshopItemAction action)
146  {
147  if (m_Overlay)
148  m_Overlay.Close();
149  }
150 
151  //------------------------------------------------------------------------------------------------
152  protected void SetAcceptInput(bool accept)
153  {
154  m_bAcceptInput = accept;
155  }
156 
157  //------------------------------------------------------------------------------------------------
159  protected bool IsContentEmpty()
160  {
161  if (m_InputField)
162  {
163  string txt = m_InputField.GetValue();
164  return txt.Length() <= 0;
165  }
166 
167  return true;
168  }
169 
170  //------------------------------------------------------------------------------------------------
171  protected void OnWriteModeLeave(string text)
172  {
173  OnTextChange(text);
174  }
175 
176  //------------------------------------------------------------------------------------------------
177  protected void OnTextChange(string text)
178  {
179  if (!m_Confirm || !m_InputField)
180  return;
181 
182  m_Confirm.SetEnabled(!m_InputField.GetValue().IsEmpty());
183  }
184 
185 
186  //------------------------------------------------------------------------------------------------
187  protected void OnFieldChanged(SCR_EditBoxComponent comp, string text)
188  {
189  if (m_Confirm)
190  m_Confirm.SetEnabled(text.Length() > 0);
191  }
192 
193  //------------------------------------------------------------------------------------------------
194  protected void OnTos()
195  {
196  GetGame().GetPlatformService().OpenBrowser(GetGame().GetBackendApi().GetLinkItem("Link_PrivacyPolicy"));
197  }
198 
199  //------------------------------------------------------------------------------------------------
200  ScriptInvokerBool GetOnReportSuccess()
201  {
202  if (!m_OnReportSuccess)
203  m_OnReportSuccess = new ScriptInvokerBool();
204 
205  return m_OnReportSuccess;
206  }
207 }
SCR_ComboBoxComponent
Definition: SCR_ComboBoxComponent.c:1
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_WorkshopItemActionDownload
Definition: SCR_WorkshopItemActionDownload.c:9
ContentBrowserDetailsMenu
Definition: ContentBrowserDetailsMenu.c:2
GetRootWidget
Widget GetRootWidget()
Definition: SCR_UITaskManagerComponent.c:160
ScriptInvokerBool
ScriptInvokerBase< ScriptInvokerBoolMethod > ScriptInvokerBool
Definition: SCR_ScriptInvokerHelper.c:41
DialogUI
Definition: DialogUI.c:1
SCR_LoadingOverlayDialog
Definition: SCR_LoadingOverlayDialog.c:5
SCR_WorkshopItemAction
Definition: SCR_WorkshopItemAction.c:16
ReportDialogUI
Definition: ReportDialogUI.c:1
SCR_EditBoxComponent
Definition: SCR_EditBoxComponent.c:8
SCR_WorkshopUiCommon
Definition: SCR_WorkshopUiCommon.c:5
SCR_DownloadManager
Definition: SCR_DownloadManager.c:20
SCR_InputButtonComponent
Definition: SCR_InputButtonComponent.c:1
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180