Major default formspec style update

- Uses formspec_prepend to set e.g. button style
- Make all formspecs use the MCL2 style consistently
This commit is contained in:
Wuzzy 2020-03-10 05:01:49 +01:00
parent 0e867e5247
commit 03ad3cca29
49 changed files with 38 additions and 32 deletions

View file

@ -4,13 +4,20 @@ mcl_vars = {}
--- GUI / inventory menu settings
mcl_vars.gui_slots = "listcolors[#9990;#FFF7;#FFF0;#000;#FFF]"
-- nonbg is added as formspec prepend in mcl_formspec_prepend
mcl_vars.gui_nonbg = mcl_vars.gui_slots
mcl_vars.gui_nonbg = mcl_vars.gui_slots ..
"style_type[image_button;border=false;bgimg=mcl_inventory_button9.png;bgimg_pressed=mcl_inventory_button9_pressed.png;bgimg_middle=2,2]"..
"style_type[button;border=false;bgimg=mcl_inventory_button9.png;bgimg_pressed=mcl_inventory_button9_pressed.png;bgimg_middle=2,2]"..
"style_type[field;textcolor=#323232]"..
"style_type[label;textcolor=#323232]"..
"style_type[textarea;textcolor=#323232]"..
"style_type[checkbox;textcolor=#323232]"
-- Background stuff must be manually added by mods (no formspec prepend)
mcl_vars.gui_bg = "bgcolor[#080808BB;true]"
mcl_vars.gui_bg_img = ""
mcl_vars.gui_bg_color = "bgcolor[#00000000]"
mcl_vars.gui_bg_img = "background9[1,1;1,1;mcl_base_textures_background9.png;true;7]"
mcl_vars.inventory_header = mcl_vars.gui_bg
-- Legacy
mcl_vars.inventory_header = ""
-- Mapgen variables
local mg_name = minetest.get_mapgen_setting("mg_name")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -490,7 +490,6 @@ local function show_trade_formspec(playername, trader, tradenum)
"size[9,8.75]"
.."background[-0.19,-0.25;9.41,9.49;mobs_mc_trading_formspec_bg.png]"
..disabled_img
..mcl_vars.inventory_header
.."label[4,0;"..minetest.formspec_escape(minetest.colorize("#313131", S(profession))).."]"
.."list[current_player;main;0,4.5;9,3;9]"
.."list[current_player;main;0,7.74;9,1;]"

View file

