3 [
Attribute(
"0", UIWidgets.CheckBox,
"Is this a big vertical tile? E.g. will use hi-res thumb picture..")]
4 protected bool m_bBigTile;
6 [
Attribute(
"480", UIWidgets.Slider,
"Estimated width of grid thumb picture, in a reference resolution.",
"320 1920 1")]
7 protected float m_fThumbnailWidth;
9 MissionWorkshopItem m_Item;
11 string m_sScenarioPath;
13 Widget m_wContentGroup;
16 TextWidget m_wDescription;
17 Widget m_wRecentlyPlayed;
18 TextWidget m_wRecentlyPlayedText;
21 Widget m_wMouseInteractButtons;
28 bool m_bIsMouseInteraction;
30 protected ref array<SCR_ModularButtonComponent> m_aMouseButtonsError = {};
35 SCR_ModularButtonComponent m_Play;
36 SCR_ModularButtonComponent m_Continue;
37 SCR_ModularButtonComponent m_FindServer;
38 SCR_ModularButtonComponent m_Host;
39 SCR_ModularButtonComponent m_Restart;
51 override void HandlerAttached(Widget w)
53 super.HandlerAttached(w);
58 m_wName = TextWidget.Cast(w.FindAnyWidget(
"Name"));
59 m_wDescription = TextWidget.Cast(w.FindAnyWidget(
"Description"));
60 m_wFeatured = w.FindAnyWidget(
"Featured");
61 m_wContentGroup = w.FindAnyWidget(
"ContentGroup");
63 m_wRecentlyPlayed = w.FindAnyWidget(
"RecentlyPlayed");
64 m_wRecentlyPlayedText = TextWidget.Cast(m_wRecentlyPlayed.FindAnyWidget(
"Label"));
66 m_wMouseInteractButtons = w.FindAnyWidget(
"MouseInteractButtons");
67 m_wPlay = w.FindAnyWidget(SCR_ScenarioEntryHelper.BUTTON_PLAY);
68 m_wContinue = w.FindAnyWidget(SCR_ScenarioEntryHelper.BUTTON_CONTINUE);
69 m_wRestart = w.FindAnyWidget(SCR_ScenarioEntryHelper.BUTTON_RESTART);
70 m_wHost = w.FindAnyWidget(SCR_ScenarioEntryHelper.BUTTON_HOST);
71 m_wFindServer = w.FindAnyWidget(SCR_ScenarioEntryHelper.BUTTON_FIND_SERVERS);
73 m_Play = SCR_ModularButtonComponent.FindComponent(m_wPlay);
75 m_Play.m_OnClicked.Insert(OnPlay);
77 m_Continue = SCR_ModularButtonComponent.FindComponent(m_wContinue);
79 m_Continue.m_OnClicked.Insert(OnContinue);
81 m_Restart = SCR_ModularButtonComponent.FindComponent(m_wRestart);
83 m_Restart.m_OnClicked.Insert(OnRestart);
85 m_Host = SCR_ModularButtonComponent.FindComponent(m_wHost);
88 m_aMouseButtonsError.Insert(
m_Host);
89 m_Host.m_OnClicked.Insert(OnHost);
92 m_FindServer = SCR_ModularButtonComponent.FindComponent(m_wFindServer);
95 m_aMouseButtonsError.Insert(m_FindServer);
96 m_FindServer.m_OnClicked.Insert(OnFindServers);
102 InputManager inputManager =
GetGame().GetInputManager();
105 m_bIsMouseInteraction = (inputManager.GetLastUsedInputDevice() == EInputDeviceType.MOUSE);
107 GetGame().OnInputDeviceUserChangedInvoker().Insert(OnInputDeviceUserChanged);
113 override void HandlerDeattached(Widget w)
115 super.HandlerDeattached(w);
121 override bool OnFocus(Widget w,
int x,
int y)
123 super.OnFocus(w, x, y);
126 UpdateModularButtons();
135 override bool OnFocusLost(Widget w,
int x,
int y)
137 super.OnFocusLost(w, x, y);
140 UpdateModularButtons();
156 if (!item.GetOwner())
160 m_wDescription.SetText(item.Description());
162 bool canContinue = m_Header && SCR_ScenarioEntryHelper.HasSave(item);
163 bool mp = SCR_ScenarioEntryHelper.IsMultiplayer(item);
165 m_wPlay.SetVisible(!canContinue);
166 m_wContinue.SetVisible(canContinue);
167 m_wRestart.SetVisible(canContinue);
169 m_wFindServer.SetVisible(mp);
171 UpdateModularButtons();
178 ResourceName texture = GetTexture();
182 if (!texture.IsEmpty())
183 comp.SetImage(texture, item.GetOwner() !=
null);
197 int timeSinceLastPlayedSeconds =
m_Item.GetTimeSinceLastPlay();
198 string sLastPlayed =
SCR_FormatHelper.GetTimeSinceEventImprecise(timeSinceLastPlayedSeconds);
200 m_wRecentlyPlayedText.SetText(sLastPlayed);
203 if (m_wMouseInteractButtons)
204 m_wMouseInteractButtons.SetVisible(
false);
210 protected void Enable(
bool enable =
true)
213 m_wContentGroup.SetVisible(enable);
218 ResourceName GetTexture()
220 if (m_bBigTile && m_Header && !m_Header.m_sPreviewImage.IsEmpty())
221 return m_Header.m_sPreviewImage;
224 return m_Header.m_sLoadingScreen;
228 BackendImage image =
m_Item.Thumbnail();
235 float width = g_Game.GetWorkspace().DPIScale(m_fThumbnailWidth);
236 ImageScale scale = image.GetLocalScale((
int)width);
246 protected void OnInputDeviceUserChanged(EInputDeviceType oldDevice, EInputDeviceType newDevice)
250 if (newDevice == EInputDeviceType.TRACK_IR || newDevice == EInputDeviceType.JOYSTICK)
253 m_bIsMouseInteraction = (newDevice == EInputDeviceType.MOUSE);
257 protected void OnPlay()
259 if (m_OnMouseInteractionButtonClicked)
260 m_OnMouseInteractionButtonClicked.Invoke(SCR_ScenarioEntryHelper.BUTTON_PLAY);
264 protected void OnContinue()
266 if (m_OnMouseInteractionButtonClicked)
267 m_OnMouseInteractionButtonClicked.Invoke(SCR_ScenarioEntryHelper.BUTTON_CONTINUE);
271 protected void OnRestart()
273 if (m_OnMouseInteractionButtonClicked)
274 m_OnMouseInteractionButtonClicked.Invoke(SCR_ScenarioEntryHelper.BUTTON_RESTART);
278 protected void OnHost()
280 if (SCR_ScenarioEntryHelper.IsInErrorState(
m_Item))
283 if (m_OnMouseInteractionButtonClicked)
284 m_OnMouseInteractionButtonClicked.Invoke(SCR_ScenarioEntryHelper.BUTTON_HOST);
288 protected void OnFindServers()
290 if (SCR_ScenarioEntryHelper.IsInErrorState(
m_Item))
293 if (m_OnMouseInteractionButtonClicked)
294 m_OnMouseInteractionButtonClicked.Invoke(SCR_ScenarioEntryHelper.BUTTON_FIND_SERVERS);
298 protected void OnCommStatusCheckFinished(
SCR_ECommStatus status,
float responseTime,
float lastSuccessTime,
float lastFailTime)
300 UpdateModularButtons();
304 protected void OnTooltipShow(
SCR_ScriptedWidgetTooltip tooltipClass, Widget tooltipWidget, Widget hoverWidget, SCR_ScriptedWidgetTooltipPreset preset,
string tag)
306 m_CurrentTooltip = tooltipClass;
307 SCR_ScenarioEntryHelper.UpdateErrorMouseButtonsTooltip(tooltipClass,
m_Item);
311 protected void UpdateModularButtons()
313 SCR_ScenarioEntryHelper.UpdateErrorMouseButtonsTooltip(m_CurrentTooltip,
m_Item);
315 if (m_wMouseInteractButtons)
316 m_wMouseInteractButtons.SetVisible(m_bFocused);
318 array<SCR_ModularButtonComponent> mouseButtons = {};
320 mouseButtons.Insert(m_Restart);
322 SCR_ScenarioEntryHelper.UpdateMouseButtons(mouseButtons, m_aMouseButtonsError,
m_Item, m_bFocused);
326 protected void UpdateWarning()
331 m_bIsInErrorState = SCR_ScenarioEntryHelper.IsModInErrorState(
m_Item);
341 if (!m_OnMouseInteractionButtonClicked)
344 return m_OnMouseInteractionButtonClicked;