1+ local editor_scripts_internal = require (" druid.editor_scripts.editor_scripts_internal" )
2+
13local M = {}
24
35
@@ -7,10 +9,8 @@ function M.open_settings()
79 local dialog_component = editor .ui .component (function (props )
810 local template_path , set_template_path = editor .ui .use_state (editor .prefs .get (" druid.widget_template_path" ))
911 local path_valid = editor .ui .use_memo (function (path )
10- -- Use resource_exists to check if the resource exists
1112 local exists = false
1213 pcall (function ()
13- -- If we can get the text property, the resource exists
1414 local content = editor .get (path , " text" )
1515 exists = content ~= nil
1616 end )
@@ -27,6 +27,11 @@ function M.open_settings()
2727 return exists
2828 end , gui_script_template_path )
2929
30+ local editor_script_set_layers_enabled , set_editor_script_set_layers_enabled = editor .ui .use_state (editor .prefs .get (" druid.command_assign_layers_enabled" ))
31+ local editor_script_create_widget_enabled , set_editor_script_create_widget_enabled = editor .ui .use_state (editor .prefs .get (" druid.command_create_widget_enabled" ))
32+ local editor_script_create_gui_script_enabled , set_editor_script_create_gui_script_enabled = editor .ui .use_state (editor .prefs .get (" druid.command_create_gui_script_enabled" ))
33+ local editor_script_create_collection_enabled , set_editor_script_create_collection_enabled = editor .ui .use_state (editor .prefs .get (" druid.command_create_collection_enabled" ))
34+
3035 return editor .ui .dialog ({
3136 title = " Druid Settings" ,
3237 content = editor .ui .vertical ({
@@ -61,7 +66,49 @@ function M.open_settings()
6166 color = editor .ui .COLOR .WARNING
6267 }) or nil ,
6368
64- -- Links section title
69+ editor .ui .label ({
70+ text = " Editor Commands:" ,
71+ color = editor .ui .COLOR .TEXT
72+ }),
73+
74+ editor .ui .grid ({
75+ columns = {{}, {grow = true }},
76+ children = {
77+ editor .bundle .grid_row (
78+ nil ,
79+ editor .ui .check_box ({
80+ value = editor_script_set_layers_enabled ,
81+ on_value_changed = set_editor_script_set_layers_enabled ,
82+ text = " Assign Layers"
83+ })
84+ ),
85+ editor .bundle .grid_row (
86+ nil ,
87+ editor .ui .check_box ({
88+ value = editor_script_create_widget_enabled ,
89+ on_value_changed = set_editor_script_create_widget_enabled ,
90+ text = " Create Druid Widget"
91+ })
92+ ),
93+ editor .bundle .grid_row (
94+ nil ,
95+ editor .ui .check_box ({
96+ value = editor_script_create_gui_script_enabled ,
97+ on_value_changed = set_editor_script_create_gui_script_enabled ,
98+ text = " Create Druid GUI Script"
99+ })
100+ ),
101+ editor .bundle .grid_row (
102+ nil ,
103+ editor .ui .check_box ({
104+ value = editor_script_create_collection_enabled ,
105+ on_value_changed = set_editor_script_create_collection_enabled ,
106+ text = " Create Druid Collection"
107+ })
108+ )
109+ }
110+ }),
111+
65112 editor .ui .label ({
66113 text = " Documentation:" ,
67114 color = editor .ui .COLOR .TEXT
@@ -124,17 +171,47 @@ function M.open_settings()
124171 editor .ui .dialog_button ({
125172 text = " Save" ,
126173 default = true ,
127- result = { template_path = template_path }
174+ result = {
175+ template_path = template_path ,
176+ gui_script_template_path = gui_script_template_path ,
177+ editor_script_set_layers_enabled = editor_script_set_layers_enabled ,
178+ editor_script_create_widget_enabled = editor_script_create_widget_enabled ,
179+ editor_script_create_gui_script_enabled = editor_script_create_gui_script_enabled ,
180+ editor_script_create_collection_enabled = editor_script_create_collection_enabled ,
181+ }
128182 })
129183 }
130184 })
131185 end )
132186
133187 local result = editor .ui .show_dialog (dialog_component ({}))
134- if result and result .template_path then
135- -- Update the preferences
136- editor .prefs .set (" druid.widget_template_path" , result .template_path )
137- print (" Widget template path updated to:" , result .template_path )
188+ if result then
189+ if result .template_path then
190+ editor .prefs .set (" druid.widget_template_path" , result .template_path )
191+ print (" Widget template path updated to:" , result .template_path )
192+ end
193+ if result .gui_script_template_path then
194+ editor .prefs .set (" druid.gui_script_template_path" , result .gui_script_template_path )
195+ print (" GUI script template path updated to:" , result .gui_script_template_path )
196+ end
197+ if result .editor_script_set_layers_enabled ~= nil then
198+ editor .prefs .set (" druid.command_assign_layers_enabled" , result .editor_script_set_layers_enabled )
199+ print (" Assign layers enabled:" , result .editor_script_set_layers_enabled )
200+ end
201+ if result .editor_script_create_widget_enabled ~= nil then
202+ editor .prefs .set (" druid.command_create_widget_enabled" , result .editor_script_create_widget_enabled )
203+ print (" Create widget enabled:" , result .editor_script_create_widget_enabled )
204+ end
205+ if result .editor_script_create_gui_script_enabled ~= nil then
206+ editor .prefs .set (" druid.command_create_gui_script_enabled" , result .editor_script_create_gui_script_enabled )
207+ print (" Create GUI script enabled:" , result .editor_script_create_gui_script_enabled )
208+ end
209+ if result .editor_script_create_collection_enabled ~= nil then
210+ editor .prefs .set (" druid.command_create_collection_enabled" , result .editor_script_create_collection_enabled )
211+ print (" Create collection enabled:" , result .editor_script_create_collection_enabled )
212+ end
213+
214+ editor_scripts_internal .call_editor_command (" reload-extensions" )
138215 end
139216
140217 return result
0 commit comments