@ -636,9 +636,7 @@ local function make_formspec(name)
if not sfinv_only then
fs[#fs + 1] = fmt("size[%f,%f;]", data.iX - 0.35, iY + 4)
fs[#fs + 1] = [[
background[1,1;1,1;craftguide_bg.png;true]
]]
fs[#fs + 1] = "background9[1,1;1,1;mcl_base_textures_background9.png;true;7]"
fs[#fs + 1] = fmt([[ tooltip[size_inc;%s]
tooltip[size_dec;%s] ]],
@ -670,7 +668,7 @@ local function make_formspec(name)
fs[#fs + 1] = fmt("label[%f,%f;%s / %u]",
sfinv_only and 6.3 or data.iX - 2.2,
0.22,
colorize("yellow", data.pagenum),
data.pagenum,
data.pagemax)
fs[#fs + 1] = fmt([[

View file

@ -410,8 +410,10 @@ function awards.getFormspec(name, to, sid)
if perc > 1 then
perc = 1
end
formspec = formspec .. "background[0,4.80;" .. barwidth ..",0.25;awards_progress_gray.png;false]"
formspec = formspec .. "background[0,4.80;" .. (barwidth * perc) ..",0.25;awards_progress_green.png;false]"
formspec = formspec .. "background[0,4.80;" .. barwidth ..",0.3;awards_progress_gray.png;false]"
if perc > 0 then
formspec = formspec .. "background[0,4.80;" .. (barwidth * perc) ..",0.3;awards_progress_green.png;false]"
end
if label then
formspec = formspec .. "label[1.75,4.63;" .. minetest.formspec_escape(label) .. "]"
end
@ -423,7 +425,8 @@ function awards.getFormspec(name, to, sid)
end
-- Create list box
formspec = formspec .. "textlist[4.75,0;6,5;awards;"
formspec = formspec ..
"textlist[4.75,0;6,5;awards;"
local first = true
for _,award in pairs(listofawards) do
local def = awards.def[award.name]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 B

After

Width:  |  Height:  |  Size: 71 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 177 B

After

Width:  |  Height:  |  Size: 71 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 B

View file

@ -1,3 +1,3 @@
minetest.register_on_joinplayer(function(player)
player:set_formspec_prepend(mcl_vars.gui_nonbg)
player:set_formspec_prepend(mcl_vars.gui_nonbg .. mcl_vars.gui_bg_color .. mcl_vars.gui_bg_img)
end)

View file

@ -348,6 +348,7 @@ mcl_inventory.set_creative_formspec = function(player, start_i, pagenum, inv_siz
"tooltip[__mcl_skins;"..F(S("Select player skin")).."]"..
-- achievements button
"image_button[9,4;1,1;mcl_achievements_button.png;__mcl_achievements;]"..
--"style_type[image_button;border=;bgimg=;bgimg_pressed=]"..
"tooltip[__mcl_achievements;"..F(S("Achievements")).."]"
-- For shortcuts
@ -387,6 +388,7 @@ mcl_inventory.set_creative_formspec = function(player, start_i, pagenum, inv_siz
bg_img = "crafting_creative_inactive.png"
end
return
"style["..this_tab..";border=false;bgimg=;bgimg_pressed=]"..
"item_image_button[" .. boffset[this_tab] ..";1,1;"..tab_icon[this_tab]..";"..this_tab..";]"..
"image[" .. offset[this_tab] .. ";1.5,1.44;" .. bg_img .. hoch[this_tab].. "]" ..
"image[" .. boffset[this_tab] .. ";1,1;crafting_creative_marker.png]"
@ -396,8 +398,9 @@ mcl_inventory.set_creative_formspec = function(player, start_i, pagenum, inv_siz
caption = "label[0,1.2;"..F(minetest.colorize("#313131", filtername[name])).."]"
end
formspec = "size[10,9.3]style_type[item_image_button;border=false]"..
mcl_vars.inventory_header..
formspec = "size[10,9.3]"..
"no_prepend[]"..
mcl_vars.gui_nonbg..mcl_vars.gui_bg_color..
"background[-0.19,-0.25;10.5,9.87;"..inv_bg.."]"..
"label[-5,-5;"..name.."]"..
tab(name, "blocks") ..

View file

@ -90,7 +90,6 @@ local function set_inventory(player, armor_change_only)
local form = "size[9,8.75]"..
"background[-0.19,-0.25;9.41,9.49;crafting_formspec_bg.png]"..
mcl_vars.inventory_header..
player_preview..
--armor
"list[detached:"..player_name.."_armor;armor;0,0;1,1;1]"..

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 B

After

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 629 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 B

After

Width:  |  Height:  |  Size: 181 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 613 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 861 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 881 B

After

Width:  |  Height:  |  Size: 104 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 96 B

View file

@ -14,7 +14,6 @@ local setup_dispenser = function(pos)
-- Set formspec and inventory
local form = "size[9,8.75]"..
"background[-0.19,-0.25;9.41,9.49;crafting_inventory_9_slots.png]"..
mcl_vars.inventory_header..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
"list[current_player;main;0,7.74;9,1;]"..

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 B

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 B

After

Width:  |  Height:  |  Size: 243 B

View file

@ -15,7 +15,6 @@ local setup_dropper = function(pos)
-- Set formspec and inventory
local form = "size[9,8.75]"..
"background[-0.19,-0.25;9.41,9.49;crafting_inventory_9_slots.png]"..
mcl_vars.inventory_header..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
"list[current_player;main;0,7.74;9,1;]"..

View file

@ -15,7 +15,6 @@ local setup_dropper = function(pos)
-- Set formspec and inventory
local form = "size[9,8.75]"..
"background[-0.19,-0.25;9.41,9.49;crafting_inventory_9_slots.png]"..
mcl_vars.inventory_header..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
"list[current_player;main;0,7.74;9,1;]"..

Binary file not shown.

Before

Width:  |  Height:  |  Size: 275 B

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 274 B

After

Width:  |  Height:  |  Size: 251 B

View file

@ -170,7 +170,7 @@ local on_rightclick = function(pos, node, player, itemstack, pointed_thing)
else
textarea = "textarea[0.5,0.5;8.5,4;"..textarea_name..";"..F(S("Commands:"))..";"..F(commands).."]"
end
local formspec = "invsize[9,5;]" ..
local formspec = "size[9,5;]" ..
textarea ..
submit ..
"image_button[8,4.5;1,1;doc_button_icon_lores.png;doc;]" ..

View file

@ -17,7 +17,6 @@ local function get_anvil_formspec(set_name)
end
return "size[9,8.75]"..
"background[-0.19,-0.25;9.41,9.49;mcl_anvils_inventory.png]"..
mcl_vars.inventory_header..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
"list[current_player;main;0,7.74;9,1;]"..

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -1,3 +1,4 @@
mcl_init?
mcl_core?
mcl_sounds?
mcl_mobitems?

View file

@ -3,6 +3,12 @@ local S =minetest.get_translator("mcl_books")
local max_text_length = 4500 -- TODO: Increase to 12800 when scroll bar was added to written book
local max_title_length = 64
local header = ""
if minetest.get_modpath("mcl_init") then
header = "no_prepend[]" .. mcl_vars.gui_nonbg .. mcl_vars.gui_bg_color ..
"style_type[button;border=false;bgimg=mcl_books_button9.png;bgimg_pressed=mcl_books_button9_pressed.png;bgimg_middle=2,2]"
end
-- Book
minetest.register_craftitem("mcl_books:book", {
description = S("Book"),
@ -81,6 +87,7 @@ local write = function(itemstack, user, pointed_thing)
local text = get_text(itemstack)
local formspec = "size[8,9]"..
header..
"background[-0.5,-0.5;9,10;mcl_books_book_bg.png]"..
"textarea[0.75,0.1;7.25,9;text;;"..minetest.formspec_escape(text).."]"..
"button[0.75,7.95;3,1;sign;"..minetest.formspec_escape(S("Sign")).."]"..
@ -101,8 +108,9 @@ local read = function(itemstack, user, pointed_thing)
local text = get_text(itemstack)
local formspec = "size[8,9]"..
header..
"background[-0.5,-0.5;9,10;mcl_books_book_bg.png]"..
"textarea[0.75,0.1;7.25,9;;"..minetest.colorize("#000000", minetest.formspec_escape(text))..";]"..
"textarea[0.75,0.1;7.25,9;;"..minetest.formspec_escape(text)..";]"..
"button_exit[2.25,7.95;3,1;ok;"..minetest.formspec_escape(S("Done")).."]"
minetest.show_formspec(user:get_player_name(), "mcl_books:written_book", formspec)
end
@ -135,6 +143,7 @@ minetest.register_on_player_receive_fields(function ( player, formname, fields )
local name = player:get_player_name()
local formspec = "size[8,9]"..
header..
"background[-0.5,-0.5;9,10;mcl_books_book_bg.png]"..
"field[0.75,1;7.25,1;title;"..minetest.formspec_escape(minetest.colorize("#000000", S("Enter book title:")))..";]"..
"label[0.75,1.5;"..minetest.formspec_escape(minetest.colorize("#404040", S("by @1", name))).."]"..

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 B

View file

@ -182,7 +182,6 @@ minetest.register_node("mcl_chests:"..basename, {
minetest.show_formspec(clicker:get_player_name(),
"mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z,
"size[9,8.75]"..
mcl_vars.inventory_header..
"background[-0.19,-0.25;9.41,10.48;mcl_chests_inventory_chest.png]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Chest"))).."]"..
"list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0.5;9,3;]"..
@ -318,7 +317,6 @@ minetest.register_node("mcl_chests:"..basename.."_left", {
"mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z,
"size[9,11.5]"..
"background[-0.19,-0.25;9.41,12.5;mcl_chests_inventory_chest_large.png]"..
mcl_vars.inventory_header..
"label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Large Chest"))).."]"..
"list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0.5;9,3;]"..
"list[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main;0,3.5;9,3;]"..
@ -454,7 +452,6 @@ minetest.register_node("mcl_chests:"..basename.."_right", {
"size[9,11.5]"..
"background[-0.19,-0.25;9.41,12.5;mcl_chests_inventory_chest_large.png]"..
mcl_vars.inventory_header..
"label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Large Chest"))).."]"..
"list[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main;0,0.5;9,3;]"..
"list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,3.5;9,3;]"..
@ -661,7 +658,6 @@ minetest.register_node("mcl_chests:ender_chest", {
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"size[9,8.75]"..
mcl_vars.inventory_header..
"background[-0.19,-0.25;9.41,10.48;mcl_chests_inventory_chest.png]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Ender Chest"))).."]"..
"list[current_player;enderchest;0,0.5;9,3;]"..
@ -782,7 +778,6 @@ for color, desc in pairs(boxtypes) do
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"size[9,8.75]"..
mcl_vars.inventory_header..
"background[-0.19,-0.25;9.41,10.48;mcl_chests_inventory_chest.png]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Shulker Box"))).."]"..
"list[current_name;main;0,0.5;9,3;]"..

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -15,8 +15,7 @@ minetest.register_node("mcl_crafting_table:crafting_table", {
player:get_inventory():set_size("craft", 9)
local form = "size[9,8.75]"..
"background[-0.19,-0.25;9.41,9.49;crafting_formspec_bg.png^crafting_inventory_workbench.png]"..
mcl_vars.inventory_header..
"background[-0.19,-0.25;9.41,9.49;crafting_formspec_bg2.png^crafting_inventory_workbench.png]"..
"label[0,4;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
"list[current_player;main;0,7.74;9,1;]"..

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -8,7 +8,6 @@ local S = minetest.get_translator("mcl_furnaces")
local function active_formspec(fuel_percent, item_percent)
return "size[9,8.75]"..
"background[-0.19,-0.25;9.41,9.49;crafting_inventory_furnace.png]"..
mcl_vars.inventory_header..
"label[0,4;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
"list[current_player;main;0,7.74;9,1;]"..
@ -32,7 +31,6 @@ end
local inactive_formspec = "size[9,8.75]"..
"background[-0.19,-0.25;9.41,9.49;crafting_inventory_furnace.png]"..
mcl_vars.inventory_header..
"label[0,4;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
"list[current_player;main;0,7.74;9,1;]"..

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -7,7 +7,6 @@ local chest = minetest.get_content_id("mcl_chests:chest")
local mcl_hoppers_formspec =
"size[9,7]"..
"background[-0.19,-0.25;9.41,10.48;mcl_hoppers_inventory.png]"..
mcl_vars.inventory_header..
"label[2,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Hopper"))).."]"..
"list[current_name;main;2,0.5;5,1;]"..
"label[0,2;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..