Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ModDetailsAdditionalInfoDialog.c
Go to the documentation of this file.
2{
4
7
8 //------------------------------------------------------------------------------------------------
10 {
11 if (!scriptedItem)
12 return null;
13
14 WorkshopItem item = scriptedItem.GetWorkshopItem();
15 if (!item)
16 return null;
17
18 string licenseText = item.LicenseText();
19
20 array<WorkshopAuthor> contributors = {};
21 int contributorsCount = item.Contributors(contributors);
22
23 string tag = "AdditionalInfo";
24 if (licenseText.IsEmpty() && contributorsCount == 0)
25 tag = "AdditionalInfo_Small";
26
29
30 dialog.SetItem(scriptedItem);
31
32 return dialog;
33 }
34
35 // --- Overrides ---
36 //------------------------------------------------------------------------------------------------
38 {
39 super.OnMenuOpen(preset);
40
41 // Connection state
44
45 BindButtonCancel(m_DynamicFooter.FindButton(UIConstants.BUTTON_BACK));
46
47 m_Licenses = m_DynamicFooter.FindButton("Licenses");
48 if (m_Licenses)
49 m_Licenses.m_OnActivated.Insert(OnLicensesButton);
50
52 }
53
54 //------------------------------------------------------------------------------------------------
55 override void OnMenuClose()
56 {
57 super.OnMenuClose();
58
61 }
62
63 // --- Protected ---
64 //------------------------------------------------------------------------------------------------
65 protected void UpdateWidgets(bool visible = true)
66 {
67 if (!m_Item)
68 return;
69
70 WorkshopItem item = m_Item.GetWorkshopItem();
71 if (!item)
72 return;
73
74 // License
75 string license = item.License();
76 string customLicenseText = item.LicenseText();
77
78 m_Widgets.m_wVerticalLayoutLicense.SetVisible(visible);
79 m_Widgets.m_wLicenseName.SetText(license);
80
81 m_Widgets.m_wLicenseContentOverlay.SetVisible(!customLicenseText.IsEmpty());
82 m_Widgets.m_wLicenseContent.SetText(customLicenseText);
83
84 // Contributors
85 array<WorkshopAuthor> contributors = {};
86 int contributorsCount = item.Contributors(contributors);
87 string contributorsNames;
88
89 foreach (int i, WorkshopAuthor contributor : contributors)
90 {
91 if (i == 0)
92 contributorsNames = contributor.Name();
93 else
94 contributorsNames += "\n" + contributor.Name();
95 }
96
97 m_Widgets.m_wVerticalLayoutContributors.SetVisible(visible && contributorsCount > 0);
98 m_Widgets.m_wContributorsContent.SetText(contributorsNames);
99 }
100
101 //------------------------------------------------------------------------------------------------
103 {
104 if (!m_Item)
105 return;
106
107 m_Item.m_OnGetAsset.Remove(OnItemLoaded);
108 m_Item.m_OnTimeout.Remove(OnItemLoadTimeout);
109 }
110
111 //------------------------------------------------------------------------------------------------
112 protected void OnItemLoaded()
113 {
115
116 m_Widgets.m_LoadingOverlayComponent.SetShown(false);
118 }
119
120 //------------------------------------------------------------------------------------------------
121 protected void OnItemLoadTimeout()
122 {
124 }
125
126 //------------------------------------------------------------------------------------------------
127 protected void OnCommStatusCheckFinished(SCR_ECommStatus status, float responseTime, float lastSuccessTime, float lastFailTime)
128 {
129 GetGame().GetCallqueue().Call(UpdateLicenseButton);
130 }
131
132 //------------------------------------------------------------------------------------------------
133 protected void UpdateLicenseButton()
134 {
135 SCR_ConnectionUICommon.SetConnectionButtonEnabled(m_Licenses, SCR_ServicesStatusHelper.SERVICE_WORKSHOP, false, false);
136 }
137
138 //------------------------------------------------------------------------------------------------
139 protected void OnLicensesButton()
140 {
141 PlatformService ps = GetGame().GetPlatformService();
142 if (!ps)
143 return;
144
145 string url = GetGame().GetBackendApi().GetLinkItem(SCR_WorkshopUiCommon.LINK_NAME_LICENSES);
146 ps.OpenBrowser(url);
147 }
148
149 // --- Public ---
150 //------------------------------------------------------------------------------------------------
151 void SetItem(SCR_WorkshopItem scriptedItem)
152 {
153 if (!scriptedItem)
154 return;
155
157
158 m_Item = scriptedItem;
159
160 if (!m_Item.GetDetailsLoaded())
161 {
162 m_Item.m_OnGetAsset.Insert(OnItemLoaded);
163 m_Item.m_OnTimeout.Insert(OnItemLoadTimeout);
164
165 m_Item.LoadDetails();
166 UpdateWidgets(false);
167
168 return;
169 }
170
171 m_Widgets.m_LoadingOverlayComponent.SetShown(false);
173 }
174}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_ECommStatus
This class may become obsolete on BackendAPI update.
void UpdateWidgets()
SCR_DynamicFooterComponent m_DynamicFooter
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.
void BindButtonCancel(SCR_InputButtonComponent button)
Allows to register a custom button to call OnCancel (i.e. one not in the conf files but placed by han...
void OnCommStatusCheckFinished(SCR_ECommStatus status, float responseTime, float lastSuccessTime, float lastFailTime)
override void OnMenuOpen(SCR_ConfigurableDialogUiPreset preset)
ref SCR_ModDetailsAdditionalInfoDialogContentWidgets m_Widgets
static SCR_ModDetailsAdditionalInfoDialog CreateDialog(SCR_WorkshopItem scriptedItem)
static ScriptInvokerCommStatus GetOnCommStatusCheckFinished()
WorkshopItem GetWorkshopItem()
Use these only if absoulutely necessary to intarract with game API.
Workshop Item instance.