Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AddonDetailsPanelComponent.c
Go to the documentation of this file.
1/*
2Panel which shows state of addon.
3
4!!! This component relies on SCR_WorkshopUiCommon to be initialized to work correctly.
5*/
6
8{
9//---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
10// This sort of visual stuff should be configurable in attributes
11
12 protected const int MAX_ADDON_TYPE_IMAGES = 12; // Max amount of addon type images will be shown.
13
14//---- REFACTOR NOTE END ----
15
17 protected ref SCR_WorkshopItem m_Item;
18 protected SCR_WorkshopItemBackendImageComponent m_BackendImageComponent;
19
20 //------------------------------------------------------------------------------------------------
21 override void HandlerAttached(Widget w)
22 {
23 super.HandlerAttached(w);
24
25 m_InfoWidgets.Init(m_CommonWidgets.m_wAdditionalInfo.GetChildren());
26
27 m_BackendImageComponent = SCR_WorkshopItemBackendImageComponent.Cast(m_CommonWidgets.m_wBackendImage.FindHandler(SCR_WorkshopItemBackendImageComponent));
28
30 }
31
32 //------------------------------------------------------------------------------------------------
35 protected void UpdateAllWidgets()
36 {
37 // Don't mess up widgets in workbench
39 return;
40
41 if (!m_Item)
42 {
44 m_CommonWidgets.m_WarningOverlayComponent.SetWarningVisible(false);
45 m_CommonWidgets.m_wMainArea.SetVisible(false);
47 m_BackendImageComponent.SetWorkshopItemAndImage(null, null);
48 return;
49 }
50
51 m_CommonWidgets.m_wMainArea.SetVisible(true);
52
53 UpdateInfo();
59 }
60
61 //------------------------------------------------------------------------------------------------
62 protected void UpdateImage()
63 {
65 m_BackendImageComponent.SetWorkshopItemAndImage(m_Item, m_Item.GetThumbnail());
66 }
67
68 //------------------------------------------------------------------------------------------------
69 protected void UpdateMANWVisuals()
70 {
71 if (!m_Item.GetWorkshopItem())
72 {
73 m_CommonWidgets.m_wMANWLogo.SetVisible(false);
74 return;
75 }
76
77 m_CommonWidgets.m_MANWComponent.UpdateAwards(m_Item);
78
79 array<WorkshopTag> items = {};
80 m_Item.GetWorkshopItem().GetTags(items);
81 foreach(WorkshopTag item: items)
82 {
83 if (item.Name() == "MANW_2025")
84 {
85 m_CommonWidgets.m_wMANWLogo.SetVisible(true);
86 return;
87 }
88 }
89
90 m_CommonWidgets.m_wMANWLogo.SetVisible(false);
91 }
92
93 //------------------------------------------------------------------------------------------------
94 protected void UpdateInfo()
95 {
96 if (!m_Item)
97 return;
98
99 // Name, description, author name
100 m_CommonWidgets.m_wNameText.SetText(m_Item.GetName());
101 m_CommonWidgets.m_wAuthorNameText.SetText(m_Item.GetAuthorName());
102 m_CommonWidgets.m_wDescriptionText.SetText(m_Item.GetSummary());
103
105 return;
106
107 // Rating
108 m_InfoWidgets.m_wModRating.SetText(UIConstants.FormatUnitPercentage(SCR_WorkshopUiCommon.GetRatingPercentage(m_Item.GetAverageRating())));
109
110 // Size
111 float sizef = m_Item.GetSizeBytes();
112 string sizeStr = SCR_ByteFormat.GetReadableSize(sizef);
113 m_InfoWidgets.m_wModSize.SetText(sizeStr);
114
115 // Version
116 bool showUpdateText;
117 string currentVersionIcon;
118 Color currentVersionIconColor;
119 string currentVersionText;
120 Color currentVersionTextColor;
121 string updateVersionText;
122
124 m_Item,
125 showUpdateText,
126 currentVersionIcon,
127 currentVersionIconColor,
128 currentVersionText,
129 currentVersionTextColor,
130 updateVersionText);
131
132 m_InfoWidgets.m_wVersionUpdateHorizontalLayout.SetVisible(showUpdateText);
133 m_InfoWidgets.m_wCurrentVersion.SetColor(currentVersionTextColor);
134 m_InfoWidgets.m_wCurrentVersion.SetText(currentVersionText);
135 m_InfoWidgets.m_wUpdateVersion.SetText(updateVersionText);
136 m_InfoWidgets.m_wCurrentVersionIcon.SetColor(currentVersionIconColor);
137 m_InfoWidgets.m_wCurrentVersionIcon.LoadImageFromSet(0, UIConstants.ICONS_IMAGE_SET, currentVersionIcon);
138
139 // Time since last downloaded
140 int timeSinceDownload = m_Item.GetTimeSinceFirstDownload();
141 m_InfoWidgets.m_wLastDownloadedHorizontalLayout.SetVisible(timeSinceDownload >= 0);
142
143 if (timeSinceDownload >= 0)
144 m_InfoWidgets.m_wLastDownloaded.SetText(SCR_FormatHelper.GetTimeSinceEventImprecise(timeSinceDownload));
145 }
146
147 //------------------------------------------------------------------------------------------------
148 protected void UpdateTypes()
149 {
151
152 if (!m_Item)
153 return;
154
155 WorkshopItem item = m_Item.GetWorkshopItem();
156 array<WorkshopTag> tagObjects = {}; // Get tag objects from workshop item
157 if (item)
158 item.GetTags(tagObjects);
159
160 foreach (WorkshopTag tag : tagObjects)
161 {
162 string image = SCR_WorkshopUiCommon.GetTagImage(tag.Name());
163 if (!image.IsEmpty())
164 AddTypeDisplay(image, UIConstants.ICONS_IMAGE_SET, UIConstants.ICONS_GLOW_IMAGE_SET);
165 }
166 }
167
168 //------------------------------------------------------------------------------------------------
169 protected void UpdateDependencies()
170 {
171 if (!m_Item)
172 return;
173
174 array<ref SCR_WorkshopItem> dependentAddons = SCR_WorkshopUiCommon.GetDownloadedDependentAddons(m_Item);
175 array<ref SCR_WorkshopItem> dependencies = m_Item.GetLatestDependencies();
176
177 m_InfoWidgets.m_wDependenciesHorizontalLayout.SetVisible(!dependencies.IsEmpty());
178 m_InfoWidgets.m_wDependentHorizontalLayout.SetVisible(!dependentAddons.IsEmpty());
179
180 if (!dependencies.IsEmpty())
181 {
182 if (dependencies.Count() == 1)
183 m_InfoWidgets.m_wDependencies.SetText(SCR_WorkshopUiCommon.LABEL_DEPENDENCIES_NUMBER_ONE);
184 else
185 m_InfoWidgets.m_wDependencies.SetTextFormat(SCR_WorkshopUiCommon.LABEL_DEPENDENCIES_NUMBER, dependencies.Count());
186 }
187
188 if (!dependentAddons.IsEmpty())
189 {
190 if (dependentAddons.Count() == 1)
191 m_InfoWidgets.m_wDependent.SetText(SCR_WorkshopUiCommon.LABEL_DEPENDENT_NUMBER_ONE);
192 else
193 m_InfoWidgets.m_wDependent.SetTextFormat(SCR_WorkshopUiCommon.LABEL_DEPENDENT_NUMBER, dependentAddons.Count());
194 }
195 }
196
197 //------------------------------------------------------------------------------------------------
198 protected void UpdateErrorMessage()
199 {
200 if (!m_Item)
201 return;
202
203 WorkshopItem item = m_Item.GetWorkshopItem();
204 SCR_ERevisionAvailability revAvailability;
205
206 if (item)
207 revAvailability = SCR_AddonManager.ItemAvailability(item);
208
209 bool localModError = revAvailability != SCR_ERevisionAvailability.ERA_AVAILABLE && revAvailability != SCR_ERevisionAvailability.ERA_UNKNOWN_AVAILABILITY;
210 float saturation = UIConstants.ENABLED_WIDGET_SATURATION;
211 bool restricted = m_Item.GetRestricted();
212
213 m_CommonWidgets.m_WarningOverlayComponent.SetWarningVisible(restricted || localModError);
214 m_CommonWidgets.m_WarningOverlayComponent.SetBlurUnderneath(restricted);
215
216 if (restricted)
217 m_CommonWidgets.m_WarningOverlayComponent.SetWarning(SCR_WorkshopUiCommon.MESSAGE_RESTRICTED_GENERIC, SCR_WorkshopUiCommon.ICON_REPORTED);
218 else
220
221 if (localModError)
222 saturation = UIConstants.DISABLED_WIDGET_SATURATION;
223
225 m_BackendImageComponent.SetImageSaturation(saturation);
226 }
227
228 //------------------------------------------------------------------------------------------------
229 override void HandlerDeattached(Widget w)
230 {
231 super.HandlerDeattached(w);
232
233 if (!m_Item)
234 return;
235
236 m_Item.m_OnChanged.Remove(Callback_OnChanged);
237 m_Item.m_OnGetAsset.Remove(OnGetAsset);
238 m_Item.m_OnDependenciesLoaded.Remove(UpdateDependencies);
239 }
240
241 //------------------------------------------------------------------------------------------------
242 protected void Callback_OnChanged()
243 {
245 }
246
247 //------------------------------------------------------------------------------------------------
248 protected void OnGetAsset(SCR_WorkshopItem item)
249 {
250 UpdateInfo();
251 UpdateImage();
253 }
254
255 // --- Public ----
256 //------------------------------------------------------------------------------------------------
258 {
259 // Clear old item
260 if (m_Item)
261 {
262 m_Item.m_OnChanged.Remove(Callback_OnChanged);
263 m_Item.m_OnGetAsset.Remove(OnGetAsset);
264 m_Item.m_OnDependenciesLoaded.Remove(UpdateDependencies);
265 }
266
267 m_Item = item;
268
269 if (m_Item)
270 {
271 m_Item.m_OnChanged.Insert(Callback_OnChanged);
272 m_Item.m_OnGetAsset.Insert(OnGetAsset);
273 m_Item.m_OnDependenciesLoaded.Insert(UpdateDependencies);
274 }
275
277 }
278
279 //------------------------------------------------------------------------------------------------
281 {
282 return m_Item;
283 }
284}
Definition Color.c:13
SCR_WorkshopItemBackendImageComponent m_BackendImageComponent
static SCR_ERevisionAvailability ItemAvailability(notnull WorkshopItem item)
ref SCR_ContentDetailsPanelBaseWidgets m_CommonWidgets
Widget AddTypeDisplay(string image, ResourceName imageset, ResourceName glowImageset)
static string GetTimeSinceEventImprecise(int timeDiffSeconds)
static bool IsEditMode()
Definition Functions.c:1566
static int GetRatingPercentage(float rating)
static string GetRevisionAvailabilityErrorTexture(WorkshopItem item)
static string GetTagImage(string tag)
Returns image associated with given Workshop tag.
static array< ref SCR_WorkshopItem > GetDownloadedDependentAddons(notnull SCR_WorkshopItem item)
static string GetRevisionAvailabilityErrorMessageVerbose(WorkshopItem item)
static void GetVersionDisplayLook(SCR_WorkshopItem item, out bool showUpdateText, out string currentVersionIcon, out Color currentVersionIconColor, out string currentVersionText, out Color currentVersionTextColor, out string updateVersionText)
Workshop Item instance.