From ed70f51e8364b0ab4008b1e161a462fdbbd35a0b Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Wed, 10 Mar 2021 21:14:57 -0500 Subject: [PATCH] misc theming fixes --- mods/default/init.lua | 33 -------- .../customize-dreambuilder-game.sh | 51 ++++-------- mods/dreambuilder_hotbar/init.lua | 7 +- mods/dreambuilder_theme_functions/init.lua | 20 ----- mods/dreambuilder_theme_light/init.lua | 40 ++++++--- mods/dreambuilder_theme_settings/init.lua | 83 ++++++++++++++++++- mods/dreambuilder_theme_settings/mod.conf | 1 - mods/mesecons_luacontroller/init.lua | 2 +- mods/unified_inventory/internal.lua | 2 +- settingtypes.txt | 51 +----------- 10 files changed, 132 insertions(+), 158 deletions(-) delete mode 100644 mods/dreambuilder_theme_functions/init.lua diff --git a/mods/default/init.lua b/mods/default/init.lua index 2a9de7a4..5b3fbdb0 100644 --- a/mods/default/init.lua +++ b/mods/default/init.lua @@ -12,36 +12,6 @@ default = {} default.LIGHT_MAX = 14 default.get_translator = S --- GUI related stuff -minetest.register_on_joinplayer(function(player) - -- Set formspec prepend - local formspec = - "listcolors["..dreambuilder_theme.listcolor_slot_bg_normal.. - ";"..dreambuilder_theme.listcolor_slot_bg_hover.. - ";"..dreambuilder_theme.listcolor_slot_border.. - ";"..dreambuilder_theme.tooltip_bgcolor.. - ";"..dreambuilder_theme.tooltip_fontcolor.."]".. - "style_type[button;bgcolor="..dreambuilder_theme.btn_color.."]".. - "style_type[button_exit;bgcolor="..dreambuilder_theme.btn_color.."]".. - "style_type[image_button;bgcolor="..dreambuilder_theme.btn_color.. - ";border="..dreambuilder_theme.image_button_borders.."]".. - "style_type[image_button_exit;bgcolor="..dreambuilder_theme.btn_color.. - ";border="..dreambuilder_theme.image_button_borders.."]".. - "style_type[item_image_button;bgcolor="..dreambuilder_theme.btn_color.. - ";border="..dreambuilder_theme.image_button_borders.."]" - local name = player:get_player_name() - local info = minetest.get_player_information(name) - if info.formspec_version > 1 then - formspec = formspec .. "background9[5,5;1,1;"..dreambuilder_theme.name.."_gui_formbg.png;true;10]" - else - formspec = formspec .. "background[5,5;1,1;"..dreambuilder_theme.name.."_gui_formbg.png;true]" - end - player:set_formspec_prepend(formspec) - - -- Set hotbar textures - player:hud_set_hotbar_image("gui_hotbar.png") - player:hud_set_hotbar_selected_image("gui_hotbar_selected.png") -end) function default.get_hotbar_bg(x,y) local out = "" @@ -51,10 +21,7 @@ function default.get_hotbar_bg(x,y) return out end -default.gui_bg = "bgcolor["..dreambuilder_theme.form_bgcolor..";"..dreambuilder_theme.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;]".. diff --git a/mods/dreambuilder_extras/customize-dreambuilder-game.sh b/mods/dreambuilder_extras/customize-dreambuilder-game.sh index 13d1751f..50272f77 100755 --- a/mods/dreambuilder_extras/customize-dreambuilder-game.sh +++ b/mods/dreambuilder_extras/customize-dreambuilder-game.sh @@ -97,7 +97,6 @@ my_mods/street_signs \ my_mods/unifieddyes \ my_mods/simple_streetlights \ my_mods/basic_materials \ -my_mods/dreambuilder_hotbar \ Calinous_mods/bedrock \ Calinous_mods/maptools \ Calinous_mods/moreores \ @@ -148,6 +147,7 @@ CWzs_mods/player_textures \ bobblocks \ unifiedbricks \ my_mods/pipeworks \ +my_mods/dreambuilder_hotbar \ RBAs_mods/unified_inventory \ Zeg9s_mods/ufos/ufos" @@ -216,13 +216,6 @@ LISTCOLORS_HIDE_SLOTS='"listcolors[#00000000;"..dreambuilder_theme.listcolor_slo mv $workdir"/mods/dreambuilder_extras/minetest.conf" $workdir -########## -sed -i 's/"gui_hotbar_selected.png"/dreambuilder_theme.name.."_gui_hotbar_selected.png"/' \ - $workdir"/mods/dreambuilder_hotbar/init.lua" - -sed -i 's/"gui_hb_bg_"/dreambuilder_theme.name.."_gui_hb_bg_"/' \ - $workdir"/mods/dreambuilder_hotbar/init.lua" - ########## sed -i "s/bgcolor\[.*\]//" \ @@ -230,42 +223,23 @@ sed -i "s/bgcolor\[.*\]//" \ ########## -sed -i '/local formspec = \[\[/ , /\]\]/ {d}' \ - $workdir"/mods/default/init.lua" - -sed -i '/Set formspec prepend/ { - a \\t\tlocal formspec = - a \\t\t"listcolors["..dreambuilder_theme.listcolor_slot_bg_normal.. - a \\t\t\t";"..dreambuilder_theme.listcolor_slot_bg_hover.. - a \\t\t\t";"..dreambuilder_theme.listcolor_slot_border.. - a \\t\t\t";"..dreambuilder_theme.tooltip_bgcolor.. - a \\t\t\t";"..dreambuilder_theme.tooltip_fontcolor.."]".. - a \\t\t"style_type[button;bgcolor="..dreambuilder_theme.btn_color.."]".. - a \\t\t"style_type[button_exit;bgcolor="..dreambuilder_theme.btn_color.."]".. - a \\t\t"style_type[image_button;bgcolor="..dreambuilder_theme.btn_color.. - a \\t\t\t";border="..dreambuilder_theme.image_button_borders.."]".. - a \\t\t"style_type[image_button_exit;bgcolor="..dreambuilder_theme.btn_color.. - a \\t\t\t";border="..dreambuilder_theme.image_button_borders.."]".. - a \\t\t"style_type[item_image_button;bgcolor="..dreambuilder_theme.btn_color.. - a \\t\t\t";border="..dreambuilder_theme.image_button_borders.."]" - }' $workdir"/mods/default/init.lua" - -sed -i '/default.gui_survival_form/ { - i default.gui_bg = "bgcolor["..dreambuilder_theme.form_bgcolor..";"..dreambuilder_theme.window_darken.."]"\n - a \\t\t\tdefault.gui_bg.. - }' $workdir"/mods/default/init.lua" - sed -i 's/gui_formbg.png/"..dreambuilder_theme.name.."_gui_formbg.png/' \ $workdir"/mods/default/init.lua" sed -i '/tableoptions/d' $workdir"/mods/default/craftitems.lua" +sed -i '/-- GUI related stuff/,/end)/{//!d;d}' \ + $workdir"/mods/default/init.lua" + +sed -i '/default.gui_bg/,/default.get_hotbar_bg/{//!d;d}' \ + $workdir"/mods/default/init.lua" + echo "depends = dreambuilder_theme_settings" >> $workdir"/mods/default/mod.conf" ########## sed -i 's/"style_type\[.*\]"/"style_type[label,textarea;font=mono]" \ -\t\t.."style_type[textarea;textcolor="..dreambuilder_theme.editor_text_color..";border="..dreambuilder_theme.editor_border.."]"/' \ +\t\t.."style_type[textarea;textcolor="..dreambuilder_theme.editor_text_color..";border=false]"/' \ $workdir"/mods/mesecons_luacontroller/init.lua" sed -i 's/jeija_luac_background.png/"..dreambuilder_theme.name.."_jeija_luac_background.png/' \ @@ -533,6 +507,11 @@ sed -i "/formspec\[n\] = fsdata.formspec/ { a \\\tn = n + 2 }" $workdir"/mods/unified_inventory/internal.lua" +sed -i '/pagedef.formspec_prepend/ { + a \\t\t"no_prepend[]"..default.gui_bg, + d + }' $workdir"/mods/unified_inventory/internal.lua" + sed -i '/ui.single_slot(8.425, 1.5)/ { a \\t\t\t"style_type[button;bgcolor="..dreambuilder_theme.btn_color.."]", }' $workdir"/mods/unified_inventory/bags.lua" @@ -551,10 +530,10 @@ sed -i "0, /depends = /s//depends = dreambuilder_theme_settings, /" $workdir"/mo ########## mv $workdir"/mods/dreambuilder_extras/dreambuilder_theme_settings" \ - $workdir"/mods/dreambuilder_extras/dreambuilder_theme_functions" \ - $workdir"/mods/dreambuilder_extras/dreambuilder_theme_light" \ $workdir"/mods/" +rsync -a $upstream_mods_path"/my_mods/dreambuilder_themes/dreambuilder_theme_light" $workdir/mods + # Add in all of the regular player skins for the player_textures mod rm -f $workdir/mods/player_textures/textures/* diff --git a/mods/dreambuilder_hotbar/init.lua b/mods/dreambuilder_hotbar/init.lua index b1f34717..2311e264 100644 --- a/mods/dreambuilder_hotbar/init.lua +++ b/mods/dreambuilder_hotbar/init.lua @@ -1,5 +1,6 @@ local mtver = minetest.get_version() local maxslots = (string.sub(mtver.string, 1, 4) ~= "0.4.") and 32 or 23 +local themename = dreambuilder_theme and dreambuilder_theme.name.."_" or "" local function validate_size(s) local size = s and tonumber(s) or 16 @@ -44,8 +45,8 @@ minetest.register_on_joinplayer(function(player) local hotbar_size = validate_size(get_hotbar_setting(player:get_player_name())) player:hud_set_hotbar_itemcount(hotbar_size) minetest.after(0.5,function(hotbar_size) - player:hud_set_hotbar_selected_image(dreambuilder_theme.name.."_gui_hotbar_selected.png") - player:hud_set_hotbar_image(dreambuilder_theme.name.."_gui_hb_bg_"..hotbar_size..".png") + player:hud_set_hotbar_selected_image(themename.."gui_hotbar_selected.png") + player:hud_set_hotbar_image(themename.."gui_hb_bg_"..hotbar_size..".png") end,hotbar_size) end) @@ -58,7 +59,7 @@ minetest.register_chatcommand("hotbar", { local player = minetest.get_player_by_name(name) player:hud_set_hotbar_itemcount(hotbar_size) minetest.chat_send_player(name, "[_] Hotbar size set to " ..hotbar_size.. ".") - player:hud_set_hotbar_image(dreambuilder_theme.name.."_gui_hb_bg_"..hotbar_size..".png") + player:hud_set_hotbar_image(themename.."_gui_hb_bg_"..hotbar_size..".png") save_hotbar_settings() end, }) diff --git a/mods/dreambuilder_theme_functions/init.lua b/mods/dreambuilder_theme_functions/init.lua deleted file mode 100644 index 374e492c..00000000 --- a/mods/dreambuilder_theme_functions/init.lua +++ /dev/null @@ -1,20 +0,0 @@ --- This mod just supplies helpers to build slot backgrounds for mods that use formspec v1 - -dreambuilder_theme = {} - -function dreambuilder_theme.single_slot_v1(xpos, ypos, bright) - return string.format("background9[%f,%f;%f,%f;%s_ui_single_slot%s.png;false;16]", - xpos, ypos, 1, 1.08, dreambuilder_theme.name, (bright and "_bright" or "") ) -end - -function dreambuilder_theme.make_inv_img_grid_v1(xpos, ypos, width, height, bright) - local tiled = {} - local n=1 - for y = 0, (height - 1) do - for x = 0, (width -1) do - tiled[n] = dreambuilder_theme.single_slot_v1(xpos + x, ypos + y, bright) - n = n + 1 - end - end - return table.concat(tiled) -end diff --git a/mods/dreambuilder_theme_light/init.lua b/mods/dreambuilder_theme_light/init.lua index 7653c420..7a3cc2c4 100644 --- a/mods/dreambuilder_theme_light/init.lua +++ b/mods/dreambuilder_theme_light/init.lua @@ -1,18 +1,32 @@ -dreambuilder_theme.name = "dbtheme_light" +if dreambuilder_theme.name ~= "dbtheme_light" then return end -dreambuilder_theme.form_bgcolor = "#F0F0F0FF" -dreambuilder_theme.btn_color = "#B0B0B0FF" +print("[Dreambuilder] Activated \"light\" theme") -dreambuilder_theme.editor_text_color = "#000000FF" -dreambuilder_theme.editor_bg_color = "#F0F0F0FF" +dreambuilder_theme.light = { + ["form_bgcolor"] = "#F0F0F0FF", + ["btn_color"] = "#B0B0B0FF", -dreambuilder_theme.listcolor_slot_bg_normal = "#FFFFFF30" -dreambuilder_theme.listcolor_slot_bg_hover = "#FFFFFF80" -dreambuilder_theme.listcolor_slot_border = "#606060" + ["editor_text_color"] = "#000000FF", + ["editor_bg_color"] = "#F0F0F0FF", -dreambuilder_theme.tooltip_bgcolor = "#A0A0A0" -dreambuilder_theme.tooltip_fontcolor = "#FFF" + ["listcolor_slot_bg_normal"] = "#FFFFFF30", + ["listcolor_slot_bg_hover"] = "#FFFFFF80", + ["listcolor_slot_border"] = "#606060", -dreambuilder_theme.window_darken = "false" -dreambuilder_theme.editor_border = "false" -dreambuilder_theme.image_button_borders = "false" + ["tooltip_bgcolor"] = "#A0A0A0", + ["tooltip_fontcolor"] = "#FFF", + + ["window_darken"] = "false", + ["editor_border"] = "false", + ["image_button_borders"] = "false" +} + +for k,v in pairs(dreambuilder_theme.light) do + dreambuilder_theme[k] = v +end + +minetest.register_on_joinplayer(function(player) + default.gui_bg = dreambuilder_theme.get_default_gui_bg(dreambuilder_theme) + default.gui_survival_form = dreambuilder_theme.get_default_gui_survival_form(dreambuilder_theme) + dreambuilder_theme.set_formspec_prepend(player, dreambuilder_theme) +end) diff --git a/mods/dreambuilder_theme_settings/init.lua b/mods/dreambuilder_theme_settings/init.lua index 88fe1635..27180d61 100644 --- a/mods/dreambuilder_theme_settings/init.lua +++ b/mods/dreambuilder_theme_settings/init.lua @@ -4,9 +4,13 @@ -- and instead add a whole theme mod to override the colors and images -- supplied by this component. -- --- Theme mods should depend on this mod to inherit the user's color --- settings from their minetest.conf. This mod in turn depends on --- `dreambuilder_theme_functions` for its global table. +-- Theme mods need to depend on this mod to inherit the user's color +-- settings and selected theme from their minetest.conf. This mod in turn +-- depends on `dreambuilder_theme_functions` for its global table. + +-- This mod just supplies helpers to build slot backgrounds for mods that use formspec v1 + +dreambuilder_theme = {} dreambuilder_theme.form_bgcolor = minetest.settings:get("dreambuilder_theme_form_bgcolor") dreambuilder_theme.btn_color = minetest.settings:get("dreambuilder_theme_btn_color") @@ -23,3 +27,76 @@ dreambuilder_theme.tooltip_fontcolor = minetest.settings:get("dreambuilde dreambuilder_theme.window_darken = minetest.settings:get_bool("dreambuilder_theme_window_darken") and "true" or "false" dreambuilder_theme.editor_border = minetest.settings:get_bool("dreambuilder_theme_editor_border") and "true" or "false" dreambuilder_theme.image_button_borders = minetest.settings:get_bool("dreambuilder_theme_image_button_borders") and "true" or "false" + +dreambuilder_theme.name = minetest.settings:get("dreambuilder_theme_name") + +if not dreambuilder_theme.name or dreambuilder_theme.name == "" then + dreambuilder_theme.name = "dbtheme_light" +end + +function dreambuilder_theme.single_slot_v1(xpos, ypos, bright) + return string.format("background9[%f,%f;%f,%f;%s_ui_single_slot%s.png;false;16]", + xpos, ypos, 1, 1.08, dreambuilder_theme.name, (bright and "_bright" or "") ) +end + +function dreambuilder_theme.make_inv_img_grid_v1(xpos, ypos, width, height, bright) + local tiled = {} + local n=1 + for y = 0, (height - 1) do + for x = 0, (width -1) do + tiled[n] = dreambuilder_theme.single_slot_v1(xpos + x, ypos + y, bright) + n = n + 1 + end + end + return table.concat(tiled) +end + +-- copied shamelessly from default ;-) + +function dreambuilder_theme.get_default_gui_bg(theme) + return "bgcolor["..theme.form_bgcolor..";"..theme.window_darken.."]" +end + +function dreambuilder_theme.get_default_gui_survival_form(theme) + return "size[8,8.5]".. + dreambuilder_theme.get_default_gui_bg(theme).. + "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]" +end + +function dreambuilder_theme.set_formspec_prepend(player, theme) + -- Set formspec prepend + local formspec = + default.gui_bg.. + "listcolors["..theme.listcolor_slot_bg_normal.. + ";"..theme.listcolor_slot_bg_hover.. + ";"..theme.listcolor_slot_border.. + ";"..theme.tooltip_bgcolor.. + ";"..theme.tooltip_fontcolor.."]".. + "style_type[button;bgcolor="..theme.btn_color.."]".. + "style_type[button_exit;bgcolor="..theme.btn_color.."]".. + "style_type[image_button;bgcolor="..theme.btn_color.. + ";border="..theme.image_button_borders.."]".. + "style_type[image_button_exit;bgcolor="..theme.btn_color.. + ";border="..theme.image_button_borders.."]".. + "style_type[item_image_button;bgcolor="..theme.btn_color.. + ";border="..theme.image_button_borders.."]" + local name = player:get_player_name() + local info = minetest.get_player_information(name) + if info.formspec_version > 1 then + formspec = formspec .. "background9[5,5;1,1;"..theme.name.."_gui_formbg.png;true;10]" + else + formspec = formspec .. "background[5,5;1,1;"..theme.name.."_gui_formbg.png;true]" + end + player:set_formspec_prepend(formspec) + + print(dump(formspec)) + -- Set hotbar textures + player:hud_set_hotbar_image("gui_hotbar.png") + player:hud_set_hotbar_selected_image("gui_hotbar_selected.png") +end diff --git a/mods/dreambuilder_theme_settings/mod.conf b/mods/dreambuilder_theme_settings/mod.conf index 92171ae1..a73d89f8 100644 --- a/mods/dreambuilder_theme_settings/mod.conf +++ b/mods/dreambuilder_theme_settings/mod.conf @@ -1,3 +1,2 @@ name = dreambuilder_theme_settings description = formspec/window theming mod -depends = dreambuilder_theme_functions diff --git a/mods/mesecons_luacontroller/init.lua b/mods/mesecons_luacontroller/init.lua index 4bb4c48a..b6118c33 100644 --- a/mods/mesecons_luacontroller/init.lua +++ b/mods/mesecons_luacontroller/init.lua @@ -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="..dreambuilder_theme.editor_text_color..";border="..dreambuilder_theme.editor_border.."]" + .."style_type[textarea;textcolor="..dreambuilder_theme.editor_text_color..";border=false]" .."background[-0.2,-0.25;12.4,10.75;"..dreambuilder_theme.name.."_jeija_luac_background.png]" .."label[0.1,8.3;"..errmsg.."]" .."textarea[0.2,0.2;12.2,9.5;code;;"..code.."]" diff --git a/mods/unified_inventory/internal.lua b/mods/unified_inventory/internal.lua index 6c033107..c1d50573 100644 --- a/mods/unified_inventory/internal.lua +++ b/mods/unified_inventory/internal.lua @@ -43,7 +43,7 @@ function ui.get_formspec(player, page) local formspec = { "formspec_version[4]size[17.75,12.25]", - pagedef.formspec_prepend and "" or "no_prepend[]", + "no_prepend[]"..default.gui_bg, ui.standard_background -- Background } local n = 4 diff --git a/settingtypes.txt b/settingtypes.txt index 0187c556..8ecb2574 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -78,50 +78,7 @@ enable_weather (Enable weather) bool true # Theme settings: -# Formspecs will use this color for the background if for some reason the -# standard background image either doesn't show on a particular form, or if a -#form uses one with transparent parts. -dreambuilder_theme_form_bgcolor (Dreambuilder theme, fallback form background color) string `#F0F0F0FF - -# Plain text buttons will be this color -dreambuilder_theme_btn_color (Dreambuilder theme, text button color) string #B0B0B0FF - -# Mods that use an editable "textarea" widget will have this for the font -# color on top of whatever text drop shadow Minetest is configured to show. -dreambuilder_theme_editor_text_color (Dreambuilder theme, textarea font color) string #000000FF - -# Mods that use an editable "textarea" widget but lack a background image will -# use this for the background color. -dreambuilder_theme_editor_bg_color (Dreambuilder theme, textarea background color) string #F0F0F0FF - -# On forms that have inventory slots but which don't use background image, -# this color will be used for the slots. -dreambuilder_theme_listcolor_slot_bg_normal (Dreambuilder theme, inventory slot main color) string #FFFFFF30 - -# On forms that have inventory slots, this color will be used when hovering -#the mouse over a slot. -dreambuilder_theme_listcolor_slot_bg_hover (Dreambuilder theme, inventory slot mouseover color) string #E0E0E0 - -# On forms that have inventory slots but which don't use background image, -# this color will be used for the slots' borders. -dreambuilder_theme_listcolor_slot_border (Dreambuilder theme, inventory slot border color) string #606060 - -# Where possible, tooltips will use this background color. -dreambuilder_theme_tooltip_bgcolor (Dreambuilder theme, tooltip background color) string #A0A0A0 - -# Where possible, tooltips' font will use this color, on top of whatever drop -# shadow is configured for Minetest in general. -dreambuilder_theme_tooltip_fontcolor (Dreambuilder theme, tooltip font color) string #FFF - -# If this is set to true, all forms/GUI will darken the rest of the window -# when they are shown. -dreambuilder_theme_window_darken (Dreambuilder theme, formspecs darken the whole window) bool false - -# If this is set to true, editable textarea widgets will be given a dark -# border. -dreambuilder_theme_editor_border (Dreambuilder theme, textarea border) bool false - -# If this is set to true, standard image buttons will have a dark, hardcoded -# gradient background. If false, buttons will have a relatively flat -# background color instead. -dreambuilder_theme_image_button_borders (Dreambuilder theme, use dark image button background) bool false +# This sets which theme to use out of those that are installed. Name +# will usually be in the form of "dbtheme_something". Dreambuilder will look +# for and apply textures and settings based on it. +dreambuilder_theme.name (Dreambuilder theme, name) string dbtheme_light