Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
ContentBrowserUI.c
Go to the documentation of this file.
2 {
3  ONLINE = 0,
6 }
7 
9 class ContentBrowserUI : SCR_SuperMenuBase
10 {
12  static const float SMALL_DOWNLOAD_THRESHOLD = 50 * 1024 * 1024; // 50 Megabytes
13 
15 
16  //------------------------------------------------------------------------------------------------
17  static ContentBrowserUI Create()
18  {
19  MenuBase menuBase = GetGame().GetMenuManager().OpenMenu(ChimeraMenuPreset.ContentBrowser);
20  ContentBrowserUI browser = ContentBrowserUI.Cast(menuBase);
21 
22  return browser;
23  }
24 
25  //------------------------------------------------------------------------------------------------
26  static void _print(string str, LogLevel logLevel = LogLevel.DEBUG)
27  {
28  Print(string.Format("[Content Browser] %1", str), logLevel);
29  }
30 
31  // --- Overrides ---
32  //------------------------------------------------------------------------------------------------
33  override void OnMenuOpen()
34  {
35  super.OnMenuOpen();
36 
37  // Setup the 'back' nav button
38  m_NavBack = m_DynamicFooter.FindButton("Back");
39  if (m_NavBack)
40  m_NavBack.m_OnActivated.Insert(Close);
41  }
42 
43  //------------------------------------------------------------------------------------------------
44  override void OnMenuClose()
45  {
46  super.OnMenuClose();
47 
48  // Restore server hosting
50  {
51  if (ServerHostingUI.GetTemporaryConfig())
52  {
53  GetGame().GetMenuManager().OpenMenu(ChimeraMenuPreset.ServerBrowserMenu);
54  SCR_CommonDialogs.CreateServerHostingDialog();
55  }
56  }
57  }
58 
59  //------------------------------------------------------------------------------------------------
60  override void OnMenuUpdate(float tDelta)
61  {
62  super.OnMenuUpdate(tDelta);
63 
64  m_fTimerLowFreqUpdate += tDelta;
65  if (m_fTimerLowFreqUpdate > 1)
66  {
67  LowFreqUpdate();
69  }
70  }
71 
72  //------------------------------------------------------------------------------------------------
74  protected void LowFreqUpdate()
75  {
76  SCR_AddonManager mgr = SCR_AddonManager.GetInstance();
77 
78  if(!mgr)
79  return;
80 
81  // Warning sign
82  // Show warning icon if there is any offline mod which has any issue
83  array<ref SCR_WorkshopItem> allAddons = mgr.GetAllAddons();
84  array<ref SCR_WorkshopItem> offlineAddons = SCR_AddonManager.SelectItemsBasic(allAddons, EWorkshopItemQuery.OFFLINE);
85 
86  bool anyIssue = false;
87 
88  foreach (SCR_WorkshopItem item : offlineAddons)
89  {
90  bool dependenciesMissing = item.GetAnyDependencyMissing();
91  bool dependenciesOutdated = item.GetAnyDependencyUpdateAvailable();
92  bool dependenciesDisabled = item.GetEnabledAndAnyDependencyDisabled();
93  bool updateAvailable = item.GetUpdateAvailable();
94 
95  if (dependenciesMissing || dependenciesOutdated || dependenciesDisabled || updateAvailable)
96  {
97  anyIssue = true;
98  break;
99  }
100  }
101 
102  m_SuperMenuComponent.GetTabView().ShowIcon(EWorkshopTabId.OFFLINE, anyIssue);
103  }
104 
105  //------------------------------------------------------------------------------------------------
106  protected static string GetWorkshopStatus()
107  {
108  // Find WS status item
109  ServiceStatusItem wsStatus = FindStatusItemByName(SCR_ServicesStatusHelper.SERVICE_WORKSHOP);
110 
111  if (!wsStatus)
112  return string.Empty;
113 
114  return wsStatus.Status();
115  }
116 
117  //------------------------------------------------------------------------------------------------
118  // TODO: Move into generic backend script api
119  protected static ServiceStatusItem FindStatusItemByName(string name)
120  {
121  BackendApi backend = GetGame().GetBackendApi();
122  int statusesCount = backend.GetStatusCount();
123 
124  for (int i = 0; i < statusesCount; i++)
125  {
126  if (backend.GetStatusItem(i).Name() == name)
127  return backend.GetStatusItem(i);
128  }
129 
130  return null;
131  }
132 
133  // --- Public ---
134  //-----------------------------------------------------------------------------------------------
136  {
137  return m_SuperMenuComponent.GetOpenedSubMenu();
138  }
139 
140  //-----------------------------------------------------------------------------------------------
142  {
143  m_SuperMenuComponent.GetTabView().ShowTab(EWorkshopTabId.MOD_MANAGER);
144  }
145 }
m_NavBack
enum EWorkshopTabId m_NavBack
The super menu class for WORKSHOP content browser.
OnMenuUpdate
override void OnMenuUpdate(float tDelta)
Definition: ContentBrowserUI.c:60
_print
void _print(string s)
Definition: SCR_ModularButtonComponent.c:665
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
ONLINE
@ ONLINE
Definition: ContentBrowserUI.c:3
SCR_CommonDialogs
Definition: CommonDialogs.c:5
SCR_SubMenuBase
Definition: SCR_SubMenuBase.c:6
IsPlatformGameConsole
bool IsPlatformGameConsole()
Definition: game.c:1393
OpenModManager
void OpenModManager()
Definition: ContentBrowserUI.c:141
OFFLINE
@ OFFLINE
Definition: ContentBrowserUI.c:4
SCR_WorkshopItem
Definition: SCR_WorkshopItem.c:21
GetOpenedSubMenu
SCR_SubMenuBase GetOpenedSubMenu()
Definition: ContentBrowserUI.c:135
EWorkshopTabId
EWorkshopTabId
Definition: ContentBrowserUI.c:1
m_fTimerLowFreqUpdate
float m_fTimerLowFreqUpdate
Definition: ContentBrowserUI.c:14
OnMenuOpen
override void OnMenuOpen()
Definition: ContentBrowserUI.c:33
MOD_MANAGER
@ MOD_MANAGER
Definition: ContentBrowserUI.c:5
SCR_SuperMenuBase
Definition: SCR_SuperMenuBase.c:6
SCR_ServicesStatusHelper
Definition: SCR_ServicesStatusHelper.c:15
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition: ChimeraMenuBase.c:3
SCR_AddonManager
Definition: SCR_AddonManager.c:72
OnMenuClose
override void OnMenuClose()
Definition: ContentBrowserUI.c:44
LowFreqUpdate
protected void LowFreqUpdate()
Update non important UI elements.
Definition: ContentBrowserUI.c:74
EWorkshopItemQuery
EWorkshopItemQuery
Definition: SCR_AddonManager.c:34
SCR_InputButtonComponent
Definition: SCR_InputButtonComponent.c:1