Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_PlayMenuTileComponent.c
Go to the documentation of this file.
2{
3 [Attribute("0", UIWidgets.CheckBox, "Is this a big vertical tile? E.g. will use hi-res thumb picture..")]
4 protected bool m_bBigTile;
5
6 [Attribute("480", UIWidgets.Slider, "Estimated width of grid thumb picture, in a reference resolution.", "320 1920 1")]
7 protected float m_fThumbnailWidth;
8
11
18
19 // Mouse interact buttons
21
23 protected bool m_bFocused;
24
25 // Button components
26 protected SCR_ModularButtonComponent m_Play;
27 protected SCR_ModularButtonComponent m_Continue;
28 protected SCR_ModularButtonComponent m_FindServer;
29 protected SCR_ModularButtonComponent m_Host;
30 protected SCR_ModularButtonComponent m_Restart;
31
32 // Warning
34
35 // Tooltip
37
38 // Script invokers for the mouse interact buttons
40
41 //------------------------------------------------------------------------------------------------
42 override void HandlerAttached(Widget w)
43 {
44 super.HandlerAttached(w);
45
48
49 m_wName = TextWidget.Cast(w.FindAnyWidget("Name"));
50 m_wDescription = TextWidget.Cast(w.FindAnyWidget("Description"));
51 m_wContentGroup = w.FindAnyWidget("ContentGroup");
52
53 m_wMouseInteractButtons = w.FindAnyWidget("MouseInteractButtons");
54 Widget wPlay = w.FindAnyWidget(SCR_ScenarioUICommon.BUTTON_PLAY);
55 Widget wContinue = w.FindAnyWidget(SCR_ScenarioUICommon.BUTTON_CONTINUE);
56 Widget wRestart = w.FindAnyWidget(SCR_ScenarioUICommon.BUTTON_RESTART);
57 Widget wHost = w.FindAnyWidget(SCR_ScenarioUICommon.BUTTON_HOST);
58 Widget wFindServer = w.FindAnyWidget(SCR_ScenarioUICommon.BUTTON_FIND_SERVERS);
59
60 m_Play = SCR_ModularButtonComponent.FindComponent(wPlay);
61 if (m_Play)
62 m_Play.m_OnClicked.Insert(OnPlay);
63
64 m_Continue = SCR_ModularButtonComponent.FindComponent(wContinue);
65 if (m_Continue)
66 m_Continue.m_OnClicked.Insert(OnContinue);
67
68 m_Restart = SCR_ModularButtonComponent.FindComponent(wRestart);
69 if (m_Restart)
70 m_Restart.m_OnClicked.Insert(OnRestart);
71
72 m_Host = SCR_ModularButtonComponent.FindComponent(wHost);
73 if (m_Host)
74 m_Host.m_OnClicked.Insert(OnHost);
75
76 m_FindServer = SCR_ModularButtonComponent.FindComponent(wFindServer);
77 if (m_FindServer)
78 m_FindServer.m_OnClicked.Insert(OnFindServers);
79
80 if (GetGame().InPlayMode())
81 Enable(false);
82
83 InputManager inputManager = GetGame().GetInputManager();
84
85 if (inputManager)
86 m_bIsMouseInteraction = (inputManager.GetLastUsedInputDevice() == EInputDeviceType.MOUSE);
87
88 GetGame().OnInputDeviceUserChangedInvoker().Insert(OnInputDeviceUserChanged);
89
91 }
92
93 //------------------------------------------------------------------------------------------------
100
101 //------------------------------------------------------------------------------------------------
102 override bool OnFocus(Widget w, int x, int y)
103 {
104 m_bFocused = true;
106
107 // Tooltips
109
110 return super.OnFocus(w, x, y);
111 }
112
113 //------------------------------------------------------------------------------------------------
114 override bool OnFocusLost(Widget w, int x, int y)
115 {
116 m_bFocused = false;
118
119 // Tooltips
121
122 return super.OnFocusLost(w, x, y);
123 }
124
125 //------------------------------------------------------------------------------------------------
128 void Setup(notnull MissionWorkshopItem item, EPlayMenuContentType contentType)
129 {
130 m_Item = item;
131
132 // Init header only if scenario is NOT coming from an addon
133 if (!item.GetOwner())
134 m_Header = SCR_MissionHeader.GetMissionHeader(item);
135
136 m_wName.SetText(item.Name());
137 m_wDescription.SetText(item.Description());
138
141
142 // Set image through SCR_ButtonImageComponent
144 if (comp)
145 {
146 ResourceName texture = GetTexture();
147
148 if (!texture.IsEmpty())
149 comp.SetImage(texture, item.GetOwner() != null);
150 }
151
152 if (contentType == EPlayMenuContentType.RECENT)
153 {
154 int timeSinceLastPlayedSeconds = m_Item.GetTimeSinceLastPlay();
155 string sLastPlayed = SCR_FormatHelper.GetTimeSinceEventImprecise(timeSinceLastPlayedSeconds);
156 }
157
159 m_wMouseInteractButtons.SetVisible(false);
160
161 Enable();
162 }
163
164 //------------------------------------------------------------------------------------------------
165 protected void Enable(bool enable = true)
166 {
167 m_wRoot.SetEnabled(enable);
168 m_wContentGroup.SetVisible(enable);
169 }
170
171 //------------------------------------------------------------------------------------------------
174 {
175 if (m_bBigTile && m_Header && !m_Header.m_sPreviewImage.IsEmpty())
176 return m_Header.m_sPreviewImage;
177
178 if (m_Header)
179 return m_Header.m_sLoadingScreen;
180
181 if (m_Item)
182 {
183 BackendImage image = m_Item.Thumbnail();
184
185 // DEBUG problems with scenario addon thumbs
186// array<ImageScale> scales = {};
187// int i = image.GetScales(scales);
188
189 // Get optimal width for the thumb
190 float width = g_Game.GetWorkspace().DPIScale(m_fThumbnailWidth);
191 ImageScale scale = image.GetLocalScale((int)width);
192 if (scale)
193 return scale.Path();
194 }
195
196 return string.Empty;
197 }
198
199 // React on switching between input methods
200 //------------------------------------------------------------------------------------------------
201 protected void OnInputDeviceUserChanged(EInputDeviceType oldDevice, EInputDeviceType newDevice)
202 {
203 //PrintFormat("OnInputDeviceUserChanged | %1 -> %2", oldDevice, newDevice);
204
205 if (newDevice == EInputDeviceType.TRACK_IR || newDevice == EInputDeviceType.JOYSTICK)
206 return;
207
208 m_bIsMouseInteraction = (newDevice == EInputDeviceType.MOUSE);
209 }
210
211 //------------------------------------------------------------------------------------------------
212 protected void OnPlay()
213 {
216 }
217
218 //------------------------------------------------------------------------------------------------
219 protected void OnContinue()
220 {
223 }
224
225 //------------------------------------------------------------------------------------------------
226 protected void OnRestart()
227 {
230 }
231
232 //------------------------------------------------------------------------------------------------
233 protected void OnHost()
234 {
236 return;
237
240 }
241
242 //------------------------------------------------------------------------------------------------
243 protected void OnFindServers()
244 {
246 return;
247
250 }
251
252 //------------------------------------------------------------------------------------------------
253 protected void OnCommStatusCheckFinished(SCR_ECommStatus status, float responseTime, float lastSuccessTime, float lastFailTime)
254 {
256 }
257
258 //------------------------------------------------------------------------------------------------
260 {
261 m_CurrentTooltip = tooltip;
263 }
264
265 //------------------------------------------------------------------------------------------------
279
280 //------------------------------------------------------------------------------------------------
281 protected void UpdateWarning()
282 {
283 if (!m_WarningOverlay)
284 return;
285
286 SCR_ERevisionAvailability availability = SCR_ScenarioUICommon.GetOwnerRevisionAvailability(m_Item);
287 m_bIsInErrorState = availability != SCR_ERevisionAvailability.ERA_AVAILABLE;
288
289 m_WarningOverlay.SetWarningVisible(m_bIsInErrorState, false);
291 }
292
293 //------------------------------------------------------------------------------------------------
302}
vector scale
ArmaReforgerScripted GetGame()
Definition game.c:1398
EPlayMenuContentType
Definition SCR_PlayMenu.c:2
ScriptInvokerBase< ScriptInvokerStringMethod > ScriptInvokerString
SCR_ECommStatus
This class may become obsolete on BackendAPI update.
Input management system for user interactions.
static string GetTimeSinceEventImprecise(int timeDiffSeconds)
SCR_ModularButtonComponent m_Continue
void Setup(notnull MissionWorkshopItem item, EPlayMenuContentType contentType)
void OnCommStatusCheckFinished(SCR_ECommStatus status, float responseTime, float lastSuccessTime, float lastFailTime)
override bool OnFocusLost(Widget w, int x, int y)
SCR_ModularButtonComponent m_Host
SCR_ModularButtonComponent m_Restart
SCR_ModularButtonComponent m_Play
SCR_ModularButtonComponent m_FindServer
override bool OnFocus(Widget w, int x, int y)
override void HandlerDeattached(Widget w)
override void HandlerAttached(Widget w)
ScriptInvokerString GetOnMouseInteractionButtonClicked()
void OnInputDeviceUserChanged(EInputDeviceType oldDevice, EInputDeviceType newDevice)
SCR_ScriptedWidgetTooltip m_CurrentTooltip
SCR_SimpleWarningOverlayComponent m_WarningOverlay
ref ScriptInvokerString m_OnMouseInteractionButtonClicked
void OnTooltipShow(SCR_ScriptedWidgetTooltip tooltip)
static void UpdateContinueMouseButton(SCR_ModularButtonComponent button, MissionWorkshopItem mission, bool entryFocused, bool visible=true)
static void UpdateMouseButtonTooltips(SCR_ScriptedWidgetTooltip tooltip, MissionWorkshopItem mission)
static bool CanJoin(MissionWorkshopItem mission)
static bool CanHost(MissionWorkshopItem mission)
static void UpdateJoinMouseButton(SCR_ModularButtonComponent button, MissionWorkshopItem mission, bool entryFocused, bool visible=true)
static void UpdateHostMouseButton(SCR_ModularButtonComponent button, MissionWorkshopItem mission, bool entryFocused, bool visible=true)
static void UpdateRestartMouseButton(SCR_ModularButtonComponent button, MissionWorkshopItem mission, bool entryFocused, bool visible=true)
static void UpdatePlayMouseButton(SCR_ModularButtonComponent button, MissionWorkshopItem mission, bool entryFocused, bool visible=true)
static SCR_ERevisionAvailability GetOwnerRevisionAvailability(MissionWorkshopItem mission)
static ScriptInvokerTooltip GetOnTooltipShow()
static ScriptInvokerCommStatus GetOnCommStatusCheckFinished()
static override SCR_SimpleWarningOverlayComponent FindComponentInHierarchy(notnull Widget root)
static string GetRevisionAvailabilityErrorMessage(WorkshopItem item)
static string GetRevisionAvailabilityErrorTexture(WorkshopItem item)
Game g_Game
Game singleton instance.
Definition gameLib.c:13
SCR_FieldOfViewSettings Attribute