9 protected const int MAX_ADDON_TYPE_IMAGES = 12;
16 override void HandlerAttached(Widget w)
18 super.HandlerAttached(w);
30 protected void UpdateAllWidgets()
42 m_BackendImageComponent.SetWorkshopItemAndImage(
null,
null);
49 int rating = Math.Ceil(
m_Item.GetAverageRating() * 100.0);
50 m_InfoWidgets.m_wModRating.SetText(WidgetManager.Translate(
"#AR-ValueUnit_Percentage", rating));
58 float sizef =
m_Item.GetSizeBytes();
60 m_InfoWidgets.m_wModSize.SetText(sizeStr);
63 Revision revisionCurrent =
m_Item.GetCurrentLocalRevision();
64 Revision revisionLatest =
m_Item.GetLatestRevision();
66 bool needsUpdate = revisionCurrent && revisionLatest && !Revision.AreEqual(revisionCurrent, revisionLatest);
68 m_InfoWidgets.m_wVersionUpdateHorizontalLayout.SetVisible(needsUpdate);
71 if (needsUpdate || !
m_Item.GetOffline())
72 m_InfoWidgets.m_wCurrentVersion.SetColor(
UIColors.NEUTRAL_ACTIVE_STANDBY);
74 m_InfoWidgets.m_wCurrentVersion.SetColor(
UIColors.CONFIRM);
77 if (
m_Item.GetOffline() && revisionCurrent)
78 revision = revisionCurrent.GetVersion();
79 else if (revisionLatest)
80 revision = revisionLatest.GetVersion();
85 m_InfoWidgets.m_wUpdateVersion.SetText(
SCR_WorkshopUiCommon.FormatVersion(revisionLatest.GetVersion()));
90 m_InfoWidgets.m_wCurrentVersionIcon.SetColor(
UIColors.NEUTRAL_ACTIVE_STANDBY);
91 m_InfoWidgets.m_wCurrentVersionIcon.LoadImageFromSet(0,
UIConstants.ICONS_IMAGE_SET,
"download");
95 m_InfoWidgets.m_wCurrentVersionIcon.SetColor(
UIColors.SLIGHT_WARNING);
96 m_InfoWidgets.m_wCurrentVersionIcon.LoadImageFromSet(0,
UIConstants.ICONS_IMAGE_SET,
"update");
100 m_InfoWidgets.m_wCurrentVersionIcon.SetColor(
UIColors.CONFIRM);
101 m_InfoWidgets.m_wCurrentVersionIcon.LoadImageFromSet(0,
UIConstants.ICONS_IMAGE_SET,
"check");
105 int timeSinceDownload =
m_Item.GetTimeSinceFirstDownload();
106 m_InfoWidgets.m_wLastDownloadedHorizontalLayout.SetVisible(timeSinceDownload >= 0);
108 if (timeSinceDownload >= 0)
109 m_InfoWidgets.m_wLastDownloaded.SetText(
SCR_FormatHelper.GetTimeSinceEventImprecise(timeSinceDownload));
112 array<WorkshopTag> tagObjects = {};
113 m_Item.GetWorkshopItem().GetTags(tagObjects);
115 foreach (WorkshopTag tag : tagObjects)
118 if (!image.IsEmpty())
123 m_BackendImageComponent.SetWorkshopItemAndImage(
m_Item,
m_Item.GetThumbnail());
127 array<ref SCR_WorkshopItem> dependencies =
m_Item.GetLatestDependencies();
129 m_InfoWidgets.m_wDependenciesHorizontalLayout.SetVisible(!dependencies.IsEmpty());
130 m_InfoWidgets.m_wDependentHorizontalLayout.SetVisible(!dependentAddons.IsEmpty());
132 if (!dependencies.IsEmpty())
134 if (dependencies.Count() == 1)
135 m_InfoWidgets.m_wDependencies.SetText(
"#AR-Workshop_Details_ModDependencies_Short_One_LC");
137 m_InfoWidgets.m_wDependencies.SetTextFormat(
"#AR-Workshop_Details_ModDependencies_Short_LC", dependencies.Count());
140 if (!dependentAddons.IsEmpty())
142 if (dependentAddons.Count() == 1)
143 m_InfoWidgets.m_wDependent.SetText(
"#AR-Workshop_Details_DependentMods_Short_One_LC");
145 m_InfoWidgets.m_wDependent.SetTextFormat(
"#AR-Workshop_Details_DependentMods_Short_LC", dependentAddons.Count());
149 WorkshopItem item =
m_Item.GetWorkshopItem();
150 ERevisionAvailability revAvailability =
SCR_AddonManager.ItemAvailability(item);
152 float saturation =
UIConstants.ENABLED_WIDGET_SATURATION;
154 m_CommonWidgets.m_WarningOverlayComponent.SetWarningVisible(
m_Item.GetRestricted() || localModError);
156 if (
m_Item.GetRestricted())
157 m_CommonWidgets.m_WarningOverlayComponent.SetWarning(
"#AR-Workshop_Dialog_Error_ModIsBlocked",
"reportedByMe");
162 saturation =
UIConstants.DISABLED_WIDGET_SATURATION;
164 m_BackendImageComponent.SetImageSaturation(saturation);
168 override void HandlerDeattached(Widget w)
170 super.HandlerDeattached(w);
173 m_Item.m_OnChanged.Remove(Callback_OnChanged);
177 protected void Callback_OnChanged()
187 m_Item.m_OnChanged.Remove(Callback_OnChanged);
192 m_Item.m_OnChanged.Insert(Callback_OnChanged);