4 static const string EFFECT_ICON_COLOR =
"IconColor";
5 static const string EFFECT_BACKGROUND_COLOR =
"BackgroundColor";
6 static const string EFFECT_NAME_COLOR =
"NameColor";
7 static const string EFFECT_WRAPPER_COLOR =
"WrapperColor";
10 static void UpdateMouseButtons(array<SCR_ModularButtonComponent> mouseButtons, array<SCR_ModularButtonComponent> errorMouseButtons,
bool inErrorState,
bool focused)
12 Color color = Color.FromInt(
UIColors.IDLE_DISABLED.PackToInt());
17 color = Color.FromInt(
UIColors.NEUTRAL_ACTIVE_STANDBY.PackToInt());
19 foreach (SCR_ModularButtonComponent button : mouseButtons)
25 effect.m_cDefault = color;
26 effect.m_cToggledOff = color;
27 button.InvokeAllEnabledEffects(
false);
31 Color highlightedColor = Color.FromInt(
UIColors.HIGHLIGHTED.PackToInt());
34 color = Color.FromInt(
UIColors.WARNING_DISABLED.PackToInt());
35 highlightedColor = Color.FromInt(
UIColors.WARNING.PackToInt());
38 foreach (SCR_ModularButtonComponent button : errorMouseButtons)
43 effect.m_cDefault = color;
44 effect.m_cToggledOff = color;
45 effect.m_cHovered = highlightedColor;
46 effect.m_cActivatedHovered = highlightedColor;
47 effect.m_cFocusGained = highlightedColor;
53 effect.m_cHovered = highlightedColor;
54 effect.m_cActivatedHovered = highlightedColor;
55 effect.m_cFocusGained = highlightedColor;
58 button.InvokeAllEnabledEffects(
false);
64 class SCR_ScenarioEntryHelper
70 static const string MESSAGE_VERBOSE_CONNECTION_ISSUES =
"AR-Workshop_WarningNoConnection";
73 static const string BUTTON_PLAY =
"Play";
74 static const string BUTTON_CONTINUE =
"Continue";
75 static const string BUTTON_RESTART =
"Restart";
76 static const string BUTTON_HOST =
"Host";
77 static const string BUTTON_FIND_SERVERS =
"FindServers";
78 static const string BUTTON_FAVORITE =
"Favorite";
81 static const string ACTION_DOUBLE_CLICK =
"MenuSelectDouble";
82 static const string ACTION_RESTART =
"MenuRestart";
83 static const string ACTION_FIND_SERVERS =
"MenuJoin";
84 static const string ACTION_FAVORITE =
"MenuFavourite";
85 static const string ACTION_HOST =
"MenuHost";
89 static void UpdateMouseButtons(array<SCR_ModularButtonComponent> mouseButtons, array<SCR_ModularButtonComponent> errorMouseButtons, MissionWorkshopItem mission,
bool focused)
91 SCR_ListEntryHelper.UpdateMouseButtons(mouseButtons, errorMouseButtons, IsInErrorState(mission), focused);
97 if (!tooltip || (tooltip.GetTag() != BUTTON_HOST && tooltip.GetTag() != BUTTON_FIND_SERVERS))
100 if (!IsInErrorState(mission))
102 tooltip.ResetMessage();
103 tooltip.SetMessageColor(Color.FromInt(
UIColors.NEUTRAL_INFORMATION.PackToInt()));
107 tooltip.SetMessage(GetErrorMessage(mission));
108 tooltip.SetMessageColor(Color.FromInt(
UIColors.WARNING.PackToInt()));
113 static void UpdateInputButtons(MissionWorkshopItem mission, array<SCR_InputButtonComponent> buttons,
bool visible =
true)
115 visible = visible && IsReady(mission);
122 mp = IsMultiplayer(mission);
123 canBeLoaded = HasSave(mission);
128 Widget w = button.GetRootWidget();
136 button.SetVisible(visible && !canBeLoaded,
false);
140 case SCR_ScenarioEntryHelper.BUTTON_PLAY:
142 button.SetVisible(visible && !canBeLoaded,
false);
146 case SCR_ScenarioEntryHelper.BUTTON_CONTINUE:
148 button.SetVisible(visible && canBeLoaded,
false);
152 case SCR_ScenarioEntryHelper.BUTTON_RESTART:
154 button.SetVisible(visible && canBeLoaded,
false);
158 case SCR_ScenarioEntryHelper.BUTTON_FIND_SERVERS:
160 button.SetVisible(visible && mp,
false);
161 if (button.IsVisible())
162 UpdateInputButton(button, mission);
167 case SCR_ScenarioEntryHelper.BUTTON_HOST:
170 if (button.IsVisible())
171 UpdateInputButton(button, mission);
185 switch (GetErrorState(mission))
189 button.ResetTexture();
190 button.SetEnabled(
true);
202 SetInputButtonEnabled(button, mission);
209 static bool SetInputButtonEnabled(
SCR_InputButtonComponent button, MissionWorkshopItem mission,
bool animate =
true)
214 bool enabled = !IsInErrorState(mission);
215 button.SetEnabled(enabled, animate);
219 button.ResetTexture();
223 string texture = GetErrorTexture(mission);
224 button.SetTexture(
UIConstants.ICONS_IMAGE_SET, texture, Color.FromInt(
UIColors.WARNING_DISABLED.PackToInt()));
236 WorkshopItem item = mission.GetOwner();
247 return GetErrorState(item);
253 BackendApi backend =
GetGame().GetBackendApi();
254 WorkshopApi workshop;
256 workshop = backend.GetWorkshop();
265 workshop.NeedScan() ||
278 static bool IsInErrorState(MissionWorkshopItem mission)
280 return IsInErrorState(GetErrorState(mission));
290 static bool IsModInErrorState(MissionWorkshopItem mission)
296 static bool HasSave(MissionWorkshopItem mission)
302 return header &&
GetGame().GetSaveManager().HasLatestSave(header);
306 static bool IsMultiplayer(MissionWorkshopItem mission)
308 return mission && mission.GetPlayerCount() > 1;
313 static bool IsReady(MissionWorkshopItem mission)
318 if (mission.GetOwner())
319 return mission.GetOwner().IsReadyToRun();
325 static string GetErrorMessage(MissionWorkshopItem mission)
327 string output =
string.Empty;
329 switch (GetErrorState(mission))
343 if (!mission ||
GetGame().GetBackendApi().GetWorkshop().NeedScan())
356 static string GetErrorMessageVerbose(MissionWorkshopItem mission)
358 string output =
string.Empty;
360 switch (GetErrorState(mission))
374 if (!mission ||
GetGame().GetBackendApi().GetWorkshop().NeedScan())
387 static string GetErrorTexture(MissionWorkshopItem mission)
389 string output =
string.Empty;
391 switch (GetErrorState(mission))
405 if (!mission ||
GetGame().GetBackendApi().GetWorkshop().NeedScan())