Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
ResourceTestTool.c
Go to the documentation of this file.
1//----------------------------------------------
9
10[WorkbenchPluginAttribute("ResourceTest Plugin", "Opens resources and creates screenshots")]
11class ResourceTestPlugin: WorkbenchPlugin
12{
13
14/*
15 override void Run()
16 {
17 string ids = "{7297BDBDE223627F},{B90A1D47FB5036FA},{7C37800102FAC817}";
18 string directory = "$logs:ResourceTestTool";
19
20 array<string> resources = new array<string>;
21 ids.Split(",", resources, true);
22
23 MakeDirectory(directory);
24 foreach (string res: resources)
25 {
26 OpenResource(res, directory, 1000);
27 }
28
29 string summeryFilename = string.Format("%1/%2", directory, "summary.txt");
30 MakeSummeryFile(summeryFilename);
31 }
32*/
33
34 override void RunCommandline()
35 {
36 ResourceManager rb = Workbench.GetModule(ResourceManager);
37
38 int errorCode = 0;
39
40 string ids;
41 rb.GetCmdLine("-resources", ids);
42
43 string directory;
44 rb.GetCmdLine("-autotest-output-dir", directory);
45 if (directory.Length() == 0)
46 {
47 directory = "$logs:ResourceTestTool";
48 }
49
50 array<string> resources = new array<string>;
51 ids.Split(",", resources, true);
52
53 FileIO.MakeDirectory(directory);
54 foreach (ResourceName res: resources)
55 {
56 if (!OpenResource(res, directory, 1000))
57 {
58 errorCode = -1;
59 }
60 }
61
62 string summeryFilename = string.Format("%1/%2", directory, "summary.txt");
63 MakeSummeryFile(summeryFilename);
64
65 Workbench.Exit(errorCode);
66 }
67
68 bool OpenResource(ResourceName resourceName, string directory, int waitTime)
69 {
70 bool success = false;
71 Print("ResourceTestPlugin: opening resource "+ resourceName, LogLevel.VERBOSE);
72
73 ResourceManager rb = Workbench.GetModule(ResourceManager);
74
75 if (rb.SetOpenedResource(resourceName))
76 {
77 success = true;
78
79 string resourceFileName = FilePath.StripPath(resourceName.GetPath());
80
81 string screenshotFilename = string.Format("%1/%2.bmp", directory, resourceFileName);
82 string metadataFilename = screenshotFilename + ".txt";
83
84 if (waitTime > 0) Sleep(waitTime);
85
86 MakeScreenshotMetafile(metadataFilename, resourceName);
87 System.MakeScreenshot(screenshotFilename);
88
89 if (waitTime > 0) Sleep(waitTime);
90 }
91
92 if (success)
93 {
94 Print("ResourceTestPlugin: opened successfully! ", LogLevel.VERBOSE);
95 }
96 else
97 {
98 Print("ResourceTestPlugin: opening failed!", LogLevel.ERROR);
99 }
100
101 return success;
102 }
103
104 private void MakeSummeryFile(string filename)
105 {
106 FileHandle descrFile = FileIO.OpenFile(filename, FileMode.WRITE);
107
108 if(descrFile)
109 {
110 descrFile.WriteLine("Autotest: Resource opening in Workbench");
111 // TODO: would be nice to have a resolution here, but widget workspace needs game
112 descrFile.Close();
113 Print("Summary file successfully saved into " + filename);
114 }
115 }
116
117 private void MakeScreenshotMetafile(string filename, ResourceName resourceName)
118 {
119 FileHandle descrFile = FileIO.OpenFile(filename, FileMode.WRITE);
120
121 if(descrFile)
122 {
123 descrFile.WriteLine(string.Format("<p>FPS: %1</p>", System.GetFPS()));
124 descrFile.WriteLine(string.Format("<p>ResourceID: %1%2</p>" ,resourceName, resourceName.GetPath()));
125
126 string link = string.Format("enfusion://ResourceManager/%1", resourceName.GetPath());
127 descrFile.WriteLine(string.Format("<a href=\"%1\">Link to Resource Manager</a>", link));
128
129 descrFile.Close();
130 Print("Screenshot metafile successfully saved into " + filename);
131 }
132 }
133
134}
135
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
ref array< string > ids
ResourceName resourceName
Definition SCR_AIGroup.c:66
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
FileMode
Mode for opening file. See FileSystem::Open.
Definition FileMode.c:14