Default formspec appearance

Posted:
Sun Jun 15, 2014 16:29
by MirceaKitsune
I know it's possible to texture formspec menus, by defining a background image for each. I was however wondering if there's also a way to define a default appearance for all formspecs, including background texture and perhaps text color. If not, could this ability be added in some form?
I seek this because I wish to texture the menus for minetest_game. However, I'm not going to re-define every individual formspec... such as inventory, chests, furnace, pause menu, etc. Even if I did that, mods which add their own formspec windows (like workbenches, technic_game engines, or things that rely on the Inventory+ buttons) would also have to be edited to use the same appearance. You also can't texture the main menu this way, or at least not easily... whereas a default per-game formspec theme would help a lot.
Obviously, when a formspec defines its own appearance, that should be used instead. I'm only looking to specify game defaults so the black transparent background and gray inventory boxes are replaced with something else.
Re: Default formspec appearance

Posted:
Sun Jun 15, 2014 16:49
by BlockMen
Since minetest_game is frozen don't expect a change like that. Use
minetest_next for that, which is a maintained minetest_game. It already has textured formspecs...
Re: Default formspec appearance

Posted:
Sun Jun 15, 2014 16:59
by rubenwardy
You wouldn't need to modify minetest_game. You could do it in builtin. (Add the possibility to change default formspec appearance.)
Or even in a mod. You could override minetest.show_formspec and check for background[] etc.
Re: Default formspec appearance

Posted:
Sun Jun 15, 2014 17:05
by BlockMen
rubenwardy wrote:You wouldn't need to modify minetest_game. You could do it in builtin. (Add the possibility to change default formspec appearance.)
Or even in a mod. You could override minetest.show_formspec and check for background[] etc.
minetest.show_formspec() is not in builtin, its in the engine itself. So you can't override it that way. And i dont like that idea at all...
Re: Default formspec appearance

Posted:
Mon Jun 16, 2014 07:43
by rubenwardy
BlockMen wrote:rubenwardy wrote:You wouldn't need to modify minetest_game. You could do it in builtin. (Add the possibility to change default formspec appearance.)
Or even in a mod. You could override minetest.show_formspec and check for background[] etc.
minetest.show_formspec() is not in builtin, its in the engine itself. So you can't override it that way. And i dont like that idea at all...
You can still override it.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
local _tmp = minetest.show_formspec
function minetest.show_formspec(name, form, spec)
-- Check for background, background image, etc
-- If not found, do this:
spec = "background[askdn]" .. spec
_tmp(name, form, spec)
end
A mod would be best. You could do it in builtin.
Re: Default formspec appearance

Posted:
Mon Jun 16, 2014 10:57
by MirceaKitsune
rubenwardy wrote:You can still override it.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
local _tmp = minetest.show_formspec
function minetest.show_formspec(name, form, spec)
-- Check for background, background image, etc
-- If not found, do this:
spec = "background[askdn]" .. spec
_tmp(name, form, spec)
end
A mod would be best. You could do it in builtin.
Awesome, that's what I was looking for! Since the additional "background" line goes at the beginning of the formspec string, it should also not break formspecs that use their own background image as it's listed later. Thanks!
One more question: Can I do it in a way that also overrides the main menu once the game is selected? That sounds a little trickier, since the script must execute before you start the server but also have an effect in-game.
I agree with adding a hook like this to builtin, to make this ability easier for everyone.
Re: Default formspec appearance

Posted:
Mon Jun 16, 2014 16:18
by twoelk
yay - why out there on the horizon, slowly approaching, an easily skinable GUI detected. Hopefully not a fatamorgana.
Re: Default formspec appearance

Posted:
Mon Jul 07, 2014 13:04
by MirceaKitsune
I'm happy to announce that yesterday, the integration of minetest_next into minetest_game has made this come true. Formspecs in any mod can now include the following defaults in their string:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
default.gui_bg..default.gui_bg_img..default.gui_slots..
Doing so gives the formspec an appearance defined in minetest_game, which other games based on it can of course change. This does of course require every mod to include the lines in its formspec... which I am doing at this moment for the stuff I still maintain, and recommend others to do. Either way, it makes what I was looking for possible at last.