From 3c4734d69a44aea133e5bd7df66a5dedb87785fb Mon Sep 17 00:00:00 2001 From: Kahrl Date: Tue, 20 Aug 2013 22:38:14 +0200 Subject: Change mainmenu texture handling + small misc changes Texture names must now be escaped in formspec elements image[], background[], image_button[], image_button_exit[]. Instead of special-case handling of texture loading (and unloading which was missing) in guiFormSpecMenu.cpp, use the newly created ISimpleTextureSource interface which is a minimal subset of ITextureSource. There is an implementation of this interface used by GUIEngine (MenuTextureSource). Fix an off-by-one bug in unescape_string; it caused requests for a texture called "\0". --- builtin/gamemgr.lua | 6 ++++-- builtin/mainmenu.lua | 5 +++-- builtin/mm_menubar.lua | 5 +++-- builtin/modstore.lua | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) (limited to 'builtin') diff --git a/builtin/gamemgr.lua b/builtin/gamemgr.lua index 8409bff03..7a5e9790f 100644 --- a/builtin/gamemgr.lua +++ b/builtin/gamemgr.lua @@ -225,7 +225,8 @@ function gamemgr.tab() if current_game.menuicon_path ~= nil and current_game.menuicon_path ~= "" then retval = retval .. - "image[5.8,-0.25;2,2;" .. current_game.menuicon_path .. "]" + "image[5.8,-0.25;2,2;" .. + engine.formspec_escape(current_game.menuicon_path) .. "]" end retval = retval .. @@ -251,7 +252,8 @@ function gamemgr.dialog_edit_game() if current_game.menuicon_path ~= nil and current_game.menuicon_path ~= "" then retval = retval .. - "image[5.25,0;2,2;" .. current_game.menuicon_path .. "]" + "image[5.25,0;2,2;" .. + engine.formspec_escape(current_game.menuicon_path) .. "]" end retval = retval .. diff --git a/builtin/mainmenu.lua b/builtin/mainmenu.lua index 787a5e280..5a1b6e929 100644 --- a/builtin/mainmenu.lua +++ b/builtin/mainmenu.lua @@ -1047,16 +1047,17 @@ function tabbuilder.tab_texture_packs() return retval .. menu.render_texture_pack_list(list) .. ";" .. index .. "]" .. - "image[0.65,0.25;4.0,3.7;"..(screenfile or no_screenshot).."]".. + "image[0.65,0.25;4.0,3.7;"..engine.formspec_escape(screenfile or no_screenshot).."]".. "textarea[1.0,3.25;3.7,1.5;;"..engine.formspec_escape(infotext or "")..";]" end -------------------------------------------------------------------------------- function tabbuilder.tab_credits() + local logofile = menu.defaulttexturedir .. "logo.png" return "vertlabel[0,-0.5;CREDITS]" .. "label[0.5,3;Minetest " .. engine.get_version() .. "]" .. "label[0.5,3.3;http://minetest.net]" .. - "image[0.5,1;" .. menu.defaulttexturedir .. "logo.png]" .. + "image[0.5,1;" .. engine.formspec_escape(logofile) .. "]" .. "textlist[3.5,-0.25;8.5,5.8;list_credits;" .. "#FFFF00" .. fgettext("Core Developers") .."," .. "Perttu Ahola (celeron55) ,".. diff --git a/builtin/mm_menubar.lua b/builtin/mm_menubar.lua index faba92a8f..c3ddbb289 100644 --- a/builtin/mm_menubar.lua +++ b/builtin/mm_menubar.lua @@ -51,7 +51,8 @@ function menubar.refresh() menubar.formspec = menubar.formspec .. "image_button[" .. buttonpos .. ",5.7;1.3,1.3;" .. - gamemgr.games[i].menuicon_path .. ";" .. btn_name .. ";;true;false]" + engine.formspec_escape(gamemgr.games[i].menuicon_path) .. ";" .. + btn_name .. ";;true;false]" else local part1 = gamemgr.games[i].id:sub(1,5) @@ -75,4 +76,4 @@ function menubar.refresh() table.insert(menubar.buttons,toadd) end -end \ No newline at end of file +end diff --git a/builtin/modstore.lua b/builtin/modstore.lua index 2f967c9b1..43f7759ad 100644 --- a/builtin/modstore.lua +++ b/builtin/modstore.lua @@ -227,7 +227,7 @@ function modstore.getmodlist(list) end retval = retval .. "image[0,".. screenshot_ypos .. ";3,2;" .. - list.data[i].texturename .. "]" + engine.formspec_escape(list.data[i].texturename) .. "]" --title + author retval = retval .."label[2.75," .. screenshot_ypos .. ";" .. -- cgit v1.2.3