Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_PrefabStructureFillingPlugin.c
Go to the documentation of this file.
1#ifdef WORKBENCH
3 name: "Prefab Structure Filling",
4 description: "Fill Prefab structure according based on the selected type",
5 category: "Prefab Structure",
6 wbModules: { "WorldEditor" },
7 awesomeFontCode: 0xF6BE)]
8class SCR_PrefabStructureFillingPlugin : WorkbenchPlugin
9{
10 //------------------------------------------------------------------------------------------------
11 protected override void Run()
12 {
13 IEntitySource entitySource = SCR_WorldEditorToolHelper.GetPrefabEditModeEntitySource();
14 if (!entitySource)
15 {
16 Print("Not in Prefab Edit mode or another error somewhere", LogLevel.WARNING);
17 return;
18 }
19
20 SCR_PrefabStructureFillingPlugin_TypeSelection typeSelection = new SCR_PrefabStructureFillingPlugin_TypeSelection();
21 if (!Workbench.ScriptDialog("Pick your poison", "So, whaddaya want?", typeSelection) || !typeSelection.m_sChoiceName) // .IsEmpty()
22 return;
23
24 typename selectedClass = ("SCR_PrefabStructureFillingPlugin_" + typeSelection.m_sChoiceName).ToType();
25 if (!selectedClass)
26 {
27 Print("Configuration class does not exist - (SCR_PrefabStructureFillingPlugin_)" + typeSelection.m_sChoiceName, LogLevel.WARNING);
28 return;
29 }
30
31 SCR_PrefabStructureFillingPlugin_TypeBase configuration = SCR_PrefabStructureFillingPlugin_TypeBase.Cast(selectedClass.Spawn());
32 if (!configuration)
33 {
34 Print("Cannot create configuration instance for " + typeSelection.m_sChoiceName, LogLevel.WARNING);
35 return;
36 }
37
38 if (!Workbench.ScriptDialog(typeSelection.m_sChoiceName + " Configuration", "Please configure", configuration))
39 {
40 if (!configuration.m_bClose)
41 Run(); // beware of stack
42
43 return;
44 }
45
46 IEntitySource actualPrefab = entitySource.GetAncestor();
47 if (!actualPrefab)
48 {
49 Print("Currently edited entity does not have a Prefab", LogLevel.WARNING);
50 return;
51 }
52
53 configuration.Process(actualPrefab);
54 }
55}
56
57class SCR_PrefabStructureFillingPlugin_TypeSelection
58{
59 // buttons for now, combobox when there are too many options
60// [Attribute(defvalue: "Car", uiwidget: UIWidgets.ComboBox, desc: "Choice Name", params: "0 inf", enums: {
61// new ParamEnum("Animal", "Animal"),
62// new ParamEnum("Character - Male", "CharacterM"),
63// new ParamEnum("Character - Female", "CharacterF"),
64// new ParamEnum("Civilian Car", "Car"),
65// new ParamEnum("Military Car", "MilitaryCar"),
66// new ParamEnum("Tank/Armored", "Tank"),
67// new ParamEnum("Helicopter", "Helicopter"),
68// new ParamEnum("Civilian airplane", "Airplane"),
69// new ParamEnum("Jet", "Jet"),
70// // etc
71// })]
72// string m_sChoiceName2 = "Civilian Car";
73// [Attribute(defvalue: "Car", uiwidget: UIWidgets.ComboBox, desc: "Choice Name", params: "0 inf", enums: SCR_ParamEnumArray.FromString(
74// "Animal,Animal,"
75// + ";CharacterM,Character - Male,"
76// + ";CharacterF,Character - Female,"
77// + ";Car,Civilian Car,"
78// + ";MilitaryCar,Military Car,"
79// + ";Tank,Tank/Armored,"
80// + ";Airplane,Civilian airplane,"
81// + ";Jet,Jet,"
82// ))]
83// string m_sChoiceName3 = "Civilian Car";
84
85 string m_sChoiceName;
86
87 //------------------------------------------------------------------------------------------------
88 [ButtonAttribute("Character")]
89 protected int ButtonCharacter()
90 {
91 m_sChoiceName = "Character";
92 return 1;
93 }
94
95 //------------------------------------------------------------------------------------------------
96 [ButtonAttribute("Car")]
97 protected int ButtonCar()
98 {
99 m_sChoiceName = "Car";
100 return 1;
101 }
102
103 //------------------------------------------------------------------------------------------------
104 [ButtonAttribute("Tank")]
105 protected int ButtonTank()
106 {
107 m_sChoiceName = "Tank";
108 return 1;
109 }
110
111 //------------------------------------------------------------------------------------------------
112 [ButtonAttribute("Helicopter")]
113 protected int ButtonHelicopter()
114 {
115 m_sChoiceName = "Helicopter";
116 return 1;
117 }
118
119 //------------------------------------------------------------------------------------------------
120 [ButtonAttribute("Cancel")]
121 protected int ButtonCancel()
122 {
123 return 0;
124 }
125}
126
133class SCR_PrefabStructureFillingPlugin_TypeBase
134{
135 // [Attribute(defvalue: "42")]
136 // protected int m_iValue = 42; // here
137
138 bool m_bClose;
139
144 protected WorldEditorAPI m_WorldEditorAPI;
145
146 //------------------------------------------------------------------------------------------------
150 bool Process(notnull IEntitySource prefab)
151 {
152 if (!prefab.GetResourceName())
153 {
154 Print("Passed value is not a Prefab - " + prefab, LogLevel.ERROR);
155 return false;
156 }
157
158 m_WorldEditorAPI = SCR_WorldEditorToolHelper.GetWorldEditorAPI();
159 if (!m_WorldEditorAPI)
160 {
161 Print("World Editor API is not available", LogLevel.ERROR);
162 return false;
163 }
164
165 return true;
166 }
167
168 //------------------------------------------------------------------------------------------------
169 [ButtonAttribute("← Back")]
170 protected int ButtonBack()
171 {
172 return 0;
173 }
174
175 //------------------------------------------------------------------------------------------------
176 [ButtonAttribute("Process", true)]
177 protected int ButtonOK()
178 {
179 return 1;
180 }
181
182 //------------------------------------------------------------------------------------------------
183 [ButtonAttribute("Cancel")]
184 protected int ButtonCancel()
185 {
186 m_bClose = true;
187 return 0;
188 }
189}
190
191#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()
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