5 [
Attribute(
"20", UIWidgets.EditBox,
desc:
"After how many character should be display preset name cut")]
6 protected int m_iPresetNameCap;
13 protected const int UPDATE_DELAY = 250;
16 override void HandlerAttached(Widget w)
18 super.HandlerAttached(w);
29 mgr.m_OnAddonsEnabledChanged.Insert(Callback_OnAddonsEnabledChanged);
30 mgr.GetPresetStorage().GetEventOnUsedPresetChanged().Insert(OnUsedPresetChanged);
32 OnUsedPresetChanged(mgr.GetPresetStorage().GetUsedPreset());
37 m_Widgets.m_UpdateButtonComponent.GetButton().m_OnClicked.Insert(OnUpdateButtonClicked);
39 HandleUpdatesButton();
40 GetGame().GetCallqueue().CallLater(HandleUpdatesButton, UPDATE_DELAY,
true);
46 override void HandlerDeattached(Widget w)
48 super.HandlerDeattached(w);
53 SCR_AddonManager.GetInstance().m_OnAddonsEnabledChanged.Remove(Callback_OnAddonsEnabledChanged);
58 GetGame().GetCallqueue().Remove(HandleUpdatesButton);
67 HandleUpdatesButton();
71 protected void Callback_OnAddonsEnabledChanged()
78 protected void OnUsedPresetChanged(
string name)
81 if (!name.IsEmpty() && name.Length() > m_iPresetNameCap)
82 name = name.Substring(0, m_iPresetNameCap) +
"...";
84 m_Widgets.m_PresetsButtonComponent.SetLabelText(name);
88 protected void UpdateAllWidgets()
97 m_Widgets.m_PresetsButtonComponent.SetCountText(nAddonsEnabled.ToString());
101 protected void OnUpdateButtonClicked()
111 Revision rev = item.GetLatestRevision();
112 item.SetItemTargetRevision(rev);
113 m_Loader.InsertItem(item);
118 m_Loader.GetOnAllPatchSizeLoaded().Insert(OnUpdatePatchSizeLoaded);
119 m_Loader.LoadPatchSizes();
126 m_Loader.GetOnAllPatchSizeLoaded().Remove(OnUpdatePatchSizeLoaded);
134 array<ref Tuple2<SCR_WorkshopItem, ref Revision>> addonsAndVersions = {};
137 addonsAndVersions.Insert(
new Tuple2<SCR_WorkshopItem, ref Revision>(item, item.GetLatestRevision()));
143 dialog.m_OnClose.Insert(OnAddonUpdateDialogClose);
149 HandleUpdatesButton();
153 protected void HandleUpdatesButton()
157 m_Widgets.m_UpdateButtonComponent.SetVisible(
false);
168 if (!item.IsDownloadRunning())
172 m_Widgets.m_UpdateButtonComponent.SetVisible(nOutdated > 0);
175 m_Widgets.m_UpdateButtonComponent.SetCountText(nOutdated.ToString());
179 protected void DisplayFailDialog()
185 array<ref Tuple2<SCR_WorkshopItem, ref Revision>> failed = {};
186 array<ref SCR_WorkshopItemActionDownload> failedActions =
SCR_DownloadManager.GetInstance().GetFailedDownloads();
191 Revision version = item.GetDependency().GetRevision();
193 failed.Insert(
new Tuple2<SCR_WorkshopItem, ref Revision>>(item, version));
201 m_FailDialog = dialog;
202 m_FailDialog.m_OnConfirm.Insert(Callback_OnFailDialogConfirm);
209 m_FailDialog.m_OnConfirm.Clear();
210 m_FailDialog.Close();