Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_PrefabStructureCreationPlugin.c
Go to the documentation of this file.
1#ifdef WORKBENCH
3 name: "Prefab Structure Creation",
4 description: "Create Prefab structure according to config",
5 category: "Prefab Structure",
6 wbModules: { "WorldEditor" },
7 awesomeFontCode: 0xF6BE)]
8class SCR_PrefabStructureCreationPlugin : WorkbenchPlugin
9{
10 [Attribute(defvalue: "0", desc: "In which addon this structure is to be created", uiwidget: UIWidgets.ComboBox, enums: SCR_ParamEnumArray.FromAddons())]
11 protected int m_iAddon;
12
13// [Attribute()]
14 protected ref SCR_PrefabHelper_Structure m_ConfigType;
15
16 [Attribute(defvalue: "{009E0970F762CC4E}Configs/Workbench/PrefabStructureCreationPlugin/CarPrefabStructure.conf", params: "conf class=SCR_PrefabHelper_Structure")]
17 protected ResourceName m_sStructureToCreate;
18
19 [Attribute(defvalue: "", desc: "Project Name (e.g S105) - allowed characters: " + ALLOWED_CHARACTERS)]
20 string m_sProjectName;
21
22 protected static const string ALLOWED_CHARACTERS = SCR_StringHelper.LETTERS + SCR_StringHelper.DIGITS + SCR_StringHelper.UNDERSCORE;
23
24 //------------------------------------------------------------------------------------------------
25 protected override void Run()
26 {
27 m_sProjectName.TrimInPlace();
28
29 if (!DialogConfirmation())
30 return;
31
32 if (!SCR_FileIOHelper.IsValidFileName(m_sProjectName))
33 return;
34
35 if (!m_ConfigType.m_Directory)
36 Print("No directory setup", LogLevel.WARNING);
37
38 string addonFileSystem = SCR_AddonTool.GetAddonFileSystem(m_iAddon);
39 string absoluteAddonDirectory;
40 if (!SCR_AddonTool.GetAddonAbsolutePath(m_iAddon, string.Empty, absoluteAddonDirectory, true))
41 {
42 Print("Cannot find path for addon " + addonFileSystem, LogLevel.ERROR);
43 return;
44 }
45
46 m_ConfigType.m_sName = m_sProjectName;
47 if (!SCR_PrefabHelper.CreatePrefabStructure(m_ConfigType, addonFileSystem))
48 {
49 Print("Cannot create Prefab structure", LogLevel.WARNING);
50 return;
51 }
52 }
53
54 //------------------------------------------------------------------------------------------------
56 protected bool DialogConfirmation()
57 {
58 if (!Workbench.ScriptDialog("Prefab Structure Creation", "", this))
59 return false;
60
61 array<string> errors = {};
62
63 if (m_sStructureToCreate)
64 {
65 m_ConfigType = SCR_ConfigHelperT<SCR_PrefabHelper_Structure>.GetConfigObject(m_sStructureToCreate);
66// m_sStructureToCreate = ResourceName.Empty;
67 if (!m_ConfigType)
68 {
69 Print("Cannot get m_ConfigType from " + m_sStructureToCreate, LogLevel.ERROR);
70 Workbench.Dialog("Error", "Cannot get m_ConfigType from " + m_sStructureToCreate);
71 return true;
72 }
73 }
74 else // no config provided
75 {
76 errors.Insert("Structure To Create is null");
77 }
78
79 m_sProjectName = SCR_StringHelper.Filter(m_sProjectName, ALLOWED_CHARACTERS, false);
80 if (!m_sProjectName)
81 errors.Insert("Project Name is invalid");
82
83 if (!errors.IsEmpty())
84 {
85 Workbench.Dialog("Error", SCR_StringHelper.Join(SCR_StringHelper.LINE_RETURN, errors));
86 errors.Clear();
87 }
88
89 return errors.IsEmpty();
90 }
91
92 //------------------------------------------------------------------------------------------------
93 [ButtonAttribute("OK")]
94 protected int ButtonOK()
95 {
96 return 1;
97 }
98
99 //------------------------------------------------------------------------------------------------
100 [ButtonAttribute("Cancel")]
101 protected int ButtonClose()
102 {
103 return 0;
104 }
105
106 //------------------------------------------------------------------------------------------------
107 // constructor
108 protected void SCR_PrefabStructureCreationPlugin();
109}
110#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 ButtonOK()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
class WorkbenchDialog_AbortRetryIgnore ButtonAttribute("OK", true)
static bool IsValidFileName(string fileName)
static ParamEnumArray FromAddons(int titleFormat=2, int hideCoreModules=0)
static string Filter(string input, string characters, bool useCharactersAsBlacklist=false)
static string Join(string separator, notnull array< string > pieces, bool joinEmptyEntries=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