Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
ResaveTool.c
Go to the documentation of this file.
1[WorkbenchPluginAttribute("Re-Save Tool", "Saves all files with given extension", "", "", {"ResourceManager"},"",0xf0c7)]
2class ResavePlugin: 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" )]
8 ref array<string> Extensions;
9
10 ref array<ResourceName> m_files = new array<ResourceName>;
11
12 void Find(ResourceName resName)
13 {
14 m_files.Insert(resName);
15 }
16
17 void Resave()
18 {
19 WBProgressDialog progress = new WBProgressDialog("Resaving...", null);
20 ResourceManager rm = Workbench.GetModule(ResourceManager);
21 int cnt = m_files.Count();
22
23 foreach (int i, ResourceName file: m_files)
24 {
25 Print("Resaving: " + file);
26 Resource res = BaseContainerTools.LoadContainer(file);
27 if (res && res.IsValid())
28 {
29 BaseContainer cont = res.GetResource().ToBaseContainer();
30 BaseContainerTools.SaveContainer(cont, file);
31 }
32 else
33 {
34 rm.RebuildResourceFile(file.GetPath(), "PC", false);
35 }
36
37 progress.SetProgress(i / cnt);
38 }
39 m_files.Clear();
40 }
41
42 override void Run()
43 {
44 if (Workbench.ScriptDialog("Resave", "Which files you want to resave?", this))
45 {
47 filter.rootPath = RootPath;
48 filter.fileExtensions = Extensions;
49 ResourceDatabase.SearchResources(filter, Find);
50
51 Resave();
52 }
53 }
54
55 override void RunCommandline()
56 {
57 ResourceManager module = Workbench.GetModule(ResourceManager);
59
60 string addonPathCli;
61 if (module.GetCmdLine("-addonPath", addonPathCli))
62 {
63 if (!FilePath.IsAbsolutePath(addonPathCli))
64 {
65 PrintFormat("Argument 'addonPath' must be an absolute path, but its value is '%1'", addonPathCli, level: LogLevel.ERROR);
66 Workbench.Exit(1);
67 return;
68 }
69
70 string addonGuid, addonId, addonExactRoot;
71 bool found = AddonBuildInfoTool.FindAddonByAbsolutePath(
72 addonPathCli, addonGuid, addonId, addonExactRoot
73 );
74 if (found)
75 filter.rootPath = addonExactRoot;
76 }
77
78 string ext;
79 if (module.GetCmdLine("-extension", ext))
80 {
81 ext.Replace("\"", "");
82 ext.Replace(".", "");
83 Extensions = {ext};
84 }
85
86 filter.fileExtensions = Extensions;
87 ResourceDatabase.SearchResources(filter, Find);
88
89 Resave();
90 Workbench.Exit(0);
91 }
92
93 [ButtonAttribute("Re-Save")]
94 bool OK()
95 {
96 return true;
97 }
98
99 [ButtonAttribute("Cancel")]
100 bool Cancel()
101 {
102 return false;
103 }
104}
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 holding reference to resource. In destructor release the resource.
Definition Resource.c:25
Object used for holding filtering params for ResourceDatabase.SearchResources() method.
Definition System.c:9
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
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)