Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_WorldSetupPlugin_GenericWorldEntity.c
Go to the documentation of this file.
1#ifdef WORKBENCH
5 name: "[Experimental] World Entity Setup (LOAD the world after this, do NOT save!)",
6 category: "World Setup",
7 description: "Set up GenericWorldEntity's Prefab",
8 shortcut: "", // "Ctrl+Shift+N", // for new content?
9 wbModules: { "WorldEditor" },
10 awesomeFontCode: 0xF0AC)]
11class SCR_WorldSetupPlugin_GenericWorldEntity : SCR_WorldSetupPluginBasePlugin
12{
13 [Attribute(desc: "The World Entity Prefab to be used for this world", uiwidget: UIWidgets.ResourceNamePicker, params: "et class=GenericWorldEntity", defvalue: "{08A95D735ECC517F}Prefabs/World/DefaultWorld/GenericWorld_Default.et")]
14 protected ResourceName m_sWorldEntityPrefab;
15
16 [Attribute(defvalue: "0", desc: "Create Prefab's child from the provided one in the selected addon and use it instead of using the provided Prefab directly")]
17 protected bool m_bCopyPrefabToAddon;
18
19 [Attribute(/* defvalue: SCR_ParamEnumArray.FromAddons(titleFormat: 2, hideCoreModules: 2)[0].m_Value, */uiwidget: UIWidgets.ComboBox, desc: "Addon in which the Prefab will be copied (if copied)", enums: SCR_ParamEnumArray.FromAddons(titleFormat: 2, hideCoreModules: 2))]
20 protected int m_iAddon;
21
22 protected static const string CHILD_PREFAB = "%1_%2"; // %1 = parent Prefab filename, %2 = world name
23 protected static const string LAYERS_DIR = "%1_Layers"; // %1 = world name
24 protected static const string DEFAULT_LAYER = "default.layer";
25 // protected static const string WORLD_ENTITY_CLASS = ((typename)GenericWorldEntity).ToString();
26 protected static const string WORLD_ENTITY_CLASS = "GenericWorldEntity";
27
28 //------------------------------------------------------------------------------------------------
29 override void Run()
30 {
31 if (!Workbench.ScriptDialog("World Setup (WorldEntity)", "This plugin replaces the current WorldEntity (generic entity or Prefab) by the provided Prefab.", this))
32 return;
33
34 ResourceName worldEntityPrefab = m_sWorldEntityPrefab;
35
36 if (worldEntityPrefab.IsEmpty())
37 {
38 Print("No World Entity Prefab provided", LogLevel.WARNING);
39 return;
40 }
41
42 WorldEditorAPI worldEditorAPI = SCR_WorldEditorToolHelper.GetWorldEditorAPI();
43 if (!worldEditorAPI)
44 {
45 Print("World Editor API is not available", LogLevel.WARNING);
46 return;
47 }
48
49 string worldPath;
50 worldEditorAPI.GetWorldPath(worldPath);
51 string worldName = FilePath.StripExtension(FilePath.StripPath(worldPath));
52
53 // duplicate the Prefab
54 if (m_bCopyPrefabToAddon)
55 worldEntityPrefab = CreatePrefabChildInAddon(worldEntityPrefab, m_iAddon, worldName);
56
57 if (worldEntityPrefab.IsEmpty())
58 {
59 Print("Child Prefab could not be created", LogLevel.WARNING);
60 return;
61 }
62
63 if (SCR_WorldFilesHelper.ReplaceWorldEntity(worldPath, worldEntityPrefab))
64 Print("File written successfully. Please LOAD the world to see the changes applied", LogLevel.NORMAL);
65 else
66 Print("File could not be written", LogLevel.WARNING);
67 }
68
69 //------------------------------------------------------------------------------------------------
74 protected string GetDefaultLayerAbsoluteFilePath(string worldPath, string worldName)
75 {
76 string defaultLayerAbsFilePath;
77 if (!Workbench.GetAbsolutePath(worldPath, defaultLayerAbsFilePath))
78 {
79 Print("Could not get absolute path for " + worldPath, LogLevel.WARNING);
80 return string.Empty;
81 }
82
83 string layerAbsDir = FilePath.StripFileName(defaultLayerAbsFilePath);
84 if (!layerAbsDir.EndsWith("/"))
85 layerAbsDir += "/";
86
87 return layerAbsDir + string.Format(LAYERS_DIR, worldName) + "/" + DEFAULT_LAYER;
88 }
89
90 //------------------------------------------------------------------------------------------------
91 [ButtonAttribute("OK", true)]
92 protected bool ButtonOK()
93 {
94 return true;
95 }
96
97 //------------------------------------------------------------------------------------------------
98 [ButtonAttribute("Cancel")]
99 protected bool ButtonCancel()
100 {
101 return false;
102 }
103}
104#endif // WORKBENCH
GenerateFlowMaps WorkbenchPlugin WorkbenchPluginAttribute("Regenerate river flow-maps", "Generate and save/overwrite river flow-maps", "", "", {"WorldEditor"}, "", 0xf773)
Definition FlowmapTool.c:59
override void Run()
bool ButtonCancel()
bool ButtonOK()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
class WorkbenchDialog_AbortRetryIgnore ButtonAttribute("OK", true)
static ParamEnumArray FromAddons(int titleFormat=2, int hideCoreModules=0)
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