5 MissionWorkshopItem m_Scenario =
null;
7 protected bool m_bIsLocal =
true;
8 protected ImageWidget m_ScenarioImage;
9 protected TextWidget m_ScenarioName;
11 protected TextWidget m_ScenarioSumary;
12 protected TextWidget m_ScenarioGameMode;
14 protected Widget m_ScenarioMod;
16 protected Widget m_wPlayableButtom;
17 protected Widget m_wWhiteFrame;
24 protected Widget m_wGamepadModNameButton;
26 protected Widget m_ScenarioModButton;
27 protected Widget m_wFavouriteOverlay;
29 private string m_sFavouriteOverlay =
"FavouriteOverlayButton";
31 private InputManager m_InputManager;
33 ContentBrowserUI m_ParentContentBrowserMenu;
35 ref ScriptInvoker m_OnPlayClicked =
new ScriptInvoker();
36 ref ScriptInvoker m_OnHostClicked =
new ScriptInvoker();
37 ref ScriptInvoker m_OnJoinClicked =
new ScriptInvoker();
40 override void HandlerAttached(Widget w)
42 super.HandlerAttached(w);
45 m_ScenarioGameMode = TextWidget.Cast(
m_wRoot.FindAnyWidget(
"ScenarioGameMode"));
46 m_ScenarioImage = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"ScenarioImage"));
47 m_ScenarioName = TextWidget.Cast(
m_wRoot.FindAnyWidget(
"ScenarioName"));
48 m_ScenarioMod =
m_wRoot.FindAnyWidget(
"ScenarioMod");
49 m_ScenarioModButton =
m_wRoot.FindAnyWidget(
"ScenarioModButton");
50 m_ScenarioSumary = TextWidget.Cast(
m_wRoot.FindAnyWidget(
"ScenarioSumary"));
51 m_wPlayableButtom =
m_wRoot.FindAnyWidget(
"PlayablePC");
52 m_wWhiteFrame =
m_wRoot.FindAnyWidget(
"WhiteFrameOverlay");
56 if (m_PlayButtonComponent)
57 m_PlayButtonComponent.m_OnActivated.Insert(OnPlay);
60 if (m_HostButtonComponent)
61 m_HostButtonComponent.m_OnActivated.Insert(OnHost);
64 if (m_JoinButtonComponent)
65 m_JoinButtonComponent.m_OnActivated.Insert(OnJoin);
67 if (m_ScenarioModButton)
72 m_ModParentComp.m_OnClicked.Insert(OpenParentMod);
76 m_wFavouriteOverlay = w.FindAnyWidget(m_sFavouriteOverlay);
77 if (m_wFavouriteOverlay)
82 m_FavComponent.m_OnChanged.Insert(OnFavouriteClicked);
86 m_wGamepadModNameButton =
m_wRoot.FindAnyWidget(
"ModNavButton");
87 GetGame().OnInputDeviceIsGamepadInvoker().Remove(OnInputDeviceIsGamepad);
88 GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepad);
90 AnimateWidget.Opacity(m_wPlayableButtom, 0, m_fAnimationRate);
95 MissionWorkshopItem GetMission()
107 void OpenParentModGamepad()
109 if (!m_ScenarioMod.IsVisible())
135 void SetParentMenu(ContentBrowserUI menu)
137 m_ParentContentBrowserMenu = menu;
148 m_ScenarioImage.LoadImageTexture(0, header.m_sIcon,
false,
true);
149 m_ScenarioImage.SetImage(0);
157 m_ScenarioName.SetText(header.m_sName);
160 if (m_ScenarioSumary)
162 if (header.m_sDescription)
163 m_ScenarioSumary.SetText(header.m_sDescription);
166 if (m_ScenarioGameMode)
168 if (m_ScenarioGameMode)
169 m_ScenarioGameMode.SetText(header.m_sGameMode);
172 if (header.IsMultiplayer())
174 m_HostButtonComponent.GetRootWidget().SetVisible(
true);
175 m_JoinButtonComponent.GetRootWidget().SetVisible(
true);
179 m_HostButtonComponent.GetRootWidget().SetVisible(
false);
180 m_JoinButtonComponent.GetRootWidget().SetVisible(
false);
185 void SetScenario(MissionWorkshopItem scenario,
bool bShowOwner =
true,
bool bShowFavourite =
true)
192 m_wFavouriteOverlay.SetVisible(
true);
193 if (scenario.IsFavorite())
194 AnimateWidget.Opacity(m_wPlayableButtom, 1,
UIConstants.FADE_RATE_DEFAULT);
195 m_FavComponent.SetSelected(scenario.IsFavorite(),
false);
199 SetScenarioHeader(header);
204 ImageScale img = scenario.Thumbnail().GetLocalScale(0);
207 m_ScenarioImage.LoadImageTexture(0, img.Path(),
false,
true);
208 m_ScenarioImage.SetImage(0);
216 m_ScenarioName.SetText(scenario.Name());
219 if (m_ScenarioSumary)
221 if (scenario.Description())
222 m_ScenarioSumary.SetText(scenario.Description());
227 m_FavComponent.SetSelected(
m_Scenario.IsFavorite(),
false);
230 WorkshopItem owner = scenario.GetOwner();
239 m_ScenarioMod.SetVisible(
true);
240 m_ModParentComp.SetContent(owner.Name());
243 m_ScenarioName.SetColor(Color.FromInt(
UIColors.CONTRAST_COLOR.PackToInt()));
249 m_ScenarioMod.SetVisible(
false);
251 int flags = owner.GetStateFlags();
252 if (!(flags & EWorkshopItemState.EWSTATE_OFFLINE) || !owner.IsLoaded())
255 m_wPlayableButtom.SetVisible(
false);
264 MissionWorkshopItem GetScenario()
273 return GetGame().GetWorkspace().GetFocusedWidget() == this.
m_wRoot;
279 if (!this.IsFocused())
282 m_OnPlayClicked.Invoke(
this);
288 if (!this.IsFocused())
291 m_OnHostClicked.Invoke(
this);
297 if (!this.IsFocused())
300 m_OnJoinClicked.Invoke(
this);
304 override void OnMenuSelect()
310 override bool OnMouseButtonDown(Widget w,
int x,
int y,
int button)
317 override bool OnMouseButtonUp(Widget w,
int x,
int y,
int button)
324 override bool OnFocus(Widget w,
int x,
int y)
330 m_FavComponent.ShowButton();
331 AnimateWidget.Opacity(m_wPlayableButtom, 1, m_fAnimationRate);
332 AnimateWidget.Color(m_wWhiteFrame, m_BackgroundSelected, m_fAnimationRate);
337 m_wGamepadModNameButton.SetOpacity(0);
341 m_InputManager.AddActionListener(
"MenuRefresh", EActionTrigger.PRESSED, OpenParentModGamepad);
342 m_wGamepadModNameButton.SetOpacity(1);
345 return super.OnFocus( w, x, y);;
349 override bool OnFocusLost(Widget w,
int x,
int y)
355 AnimateWidget.Color(m_wWhiteFrame, Color.FromInt(
UIColors.TRANSPARENT.PackToInt()), m_fAnimationRate);
356 AnimateWidget.Opacity(m_wPlayableButtom, 0, m_fAnimationRate);
357 AnimateWidget.Opacity(m_wGamepadModNameButton, 0, m_fAnimationRate);
359 m_InputManager.RemoveActionListener(
"MenuRefresh", EActionTrigger.PRESSED, OpenParentModGamepad);
360 m_wGamepadModNameButton.SetOpacity(0);
361 m_FavComponent.HideButton();
362 return super.OnFocusLost( w, x, y);;
366 void OnButtonHovered()
372 void OnInputDeviceIsGamepad(
bool isGamepad)
378 void OnFavouriteClicked()
380 m_Scenario.SetFavorite(m_FavComponent.IsSelected());