-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Forms: General Styles: ability to configure default styles. Closes #1708
- Loading branch information
Showing
6 changed files
with
81 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,28 @@ | ||
local config = require('forms.DefaultStyle.config') | ||
|
||
|
||
--- @class forms.DefaultStyle | ||
local DefaultStyle = { | ||
label = { font = 'normal', font_size = '+0', textcolor = '#fff', --[[noclip = 'false'--]] }, | ||
} | ||
local DefaultStyle = {} | ||
|
||
--- @param name string | ||
--- @return minetest.FormSpec.Style | ||
function DefaultStyle.get(name) | ||
return config[name] | ||
end | ||
|
||
--- @param name string | ||
--- @param style minetest.FormSpec.Style | ||
--- @return forms.DefaultStyle | ||
function DefaultStyle.set(name, style) | ||
config[name] = style | ||
|
||
return DefaultStyle | ||
end | ||
|
||
---@return fun(tbl: table<string, minetest.FormSpec.Style>):string, minetest.FormSpec.Style | ||
function DefaultStyle.list() | ||
return pairs(config) | ||
end | ||
|
||
|
||
return DefaultStyle |
31 changes: 31 additions & 0 deletions
31
mods/lord/Game/lord_forms/src/forms/DefaultStyle/config.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
|
||
--- @alias forms.DefaultStyle.config minetest.FormSpec.Style[]|table<string,minetest.FormSpec.Style> | ||
|
||
--- @type forms.DefaultStyle.config | ||
local config = { | ||
--- @type minetest.FormSpec.Style | ||
label = { font = 'normal', font_size = '+0', textcolor = '#fff', --[[noclip = 'false'--]] }, | ||
button = { | ||
bgimg = 'button_bg.png', | ||
bgimg_middle = 4, | ||
font = 'bold', | ||
textcolor = '#fffc', | ||
padding = '0', | ||
}, | ||
--- @type minetest.FormSpec.Style | ||
some = { | ||
|
||
} | ||
|
||
-- as for now, this styles is not supported by MT | ||
--.. spec.style_type({'field', 'field:focused', 'field:hovered', 'field:pressed'}, { | ||
-- bgcolor = '#600', | ||
-- bgcolor_hovered = '#000', | ||
-- bgcolor_pressed = '#000', | ||
-- padding = 0 | ||
--}) | ||
} | ||
|
||
|
||
return config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,29 @@ | ||
local spec = minetest.formspec | ||
local DefaultStyle = require('forms.DefaultStyle') | ||
local spec = minetest.formspec | ||
|
||
|
||
local formspec_prepend = '' | ||
.. spec.bgcolor('#000c', 'true') | ||
.. spec.background9(5, 5, 1, 1, 'gui_formbg.png', 'true', 10) | ||
.. spec.listcolors('#0007', '#5a5a5a', '#141318', '#1238', '#fffc') | ||
.. spec.style_type('button', { | ||
bgimg = 'button_bg.png', | ||
bgimg_middle = 4, | ||
font = 'bold', | ||
textcolor = '#fffc', | ||
padding = '0', | ||
}) | ||
-- as for now, this styles is not supported by MT | ||
--.. spec.style_type({'field', 'field:focused', 'field:hovered', 'field:pressed'}, { | ||
-- bgcolor = '#600', | ||
-- bgcolor_hovered = '#000', | ||
-- bgcolor_pressed = '#000', | ||
-- padding = 0 | ||
--}) | ||
|
||
|
||
local function build_formspec_prepend() | ||
formspec_prepend = '' | ||
.. spec.bgcolor('#000c', 'true') | ||
.. spec.background9(5, 5, 1, 1, 'gui_formbg.png', 'true', 10) | ||
.. spec.listcolors('#0007', '#5a5a5a', '#141318', '#1238', '#fffc') | ||
|
||
for name, style in DefaultStyle.list() do | ||
formspec_prepend = formspec_prepend | ||
.. spec.style_type('button', DefaultStyle.get('button')) | ||
end | ||
end | ||
|
||
|
||
return { | ||
register = function() | ||
minetest.register_on_mods_loaded(build_formspec_prepend) | ||
|
||
minetest.register_on_joinplayer(function(player) | ||
player:set_formspec_prepend(formspec_prepend) | ||
end) | ||
end | ||
end, | ||
} |
2 changes: 1 addition & 1 deletion
2
mods/lord/Player/lord_inventory/src/inventory/Form/AboutTab.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters