Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_WorkshopDialogs.c
Go to the documentation of this file.
1/*
2Common dialogs in Workshop
3// TODO: Cleanup and update looks
4*/
5
7{
8 static const ResourceName DIALOGS_CONFIG = "{26F075E5D30629E5}Configs/ContentBrowser/ContentBrowserDialogs.conf";
9 static const string WIDGET_LIST = "AddonList";
10
11 //------------------------------------------------------------------------------------------------
12 static SCR_ConfigurableDialogUi CreateDialog(string presetName)
13 {
14 return SCR_ConfigurableDialogUi.CreateFromPreset(DIALOGS_CONFIG, presetName);
15 }
16}
17
18class SCR_FailedModsDownloadDialog : SCR_ConfigurableDialogUi
19{
20 protected static const string FAILED_ADDON_LIST_DIALOG = "failed_dialogs_list";
21 protected const string STR_AFFECTED_MODS = "#AR-Workshop_FailedModsDownload";
22 protected const string FAILED_ADDON_FORMAT = "- %1 \n";
23
24 protected const string MESSAGE_ERROR_UNKNOWN = "#AR-AddonValidate_Error_Unknown_UC";
25 protected const string MESSAGE_ERROR_BUSY = "#AR-AddonValidate_Error_Busy_UC";
26 protected const string MESSAGE_ERROR_AUTH = "#AR-AddonValidate_Error_NoInternet_UC";
27 protected const string MESSAGE_ERROR_STORAGE = "#AR-AddonValidate_Error_AvailableSpace_UC";
28
29 protected static ref SCR_FailedModsDownloadDialog m_Instance;
30
31 protected ref array<SCR_WorkshopItemActionDownload> m_aDisplayedActions = {};
32
33 //------------------------------------------------------------------------------------------
34 static void ShowFailedModsDialog(SCR_WorkshopItemActionDownload action, int reason)
35 {
36 // Add failed addons to dialog
37 if (m_Instance)
38 {
39 m_Instance.UpdateFailedModsDialogContent(action, false);
40 return;
41 }
42
43 string message;
44
45 // Choose message dialog
46 switch (reason)
47 {
48 default:
49 case EBackendError.EBERR_UNKNOWN: message = MESSAGE_ERROR_UNKNOWN; break; // Unknown
50 case EBackendError.EBERR_BUSY: message = MESSAGE_ERROR_BUSY; break; // Mod is busy doing something else
51 case EBackendError.EBERR_AUTH_FAILED: message = MESSAGE_ERROR_AUTH; break; // Cant login ?
52 case EBackendError.EBERR_STORAGE_IS_FULL: message = MESSAGE_ERROR_STORAGE; break; // No Available space
53 }
54
55 if (!message.IsEmpty())
56 message += "\n";
57
58 // Create dialog
59 m_Instance = new SCR_FailedModsDownloadDialog();
60
61 CreateFromPreset(SCR_WorkshopDialogs.DIALOGS_CONFIG, FAILED_ADDON_LIST_DIALOG, m_Instance);
62 m_Instance.SetMessageFormat(message, reason);
63 m_Instance.UpdateFailedModsDialogContent(action, true);
64 }
65
66 //------------------------------------------------------------------------------------------------
67 void SetMessageFormat(string text, int reason)
68 {
69 if (m_wMessage)
70 {
71 m_wMessage.SetVisible(true);
72 m_wMessage.SetTextFormat(text, reason);
73 }
74 }
75
76 //-----------------------------------------------------------------------------------------------
77 override void Close()
78 {
79 super.Close();
80
81 m_Instance = null;
82 }
83
84 //-----------------------------------------------------------------------------------------------
86 {
87 if (!action)
88 return;
89
90 Widget contentWidget = GetContentLayoutRoot();
91 if (!contentWidget)
92 return;
93
95 if (!content)
96 return;
97
98 if (m_aDisplayedActions.Contains(action))
99 return;
100
101 m_aDisplayedActions.Insert(action);
102
103 if (initial)
104 content.SetMessage(STR_AFFECTED_MODS + "\n\n" + string.Format(FAILED_ADDON_FORMAT, action.GetAddonName()));
105 else
106 content.SetMessage(content.GetMessage() + string.Format(FAILED_ADDON_FORMAT, action.GetAddonName()));
107 }
108}
109
112{
113 protected float m_fSizeBytes;
114
116
117 protected ref array<SCR_WorkshopItemActionDownload> m_aDisplayedActions = {};
118
119 //------------------------------------------------------------------------------------------------
121 {
122 if (m_Instance)
123 {
124 m_Instance.AddToSize(sizeBytes, action);
125 return;
126 }
127
129
130 CreateFromPreset(SCR_CommonDialogs.DIALOGS_CONFIG, "error_not_enough_storage", m_Instance);
131 m_Instance.AddToSize(sizeBytes, action);
132 }
133
134 //-----------------------------------------------------------------------------------------------
135 override void Close()
136 {
137 super.Close();
138
139 m_Instance = null;
140 }
141
142 //------------------------------------------------------------------------------------------------
144 void AddToSize(float sizeBytes, SCR_WorkshopItemActionDownload action)
145 {
146 if (!action)
147 return;
148
149 if (m_aDisplayedActions.Contains(action))
150 return;
151
152 m_aDisplayedActions.Insert(action);
153
154 m_fSizeBytes += sizeBytes;
155
156 string sizeStr = SCR_ByteFormat.GetReadableSize(m_fSizeBytes);
157 string messageStr = WidgetManager.Translate(m_DialogPreset.m_sMessage, sizeStr);
158
159 SetMessage(messageStr);
160 }
161}
class RestAPIHelper< JsonApiStruct T > content
string message
SCR_PlayerListedAdminManagerComponentClass m_Instance
const string STR_AFFECTED_MODS
const string MESSAGE_ERROR_STORAGE
void UpdateFailedModsDialogContent(SCR_WorkshopItemActionDownload action, bool initial)
const string MESSAGE_ERROR_BUSY
const string MESSAGE_ERROR_AUTH
ref array< SCR_WorkshopItemActionDownload > m_aDisplayedActions
void SetMessageFormat(string text, int reason)
const string MESSAGE_ERROR_UNKNOWN
class SCR_WorkshopDialogs FAILED_ADDON_LIST_DIALOG
const string FAILED_ADDON_FORMAT
static SCR_ConfigurableDialogUi CreateFromPreset(ResourceName presetsResourceName, string tag, SCR_ConfigurableDialogUi customDialogObj=null)
Creates a dialog from preset.
Widget GetContentLayoutRoot()
Returns the root of the content layout.
ref SCR_ConfigurableDialogUiPreset m_DialogPreset
There is not enough storage on your hard drive. The space required is at least %1.
static ref SCR_NotEnoughStorageDialog m_Instance
void AddToSize(float sizeBytes, SCR_WorkshopItemActionDownload action)
Increase size displayed in dialog.
static void ShowNotEnoughStorageDialog(float sizeBytes, SCR_WorkshopItemActionDownload action)
ref array< SCR_WorkshopItemActionDownload > m_aDisplayedActions
EBackendError
Backend error.