Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
ResaveMetaTool.c
Go to the documentation of this file.
1[WorkbenchPluginAttribute("Re-Save Meta Tool", "Saves all meta files with given extension", "", "", {"ResourceManager"},"",0xf0c7)]
2class ResaveMetaPlugin: WorkbenchPlugin
3{
4 [Attribute(uiwidget: UIWidgets.FileNamePicker, desc: "Root directory to search", params:"unregFolders" )]
5 string RootPath;
6
7 [Attribute(uiwidget: UIWidgets.EditBox, desc: "File extensions (without .meta)" )]
8 ref array<string> Extensions;
9
10 ResourceManager m_module;
11 ref array<string> m_files = {};
12
13 void Find(ResourceName resName, string file)
14 {
15 m_files.Insert(file);
16 }
17
18 void Resave()
19 {
20 WBProgressDialog progress = new WBProgressDialog("Resaving...", m_module);
21 int cnt = m_files.Count();
22 foreach (int i, string file: m_files)
23 {
24 MetaFile mf = m_module.GetMetaFile(file);
25 if (mf)
26 {
27 mf.Save();
28 mf.Release();
29 }
30
31 progress.SetProgress(i / cnt);
32 }
33 m_files.Clear();
34 }
35
36 override void Run()
37 {
38 if (Workbench.ScriptDialog("Resave", "Which files metafiles you want to resave?", this))
39 {
40 m_module = Workbench.GetModule(ResourceManager);
41
43 filter.rootPath = RootPath;
44 filter.fileExtensions = Extensions;
45 ResourceDatabase.SearchResources(filter, Find);
46
47 Resave();
48 }
49 }
50
51 override void RunCommandline()
52 {
53 m_module = Workbench.GetModule(ResourceManager);
55
56 string addonPathCli;
57 if (m_module.GetCmdLine("-addonPath", addonPathCli))
58 {
59 if (!FilePath.IsAbsolutePath(addonPathCli))
60 {
61 PrintFormat("Argument 'addonPath' must be an absolute path, but its value is '%1'", addonPathCli, level: LogLevel.ERROR);
62 Workbench.Exit(1);
63 return;
64 }
65
66 string addonGuid, addonId, addonExactRoot;
67 bool found = AddonBuildInfoTool.FindAddonByAbsolutePath(
68 addonPathCli, addonGuid, addonId, addonExactRoot
69 );
70 if (found)
71 filter.rootPath = addonExactRoot;
72 }
73
74 string ext;
75 if (m_module.GetCmdLine("-extension", ext))
76 {
77 ext.Replace("\"", "");
78 ext.Replace(".", "");
79 Extensions = {ext};
80 }
81
82 filter.fileExtensions = Extensions;
83 ResourceDatabase.SearchResources(filter, Find);
84
85 Resave();
86 Workbench.Exit(0);
87 }
88
89 [ButtonAttribute("Re-Save")]
90 bool OK()
91 {
92 return true;
93 }
94
95 [ButtonAttribute("Cancel")]
96 bool Cancel()
97 {
98 return false;
99 }
100}
override void RunCommandline()
Definition FlowmapTool.c:60
GenerateFlowMaps WorkbenchPlugin WorkbenchPluginAttribute("Regenerate river flow-maps", "Generate and save/overwrite river flow-maps", "", "", {"WorldEditor"}, "", 0xf773)
Definition FlowmapTool.c:59
override void Run()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
SCR_RespawnComponentClass OK
Result code for request/assign response.
Definition EMoveError.c:14
class WorkbenchDialog_AbortRetryIgnore ButtonAttribute("OK", true)
Object used for holding filtering params for ResourceDatabase.SearchResources() method.
Definition System.c:9
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
SCR_FieldOfViewSettings Attribute
proto int Find(T value)