Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ModsHandlerLib.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
6 //------------------------------------------------------------------------------------------------
8 {
9  //------------------------------------------------------------------------------------------------
11  static float GetModListSize(array<Dependency> dependencies)
12  {
13  // Empty array check
14  if (dependencies.IsEmpty())
15  return -1;
16 
17  // Size count
18  float size = 0;
19 
20  foreach (Dependency dependency : dependencies)
21  {
22  size += dependency.TotalFileSize();
23  }
24 
25  // Result
26  return size;
27  }
28 
29  //------------------------------------------------------------------------------------------------
31  static float GetModListSize(array<ref SCR_WorkshopItem> items)
32  {
33  // Empty array check
34  if (items.IsEmpty())
35  return -1;
36 
37  // Size count
38  float size = 0;
39 
40  foreach (SCR_WorkshopItem item : items)
41  {
42  size += item.GetSizeBytes();
43  }
44 
45  // Result
46  return size;
47  }
48 
49  //------------------------------------------------------------------------------------------------
53  static bool AllItemsCached(array<Dependency> aDependencies, out array<Dependency> aDepsToLoad)
54  {
55  for (int i = 0; i < aDependencies.Count(); i++)
56  {
57  WorkshopItem item = aDependencies[i].GetCachedItem();
58 
59  // Is cashed item missing?
60  if(!item)
61  {
62  // Items to load batch
63  aDepsToLoad.Insert(aDependencies[i]);
64  continue;
65  }
66  }
67 
68  // Are there dependecies to load
69  if (aDepsToLoad.Count() == 0)
70  return true;
71 
72  return false;
73  }
74 
75  //------------------------------------------------------------------------------------------------
78  static bool AllModsUpdated(array<Dependency> dependencies)
79  {
80  // No dependencies in list
81  if (dependencies.Count() == 0)
82  return true;
83 
84  // Fill items array to check
85  array<WorkshopItem> aRoomItems = new array<WorkshopItem>;
86 
87  foreach (Dependency dependency : dependencies)
88  {
89  WorkshopItem item = dependency.GetCachedItem();
90 
91  if (item)
92  aRoomItems.Insert(item);
93  }
94 
95  // Compare items
96  foreach (WorkshopItem item : aRoomItems)
97  {
98  int flags = item.GetStateFlags();
99 
100  if (flags & EWorkshopItemState.EWSTATE_OFFLINE)
101  {
102  if (flags & EWorkshopItemState.EWSTATE_OUTDATED)
103  return false;
104  }
105  else
106  return false;
107  }
108 
109  return true;
110  }
111 
112  //------------------------------------------------------------------------------------------------
113  // TODO@wernejak - setup this debug when needed data are ready
114  static void SetupDebug()
115  {
116  // Debug menu
117  /*DiagMenu.RegisterMenu(SCR_DebugMenuID.DEBUGUI_ADDONS_INFO, "Enabled addons", "Addons");
118  DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_ADDONS_INFO, "", "Show enabled addons list", "Enabled addons", false);*/
119 
120  //SCR_AddonManager.GetAllAddons();
121  }
122 
123  //------------------------------------------------------------------------------------------------
126  protected static bool ItemVersionMatch(SCR_WorkshopItem item)
127  {
128  // Check item
129  WorkshopItem wsItem = item.GetWorkshopItem();
130  if (!wsItem)
131  return false;
132 
133  // Dependency check
134  Dependency dependency = item.GetDependency();
135  if (!dependency)
136  return false;
137 
138  // Does active version match required?
139  return Revision.AreEqual(item.GetCurrentLocalRevision(), dependency.GetRevision());
140  }
141 };
142 
143 //------------------------------------------------------------------------------------------------
145 {
151 };
SCR_ModHandlerLib
Definition: SCR_ModsHandlerLib.c:7
ERoomModStates
ERoomModStates
Definition: SCR_ModsHandlerLib.c:144
SCR_WorkshopItem
Definition: SCR_WorkshopItem.c:21
MISSING
@ MISSING
Definition: SCR_ModsHandlerLib.c:146
BANNED
@ BANNED
Definition: SCR_ModsHandlerLib.c:150
CLIENT_REPORTED
@ CLIENT_REPORTED
Definition: SCR_ModsHandlerLib.c:149
LOCAL_VERSION_MATCH
@ LOCAL_VERSION_MATCH
Definition: SCR_ModsHandlerLib.c:147
LOCAL_VERSION_MISMATCH
@ LOCAL_VERSION_MISMATCH
Definition: SCR_ModsHandlerLib.c:148