8 protected MissionWorkshopItem m_Mission;
10 protected const string MOD_ICON =
"modIcon";
12 protected Widget m_wLineBackground;
15 override void HandlerAttached(Widget w)
24 m_FavComponent =
m_Widgets.m_FavouriteButtonComponent;
26 m_aMouseButtons.Insert(m_FavComponent);
27 m_aMouseButtons.Insert(
m_Widgets.m_PlayComponent);
28 m_aMouseButtons.Insert(
m_Widgets.m_ContinueComponent);
29 m_aMouseButtons.Insert(
m_Widgets.m_RestartComponent);
30 m_aMouseButtons.Insert(
m_Widgets.m_HostComponent);
31 m_aMouseButtons.Insert(
m_Widgets.m_FindServersComponent);
33 m_aMouseButtonsError.Insert(
m_Widgets.m_HostComponent);
34 m_aMouseButtonsError.Insert(
m_Widgets.m_FindServersComponent);
36 m_Widgets.m_PlayComponent.m_OnClicked.Insert(OnPlay);
37 m_Widgets.m_ContinueComponent.m_OnClicked.Insert(OnContinue);
38 m_Widgets.m_RestartComponent.m_OnClicked.Insert(OnRestart);
39 m_Widgets.m_HostComponent.m_OnClicked.Insert(OnHost);
40 m_Widgets.m_FindServersComponent.m_OnClicked.Insert(OnFindServers);
45 m_wLineBackground = w.FindAnyWidget(
"LineBackground");
47 super.HandlerAttached(w);
51 override void HandlerDeattached(Widget w)
53 super.HandlerDeattached(w);
58 override void UpdateModularButtons()
64 bool mp = SCR_ScenarioEntryHelper.IsMultiplayer(m_Mission);
65 bool canContinue = SCR_ScenarioEntryHelper.HasSave(m_Mission);
66 bool show = m_bMouseButtonsEnabled && m_bFocused && SCR_ScenarioEntryHelper.IsReady(m_Mission);
68 m_Widgets.m_Play.SetVisible(show && !canContinue);
69 m_Widgets.m_Continue.SetVisible(show && canContinue);
70 m_Widgets.m_Restart.SetVisible(canContinue);
74 m_Widgets.m_FindServers.SetVisible(show && mp);
76 m_bIsInErrorState = SCR_ScenarioEntryHelper.IsInErrorState(m_Mission);
77 SCR_ScenarioEntryHelper.UpdateErrorMouseButtonsTooltip(m_CurrentTooltip, m_Mission);
79 bool inError = SCR_ScenarioEntryHelper.IsModInErrorState(m_Mission);
81 if (
m_Widgets.m_SourceImageCommunity.IsVisible())
83 string icon = MOD_ICON;
84 Color color = Color.FromInt(
UIColors.NEUTRAL_INFORMATION.PackToInt());
88 icon = SCR_ScenarioEntryHelper.GetErrorTexture(m_Mission);
90 color = Color.FromInt(
UIColors.WARNING.PackToInt());
92 color = Color.FromInt(
UIColors.WARNING_DISABLED.PackToInt());
96 m_Widgets.m_SourceImageCommunity.SetIsColorInherited(!inError);
97 m_Widgets.m_SourceImageCommunity.SetColor(color);
100 super.UpdateModularButtons();
104 override bool SetFavorite(
bool favorite)
106 if (!m_Mission || !super.SetFavorite(favorite))
109 m_Mission.SetFavorite(favorite);
114 override void OnTooltipShow(
SCR_ScriptedWidgetTooltip tooltipClass, Widget tooltipWidget, Widget hoverWidget, SCR_ScriptedWidgetTooltipPreset preset,
string tag)
116 SCR_ScenarioEntryHelper.UpdateErrorMouseButtonsTooltip(tooltipClass, m_Mission);
118 super.OnTooltipShow(tooltipClass, tooltipWidget, hoverWidget, preset, tag);
122 protected void UpdateAllWidgets()
129 SetFavorite(m_Mission.IsFavorite());
132 m_Widgets.m_NameText.SetText(m_Mission.Name());
140 int playerCount = m_Mission.GetPlayerCount();
141 bool mp = SCR_ScenarioEntryHelper.IsMultiplayer(m_Mission);
143 m_Widgets.m_SinglePlayerImage.SetVisible(!m_bMouseButtonsEnabled && !mp);
144 m_Widgets.m_MultiPlayerImage.SetVisible(!m_bMouseButtonsEnabled && mp);
145 m_Widgets.m_PlayerCountText.SetText(playerCount.ToString());
148 int timeSinceLastPlayedSeconds = m_Mission.GetTimeSinceLastPlay();
149 string timeSinceLastPlayText;
151 if (timeSinceLastPlayedSeconds > 0)
152 timeSinceLastPlayText =
SCR_FormatHelper.GetTimeSinceEventImprecise(timeSinceLastPlayedSeconds);
154 timeSinceLastPlayText =
"-";
156 m_Widgets.m_LastPlayedText.SetText(timeSinceLastPlayText);
159 WorkshopItem sourceAddon = m_Mission.GetOwner();
160 m_Widgets.m_SourceImageOfficial.SetVisible(sourceAddon ==
null);
161 m_Widgets.m_SourceImageCommunity.SetVisible(sourceAddon !=
null);
162 m_Widgets.m_SourceNameTextOfficial.SetVisible(sourceAddon ==
null);
163 m_Widgets.m_SourceNameTextCommunity.SetVisible(sourceAddon !=
null);
164 string sourceAddonText =
string.Empty;
166 m_Widgets.m_SourceNameTextCommunity.SetText(sourceAddon.Name());
168 m_Widgets.m_SourceNameTextOfficial.SetText(
"#AR-Editor_Attribute_OverlayLogo_Reforger");
171 UpdateModularButtons();
175 protected void OnPlay()
177 if (m_OnMouseInteractionButtonClicked)
178 m_OnMouseInteractionButtonClicked.Invoke(SCR_ScenarioEntryHelper.BUTTON_PLAY);
182 protected void OnContinue()
184 if (m_OnMouseInteractionButtonClicked)
185 m_OnMouseInteractionButtonClicked.Invoke(SCR_ScenarioEntryHelper.BUTTON_CONTINUE);
189 protected void OnRestart()
191 if (m_OnMouseInteractionButtonClicked)
192 m_OnMouseInteractionButtonClicked.Invoke(SCR_ScenarioEntryHelper.BUTTON_RESTART);
196 protected void OnHost()
198 if (m_bIsInErrorState)
201 if (m_OnMouseInteractionButtonClicked)
202 m_OnMouseInteractionButtonClicked.Invoke(SCR_ScenarioEntryHelper.BUTTON_HOST);
206 protected void OnFindServers()
208 if (m_bIsInErrorState)
211 if (m_OnMouseInteractionButtonClicked)
212 m_OnMouseInteractionButtonClicked.Invoke(SCR_ScenarioEntryHelper.BUTTON_FIND_SERVERS);
216 protected void OnCommStatusCheckFinished(
SCR_ECommStatus status,
float responseTime,
float lastSuccessTime,
float lastFailTime)
218 UpdateModularButtons();
223 void NotifyScenarioUpdate()
229 void SetScenario(MissionWorkshopItem mission)
237 MissionWorkshopItem GetScenario()
243 void ShowFavouriteButton(
bool show)
245 m_Widgets.m_FavouriteButtonOverlay.SetVisible(show);
249 void ShowName(
bool show)
255 void ShowPlayerCount(
bool show)
257 m_Widgets.m_PlayerCount.SetVisible(show);
261 void ShowLastPlayedText(
bool show)
263 m_Widgets.m_LastPlayedTextSize.SetVisible(show);
267 void ShowSource(
bool show)