Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
AssetLibraryUtils.c
Go to the documentation of this file.
1class GetLoadedProjectsResponse : JsonApiStruct
2{
3 ref array<string> loadedProjects;
4
5 void GetLoadedProjectsResponse(array<string> projects)
6 {
7 this.loadedProjects = projects;
8 }
9
10 override void OnPack()
11 {
12 StartArray("Loaded Projects");
13 foreach (string item : loadedProjects)
14 {
15 ItemString(item);
16 }
17 EndArray();
18 }
19}
20
21static array<string> GetLoadedProjectsArray()
23 array<string> addons = new array<string>;
24 array<string> result = new array<string>();
25 //Get GUIDs of loaded addons
26 GameProject.GetLoadedAddons(addons);
27 string addonName, absPath;
28 //Go throught the addons
29 foreach (string addon : addons)
30 {
31 //ID from the GUID
32 addonName = GameProject.GetAddonID(addon);
33 //Find AbsPath to gproj
34 if(addonName != "core")
35 {
36 Workbench.GetAbsolutePath("$" + addonName + ":", absPath, false);
37 result.Insert(addonName);
38 }
39 }
40 return result;
41}
42
43class GetLoadedProjects : NetApiHandler
44{
45 override JsonApiStruct GetResponse(JsonApiStruct request)
46 {
48 }
49}
50
51//-------------------------------------------------------
52
54{
55 string path;
56
58 {
59 RegV("path");
60 }
61}
62
63class LocateProjectResponse : JsonApiStruct
64{
65 private string status;
66 private string message;
67 private string projectName;
68 private string projectPath;
69
70 void LocateProjectResponse(string _status, string _message, string _projectName, string _projectPath)
71 {
72 status = _status;
73 message = _message;
74 projectName = _projectName;
75 projectPath = _projectPath;
76 RegAll();
77 }
78}
79
80class LocateProject : NetApiHandler
81{
82 override JsonApiStruct GetRequest()
83 {
84 return new LocateProjectRequest();
85 }
86
88 {
90
91 array<string> loadedAddons = new array<string>;
92 GameProject.GetLoadedAddons(loadedAddons);
93
94 foreach (string addon : loadedAddons)
95 {
96 string addonName = GameProject.GetAddonID(addon);
97 string absPath;
98
99 Workbench.GetAbsolutePath("$" + addonName + ":", absPath, false);
100 if (absPath != "" && req.path.Contains(absPath))
101 {
102 return new LocateProjectResponse("OK", "", addonName, absPath);
103 }
104 }
105
106 return new LocateProjectResponse("ERROR", string.Format("Could not find active project in path \"%1\". Please select a different path.", req.path), "", "");
107 }
108}
109
110//-------------------------------------------------------
111
112class LocatePrefabsFromPathRequest : JsonApiStruct
113{
114 string selectedProject;
115 string projectPath;
116 string selectedFolder;
117
118 void LocatePrefabsFromPathRequest()
119 {
120 RegV("selectedProject");
121 RegV("projectPath");
122 RegV("selectedFolder");
123 }
124}
125
126class LocatePrefabsFromPathResponse : JsonApiStruct
127{
128 private string status;
129 private string message;
130 private ref array<string> prefabsPaths;
131
132 void LocatePrefabsFromPathResponse(string _status, string _message, array<string> paths)
133 {
134 status = _status;
135 message = _message;
136 prefabsPaths = paths;
137
138 RegV("status");
139 RegV("message");
140 RegV("prefabsPaths");
141 }
142}
143
144class LocatePrefabsFromPath : NetApiHandler
145{
146 override JsonApiStruct GetRequest()
147 {
148 return new LocatePrefabsFromPathRequest();
149 }
150
151 override JsonApiStruct GetResponse(JsonApiStruct request)
152 {
153 LocatePrefabsFromPathRequest req = LocatePrefabsFromPathRequest.Cast(request);
154 array<string> paths = {};
155
156 // get absolute path to the project
157 string projectAbsPath;
158 Workbench.GetAbsolutePath("$" + req.selectedProject + ":", projectAbsPath, false);
159 bool folderExists = false;
160 if (req.selectedFolder.Contains(req.projectPath))
161 {
162 string absPath = req.selectedFolder;
163 absPath.Replace("\\", "/");
164 FileIO.FindFiles(paths.Insert, absPath, ".et");
165 if (paths.Count() == 0)
166 {
167 string errorMessage = "Could not find any Prefabs! Does " + req.selectedFolder + " folder exist in your project? Does " + req.selectedFolder + " folder contain any prefabs?";
168 return LocatePrefabsFromPathResponse("ERROR", errorMessage, null);
169 }
170 }
171 else
172 {
173 string errorMessage = "Could not find any Prefabs! Does " + req.selectedFolder + " folder exist in your project? Does " + req.selectedFolder + " folder contain any prefabs?";
174 return LocatePrefabsFromPathResponse("ERROR", errorMessage, null);
175 }
176
177 int messageApproxSize;
178
179 foreach(string entry : paths)
180 {
181 messageApproxSize += entry.Length();
182 }
183
184 if (messageApproxSize > 500000)
185 {
186 string errorMessage = "Too many prefabs! (Approximate size " + (messageApproxSize/1000) + " kB, limit is 512 kB.) Please try importing a directory containing less prefabs.";
187 return LocatePrefabsFromPathResponse("ERROR", errorMessage, null);
188 }
189
190 return LocatePrefabsFromPathResponse("OK", "", paths);
191 }
192}
193
194//-------------------------------------------------------
195
196class GetPrefabGUIDRequest : JsonApiStruct
197{
198 string prefabPath;
199
200 void GetPrefabGUIDRequest()
201 {
202 RegV("prefabPath");
203 }
204}
205
206class GetPrefabGUIDResponse : JsonApiStruct
207{
208 private string status;
209 private string message;
210 private string guid;
211
212 void GetPrefabGUIDResponse(string _status, string _message, string _guid)
213 {
214 status = _status;
215 guid = _guid;
216 message = _message;
217
218 RegV("status");
219 RegV("message");
220 RegV("guid");
221 }
222}
223
224class GetPrefabGUID : NetApiHandler
225{
226 override JsonApiStruct GetRequest()
227 {
228 return new GetPrefabGUIDRequest();
229 }
230
231 override JsonApiStruct GetResponse(JsonApiStruct request)
232 {
233 GetPrefabGUIDRequest req = GetPrefabGUIDRequest.Cast(request);
234
235 ResourceManager rm = Workbench.GetModule(ResourceManager);
236 MetaFile meta = rm.GetMetaFile(req.prefabPath);
237
238 // check if meta exists
239 if (!meta)
240 {
241 return GetPrefabGUIDResponse("ERROR", "Meta file not found!", "");
242 }
243
244 // get data
245 string name = meta.GetResourceID();
246 string guid = name.Substring(name.IndexOf("{") + 1, name.IndexOf("}") - 1);
247
248 return GetPrefabGUIDResponse("OK", "GUID found.", guid);
249 }
250}
251
252//-------------------------------------------------------
253
254class GetPathToAssetsFromGuidsRequest : JsonApiStruct
255{
256 ref array<string> guids;
257
258 void GetPathToAssetsFromGuidsRequest()
259 {
260 RegV("guids");
261 }
262}
263
264class GetPathToAssetsFromGuidsResponse : JsonApiStruct
265{
266 ref array<ResourceName> prefabsPaths;
267 ref array<string> invalidGuids;
268
269 void GetPathToAssetsFromGuidsResponse(array<ResourceName> paths, array<string> _invalidGuids)
270 {
271 prefabsPaths = paths;
272 invalidGuids = _invalidGuids;
273
274 RegV("prefabsPaths");
275 RegV("invalidGuids");
276 }
277}
278
279class GetPathToAssetsFromGuids : NetApiHandler
280{
281 override JsonApiStruct GetRequest()
282 {
283 return new GetPathToAssetsFromGuidsRequest();
284 }
285
286 override JsonApiStruct GetResponse(JsonApiStruct request)
287 {
288 GetPathToAssetsFromGuidsRequest req = GetPathToAssetsFromGuidsRequest.Cast(request);
289 array<ResourceName> paths = {};
290 array<string> invalidGuids = {};
291
292 foreach (string guid : req.guids)
293 {
294 ResourceName guidRes = "{" + guid + "}";
295 ResourceName abs;
296
297 if (Workbench.GetAbsolutePath(guidRes.GetPath(), abs, true))
298 {
299 if (abs.Contains(".et"))
300 {
301 paths.Insert(abs);
302 }
303 else
304 {
305 invalidGuids.Insert(guid);
306 }
307 }
308 }
309
310 return GetPathToAssetsFromGuidsResponse(paths, invalidGuids);
311 }
312}
string path
override JsonApiStruct GetResponse(JsonApiStruct request)
void GetLoadedProjectsResponse(array< string > projects)
GetLoadedProjectsResponse JsonApiStruct GetLoadedProjectsArray()
LocateProjectResponse JsonApiStruct GetRequest()
void LocateProjectRequest()
override void OnPack()
SCR_AICombatMoveRequestBase GetRequest()
base classes for filtering in server browser