Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_GMMenuTileComponent.c
Go to the documentation of this file.
2 {
3  MissionWorkshopItem m_Item;
4  ref SCR_MissionHeader m_Header;
5  string m_sScenarioPath;
6  Widget m_wFeatured;
7  TextWidget m_wTypeText;
8  TextWidget m_wName;
9  TextWidget m_wDescription;
11  SCR_InputButtonComponent m_Continue;
12  SCR_InputButtonComponent m_Restart;
13  SCR_InputButtonComponent m_FindServer;
14  Widget m_wFooter;
15 
16  // All return SCR_GMMenuTileComponent as script invoker
17  ref ScriptInvoker m_OnPlay = new ScriptInvoker();
18  ref ScriptInvoker m_OnContinue = new ScriptInvoker();
19  ref ScriptInvoker m_OnRestart = new ScriptInvoker();
20  ref ScriptInvoker m_OnFindServer = new ScriptInvoker();
21 
22  //------------------------------------------------------------------------------------------------
23  override void HandlerAttached(Widget w)
24  {
25  super.HandlerAttached(w);
26  m_wTypeText = TextWidget.Cast(w.FindAnyWidget("TypeText"));
27  m_wName = TextWidget.Cast(w.FindAnyWidget("Name"));
28  m_wDescription = TextWidget.Cast(w.FindAnyWidget("Description"));
29  m_wFooter = w.FindAnyWidget("Footer");
30  m_wFeatured = w.FindAnyWidget("Featured");
31  m_Play = SCR_InputButtonComponent.GetInputButtonComponent("Play", w);
32  if (m_Play)
33  m_Play.m_OnActivated.Insert(OnPlay);
34 
35  m_Continue = SCR_InputButtonComponent.GetInputButtonComponent("Continue", w);
36  if (m_Continue)
37  m_Continue.m_OnActivated.Insert(OnContinue);
38 
39  m_FindServer = SCR_InputButtonComponent.GetInputButtonComponent("FindServer", w);
40  if (m_FindServer)
41  m_FindServer.m_OnActivated.Insert(OnFindServer);
42 
43  m_Restart = SCR_InputButtonComponent.GetInputButtonComponent("Restart", w);
44  if (m_Restart)
45  m_Restart.m_OnActivated.Insert(OnRestart);
46 
47  m_wFooter.SetOpacity(0);
48  m_wFooter.SetEnabled(false);
49  }
50 
51  //------------------------------------------------------------------------------------------------
52  override bool OnDoubleClick(Widget w, int x, int y, int button)
53  {
54  super.OnDoubleClick(w, x, y, button);
55 
56  if (button == 0)
57  m_OnPlay.Invoke(this);
58 
59  return false;
60  }
61 
62  //------------------------------------------------------------------------------------------------
63  override bool OnFocus(Widget w, int x, int y)
64  {
65  super.OnFocus(w, x, y);
66  //AnimateWidget.Opacity(m_wFooter, 1, m_fAnimationRate);
67  m_wFooter.SetOpacity(1);
68  m_wFooter.SetEnabled(true);
69  return false;
70  }
71 
72  //------------------------------------------------------------------------------------------------
73  override bool OnFocusLost(Widget w, int x, int y)
74  {
75  super.OnFocusLost(w, x, y);
76  //AnimateWidget.Opacity(m_wFooter, 0, m_fAnimationRate);
77  m_wFooter.SetOpacity(0);
78  m_wFooter.SetEnabled(false);
79 
80  return false;
81  }
82 
83  //------------------------------------------------------------------------------------------------
89  void ShowMission(notnull MissionWorkshopItem item, bool isFeatured = false, bool isRecent = false, bool isRecommended = false)
90  {
91  m_Item = item;
92 
93  if (isFeatured)
94  m_wTypeText.SetText("#AR-MainMenu_Featured");
95  else if (isRecent)
96  m_wTypeText.SetText("#AR-MainMenu_Recent");
97  else if (isRecommended)
98  m_wTypeText.SetText("#AR-MainMenu_Recommended");
99  else
100  m_wTypeText.SetText(" "); // Hide the widget, keep space
101 
102  m_wName.SetText(item.Name());
103  m_wDescription.SetText(item.Description());
104 
105  // Set image through SCR_ButtonImageComponent
106  m_Header = SCR_MissionHeader.Cast(MissionHeader.ReadMissionHeader(item.Id()));
108  if (comp)
109  {
110  ResourceName texture = GetTexture();
111  if (!texture.IsEmpty())
112  comp.SetImage(texture);
113  }
114 
115  m_wFeatured.SetVisible(isFeatured);
116 
117  bool canContinue = m_Header && GetGame().GetSaveManager().HasLatestSave(m_Header);
118  m_Play.SetVisible(!canContinue);
119  m_Continue.SetVisible(canContinue);
120 
121  m_Restart.SetVisible(canContinue);
122  m_FindServer.SetVisible(item.GetPlayerCount() > 1);
123  }
124 
125  //------------------------------------------------------------------------------------------------
127  ResourceName GetTexture()
128  {
129  if (!m_Header)
130  return m_Item.Thumbnail().GetLocalScale(1920).Path();
131 
132  if (!m_Header.m_sPreviewImage.IsEmpty())
133  return m_Header.m_sPreviewImage;
134 
135  if (!m_Header.m_sIcon.IsEmpty())
136  return m_Header.m_sIcon;
137 
138  return m_Header.m_sLoadingScreen;
139  }
140 
141  //------------------------------------------------------------------------------------------------
142  void OnPlay()
143  {
144  m_OnPlay.Invoke(this);
145  }
146 
147  //------------------------------------------------------------------------------------------------
148  void OnContinue()
149  {
150  m_OnContinue.Invoke(this);
151  }
152 
153  //------------------------------------------------------------------------------------------------
154  void OnRestart()
155  {
156  m_OnRestart.Invoke(this);
157  }
158 
159  //------------------------------------------------------------------------------------------------
160  void OnFindServer()
161  {
162  m_OnFindServer.Invoke(this);
163  }
164 }
m_wName
TextWidget m_wName
Definition: SCR_PlayerListMenu.c:20
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
SCR_TileBaseComponent
Definition: SCR_TileBaseComponent.c:1
m_Item
NewsFeedItem m_Item
Definition: SCR_NewsSubMenu.c:2
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
MissionHeader
Definition: MissionHeader.c:32
SCR_GMMenuTileComponent
Definition: SCR_GMMenuTileComponent.c:1
SCR_ButtonImageComponent
Definition: SCR_ButtonImageComponent.c:2
SCR_MissionHeader
Definition: SCR_MissionHeader.c:1
SCR_InputButtonComponent
Definition: SCR_InputButtonComponent.c:1