Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ServerScenarioDetailsPanelComponent.c
Go to the documentation of this file.
1/*
2Scenaraio panel with additional mods data.
3Used mainly in server browser for displaying server(room) scenario and it's mods data
4*/
5
7{
8 [Attribute("", UIWidgets.ResourceNamePicker, "Layout", "edds")]
9 protected string m_sDefaultScenarioImg;
10
11 // Widget Names
12 protected const string WIDGET_MODS_COUNT = "ModsCount";
13 protected const string WIDGET_MODS_LOADING = "LoadingMods";
14 protected const string WIDGET_MODS_ICON = "ModsSizeIcon";
15 protected const string WIDGET_MODS_SIZE = "ModsSizeText";
16 protected const string WIDGET_MODS_LOCKED_ICON = "ModsLockedIcon";
17
18 // Localized strings
19 protected const string STR_VERSION_MISMATCH = "#AR-ServerBrowser_JoinModVersionMissmatch";
20 protected const string STR_UNJOINABLE = "#AR-ServerBrowser_NoneServers";
21
22 protected const string STR_DEFAULT_VERSION = "0.0.0.0";
23
24 // Mods Widgets
30
32
33 // Server additional data
34 protected Room m_Room;
36 protected bool m_bHideScenarioImg;
37
38 //------------------------------------------------------------------------------------------------
39 // Override functions
40 //------------------------------------------------------------------------------------------------
41
42 //------------------------------------------------------------------------------------------------
43 override void HandlerAttached(Widget w)
44 {
45 super.HandlerAttached(w);
46
47 // Get additional
48 m_wTxtModsCount = TextWidget.Cast(w.FindAnyWidget(WIDGET_MODS_COUNT));
49 m_wModsSizeText = TextWidget.Cast(w.FindAnyWidget(WIDGET_MODS_SIZE));
50 m_wImgModsIcon = ImageWidget.Cast(w.FindAnyWidget(WIDGET_MODS_ICON));
52
53 Widget wModsLoading = w.FindAnyWidget(WIDGET_MODS_LOADING);
54 if (wModsLoading)
55 m_ModsLoading = SCR_LoadingOverlay.Cast(wModsLoading.FindHandler(SCR_LoadingOverlay));
56
57 m_wImageCrossplay = AddTypeDisplay("platform-crossplay", UIConstants.ICONS_IMAGE_SET, UIConstants.ICONS_GLOW_IMAGE_SET);
58
59 if (!GetGame().InPlayMode())
60 return;
61
62 // Setup widgets
65 }
66
67 //------------------------------------------------------------------------------------------------
68 override void SetScenario(MissionWorkshopItem scenario)
69 {
71 {
74 }
75
77
78 // Update scenario
79 m_Scenario = scenario;
80 if (scenario)
81 {
82 SCR_MissionHeader header = SCR_MissionHeader.Cast(scenario.GetHeader());
83 m_Header = header;
84 }
85 else
86 m_Header = null;
87
89
90 // Set room version
91 string strVersion = UIConstants.FormatVersion(STR_DEFAULT_VERSION);
92
93 if (!m_Room || !m_Room.Joinable())
94 strVersion = STR_UNJOINABLE + "!";
95
96 else if (m_Room.GameVersion())
97 {
98 strVersion = UIConstants.FormatVersion(m_Room.GameVersion());
99
100 if (m_Room.GameVersion() != GetGame().GetBuildVersion())
101 strVersion += " - " + STR_VERSION_MISMATCH + "!";
102 }
103
104 m_CommonWidgets.m_wAuthorNameText.SetText(strVersion);
105
106 m_CommonWidgets.m_wNameImg.SetVisible(false);
107 }
108
109 //------------------------------------------------------------------------------------------------
111 {
113 m_BackendImageComponent.GetOnImageSelected().Remove(OnScenarioBackendImageSelected);
114
115 m_CommonWidgets.m_wLoadingOverlay.SetVisible(false);
116 }
117
118 //------------------------------------------------------------------------------------------------
119 void SetHideScenarioImg(bool hideContent) { m_bHideScenarioImg = hideContent; }
120
121 //------------------------------------------------------------------------------------------------
123 override protected void UpdateAllWidgets()
124 {
125 super.UpdateAllWidgets();
126
128 m_CommonWidgets.m_wImage.LoadImageTexture(0, m_sDefaultScenarioImg, false, true);
129 }
130
131 //------------------------------------------------------------------------------------------------
132 // public functions
133 //------------------------------------------------------------------------------------------------
134
135 //------------------------------------------------------------------------------------------------
138 void SetDefaultScenario(string contentTag)
139 {
140 // Get content
142 if (!content)
143 {
144 #ifdef SB_DEBUG
145 Print("[SCR_ServerScenarioDeatilsPanelComponent] No fallback content was found!");
146 #endif
147 return;
148 }
149
150 // Set fallback image
151 if (!content.m_sImage.IsEmpty())
152 m_CommonWidgets.m_wImage.LoadImageTexture(0, content.m_sImage);
153 else
154 {
155 if (m_FallbackContent && m_FallbackContent.m_DefaultContent)
156 {
157 if (!m_FallbackContent.m_DefaultContent.m_sImage.IsEmpty())
158 m_CommonWidgets.m_wImage.LoadImageTexture(0, m_FallbackContent.m_DefaultContent.m_sImage);
159 }
160 }
161
162 // Correct image size
163 int sx, sy;
164 m_CommonWidgets.m_wImage.GetImageSize(0, sx, sy);
165 m_CommonWidgets.m_wImage.SetSize(sx, sy);
166 m_CommonWidgets.m_wLoadingOverlay.SetVisible(false);
167
168 // Title
169 string title = content.m_sTitle;
170
171 m_CommonWidgets.m_wNameText.SetText(title);
172 if (!content.m_sTitleImageName.IsEmpty())
173 {
174 m_CommonWidgets.m_wNameImg.LoadImageFromSet(0, UIConstants.ICONS_IMAGE_SET, content.m_sTitleImageName);
175 m_CommonWidgets.m_wNameImg.SetColor(content.m_sTitleImageColor);
176 m_CommonWidgets.m_wNameImg.SetVisible(true);
177 }
178
179 // Description
180 m_CommonWidgets.m_wDescriptionText.SetText(content.m_sDescription);
181
182 // Show default description
183 m_CommonWidgets.m_wImage.SetVisible(true);
184 m_CommonWidgets.m_wNameText.SetVisible(true);
185 m_CommonWidgets.m_wDescriptionText.SetVisible(true);
186
187 m_CommonWidgets.m_wAuthorNameText.SetVisible(false);
188
190 m_wImageCrossplay.SetVisible(false);
191
193 }
194
195 //------------------------------------------------------------------------------------------------
196 void DisplayRoomData(Room room, bool showMods = true)
197 {
199 m_CommonWidgets.m_wTopSize.SetOpacity(1);
200
201 // Display mods loading
203
204 bool show = room.IsModded() && showMods;
205
206 m_ModsLoading.SetShown(show);
207 m_wImgModsLocked.SetVisible(false);
208
209 if (!room.IsModded())
210 return;
211
212 // Loading for public modded server
213 if (!room.PasswordProtected())
214 {
215 m_ModsLoading.SetShown(show);
216 }
217 else
218 {
219 // Warning for protected modded server
220 if (!room.IsAuthorized())
221 {
222 m_ModsLoading.SetShown(false);
223
224 m_wImgModsIcon.SetVisible(true);
225 m_wImgModsLocked.SetVisible(true);
226 }
227 }
228 }
229
230 //-----------------------------------------------------------------------------------
231 protected void DisplayRoomDataScenario(Room room)
232 {
233 m_Room = room;
234
235 // Check room
236 if (!m_Room)
237 return;
238
239 // Set room version
240 string strVersion = UIConstants.FormatVersion(STR_DEFAULT_VERSION);
241 if (room.GameVersion())
242 strVersion = UIConstants.FormatVersion(room.GameVersion());
243
244 // Scenario
245 string scenarioDescription;
246 if (m_Scenario)
247 scenarioDescription = m_Scenario.Description();
248
249 // Set content
250 string title = room.ScenarioName();
251 //title.ToUpper();
252 m_CommonWidgets.m_wNameText.SetText(title);
253 m_CommonWidgets.m_wDescriptionText.SetText(scenarioDescription);
254 m_CommonWidgets.m_wAuthorNameText.SetText(strVersion);
255 m_CommonWidgets.m_wCrossplayHorizontalLayout.SetVisible(room.IsCrossPlatform());
256
257 // Version match
258 if (room.GameVersion() == GetGame().GetBuildVersion() && room.Joinable())
259 {
260 m_CommonWidgets.m_wAuthorNameText.SetColor(Color.FromInt(UIColors.SUB_HEADER.PackToInt()));
261 }
262 else
263 {
264 m_CommonWidgets.m_wAuthorNameText.SetColor(Color.FromInt(UIColors.WARNING.PackToInt()));
265
266 string text = m_CommonWidgets.m_wAuthorNameText.GetText();
267 if(room.Joinable())
268 text += " - " + STR_VERSION_MISMATCH + "!";
269
270 m_CommonWidgets.m_wAuthorNameText.SetText(text);
271 }
272
273 m_CommonWidgets.m_wNameText.SetVisible(true);
274 m_CommonWidgets.m_wAuthorNameText.SetVisible(true);
275 m_CommonWidgets.m_wLoadingOverlay.SetVisible(true);
276
278 m_wImageCrossplay.SetVisible(m_Room.IsCrossPlatform());
279 }
280
281 //-----------------------------------------------------------------------------------
283 {
285 m_BackendImageComponent.SetImage(null);
286
287 m_CommonWidgets.m_wLoadingOverlay.SetVisible(false);
288 }
289
290 //-----------------------------------------------------------------------------------
293 protected void HideModsWidgets()
294 {
295 m_wTxtModsCount.SetVisible(false);
296 m_wImgModsIcon.SetVisible(false);
297 m_wModsSizeText.SetVisible(false);
298
299 m_ModsLoading.SetShown(false);
300 }
301
302 //-----------------------------------------------------------------------------------
305 {
306 //m_aMods = mods;
307
308 // Check widgets
309 if (!m_wTxtModsCount)
310 return;
311
312 // Get values
313 array<ref SCR_WorkshopItem> allMods = m_ModsManager.GetRoomItemsScripted();
314
315 int count = allMods.Count();
316 m_ModsLoading.SetShown(false);
317
318 // Show UGC restricted message
319 if (count > 0 && !SCR_AddonManager.GetInstance().GetUgcPrivilege())
320 {
321 m_wModsSizeText.SetText("#AR-ServerBrowser_ContentNotAllowed");
322 m_wModsSizeText.SetColor(Color.FromInt(UIColors.WARNING.PackToInt()));
323 m_wModsSizeText.SetVisible(true);
324 return;
325 }
326
327 // Hide mods widget if no mods
328 bool show = (count != 0);
329
330 m_wImgModsIcon.SetVisible(show);
331 m_wTxtModsCount.SetVisible(show);
332 m_wModsSizeText.SetVisible(show);
333 m_wModsSizeText.SetColor(Color.FromInt(UIColors.NEUTRAL_ACTIVE_STANDBY.PackToInt()));
334
335 if (!show)
336 return;
337
338 string totalSize = m_ModsManager.GetModListSizeString(allMods);
339
340 // Set Text
341 m_wTxtModsCount.SetText(count.ToString());
342 m_wModsSizeText.SetText(totalSize);
343 m_wModsSizeText.Update();
344
345 // Check mods to update size
346 array<ref SCR_WorkshopItem> toUpdateMods = m_ModsManager.GetRoomItemsToUpdate();
347
348 // Check to update mods count
349 if (toUpdateMods.IsEmpty())
350 return;
351 }
352
353 //-----------------------------------------------------------------------------------
355 void DisplayModsCount(int count)
356 {
357 // Show if modded
358 if (count != 0)
359 {
360 m_wTxtModsCount.SetText(count.ToString());
361
362 // Set widgets
363 m_wTxtModsCount.SetVisible(true);
364 m_wImgModsIcon.SetVisible(true);
365 m_wModsSizeText.SetVisible(false);
366 }
367 }
368
369 //-----------------------------------------------------------------------------------
371 {
372 m_ModsManager = manager;
373 }
374}
class RestAPIHelper< JsonApiStruct T > content
ArmaReforgerScripted GetGame()
Definition game.c:1398
Definition Color.c:13
Definition Room.c:13
bool GetUgcPrivilege()
Returns immediate value of UserPrivilege.USER_GEN_CONTENT.
static SCR_AddonManager GetInstance()
ref SCR_ContentDetailsPanelBaseWidgets m_CommonWidgets
DetailsPanelContentPreset FallbackContentByTag(string contentTag)
Get fallback content by tag.
ref DetailsPanelContentPresetConfig m_FallbackContent
Widget AddTypeDisplay(string image, ResourceName imageset, ResourceName glowImageset)
SCR_ScenarioBackendImageComponent m_BackendImageComponent
void DisplayModsCount(int count)
Quick display mods count.
override void SetScenario(MissionWorkshopItem scenario)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
SCR_FieldOfViewSettings Attribute