monarch
monarch copied to clipboard
Add posibility to change the template that the editor script is using.
I often find myself using the editor script to setup a monarch scene then open up the gui scene/script and add a bunch of "defaults" that I always have. These are often a few fonts a texture and some layers and in the case of the script utility/gui modules.
Now I am tired of it, so I thought that it could be a good idea for the user to extend/change the template that the script.
The idea is that a user could create their template, open it as a text and copy it and use it as the return string.
local M = {}
function M.gui_template(gui_script)
return "the complete document that should be used"
end
return M
(I also changed gui_script_content (and renamed it to gui_script_template) to be a function and thus use the same pattern as the other templates)
Am of course open to alternatives if you have a better idea how the user can setup/supply templates.
The idea is that a user could create their template, open it as a text and copy it and use it as the return string.
Another idea (not sure if it's better): what if editor_script_settings.lua has
M.GUI_TEMPLATE = "path/to/template.gui"
M.GUI_SCRIPT_TEMPLATE = "path/to/template.gui_script
And the editor script would use those two files as templates? Or maybe only M.GUI_TEMPLATE and use parse it and also copy the .gui_script file specified in the .gui file?
I was considering this too. But I think that by having it as a function that returns the template the user can add logic to it if needed, which feels a lot more flexible. The trade off is of course the simplicity, but if someone would like to change the template I would presume they are towards the "power user" side.
So the question is, what to we prefer. Simplicity or flexibility?
True. What about a combination?
If M.gui_template is a function it will be called and the returned value will be used as the content of the created .gui file. If it is a string it will be used as a path to a file. And if it is nil a default empty .gui file will be created.
Too complicated?
I think that gives the best of both worlds. I think that people will understand it, as long as the documentation is very clear about it.