Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
WorldTestTool.c
Go to the documentation of this file.
1[WorkbenchPluginAttribute("WorldTest Plugin", "Open Map and run game mode")]
2class WorldTestPlugin: WorkbenchPlugin
3{
4
5 override void RunCommandline()
6 {
7 ResourceManager rb = Workbench.GetModule(ResourceManager);
8 string path;
9 rb.GetCmdLine("-world", path);
10
11 string wait;
12 rb.GetCmdLine("-wait", wait); // if wait param is specified then plugin waits provided amount of seconds before exiting back to edit mode. If value is <0 then plugin will wait for the game to switch back using Game().RequestClose().
13 int waitTime = 1000;
14 if (wait)
15 {
16 waitTime = wait.ToInt();
17 }
18
19 if (TestMap(path, waitTime))
20 {
21 Workbench.Exit(0);
22 }
23 else
24 {
25 Workbench.Exit(-1);
26 }
27 }
28
29 bool WaitForGameMode(WorldEditor we, int timeout = 120000)
30 {
31 while (we.GetApi() && !we.GetApi().IsGameMode())
32 {
33 Sleep(50);
34 timeout -= 50;
35 if (timeout < 0)
36 return false;
37 }
38
39 if (we.GetApi() == null)
40 return false;
41 return true;
42 }
43
44 bool TestMap(string path, int waitTime)
45 {
46 bool success = false;
47 Print("WorldTestPlugin: opening map "+ path, LogLevel.VERBOSE);
48
49 Workbench.OpenModule(WorldEditor);
50 WorldEditor we = Workbench.GetModule(WorldEditor);
51
52 if (we.SetOpenedResource(path))
53 {
54 Sleep(300);
55 Print("WorldTestPlugin: running game mode", LogLevel.VERBOSE);
56
57 we.SwitchToGameMode(false, true);
58 WaitForGameMode(we);
59
60 if (waitTime < 0)
61 {
62 while (we.GetApi().IsGameMode())
63 {
64 Sleep(1000);
65 }
66 }
67 else
68 {
69 Sleep(waitTime);
70 we.SwitchToEditMode();
71 }
72 Print("WorldTestPlugin: closing game mode", LogLevel.VERBOSE);
73 success = true;
74 Sleep(100);
75
76 we.Close();
77 }
78
79 if (success)
80 {
81 Print("WorldTestPlugin: test successful!", LogLevel.VERBOSE);
82 }
83 else
84 {
85 Print("WorldTestPlugin: test failed!", LogLevel.ERROR);
86 }
87
88 return success;
89 }
90}
91
string path
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
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