Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_WorldDataExportTool.c
Go to the documentation of this file.
1#ifdef WORKBENCH
2enum SCR_EMapDataExportType
3{
4 GEOMETRY_2D,
6 RASTERIZATION
7}
8
12
13//------------------------------------------------------------------------------------------------
14[WorkbenchToolAttribute("Export Map data", "Export data of various types from the current world", "", awesomeFontCode: 0xF0AC)]
15class SCR_WorldMapExportTool : WorldEditorTool
16{
17 /*
18 Category: Export File
19 */
20
21 [Attribute(desc: "Folder where the file will be saved", params: "unregFolders", category: "Export File")]
22 protected ResourceName m_sDestinationPath;
23
24 [Attribute("0", UIWidgets.ComboBox, "Export type", enumType: SCR_EMapDataExportType, category: "Export File")]
25 protected SCR_EMapDataExportType m_eType;
26
27 /*
28 Category: Geometry 2D
29 */
30
31 [Attribute("1", UIWidgets.CheckBox, "Generation of Roads' data", category: "Geometry 2D")]
32 protected bool m_bGenerateRoads;
33
34 [Attribute("1", UIWidgets.CheckBox, "Save Roads' data to exported file", category: "Geometry 2D")]
35 protected bool m_bSaveRoads;
36
37 [Attribute("1", UIWidgets.CheckBox, "Generation of Powerlines' data", category: "Geometry 2D")]
38 protected bool m_bGeneratePowerLines;
39
40 [Attribute("1", UIWidgets.CheckBox, "Save Powerlines' data to exported file", category: "Geometry 2D")]
41 protected bool m_bSavePowerLines;
42
43 [Attribute("1", UIWidgets.CheckBox, "Generation of Buildings' data", category: "Geometry 2D")]
44 protected bool m_bGenerateBuildings;
45
46 [Attribute("1", UIWidgets.CheckBox, "Save Buildings' data to exported file", category: "Geometry 2D")]
47 protected bool m_bSaveBuildings;
48
49 [Attribute("1", UIWidgets.CheckBox, "Generation of Areas' data", category: "Geometry 2D")]
50 protected bool m_bGenerateAreas;
51
52 [Attribute("1", UIWidgets.CheckBox, "Ignore Generator entities during generation", category: "Geometry 2D")]
53 protected bool m_bIgnoreGeneratorAreas;
54
55 [Attribute("1", UIWidgets.CheckBox, "Save Areas' data to exported file", category: "Geometry 2D")]
56 protected bool m_bSaveAreas;
57
58 [Attribute("1", UIWidgets.CheckBox, "Generation of Water Bodies' data", category: "Geometry 2D")]
59 protected bool m_bGenerateWaterBodies;
60
61 [Attribute("1", UIWidgets.CheckBox, "Save Water Bodies' data to exported file", category: "Geometry 2D")]
62 protected bool m_bSaveWaterBodies;
63
64 [Attribute("1", UIWidgets.CheckBox, "Generation of Hills' data", category: "Geometry 2D")]
65 protected bool m_bGenerateHills;
66
67 [Attribute("50.0", UIWidgets.Slider, "Minimum hill height", "30 155 5", category: "Geometry 2D")]
68 protected float m_fHillMinimumHeight;
69
70 [Attribute("1", UIWidgets.CheckBox, "Save Hills' data to exported file", category: "Geometry 2D")]
71 protected bool m_bSaveHills;
72
73 /*
74 Category: Rasterization
75 */
76
77 [Attribute("1.0 1.0 1.0 1.0", UIWidgets.ColorPicker, "Land color Bright", category: "Rasterization")]
78 protected ref Color m_LandColorBright;
79
80 [Attribute("0.5 0.5 0.5 1.0", UIWidgets.ColorPicker, "Land color Dark", category: "Rasterization")]
81 protected ref Color m_LandColorDark;
82
83 [Attribute("0.863 0.980 1.0 1.0", UIWidgets.ColorPicker, "Ocean color Bright", category: "Rasterization")]
84 protected ref Color m_OceanColorBright;
85
86 [Attribute("0.757 0.91 0.929 1.0", UIWidgets.ColorPicker, "Ocean color Dark", category: "Rasterization")]
87 protected ref Color m_OceanColorDark;
88
89 [Attribute("2.5", UIWidgets.Slider, "Land scale factor", "0 10 0.1", category: "Rasterization")]
90 protected float m_fLandScale;
91
92 [Attribute("1.2", UIWidgets.Slider, "Ocean scale factor", "0 10 0.1", category: "Rasterization")]
93 protected float m_fOceanScale;
94
95 [Attribute("500.0", UIWidgets.Slider, "Height scale factor", "-1000 1000 1.0", category: "Rasterization")]
96 protected float m_fHeightScale;
97
98 [Attribute("60.0", UIWidgets.Slider, "Depth scale factor", "-1000 1000 1.0", category: "Rasterization")]
99 protected float m_fDepthScale;
100
101 [Attribute("-50.0", UIWidgets.Slider, "Depth Lerp meters", "-1000 1000 1.0", category: "Rasterization")]
102 protected float m_fDepthLerpMeters;
103
104 [Attribute("0.5", UIWidgets.Slider, "Shade intensity factor", "0.5 15 0.01", category: "Rasterization")]
105 protected float m_fShadeIntensity;
106
107 [Attribute("1.8", UIWidgets.Slider, "Height intensity factor", "0.5 15 0.01", category: "Rasterization")]
108 protected float m_fHeightIntensity;
109
110 [Attribute("1", UIWidgets.CheckBox, "Include Areas defined by Generators", category: "Rasterization")]
111 protected bool m_bIncludeGeneratorAreas;
112
113 [Attribute("0.608 0.784 0.529 1.0", UIWidgets.ColorPicker, "Forest area color", category: "Rasterization")]
114 protected ref Color m_ForestAreaColor;
115
116 [Attribute("1.25", UIWidgets.Slider, "Forest area intensity factor", "0.5 15 0.01", category: "Rasterization")]
117 protected float forestAreaIntensity;
118
119 [Attribute("0.745 0.745 0.745 1.0", UIWidgets.ColorPicker, "Other area color", category: "Rasterization")]
120 protected ref Color m_OtherAreaColor;
121
122 [Attribute("1.0", UIWidgets.Slider, "Other area intensity factor", "0.5 15 0.01", category: "Rasterization")]
123 protected float m_fOtherAreaIntensity;
124
125 protected ref MapDataExporter m_DataExporter = new MapDataExporter();
126
127 //------------------------------------------------------------------------------------------------
128 [ButtonAttribute("Export")]
129 protected void Execute()
130 {
131 Export();
132 }
133
134 //------------------------------------------------------------------------------------------------
137 static string GetReportMessage(DataExportErrorType errorCode)
138 {
139 switch (errorCode)
140 {
141 case DataExportErrorType.DataExportErrorNoGame: return "Game not found";
142 case DataExportErrorType.DataExportErrorNoDataType: return "Data type not found";
143 case DataExportErrorType.DataExportErrorNoMapEntity: return "Map Entity not found";
144 case DataExportErrorType.DataExportErrorNoWorld: return "World not found";
145 case DataExportErrorType.DataExportErrorNoWorldPath: return "World path empty";
146 case DataExportErrorType.DataExportErrorNoOutputFile: return "Could not open output file";
147 case DataExportErrorType.DataExportErrorNoCompatibleWorld: return "World is not compatible";
148 case DataExportErrorType.DataExportErrorNoSoundWorld: return "Sound World not found";
149 case DataExportErrorType.DataExportErrorNotSavingToFile: return "Not saving to file, Default Map created";
150 case DataExportErrorType.DataExportErrorInvalidSoundmap: return "Invalid Soundmap";
151 case DataExportErrorType.DataExportErrorNoLandOrOcean: return "No Land or Ocean color found";
152 case DataExportErrorType.DataExportErrorNoTerrain: return "Terrain not found";
153 }
154
155 return "Unknown, code=" + errorCode;
156 }
157
158 //------------------------------------------------------------------------------------------------
159 // Export
160 protected bool Export()
161 {
162 WorldEditor worldEditor = Workbench.GetModule(WorldEditor);
163 WorldEditorAPI worldEditorAPI = worldEditor.GetApi();
164 string worldPath;
165 worldEditorAPI.GetWorldPath(worldPath);
166
167 WBProgressDialog progress = new WBProgressDialog("Processing", worldEditor);
168
169 string exportPath = m_sDestinationPath.GetPath();
170
171 if (m_eType == SCR_EMapDataExportType.GEOMETRY_2D)
172 {
173 Print("Exporting map 2D map data...", LogLevel.NORMAL);
174 ExcludeGenerateFlags generateFlags = ExcludeGenerateFlags.ExcludeGenerateNone;
175 if (!m_bGenerateRoads)
176 generateFlags = generateFlags | ExcludeGenerateFlags.ExcludeGenerateRoads;
177
178 if (!m_bGeneratePowerLines)
179 generateFlags = generateFlags | ExcludeGenerateFlags.ExcludeGeneratePowerlines;
180
181 if (!m_bGenerateBuildings)
182 generateFlags = generateFlags | ExcludeGenerateFlags.ExcludeGenerateBuildings;
183
184 if (!m_bGenerateAreas)
185 generateFlags = generateFlags | ExcludeGenerateFlags.ExcludeGenerateAreas;
186
187 if (!m_bGenerateWaterBodies)
188 generateFlags = generateFlags | ExcludeGenerateFlags.ExcludeGenerateWaterBodies;
189
190 if (!m_bGenerateHills)
191 generateFlags = generateFlags | ExcludeGenerateFlags.ExcludeGenerateHills;
192
193 ExcludeSaveFlags saveFlags = ExcludeSaveFlags.ExcludeSaveNone;
194 if (!m_bSaveRoads)
195 saveFlags = saveFlags | ExcludeSaveFlags.ExcludeSaveRoads;
196
197 if (!m_bSavePowerLines)
198 saveFlags = saveFlags | ExcludeSaveFlags.ExcludeSavePowerlines;
199
200 if (!m_bSaveBuildings)
201 saveFlags = saveFlags | ExcludeSaveFlags.ExcludeSaveBuildings;
202
203 if (!m_bSaveAreas)
204 saveFlags = saveFlags | ExcludeSaveFlags.ExcludeSaveAreas;
205
206 if (!m_bSaveWaterBodies)
207 saveFlags = saveFlags | ExcludeSaveFlags.ExcludeSaveWaterBodies;
208
209 if (!m_bSaveHills)
210 saveFlags = saveFlags | ExcludeSaveFlags.ExcludeSaveHills;
211
212 DataExportErrorType result = m_DataExporter.ExportData(EMapDataType.Geometry2D, exportPath, worldPath, m_fHillMinimumHeight, m_bIgnoreGeneratorAreas, generateFlags, saveFlags);
213 if (result != DataExportErrorType.DataExportErrorNone)
214 {
215 string reason = GetReportMessage(result);
216 Print(string.Format("Could not export 2D map data. (%1)", reason), LogLevel.ERROR);
217 return false;
218 }
219 }
220 else if (m_eType == SCR_EMapDataExportType.SOUNDMAP)
221 {
222 Print("Exporting Soundmap...", LogLevel.NORMAL);
223 DataExportErrorType result = m_DataExporter.ExportData(EMapDataType.Soundmap, exportPath, worldPath);
224 if (result != DataExportErrorType.DataExportErrorNone)
225 {
226 string reason = GetReportMessage(result);
227 Print(string.Format("Could not export Soundmap data. (%1)", reason), LogLevel.ERROR);
228 return false;
229 }
230 }
231 else if (m_eType == SCR_EMapDataExportType.RASTERIZATION)
232 {
233 Print("Exporting map rasterization...", LogLevel.NORMAL);
234 DataExportErrorType result = m_DataExporter.SetupColors(m_LandColorBright, m_LandColorDark, m_OceanColorBright, m_OceanColorDark, m_ForestAreaColor, m_OtherAreaColor);
235 if (result == DataExportErrorType.DataExportErrorNone)
236 result = m_DataExporter.ExportRasterization(exportPath, worldPath, m_fLandScale, m_fOceanScale, m_fHeightScale, m_fDepthScale, m_fDepthLerpMeters, m_fShadeIntensity, m_fHeightIntensity, m_bIncludeGeneratorAreas, forestAreaIntensity, m_fOtherAreaIntensity);
237
238 if (result != DataExportErrorType.DataExportErrorNone)
239 {
240 string reason = GetReportMessage(result);
241 Print(string.Format("Could not export map rasterization. (%1)", reason), LogLevel.ERROR);
242 return false;
243 }
244 }
245
246 return true;
247 }
248}
249
250[WorkbenchPluginAttribute("World Data Export Plugin", "Open world and export defined data type")]
251class WorldDataExport : WorkbenchPlugin // TODO: SCR_WorldDataExportPlugin
252{
253 //------------------------------------------------------------------------------------------------
254 // CLI arguments
255 override void RunCommandline()
256 {
257 ResourceManager rb = Workbench.GetModule(ResourceManager);
258 string path;
259 rb.GetCmdLine("-world", path);
260 string type;
261 rb.GetCmdLine("-type", type);
262 string dir;
263 rb.GetCmdLine("-saveDir", dir);
264
265 ExcludeGenerateFlags generateflags = ExcludeGenerateFlags.ExcludeGenerateNone;
266 ExcludeSaveFlags saveFlags = ExcludeSaveFlags.ExcludeSaveNone;
267 string tmp;
268 if (rb.GetCmdLine("-excludehills", tmp))
269 {
270 generateflags = generateflags | ExcludeGenerateFlags.ExcludeGenerateHills;
271 saveFlags = saveFlags | ExcludeSaveFlags.ExcludeSaveHills;
272 }
273
274 if (ExportWorldData(path, type, dir, generateflags, saveFlags))
275 Workbench.Exit(0);
276 else
277 Workbench.Exit(-1);
278 }
279
280 //------------------------------------------------------------------------------------------------
281 // Export
282 protected bool ExportWorldData(string path, string type, string dir, ExcludeGenerateFlags excludeFlags, ExcludeSaveFlags saveFlags)
283 {
284 Print("WorldDataExport: opening world " + path, LogLevel.VERBOSE);
285
286 Workbench.OpenModule(WorldEditor);
287 WorldEditor worldEditor = Workbench.GetModule(WorldEditor);
288 if (!worldEditor.SetOpenedResource(path))
289 return false;
290
291 Sleep(300);
292
293 bool success = true;
294 bool exportMap = true;
295 bool exportSound = true;
296 bool exportRasterization = true;
297 if (!type.IsEmpty())
298 {
299 if (type.StartsWith("2DMap"))
300 {
301 exportSound = false;
302 exportRasterization = false;
303 }
304 else if (type.StartsWith("SoundMap"))
305 {
306 exportMap = false;
307 exportRasterization = false;
308 }
309 else if (type.StartsWith("2DRasterization"))
310 {
311 exportSound = false;
312 exportMap = false;
313 }
314 }
315
316 WorldEditorAPI worldEditorAPI = worldEditor.GetApi();
317 string worldPath;
318 worldEditorAPI.GetWorldPath(worldPath);
319
320 MapDataExporter mapDataExporter = new MapDataExporter();
321
322 WBProgressDialog progress = new WBProgressDialog("Processing", worldEditor);
323 if (exportMap)
324 {
325 Print("Exporting map 2D map data...", LogLevel.NORMAL);
326 DataExportErrorType result = mapDataExporter.ExportData(EMapDataType.Geometry2D, dir, worldPath, 50, true, excludeFlags, saveFlags);
327 if (result != DataExportErrorType.DataExportErrorNone)
328 {
329 string reason = SCR_WorldMapExportTool.GetReportMessage(result);
330 Print(string.Format("Could not export 2D map data. (%1)", reason), LogLevel.ERROR);
331 success = false;
332 }
333 }
334
335 if (exportSound)
336 {
337 Print("Exporting Soundmap...", LogLevel.NORMAL);
338 DataExportErrorType result = mapDataExporter.ExportData(EMapDataType.Soundmap, dir, worldPath);
339 if (result != DataExportErrorType.DataExportErrorNone)
340 {
341 string reason = SCR_WorldMapExportTool.GetReportMessage(result);
342 Print(string.Format("Could not export Soundmap data. (%1)", reason), LogLevel.ERROR);
343 success = false;
344 }
345 }
346
347 if (exportRasterization)
348 {
349 Print("Exporting map rasterization...", LogLevel.NORMAL);
350 //TODO: change to user defined values (along with WorldMapExportTool)
351 const Color landColorBright = new Color(1.0, 1.0, 1.0, 1.0);
352 const Color landColorDark = new Color(0.5, 0.5, 0.5, 1.0);
353 const Color oceanColorBright = new Color(0.863, 0.980, 1.0, 1.0);
354 const Color oceanColorDark = new Color(0.757, 0.91, 0.929, 1.0);
355 const float landScale = 2.5;
356 const float oceanScale = 1.2;
357 const float heightScale = 500.0;
358 const float depthScale = 60.0;
359 const float depthLerpMeters = -50.0;
360 const float shadeIntensity = 0.5;
361 const float heightIntensity = 1.8;
362 const bool includeGeneratorAreas = true;
363 const Color forestAreaColor = new Color(0.608, 0.784, 0.529, 1.0);
364 const float forestAreaIntensity = 1.25;
365 const Color otherAreaColor = new Color(0.745, 0.745, 0.745, 1.0);
366 const float otherAreaIntensity = 1.0;
367
368 DataExportErrorType result = mapDataExporter.SetupColors(landColorBright, landColorDark, oceanColorBright, oceanColorDark, forestAreaColor, otherAreaColor);
369 if (result == DataExportErrorType.DataExportErrorNone)
370 result = mapDataExporter.ExportRasterization(dir, worldPath, landScale, oceanScale, heightScale, depthScale, depthLerpMeters, shadeIntensity, heightIntensity, includeGeneratorAreas, forestAreaIntensity, otherAreaIntensity);
371
372 if (result != DataExportErrorType.DataExportErrorNone)
373 {
374 string reason = SCR_WorldMapExportTool.GetReportMessage(result);
375 Print(string.Format("Could not export map rasterization. (%1)", reason), LogLevel.ERROR);
376 success = false;
377 }
378 }
379
380 if (success)
381 Print("WorldDataExport: export successful!", LogLevel.VERBOSE);
382
383 Sleep(100);
384 worldEditor.Close();
385
386 return success;
387 }
388}
389#endif // WORKBENCH
string path
DataExportErrorType
ExcludeGenerateFlags
ExcludeSaveFlags
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
bool Execute(notnull SCR_AIGroupUtilityComponent groupUtility, vector targetPosition, SCR_AIActivitySmokeCoverFeatureProperties smokeCoverProperties, notnull array< AIAgent > avoidAgents, notnull array< AIAgent > excludeAgents, int maxPositionCount=1, SCR_AIActivityBase contextActivity=null)
SCR_ECampaignBaseType m_eType
EDamageType type
SOUNDMAP
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
class WorkbenchDialog_AbortRetryIgnore ButtonAttribute("OK", true)
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
SCR_FieldOfViewSettings Attribute
EMapDataType