Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CreateEditablePrefabsPlugin.c
Go to the documentation of this file.
1#ifdef WORKBENCH
2[WorkbenchPluginAttribute(name: "Create/Update Selected Editable Prefabs", category: SCR_PluginCategory.EDITOR, shortcut: "Ctrl+Shift+U", wbModules: { "WorldEditor" }, awesomeFontCode: 0xF1B2)]
3class SCR_CreateEditablePrefabsPlugin : SCR_PrefabEditingPluginBase
4{
5 [Attribute(defvalue: "{90B4D95CF3610F3D}Configs/Workbench/EditablePrefabs/EditablePrefabsConfig.conf", desc: "", params: "conf")]
6 protected ResourceName m_sConfig;
7
8 [Attribute(desc: "[UNUSED] When enabled, the process will only update existing editable entities, not create new ones.")]
9 protected bool m_bOnlyUpdate;
10
11 //------------------------------------------------------------------------------------------------
12 override void Run()
13 {
14 //TODO: m_bOnlyUpdate = false is Hotfix needs to be fixed and removed
15 m_bOnlyUpdate = false;
16
17 Workbench.OpenModule(WorldEditor); // also used by SCR_CreateEditablePrefabsPluginResourceManager which is a ResourceManager plugin
18 WorldEditor worldEditor = Workbench.GetModule(WorldEditor);
19 if (!worldEditor)
20 return;
21
22 WorldEditorAPI api = worldEditor.GetApi();
23 if (!api)
24 return;
25
26 EditablePrefabsConfig config = EditablePrefabsConfig.GetConfig(m_sConfig);
27 if (!config || !config.IsValid())
28 return;
29
30 config.GetLinks();
31 if (!config.CreateWorld())
32 return;
33
34 //--- Get selected entities
35 array<ResourceName> selectedPrefabs = {};
36 if (!GetPrefabs(selectedPrefabs))
37 return;
38
39 map<string, SCR_EEditablePrefabResult> results = new map<string, SCR_EEditablePrefabResult>();
40
41 WBProgressDialog progress = new WBProgressDialog("Processing Prefabs...", worldEditor);
42
43 //--- Iterate through all entities
44 api.BeginEntityAction();
45 int count = selectedPrefabs.Count();
46 float prevProgress, currProgress;
47 foreach (int i, ResourceName selectedPrefab : selectedPrefabs)
48 {
49 config.CreateEditablePrefab(api, selectedPrefab, m_bOnlyUpdate, results);
50
51 currProgress = i / count;
52 if (currProgress - prevProgress >= 0.01) // min 1%
53 {
54 progress.SetProgress(currProgress); // expensive
55 prevProgress = currProgress;
56 }
57 }
58 api.EndEntityAction();
59
60 worldEditor.Save(); //--- Save to world so it's not marked as edited
61
62 config.LogResults(results);
63 }
64
65 //------------------------------------------------------------------------------------------------
66 override void Configure()
67 {
68 Workbench.ScriptDialog("Configure 'Create/Update Selected Editable Prefabs' plugin", "", this);
69 }
70
71 //------------------------------------------------------------------------------------------------
72 [ButtonAttribute("Close")]
73 protected bool ButtonClose()
74 {
75 return false;
76 }
77}
78
79[WorkbenchPluginAttribute(name: "Create/Update Selected Editable Prefabs", category: SCR_PluginCategory.EDITOR, shortcut: "Ctrl+Shift+U", wbModules: { "ResourceManager" })]
80class SCR_CreateEditablePrefabsPluginResourceManager : SCR_CreateEditablePrefabsPlugin
81{
82 //------------------------------------------------------------------------------------------------
83 override void GetSelected(out array<ResourceName> selection)
84 {
85 GetSelectedResourceBrowser(selection);
86 }
87}
88#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()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
override void Configure()
class WorkbenchDialog_AbortRetryIgnore ButtonAttribute("OK", true)
SCR_FieldOfViewSettings Attribute
proto external int GetSelected(out notnull array< MapItem > outItems)
Get all selected entities.