Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ModReportDialogComponent.c
Go to the documentation of this file.
2 {
3  // Const localized strings
4  protected const string MSG_SELECT = "#AR-Workshop_SelectMsg";
5  protected const string LINE_DOWNLOADED = "#AR-Workshop_Details_Downloaded";
6  protected const string TAG_AUTHOR_UNBLOCK = "unblock_author_simple";
7 
8  protected const int AUTHOR_MOD_LIMIT = 50;
9 
10  // Attributes
11  [Attribute("{ADEA32EB841E8629}Configs/ContentBrowser/ContentBrowserReportDialogs.conf", UIWidgets.ResourceNamePicker, "Layout of the navigation button", params: "layout")]
12  protected ResourceName m_sDialogsConfig;
13 
14  [Attribute("select_report")]
15  protected string m_sTagSelectReport;
16 
17  [Attribute("report_author")]
18  protected string m_sTagReportAuthor;
19 
20  // Variables
21  protected ref SCR_ConfigurableDialogUi m_CurrentDialog;
22  protected ReportDialogUI m_ReportDialog;
23 
24  protected ref SCR_WorkshopItem m_Item;
25  protected WorkshopAuthor m_Author;
26 
27  protected ref SCR_WorkshopApiCallback_RequestPage m_CallbackPage;
28  protected ref SCR_ContentBrowser_GetAssetListParams m_Params;
29 
30  protected ref array<ref SCR_ConfigurableDialogUi> m_aDialogs = {};
31  protected SCR_LoadingOverlayDialog m_LoadingOverlayDlg;
32 
33  protected ref array <ref SCR_WorkshopItem> m_aAuthorModsList = {};
34 
35  protected ref SCR_WorkshopItemActionAddAuthorBlock m_ActionAddAuthorBlock;
36  protected ref SCR_WorkshopItemActionRemoveAuthorBlock m_ActionRemoveAuthorBlock;
37 
38  protected ref ScriptInvokerVoid m_OnItemReportSuccessDialogClose;
39 
40  //------------------------------------------------------------------------------------------------
41  void OpenSelectReport(notnull SCR_WorkshopItem item)
42  {
43  m_CurrentDialog = SCR_ConfigurableDialogUi.CreateFromPreset(m_sDialogsConfig, m_sTagSelectReport);
44  if (!m_CurrentDialog)
45  return;
46 
47  m_aDialogs.Insert(m_CurrentDialog);
48 
49  m_Item = item;
50  m_Author = item.GetWorkshopItem().Author();
51 
52  // Message
53  string author = m_Item.GetAuthorName();
54  m_CurrentDialog.GetMessageWidget().SetTextFormat(MSG_SELECT, author);
55  m_CurrentDialog.GetMessageWidget().SetVisible(true);
56 
57  // Actions
58  m_CurrentDialog.m_OnConfirm.Insert(OnSelectReportConfirm);
59  m_CurrentDialog.m_OnCancel.Insert(OnSelectReportCancel);
60 
61  // Author report action
62  SCR_InputButtonComponent butAuthor = m_CurrentDialog.FindButton("report_author");
63  if (butAuthor)
64  butAuthor.m_OnActivated.Insert(OnSelectReportAuthor);
65  }
66 
67  //------------------------------------------------------------------------------------------------
68  protected void OnSelectReportConfirm(SCR_ConfigurableDialogUi dialog)
69  {
70  OpenReportThis();
71  m_CurrentDialog.ClearButtons();
72  }
73 
74  //------------------------------------------------------------------------------------------------
75  protected void OnSelectReportCancel(SCR_ConfigurableDialogUi dialog)
76  {
77  m_CurrentDialog.ClearButtons();
78  }
79 
80  //------------------------------------------------------------------------------------------------
81  void OnSelectReportAuthor()
82  {
83  if (m_CurrentDialog)
84  m_CurrentDialog.ClearButtons();
85 
86  if (!m_Author.IsBlocked())
87  {
88  // Block author
89  m_LoadingOverlayDlg = SCR_LoadingOverlayDialog.Create();
90  OpenReportAuthorModList();
91  }
92  else
93  {
94  // Show cancel report block
95  OpenRemoveAuthorBlockModList();
96  }
97  }
98 
99  //------------------------------------------------------------------------------------------------
101  void OpenReportThis()
102  {
103  m_ReportDialog = ReportDialogUI.Cast(GetGame().GetMenuManager().OpenDialog(ChimeraMenuPreset.ReportItemDialog));
104  if (!m_ReportDialog)
105  return;
106 
107  // Invoker actions
108  m_ReportDialog.GetOnReportSuccess().Insert(OnItemReportedSuccessfully);
109  m_ReportDialog.m_OnCancel.Insert(OnCancelThisReport);
110  }
111 
112  //------------------------------------------------------------------------------------------------
113  protected void OnItemReportedSuccessfully(bool isAuthorBlocked)
114  {
115  SCR_ConfigurableDialogUi dlg = SCR_WorkshopUiCommon.CreateDialog("report_success");
116  dlg.m_OnClose.Insert(OnItemReportSuccessDialogClose);
117 
118  // Message
119  string msg;
120 
121  if (!isAuthorBlocked)
122  msg = dlg.GetMessageStr() + "\n\n" ;
123 
124  msg += "#AR-Workshop_ReportModReverse";
125  dlg.GetMessageWidget().SetTextFormat(msg, "#AR-Workshop_Filter_Reported", "#AR-Workshop_CancelReport");
126  }
127 
128  //------------------------------------------------------------------------------------------------
129  protected void OnItemReportSuccessDialogClose()
130  {
131  if (m_OnItemReportSuccessDialogClose)
132  m_OnItemReportSuccessDialogClose.Invoke();
133  }
134 
135  //------------------------------------------------------------------------------------------------
136  protected void OnCancelThisReport()
137  {
138  if (m_ReportDialog)
139  m_ReportDialog.m_OnCancel.Remove(OnCancelThisReport);
140 
141  OpenSelectReport(m_Item);
142  }
143 
144  //------------------------------------------------------------------------------------------------
146  protected void OpenReportAuthorModList()
147  {
148  string author = m_Item.GetAuthorName();
149 
150  OpenAuthorModsDialog();
151 
152  // Setup message
153  string msg = "#AR-Workshop_ReportAuthorMsg";
154  SCR_AddonListDialog addonDialog = SCR_AddonListDialog.Cast(m_CurrentDialog);
155 
156  // Show affected mods only if there are any mods to be displayed
157  if (addonDialog && !addonDialog.GetDonwloadLines().IsEmpty())
158  msg += "\n\n#AR-Workshop_AffectedMods";
159 
160  m_CurrentDialog.GetMessageWidget().SetTextFormat(msg, author);
161 
162  // Actions
163  m_CurrentDialog.m_OnConfirm.Insert(OnConfirmReportAuthorModList);
164  m_CurrentDialog.m_OnCancel.Insert(OnCancelReportAuthorModList);
165  m_LoadingOverlayDlg.Close();
166  }
167 
168  //------------------------------------------------------------------------------------------------
170  protected void OpenRemoveAuthorBlockModList()
171  {
172  m_CurrentDialog = SCR_ConfigurableDialogUi.CreateFromPreset(m_sDialogsConfig, TAG_AUTHOR_UNBLOCK);
173 
174  // Add author to message
175  string msg = m_CurrentDialog.GetMessageStr();
176  string author = m_Item.GetAuthorName();
177  m_CurrentDialog.GetMessageWidget().SetTextFormat(msg, author);
178 
179  // Actions
180  m_CurrentDialog.m_OnConfirm.Insert(OnConfirmRemoveAuthorBlock);
181  m_CurrentDialog.m_OnCancel.Insert(OnCancelRemoveAuthorReport);
182  }
183 
184  //------------------------------------------------------------------------------------------------
185  protected void OpenAuthorModsDialog(bool showReported = true)
186  {
187  // Create dialog list
188  array<WorkshopItem> toReport = {};
189  if (m_Author.IsBlocked())
190  m_Author.GetPageItems(toReport);
191  else
192  m_Author.GetOfflineItems(toReport);
193 
194  m_aAuthorModsList.Clear();
195 
196  SCR_WorkshopItem scrItem;
197  foreach (WorkshopItem item : toReport)
198  {
199  scrItem = SCR_AddonManager.GetInstance().Register(item);
200  m_aAuthorModsList.Insert(scrItem);
201  }
202 
203  SCR_AddonListDialog dialog = SCR_AddonListDialog.CreateItemsList(m_aAuthorModsList, m_sTagReportAuthor, m_sDialogsConfig);
204  m_CurrentDialog = dialog;
205  if (!dialog)
206  return;
207 
208  m_aDialogs.Insert(m_CurrentDialog);
209 
210  // Show message
211  m_CurrentDialog.GetMessageWidget().SetVisible(true);
212 
213  // Mark mod entries
214  array<SCR_DownloadManager_AddonDownloadLine> lines = dialog.GetDonwloadLines();
215 
216  SCR_WorkshopItem item;
217  foreach (SCR_DownloadManager_AddonDownloadLine line : lines)
218  {
219  item = line.GetItem();
220 
221  // Owned
222  if (item.GetOffline())
223  {
224  line.DisplayError(LINE_DOWNLOADED);
225  continue;
226  }
227  }
228  }
229 
230  //------------------------------------------------------------------------------------------------
231  protected void OnConfirmReportAuthorModList()
232  {
233  // Block
234  m_ActionAddAuthorBlock = m_Item.AddAuthorBlock();
235 
236  m_ActionAddAuthorBlock.m_OnCompleted.Insert(OnAuthorReportSuccess);
237  m_ActionAddAuthorBlock.m_OnFailed.Insert(OnAuthorReportFail);
238 
239  if (!m_ActionAddAuthorBlock.Activate() && !m_ActionAddAuthorBlock.Reactivate())
240  return;
241 
242 
243  OnCancelReportAuthorModList();
244  m_LoadingOverlayDlg = SCR_LoadingOverlayDialog.Create();
245  }
246 
247  //------------------------------------------------------------------------------------------------
248  protected void OnConfirmRemoveAuthorBlock()
249  {
250  m_ActionRemoveAuthorBlock = m_Item.RemoveAuthorBlock();
251 
252  m_ActionRemoveAuthorBlock.m_OnCompleted.Insert(OnRemoveAuthorBlockSuccess);
253  m_ActionRemoveAuthorBlock.m_OnFailed.Insert(OnAuthorReportFail);
254 
255  if (!m_ActionRemoveAuthorBlock.Activate() && !m_ActionRemoveAuthorBlock.Reactivate())
256  return;
257 
258  OnCancelReportAuthorModList();
259  m_LoadingOverlayDlg = SCR_LoadingOverlayDialog.Create();
260  }
261 
262  //------------------------------------------------------------------------------------------------
263  protected void OnAuthorReportFail()
264  {
265  CloseDialogs();
266  m_LoadingOverlayDlg.Close();
267  }
268 
269  //------------------------------------------------------------------------------------------------
270  protected void OnAuthorReportSuccess()
271  {
272  OnItemReportedSuccessfully(true);
273 
274  SCR_DownloadManager mgr = SCR_DownloadManager.GetInstance();
275 
276  // Clear up all author items loading and remove from local storage
277  foreach (SCR_WorkshopItem item : m_aAuthorModsList)
278  {
279  item.DeleteLocally();
280  item.SetSubscribed(false);
281 
282  // Cancel download
283  if (!mgr)
284  continue;
285 
286  SCR_WorkshopItemActionDownload action = mgr.GetActionOfItem(item);
287  if (action)
288  action.Cancel();
289  }
290 
291  CloseDialogs();
292  m_LoadingOverlayDlg.Close();
293  }
294 
295  //------------------------------------------------------------------------------------------------
296  protected void CloseDialogs()
297  {
298  foreach (SCR_ConfigurableDialogUi dialog : m_aDialogs)
299  {
300  dialog.Close();
301  }
302 
303  m_aDialogs.Clear();
304  }
305 
306  //------------------------------------------------------------------------------------------------
307  protected void OnCancelReportAuthorModList()
308  {
309  m_CurrentDialog.m_OnConfirm.Remove(OnConfirmReportAuthorModList);
310  m_CurrentDialog.m_OnCancel.Remove(OnCancelReportAuthorModList);
311  }
312 
313  //------------------------------------------------------------------------------------------------
314  protected void OnRemoveAuthorBlockSuccess()
315  {
316  //m_CurrentDialog.Close();
317  m_LoadingOverlayDlg.Close();
318  }
319 
320  //------------------------------------------------------------------------------------------------
321  protected void OnCancelRemoveAuthorReport()
322  {
323  m_CurrentDialog.m_OnConfirm.Remove(OnRemoveAuthorBlockSuccess);
324  m_CurrentDialog.m_OnCancel.Remove(OnCancelRemoveAuthorReport);
325  }
326 
327  //------------------------------------------------------------------------------------------------
328  protected void OnCancelAuthorReport()
329  {
330  m_ReportDialog.m_OnCancel.Remove(OnCancelAuthorReport);
331  }
332 
333  //------------------------------------------------------------------------------------------------
334  void SetItem(notnull SCR_WorkshopItem item)
335  {
336  m_Item = item;
337  m_Author = item.GetWorkshopItem().Author();
338  }
339 
340  //------------------------------------------------------------------------------------------------
341  ScriptInvokerVoid GetOnItemReportSuccessDialogClose()
342  {
343  if (!m_OnItemReportSuccessDialogClose)
344  m_OnItemReportSuccessDialogClose = new ScriptInvokerVoid();
345 
346  return m_OnItemReportSuccessDialogClose;
347  }
348 }
SCR_ContentBrowser_GetAssetListParams
Definition: SCR_ContentBrowser_AddonsSubMenu.c:1558
SCR_ModReportDialogComponent
Definition: SCR_ModReportDialogComponent.c:1
SCR_WorkshopApiCallback_RequestPage
Definition: SCR_OnlineServiceWorkshop.c:164
m_Item
NewsFeedItem m_Item
Definition: SCR_NewsSubMenu.c:2
SCR_WorkshopItemActionAddAuthorBlock
Action for blocking author.
Definition: WorkshopItemActions.c:210
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_WorkshopItemActionDownload
Definition: SCR_WorkshopItemActionDownload.c:9
SCR_WorkshopItem
Definition: SCR_WorkshopItem.c:21
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_WorkshopItemActionRemoveAuthorBlock
Action for removing author mod content blocking.
Definition: WorkshopItemActions.c:220
SCR_LoadingOverlayDialog
Definition: SCR_LoadingOverlayDialog.c:5
ScriptInvokerVoid
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
Definition: SCR_ScriptInvokerHelper.c:9
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition: ChimeraMenuBase.c:3
ReportDialogUI
Definition: ReportDialogUI.c:1
SCR_ConfigurableDialogUi
Definition: SCR_ConfigurableDialogUI.c:13
SCR_AddonManager
Definition: SCR_AddonManager.c:72
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
SCR_WorkshopUiCommon
Definition: SCR_WorkshopUiCommon.c:5
SCR_ScriptedWidgetComponent
Definition: SCR_ScriptedWidgetComponent.c:7
SCR_AddonListDialog
Shows a list of addons and some text.
Definition: SCR_WorkshopUiCommon.c:820
SCR_DownloadManager
Definition: SCR_DownloadManager.c:20
SCR_DownloadManager_AddonDownloadLine
Definition: SCR_DownloadManager_AddonDownloadLine.c:5
SCR_InputButtonComponent
Definition: SCR_InputButtonComponent.c:1