make formspec colors configurable via minetest.conf

also gather all theme-related images and other stuff into one mod,
and make others depend on it.
This commit is contained in:
Vanessa Dannenberg
2021-03-03 18:37:09 -05:00
parent b85510f6ac
commit fd2a59df2b
40 changed files with 212 additions and 100 deletions

View File

@@ -15,16 +15,20 @@ default.get_translator = S
-- GUI related stuff
minetest.register_on_joinplayer(function(player)
-- Set formspec prepend
local formspec = [[
listcolors[#FFFFFF30;#B0B0B0;#606060;#A0A0A0;#FFF]
style_type[button;bgcolor=#B0B0B0FF]
style_type[button_exit;bgcolor=#B0B0B0FF]
style_type[image_button;bgcolor=#B0B0B0FF;border=false]
style_type[image_button_exit;bgcolor=#B0B0B0FF;border=false]
style_type[item_image_button;bgcolor=#B0B0B0FF;border=false]
style_type[scrollbar;bgimg=#808080FF;fgimg=#606060FF;border=true]
]]
local formspec =
"listcolors["..dreambuilder.listcolor_slot_bg_normal..
";"..dreambuilder.listcolor_slot_bg_hover..
";"..dreambuilder.listcolor_slot_border..
";"..dreambuilder.tooltip_bgcolor..
";"..dreambuilder.tooltip_fontcolor.."]"..
"style_type[button;bgcolor="..dreambuilder.form_bgcolor.."]"..
"style_type[button_exit;bgcolor="..dreambuilder.form_bgcolor.."]"..
"style_type[image_button;bgcolor="..dreambuilder.form_bgcolor..
";border="..dreambuilder.image_button_borders.."]"..
"style_type[image_button_exit;bgcolor="..dreambuilder.form_bgcolor..
";border="..dreambuilder.image_button_borders.."]"..
"style_type[item_image_button;bgcolor="..dreambuilder.form_bgcolor..
";border="..dreambuilder.image_button_borders.."]"
local name = player:get_player_name()
local info = minetest.get_player_information(name)
if info.formspec_version > 1 then
@@ -47,7 +51,10 @@ function default.get_hotbar_bg(x,y)
return out
end
default.gui_bg = "bgcolor["..dreambuilder.form_bgcolor..";"..dreambuilder.window_darken.."]"
default.gui_survival_form = "size[8,8.5]"..
default.gui_bg..
"list[current_player;main;0,4.25;8,1;]"..
"list[current_player;main;0,5.5;8,3;8]"..
"list[current_player;craft;1.75,0.5;3,3;]"..

View File

@@ -1,3 +1,4 @@
name = default
description = Minetest Game mod: default
optional_depends = player_api
depends = dreambuilder_gui_theming

View File

@@ -14,6 +14,7 @@ echo -e "\nSetting up..."
rm -rf $game_path/* $workdir*
mkdir $workdir
rm -f /tmp/herefile*
echo -e "\nAdding minetest_game as the base..."
@@ -42,7 +43,6 @@ rm $workdir"/README.md" \
mv $workdir"/mods/dreambuilder_extras/README.md" $workdir
mv $workdir"/mods/dreambuilder_extras/default_README.txt" $workdir"/mods/default/README.txt"
mv $workdir"/mods/dreambuilder_extras/game.conf" $workdir
mv $workdir"/mods/dreambuilder_extras/minetest.conf" $workdir
mv $workdir"/mods/dreambuilder_extras/minetest.conf.example" $workdir
mv $workdir"/mods/dreambuilder_extras/settingtypes.txt" $workdir
mv $workdir"/mods/dreambuilder_extras/dreambuilder_screenshot.png" $workdir"/screenshot.png"
@@ -207,17 +207,76 @@ sed -i "s/LOAD_OTHERGEN_MODULE = true/LOAD_OTHERGEN_MODULE = false/" \
rm -rf $workdir/mods/worldedit_brush
# Create the standard in-game lightly-shaded theme, and expand on it
# Create the standard in-game lightly-shaded theme, expand on it, make it user-configurable
rm $workdir"/mods/default/textures/gui_formbg.png"
cat > /tmp/listcolors << 'EOF'
"listcolors["..dreambuilder.listcolor_slot_bg_normal..
";"..dreambuilder.listcolor_slot_bg_hover..
";"..dreambuilder.listcolor_slot_border..
";"..dreambuilder.tooltip_bgcolor..
";"..dreambuilder.tooltip_fontcolor.."]"..
EOF
cat > /tmp/herefileA << 'EOF'
"style_type[button;bgcolor="..dreambuilder.form_bgcolor.."]"..
"style_type[button_exit;bgcolor="..dreambuilder.form_bgcolor.."]"..
"style_type[image_button;bgcolor="..dreambuilder.form_bgcolor..
";border="..dreambuilder.image_button_borders.."]"..
"style_type[image_button_exit;bgcolor="..dreambuilder.form_bgcolor..
";border="..dreambuilder.image_button_borders.."]"..
"style_type[item_image_button;bgcolor="..dreambuilder.form_bgcolor..
";border="..dreambuilder.image_button_borders.."]"
EOF
mv $workdir"/mods/dreambuilder_extras/minetest.conf" $workdir
sed -i "s/bgcolor\[.*\]//" \
$workdir"/mods/beds/init.lua"
sed -i '/local formspec = \[\[/ , /\]\]/ {d}' \
$workdir"/mods/default/init.lua"
sed -i '/Set formspec prepend/ {
a \\t\tlocal formspec =
r /tmp/listcolors
r /tmp/herefileA
}' $workdir"/mods/default/init.lua"
sed -i '/default.gui_survival_form/ {
i default.gui_bg = "bgcolor["..dreambuilder.form_bgcolor..";"..dreambuilder.window_darken.."]"\n
a \\t\t\tdefault.gui_bg..
}' $workdir"/mods/default/init.lua"
echo "depends = dreambuilder_gui_theming" >> $workdir"/mods/default/mod.conf"
sed -i 's/"style_type\[.*\]"/"style_type[label,textarea;font=mono]" \
\t\t.."style_type[textarea;textcolor="..dreambuilder.form_bgcolor..";border="..dreambuilder.editor_border.."]"/' \
$workdir"/mods/mesecons_luacontroller/init.lua"
sed -i "0,/depends =/s//depends = dreambuilder_gui_theming, /" $workdir"/mods/mesecons/mod.conf"
sed -i 's/"size\[8,9\]" \.\./"size[8,9]" .. \
\t\t"image[-0.39,-0.4;10.7,11.4;default_chest_inv_bg.png]".. \
\t\t"listcolors[#00000000;#00000000;#00000000;"..dreambuilder.tooltip_bgcolor..";"..dreambuilder.tooltip_fontcolor.."]"../' \
$workdir"/mods/pipeworks/compat-chests.lua"
sed -i 's/"size\[8,8.5\]"\.\./"size[8,8.5]".. \
\t\t"image[-0.39,-0.4;10.7,10.9;default_furnace_inv_bg.png]".. \
\t\t"listcolors[#00000000;#00000000;#00000000;"..dreambuilder.tooltip_bgcolor..";"..dreambuilder.tooltip_fontcolor.."]"../' \
$workdir"/mods/pipeworks/compat-furnaces.lua"
sed -i "0, /depends = /s//depends = dreambuilder_gui_theming, /" $workdir"/mods/pipeworks/mod.conf"
sed -i 's/"size\[8,7;\]" ../"size[8,7]" .. \
\t"image[-0.39,-0.4;10.7,9.1;vessels_inv_bg.png]".. \
\t"listcolors[#00000000;#00000000;#00000000;"..dreambuilder.tooltip_bgcolor..";"..dreambuilder.tooltip_fontcolor.."]"../' \
$workdir"/mods/vessels/init.lua"
sed -i "0, /depends = /s//depends = dreambuilder_gui_theming, /" $workdir"/mods/vessels/mod.conf"
inv_slot_colors="\"listcolors\[#00000000;#00000000;#00000000;#A0A0A0;#FFF\]\" .."
form_bgcolor="#F0F0F0FF"
btn_color="#B0B0B0FF"
editor_text_color="#000000FF"
editor_bg_color="#F0F0F0FF"
scrollbar_color="#808080FF"
scrollbar_handle_color="#606060FF"
sed -i 's/"field\[.*\]"/ \
\t\t\t"formspec_version[4]".. \
@@ -235,58 +294,32 @@ sed -i 's/"field\[.*")/ \
\t\t\t\t\t)/' \
$workdir"/mods/technic/machines/register/battery_box.lua"
sed -i 's/INSERT_BGCOLOR/default.gui_bg = "bgcolor['"$form_bgcolor"';false]"/' \
$workdir"/mods/dreambuilder_extras/init.lua"
sed -i "s/bgcolor\[.*\]//" \
$workdir"/mods/default/init.lua"
sed -i '/local n = 4/ {
i \\tformspec[4]="style_type[image_button;bgcolor="..dreambuilder.form_bgcolor.."]"
i \\tlocal n = 5
d
}' $workdir"/mods/unified_inventory/internal.lua"
sed -i "s/bgcolor\[.*\]//" \
$workdir"/mods/beds/init.lua"
sed -i "0, /depends = /s//depends = dreambuilder_gui_theming, /" $workdir"/mods/unified_inventory/mod.conf"
sed -i "s/listcolors\[.*\]/listcolors[#FFFFFF30;#B0B0B0;#606060;#A0A0A0;#FFF] \
\n\t\t\tstyle_type[button;bgcolor="$btn_color"] \
\n\t\t\tstyle_type[button_exit;bgcolor="$btn_color"] \
\n\t\t\tstyle_type[image_button;bgcolor="$btn_color";border=false] \
\n\t\t\tstyle_type[image_button_exit;bgcolor="$btn_color";border=false] \
\n\t\t\tstyle_type[item_image_button;bgcolor="$btn_color";border=false] \
\n\t\t\tstyle_type[scrollbar;bgimg="$scrollbar_color";fgimg="$scrollbar_handle_color";border=true] \
\n\t ]]/" \
$workdir"/mods/default/init.lua"
mv $workdir"/mods/dreambuilder_extras/dreambuilder_gui_theming" \
$workdir"/mods/"
sed -i 's/"style_type\[.*\]"/"style_type[label,textarea;font=mono]" \
\t\t.."style_type[textarea;textcolor='"$editor_text_color"';border=false]"/' \
$workdir"/mods/mesecons_luacontroller/init.lua"
sed -i 's/"size\[8,9\]" \.\./"size[8,9]" .. \
\t\t"image[-0.39,-0.4;10.7,11.4;default_chest_inv_bg.png]" .. \
\t\t'"$inv_slot_colors"'/' \
$workdir"/mods/pipeworks/compat-chests.lua"
sed -i 's/"size\[8,8.5\]"\.\./"size[8,8.5]".. \
\t\t"image[-0.39,-0.4;10.7,10.9;default_furnace_inv_bg.png]" .. \
\t\t'"$inv_slot_colors"'/' \
$workdir"/mods/pipeworks/compat-furnaces.lua"
sed -i 's/"size\[8,7;\]" ../"size[8,7]" .. \
\t"image[-0.39,-0.4;10.7,9.1;vessels_inv_bg.png]" .. \
\t'"$inv_slot_colors"'/' \
$workdir"/mods/vessels/init.lua"
rm $workdir"/mods/unified_inventory/textures/ui_bags_header.png" \
$workdir"/mods/unified_inventory/textures/ui_bags_inv"* \
$workdir"/mods/unified_inventory/textures/ui_bags_trash.png" \
$workdir"/mods/unified_inventory/textures/ui_crafting_form.png" \
$workdir"/mods/unified_inventory/textures/ui_form_bg.png" \
$workdir"/mods/unified_inventory/textures/ui_main_inventory.png" \
$workdir"/mods/unified_inventory/textures/ui_single_slot.png"
mv $workdir"/mods/dreambuilder_extras/ui_"*".png" $workdir"/mods/unified_inventory/textures/"
sed -i 's/local n = 4/formspec[4]="style_type[image_button;bgcolor='"$btn_color"']" \
\tlocal n = 5/' \
$workdir"/mods/unified_inventory/internal.lua"
rm $workdir"/mods/default/textures/gui_formbg.png" \
$workdir"/mods/mesecons/textures/jeija_close_window.png" \
$workdir"/mods/mesecons_luacontroller/textures/jeija_luac_background.png" \
$workdir"/mods/mesecons_luacontroller/textures/jeija_luac_runbutton.png" \
$workdir"/mods/unified_inventory/textures/ui_bags_header.png" \
$workdir"/mods/unified_inventory/textures/ui_bags_inv"* \
$workdir"/mods/unified_inventory/textures/ui_bags_trash.png" \
$workdir"/mods/unified_inventory/textures/ui_crafting_form.png" \
$workdir"/mods/unified_inventory/textures/ui_form_bg.png" \
$workdir"/mods/unified_inventory/textures/ui_main_inventory.png" \
$workdir"/mods/unified_inventory/textures/ui_single_slot.png" \
$workdir"/mods/vessels/textures/vessels_shelf_slot.png"
rm /tmp/herefile*
# Add in all of the regular player skins for the player_textures mod

View File

@@ -1,23 +1,8 @@
-- This mod contains a number of features specific to dreambuilder
-- such as mesh-based apples, some color settings, etc.
-- The actual "mod part" of this "extras" folder just suplies 3d apples
-- and makes the lavacooling a bit more random and hence natural-loking.
--
-- by Vanessa Dannenberg
default.gui_bg = "bgcolor[#F0F0F0FF;false]"
default.gui_survival_form = "size[8,8.5]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"list[current_player;main;0,4.25;8,1;]"..
"list[current_player;main;0,5.5;8,3;8]"..
"list[current_player;craft;1.75,0.5;3,3;]"..
"list[current_player;craftpreview;5.75,1.5;1,1;]"..
"image[4.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
"listring[current_player;main]"..
"listring[current_player;craft]"..
default.get_hotbar_bg(0,4.25)
default.cool_lava = function (pos, node) end
minetest.register_abm({

View File

@@ -1,2 +1,2 @@
min_minetest_version = 5.3.0
depends = default
depends = dreambuilder_gui_theming, default

View File

@@ -0,0 +1,22 @@
-- Dreambuilder theming mod
-- really all this does is preload the global config and supply some textures :P
-- colors can be changed with your local minetest.conf
dreambuilder = {}
dreambuilder.form_bgcolor = minetest.settings:get("dreambuilder_form_bgcolor")
dreambuilder.btn_color = minetest.settings:get("dreambuilder_btn_color")
dreambuilder.editor_text_color = minetest.settings:get("dreambuilder_editor_text_color")
dreambuilder.editor_bg_color = minetest.settings:get("dreambuilder_editor_bg_color")
dreambuilder.listcolor_slot_bg_normal = minetest.settings:get("dreambuilder_listcolor_slot_bg_normal")
dreambuilder.listcolor_slot_bg_hover = minetest.settings:get("dreambuilder_listcolor_slot_bg_hover")
dreambuilder.listcolor_slot_border = minetest.settings:get("dreambuilder_listcolor_slot_border")
dreambuilder.tooltip_bgcolor = minetest.settings:get("dreambuilder_tooltip_bgcolor")
dreambuilder.tooltip_fontcolor = minetest.settings:get("dreambuilder_tooltip_fontcolor")
-- where these three are used, strings are needed, not actual bools.
dreambuilder.window_darken = minetest.settings:get_bool("dreambuilder_window_darken") and "true" or "false"
dreambuilder.editor_border = minetest.settings:get_bool("dreambuilder_editor_border") and "true" or "false"
dreambuilder.image_button_borders = minetest.settings:get_bool("dreambuilder_image_button_borders") and "true" or "false"

View File

@@ -0,0 +1,2 @@
name = dreambuilder_gui_theming
description = formspec/window theming mod

View File

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

View File

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 274 B

After

Width:  |  Height:  |  Size: 274 B

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

Before

Width:  |  Height:  |  Size: 642 B

After

Width:  |  Height:  |  Size: 642 B

View File

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

Before

Width:  |  Height:  |  Size: 264 B

After

Width:  |  Height:  |  Size: 264 B

View File

@@ -1,2 +1,2 @@
name = mesecons
depends = default
depends = dreambuilder_gui_theming, default

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 B

View File

@@ -665,7 +665,7 @@ local function reset_formspec(meta, code, errmsg)
errmsg = minetest.formspec_escape(tostring(errmsg or ""))
meta:set_string("formspec", "size[12,10]"
.."style_type[label,textarea;font=mono]"
.."style_type[textarea;textcolor=#000000FF;border=false]"
.."style_type[textarea;textcolor="..dreambuilder.form_bgcolor..";border="..dreambuilder.editor_border.."]"
.."background[-0.2,-0.25;12.4,10.75;jeija_luac_background.png]"
.."label[0.1,8.3;"..errmsg.."]"
.."textarea[0.2,0.2;12.2,9.5;code;;"..code.."]"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 655 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -15,8 +15,8 @@ local function get_chest_formspec(pos)
local spos = pos.x .. "," .. pos.y .. "," .. pos.z
local formspec =
"size[8,9]" ..
"image[-0.39,-0.4;10.7,11.4;default_chest_inv_bg.png]" ..
"listcolors[#00000000;#00000000;#00000000;#A0A0A0;#FFF]" ..
"image[-0.39,-0.4;10.7,11.4;default_chest_inv_bg.png]"..
"listcolors[#00000000;#00000000;#00000000;"..dreambuilder.tooltip_bgcolor..";"..dreambuilder.tooltip_fontcolor.."]"..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..

View File

@@ -12,8 +12,8 @@ local tube_entry = "^pipeworks_tube_connection_stony.png"
local function active_formspec(fuel_percent, item_percent, pos, meta)
local formspec =
"size[8,8.5]"..
"image[-0.39,-0.4;10.7,10.9;default_furnace_inv_bg.png]" ..
"listcolors[#00000000;#00000000;#00000000;#A0A0A0;#FFF]" ..
"image[-0.39,-0.4;10.7,10.9;default_furnace_inv_bg.png]"..
"listcolors[#00000000;#00000000;#00000000;"..dreambuilder.tooltip_bgcolor..";"..dreambuilder.tooltip_fontcolor.."]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
@@ -47,8 +47,8 @@ end
local function inactive_formspec(pos, meta)
local formspec = "size[8,8.5]"..
"image[-0.39,-0.4;10.7,10.9;default_furnace_inv_bg.png]" ..
"listcolors[#00000000;#00000000;#00000000;#A0A0A0;#FFF]" ..
"image[-0.39,-0.4;10.7,10.9;default_furnace_inv_bg.png]"..
"listcolors[#00000000;#00000000;#00000000;"..dreambuilder.tooltip_bgcolor..";"..dreambuilder.tooltip_fontcolor.."]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..

View File

@@ -1,5 +1,5 @@
name = pipeworks
description = This mod uses mesh nodes and nodeboxes to supply a complete set of 3D pipes and tubes, along with devices that work with them.
depends = default, basic_materials, screwdriver
depends = dreambuilder_gui_theming, default, basic_materials, screwdriver
optional_depends = mesecons, mesecons_mvps, digilines, signs_lib
min_minetest_version = 5.2.0

View File

@@ -67,7 +67,7 @@ function unified_inventory.get_formspec(player, page)
pagedef.formspec_prepend and "" or "no_prepend[]",
unified_inventory.standard_background -- Background
}
formspec[4]="style_type[image_button;bgcolor=#B0B0B0FF]"
formspec[4]="style_type[image_button;bgcolor="..dreambuilder.form_bgcolor.."]"
local n = 5
if draw_lite_mode then

View File

@@ -1,5 +1,5 @@
name = unified_inventory
depends = default
depends = dreambuilder_gui_theming, default
optional_depends = creative, sfinv, datastorage, farming
description = """
Unified Inventory replaces the default survival and creative inventory.

View File

@@ -9,8 +9,8 @@ local S = minetest.get_translator("vessels")
local vessels_shelf_formspec =
"size[8,7]" ..
"image[-0.39,-0.4;10.7,9.1;vessels_inv_bg.png]" ..
"listcolors[#00000000;#00000000;#00000000;#A0A0A0;#FFF]" ..
"image[-0.39,-0.4;10.7,9.1;vessels_inv_bg.png]"..
"listcolors[#00000000;#00000000;#00000000;"..dreambuilder.tooltip_bgcolor..";"..dreambuilder.tooltip_fontcolor.."]"..
"list[context;vessels;0,0.3;8,2;]" ..
"list[current_player;main;0,2.85;8,1;]" ..
"list[current_player;main;0,4.08;8,3;8]" ..

View File

@@ -1,4 +1,4 @@
name = vessels
description = Minetest Game mod: vessels
depends = default
depends = dreambuilder_gui_theming, default
optional_depends = dungeon_loot

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 B