1
0

Yet another MainMenu improvements PR (#101)

* Yet another improvements instead of a complete redo

Co-authored-by: luk3yx <luk3yx@users.noreply.github.com>
This commit is contained in:
Maksym H 2022-11-13 17:44:48 +01:00
parent 3ce839dc11
commit 3d33abf1cd
77 changed files with 495 additions and 316 deletions

View File

@ -16,8 +16,6 @@
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
local defaulttexturedir = core.formspec_escape(defaulttexturedir)
local function buttonbar_formspec(self) local function buttonbar_formspec(self)
if self.hidden then if self.hidden then
@ -25,7 +23,7 @@ local function buttonbar_formspec(self)
end end
local formspec = string.format("background9[%f,%f;%f,%f;%sside_menu_left.png;false;30]", local formspec = string.format("background9[%f,%f;%f,%f;%sside_menu_left.png;false;30]",
self.pos.x, self.pos.y - 0.1, self.size.x + 0.025, self.size.y + 0.35, defaulttexturedir) self.pos.x, self.pos.y - 0.1, self.size.x + 0.025, self.size.y + 0.35, defaulttexturedir_esc)
for i=self.startbutton,#self.buttons,1 do for i=self.startbutton,#self.buttons,1 do
local btn_name = self.buttons[i].name local btn_name = self.buttons[i].name
@ -62,8 +60,8 @@ local function buttonbar_formspec(self)
if button.cdb then if button.cdb then
formspec = formspec .. formspec = formspec ..
"style[" .. btn_name .. ";bgimg=" .. defaulttexturedir .. "style[" .. btn_name .. ";bgimg=" .. defaulttexturedir_esc ..
"btn_download.png;bgimg_hovered=" .. defaulttexturedir .. "btn_download_hover.png]" .. "btn_download.png;bgimg_hovered=" .. defaulttexturedir_esc .. "btn_download_hover.png]" ..
("image_button[%f,%f;%f,%f;;%s;%s;true;%s]tooltip[%s;%s]"):format( ("image_button[%f,%f;%f,%f;;%s;%s;true;%s]tooltip[%s;%s]"):format(
btn_pos.x, btn_pos.y, self.btn_size, self.btn_size, btn_pos.x, btn_pos.y, self.btn_size, self.btn_size,
@ -120,15 +118,15 @@ local function buttonbar_formspec(self)
self.name, text_inc) self.name, text_inc)
else else
formspec = formspec .. formspec = formspec ..
"style[btnbar_dec_" .. self.name .. ";bgimg=" .. defaulttexturedir .. "style[btnbar_dec_" .. self.name .. ";bgimg=" .. defaulttexturedir_esc ..
"btn_up.png;bgimg_hovered=" .. defaulttexturedir .. "btn_up_hover.png]" .. "btn_up.png;bgimg_hovered=" .. defaulttexturedir_esc .. "btn_up_hover.png]" ..
("image_button[%f,%f;%f,%f;;btnbar_dec_%s;;true;false]"):format( ("image_button[%f,%f;%f,%f;;btnbar_dec_%s;;true;false]"):format(
btn_dec_pos.x, btn_dec_pos.y, btn_size.x, btn_size.y, btn_dec_pos.x, btn_dec_pos.y, btn_size.x, btn_size.y,
self.name) self.name)
formspec = formspec .. formspec = formspec ..
"style[btnbar_inc_" .. self.name .. ";bgimg=" .. defaulttexturedir .. "style[btnbar_inc_" .. self.name .. ";bgimg=" .. defaulttexturedir_esc ..
"btn_down.png;bgimg_hovered=" .. defaulttexturedir .. "btn_down_hover.png]" .. "btn_down.png;bgimg_hovered=" .. defaulttexturedir_esc .. "btn_down_hover.png]" ..
("image_button[%f,%f;%f,%f;;btnbar_inc_%s;;true;false]"):format( ("image_button[%f,%f;%f,%f;;btnbar_inc_%s;;true;false]"):format(
btn_inc_pos.x, btn_inc_pos.y, btn_size.x, btn_size.y, btn_inc_pos.x, btn_inc_pos.y, btn_size.x, btn_size.y,
self.name) self.name)

View File

@ -50,7 +50,7 @@ local dialog_metatable = {
} }
dialog_metatable.__index = dialog_metatable dialog_metatable.__index = dialog_metatable
local bg = core.formspec_escape(defaulttexturedir .. "bg_common.png") local bg = defaulttexturedir_esc .. "bg_common.png"
function dialog_create(name, get_formspec, buttonhandler, eventhandler, add_background) function dialog_create(name, get_formspec, buttonhandler, eventhandler, add_background)
local self = {} local self = {}
@ -62,7 +62,7 @@ function dialog_create(name, get_formspec, buttonhandler, eventhandler, add_back
if add_background then if add_background then
function self.formspec(data) function self.formspec(data)
return ([[ return ([[
size[12,5.4,false] size[12,5.4]
bgcolor[#0000] bgcolor[#0000]
background9[0,0;0,0;%s;true;40] background9[0,0;0,0;%s;true;40]
%s %s
@ -87,8 +87,9 @@ function messagebox(name, message)
return ([[ return ([[
set_focus[ok;true] set_focus[ok;true]
textarea[1,1;10,4;;;%s] textarea[1,1;10,4;;;%s]
%s
button[5,4.5;2,0.8;ok;%s] button[5,4.5;2,0.8;ok;%s]
]]):format(message, fgettext("OK")) ]]):format(message, btn_style("ok"), fgettext("OK"))
end, end,
function(this, fields) function(this, fields)
if fields.ok then if fields.ok then

View File

@ -26,8 +26,6 @@
-- element.getFormspec() returns formspec of tabview -- -- element.getFormspec() returns formspec of tabview --
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local defaulttexturedir = core.formspec_escape(defaulttexturedir)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local function add_tab(self,tab) local function add_tab(self,tab)
assert(tab.size == nil or (type(tab.size) == table and assert(tab.size == nil or (type(tab.size) == table and
@ -72,12 +70,12 @@ end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local function make_side_pane_tab(y, tab_name, tooltip, selected) local function make_side_pane_tab(y, tab_name, tooltip, selected)
local formspec = "style[" .. tab_name .. "_tab;bgimg=" .. local formspec = "style[" .. tab_name .. "_tab;bgimg=" ..
defaulttexturedir .. tab_name defaulttexturedir_esc .. tab_name
if selected then if selected then
formspec = formspec .. "_menu_selected.png]" formspec = formspec .. "_menu_selected.png]"
else else
formspec = formspec .. "_menu.png;bgimg_hovered=" .. formspec = formspec .. "_menu.png;bgimg_hovered=" ..
defaulttexturedir .. tab_name .. "_menu_hover.png]" defaulttexturedir_esc .. tab_name .. "_menu_hover.png]"
end end
return formspec .. return formspec ..
@ -98,14 +96,15 @@ local function get_formspec(self)
string.format("size[%f,%f,%s]",tsize.width + 2,tsize.height + 1, string.format("size[%f,%f,%s]",tsize.width + 2,tsize.height + 1,
dump(self.fixed_size)) .. dump(self.fixed_size)) ..
"bgcolor[#0000]" .. "bgcolor[#0000]" ..
"listcolors[#000;#000;#000;#dff6f5;#302c2e]" ..
"container[1,1]" .. "container[1,1]" ..
"background9[-0.2,-1.26;" .. tsize.width + 0.4 .. "," .. "background9[-0.2,-1.26;" .. tsize.width + 0.4 .. "," ..
tsize.height + 1.75 .. ";" .. defaulttexturedir .. tsize.height + 1.75 .. ";" .. defaulttexturedir_esc ..
"bg_common.png;false;40]" .. "bg_common.png;false;40]" ..
"background9[12.13,1.05;0.9,2.6;" .. defaulttexturedir .. "side_menu.png;false;30]" .. "background9[12.13,1.05;0.9,2.6;" .. defaulttexturedir_esc .. "side_menu.png;false;30]" ..
make_side_pane_tab(0.9, "settings", fgettext("Settings"), name == "settings") .. make_side_pane_tab(0.9, "settings", fgettext("Settings"), name == "settings") ..
"image[12.15,2.26;0.9,0.06;" .. defaulttexturedir .. "side_menu_divider.png]" .. "image[12.15,2.26;0.9,0.06;" .. defaulttexturedir_esc .. "side_menu_divider.png]" ..
make_side_pane_tab(2.3, "authors", fgettext("Credits"), name == "credits") make_side_pane_tab(2.3, "authors", fgettext("Credits"), name == "credits")
end end
@ -207,27 +206,28 @@ end]]
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local function button_header(self) local function button_header(self)
local visible_tabs = {} local visible_tabs = {}
local btn_widths = {} -- local btn_widths = {}
local total_width = 0 -- local total_width = 0
for i, tab in ipairs(self.tablist) do for i, tab in ipairs(self.tablist) do
if not tab.hidden and tab.caption ~= "" then if not tab.hidden and tab.caption ~= "" then
visible_tabs[#visible_tabs + 1] = tab visible_tabs[#visible_tabs + 1] = tab
local w = utf8.len(core.get_translated_string(tab.caption)) -- local w = math.max(utf8.len(core.get_translated_string(tab.caption)), 10)
btn_widths[#visible_tabs] = w -- btn_widths[#visible_tabs] = w
total_width = total_width + w -- total_width = total_width + w
end end
end end
local toadd = "" local toadd = ""
local coords_per_char = 12 / total_width -- local coords_per_char = 12 / total_width
-- The formspec is 15.4875 "real" coordinates wide -- The formspec is 15.4875 "real" coordinates wide
-- local x = (12.39 - total_width) / 2 - 0.3 -- local x = (12.39 - total_width) / 2 - 0.3
local x = -0.1 local x = -0.1
local w = 12 / #visible_tabs
for i = 1, #visible_tabs do for i = 1, #visible_tabs do
local caption = visible_tabs[i].caption local caption = visible_tabs[i].caption
local w = btn_widths[i] * coords_per_char -- local w = btn_widths[i] * coords_per_char
local texture = "upper_buttons_middle" local texture = "upper_buttons_middle"
if i == 1 then if i == 1 then
texture = "upper_buttons_left" texture = "upper_buttons_left"
@ -236,13 +236,13 @@ local function button_header(self)
end end
local btn_name = self.name .. "_" .. i local btn_name = self.name .. "_" .. i
toadd = toadd .. toadd = toadd ..
"style[" .. btn_name .. ";padding=-10;bgimg=" .. defaulttexturedir .. "style[" .. btn_name .. ";padding=-10;bgimg=" .. defaulttexturedir_esc ..
texture texture
if i == math.abs(self.last_tab_index) then if i == math.abs(self.last_tab_index) then
toadd = toadd .. "_selected.png;" toadd = toadd .. "_selected.png;"
else else
toadd = toadd .. ".png;bgimg_hovered=" .. defaulttexturedir .. toadd = toadd .. ".png;bgimg_hovered=" .. defaulttexturedir_esc ..
texture .. "_hover.png;" texture .. "_hover.png;"
end end
@ -293,7 +293,7 @@ local function handle_tab_buttons(self,fields)
for field in pairs(fields) do for field in pairs(fields) do
if field:sub(1, name_prefix_len) == name_prefix then if field:sub(1, name_prefix_len) == name_prefix then
local index = tonumber(field:sub(name_prefix_len + 1)) local index = tonumber(field:sub(name_prefix_len + 1))
if self.last_tab_index == index then return false end if math.abs(self.last_tab_index) == index then return false end
switch_to_tab(self, index) switch_to_tab(self, index)
return true return true
end end

View File

@ -71,14 +71,16 @@ function ui.update()
"formspec_version[3]", "formspec_version[3]",
"size[14,8.25]", "size[14,8.25]",
"bgcolor[#0000]", "bgcolor[#0000]",
"background9[0,0;0,0;" .. core.formspec_escape(defaulttexturedir .. "background9[0,0;0,0;", defaulttexturedir_esc, "bg_common.png;true;40]",
"bg_common.png") .. ";true;40]",
"set_focus[btn_reconnect_yes;true]", "set_focus[btn_reconnect_yes;true]",
"box[0.5,1.2;13,5;#000]", "textarea[0.6,0.5;12.8,0.6;;;", fgettext("The server has requested a reconnect:"), "]",
("textarea[0.5,1.2;13,5;;%s;%s]"):format( "background9[0.4,1.1;13.2,5.2;", defaulttexturedir_esc,
fgettext("The server has requested a reconnect:"), error_message), "worldlist_bg.png;false;40]",
"button[2,6.6;4,1;btn_reconnect_yes;" .. fgettext("Reconnect") .. "]", "textarea[0.6,1.3;12.8,4.8;;;", error_message, "]",
"button[8,6.6;4,1;btn_reconnect_no;" .. fgettext("Main menu") .. "]" btn_style("btn_reconnect_yes") ..
"button[2,6.725;4,1;btn_reconnect_yes;" .. fgettext("Reconnect") .. "]",
btn_style("btn_reconnect_no") ..
"button[8,6.725;4,1;btn_reconnect_no;" .. fgettext("Main menu") .. "]"
} }
ui.overridden = true ui.overridden = true
elseif gamedata ~= nil and gamedata.errormessage ~= nil then elseif gamedata ~= nil and gamedata.errormessage ~= nil then
@ -95,23 +97,26 @@ function ui.update()
if (maintab == "local" or maintab == "local_default") and mod_error and if (maintab == "local" or maintab == "local_default") and mod_error and
core.get_us_time() - connect_time > 30 then core.get_us_time() - connect_time > 30 then
restart_btn = restart_btn =
"button[2,6.6;4,1;btn_reconnect_yes;" .. fgettext("Restart") .. "]" .. btn_style("btn_reconnect_yes") ..
"button[8,6.6;4,1;btn_reconnect_no;" .. fgettext("Main menu") .. "]" .. "button[2,6.725;4,1;btn_reconnect_yes;" .. fgettext("Restart") .. "]" ..
btn_style("btn_reconnect_no") ..
"button[8,6.725;4,1;btn_reconnect_no;" .. fgettext("Main menu") .. "]" ..
"set_focus[btn_reconnect_yes;true]" "set_focus[btn_reconnect_yes;true]"
else else
restart_btn = restart_btn =
"button[5,6.6;4,1;btn_reconnect_no;" .. fgettext("OK") .. "]" .. btn_style("btn_reconnect_no") ..
"button[5,6.725;4,1;btn_reconnect_no;" .. fgettext("OK") .. "]" ..
"set_focus[btn_reconnect_no;true]" "set_focus[btn_reconnect_no;true]"
end end
formspec = { formspec = {
"formspec_version[3]", "formspec_version[3]",
"size[14,8.25]", "size[14,8.25]",
"bgcolor[#0000]", "bgcolor[#0000]",
"background9[0,0;0,0;" .. core.formspec_escape(defaulttexturedir .. "background9[0,0;0,0;", defaulttexturedir_esc, "bg_common.png;true;40]",
"bg_common.png") .. ";true;40]", "textarea[0.6,0.5;12.8,0.6;;;", error_title, "]",
"box[0.5,1.2;13,5;#000]", "background9[0.4,1.1;13.2,5.2;", defaulttexturedir_esc,
("textarea[0.5,1.2;13,5;;%s;%s]"):format( "worldlist_bg.png;false;40]",
error_title, error_message), "textarea[0.6,1.3;12.8,4.8;;;", error_message, "]",
restart_btn restart_btn
} }
ui.overridden = true ui.overridden = true

View File

@ -300,3 +300,36 @@ function get_language_list()
return languages, language_dropdown, lang_idx, language_name_list return languages, language_dropdown, lang_idx, language_name_list
end end
--------------------------------------------------------------------------------
local device_is_tablet = core.settings:get_bool("device_is_tablet", false)
local screen_density = core.get_screen_info().density
function is_high_dpi()
if PLATFORM == "OSX" then
return tonumber(core.settings:get("screen_dpi")) / 72 >= 2
elseif PLATFORM == "iOS" and device_is_tablet then
return screen_density >= 2
else
return screen_density >= 3
end
end
--------------------------------------------------------------------------------
function btn_style(field, color)
local button_path = defaulttexturedir_esc .. "gui" .. DIR_DELIM
local btn_size = is_high_dpi() and ".x2" or ""
color = (color and "_" .. color) or ""
local retval =
"style[" .. field .. ";border=false]" ..
"style[" .. field .. ";bgimg=" .. button_path .. "gui_button" .. color .. btn_size ..
".png;bgimg_middle=" .. (is_high_dpi() and 48 or 32) .. ";padding=" .. (is_high_dpi() and -30 or -20) .. "]"
if color ~= "_gray" then
retval = retval ..
"style[" .. field .. ":hovered;bgimg=" .. button_path .. "gui_button" .. color .. "_hovered" .. btn_size ..
".png]" ..
"style[" .. field .. ":pressed;bgimg=" .. button_path .. "gui_button" .. color .. "_pressed" .. btn_size ..
".png]"
end
return retval
end

View File

@ -69,12 +69,11 @@ local function get_formspec(data)
local mod = data.list:get_list()[data.selected_mod] or {name = ""} local mod = data.list:get_list()[data.selected_mod] or {name = ""}
local retval = local retval =
"size[11.5,7.5,false]" .. "size[11.5,7.5]" ..
"bgcolor[#0000]" .. "bgcolor[#0000]" ..
"background9[0,0;0,0;" .. core.formspec_escape(defaulttexturedir .. "background9[0,0;0,0;" .. defaulttexturedir_esc .. "bg_common.png;true;40]" ..
"bg_common.png") .. ";true;40]" .. "background9[0.05,0.05;5.3,6.8;" .. defaulttexturedir_esc .. "desc_bg.png;false;32]" ..
"label[0.5,0;" .. fgettext("World:") .. "]" .. "label[0.1,0;" .. fgettext("World:") .. " " .. data.worldspec.name .. "]"
"label[1.75,0;" .. data.worldspec.name .. "]"
if mod.is_modpack or mod.type == "game" then if mod.is_modpack or mod.type == "game" then
local info = core.formspec_escape( local info = core.formspec_escape(
@ -87,56 +86,59 @@ local function get_formspec(data)
end end
end end
retval = retval .. retval = retval ..
"textarea[0.25,0.7;5.75,7.2;;" .. info .. ";]" "textarea[0.4,0.8;5.2,6.8;;" ..
fgettext("Information:") .. ";" .. info .. "]"
else else
local hard_deps, soft_deps = pkgmgr.get_dependencies(mod.path) local hard_deps, soft_deps = pkgmgr.get_dependencies(mod.path)
local hard_deps_str = table.concat(hard_deps, ",") local hard_deps_str = table.concat(hard_deps, ",")
local soft_deps_str = table.concat(soft_deps, ",") local soft_deps_str = table.concat(soft_deps, ",")
retval = retval .. retval = retval ..
"label[0,0.7;" .. fgettext("Mod:") .. "]" .. "label[0.1,0.7;" .. fgettext("Mod:") .. " " .. mod.name .. "]"
"label[0.75,0.7;" .. mod.name .. "]"
if hard_deps_str == "" then if hard_deps_str == "" then
if soft_deps_str == "" then if soft_deps_str == "" then
retval = retval .. retval = retval ..
"label[0,1.25;" .. "label[0.1,1.25;" ..
fgettext("No (optional) dependencies") .. "]" fgettext("No (optional) dependencies") .. "]"
else else
retval = retval .. retval = retval ..
"label[0,1.25;" .. fgettext("No hard dependencies") .. "label[0.1,1.25;" .. fgettext("No hard dependencies") ..
"]" .. "]" ..
"label[0,1.75;" .. fgettext("Optional dependencies:") .. "label[0.1,1.75;" .. fgettext("Optional dependencies:") ..
"]" .. "]" ..
"textlist[0,2.25;5,4;world_config_optdepends;" .. "textlist[0.1,2.25;5,4;world_config_optdepends;" ..
soft_deps_str .. ";0]" soft_deps_str .. ";0]"
end end
else else
if soft_deps_str == "" then if soft_deps_str == "" then
retval = retval .. retval = retval ..
"label[0,1.25;" .. fgettext("Dependencies:") .. "]" .. "label[0.1,1.25;" .. fgettext("Dependencies:") .. "]" ..
"textlist[0,1.75;5,4;world_config_depends;" .. "textlist[0.1,1.75;5,4;world_config_depends;" ..
hard_deps_str .. ";0]" .. hard_deps_str .. ";0]" ..
"label[0,6;" .. fgettext("No optional dependencies") .. "]" "label[0.1,6;" .. fgettext("No optional dependencies") .. "]"
else else
retval = retval .. retval = retval ..
"label[0,1.25;" .. fgettext("Dependencies:") .. "]" .. "label[0.1,1.25;" .. fgettext("Dependencies:") .. "]" ..
"textlist[0,1.75;5,2.125;world_config_depends;" .. "textlist[0.1,1.75;5,2.125;world_config_depends;" ..
hard_deps_str .. ";0]" .. hard_deps_str .. ";0]" ..
"label[0,3.9;" .. fgettext("Optional dependencies:") .. "label[0.1,3.9;" .. fgettext("Optional dependencies:") ..
"]" .. "]" ..
"textlist[0,4.375;5,1.8;world_config_optdepends;" .. "textlist[0.1,4.375;5,1.8;world_config_optdepends;" ..
soft_deps_str .. ";0]" soft_deps_str .. ";0]"
end end
end end
end end
retval = retval .. retval = retval ..
"button[3.25,7;2.5,0.5;btn_config_world_save;" .. btn_style("btn_config_world_save") ..
"button[5.5,7.1;3,0.5;btn_config_world_save;" ..
fgettext("Save") .. "]" .. fgettext("Save") .. "]" ..
"button[5.75,7;2.5,0.5;btn_config_world_cancel;" .. btn_style("btn_config_world_cancel") ..
"button[8.5,7.1;3,0.5;btn_config_world_cancel;" ..
fgettext("Cancel") .. "]" .. fgettext("Cancel") .. "]" ..
"button[9,7;2.5,0.5;btn_config_world_cdb;" .. btn_style("btn_config_world_cdb") ..
"button[-0.05,7.1;3.5,0.5;btn_config_world_cdb;" ..
fgettext("Find More Mods") .. "]" fgettext("Find More Mods") .. "]"
if mod.name ~= "" and not mod.is_game_content then if mod.name ~= "" and not mod.is_game_content then
@ -144,26 +146,30 @@ local function get_formspec(data)
if pkgmgr.is_modpack_entirely_enabled(data, mod.name) then if pkgmgr.is_modpack_entirely_enabled(data, mod.name) then
retval = retval .. retval = retval ..
"button[5.5,0.125;3,0.5;btn_mp_disable;" .. btn_style("btn_mp_disable") ..
"button[5.5,0.025;3,0.5;btn_mp_disable;" ..
fgettext("Disable modpack") .. "]" fgettext("Disable modpack") .. "]"
else else
retval = retval .. retval = retval ..
"button[5.5,0.125;3,0.5;btn_mp_enable;" .. btn_style("btn_mp_enable") ..
"button[5.5,0.025;3,0.5;btn_mp_enable;" ..
fgettext("Enable modpack") .. "]" fgettext("Enable modpack") .. "]"
end end
else else
retval = retval .. retval = retval ..
"checkbox[5.5,-0.125;cb_mod_enable;" .. fgettext("enabled") .. "checkbox[5.5,-0.125;cb_mod_enable;" .. fgettext("Enabled") ..
";" .. tostring(mod.enabled) .. "]" ";" .. tostring(mod.enabled) .. "]"
end end
end end
if enabled_all then if enabled_all then
retval = retval .. retval = retval ..
"button[8.95,0.125;2.5,0.5;btn_disable_all_mods;" .. btn_style("btn_disable_all_mods") ..
"button[8.95,0.025;2.5,0.5;btn_disable_all_mods;" ..
fgettext("Disable all") .. "]" fgettext("Disable all") .. "]"
else else
retval = retval .. retval = retval ..
"button[8.95,0.125;2.5,0.5;btn_enable_all_mods;" .. btn_style("btn_enable_all_mods") ..
"button[8.95,0.025;2.5,0.5;btn_enable_all_mods;" ..
fgettext("Enable all") .. "]" fgettext("Enable all") .. "]"
end end
return retval .. return retval ..

View File

@ -15,6 +15,8 @@
--with this program; if not, write to the Free Software Foundation, Inc., --with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
local esc = core.formspec_escape
if not core.get_http_api then if not core.get_http_api then
function create_store_dlg() function create_store_dlg()
return messagebox("store", return messagebox("store",
@ -104,9 +106,6 @@ local function start_install(package)
elseif package.type == "game" then elseif package.type == "game" then
conf_path = path .. DIR_DELIM .. "game.conf" conf_path = path .. DIR_DELIM .. "game.conf"
name_is_title = true name_is_title = true
ui.childlist = {}
menudata.init_tabs()
elseif package.type == "txp" then elseif package.type == "txp" then
conf_path = path .. DIR_DELIM .. "texture_pack.conf" conf_path = path .. DIR_DELIM .. "texture_pack.conf"
end end
@ -325,7 +324,7 @@ function install_dialog.get_formspec()
selected_game_idx = i selected_game_idx = i
end end
games[i] = core.formspec_escape(games[i].name) games[i] = esc(games[i].name)
end end
local selected_game = pkgmgr.games[selected_game_idx] local selected_game = pkgmgr.games[selected_game_idx]
@ -336,7 +335,7 @@ function install_dialog.get_formspec()
local formatted_deps = {} local formatted_deps = {}
for _, dep in pairs(install_dialog.dependencies) do for _, dep in pairs(install_dialog.dependencies) do
formatted_deps[#formatted_deps + 1] = "#fff" formatted_deps[#formatted_deps + 1] = "#fff"
formatted_deps[#formatted_deps + 1] = core.formspec_escape(dep.name) formatted_deps[#formatted_deps + 1] = esc(dep.name)
if dep.installed then if dep.installed then
formatted_deps[#formatted_deps + 1] = "#ccf" formatted_deps[#formatted_deps + 1] = "#ccf"
formatted_deps[#formatted_deps + 1] = fgettext("Already installed") formatted_deps[#formatted_deps + 1] = fgettext("Already installed")
@ -368,8 +367,9 @@ function install_dialog.get_formspec()
local formspec = { local formspec = {
"formspec_version[3]", "formspec_version[3]",
"size[7,7.85]", "size[7,7.85]",
"bgcolor[#0000]",
"background9[0,0;0,0;", defaulttexturedir_esc, "bg_common.png", ";true;40]",
"style[title;border=false]", "style[title;border=false]",
"box[0,0;7,0.5;#3333]",
"button[0,0;7,0.5;title;", fgettext("Install $1", package.title) , "]", "button[0,0;7,0.5;title;", fgettext("Install $1", package.title) , "]",
"container[0.375,0.70]", "container[0.375,0.70]",
@ -388,13 +388,13 @@ function install_dialog.get_formspec()
fgettext("Install missing dependencies"), ";", fgettext("Install missing dependencies"), ";",
will_install_deps and "true" or "false", "]", will_install_deps and "true" or "false", "]",
"box[0,5.4;7,1.2;", message_bg, "]", "box[0.04,5.4;6.94,1.2;", message_bg, "]",
"textarea[0.375,5.5;6.25,1;;;", message, "]", "textarea[0.375,5.5;6.25,1;;;", message, "]",
"container[1.375,6.85]", btn_style("install_all"),
"button[0,0;2,0.8;install_all;", fgettext("Install"), "]", "button[0.5,6.85;2.8,0.8;install_all;", fgettext("Install"), "]",
"button[2.25,0;2,0.8;cancel;", fgettext("Cancel"), "]", btn_style("cancel"),
"container_end[]", "button[3.75,6.85;2.8,0.8;cancel;", fgettext("Cancel"), "]",
} }
return table.concat(formspec, "") return table.concat(formspec, "")
@ -455,11 +455,12 @@ local confirm_overwrite = {}
function confirm_overwrite.get_formspec() function confirm_overwrite.get_formspec()
local package = confirm_overwrite.package local package = confirm_overwrite.package
return "size[11.5,4.5,true]" .. return "size[11.5,4.5]" ..
"label[2,2;" .. "label[2,2;" ..
fgettext("\"$1\" already exists. Would you like to overwrite it?", package.name) .. "]".. fgettext("\"$1\" already exists. Would you like to overwrite it?", package.name) .. "]"..
"style[install;bgcolor=red]" .. btn_style("install", "red") ..
"button[3.25,3.5;2.5,0.5;install;" .. fgettext("Overwrite") .. "]" .. "button[3.25,3.5;2.5,0.5;install;" .. fgettext("Overwrite") .. "]" ..
btn_style("cancel") ..
"button[5.75,3.5;2.5,0.5;cancel;" .. fgettext("Cancel") .. "]" "button[5.75,3.5;2.5,0.5;cancel;" .. fgettext("Cancel") .. "]"
end end
@ -498,9 +499,9 @@ end
local function get_screenshot(package) local function get_screenshot(package)
if not package.thumbnail then if not package.thumbnail then
return defaulttexturedir .. "no_screenshot.png" return defaulttexturedir_esc .. "no_screenshot.png"
elseif screenshot_downloading[package.thumbnail] then elseif screenshot_downloading[package.thumbnail] then
return defaulttexturedir .. "loading_screenshot.png" return defaulttexturedir_esc .. "loading_screenshot.png"
end end
-- Get tmp screenshot path -- Get tmp screenshot path
@ -512,12 +513,12 @@ local function get_screenshot(package)
local file = io.open(filepath, "r") local file = io.open(filepath, "r")
if file then if file then
file:close() file:close()
return filepath return esc(filepath)
end end
-- Show error if we've failed to download before -- Show error if we've failed to download before
if screenshot_downloaded[package.thumbnail] then if screenshot_downloaded[package.thumbnail] then
return defaulttexturedir .. "error_screenshot.png" return defaulttexturedir_esc .. "error_screenshot.png"
end end
-- Download -- Download
@ -538,10 +539,10 @@ local function get_screenshot(package)
screenshot_downloading[package.thumbnail] = true screenshot_downloading[package.thumbnail] = true
else else
core.log("error", "ERROR: async event failed") core.log("error", "ERROR: async event failed")
return defaulttexturedir .. "error_screenshot.png" return defaulttexturedir_esc .. "error_screenshot.png"
end end
return defaulttexturedir .. "loading_screenshot.png" return defaulttexturedir_esc .. "loading_screenshot.png"
end end
function store.load() function store.load()
@ -703,40 +704,48 @@ function store.get_formspec(dlgdata)
if #store.packages_full > 0 then if #store.packages_full > 0 then
formspec = { formspec = {
"formspec_version[3]", "formspec_version[3]",
"size[15.75,9.5;false]", "size[15.75,9.5]",
"bgcolor[#0000]" .. "bgcolor[#0000]",
"background9[0,0;0,0;", core.formspec_escape(defaulttexturedir .. "background9[0,0;0,0;", defaulttexturedir_esc, "bg_common.png;true;40]",
"bg_common.png"), ";true;40]",
"style[status,downloading,queued;border=false]", "style[status,downloading,queued;border=false]",
"container[0.375,0.375]", "container[0.375,0.375]",
"field[0,0;7.225,0.8;search_string;;", core.formspec_escape(search_string), "]", "image[0,0;7.25,0.8;", defaulttexturedir_esc, "field_bg.png;32]",
"style[search_string;border=false;bgcolor=transparent]",
"field[0.1,0;7.15,0.8;search_string;;", esc(search_string), "]",
"field_close_on_enter[search_string;false]", "field_close_on_enter[search_string;false]",
"image_button[7.3,0;0.8,0.8;", core.formspec_escape(defaulttexturedir .. "search.png"), ";search;;true;false]", "set_focus[search_string;true]",
-- "image_button[8.125,0;0.8,0.8;", core.formspec_escape(defaulttexturedir .. "clear.png"), ";clear;;true;false]", btn_style("search"),
-- "dropdown[9.6,0;2.4,0.8;type;", table.concat(filter_types_titles, ","), ";", filter_type, "]", "image_button[7.4,0;0.8,0.8;", defaulttexturedir_esc, "search.png;search;;true;false]",
-- "image_button[8.125,0;0.8,0.8;", defaulttexturedir_esc, "clear.png;clear;;true;false]",
"dropdown[8.35,0;3.5,0.8;type;", table.concat(filter_types_titles, ","), ";", filter_type, "]",
"container_end[]", "container_end[]",
-- Page nav buttons -- Page nav buttons
"container[0,", H - 0.8 - 0.375, "]", "container[0,", H - 0.8 - 0.375, "]",
"style[back;padding=-5;bgimg=", core.formspec_escape(defaulttexturedir .. "select_btn.png"), ";bgimg_middle=10]", btn_style("back"),
"image_button[0.375,0;5,0.8;;back;", "< ", fgettext("Back to Main Menu"), ";true;false]", "button[0.375,0;5,0.8;back;< ", fgettext("Back to Main Menu"), "]",
"container[", W - 0.375 - 0.8*4 - 2, ",0]", "container[", W - 0.375 - 0.8*4 - 2, ",0]",
"image_button[0,0;0.8,0.8;", core.formspec_escape(defaulttexturedir), "start_icon.png;pstart;]", btn_style("pstart"),
"image_button[0.8,0;0.8,0.8;", core.formspec_escape(defaulttexturedir), "prev_icon.png;pback;]", "image_button[-0.1,0;0.8,0.8;", defaulttexturedir_esc, "start_icon.png;pstart;;true;false]",
btn_style("pback"),
"image_button[0.8,0;0.8,0.8;", defaulttexturedir_esc, "prev_icon.png;pback;;true;false]",
"style[pagenum;border=false]", "style[pagenum;border=false]",
"button[1.6,0;2,0.8;pagenum;", tonumber(cur_page), " / ", tonumber(dlgdata.pagemax), "]", "button[1.5,0;2,0.8;pagenum;", tonumber(cur_page), " / ", tonumber(dlgdata.pagemax), "]",
"image_button[3.6,0;0.8,0.8;", core.formspec_escape(defaulttexturedir), "next_icon.png;pnext;]", btn_style("pnext"),
"image_button[4.4,0;0.8,0.8;", core.formspec_escape(defaulttexturedir), "end_icon.png;pend;]", "image_button[3.5,0;0.8,0.8;", defaulttexturedir_esc, "next_icon.png;pnext;;true;false]",
btn_style("pend"),
"image_button[4.4,0;0.8,0.8;", defaulttexturedir_esc, "end_icon.png;pend;;true;false]",
"container_end[]", "container_end[]",
"container_end[]", "container_end[]",
} }
if number_downloading > 0 then if number_downloading > 0 then
formspec[#formspec + 1] = "button[12.75,0.375;2.625,0.8;downloading;" formspec[#formspec + 1] = "style[downloading;content_offset=0]"
formspec[#formspec + 1] = "button[12.4,0.375;3.1,0.8;downloading;"
if #download_queue > 0 then if #download_queue > 0 then
formspec[#formspec + 1] = fgettext("$1 downloading,\n$2 queued", number_downloading, #download_queue) formspec[#formspec + 1] = fgettext("$1 downloading,\n$2 queued", number_downloading, #download_queue)
else else
@ -754,32 +763,33 @@ function store.get_formspec(dlgdata)
end end
if num_avail_updates == 0 then if num_avail_updates == 0 then
formspec[#formspec + 1] = "button[12.65,0.375;2.825,0.8;status;" formspec[#formspec + 1] = "style[status;content_offset=0]"
formspec[#formspec + 1] = "button[12.4,0.375;3.1,0.8;status;"
formspec[#formspec + 1] = fgettext("No updates") formspec[#formspec + 1] = fgettext("No updates")
formspec[#formspec + 1] = "]" formspec[#formspec + 1] = "]"
else else
formspec[#formspec + 1] = "button[12.75,0.375;2.625,0.8;update_all;" formspec[#formspec + 1] = "style[update_all;content_offset=0]"
formspec[#formspec + 1] = btn_style("update_all")
formspec[#formspec + 1] = "button[12.4,0.375;3.1,0.8;update_all;"
formspec[#formspec + 1] = fgettext("Update All [$1]", num_avail_updates) formspec[#formspec + 1] = fgettext("Update All [$1]", num_avail_updates)
formspec[#formspec + 1] = "]" formspec[#formspec + 1] = "]"
end end
end end
if #store.packages == 0 then if #store.packages == 0 then
formspec[#formspec + 1] = "label[4,3;" formspec[#formspec + 1] = "style[msg;content_offset=0]"
formspec[#formspec + 1] = "image_button[1,4.25;13.75,1;;msg;"
formspec[#formspec + 1] = fgettext("No results") formspec[#formspec + 1] = fgettext("No results")
formspec[#formspec + 1] = "]" formspec[#formspec + 1] = ";false;false]"
end end
else else
formspec = { formspec = {
"size[12,6.4;false]", "size[12,6.4]",
"bgcolor[#0000]" .. "bgcolor[#0000]",
"background9[0,0;0,0;", core.formspec_escape(defaulttexturedir .. "background9[0,0;0,0;", defaulttexturedir_esc, "bg_common.png;true;40]",
"bg_common.png"), ";true;40]",
"label[4,3;", fgettext("No packages could be retrieved"), "]", "label[4,3;", fgettext("No packages could be retrieved"), "]",
"container[0,", H - 0.8 - 0.375 - 2, "]", btn_style("back"),
"style[back;padding=-5;bgimg=", core.formspec_escape(defaulttexturedir .. "select_btn.png"), ";bgimg_middle=10]", "button[0-0.11,5.8;5.5,0.9;back;< ", fgettext("Back to Main Menu"), "]",
"image_button[0,0;4,0.8;;back;", "< ", fgettext("Back to Main Menu"), ";true;false]",
"container_end[]",
} }
end end
@ -798,29 +808,29 @@ function store.get_formspec(dlgdata)
-- image -- image
formspec[#formspec + 1] = "image[0,0;1.5,1;" formspec[#formspec + 1] = "image[0,0;1.5,1;"
formspec[#formspec + 1] = core.formspec_escape(get_screenshot(package)) formspec[#formspec + 1] = get_screenshot(package)
formspec[#formspec + 1] = "]" formspec[#formspec + 1] = "]"
-- title -- title
formspec[#formspec + 1] = "label[1.875,0.1;" formspec[#formspec + 1] = "label[1.875,0.1;"
formspec[#formspec + 1] = core.formspec_escape( formspec[#formspec + 1] = esc(
core.colorize(mt_color_green, package.title) .. core.colorize(mt_color_green, package.title) ..
core.colorize("#BFBFBF", " by " .. package.author)) core.colorize("#BFBFBF", " by " .. package.author))
formspec[#formspec + 1] = "]" formspec[#formspec + 1] = "]"
-- buttons -- buttons
local left_base = "image_button[-1.55,0;0.7,0.7;" .. core.formspec_escape(defaulttexturedir) local left_base = "image_button[-1.55,0;0.7,0.7;" .. defaulttexturedir_esc
formspec[#formspec + 1] = "container[" formspec[#formspec + 1] = "container["
formspec[#formspec + 1] = W - 0.375*2 formspec[#formspec + 1] = W - 0.375*2
formspec[#formspec + 1] = ",0.1]" formspec[#formspec + 1] = ",0.1]"
if package.downloading then if package.downloading then
formspec[#formspec + 1] = "animated_image[-1.7,-0.15;1,1;downloading;" formspec[#formspec + 1] = "animated_image[-1.7,-0.15;1,1;downloading;"
formspec[#formspec + 1] = core.formspec_escape(defaulttexturedir) formspec[#formspec + 1] = defaulttexturedir_esc
formspec[#formspec + 1] = "cdb_downloading.png;3;400;]" formspec[#formspec + 1] = "cdb_downloading.png;4;300;]"
elseif package.queued then elseif package.queued then
formspec[#formspec + 1] = left_base formspec[#formspec + 1] = left_base
formspec[#formspec + 1] = core.formspec_escape(defaulttexturedir) formspec[#formspec + 1] = defaulttexturedir_esc
formspec[#formspec + 1] = "cdb_queued.png;queued]" formspec[#formspec + 1] = "cdb_queued.png;queued]"
elseif not package.path then elseif not package.path then
local elem_name = "install_" .. i .. ";" local elem_name = "install_" .. i .. ";"
@ -846,7 +856,7 @@ function store.get_formspec(dlgdata)
local web_elem_name = "view_" .. i .. ";" local web_elem_name = "view_" .. i .. ";"
formspec[#formspec + 1] = "image_button[-0.7,0;0.7,0.7;" .. formspec[#formspec + 1] = "image_button[-0.7,0;0.7,0.7;" ..
core.formspec_escape(defaulttexturedir) .. "cdb_viewonline.png;" .. web_elem_name .. "]" defaulttexturedir_esc .. "cdb_viewonline.png;" .. web_elem_name .. "]"
formspec[#formspec + 1] = "tooltip[" .. web_elem_name .. formspec[#formspec + 1] = "tooltip[" .. web_elem_name ..
fgettext("View more information in a web browser") .. tooltip_colors fgettext("View more information in a web browser") .. tooltip_colors
formspec[#formspec + 1] = "container_end[]" formspec[#formspec + 1] = "container_end[]"
@ -857,7 +867,7 @@ function store.get_formspec(dlgdata)
formspec[#formspec + 1] = "textarea[1.855,0.3;" formspec[#formspec + 1] = "textarea[1.855,0.3;"
formspec[#formspec + 1] = tostring(description_width) formspec[#formspec + 1] = tostring(description_width)
formspec[#formspec + 1] = ",0.8;;;" formspec[#formspec + 1] = ",0.8;;;"
formspec[#formspec + 1] = core.formspec_escape(package.short_description) formspec[#formspec + 1] = esc(package.short_description)
formspec[#formspec + 1] = "]" formspec[#formspec + 1] = "]"
formspec[#formspec + 1] = "style_type[textarea;font_size=]" formspec[#formspec + 1] = "style_type[textarea;font_size=]"
@ -955,7 +965,7 @@ function store.handle_submit(this, fields)
local function on_confirm() local function on_confirm()
local deps = get_raw_dependencies(package) local deps = get_raw_dependencies(package)
if deps and has_hard_deps(deps) then if deps and has_hard_deps(deps) and #pkgmgr.games > 0 then
local dlg = install_dialog.create(package, deps) local dlg = install_dialog.create(package, deps)
dlg:set_parent(this) dlg:set_parent(this)
this:hide() this:hide()
@ -1008,11 +1018,6 @@ function create_store_dlg(type)
search_string = "" search_string = ""
cur_page = 1 cur_page = 1
-- ToDo: delete me when MultiCraft ContentDB is ready
if type and type ~= "game" then
type = "game"
end
if type then if type then
-- table.indexof does not work on tables that contain `nil` -- table.indexof does not work on tables that contain `nil`
for i, v in pairs(filter_types_type) do for i, v in pairs(filter_types_type) do

View File

@ -97,14 +97,14 @@ local function create_world_formspec(dialogdata)
-- Error out when no games found -- Error out when no games found
if #pkgmgr.games == 0 then if #pkgmgr.games == 0 then
return "size[12.25,3,false]" .. return "size[12.25,3]" ..
"bgcolor[#0000]" .. "bgcolor[#0000]" ..
"background9[0,0;0,0;" .. core.formspec_escape(defaulttexturedir .. "background9[0,0;0,0;" .. defaulttexturedir_esc .. "bg_common.png;true;40]" ..
"bg_common.png") .. ";true;40]" ..
"box[0,0;12,2;#ff8800]" .. "box[0,0;12,2;#ff8800]" ..
"textarea[0.3,0;11.7,2;;;".. "textarea[0.3,0;11.7,2;;;"..
fgettext("You have no games installed.") .. "\n" .. fgettext("You have no games installed.") .. "\n" ..
fgettext("Download one from minetest.net") .. "]" .. fgettext("Download one from minetest.net") .. "]" ..
btn_style("world_create_cancel") ..
"button[4.75,2.5;3,0.5;world_create_cancel;" .. fgettext("Cancel") .. "]" "button[4.75,2.5;3,0.5;world_create_cancel;" .. fgettext("Cancel") .. "]"
end end
@ -334,10 +334,9 @@ local function create_world_formspec(dialogdata)
end end
local retval = local retval =
"size[12.25,7,false]" .. "size[12.25,7]" ..
"bgcolor[#0000]" .. "bgcolor[#0000]" ..
"background9[0,0;0,0;" .. core.formspec_escape(defaulttexturedir .. "background9[0,0;0,0;" .. defaulttexturedir_esc .. "bg_common.png;true;40]" ..
"bg_common.png") .. ";true;40]" ..
-- Left side -- Left side
"container[0,0]".. "container[0,0]"..
@ -367,8 +366,9 @@ local function create_world_formspec(dialogdata)
"container_end[]".. "container_end[]"..
-- Menu buttons -- Menu buttons
"style[world_create_confirm;bgcolor=#00d12b]" .. btn_style("world_create_confirm", "green") ..
"button[3.25,6.5;3,0.5;world_create_confirm;" .. fgettext("Create") .. "]" .. "button[3.25,6.5;3,0.5;world_create_confirm;" .. fgettext("Create") .. "]" ..
btn_style("world_create_cancel") ..
"button[6.25,6.5;3,0.5;world_create_cancel;" .. fgettext("Cancel") .. "]" "button[6.25,6.5;3,0.5;world_create_cancel;" .. fgettext("Cancel") .. "]"
return retval return retval

View File

@ -56,19 +56,23 @@ local function create_world_formspec()
end end
mglist = mglist:sub(1, -2) mglist = mglist:sub(1, -2)
return return "real_coordinates[true]" .. "formspec_version[3]" ..
"label[1.5,0.9;" .. fgettext("World name") .. ":" .. "]"..
"field[4.5,1.2;6,0.5;te_world_name;;]" ..
"label[1.5,1.9;" .. fgettext("Seed") .. ":" .. "]".. "image[3.5,1.1;8.5,0.8;" .. defaulttexturedir_esc .. "field_bg.png;32]" ..
"field[4.5,2.2;6,0.5;te_seed;;".. current_seed .. "]" .. "style[te_world_name;border=false;bgcolor=transparent]" ..
"field[3.55,1.1;8.4,0.8;te_world_name;" .. fgettext("World name") .. ":" .. ";]" ..
"label[1.5,2.9;" .. fgettext("Mapgen") .. ":" .. "]".. "image[3.5,2.5;8.5,0.8;" .. defaulttexturedir_esc .. "field_bg.png;32]" ..
"dropdown[4.2,2.75;6.3;dd_mapgen;" .. mglist .. ";" .. selindex .. "]" .. "style[te_seed;border=false;bgcolor=transparent]" ..
"field[3.55,2.5;8.4,0.8;te_seed;" .. fgettext("Seed") .. ":" .. ";".. current_seed .. "]" ..
"style[world_create_confirm;bgcolor=#00d12b]" .. "label[3.5,3.7;" .. fgettext("Mapgen") .. ":" .. "]"..
"button[3.5,4.4;2.5,0.5;world_create_confirm;" .. fgettext("Create") .. "]" .. "dropdown[3.5,3.9;8.5,0.8;dd_mapgen;" .. mglist .. ";" .. selindex .. "]" ..
"button[6,4.4;2.5,0.5;world_create_cancel;" .. fgettext("Cancel") .. "]"
btn_style("world_create_confirm", "green") ..
"button[4.1,5.3;3.5,0.8;world_create_confirm;" .. fgettext("Create") .. "]" ..
btn_style("world_create_cancel") ..
"button[7.9,5.3;3.5,0.8;world_create_cancel;" .. fgettext("Cancel") .. "]"
end end
local function create_world_buttonhandler(this, fields) local function create_world_buttonhandler(this, fields)

View File

@ -19,15 +19,24 @@
local function delete_content_formspec(dialogdata) local function delete_content_formspec(dialogdata)
local title = dialogdata.content.title or dialogdata.content.name local title = dialogdata.content.title or dialogdata.content.name
local retval = local retval = {
"image_button[2,1;8,3;" .. core.formspec_escape(defaulttexturedir) .. "real_coordinates[true]",
"blank.png;;" .. fgettext("Are you sure you want to delete \"$1\"?", title) .. "image[6.5,0.8;2.5,2.5;", defaulttexturedir_esc, "attention.png]",
";true;false;]" ..
"style[dlg_delete_content_confirm;bgcolor=red]" ..
"button[3,4.8;3,0.5;dlg_delete_content_confirm;" .. fgettext("Delete") .. "]" ..
"button[6,4.8;3,0.5;dlg_delete_content_cancel;" .. fgettext("Cancel") .. "]"
return retval "style[msg;content_offset=0]",
"image_button[1,3.5;13.5,0.8;;msg;",
fgettext("Are you sure you want to delete \"$1\"?", title), ";false;false]",
btn_style("dlg_delete_content_confirm", "red"),
"image_button[4.1,5.3;3.5,0.8;;dlg_delete_content_confirm;",
fgettext("Delete"), ";true;false]",
btn_style("dlg_delete_content_cancel"),
"image_button[7.9,5.3;3.5,0.8;;dlg_delete_content_cancel;",
fgettext("Cancel"), ";true;false]",
}
return table.concat(retval)
end end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -45,9 +54,6 @@ local function delete_content_buttonhandler(this, fields)
if this.data.content.type == "game" then if this.data.content.type == "game" then
pkgmgr.update_gamelist() pkgmgr.update_gamelist()
ui.childlist = {}
menudata.init_tabs()
else else
pkgmgr.refresh_globals() pkgmgr.refresh_globals()
end end

View File

@ -23,14 +23,30 @@ local function delete_world_formspec(dialogdata)
delete_name = delete_name .. " (" .. game_name .. ")" delete_name = delete_name .. " (" .. game_name .. ")"
end end
local retval = local formspec = {
"image_button[2,1;8,3;" .. core.formspec_escape(defaulttexturedir .. "real_coordinates[true]",
"blank.png") .. ";;" .. fgettext("Delete World \"$1\"?", delete_name) .. "image[6.5,0.8;2.5,2.5;", defaulttexturedir_esc, "attention.png]",
";true;false;]" ..
"style[world_delete_confirm;bgcolor=red]" .. "style[msg,wait;content_offset=0]",
"button[3,4.8;3,0.5;world_delete_confirm;" .. fgettext("Delete") .. "]" .. "image_button[1,3.5;13.5,0.8;;msg;",
"button[6,4.8;3,0.5;world_delete_cancel;" .. fgettext("Cancel") .. "]" fgettext("Delete World \"$1\"?", delete_name), ";false;false]",
return retval
btn_style("world_delete_cancel"),
"image_button[7.9,5.3;3.5,0.8;;world_delete_cancel;",
fgettext("Cancel"), ";true;false]",
}
if dialogdata.cooldown > 0 then
formspec[#formspec + 1] = btn_style("wait", "gray")
formspec[#formspec + 1] = "image_button[4.1,5.3;3.5,0.8;;wait;" ..
fgettext("Delete") .. " (" .. dialogdata.cooldown .. ");true;false]"
else
formspec[#formspec + 1] = btn_style("world_delete_confirm", "red")
formspec[#formspec + 1] = "image_button[4.1,5.3;3.5,0.8;;world_delete_confirm;" ..
fgettext("Delete") .. ";true;false]"
end
return table.concat(formspec)
end end
local function delete_world_buttonhandler(this, fields) local function delete_world_buttonhandler(this, fields)
@ -52,6 +68,23 @@ local function delete_world_buttonhandler(this, fields)
return false return false
end end
-- core.handle_async requires a function defined in Lua
local function sleep_ms(delay)
return core.sleep_ms(delay)
end
local function start_timer(msgbox)
core.handle_async(sleep_ms, 1000, function()
-- If this.hidden isn't true then the dialog must have been closed and
-- the countdown can be stopped.
if msgbox.parent and msgbox.parent.hidden then
msgbox.data.cooldown = msgbox.data.cooldown - 1
ui.update()
start_timer(msgbox)
end
end)
end
function create_delete_world_dlg(name_to_del, index_to_del, game_to_del) function create_delete_world_dlg(name_to_del, index_to_del, game_to_del)
assert(name_to_del ~= nil and type(name_to_del) == "string" and name_to_del ~= "") assert(name_to_del ~= nil and type(name_to_del) == "string" and name_to_del ~= "")
@ -64,6 +97,8 @@ function create_delete_world_dlg(name_to_del, index_to_del, game_to_del)
retval.data.delete_name = name_to_del retval.data.delete_name = name_to_del
retval.data.delete_game = game_to_del retval.data.delete_game = game_to_del
retval.data.delete_index = index_to_del retval.data.delete_index = index_to_del
retval.data.cooldown = 5
start_timer(retval)
return retval return retval
end end

View File

@ -15,23 +15,24 @@
--with this program; if not, write to the Free Software Foundation, Inc., --with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
local blank = core.formspec_escape(defaulttexturedir .. "blank.png")
local function outdated_server_formspec(this) local function outdated_server_formspec(this)
return ([[ return ([[
style_type[image_button;content_offset=0] style_type[image_button;content_offset=0]
image[4.9,0.3;2.5,2.5;%s] image[4.9,0.3;2.5,2.5;%sattention.png]
image_button[1,2.5;10,0.8;%s;;%s;false;false] style[msg;content_offset=0]
image_button[1,3.2;10,0.8;%s;;%s;false;false] image_button[1,2.5;10,0.8;;msg;%s;false;false]
image_button[1,3.2;10,0.8;;msg;%s;false;false]
%s
button[2,4.5;4,0.8;cancel;%s] button[2,4.5;4,0.8;cancel;%s]
style[continue;bgcolor=yellow] %s
button[6,4.5;4,0.8;continue;%s] button[6,4.5;4,0.8;continue;%s]
]]):format( ]]):format(
core.formspec_escape(defaulttexturedir .. "attention.png"), defaulttexturedir_esc,
blank,
fgettext("The server you are trying to connect to is outdated!"), fgettext("The server you are trying to connect to is outdated!"),
blank,
fgettext("Support for older servers may be removed at any time."), fgettext("Support for older servers may be removed at any time."),
btn_style("cancel"),
fgettext("Cancel"), fgettext("Cancel"),
btn_style("continue", "yellow"),
fgettext("Join anyway") fgettext("Join anyway")
) )
end end

View File

@ -19,8 +19,10 @@
local function rename_modpack_formspec(dialogdata) local function rename_modpack_formspec(dialogdata)
local retval = local retval =
btn_style("dlg_rename_modpack_confirm", "green") ..
"button[3,4.8;3,0.5;dlg_rename_modpack_confirm;".. "button[3,4.8;3,0.5;dlg_rename_modpack_confirm;"..
fgettext("Accept") .. "]" .. fgettext("Accept") .. "]" ..
btn_style("dlg_rename_modpack_cancel") ..
"button[6,4.8;3,0.5;dlg_rename_modpack_cancel;".. "button[6,4.8;3,0.5;dlg_rename_modpack_cancel;"..
fgettext("Cancel") .. "]" fgettext("Cancel") .. "]"
@ -32,7 +34,11 @@ local function rename_modpack_formspec(dialogdata)
input_y = 2.5 input_y = 2.5
end end
retval = retval .. retval = retval ..
"field[2.5," .. input_y .. ";7,0.5;te_modpack_name;" .. "formspec_version[3]" ..
"image[2.5," .. input_y - 0.47 .. ";8.55,0.84;" ..
defaulttexturedir_esc .. "field_bg.png;32]" ..
"style[te_modpack_name;border=false;bgcolor=transparent]" ..
"field[2.85," .. input_y .. ";6.9,0.5;te_modpack_name;" ..
fgettext("Rename Modpack:") .. ";" .. dialogdata.mod.dir_name .. "]" fgettext("Rename Modpack:") .. ";" .. dialogdata.mod.dir_name .. "]"
return retval return retval

View File

@ -621,7 +621,8 @@ local function create_change_setting_formspec(dialogdata)
end end
formspec = "field[0.28," .. height + 0.15 .. ";8,1;te_setting_value;;" formspec = "field[0.28," .. height + 0.15 .. ";8,1;te_setting_value;;"
.. core.formspec_escape(current_value) .. "]" .. core.formspec_escape(current_value) .. "]"
.. "button[8," .. height - 0.15 .. ";2,1;btn_browser_" .. btn_style("btn_browser_" .. setting.type)
.. "button[8," .. height - 0.2 .. ";2,1;btn_browser_"
.. setting.type .. ";" .. fgettext("Browse") .. "]" .. setting.type .. ";" .. fgettext("Browse") .. "]"
height = height + 1.15 height = height + 1.15
@ -825,14 +826,15 @@ local function create_change_setting_formspec(dialogdata)
end end
return ( return (
"size[" .. width .. "," .. height + 0.25 .. ",false]" .. "size[" .. width .. "," .. height + 0.25 .. "]" ..
"bgcolor[#0000]" .. "bgcolor[#0000]" ..
"background9[0,0;0,0;" .. core.formspec_escape(defaulttexturedir .. "background9[0,0;0,0;" .. defaulttexturedir_esc .. "bg_common.png;true;40]" ..
"bg_common.png") .. ";true;40]" ..
create_textfield(description_box, setting_name, comment_text) .. create_textfield(description_box, setting_name, comment_text) ..
formspec .. formspec ..
btn_style("btn_done") ..
"button[" .. width / 2 - 2.5 .. "," .. height - 0.4 .. ";2.5,1;btn_done;" .. "button[" .. width / 2 - 2.5 .. "," .. height - 0.4 .. ";2.5,1;btn_done;" ..
fgettext("Save") .. "]" .. fgettext("Save") .. "]" ..
btn_style("btn_cancel") ..
"button[" .. width / 2 .. "," .. height - 0.4 .. ";2.5,1;btn_cancel;" .. "button[" .. width / 2 .. "," .. height - 0.4 .. ";2.5,1;btn_cancel;" ..
fgettext("Cancel") .. "]" fgettext("Cancel") .. "]"
) )
@ -1019,8 +1021,12 @@ local function create_settings_formspec(tabview, _, tabdata)
local formspec = local formspec =
"tablecolumns[color;tree;text,width=28;text]" .. "tablecolumns[color;tree;text,width=28;text]" ..
"tableoptions[background=#00000000;border=false]" .. "tableoptions[background=#00000000;border=false]" ..
"field[0.3,0.1;10.2,1;search_string;;" .. core.formspec_escape(search_string) .. "]" .. "formspec_version[3]" ..
"image[-0.05,-0.13;12.55,0.8;" .. defaulttexturedir_esc .. "field_bg.png;32]" ..
"style[search_string;border=false;bgcolor=transparent]" ..
"field[0.3,0.15;10.15,0.9;search_string;;" .. core.formspec_escape(search_string) .. "]" ..
"field_close_on_enter[search_string;false]" .. "field_close_on_enter[search_string;false]" ..
btn_style("search") ..
"button[10.1,-0.22;2,1;search;" .. fgettext("Search") .. "]" .. "button[10.1,-0.22;2,1;search;" .. fgettext("Search") .. "]" ..
"table[0,0.8;12,3.5;list_settings;" "table[0,0.8;12,3.5;list_settings;"
@ -1068,9 +1074,12 @@ local function create_settings_formspec(tabview, _, tabdata)
formspec = formspec:sub(1, -2) -- remove trailing comma formspec = formspec:sub(1, -2) -- remove trailing comma
end end
formspec = formspec .. ";" .. selected_setting .. "]" .. formspec = formspec .. ";" .. selected_setting .. "]" ..
btn_style("btn_back") ..
"button[0,4.9;4,1;btn_back;".. fgettext("< Back to Settings page") .. "]" .. "button[0,4.9;4,1;btn_back;".. fgettext("< Back to Settings page") .. "]" ..
"button[10,4.9;2,1;btn_edit;" .. fgettext("Edit") .. "]" .. btn_style("btn_restore") ..
"button[7,4.9;3,1;btn_restore;" .. fgettext("Restore Default") .. "]" .. "button[5.5,4.9;4,1;btn_restore;" .. fgettext("Restore Default") .. "]" ..
btn_style("btn_edit") ..
"button[9.5,4.9;2.5,1;btn_edit;" .. fgettext("Edit") .. "]" ..
"checkbox[0,4.3;cb_tech_settings;" .. fgettext("Show technical names") .. ";" "checkbox[0,4.3;cb_tech_settings;" .. fgettext("Show technical names") .. ";"
.. dump(core.settings:get_bool("main_menu_technical_settings")) .. "]" .. dump(core.settings:get_bool("main_menu_technical_settings")) .. "]"

View File

@ -25,7 +25,6 @@ if not core.get_http_api then
end end
local esc = core.formspec_escape local esc = core.formspec_escape
local defaulttexturedir = esc(defaulttexturedir)
local LANG = core.settings:get("language") local LANG = core.settings:get("language")
if not (LANG and (LANG ~= "")) then LANG = os.getenv("LANG") end if not (LANG and (LANG ~= "")) then LANG = os.getenv("LANG") end
@ -45,19 +44,21 @@ local function version_info_formspec(data)
return ([[ return ([[
style_type[image_button;content_offset=0] style_type[image_button;content_offset=0]
image[4.9,0;2.5,2.5;%s] image[4.9,0;2.5,2.5;%slogo.png]
image_button[1,2;10,0.8;%s;;%s;false;false] style[msg;content_offset=0]
image_button[1,2;10,0.8;;msg;%s;false;false]
hypertext[1.3,2.6;10,2;;<center>%s</center>] hypertext[1.3,2.6;10,2;;<center>%s</center>]
style[version_check_remind;bgcolor=yellow] %s
button[2,4.5;4,0.8;version_check_remind;%s] button[2,4.5;4,0.8;version_check_remind;%s]
style[version_check_visit;bgcolor=green] %s
button[6,4.5;4,0.8;version_check_visit;%s] button[6,4.5;4,0.8;version_check_visit;%s]
]]):format( ]]):format(
defaulttexturedir .. "logo.png", defaulttexturedir_esc,
defaulttexturedir .. "blank.png",
esc(data.title), esc(data.title),
esc(changes), esc(changes),
btn_style("version_check_remind", "yellow"),
fgettext("Cancel"), fgettext("Cancel"),
btn_style("version_check_visit", "green"),
fgettext("Update") fgettext("Update")
) -- "Remind me later", "Update now" ) -- "Remind me later", "Update now"
end end

View File

@ -26,6 +26,7 @@ local basepath = core.get_builtin_path()
local mobile = PLATFORM == "Android" or PLATFORM == "iOS" local mobile = PLATFORM == "Android" or PLATFORM == "iOS"
defaulttexturedir = core.get_texturepath_share() .. DIR_DELIM .. "base" .. defaulttexturedir = core.get_texturepath_share() .. DIR_DELIM .. "base" ..
DIR_DELIM .. "pack" .. DIR_DELIM DIR_DELIM .. "pack" .. DIR_DELIM
defaulttexturedir_esc = core.formspec_escape(defaulttexturedir)
dofile(basepath .. "common" .. DIR_DELIM .. "filterlist.lua") dofile(basepath .. "common" .. DIR_DELIM .. "filterlist.lua")
dofile(basepath .. "fstk" .. DIR_DELIM .. "buttonbar.lua") dofile(basepath .. "fstk" .. DIR_DELIM .. "buttonbar.lua")

View File

@ -20,18 +20,10 @@ serverlistmgr = {}
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local function order_server_list(list) local function order_server_list(list)
local res = {} local res = {}
--orders the favorite list after support
-- orders the multicraft list before support
for i = 1, #list do for i = 1, #list do
local fav = list[i] local fav = list[i]
if fav.server_id == "multicraft" then if is_server_protocol_compat(fav.proto_min, fav.proto_max) then
res[#res + 1] = fav
end
end
for i = 1, #list do
local fav = list[i]
if is_server_protocol_compat(fav.proto_min, fav.proto_max) and
fav.server_id ~= "multicraft" then
res[#res + 1] = fav res[#res + 1] = fav
end end
end end
@ -66,11 +58,8 @@ function serverlistmgr.sync()
core.handle_async( core.handle_async(
function(param) function(param)
local http = core.get_http_api() local http = core.get_http_api()
local serverlist = core.settings:get("serverlist_url") local url = ("%s/list?proto_version_min=%d&proto_version_max=%d&platform=%s"):format(
local address = ("%s/list%s"):format(serverlist, core.settings:get("serverlist_url"),
serverlist == minetest.decode_base64("c2VydmVycy5tdWx0aWNyYWZ0Lndvcmxk") and "_prod" or "")
local url = ("%s?proto_version_min=%d&proto_version_max=%d&platform=%s"):format(
address,
core.get_min_supp_proto(), core.get_min_supp_proto(),
core.get_max_supp_proto(), core.get_max_supp_proto(),
PLATFORM) PLATFORM)

View File

@ -16,9 +16,6 @@
--with this program; if not, write to the Free Software Foundation, Inc., --with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
local esc = core.formspec_escape
local defaulttexturedir = esc(defaulttexturedir)
local packages_raw local packages_raw
local packages local packages
@ -62,15 +59,14 @@ local function get_formspec(tabview, name, tabdata)
local retval = local retval =
"style_type[image_button;padding=-5;bgimg=" .. defaulttexturedir ..
"select_btn.png;bgimg_middle=10]" ..
"label[-0.05,-0.25;".. fgettext("Installed Packages:") .. "]" .. "label[-0.05,-0.25;".. fgettext("Installed Packages:") .. "]" ..
"background9[0,0.23;5.3,4.46;" .. defaulttexturedir .. "worldlist_bg.png" .. ";false;40]" .. "background9[0,0.23;5.3,4.46;" .. defaulttexturedir_esc .. "worldlist_bg.png" .. ";false;40]" ..
"tablecolumns[color;tree;text]" .. "tablecolumns[color;tree;text]" ..
"tableoptions[background=#0000;border=false]" .. "tableoptions[background=#0000;border=false]" ..
"table[0,0.25;5.1,4.3;pkglist;" .. "table[0,0.25;5.1,4.3;pkglist;" ..
pkgmgr.render_packagelist(packages) .. pkgmgr.render_packagelist(packages) ..
";" .. tabdata.selected_pkg .. "]" .. ";" .. tabdata.selected_pkg .. "]" ..
btn_style("btn_contentdb") ..
"image_button[-0.11,4.8;5.5,0.9;;btn_contentdb;" .. fgettext("Browse online content") .. ";true;false]" "image_button[-0.11,4.8;5.5,0.9;;btn_contentdb;" .. fgettext("Browse online content") .. ";true;false]"
@ -91,7 +87,7 @@ local function get_formspec(tabview, name, tabdata)
end end
if modscreenshot == nil then if modscreenshot == nil then
modscreenshot = defaulttexturedir .. "no_screenshot.png" modscreenshot = defaulttexturedir_esc .. "no_screenshot.png"
end end
local info = core.get_content_info(selected_pkg.path) local info = core.get_content_info(selected_pkg.path)
@ -101,13 +97,14 @@ local function get_formspec(tabview, name, tabdata)
end end
retval = retval .. retval = retval ..
"image[5.5,0;3,2;" .. esc(modscreenshot) .. "]" .. "image[5.5,0;3,2;" .. core.formspec_escape(modscreenshot) .. "]" ..
"label[8.25,0.6;" .. esc(selected_pkg.name) .. "]" .. "label[8.25,0.6;" .. core.formspec_escape(selected_pkg.name) .. "]" ..
"background9[5.6,2.3;6.2,2.4;" .. defaulttexturedir .. "desc_bg.png" .. ";false;32]" "background9[5.6,2.3;6.2,2.4;" .. defaulttexturedir_esc .. "desc_bg.png" .. ";false;32]"
if selected_pkg.type == "mod" then if selected_pkg.type == "mod" then
if selected_pkg.is_modpack then if selected_pkg.is_modpack then
retval = retval .. retval = retval ..
btn_style("btn_mod_mgr_rename_modpack") ..
"image_button[8.65,4.8;3.25,0.9;;btn_mod_mgr_rename_modpack;" .. "image_button[8.65,4.8;3.25,0.9;;btn_mod_mgr_rename_modpack;" ..
fgettext("Rename") .. ";true;false]" fgettext("Rename") .. ";true;false]"
else else
@ -136,10 +133,12 @@ local function get_formspec(tabview, name, tabdata)
if selected_pkg.type == "txp" then if selected_pkg.type == "txp" then
if selected_pkg.enabled then if selected_pkg.enabled then
retval = retval .. retval = retval ..
btn_style("btn_mod_mgr_disable_txp") ..
"image_button[8.65,4.8;3.25,0.9;;btn_mod_mgr_disable_txp;" .. "image_button[8.65,4.8;3.25,0.9;;btn_mod_mgr_disable_txp;" ..
fgettext("Disable Texture Pack") .. ";true;false]" fgettext("Disable Texture Pack") .. ";true;false]"
else else
retval = retval .. retval = retval ..
btn_style("btn_mod_mgr_use_txp") ..
"image_button[8.65,4.8;3.25,0.9;;btn_mod_mgr_use_txp;" .. "image_button[8.65,4.8;3.25,0.9;;btn_mod_mgr_use_txp;" ..
fgettext("Use Texture Pack") .. ";true;false]" fgettext("Use Texture Pack") .. ";true;false]"
end end
@ -151,6 +150,7 @@ local function get_formspec(tabview, name, tabdata)
if core.may_modify_path(selected_pkg.path) then if core.may_modify_path(selected_pkg.path) then
retval = retval .. retval = retval ..
btn_style("btn_mod_mgr_delete_mod") ..
"image_button[5.5,4.8;3.25,0.9;;btn_mod_mgr_delete_mod;" .. "image_button[5.5,4.8;3.25,0.9;;btn_mod_mgr_delete_mod;" ..
fgettext("Uninstall Package") .. ";true;false]" fgettext("Uninstall Package") .. ";true;false]"
end end

View File

@ -15,9 +15,6 @@
--with this program; if not, write to the Free Software Foundation, Inc., --with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
local esc = core.formspec_escape
local defaulttexturedir = esc(defaulttexturedir)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local multicraft_developers = { local multicraft_developers = {
@ -106,6 +103,7 @@ local previous_contributors = {
"Jeija <jeija@mesecons.net> [HTTP, particles]", "Jeija <jeija@mesecons.net> [HTTP, particles]",
} }
local esc = core.formspec_escape
local function buildCreditList(source) local function buildCreditList(source)
local ret = {} local ret = {}
for i = 1, #source do for i = 1, #source do
@ -119,7 +117,7 @@ return {
caption = "", -- fgettext("Credits"), caption = "", -- fgettext("Credits"),
cbf_formspec = function(tabview, name, tabdata) cbf_formspec = function(tabview, name, tabdata)
local version = core.get_version() local version = core.get_version()
local logofile = defaulttexturedir .. "logo.png" local logofile = defaulttexturedir_esc .. "logo.png"
local fs = "image[-0.25,-0.3;2,2;" .. logofile .. "]" .. local fs = "image[-0.25,-0.3;2,2;" .. logofile .. "]" ..
"label[1.3,-0.25;" .. "label[1.3,-0.25;" ..
"MultiCraft Open Source, ver. " .. version.string .. "\n" .. "MultiCraft Open Source, ver. " .. version.string .. "\n" ..
@ -127,14 +125,12 @@ return {
"License: GNU LGPLv3.0+ and CC BY-SA 4.0\n" .. "License: GNU LGPLv3.0+ and CC BY-SA 4.0\n" ..
"Created and Powered by Minetest Engine, ver. 5.4.1]" .. "Created and Powered by Minetest Engine, ver. 5.4.1]" ..
"style[homepage;padding=-5;bgimg=" .. defaulttexturedir .. btn_style("homepage") ..
"select_btn.png;bgimg_middle=10]" .. "image_button[9.5,-0.2;2.6,0.85;;homepage;Home Page;true;false]" ..
"image_button[9.5,-0.2;2.6,0.8;;homepage;Home Page;true;false]" .. btn_style("privacy") ..
"style[privacy;padding=-5;bgimg=" .. defaulttexturedir .. "image_button[9.5,0.6;2.6,0.85;;privacy;Privacy Policy;true;false]" ..
"select_btn.png;bgimg_middle=10]" ..
"image_button[9.5,0.65;2.6,0.8;;privacy;Privacy Policy;true;false]" ..
"background9[0,1.5;12,4.2;" .. defaulttexturedir .. "background9[0,1.5;12,4.2;" .. defaulttexturedir_esc ..
"worldlist_bg.png" .. ";false;40]" .. "worldlist_bg.png" .. ";false;40]" ..
"tablecolumns[color;text]" .. "tablecolumns[color;text]" ..
"tableoptions[background=#0000;highlight=#00000000;border=false]" .. "tableoptions[background=#0000;highlight=#00000000;border=false]" ..

View File

@ -19,7 +19,7 @@ local lang = core.settings:get("language")
if not lang or lang == "" then lang = os.getenv("LANG") end if not lang or lang == "" then lang = os.getenv("LANG") end
local esc = core.formspec_escape local esc = core.formspec_escape
local defaulttexturedir = esc(defaulttexturedir) local small_screen = (PLATFORM == "Android" or PLATFORM == "iOS") and not core.settings:get_bool("device_is_tablet")
local function current_game() local function current_game()
local last_game_id = core.settings:get("menu_last_game") local last_game_id = core.settings:get("menu_last_game")
@ -118,53 +118,56 @@ local function get_formspec(_, _, tab_data)
creative_bg = "creative_bg_" .. lang .. ".png" creative_bg = "creative_bg_" .. lang .. ".png"
end end
local space = small_screen and ("\n"):rep(3) or ("\n"):rep(5)
local retval = local retval =
"style[world_delete;fgimg=" .. defaulttexturedir .. "style[world_delete;fgimg=" .. defaulttexturedir_esc ..
"world_delete.png;fgimg_hovered=" .. defaulttexturedir .. "world_delete_hover.png]" .. "world_delete.png;fgimg_hovered=" .. defaulttexturedir_esc .. "world_delete_hover.png]" ..
"image_button[-0.1,4.84;3.45,0.92;;world_delete;;true;false]" .. "image_button[-0.1,4.84;3.45,0.92;;world_delete;;true;false]" ..
"tooltip[world_delete;".. fgettext("Delete") .. "]" .. "tooltip[world_delete;".. fgettext("Delete") .. "]" ..
"style[world_create;fgimg=" .. defaulttexturedir .. "style[world_create;fgimg=" .. defaulttexturedir_esc ..
"world_new.png;fgimg_hovered=" .. defaulttexturedir .. "world_new_hover.png]" .. "world_new.png;fgimg_hovered=" .. defaulttexturedir_esc .. "world_new_hover.png]" ..
"image_button[3.15,4.84;3.45,0.92;;world_create;;true;false]" .. "image_button[3.15,4.84;3.45,0.92;;world_create;;true;false]" ..
"tooltip[world_create;".. fgettext("New") .. "]" .. "tooltip[world_create;".. fgettext("New") .. "]"
"style[play;fgimg=" .. defaulttexturedir .. "btn_play.png;fgimg_hovered=" .. local world = menudata.worldlist:get_list()[index]
defaulttexturedir .. "btn_play_hover.png]" .. local game = world and pkgmgr.find_by_gameid(world.gameid)
"image_button[6.72,1.43;4.96,1.41;;play;;true;false]" .. if game and game.moddable then
retval = retval ..
btn_style("world_configure") ..
"image_button[9,4.84;3,0.92;;world_configure;" .. fgettext("Select Mods") .. ";true;false]"
end
retval = retval ..
btn_style("play") ..
"style[play;font_size=*" .. (small_screen and 2.25 or 3) .. "]" ..
"image_button[6.72,1.43;4.96,1.41;;play;" .. space .. " " ..
fgettext("Play") .. space .. ";true;false]" ..
"image[7,1.63;1,1;" .. defaulttexturedir_esc .. "btn_play_icon.png]" ..
"tooltip[play;".. fgettext("Play Game") .. "]" .. "tooltip[play;".. fgettext("Play Game") .. "]" ..
"image_button[7.2,3.09;4,0.83;" .. defaulttexturedir .. creative_bg .. ";;;true;false]" .. "image_button[7.2,3.09;4,0.83;" .. defaulttexturedir_esc .. creative_bg .. ";;;true;false]" ..
"style[cb_creative_mode;content_offset=0]" .. "style[cb_creative_mode;content_offset=0]" ..
"image_button[7.2,3.09;4,0.83;" .. defaulttexturedir .. creative_checkbox .. "image_button[7.2,3.09;4,0.83;" .. defaulttexturedir_esc .. creative_checkbox ..
";cb_creative_mode;;true;false]" .. ";cb_creative_mode;;true;false]" ..
"background9[0,0;6.5,4.8;" .. defaulttexturedir .. "worldlist_bg.png" .. ";false;40]" .. "background9[0,0;6.5,4.8;" .. defaulttexturedir_esc .. "worldlist_bg.png" .. ";false;40]" ..
"tableoptions[background=#0000;border=false]" .. "tableoptions[background=#0000;border=false]" ..
"table[0,0;6.28,4.64;sp_worlds;" .. menu_render_worldlist() .. ";" .. index .. "]" "table[0,0;6.28,4.64;sp_worlds;" .. menu_render_worldlist() .. ";" .. index .. "]"
if tab_data.hidden then if tab_data.hidden then
retval = retval .. retval = retval ..
"style[switch_local_default;fgimg=" .. defaulttexturedir .. "switch_local_default.png;fgimg_hovered=" .. "style[switch_local_default;fgimg=" .. defaulttexturedir_esc .. "switch_local_default.png;fgimg_hovered=" ..
defaulttexturedir .. "switch_local_default_hover.png]" .. defaulttexturedir_esc .. "switch_local_default_hover.png]" ..
"image_button[10.6,-0.1;1.5,1.5;;switch_local_default;;true;false]" "image_button[10.6,-0.1;1.5,1.5;;switch_local_default;;true;false]"
end end
if PLATFORM ~= "Android" and PLATFORM ~= "iOS" then
retval = retval ..
"style[world_configure;padding=-5;bgimg=" .. defaulttexturedir ..
"select_btn.png;bgimg_middle=10]" ..
"image_button[9.3,4.84;2.7,0.92;;world_configure;" .. fgettext("Select Mods") .. ";true;false]"
end
local enable_server = core.settings:get_bool("enable_server") local enable_server = core.settings:get_bool("enable_server")
if enable_server then if enable_server then
retval = retval .. retval = retval ..
"checkbox[6.6,5;cb_server;".. fgettext("Create Server") ..";" .. "checkbox[6.6,5;cb_server;".. fgettext("Create Server") ..";" ..
dump(enable_server) .. "]" dump(enable_server) .. "]"
end
if enable_server then
if core.settings:get_bool("server_announce") then if core.settings:get_bool("server_announce") then
retval = retval .. retval = retval ..
"checkbox[9.3,5;cb_server_announce;" .. fgettext("Announce Server") .. ";true]" "checkbox[9.3,5;cb_server_announce;" .. fgettext("Announce Server") .. ";true]"
@ -180,7 +183,7 @@ local function get_formspec(_, _, tab_data)
return retval return retval
end end
local function main_button_handler(this, fields, name) local function main_button_handler(this, fields, name, tab_data)
assert(name == "local") assert(name == "local")
local world_doubleclick = false local world_doubleclick = false
@ -243,6 +246,22 @@ local function main_button_handler(this, fields, name)
if world then if world then
local game = pkgmgr.find_by_gameid(world.gameid) local game = pkgmgr.find_by_gameid(world.gameid)
core.settings:set("menu_last_game", (game and game.id or "")) core.settings:set("menu_last_game", (game and game.id or ""))
-- Disable all mods on games that aren't moddable
if game and not game.moddable then
local conf = Settings(world.path .. DIR_DELIM .. "world.mt")
local needs_update = false
for _, key in ipairs(conf:get_names()) do
if key:sub(1, 9) == "load_mod_" and conf:get_bool(key) then
conf:set_bool(key, false)
needs_update = true
end
end
if needs_update then
conf:write()
end
end
end end
if core.settings:get_bool("enable_server") then if core.settings:get_bool("enable_server") then
@ -327,7 +346,7 @@ local function main_button_handler(this, fields, name)
if #pkgmgr.games > 1 or (pkgmgr.games[1] and pkgmgr.games[1].id ~= "default") then if #pkgmgr.games > 1 or (pkgmgr.games[1] and pkgmgr.games[1].id ~= "default") then
this:set_tab("content") this:set_tab("content")
else else
local dlg = create_store_dlg() local dlg = create_store_dlg("game")
dlg:set_parent(this) dlg:set_parent(this)
this:hide() this:hide()
dlg:show() dlg:show()

View File

@ -18,8 +18,7 @@
local lang = core.settings:get("language") local lang = core.settings:get("language")
if not lang or lang == "" then lang = os.getenv("LANG") end if not lang or lang == "" then lang = os.getenv("LANG") end
local esc = core.formspec_escape local small_screen = (PLATFORM == "Android" or PLATFORM == "iOS") and not core.settings:get_bool("device_is_tablet")
local defaulttexturedir = esc(defaulttexturedir)
local default_worlds = { local default_worlds = {
{name = "World 1", mg_name = "v7p", seed = "15823438331521897617"}, {name = "World 1", mg_name = "v7p", seed = "15823438331521897617"},
@ -30,6 +29,8 @@ local default_worlds = {
} }
local function create_default_worlds() local function create_default_worlds()
if #menudata.worldlist:get_list() > 0 then return end
local _, gameindex = pkgmgr.find_by_gameid("default") local _, gameindex = pkgmgr.find_by_gameid("default")
if not gameindex or gameindex == 0 then return end if not gameindex or gameindex == 0 then return end
@ -62,7 +63,7 @@ end
local checked_worlds = false local checked_worlds = false
local function get_formspec(this) local function get_formspec(this)
-- Only check the worlds once (on restart) -- Only check the worlds once (on restart)
if not checked_worlds and #menudata.worldlist:get_list() == 0 then if not checked_worlds then
create_default_worlds() create_default_worlds()
end end
checked_worlds = true checked_worlds = true
@ -86,40 +87,43 @@ local function get_formspec(this)
creative_bg = "creative_bg_" .. lang .. ".png" creative_bg = "creative_bg_" .. lang .. ".png"
end end
local space = small_screen and ("\n"):rep(3) or ("\n"):rep(5)
local retval = local retval =
"style[world_delete;fgimg=" .. defaulttexturedir .. "style[world_delete;fgimg=" .. defaulttexturedir_esc ..
"world_delete.png;fgimg_hovered=" .. defaulttexturedir .. "world_delete_hover.png]" .. "world_delete.png;fgimg_hovered=" .. defaulttexturedir_esc .. "world_delete_hover.png]" ..
"image_button[-0.1,4.84;3.45,0.92;;world_delete;;true;false]" .. "image_button[-0.1,4.84;3.45,0.92;;world_delete;;true;false]" ..
"tooltip[world_delete;".. fgettext("Delete") .. "]" .. "tooltip[world_delete;".. fgettext("Delete") .. "]" ..
"style[world_create;fgimg=" .. defaulttexturedir .. "style[world_create;fgimg=" .. defaulttexturedir_esc ..
"world_new.png;fgimg_hovered=" .. defaulttexturedir .. "world_new_hover.png]" .. "world_new.png;fgimg_hovered=" .. defaulttexturedir_esc .. "world_new_hover.png]" ..
"image_button[3.15,4.84;3.45,0.92;;world_create;;true;false]" .. "image_button[3.15,4.84;3.45,0.92;;world_create;;true;false]" ..
"tooltip[world_create;".. fgettext("New") .. "]" .. "tooltip[world_create;".. fgettext("New") .. "]" ..
"style[play;fgimg=" .. defaulttexturedir .. "btn_play.png;fgimg_hovered=" .. btn_style("play") ..
defaulttexturedir .. "btn_play_hover.png]" .. "style[play;font_size=*" .. (small_screen and 2.25 or 3) .. "]" ..
"image_button[6.72,1.43;4.96,1.41;;play;;true;false]" .. "image_button[6.72,1.43;4.96,1.41;;play;" .. space .. " " ..
fgettext("Play") .. space .. ";true;false]" ..
"image[7,1.63;1,1;" .. defaulttexturedir_esc .. "btn_play_icon.png]" ..
"tooltip[play;".. fgettext("Play Game") .. "]" .. "tooltip[play;".. fgettext("Play Game") .. "]" ..
"image_button[7.2,3.09;4,0.83;" .. defaulttexturedir .. creative_bg .. ";;;true;false]" .. "image_button[7.2,3.09;4,0.83;" .. defaulttexturedir_esc .. creative_bg .. ";;;true;false]" ..
"style[cb_creative_mode;content_offset=0]" .. "style[cb_creative_mode;content_offset=0]" ..
"image_button[7.2,3.09;4,0.83;" .. defaulttexturedir .. creative_checkbox .. "image_button[7.2,3.09;4,0.83;" .. defaulttexturedir_esc .. creative_checkbox ..
";cb_creative_mode;;true;false]" .. ";cb_creative_mode;;true;false]" ..
"background9[0,0;6.5,4.8;" .. defaulttexturedir .. "worldlist_bg.png" .. ";false;40]" .. "background9[0,0;6.5,4.8;" .. defaulttexturedir_esc .. "worldlist_bg.png" .. ";false;40]" ..
"tableoptions[background=#0000;border=false]" .. "tableoptions[background=#0000;border=false]" ..
"table[0,0;6.28,4.64;sp_worlds;" .. menu_render_worldlist() .. ";" .. index .. "]" .. "table[0,0;6.28,4.64;sp_worlds;" .. menu_render_worldlist() .. ";" .. index .. "]" ..
"style[switch_local;fgimg=" .. defaulttexturedir .. "switch_local.png;fgimg_hovered=" .. "style[switch_local;fgimg=" .. defaulttexturedir_esc .. "switch_local.png;fgimg_hovered=" ..
defaulttexturedir .. "switch_local_hover.png]" .. defaulttexturedir_esc .. "switch_local_hover.png]" ..
"image_button[10.6,-0.1;1.5,1.5;;switch_local;;true;false]" "image_button[10.6,-0.1;1.5,1.5;;switch_local;;true;false]"
if PLATFORM == "Android" then if PLATFORM == "Android" then
retval = retval .. retval = retval ..
"image_button[6.6,-0.1;1.5,1.5;" .. "image_button[6.6,-0.1;1.5,1.5;" ..
defaulttexturedir .. "gift_btn.png;upgrade;;true;false;" .. defaulttexturedir_esc .. "gift_btn.png;upgrade;;true;false;" ..
defaulttexturedir .. "gift_btn_pressed.png]" defaulttexturedir_esc .. "gift_btn_pressed.png]"
end end
local enable_server = core.settings:get_bool("enable_server") local enable_server = core.settings:get_bool("enable_server")
@ -138,7 +142,7 @@ local function get_formspec(this)
retval = retval .. retval = retval ..
-- Name / Password -- Name / Password
"field[6.9,4.6;2.8,0.5;te_playername;" .. fgettext("Name") .. ":;" .. "field[6.9,4.6;2.8,0.5;te_playername;" .. fgettext("Name") .. ":;" ..
esc(core.settings:get("name")) .. "]" .. core.formspec_escape(core.settings:get("name")) .. "]" ..
"pwdfield[9.6,4.6;2.8,0.5;te_passwd;" .. fgettext("Password") .. ":]" "pwdfield[9.6,4.6;2.8,0.5;te_passwd;" .. fgettext("Password") .. ":]"
end end

View File

@ -19,8 +19,8 @@
local password_tmp = "" local password_tmp = ""
local esc = core.formspec_escape local esc = core.formspec_escape
local defaulttexturedir = esc(defaulttexturedir)
local lower = utf8.lower local lower = utf8.lower
local small_screen = (PLATFORM == "Android" or PLATFORM == "iOS") and not core.settings:get_bool("device_is_tablet")
local function get_formspec(tabview, name, tabdata) local function get_formspec(tabview, name, tabdata)
-- Update the cached supported proto info, -- Update the cached supported proto info,
@ -46,41 +46,52 @@ local function get_formspec(tabview, name, tabdata)
local retval = local retval =
-- Search -- Search
"formspec_version[3]" .. "formspec_version[3]" ..
"image[-0.1,4.9;7,0.89;" .. defaulttexturedir .. "desc_bg.png;32]" .. "image[-0.1,4.93;7,0.81;" .. defaulttexturedir_esc .. "field_bg.png;32]" ..
"style[Dte_search;border=false;bgcolor=transparent]" .. "style[Dte_search;border=false;bgcolor=transparent]" ..
"field[0.25,5.2;5.75,1;Dte_search;;" .. esc(tabdata.search_for) .. "]" .. "field[0.25,5.25;5.7,0.83;Dte_search;;" .. esc(tabdata.search_for) .. "]" ..
"image_button[5.6,4.93;0.83,0.83;" .. defaulttexturedir .. btn_style("btn_mp_search") ..
"image_button[5.6,4.93;0.83,0.83;" .. defaulttexturedir_esc ..
"search.png;btn_mp_search;;true;false]" .. "search.png;btn_mp_search;;true;false]" ..
"image_button[6.35,4.93;0.83,0.83;" .. defaulttexturedir .. btn_style("btn_mp_refresh") ..
"image_button[6.35,4.93;0.83,0.83;" .. defaulttexturedir_esc ..
"refresh.png;btn_mp_refresh;;true;false]" .. "refresh.png;btn_mp_refresh;;true;false]" ..
-- Address / Port -- Address / Port
"field[7.4,0.55;5,0.5;te_address;" .. fgettext("Address / Port") .. ":" .. ";" .. "image[7.1,0.09;6,0.8;" .. defaulttexturedir_esc .. "field_bg.png;32]" ..
"style[te_address;border=false;bgcolor=transparent]" ..
"field[7.45,0.55;4.9,0.5;te_address;" .. fgettext("Address / Port") .. ":" .. ";" ..
esc(address) .. "]" .. esc(address) .. "]" ..
-- Name -- Name
"field[7.4,1.7;3.2,0.5;te_name;" .. fgettext("Name") .. ":" .. ";" .. "image[7.1,1.25;2.95,0.8;" .. defaulttexturedir_esc .. "field_bg.png;32]" ..
"style[te_name;border=false;bgcolor=transparent]" ..
"field[7.45,1.7;2.45,0.5;te_name;" .. fgettext("Name") .. ":" .. ";" ..
esc(core.settings:get("name")) .. "]" .. esc(core.settings:get("name")) .. "]" ..
-- Password
"image[9.55,1.25;2.95,0.8;" .. defaulttexturedir_esc .. "field_bg.png;32]" ..
"style[te_pwd;border=false;bgcolor=transparent]" ..
"pwdfield[9.9,1.7;2.45,0.5;te_pwd;" .. fgettext("Password") .. ":" .. ";" ..
esc(password_tmp) .. "]" ..
-- Description Background -- Description Background
"background9[7.2,2.2;4.8,2.65;" .. defaulttexturedir .. "desc_bg.png" .. ";false;32]" .. "background9[7.2,2.2;4.8,2.65;" .. defaulttexturedir_esc .. "desc_bg.png" .. ";false;32]" ..
-- Connect -- Connect
"style[btn_mp_connect;fgimg=" .. defaulttexturedir .. btn_style("btn_mp_connect") ..
"btn_play.png;fgimg_hovered=" .. defaulttexturedir .. "btn_play_hover.png]" .. "style[btn_mp_connect;font_size=*" .. (small_screen and 1.5 or 2) .. "]" ..
"image_button[8.8,4.9;3.3,0.9;;btn_mp_connect;;true;false]" .. "image_button[8.8,4.88;3.3,0.9;;btn_mp_connect;" ..
"tooltip[btn_mp_connect;".. fgettext("Connect") .. "]" ("\n"):rep(3) .. " " .. fgettext("Play") .. ("\n"):rep(3) .. ";true;false]" .. -- Connect
"image[9,5;0.6,0.6;" .. defaulttexturedir_esc .. "btn_play_icon.png]" ..
-- Password "tooltip[btn_mp_connect;" .. fgettext("Connect") .. "]"
retval = retval .. "pwdfield[10.45,1.7;1.95,0.5;te_pwd;" ..
fgettext("Password") .. ":" .. ";" .. esc(password_tmp) .. "]"
if tabdata.selected and selected then if tabdata.selected and selected then
if gamedata.fav then if gamedata.fav then
retval = retval .. retval = retval ..
"style[btn_delete_favorite;fgimg=" .. defaulttexturedir .. btn_style("btn_delete_favorite", "red") ..
"trash.png;fgimg_hovered=" .. defaulttexturedir .. "trash_hover.png]" .. "image_button[7.1,4.93;0.83,0.83;" .. defaulttexturedir_esc ..
"image_button[7.1,4.93;0.83,0.83;;btn_delete_favorite;;true;false]" "trash.png;btn_delete_favorite;;true;false;" .. defaulttexturedir_esc .. "trash_pressed.png]" ..
"tooltip[btn_delete_favorite;" .. fgettext("Del. Favorite") .. "]"
end end
if selected.description then if selected.description then
retval = retval .. "textarea[7.5,2.2;4.8,3;;" .. retval = retval .. "textarea[7.5,2.2;4.8,3;;" ..
@ -91,7 +102,7 @@ local function get_formspec(tabview, name, tabdata)
--favorites --favorites
retval = retval .. retval = retval ..
"background9[0,-0.1;7.1,5;" .. "background9[0,-0.1;7.1,5;" ..
defaulttexturedir .. "worldlist_bg.png" .. ";false;40]" .. defaulttexturedir_esc .. "worldlist_bg.png" .. ";false;40]" ..
"tableoptions[background=#0000;border=false]" .. "tableoptions[background=#0000;border=false]" ..
"tablecolumns[" .. "tablecolumns[" ..
image_column(fgettext("Favorite")) .. ",align=center;" .. image_column(fgettext("Favorite")) .. ",align=center;" ..

View File

@ -172,10 +172,12 @@ local function formspec(tabview, name, tabdata)
end end
tab_string = tab_string .. tab_string = tab_string ..
btn_style("btn_change_keys") ..
"button[8,4.75;3.95,1;btn_change_keys;" "button[8,4.75;3.95,1;btn_change_keys;"
.. fgettext("Change Keys") .. "]" .. fgettext("Change Keys") .. "]"
tab_string = tab_string .. tab_string = tab_string ..
btn_style("btn_advanced_settings") ..
"button[0,4.75;3.95,1;btn_advanced_settings;" "button[0,4.75;3.95,1;btn_advanced_settings;"
.. fgettext("All Settings") .. "]" .. fgettext("All Settings") .. "]"

View File

@ -19,13 +19,22 @@
local function create_confirm_reset_dlg() local function create_confirm_reset_dlg()
return dialog_create("reset_all_settings", return dialog_create("reset_all_settings",
function() function()
return return table.concat({
"image_button[2,1;8,3;" .. core.formspec_escape(defaulttexturedir .. "real_coordinates[true]",
"blank.png") .. ";;" .. fgettext("Reset all settings?") .. "image[6.5,0.8;2.5,2.5;", defaulttexturedir_esc, "attention.png]",
";true;false;]" ..
"style[reset_confirm;bgcolor=red]" .. "style[msg;content_offset=0]",
"button[3,4.8;3,0.5;reset_confirm;" .. fgettext("Reset") .. "]" .. "image_button[1,3.5;13.5,0.8;;msg;",
"button[6,4.8;3,0.5;reset_cancel;" .. fgettext("Cancel") .. "]" fgettext("Reset all settings?"), ";false;false]",
btn_style("reset_confirm", "red"),
"image_button[4.1,5.3;3.5,0.8;;reset_confirm;",
fgettext("Reset"), ";true;false]",
btn_style("reset_cancel"),
"image_button[7.9,5.3;3.5,0.8;;reset_cancel;",
fgettext("Cancel"), ";true;false]",
})
end, end,
function(this, fields) function(this, fields)
if fields["reset_confirm"] then if fields["reset_confirm"] then
@ -84,7 +93,7 @@ local function formspec(tabview, name, tabdata)
local sensitivity = tonumber(core.settings:get("touch_sensitivity")) * 2000 local sensitivity = tonumber(core.settings:get("touch_sensitivity")) * 2000
local touchtarget = core.settings:get_bool("touchtarget") or false local touchtarget = core.settings:get_bool("touchtarget") or false
local fancy_leaves = core.settings:get("leaves_style") == "fancy" local fancy_leaves = core.settings:get("leaves_style") == "fancy"
local fast_move = core.settings:get_bool("fast_move") or false local arm_inertia = core.settings:get_bool("arm_inertia") or false
local sound = tonumber(core.settings:get("sound_volume")) ~= 0 and true or false local sound = tonumber(core.settings:get("sound_volume")) ~= 0 and true or false
local tab_string = local tab_string =
@ -107,8 +116,8 @@ local function formspec(tabview, name, tabdata)
.. dump(fancy_leaves) .. "]" .. .. dump(fancy_leaves) .. "]" ..
"checkbox[0.15,3.5;cb_touchtarget;" .. fgettext("Touchtarget") .. ";" "checkbox[0.15,3.5;cb_touchtarget;" .. fgettext("Touchtarget") .. ";"
.. dump(touchtarget) .. "]" .. .. dump(touchtarget) .. "]" ..
"checkbox[0.15,4.1;cb_fast_move;" .. fgettext("Fast movement") .. ";" "checkbox[0.15,4.1;cb_arm_inertia;" .. fgettext("Arm inertia") .. ";"
.. dump(fast_move) .. "]" .. .. dump(arm_inertia) .. "]" ..
"checkbox[0.15,4.7;cb_sound;" .. fgettext("Sound") .. ";" "checkbox[0.15,4.7;cb_sound;" .. fgettext("Sound") .. ";"
.. dump(sound) .. "]" .. .. dump(sound) .. "]" ..
@ -146,10 +155,12 @@ local function formspec(tabview, name, tabdata)
end end
--[[tab_string = tab_string .. --[[tab_string = tab_string ..
btn_style("btn_change_keys") ..
"button[8,3.22;3.95,1;btn_change_keys;" "button[8,3.22;3.95,1;btn_change_keys;"
.. fgettext("Change Keys") .. "]" .. fgettext("Change Keys") .. "]"
tab_string = tab_string .. tab_string = tab_string ..
btn_style("btn_advanced_settings") ..
"button[8,4.57;3.95,1;btn_advanced_settings;" "button[8,4.57;3.95,1;btn_advanced_settings;"
.. fgettext("All Settings") .. "]"]] .. fgettext("All Settings") .. "]"]]
@ -179,6 +190,7 @@ local function formspec(tabview, name, tabdata)
"label[8.25,3.35;" .. fgettext("Language") .. ":]" .. "label[8.25,3.35;" .. fgettext("Language") .. ":]" ..
"dropdown[8.25,3.8;3.58;dd_language;" .. language_dropdown .. ";" .. "dropdown[8.25,3.8;3.58;dd_language;" .. language_dropdown .. ";" ..
lang_idx .. ";true]" .. lang_idx .. ";true]" ..
btn_style("btn_reset") ..
"button[8.25,4.81;3.5,0.8;btn_reset;" .. fgettext("Reset all settings") .. "]" "button[8.25,4.81;3.5,0.8;btn_reset;" .. fgettext("Reset all settings") .. "]"
return tab_string return tab_string
@ -229,8 +241,8 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
core.settings:set("touchtarget", fields["cb_touchtarget"]) core.settings:set("touchtarget", fields["cb_touchtarget"])
return true return true
end end
if fields["cb_fast_move"] then if fields["cb_arm_inertia"] then
core.settings:set("fast_move", fields["cb_fast_move"]) core.settings:set("arm_inertia", fields["cb_arm_inertia"])
return true return true
end end
if fields["cb_sound"] then if fields["cb_sound"] then

View File

@ -4351,15 +4351,18 @@ void Game::showPauseMenu()
#ifdef __IOS__ #ifdef __IOS__
ypos += 0.5f; ypos += 0.5f;
#endif #endif
const bool high_dpi = RenderingEngine::isHighDpi();
const std::string x2 = high_dpi ? ".x2" : "";
std::ostringstream os; std::ostringstream os;
os << "formspec_version[1]" << SIZE_TAG os << "formspec_version[1]" << SIZE_TAG
<< "no_prepend[]" << "no_prepend[]"
<< "bgcolor[#00000060;true]" << "bgcolor[#00000060;true]"
<< "style_type[image_button_exit,image_button;bgimg=gui_button.png;bgimg_middle=20;padding=-10]" << "style_type[image_button_exit,image_button;bgimg=gui/gui_button" << x2 <<
<< "style_type[image_button_exit,image_button:hovered;bgimg=gui_button_hovered.png]" ".png;bgimg_middle=" << (high_dpi ? "48" : "32") << ";padding=" << (high_dpi ? "-30" : "-20") << "]"
<< "style_type[image_button_exit,image_button:pressed;bgimg=gui_button_pressed.png]" << "style_type[image_button_exit,image_button:hovered;bgimg=gui/gui_button_hovered" << x2 << ".png]"
<< "style_type[image_button_exit,image_button:pressed;bgimg=gui/gui_button_pressed" << x2 << ".png]"
<< "image_button_exit[3.5," << (ypos++) << ";4,0.9;;btn_continue;" << "image_button_exit[3.5," << (ypos++) << ";4,0.9;;btn_continue;"
<< strgettext("Continue") << ";;false]"; << strgettext("Continue") << ";;false]";
@ -4452,6 +4455,8 @@ void Game::showChangePasswordDialog(std::string old_pw, std::string new_pw,
str_formspec_escape(new_pw); str_formspec_escape(new_pw);
str_formspec_escape(confirm_pw); str_formspec_escape(confirm_pw);
const bool high_dpi = RenderingEngine::isHighDpi();
const std::string x2 = high_dpi ? ".x2" : "";
std::ostringstream os; std::ostringstream os;
os << "formspec_version[5]" os << "formspec_version[5]"
<< "size[10.5,7.5]" << "size[10.5,7.5]"
@ -4461,9 +4466,10 @@ void Game::showChangePasswordDialog(std::string old_pw, std::string new_pw,
<< "pwdfield[1,1.2;8.5,0.8;old_pw;" << strgettext("Old Password") << ":;" << old_pw << "]" << "pwdfield[1,1.2;8.5,0.8;old_pw;" << strgettext("Old Password") << ":;" << old_pw << "]"
<< "pwdfield[1,2.8;8.5,0.8;new_pw;" << strgettext("New Password") << ":;" << new_pw << "]" << "pwdfield[1,2.8;8.5,0.8;new_pw;" << strgettext("New Password") << ":;" << new_pw << "]"
<< "pwdfield[1,4.4;8.5,0.8;confirm_pw;" << strgettext("Confirm Password") << ":;" << confirm_pw << "]" << "pwdfield[1,4.4;8.5,0.8;confirm_pw;" << strgettext("Confirm Password") << ":;" << confirm_pw << "]"
<< "style_type[image_button_exit,image_button;bgimg=gui_button.png;bgimg_middle=20;padding=-10]" << "style_type[image_button_exit,image_button;bgimg=gui/gui_button" << x2
<< "style_type[image_button_exit,image_button:hovered;bgimg=gui_button_hovered.png]" << ".png;bgimg_middle=" << (high_dpi ? "48" : "32") << ";padding=" << (high_dpi ? "-30" : "-20") << "]"
<< "style_type[image_button_exit,image_button:pressed;bgimg=gui_button_pressed.png]" << "style_type[image_button_exit,image_button:hovered;bgimg=gui/gui_button_hovered" << x2 << ".png]"
<< "style_type[image_button_exit,image_button:pressed;bgimg=gui/gui_button_pressed" << x2 << ".png]"
<< "image_button[1,5.9;4.1,0.8;;btn_change_pw;" << strgettext("Change") << ";;false]" << "image_button[1,5.9;4.1,0.8;;btn_change_pw;" << strgettext("Change") << ";;false]"
<< "image_button_exit[5.4,5.9;4.1,0.8;;btn_cancel;" << strgettext("Cancel") << ";;false]"; << "image_button_exit[5.4,5.9;4.1,0.8;;btn_cancel;" << strgettext("Cancel") << ";;false]";

View File

@ -801,3 +801,15 @@ v2u32 RenderingEngine::getDisplaySize()
return engine->getWindowSize(); return engine->getWindowSize();
} }
#endif // __ANDROID__/__IOS__ #endif // __ANDROID__/__IOS__
bool RenderingEngine::isHighDpi()
{
#if defined(__MACH__) && defined(__APPLE__) && !defined(__IOS__)
return g_settings->getFloat("screen_dpi") / 72.0f >= 2;
#elif defined(__IOS__)
float density = RenderingEngine::getDisplayDensity();
return g_settings->getBool("device_is_tablet") ? (density >= 2) : (density >= 3);
#else
return RenderingEngine::getDisplayDensity() >= 3;
#endif
}

View File

@ -50,6 +50,7 @@ public:
static const char *getVideoDriverFriendlyName(irr::video::E_DRIVER_TYPE type); static const char *getVideoDriverFriendlyName(irr::video::E_DRIVER_TYPE type);
static float getDisplayDensity(); static float getDisplayDensity();
static v2u32 getDisplaySize(); static v2u32 getDisplaySize();
static bool isHighDpi();
bool setupTopLevelWindow(const std::string &name); bool setupTopLevelWindow(const std::string &name);
void setupTopLevelXorgWindow(const std::string &name); void setupTopLevelXorgWindow(const std::string &name);

View File

@ -133,13 +133,17 @@ SubgameSpec findSubgame(const std::string &id)
if (conf.exists("release")) if (conf.exists("release"))
game_release = conf.getS32("release"); game_release = conf.getS32("release");
bool moddable = true;
if (conf.exists("moddable"))
moddable = conf.getBool("moddable");
std::string menuicon_path; std::string menuicon_path;
#ifndef SERVER #ifndef SERVER
menuicon_path = getImagePath( menuicon_path = getImagePath(
game_path + DIR_DELIM + "menu" + DIR_DELIM + "icon.png"); game_path + DIR_DELIM + "menu" + DIR_DELIM + "icon.png");
#endif #endif
return SubgameSpec(id, game_path, gamemod_path, mods_paths, game_name, return SubgameSpec(id, game_path, gamemod_path, mods_paths, game_name,
menuicon_path, game_author, game_release); menuicon_path, game_author, game_release, moddable);
} }
SubgameSpec findWorldSubgame(const std::string &world_path) SubgameSpec findWorldSubgame(const std::string &world_path)

View File

@ -35,6 +35,7 @@ struct SubgameSpec
std::string gamemods_path; std::string gamemods_path;
std::set<std::string> addon_mods_paths; std::set<std::string> addon_mods_paths;
std::string menuicon_path; std::string menuicon_path;
bool moddable;
SubgameSpec(const std::string &id = "", const std::string &path = "", SubgameSpec(const std::string &id = "", const std::string &path = "",
const std::string &gamemods_path = "", const std::string &gamemods_path = "",
@ -42,11 +43,12 @@ struct SubgameSpec
std::set<std::string>(), std::set<std::string>(),
const std::string &name = "", const std::string &name = "",
const std::string &menuicon_path = "", const std::string &menuicon_path = "",
const std::string &author = "", int release = 0) : const std::string &author = "", int release = 0,
const bool moddable = true) :
id(id), id(id),
name(name), author(author), release(release), path(path), name(name), author(author), release(release), path(path),
gamemods_path(gamemods_path), addon_mods_paths(addon_mods_paths), gamemods_path(gamemods_path), addon_mods_paths(addon_mods_paths),
menuicon_path(menuicon_path) menuicon_path(menuicon_path), moddable(moddable)
{ {
} }

View File

@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/tile.h" // ITextureSource #include "client/tile.h" // ITextureSource
#include "client/fontengine.h" #include "client/fontengine.h"
#include "client/renderingengine.h"
#include "debug.h" #include "debug.h"
#include "irrlichttypes_extrabloated.h" #include "irrlichttypes_extrabloated.h"
#include "util/string.h" #include "util/string.h"
@ -75,20 +76,22 @@ public:
static std::array<StyleSpec, NUM_STATES> getButtonStyle(const std::string texture_path = "") { static std::array<StyleSpec, NUM_STATES> getButtonStyle(const std::string texture_path = "") {
std::array<StyleSpec, NUM_STATES> ret; std::array<StyleSpec, NUM_STATES> ret;
const bool high_dpi = RenderingEngine::isHighDpi();
const std::string x2 = high_dpi ? ".x2" : "";
StyleSpec btn_spec; StyleSpec btn_spec;
btn_spec.set(BGIMG, texture_path + "gui_button.png"); btn_spec.set(BGIMG, texture_path + "gui/gui_button" + x2 + ".png");
btn_spec.set(BGIMG_MIDDLE, "20"); btn_spec.set(BGIMG_MIDDLE, high_dpi ? "48" : "32");
btn_spec.set(BORDER, "false"); btn_spec.set(BORDER, "false");
btn_spec.set(PADDING, "-10"); btn_spec.set(PADDING, high_dpi ? "-30" : "-20");
ret[STATE_DEFAULT] = btn_spec; ret[STATE_DEFAULT] = btn_spec;
StyleSpec hovered_spec; StyleSpec hovered_spec;
hovered_spec.set(BGIMG, texture_path + "gui_button_hovered.png"); hovered_spec.set(BGIMG, texture_path + "gui/gui_button_hovered" + x2 + ".png");
ret[STATE_HOVERED] = hovered_spec; ret[STATE_HOVERED] = hovered_spec;
StyleSpec pressed_spec; StyleSpec pressed_spec;
pressed_spec.set(BGIMG, texture_path + "gui_button_pressed.png"); pressed_spec.set(BGIMG, texture_path + "gui/gui_button_pressed" + x2 + ".png");
ret[STATE_PRESSED] = pressed_spec; ret[STATE_PRESSED] = pressed_spec;
return ret; return ret;

View File

@ -1563,6 +1563,9 @@ void GUIFormSpecMenu::parsePwdField(parserData* data, const std::string &element
e->setNotClipped(style.getBool(StyleSpec::NOCLIP, false)); e->setNotClipped(style.getBool(StyleSpec::NOCLIP, false));
e->setDrawBorder(style.getBool(StyleSpec::BORDER, true)); e->setDrawBorder(style.getBool(StyleSpec::BORDER, true));
e->setOverrideColor(style.getColor(StyleSpec::TEXTCOLOR, video::SColor(0xFFFFFFFF))); e->setOverrideColor(style.getColor(StyleSpec::TEXTCOLOR, video::SColor(0xFFFFFFFF)));
if (style.get(StyleSpec::BGCOLOR, "") == "transparent") {
e->setDrawBackground(false);
}
e->setOverrideFont(style.getFont()); e->setOverrideFont(style.getFont());
irr::SEvent evt; irr::SEvent evt;

View File

@ -326,6 +326,10 @@ int ModApiMainMenu::l_get_games(lua_State *L)
lua_pushstring(L, game.menuicon_path.c_str()); lua_pushstring(L, game.menuicon_path.c_str());
lua_settable(L, top_lvl2); lua_settable(L, top_lvl2);
lua_pushstring(L, "moddable");
lua_pushboolean(L, game.moddable);
lua_settable(L, top_lvl2);
lua_pushstring(L, "addon_mods_paths"); lua_pushstring(L, "addon_mods_paths");
lua_newtable(L); lua_newtable(L);
int table2 = lua_gettop(L); int table2 = lua_gettop(L);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 259 B

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 B

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 690 B

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 435 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 435 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 435 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 425 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 517 B

After

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 517 B

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 B

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 273 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 187 B

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 570 B

After

Width:  |  Height:  |  Size: 73 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 194 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 660 B

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 329 B

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 329 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 B