10 protected const ResourceName LINE_LAYOUT =
"{6D73127FB096229D}UI/layouts/Menus/ContentBrowser/DownloadManager/ReportedAddonEntry.layout";
12 protected const ResourceName DIALOGS_CONFIG =
"{ADEA32EB841E8629}Configs/ContentBrowser/ContentBrowserReportDialogs.conf";
13 protected const string AUTHOR_REPORT_TAG =
"report_author";
14 protected const string AUTHOR_UNBLOCK_TAG =
"unblock_author_simple";
16 protected const string MSG_REPORTED =
"#AR-Workshop_State_Reported";
17 protected const string MSG_BANNED =
"#AR-Workshop_State_Banned";
18 protected const string MSG_AUTHOR =
"#AR-Workshop_FilterCategory_Author";
19 protected const string STR_FIXED_REPORT =
"#AR-Workshop_Dialog_Success";
21 protected const string WIDGET_DETAIL =
"TxtDetailType";
22 protected const string WIDGET_MESSAGE =
"TxtDetailMessage";
24 protected const string BUTTON_CANCEL_REPORT =
"cancelReport";
26 protected const int AUTHOR_MOD_LIMIT = 20;
28 protected ref ScriptInvoker<SCR_ReportedAddonsDialog> Event_OnAllReportsCanceled;
29 protected bool m_bBlocked;
32 protected TextWidget m_wTxtType;
33 protected TextWidget m_wTxtMessage;
35 protected Widget m_wList;
41 protected SCR_ModularButtonComponent m_LineFocused;
45 protected ref map<SCR_ModularButtonComponent, SCR_WorkshopItem> m_mButtonsItems;
46 protected ref map<SCR_ModularButtonComponent, WorkshopAuthor> m_mButtonsAuthors;
48 protected WorkshopAuthor m_LoadingAuthor;
58 m_mButtonsItems =
new map<SCR_ModularButtonComponent, SCR_WorkshopItem>();
59 m_mButtonsAuthors =
new map<SCR_ModularButtonComponent, WorkshopAuthor>();
64 m_wTxtType = TextWidget.Cast(
GetRootWidget().FindAnyWidget(WIDGET_DETAIL));
74 button.m_OnActivated.Clear();
75 button.m_OnActivated.Insert(OnCancelReport);
82 protected void SetupReports()
84 ref array<WorkshopAuthor> blockedAuthors = {};
89 if (item.GetBlocked())
91 CreateAddonEntry(item);
97 if (item.GetModAuthorReportedByMe())
100 WorkshopAuthor author = item.GetWorkshopItem().Author();
102 if (!blockedAuthors.Contains(author))
105 blockedAuthors.Insert(author);
106 CreateAuthorEntry(author);
111 if (item.GetReportedByMe())
112 CreateAddonEntry(item);
117 protected override void OnConfirm()
119 OnCancelReportActived();
120 m_OnConfirm.Invoke(
this);
129 protected SCR_ModularButtonComponent CreateEntry(
string name,
string message)
131 Widget entry =
GetGame().GetWorkspace().CreateWidgets(LINE_LAYOUT,
m_wList);
134 comp.SetMessages(name, message);
137 SCR_ModularButtonComponent button = SCR_ModularButtonComponent.Cast(entry.FindHandler(SCR_ModularButtonComponent));
142 button.m_OnFocus.Insert(OnAddonLineFocus);
156 string msg = MSG_REPORTED;
158 if (item.GetBlocked())
162 SCR_ModularButtonComponent button = CreateEntry(item.GetName(), msg);
163 m_mButtonsItems.Insert(button, item);
166 button.m_OnDoubleClicked.Insert(OnAddonEntrySelected);
170 protected void OnAddonEntrySelected(SCR_ModularButtonComponent button)
173 m_mButtonsItems.Find(button, item);
176 Print(
"Item wasn't found or set!");
179 item.m_OnMyReportLoaded.Insert(OnAddonReportLoadSuccess);
180 item.m_OnError.Insert(OnAddonReportLoadError);
181 item.m_OnTimeout.Insert(OnAddonReportLoadError);
192 item.m_OnMyReportLoaded.Remove(OnAddonReportLoadSuccess);
193 item.m_OnError.Remove(OnAddonReportLoadError);
194 item.m_OnTimeout.Remove(OnAddonReportLoadError);
196 m_LoadingOvelay.Close();
201 if (m_DialogCancelReport)
203 m_DialogCancelReport.m_OnConfirm.Insert(OnCancelReportConfirm);
204 m_DialogCancelReport.m_OnClose.Insert(OnCancelReportDialog);
205 m_DialogCancelReport.m_OnClose.Insert(OnReportDialogClose);
213 item.m_OnMyReportLoaded.Remove(OnAddonReportLoadSuccess);
214 item.m_OnError.Remove(OnAddonReportLoadError);
215 item.m_OnTimeout.Remove(OnAddonReportLoadError);
217 m_LoadingOvelay.Close();
226 protected void CreateAuthorEntry(notnull WorkshopAuthor author)
228 SCR_ModularButtonComponent button = CreateEntry(author.Name(), MSG_AUTHOR);
229 m_mButtonsAuthors.Insert(button, author);
232 button.m_OnDoubleClicked.Insert(OnAuthorEntrySelected);
236 protected void OnAuthorEntrySelected(SCR_ModularButtonComponent button)
238 m_mButtonsAuthors.Find(button, m_LoadingAuthor);
240 if (!m_LoadingAuthor)
241 Print(
"Author wasn't found or set!");
258 AuthorBlockCancelDialog();
262 protected void OnCancelReport()
264 if (m_mButtonsItems.Contains(m_LineFocused))
266 OnAddonEntrySelected(m_LineFocused);
270 OnAuthorEntrySelected(m_LineFocused);
275 protected void AuthorBlockCancelDialog()
278 dialog.SetMessage(WidgetManager.Translate(dialog.GetMessageStr(), m_LoadingAuthor.Name()));
280 dialog.m_OnConfirm.Insert(OnConfirmRemoveAuthorBlock);
281 dialog.m_OnCancel.Insert(OnCancelRemoveAuthorReport);
282 dialog.m_OnClose.Insert(OnReportDialogClose);
288 m_LoadingOvelay.Close();
289 callback.GetEventOnResponse().Remove(OnAuthorReportLoadResponse);
293 OpenAuthorModsDialog(m_LoadingAuthor);
298 protected void OpenAuthorModsDialog(WorkshopAuthor author)
301 array<WorkshopItem> items = {};
302 author.GetPageItems(items);
305 array<ref SCR_WorkshopItem> scrItems;
308 foreach (WorkshopItem item : items)
311 scrItems.Insert(scrItem);
317 dialog.GetMessageWidget().SetTextFormat(
318 "#AR-Workshop_CancelAuthorReport" +
"\n\n" +
"#AR-Workshop_AffectedMods", m_LoadingAuthor.Name());
321 dialog.m_OnConfirm.Insert(OnConfirmRemoveAuthorBlock);
322 dialog.m_OnCancel.Insert(OnCancelRemoveAuthorReport);
323 dialog.m_OnClose.Insert(OnReportDialogClose);
329 m_ReportCallback.GetEventOnResponse().Insert(OnRemoveAuthorBlockResponse);
331 m_LoadingAuthor.RemoveBlock(m_ReportCallback);
333 OnCancelRemoveAuthorReport(dialog);
340 m_LoadingOvelay.Close();
341 callback.GetEventOnResponse().Remove(OnRemoveAuthorBlockResponse);
345 SCR_ModularButtonComponent button = m_mButtonsAuthors.GetKeyByValue(m_LoadingAuthor);
346 DisplayReportCancelSuccess(button);
349 m_mButtonsAuthors.Remove(button);
351 AllButtonsCanceled();
363 dialog.m_OnClose.Remove(OnReportDialogClose);
364 GetGame().GetCallqueue().CallLater(FocusTopLine);
368 protected void DisplayReportCancelSuccess(notnull SCR_ModularButtonComponent button)
375 entry.GetMessage().SetColor(Color.FromInt(
UIColors.CONFIRM.PackToInt()));
376 entry.SetMessages(entry.GetLeftText(), STR_FIXED_REPORT);
380 button.m_OnFocus.Remove(OnAddonLineFocus);
381 button.m_OnDoubleClicked.Remove(OnAddonEntrySelected);
382 button.GetRootWidget().SetFlags(WidgetFlags.NOFOCUS);
386 protected void AllButtonsCanceled()
388 if (m_mButtonsItems.IsEmpty() && m_mButtonsAuthors.IsEmpty())
391 InvokeOnAllReportsCanceled();
398 dialog.m_OnConfirm.Remove(OnConfirmRemoveAuthorBlock);
399 dialog.m_OnCancel.Remove(OnCancelRemoveAuthorReport);
408 protected void OnAddonLineFocus(SCR_ModularButtonComponent button)
410 Widget w = button.GetRootWidget();
411 SCR_ModularButtonComponent line = SCR_ModularButtonComponent.Cast(w.FindHandler(SCR_ModularButtonComponent));
414 m_LineFocused = line;
419 protected void OnCancelReportActived()
424 if (m_mButtonsAuthors.Contains(m_LineFocused))
426 OnAuthorEntrySelected(m_LineFocused);
430 OnAddonEntrySelected(m_LineFocused);
436 m_DialogCancelReport.GetWorkshopItemAction().m_OnCompleted.Insert(OnCancelReportSuccess);
437 m_DialogCancelReport.GetWorkshopItemAction().m_OnFailed.Insert(OnCancelReportFail);
440 m_DialogCancelReport.m_OnConfirm.Remove(OnCancelReportConfirm);
446 SCR_ModularButtonComponent button = m_mButtonsItems.GetKeyByValue(action.GetWorkshopItem());
447 DisplayReportCancelSuccess(button);
450 m_mButtonsItems.Remove(button);
452 AllButtonsCanceled();
459 action.m_OnCompleted.Remove(OnCancelReportSuccess);
460 action.m_OnFailed.Remove(OnCancelReportFail);
467 m_DialogCancelReport.m_OnConfirm.Remove(OnCancelReportConfirm);
468 m_DialogCancelReport.m_OnCancel.Remove(OnCancelReportDialog);
472 protected void FocusTopLine()
475 foreach (SCR_ModularButtonComponent button,
SCR_WorkshopItem item : m_mButtonsItems)
477 if (button.GetRootWidget().IsFocusable())
479 GetGame().GetWorkspace().SetFocusedWidget(button.GetRootWidget());
485 foreach (SCR_ModularButtonComponent button, WorkshopAuthor author : m_mButtonsAuthors)
487 if (button.GetRootWidget().IsFocusable())
489 GetGame().GetWorkspace().SetFocusedWidget(button.GetRootWidget());
500 protected void InvokeOnAllReportsCanceled()
502 if (!Event_OnAllReportsCanceled)
503 Event_OnAllReportsCanceled =
new ScriptInvoker();
505 Event_OnAllReportsCanceled.Invoke(
this);
509 ScriptInvoker GetOnAllReportsCanceled()
511 if (!Event_OnAllReportsCanceled)
512 Event_OnAllReportsCanceled =
new ScriptInvoker();
514 return Event_OnAllReportsCanceled;