Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add posibility to change the template that the editor script is using. #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Jerakin
Copy link
Contributor

@Jerakin Jerakin commented Sep 3, 2020

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.

@britzl
Copy link
Owner

britzl commented Sep 6, 2020

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?

@Jerakin
Copy link
Contributor Author

Jerakin commented Sep 6, 2020

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?

@britzl
Copy link
Owner

britzl commented Sep 6, 2020

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?

@Jerakin
Copy link
Contributor Author

Jerakin commented Sep 6, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants