Default formspec appearance

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

Default formspec appearance

by MirceaKitsune » Sun Jun 15, 2014 16:29

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.
 

User avatar
BlockMen
Member
 
Posts: 768
Joined: Fri Mar 01, 2013 17:24
GitHub: BlockMen

Re: Default formspec appearance

by BlockMen » Sun Jun 15, 2014 16:49

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...
Last edited by BlockMen on Sun Jun 15, 2014 17:08, edited 1 time in total.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Default formspec appearance

by rubenwardy » Sun Jun 15, 2014 16:59

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.
 

User avatar
BlockMen
Member
 
Posts: 768
Joined: Fri Mar 01, 2013 17:24
GitHub: BlockMen

Re: Default formspec appearance

by BlockMen » Sun Jun 15, 2014 17:05

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...
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Default formspec appearance

by rubenwardy » Mon Jun 16, 2014 07:43

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.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

Re: Default formspec appearance

by MirceaKitsune » Mon Jun 16, 2014 10:57

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.
 

twoelk
Member
 
Posts: 1092
Joined: Fri Apr 19, 2013 16:19

Re: Default formspec appearance

by twoelk » Mon Jun 16, 2014 16:18

yay - why out there on the horizon, slowly approaching, an easily skinable GUI detected. Hopefully not a fatamorgana.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

Re: Default formspec appearance

by MirceaKitsune » Mon Jul 07, 2014 13:04

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.
 


Return to Minetest General

Who is online

Users browsing this forum: No registered users and 8 guests