5 protected const ResourceName DOWNLOAD_LINE_LAYOUT =
"{BB5AEDDA3C4134FD}UI/layouts/Menus/ContentBrowser/DownloadManager/DownloadManager_AddonDownloadLineConfirmation.layout";
7 protected bool m_bDownloadMainItem;
8 protected ref array<ref SCR_WorkshopItem> m_aDependencies;
9 protected ref array<ref Revision> m_aDependencyVersions;
10 protected bool m_bSubscribeToAddons;
12 protected ref array<ref SCR_WorkshopItemAction> m_aCreatedActions = {};
16 protected ref ScriptInvoker m_OnDownloadConfirmed;
27 dlg.m_bSubscribeToAddons = subscribeToAddons;
28 dlg.m_Item = mainItem;
29 dlg.m_bDownloadMainItem = downloadMainItem;
30 dlg.m_aDependencies =
new array<ref SCR_WorkshopItem>;
31 foreach (
auto i : dependencies)
32 dlg.m_aDependencies.Insert(i);
36 dlg.SetStyleDownloadAddonsWithDependencies();
42 protected static void SetupDownloadDialogAddons(notnull out
SCR_DownloadConfirmationDialog dialog, notnull array<ref Tuple2<SCR_WorkshopItem, ref Revision>> addonsAndVersions,
bool subscribeToAddons)
44 dialog.m_bDownloadMainItem =
false;
45 dialog.m_bSubscribeToAddons = subscribeToAddons;
46 dialog.m_aDependencies =
new array<ref SCR_WorkshopItem>;
47 dialog.m_aDependencyVersions =
new array<ref Revision>;
49 foreach (Tuple2<SCR_WorkshopItem, ref Revision> i : addonsAndVersions)
51 dialog.m_aDependencies.Insert(i.param1);
52 dialog.m_aDependencyVersions.Insert(i.param2);
58 static SCR_DownloadConfirmationDialog CreateForAddons(notnull array<ref Tuple2<SCR_WorkshopItem, ref Revision>> addonsAndVersions,
bool subscribeToAddons)
62 SetupDownloadDialogAddons(dlg, addonsAndVersions, subscribeToAddons);
66 dlg.SetStyleDownloadAddons();
77 m_Widgets.m_MainAddonSection.SetVisible(m_bDownloadMainItem);
78 if (
m_Item !=
null && m_bDownloadMainItem)
84 OnAllPatchSizeLoaded(m_Loader,
true);
90 if (confirmAlternativeButton)
91 confirmAlternativeButton.m_OnActivated.Insert(OnConfirmAlternative);
96 if (confirmAlternativeButton)
97 confirmAlternativeButton.SetVisible(
false);
99 confirmButton.SetLabel(
"#AR-Workshop_Dialog_ConfirmDownload_ButtonDownload");
101 else if (!m_bDownloadMainItem)
104 if (confirmAlternativeButton)
105 confirmAlternativeButton.SetVisible(
false);
109 m_Widgets.m_OtherAddonsMessage.SetVisible(
false);
113 protected void LoadAddonPatchSizes()
115 array<ref SCR_WorkshopItem> versionDifferences =
SCR_AddonManager.SelectItemsAnd(
120 if (versionDifferences.IsEmpty())
122 OnAllPatchSizeLoaded(m_Loader,
true);
127 m_Loader.ClearItems();
131 Revision rev = item.GetDependency().GetRevision();
132 item.SetItemTargetRevision(rev);
133 m_Loader.InsertItem(item);
136 m_Loader.GetOnAllPatchSizeLoaded().Insert(OnAllPatchSizeLoaded);
137 m_Loader.LoadPatchSizes();
140 m_Widgets.m_LoadingOverlayComponent.SetShown(
true);
141 m_Widgets.m_AddonContentVertical.SetVisible(
false);
149 loader.GetOnAllPatchSizeLoaded().Remove(OnAllPatchSizeLoaded);
152 m_Widgets.m_LoadingOverlayComponent.SetShown(
false);
153 m_Widgets.m_AddonContentVertical.SetVisible(
true);
161 m_Widgets.m_TotalAddonSizeText.SetText(totalSizeStr);
167 protected void CreateAddonWidget(notnull
SCR_WorkshopItem dep, Widget listRoot)
173 Dependency dependency = dep.GetDependency();
175 Revision revision =
null;
177 revision = dependency.GetRevision();
180 comp.InitForWorkshopItem(dep, revision);
184 protected void CreateAddonList()
195 CreateAddonWidget(missing,
m_Widgets.m_OtherAddonsList);
199 array<ref SCR_WorkshopItem> versionDifferences =
SCR_AddonManager.SelectItemsAnd(
203 int vDifCount = versionDifferences.Count();
204 bool hasDifference = vDifCount > 0;
207 m_Widgets.m_UpdateAddonsList.SetVisible(hasDifference);
208 m_Widgets.m_UpdateAddonsMessage.SetVisible(hasDifference);
209 m_Widgets.m_UpdateSpacer.SetVisible(hasDifference && missingAddons.IsEmpty());
216 CreateAddonWidget(addon,
m_Widgets.m_UpdateAddonsList);
220 m_Widgets.m_UpdateAddonsMessage.SetTextFormat(
"#AR-Workshop_Dialog_ConfirmDownload_VersionDifferences", vDifCount);
229 void SetStyleDownloadAddonsWithDependencies()
233 m_Widgets.m_OtherAddonsMessage.SetVisible(
true);
234 m_Widgets.m_OtherAddonsMessage.SetTextFormat(
235 "#AR-Workshop_Dialog_ConfirmDownload_DependenciesWillBeDownloaded",
242 void SetStyleDownloadAddons()
244 m_Widgets.m_OtherAddonsMessage.SetVisible(
false);
248 override void OnConfirm()
261 if (dep.IsDownloadRunning())
264 Revision targetVersion;
265 if (m_aDependencyVersions !=
null)
266 targetVersion = m_aDependencyVersions[i];
271 action = dep.Download(targetVersion);
273 action = dep.DownloadLatestVersion();
278 m_aCreatedActions.Insert(action);
284 if (m_bSubscribeToAddons)
287 m_Item.SetSubscribed(
true);
291 dependency.SetSubscribed(
true);
300 void OnConfirmAlternative()
309 if (m_bSubscribeToAddons)
312 m_Item.SetSubscribed(
true);
320 array<ref SCR_WorkshopItemAction> GetActions()
322 array<ref SCR_WorkshopItemAction> a = {};