Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ValidateRepair_Dialog.c
Go to the documentation of this file.
2{
3 protected const ResourceName DOWNLOAD_LINE_LAYOUT = "{8E94F18104D88E73}UI/layouts/Menus/ContentBrowser/ValidateRepair/ValidateRepairLine.layout";
4 protected const string WIDGET_VERTICAL_NAME = "DownloadManagerVertical";
5 protected const string WIDGET_SCROLL_NAME = "DownloadManagerScroll";
6
7 protected const string WIDGET_STATUS_TEXT_NAME = "m_GlobalStatusText";
8
9 protected const string TEXT_VALIDATING_FORMAT = "#AR-AddonValidate_ValidationProgress";
10 protected const string TEXT_VALIDATED_FORMAT = "#AR-AddonValidate_ValidationFinished";
11 protected const string TEXT_ERROR_FORMAT = "#AR-AddonValidate_ValidationError";
12
13 protected const string BUTTON_VALIDATE = "validation";
14 protected const string BUTTON_REDOWNLOAD = "redownload";
15
16 protected const ResourceName ADDON_VISUALS_CONFIG = "{DFFE187A7738CE15}scripts/Game/UI/Menu/ValidateRepair/AddonLineValidateStates.conf";
17
19
20 protected ref array<SCR_AddonLineValidateRepairComponent> m_aEntriesValidating = {};
21 protected ref array<SCR_AddonLineValidateRepairComponent> m_aEntriesRepairing = {};
22 protected ref array<SCR_AddonLineValidateRepairComponent> m_aEntriesDownloading = {};
23
25
29
33
34 protected int m_iValidationCount;
36 protected bool m_bValidationStarting;
37
38 //------------------------------------------------------------------------------------------------
40 {
41 return !m_aEntriesValidating.IsEmpty();
42 }
43
44 //------------------------------------------------------------------------------------------------
46 {
47 return !m_aEntriesRepairing.IsEmpty();
48 }
49
50 //------------------------------------------------------------------------------------------------
52 {
53 return !m_aEntriesDownloading.IsEmpty();
54 }
55
56 //------------------------------------------------------------------------------------------------
58 {
59 super.OnMenuOpen(preset);
60
62 BaseContainer container = rsc.GetResource().ToBaseContainer();
63 SCR_AddonLineValidateStates statesConfig = SCR_AddonLineValidateStates.Cast(BaseContainerTools.CreateInstanceFromContainer(container));
64
65 if (statesConfig)
66 {
68 foreach (SCR_AddonLineValidateState state : statesConfig.m_aStates)
69 {
70 if (!m_mCachedAddonStates.Contains(state.GetState()))
71 m_mCachedAddonStates.Insert(state.GetState(), state);
72 }
73
75 foreach (SCR_AddonLineValidateError errorType : statesConfig.m_aErrors)
76 {
77 if (!m_mCachedAddonErrors.Contains(errorType.GetErrorCode()))
78 m_mCachedAddonErrors.Insert(errorType.GetErrorCode(), errorType.GetText());
79 }
80 }
81
83 m_wGlobalStatusText.SetText(string.Empty);
84 }
85
86
87 //------------------------------------------------------------------------------------------------
88 override void OnMenuClose()
89 {
90 Widget vLayout = m_wRoot.FindAnyWidget(WIDGET_VERTICAL_NAME);
92
93 if (!scroll || !vLayout)
94 return;
95
96 Widget childWidget = vLayout.GetChildren();
97 while (childWidget)
98 {
99 vLayout.RemoveChild(childWidget);
100 childWidget = vLayout.GetChildren();
101 }
102
103 super.OnMenuClose();
104 }
105
106 //------------------------------------------------------------------------------------------------
107 override protected void Init(Widget root, SCR_ConfigurableDialogUiPreset preset, MenuBase proxyMenu)
108 {
109 super.Init(root, preset, proxyMenu);
110
113
116 m_ButtonRedownload.SetVisible(false);
117 }
118
119 //------------------------------------------------------------------------------------------------
120 protected void BindButtonValidate(notnull SCR_InputButtonComponent button)
121 {
122 button.m_OnActivated.Insert(OnValidateAllButton);
123
126 else
127 m_aButtonComponents.Insert(BUTTON_VALIDATE, button);
128 }
129
130 //------------------------------------------------------------------------------------------------
131 protected void BindButtonRedownload(notnull SCR_InputButtonComponent button)
132 {
133 button.m_OnActivated.Insert(OnReDownloadSelectedAddon);
134
137 else
139 }
140
141 //------------------------------------------------------------------------------------------------
142 void LoadAddons(bool enabledAddons)
143 {
144 InitList(enabledAddons);
145 }
146
147 //------------------------------------------------------------------------------------------------
148 void LoadAddon(notnull SCR_WorkshopItem item)
149 {
150 CreateList({item});
151
153 }
154
155 //------------------------------------------------------------------------------------------------
156 // Init list of downloads
157 protected void InitList(bool loadEnabledMods = true)
158 {
159 array<WorkshopItem> rawWorkshopItems = {};
160 GetGame().GetBackendApi().GetWorkshop().GetOfflineItems(rawWorkshopItems);
161
162 // Register items in Addon Manager
163 array<SCR_WorkshopItem> itemsRegistered = {};
164
165 Revision itemRev;
166 SCR_WorkshopItem itemRegistered;
167 foreach (WorkshopItem i : rawWorkshopItems)
168 {
169 itemRegistered = SCR_AddonManager.GetInstance().Register(i);
170
171 if (itemRegistered.IsWorldSave())
172 continue;
173
174 if (itemRegistered.GetEnabled() != loadEnabledMods)
175 continue;
176
177 itemRev = itemRegistered.GetCurrentLocalRevision();
178 if (!itemRev.IsDownloaded())
179 continue;
180
181 // Addons
182 itemsRegistered.Insert(itemRegistered);
183 }
184
185 // Sort by name...
186 SCR_Sorting<SCR_WorkshopItem, SCR_CompareWorkshopItemName>.HeapSort(itemsRegistered);
187
188 // Convert back to array<ref ...>
189 array<ref SCR_WorkshopItem> itemsSorted = {};
190 foreach (SCR_WorkshopItem i : itemsRegistered)
191 {
192 itemsSorted.Insert(i);
193 }
194
195 CreateList(itemsSorted);
196
198 }
199
200 //------------------------------------------------------------------------------------------------
201 protected void CreateList(array<ref SCR_WorkshopItem> items)
202 {
203 Widget vLayout = m_wRoot.FindAnyWidget(WIDGET_VERTICAL_NAME);
205
206 if (!scroll || !vLayout)
207 return;
208
209 // Store scroll pos
210 float scrollx, scrolly;
211 scroll.GetSliderPos(scrollx, scrolly);
212
213 foreach (SCR_WorkshopItem item : items)
214 {
215 Widget entry = GetGame().GetWorkspace().CreateWidgets(DOWNLOAD_LINE_LAYOUT, vLayout);
216
219
220 // Store widgets and component
221 m_mEntriesComponents.Insert(comp, item);
222 comp.GetOnFocus().Insert(OnFocusAddon);
223 comp.GetOnFocusLost().Insert(OnFocusLostAddon);
224
226 comp.GetOnValidateEnd().Insert(OnAddonValidated);
227
229 comp.GetOnRepairEnd().Insert(OnAddonRepaired);
230 }
231
232 // Restore scroll pos
233 scroll.SetSliderPos(scrollx, scrolly);
234 }
235
236 //------------------------------------------------------------------------------------------------
237 protected void UpdateStatusText()
238 {
240 return;
241
242 int progressCount = m_aEntriesValidating.Count() + m_aEntriesRepairing.Count() + m_aEntriesDownloading.Count();
243 if (progressCount > 0 && progressCount <= m_iValidationCount)
245 else
246 {
249 else
251
252 m_ButtonValidate.SetEnabled(true);
253 m_ButtonRedownload.SetEnabled(true);
254
256 GetGame().GetCallqueue().Call(DelayedDownloadButtonVisibility);
257 }
258 }
259
260 //------------------------------------------------------------------------------------------------
262 {
263 if (m_FocusedAddon && m_FocusedAddon.HasFailed() && !m_FocusedAddon.HasFailedDownloading())
264 m_ButtonRedownload.SetVisible(true);
265 else
266 m_ButtonRedownload.SetVisible(false);
267 }
268
269 //------------------------------------------------------------------------------------------------
270 protected void OnFocusAddon(notnull SCR_AddonLineValidateRepairComponent addonComponent)
271 {
272 m_FocusedAddon = addonComponent;
273
274 if (m_FocusedAddon.HasFailed() && !m_FocusedAddon.HasFailedDownloading())
275 m_ButtonRedownload.SetVisible(true);
276 }
277
278 //------------------------------------------------------------------------------------------------
279 protected void OnFocusLostAddon(notnull SCR_AddonLineValidateRepairComponent addonComponent)
280 {
281 if (m_FocusedAddon == addonComponent)
282 m_FocusedAddon = null;
283
284 m_ButtonRedownload.SetVisible(false);
285 }
286
287 //------------------------------------------------------------------------------------------------
289 {
290 m_aEntriesValidating.Insert(addonComponent);
292 }
293
294 //------------------------------------------------------------------------------------------------
295 protected void OnAddonStartRepairing(notnull SCR_AddonLineValidateRepairComponent addonComponent)
296 {
297 m_aEntriesRepairing.Insert(addonComponent);
299 }
300
301 //------------------------------------------------------------------------------------------------
303 {
304 m_aEntriesDownloading.Insert(addonComponent);
306 }
307
308 //------------------------------------------------------------------------------------------------
309 protected void OnAddonDownloaded(notnull SCR_AddonLineValidateRepairComponent addonComponent)
310 {
311 if (addonComponent.HasFailed())
313
314 m_aEntriesDownloading.RemoveItem(addonComponent);
316 }
317
318 //------------------------------------------------------------------------------------------------
319 protected void OnAddonValidated(notnull SCR_AddonLineValidateRepairComponent addonComponent)
320 {
321 if (addonComponent.HasFailed())
323
324 m_aEntriesValidating.RemoveItem(addonComponent);
326 }
327
328 //------------------------------------------------------------------------------------------------
329 protected void OnAddonRepaired(notnull SCR_AddonLineValidateRepairComponent addonComponent)
330 {
331 if (addonComponent.HasFailed())
333
334 m_aEntriesRepairing.RemoveItem(addonComponent);
336 }
337
338 //------------------------------------------------------------------------------------------------
339 protected void OnValidateAllButton()
340 {
342 m_wGlobalStatusText.SetText("");
343
347 {
348 if (component.StartValidating())
350 }
351
352 if (m_iValidationCount > 0)
354
355 m_bValidationStarting = false;
356 }
357
358 //------------------------------------------------------------------------------------------------
360 {
361 if (m_FocusedAddon && m_FocusedAddon.StartCleanDownload())
362 {
365 }
366 }
367
368 //------------------------------------------------------------------------------------------------
369 protected void DisableButtons()
370 {
371 m_ButtonValidate.SetEnabled(false);
372 //m_ButtonRedownload.SetEnabled(false);
373 }
374
375 //------------------------------------------------------------------------------------------------
376 protected void OnCloseButton()
377 {
378 Close();
379 }
380}
ArmaReforgerScripted GetGame()
Definition game.c:1398
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
void Init(notnull SCR_WorkshopItem item, notnull map< SCR_EAddonValidateState, ref SCR_AddonLineValidateState > states, notnull map< int, string > errorMessages)
Setup line.
ScriptInvokerScriptedWidgetComponent GetOnRepairEnd()
ScriptInvokerScriptedWidgetComponent GetOnRepairStart()
ScriptInvokerScriptedWidgetComponent GetOnValidateEnd()
ScriptInvokerScriptedWidgetComponent GetOnValidateStart()
SCR_WorkshopItem Register(WorkshopItem item)
Returns a SCR_WorkshopItem. If it's not registered, creates a new one and registers it.
static SCR_AddonManager GetInstance()
ref map< string, SCR_InputButtonComponent > m_aButtonComponents
SCR_InputButtonComponent FindButton(string tag)
Returns a button with given tag.
SCR_InputButtonComponent m_ButtonValidate
void OnAddonDownloaded(notnull SCR_AddonLineValidateRepairComponent addonComponent)
void OnAddonStartDownloading(notnull SCR_AddonLineValidateRepairComponent addonComponent)
void OnFocusAddon(notnull SCR_AddonLineValidateRepairComponent addonComponent)
void BindButtonValidate(notnull SCR_InputButtonComponent button)
void OnFocusLostAddon(notnull SCR_AddonLineValidateRepairComponent addonComponent)
void CreateList(array< ref SCR_WorkshopItem > items)
void InitList(bool loadEnabledMods=true)
SCR_InputButtonComponent m_ButtonRedownload
void Init(Widget root, SCR_ConfigurableDialogUiPreset preset, MenuBase proxyMenu)
ref map< SCR_EAddonValidateState, ref SCR_AddonLineValidateState > m_mCachedAddonStates
Holds all the different cached id with the enum as key.
ref map< int, string > m_mCachedAddonErrors
void OnAddonStartRepairing(notnull SCR_AddonLineValidateRepairComponent addonComponent)
override void OnMenuOpen(SCR_ConfigurableDialogUiPreset preset)
void OnAddonRepaired(notnull SCR_AddonLineValidateRepairComponent addonComponent)
ref array< SCR_AddonLineValidateRepairComponent > m_aEntriesDownloading
void LoadAddons(bool enabledAddons)
ref map< SCR_AddonLineValidateRepairComponent, SCR_WorkshopItem > m_mEntriesComponents
void LoadAddon(notnull SCR_WorkshopItem item)
SCR_AddonLineValidateRepairComponent m_FocusedAddon
ref array< SCR_AddonLineValidateRepairComponent > m_aEntriesValidating
void OnAddonValidated(notnull SCR_AddonLineValidateRepairComponent addonComponent)
void BindButtonRedownload(notnull SCR_InputButtonComponent button)
void OnAddonStartValidating(notnull SCR_AddonLineValidateRepairComponent addonComponent)
ref array< SCR_AddonLineValidateRepairComponent > m_aEntriesRepairing
Revision GetCurrentLocalRevision()
Returns the revision which we currently have on the local storage.
Workshop Item instance.
Definition Types.c:486