9 protected const string ICON_UPDATE =
"update";
10 protected const string TOOLTIP_UPDATE =
"#AR-Workshop_ButtonUpdate";
11 protected const string TOOLTIP_CANCEL_DOWNLOAD =
"#AR-Workshop_ButtonCancelDownload";
18 protected bool m_bCanUpdate =
true;
28 protected SCR_EAddonLineErrorFlags m_eAddonLineErrorFlags;
34 override void HandlerAttached(Widget w)
42 m_aMouseButtons.Insert(
m_Widgets.m_MoveLeftButtonComponent0);
43 m_aMouseButtons.Insert(
m_Widgets.m_MoveRightButtonComponent0);
44 m_aMouseButtons.Insert(
m_Widgets.m_DeleteButtonComponent0);
46 m_aMouseButtonsError.Insert(
m_Widgets.m_MoveRightButtonComponent0);
49 m_Widgets.m_DeleteButtonComponent0.m_OnClicked.Insert(OnDeleteButton);
50 m_Widgets.m_MoveRightButtonComponent0.m_OnClicked.Insert(OnEnableButton);
51 m_Widgets.m_MoveLeftButtonComponent0.m_OnClicked.Insert(OnDisableButton);
54 m_Widgets.m_UpdateButtonComponent0.m_OnClicked.Insert(OnUpdateButton);
55 m_Widgets.m_FixButtonComponent0.m_OnClicked.Insert(OnFixButton);
61 m_Widgets.m_UpdateButtonComponent0.m_OnMouseEnter.Insert(OnUpdateButtonMouseEnter);
62 m_Widgets.m_UpdateButtonComponent0.m_OnMouseLeave.Insert(OnUpdateButtonMouseLeave);
64 m_Widgets.m_IncompatibleButtonComponent0.m_OnMouseEnter.Insert(OnIncompatibleButtonMouseEnter);
65 m_Widgets.m_IncompatibleButtonComponent0.m_OnMouseLeave.Insert(OnIncompatibleButtonMouseLeave);
67 m_Widgets.m_MoveLeftButtonComponent0.m_OnMouseEnter.Insert(OnSideButtonMouseEnter);
68 m_Widgets.m_MoveLeftButtonComponent0.m_OnMouseLeave.Insert(OnSideButtonMouseLeave);
69 m_Widgets.m_MoveRightButtonComponent0.m_OnMouseEnter.Insert(OnSideButtonMouseEnter);
70 m_Widgets.m_MoveRightButtonComponent0.m_OnMouseLeave.Insert(OnSideButtonMouseLeave);
72 super.HandlerAttached(w);
76 override bool OnFocus(Widget w,
int x,
int y)
78 bool result = super.OnFocus(w, x, y);
86 override bool OnFocusLost(Widget w,
int x,
int y)
88 bool result = super.OnFocusLost(w, x, y);
96 override void OnTooltipShow(
SCR_ScriptedWidgetTooltip tooltipClass, Widget tooltipWidget, Widget hoverWidget, SCR_ScriptedWidgetTooltipPreset preset,
string tag)
98 super.OnTooltipShow(tooltipClass, tooltipWidget, hoverWidget, preset, tag);
100 if (tag ==
"MissingDependencies")
101 tooltipClass.SetMessageColor(Color.FromInt(
UIColors.WARNING.PackToInt()));
109 protected void UpdateAllWidgets()
111 if (!m_bCanUpdate || !
m_Item)
119 bool downloading =
m_Item.GetDownloadAction() ||
m_Item.GetDependencyCompositeAction();
120 bool problemCritical;
121 string problemDescription;
126 stateText =
string.Format(
"%1%%", Math.Round(100.0*progress));
127 m_Widgets.m_wHorizontalState.SetVisible(
true);
128 m_Widgets.m_wUpdateButton.SetVisible(
false);
132 m_Widgets.m_wHorizontalState.SetVisible(
false);
135 m_Widgets.m_wStateText.SetText(stateText);
138 ShowCompatibilityState();
151 m_Widgets.m_wFixButton.SetVisible(RequiresDownloadingDependencies());
155 protected void HandleEnableButtons(
bool addonEnabled,
bool forceHidden =
false)
158 m_Widgets.m_wLeftSeparator.SetVisible(!addonEnabled || forceHidden);
159 m_Widgets.m_wSizeMoveRight.SetVisible(!addonEnabled && !forceHidden);
160 m_Widgets.m_wMoveRightButton.SetVisible(!addonEnabled && m_bFocused && !forceHidden);
163 m_Widgets.m_wRightSeparator.SetVisible(addonEnabled || forceHidden);
164 m_Widgets.m_wSizeMoveLeft.SetVisible(addonEnabled || forceHidden);
165 m_Widgets.m_wMoveLeftButton.SetVisible(addonEnabled && m_bFocused && !forceHidden);
171 protected void ShowCompatibilityState()
179 m_Widgets.m_wIncompatibleButton.SetVisible(showIncompatibility);
181 if (!showIncompatibility)
190 if (!texture.IsEmpty())
191 m_Widgets.m_IncompatibleButtonComponent1.SetImage(texture);
201 m_Widgets.m_wUpdateButton.SetVisible(showUpdate);
211 m_UpdateButtonIconColor.m_cDefault = Color.FromInt(
UIColors.WARNING_DISABLED.PackToInt());
213 m_Widgets.m_UpdateButtonComponent0.InvokeAllEnabledEffects(
true);
215 if (updateImage.IsEmpty())
216 updateImage = ICON_UPDATE;
218 m_Widgets.m_UpdateButtonComponent1.SetImage(updateImage);
223 protected void UpdateIssueState()
227 bool issues = HasItemAnyIssue();
229 m_bIsInErrorState = issues || downloadIssue;
230 m_bDisabled = m_bIsInErrorState;
233 m_eAddonLineErrorFlags = 0;
236 m_eAddonLineErrorFlags |= SCR_EAddonLineErrorFlags.ITEM_ISSUES;
239 m_eAddonLineErrorFlags |= SCR_EAddonLineErrorFlags.REVISION_AVAILABILITY_ISSUE;
241 if (RequiresDownloadingDependencies())
242 m_eAddonLineErrorFlags |= SCR_EAddonLineErrorFlags.MISSING_DEPENDENCIES;
245 m_eAddonLineErrorFlags |= SCR_EAddonLineErrorFlags.DOWNLOAD_ISSUES;
252 protected void OnDeleteButton();
253 protected void OnActionButton();
254 protected void OnUpdateButton();
257 protected void OnFixButton()
260 m_OnFixButton.Invoke(
this);
264 void OnOpenDetailsButton()
273 void OnEnableButton()
279 if (availability ==
SCR_ERevisionAvailability.ERA_DOWNLOAD_NOT_FINISHED || m_eAddonLineErrorFlags & SCR_EAddonLineErrorFlags.MISSING_DEPENDENCIES)
283 if (m_OnEnableButton)
284 m_OnEnableButton.Invoke(
this);
286 HandleEnableButtons(
true);
291 void OnDisableButton()
296 if (m_OnDisableButton)
297 m_OnDisableButton.Invoke(
this);
299 HandleEnableButtons(
false);
306 protected void OnUpdateButtonMouseEnter()
312 protected void OnUpdateButtonMouseLeave()
318 protected void OnUpdateTooltipooltipShow(
SCR_ScriptedWidgetTooltip tooltipClass, Widget tooltipWidget, Widget hoverWidget, SCR_ScriptedWidgetTooltipPreset preset,
string tag)
321 bool downloading =
m_Item.GetDownloadAction() ||
m_Item.GetDependencyCompositeAction();
322 string message = TOOLTIP_UPDATE;
323 Color color = Color.FromInt(
UIColors.NEUTRAL_INFORMATION.PackToInt());
330 message = TOOLTIP_CANCEL_DOWNLOAD;
335 color = Color.FromInt(
UIColors.WARNING.PackToInt());
338 tooltipClass.SetMessage(message);
339 tooltipClass.SetMessageColor(color);
344 protected void OnIncompatibleButtonMouseEnter()
350 protected void OnIncompatibleButtonMouseLeave()
356 protected void OnIncompatibleTooltipooltipShow(
SCR_ScriptedWidgetTooltip tooltipClass, Widget tooltipWidget, Widget hoverWidget, SCR_ScriptedWidgetTooltipPreset preset,
string tag)
358 tooltipClass.SetMessageColor(Color.FromInt(
UIColors.WARNING.PackToInt()));
362 tooltipClass.SetMessage(
SCR_WorkshopUiCommon.GetRevisionAvailabilityErrorMessage(availability));
363 tooltipClass.SetMessageColor(Color.FromInt(
UIColors.WARNING.PackToInt()));
368 protected void OnSideButtonMouseEnter()
374 protected void OnSideButtonMouseLeave()
380 protected void OnSideTooltipooltipShow(
SCR_ScriptedWidgetTooltip tooltipClass, Widget tooltipWidget, Widget hoverWidget, SCR_ScriptedWidgetTooltipPreset preset,
string tag)
382 if (m_bIsInErrorState &&
m_Item && !
m_Item.GetEnabled())
383 tooltipClass.SetMessageColor(Color.FromInt(
UIColors.WARNING.PackToInt()));
408 void EnableUpdate(
bool enable)
410 m_bCanUpdate = enable;
414 bool HasItemAnyIssue()
428 bool RequiresDownloadingDependencies()
433 array<ref SCR_WorkshopItem> dependencies =
m_Item.GetLatestDependencies();
435 if (!dependencies.IsEmpty())
438 return !dependencies.IsEmpty();
442 SCR_EAddonLineErrorFlags GetErrorFlags()
444 return m_eAddonLineErrorFlags;
450 if (!m_OnEnableButton)
453 return m_OnEnableButton;
459 if (!m_OnDisableButton)
462 return m_OnDisableButton;
471 return m_OnFixButton;
476 enum SCR_EAddonLineErrorFlags
481 DOWNLOAD_ISSUES = 1 << 3