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.
local defaulttexturedir = core.formspec_escape(defaulttexturedir)
local function buttonbar_formspec(self)
if self.hidden then
@ -25,7 +23,7 @@ local function buttonbar_formspec(self)
end
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
local btn_name = self.buttons[i].name
@ -62,8 +60,8 @@ local function buttonbar_formspec(self)
if button.cdb then
formspec = formspec ..
"style[" .. btn_name .. ";bgimg=" .. defaulttexturedir ..
"btn_download.png;bgimg_hovered=" .. defaulttexturedir .. "btn_download_hover.png]" ..
"style[" .. btn_name .. ";bgimg=" .. defaulttexturedir_esc ..
"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(
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)
else
formspec = formspec ..
"style[btnbar_dec_" .. self.name .. ";bgimg=" .. defaulttexturedir ..
"btn_up.png;bgimg_hovered=" .. defaulttexturedir .. "btn_up_hover.png]" ..
"style[btnbar_dec_" .. self.name .. ";bgimg=" .. defaulttexturedir_esc ..
"btn_up.png;bgimg_hovered=" .. defaulttexturedir_esc .. "btn_up_hover.png]" ..
("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,
self.name)
formspec = formspec ..
"style[btnbar_inc_" .. self.name .. ";bgimg=" .. defaulttexturedir ..
"btn_down.png;bgimg_hovered=" .. defaulttexturedir .. "btn_down_hover.png]" ..
"style[btnbar_inc_" .. self.name .. ";bgimg=" .. defaulttexturedir_esc ..
"btn_down.png;bgimg_hovered=" .. defaulttexturedir_esc .. "btn_down_hover.png]" ..
("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,
self.name)

View File

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

View File

@ -26,8 +26,6 @@
-- element.getFormspec() returns formspec of tabview --
--------------------------------------------------------------------------------
local defaulttexturedir = core.formspec_escape(defaulttexturedir)
--------------------------------------------------------------------------------
local function add_tab(self,tab)
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 formspec = "style[" .. tab_name .. "_tab;bgimg=" ..
defaulttexturedir .. tab_name
defaulttexturedir_esc .. tab_name
if selected then
formspec = formspec .. "_menu_selected.png]"
else
formspec = formspec .. "_menu.png;bgimg_hovered=" ..
defaulttexturedir .. tab_name .. "_menu_hover.png]"
defaulttexturedir_esc .. tab_name .. "_menu_hover.png]"
end
return formspec ..
@ -98,14 +96,15 @@ local function get_formspec(self)
string.format("size[%f,%f,%s]",tsize.width + 2,tsize.height + 1,
dump(self.fixed_size)) ..
"bgcolor[#0000]" ..
"listcolors[#000;#000;#000;#dff6f5;#302c2e]" ..
"container[1,1]" ..
"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]" ..
"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") ..
"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")
end
@ -207,27 +206,28 @@ end]]
--------------------------------------------------------------------------------
local function button_header(self)
local visible_tabs = {}
local btn_widths = {}
local total_width = 0
-- local btn_widths = {}
-- local total_width = 0
for i, tab in ipairs(self.tablist) do
if not tab.hidden and tab.caption ~= "" then
visible_tabs[#visible_tabs + 1] = tab
local w = utf8.len(core.get_translated_string(tab.caption))
btn_widths[#visible_tabs] = w
total_width = total_width + w
-- local w = math.max(utf8.len(core.get_translated_string(tab.caption)), 10)
-- btn_widths[#visible_tabs] = w
-- total_width = total_width + w
end
end
local toadd = ""
local coords_per_char = 12 / total_width
-- local coords_per_char = 12 / total_width
-- The formspec is 15.4875 "real" coordinates wide
-- local x = (12.39 - total_width) / 2 - 0.3
local x = -0.1
local w = 12 / #visible_tabs
for i = 1, #visible_tabs do
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"
if i == 1 then
texture = "upper_buttons_left"
@ -236,13 +236,13 @@ local function button_header(self)
end
local btn_name = self.name .. "_" .. i
toadd = toadd ..
"style[" .. btn_name .. ";padding=-10;bgimg=" .. defaulttexturedir ..
"style[" .. btn_name .. ";padding=-10;bgimg=" .. defaulttexturedir_esc ..
texture
if i == math.abs(self.last_tab_index) then
toadd = toadd .. "_selected.png;"
else
toadd = toadd .. ".png;bgimg_hovered=" .. defaulttexturedir ..
toadd = toadd .. ".png;bgimg_hovered=" .. defaulttexturedir_esc ..
texture .. "_hover.png;"
end
@ -293,7 +293,7 @@ local function handle_tab_buttons(self,fields)
for field in pairs(fields) do
if field:sub(1, name_prefix_len) == name_prefix then
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)
return true
end

View File

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

View File

@ -300,3 +300,36 @@ function get_language_list()
return languages, language_dropdown, lang_idx, language_name_list
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 retval =
"size[11.5,7.5,false]" ..
"size[11.5,7.5]" ..
"bgcolor[#0000]" ..
"background9[0,0;0,0;" .. core.formspec_escape(defaulttexturedir ..
"bg_common.png") .. ";true;40]" ..
"label[0.5,0;" .. fgettext("World:") .. "]" ..
"label[1.75,0;" .. data.worldspec.name .. "]"
"background9[0,0;0,0;" .. defaulttexturedir_esc .. "bg_common.png;true;40]" ..
"background9[0.05,0.05;5.3,6.8;" .. defaulttexturedir_esc .. "desc_bg.png;false;32]" ..
"label[0.1,0;" .. fgettext("World:") .. " " .. data.worldspec.name .. "]"
if mod.is_modpack or mod.type == "game" then
local info = core.formspec_escape(
@ -87,56 +86,59 @@ local function get_formspec(data)
end
end
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
local hard_deps, soft_deps = pkgmgr.get_dependencies(mod.path)
local hard_deps_str = table.concat(hard_deps, ",")
local soft_deps_str = table.concat(soft_deps, ",")
retval = retval ..
"label[0,0.7;" .. fgettext("Mod:") .. "]" ..
"label[0.75,0.7;" .. mod.name .. "]"
"label[0.1,0.7;" .. fgettext("Mod:") .. " " .. mod.name .. "]"
if hard_deps_str == "" then
if soft_deps_str == "" then
retval = retval ..
"label[0,1.25;" ..
"label[0.1,1.25;" ..
fgettext("No (optional) dependencies") .. "]"
else
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]"
end
else
if soft_deps_str == "" then
retval = retval ..
"label[0,1.25;" .. fgettext("Dependencies:") .. "]" ..
"textlist[0,1.75;5,4;world_config_depends;" ..
"label[0.1,1.25;" .. fgettext("Dependencies:") .. "]" ..
"textlist[0.1,1.75;5,4;world_config_depends;" ..
hard_deps_str .. ";0]" ..
"label[0,6;" .. fgettext("No optional dependencies") .. "]"
"label[0.1,6;" .. fgettext("No optional dependencies") .. "]"
else
retval = retval ..
"label[0,1.25;" .. fgettext("Dependencies:") .. "]" ..
"textlist[0,1.75;5,2.125;world_config_depends;" ..
"label[0.1,1.25;" .. fgettext("Dependencies:") .. "]" ..
"textlist[0.1,1.75;5,2.125;world_config_depends;" ..
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]"
end
end
end
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") .. "]" ..
"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") .. "]" ..
"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") .. "]"
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
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") .. "]"
else
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") .. "]"
end
else
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) .. "]"
end
end
if enabled_all then
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") .. "]"
else
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") .. "]"
end
return retval ..

View File

@ -15,6 +15,8 @@
--with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
local esc = core.formspec_escape
if not core.get_http_api then
function create_store_dlg()
return messagebox("store",
@ -104,9 +106,6 @@ local function start_install(package)
elseif package.type == "game" then
conf_path = path .. DIR_DELIM .. "game.conf"
name_is_title = true
ui.childlist = {}
menudata.init_tabs()
elseif package.type == "txp" then
conf_path = path .. DIR_DELIM .. "texture_pack.conf"
end
@ -325,7 +324,7 @@ function install_dialog.get_formspec()
selected_game_idx = i
end
games[i] = core.formspec_escape(games[i].name)
games[i] = esc(games[i].name)
end
local selected_game = pkgmgr.games[selected_game_idx]
@ -336,7 +335,7 @@ function install_dialog.get_formspec()
local formatted_deps = {}
for _, dep in pairs(install_dialog.dependencies) do
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
formatted_deps[#formatted_deps + 1] = "#ccf"
formatted_deps[#formatted_deps + 1] = fgettext("Already installed")
@ -368,8 +367,9 @@ function install_dialog.get_formspec()
local formspec = {
"formspec_version[3]",
"size[7,7.85]",
"bgcolor[#0000]",
"background9[0,0;0,0;", defaulttexturedir_esc, "bg_common.png", ";true;40]",
"style[title;border=false]",
"box[0,0;7,0.5;#3333]",
"button[0,0;7,0.5;title;", fgettext("Install $1", package.title) , "]",
"container[0.375,0.70]",
@ -388,13 +388,13 @@ function install_dialog.get_formspec()
fgettext("Install missing dependencies"), ";",
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, "]",
"container[1.375,6.85]",
"button[0,0;2,0.8;install_all;", fgettext("Install"), "]",
"button[2.25,0;2,0.8;cancel;", fgettext("Cancel"), "]",
"container_end[]",
btn_style("install_all"),
"button[0.5,6.85;2.8,0.8;install_all;", fgettext("Install"), "]",
btn_style("cancel"),
"button[3.75,6.85;2.8,0.8;cancel;", fgettext("Cancel"), "]",
}
return table.concat(formspec, "")
@ -455,11 +455,12 @@ local confirm_overwrite = {}
function confirm_overwrite.get_formspec()
local package = confirm_overwrite.package
return "size[11.5,4.5,true]" ..
return "size[11.5,4.5]" ..
"label[2,2;" ..
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") .. "]" ..
btn_style("cancel") ..
"button[5.75,3.5;2.5,0.5;cancel;" .. fgettext("Cancel") .. "]"
end
@ -498,9 +499,9 @@ end
local function get_screenshot(package)
if not package.thumbnail then
return defaulttexturedir .. "no_screenshot.png"
return defaulttexturedir_esc .. "no_screenshot.png"
elseif screenshot_downloading[package.thumbnail] then
return defaulttexturedir .. "loading_screenshot.png"
return defaulttexturedir_esc .. "loading_screenshot.png"
end
-- Get tmp screenshot path
@ -512,12 +513,12 @@ local function get_screenshot(package)
local file = io.open(filepath, "r")
if file then
file:close()
return filepath
return esc(filepath)
end
-- Show error if we've failed to download before
if screenshot_downloaded[package.thumbnail] then
return defaulttexturedir .. "error_screenshot.png"
return defaulttexturedir_esc .. "error_screenshot.png"
end
-- Download
@ -538,10 +539,10 @@ local function get_screenshot(package)
screenshot_downloading[package.thumbnail] = true
else
core.log("error", "ERROR: async event failed")
return defaulttexturedir .. "error_screenshot.png"
return defaulttexturedir_esc .. "error_screenshot.png"
end
return defaulttexturedir .. "loading_screenshot.png"
return defaulttexturedir_esc .. "loading_screenshot.png"
end
function store.load()
@ -703,40 +704,48 @@ function store.get_formspec(dlgdata)
if #store.packages_full > 0 then
formspec = {
"formspec_version[3]",
"size[15.75,9.5;false]",
"bgcolor[#0000]" ..
"background9[0,0;0,0;", core.formspec_escape(defaulttexturedir ..
"bg_common.png"), ";true;40]",
"size[15.75,9.5]",
"bgcolor[#0000]",
"background9[0,0;0,0;", defaulttexturedir_esc, "bg_common.png;true;40]",
"style[status,downloading,queued;border=false]",
"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]",
"image_button[7.3,0;0.8,0.8;", core.formspec_escape(defaulttexturedir .. "search.png"), ";search;;true;false]",
-- "image_button[8.125,0;0.8,0.8;", core.formspec_escape(defaulttexturedir .. "clear.png"), ";clear;;true;false]",
-- "dropdown[9.6,0;2.4,0.8;type;", table.concat(filter_types_titles, ","), ";", filter_type, "]",
"set_focus[search_string;true]",
btn_style("search"),
"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[]",
-- Page nav buttons
"container[0,", H - 0.8 - 0.375, "]",
"style[back;padding=-5;bgimg=", core.formspec_escape(defaulttexturedir .. "select_btn.png"), ";bgimg_middle=10]",
"image_button[0.375,0;5,0.8;;back;", "< ", fgettext("Back to Main Menu"), ";true;false]",
btn_style("back"),
"button[0.375,0;5,0.8;back;< ", fgettext("Back to Main Menu"), "]",
"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;]",
"image_button[0.8,0;0.8,0.8;", core.formspec_escape(defaulttexturedir), "prev_icon.png;pback;]",
btn_style("pstart"),
"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]",
"button[1.6,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;]",
"image_button[4.4,0;0.8,0.8;", core.formspec_escape(defaulttexturedir), "end_icon.png;pend;]",
"button[1.5,0;2,0.8;pagenum;", tonumber(cur_page), " / ", tonumber(dlgdata.pagemax), "]",
btn_style("pnext"),
"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[]",
}
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
formspec[#formspec + 1] = fgettext("$1 downloading,\n$2 queued", number_downloading, #download_queue)
else
@ -754,32 +763,33 @@ function store.get_formspec(dlgdata)
end
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] = "]"
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] = "]"
end
end
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] = "]"
formspec[#formspec + 1] = ";false;false]"
end
else
formspec = {
"size[12,6.4;false]",
"bgcolor[#0000]" ..
"background9[0,0;0,0;", core.formspec_escape(defaulttexturedir ..
"bg_common.png"), ";true;40]",
"size[12,6.4]",
"bgcolor[#0000]",
"background9[0,0;0,0;", defaulttexturedir_esc, "bg_common.png;true;40]",
"label[4,3;", fgettext("No packages could be retrieved"), "]",
"container[0,", H - 0.8 - 0.375 - 2, "]",
"style[back;padding=-5;bgimg=", core.formspec_escape(defaulttexturedir .. "select_btn.png"), ";bgimg_middle=10]",
"image_button[0,0;4,0.8;;back;", "< ", fgettext("Back to Main Menu"), ";true;false]",
"container_end[]",
btn_style("back"),
"button[0-0.11,5.8;5.5,0.9;back;< ", fgettext("Back to Main Menu"), "]",
}
end
@ -798,29 +808,29 @@ function store.get_formspec(dlgdata)
-- image
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] = "]"
-- title
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("#BFBFBF", " by " .. package.author))
formspec[#formspec + 1] = "]"
-- 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] = W - 0.375*2
formspec[#formspec + 1] = ",0.1]"
if package.downloading then
formspec[#formspec + 1] = "animated_image[-1.7,-0.15;1,1;downloading;"
formspec[#formspec + 1] = core.formspec_escape(defaulttexturedir)
formspec[#formspec + 1] = "cdb_downloading.png;3;400;]"
formspec[#formspec + 1] = defaulttexturedir_esc
formspec[#formspec + 1] = "cdb_downloading.png;4;300;]"
elseif package.queued then
formspec[#formspec + 1] = left_base
formspec[#formspec + 1] = core.formspec_escape(defaulttexturedir)
formspec[#formspec + 1] = defaulttexturedir_esc
formspec[#formspec + 1] = "cdb_queued.png;queued]"
elseif not package.path then
local elem_name = "install_" .. i .. ";"
@ -846,7 +856,7 @@ function store.get_formspec(dlgdata)
local web_elem_name = "view_" .. i .. ";"
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 ..
fgettext("View more information in a web browser") .. tooltip_colors
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] = tostring(description_width)
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] = "style_type[textarea;font_size=]"
@ -955,7 +965,7 @@ function store.handle_submit(this, fields)
local function on_confirm()
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)
dlg:set_parent(this)
this:hide()
@ -1008,11 +1018,6 @@ function create_store_dlg(type)
search_string = ""
cur_page = 1
-- ToDo: delete me when MultiCraft ContentDB is ready
if type and type ~= "game" then
type = "game"
end
if type then
-- table.indexof does not work on tables that contain `nil`
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
if #pkgmgr.games == 0 then
return "size[12.25,3,false]" ..
return "size[12.25,3]" ..
"bgcolor[#0000]" ..
"background9[0,0;0,0;" .. core.formspec_escape(defaulttexturedir ..
"bg_common.png") .. ";true;40]" ..
"background9[0,0;0,0;" .. defaulttexturedir_esc .. "bg_common.png;true;40]" ..
"box[0,0;12,2;#ff8800]" ..
"textarea[0.3,0;11.7,2;;;"..
fgettext("You have no games installed.") .. "\n" ..
fgettext("Download one from minetest.net") .. "]" ..
btn_style("world_create_cancel") ..
"button[4.75,2.5;3,0.5;world_create_cancel;" .. fgettext("Cancel") .. "]"
end
@ -334,10 +334,9 @@ local function create_world_formspec(dialogdata)
end
local retval =
"size[12.25,7,false]" ..
"size[12.25,7]" ..
"bgcolor[#0000]" ..
"background9[0,0;0,0;" .. core.formspec_escape(defaulttexturedir ..
"bg_common.png") .. ";true;40]" ..
"background9[0,0;0,0;" .. defaulttexturedir_esc .. "bg_common.png;true;40]" ..
-- Left side
"container[0,0]"..
@ -367,8 +366,9 @@ local function create_world_formspec(dialogdata)
"container_end[]"..
-- 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") .. "]" ..
btn_style("world_create_cancel") ..
"button[6.25,6.5;3,0.5;world_create_cancel;" .. fgettext("Cancel") .. "]"
return retval

View File

@ -56,19 +56,23 @@ local function create_world_formspec()
end
mglist = mglist:sub(1, -2)
return
"label[1.5,0.9;" .. fgettext("World name") .. ":" .. "]"..
"field[4.5,1.2;6,0.5;te_world_name;;]" ..
return "real_coordinates[true]" .. "formspec_version[3]" ..
"label[1.5,1.9;" .. fgettext("Seed") .. ":" .. "]"..
"field[4.5,2.2;6,0.5;te_seed;;".. current_seed .. "]" ..
"image[3.5,1.1;8.5,0.8;" .. defaulttexturedir_esc .. "field_bg.png;32]" ..
"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") .. ":" .. "]"..
"dropdown[4.2,2.75;6.3;dd_mapgen;" .. mglist .. ";" .. selindex .. "]" ..
"image[3.5,2.5;8.5,0.8;" .. defaulttexturedir_esc .. "field_bg.png;32]" ..
"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]" ..
"button[3.5,4.4;2.5,0.5;world_create_confirm;" .. fgettext("Create") .. "]" ..
"button[6,4.4;2.5,0.5;world_create_cancel;" .. fgettext("Cancel") .. "]"
"label[3.5,3.7;" .. fgettext("Mapgen") .. ":" .. "]"..
"dropdown[3.5,3.9;8.5,0.8;dd_mapgen;" .. mglist .. ";" .. selindex .. "]" ..
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
local function create_world_buttonhandler(this, fields)

View File

@ -19,15 +19,24 @@
local function delete_content_formspec(dialogdata)
local title = dialogdata.content.title or dialogdata.content.name
local retval =
"image_button[2,1;8,3;" .. core.formspec_escape(defaulttexturedir) ..
"blank.png;;" .. fgettext("Are you sure you want to delete \"$1\"?", title) ..
";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") .. "]"
local retval = {
"real_coordinates[true]",
"image[6.5,0.8;2.5,2.5;", defaulttexturedir_esc, "attention.png]",
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
--------------------------------------------------------------------------------
@ -45,9 +54,6 @@ local function delete_content_buttonhandler(this, fields)
if this.data.content.type == "game" then
pkgmgr.update_gamelist()
ui.childlist = {}
menudata.init_tabs()
else
pkgmgr.refresh_globals()
end

View File

@ -23,14 +23,30 @@ local function delete_world_formspec(dialogdata)
delete_name = delete_name .. " (" .. game_name .. ")"
end
local retval =
"image_button[2,1;8,3;" .. core.formspec_escape(defaulttexturedir ..
"blank.png") .. ";;" .. fgettext("Delete World \"$1\"?", delete_name) ..
";true;false;]" ..
"style[world_delete_confirm;bgcolor=red]" ..
"button[3,4.8;3,0.5;world_delete_confirm;" .. fgettext("Delete") .. "]" ..
"button[6,4.8;3,0.5;world_delete_cancel;" .. fgettext("Cancel") .. "]"
return retval
local formspec = {
"real_coordinates[true]",
"image[6.5,0.8;2.5,2.5;", defaulttexturedir_esc, "attention.png]",
"style[msg,wait;content_offset=0]",
"image_button[1,3.5;13.5,0.8;;msg;",
fgettext("Delete World \"$1\"?", delete_name), ";false;false]",
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
local function delete_world_buttonhandler(this, fields)
@ -52,6 +68,23 @@ local function delete_world_buttonhandler(this, fields)
return false
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)
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_game = game_to_del
retval.data.delete_index = index_to_del
retval.data.cooldown = 5
start_timer(retval)
return retval
end

View File

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

View File

@ -19,8 +19,10 @@
local function rename_modpack_formspec(dialogdata)
local retval =
btn_style("dlg_rename_modpack_confirm", "green") ..
"button[3,4.8;3,0.5;dlg_rename_modpack_confirm;"..
fgettext("Accept") .. "]" ..
btn_style("dlg_rename_modpack_cancel") ..
"button[6,4.8;3,0.5;dlg_rename_modpack_cancel;"..
fgettext("Cancel") .. "]"
@ -32,7 +34,11 @@ local function rename_modpack_formspec(dialogdata)
input_y = 2.5
end
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 .. "]"
return retval

View File

@ -621,7 +621,8 @@ local function create_change_setting_formspec(dialogdata)
end
formspec = "field[0.28," .. height + 0.15 .. ";8,1;te_setting_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") .. "]"
height = height + 1.15
@ -825,14 +826,15 @@ local function create_change_setting_formspec(dialogdata)
end
return (
"size[" .. width .. "," .. height + 0.25 .. ",false]" ..
"size[" .. width .. "," .. height + 0.25 .. "]" ..
"bgcolor[#0000]" ..
"background9[0,0;0,0;" .. core.formspec_escape(defaulttexturedir ..
"bg_common.png") .. ";true;40]" ..
"background9[0,0;0,0;" .. defaulttexturedir_esc .. "bg_common.png;true;40]" ..
create_textfield(description_box, setting_name, comment_text) ..
formspec ..
btn_style("btn_done") ..
"button[" .. width / 2 - 2.5 .. "," .. height - 0.4 .. ";2.5,1;btn_done;" ..
fgettext("Save") .. "]" ..
btn_style("btn_cancel") ..
"button[" .. width / 2 .. "," .. height - 0.4 .. ";2.5,1;btn_cancel;" ..
fgettext("Cancel") .. "]"
)
@ -1019,8 +1021,12 @@ local function create_settings_formspec(tabview, _, tabdata)
local formspec =
"tablecolumns[color;tree;text,width=28;text]" ..
"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]" ..
btn_style("search") ..
"button[10.1,-0.22;2,1;search;" .. fgettext("Search") .. "]" ..
"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
end
formspec = formspec .. ";" .. selected_setting .. "]" ..
btn_style("btn_back") ..
"button[0,4.9;4,1;btn_back;".. fgettext("< Back to Settings page") .. "]" ..
"button[10,4.9;2,1;btn_edit;" .. fgettext("Edit") .. "]" ..
"button[7,4.9;3,1;btn_restore;" .. fgettext("Restore Default") .. "]" ..
btn_style("btn_restore") ..
"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") .. ";"
.. dump(core.settings:get_bool("main_menu_technical_settings")) .. "]"

View File

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

View File

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

View File

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

View File

@ -16,9 +16,6 @@
--with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
local esc = core.formspec_escape
local defaulttexturedir = esc(defaulttexturedir)
local packages_raw
local packages
@ -62,15 +59,14 @@ local function get_formspec(tabview, name, tabdata)
local retval =
"style_type[image_button;padding=-5;bgimg=" .. defaulttexturedir ..
"select_btn.png;bgimg_middle=10]" ..
"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]" ..
"tableoptions[background=#0000;border=false]" ..
"table[0,0.25;5.1,4.3;pkglist;" ..
pkgmgr.render_packagelist(packages) ..
";" .. 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]"
@ -91,7 +87,7 @@ local function get_formspec(tabview, name, tabdata)
end
if modscreenshot == nil then
modscreenshot = defaulttexturedir .. "no_screenshot.png"
modscreenshot = defaulttexturedir_esc .. "no_screenshot.png"
end
local info = core.get_content_info(selected_pkg.path)
@ -101,13 +97,14 @@ local function get_formspec(tabview, name, tabdata)
end
retval = retval ..
"image[5.5,0;3,2;" .. esc(modscreenshot) .. "]" ..
"label[8.25,0.6;" .. esc(selected_pkg.name) .. "]" ..
"background9[5.6,2.3;6.2,2.4;" .. defaulttexturedir .. "desc_bg.png" .. ";false;32]"
"image[5.5,0;3,2;" .. core.formspec_escape(modscreenshot) .. "]" ..
"label[8.25,0.6;" .. core.formspec_escape(selected_pkg.name) .. "]" ..
"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.is_modpack then
retval = retval ..
btn_style("btn_mod_mgr_rename_modpack") ..
"image_button[8.65,4.8;3.25,0.9;;btn_mod_mgr_rename_modpack;" ..
fgettext("Rename") .. ";true;false]"
else
@ -136,10 +133,12 @@ local function get_formspec(tabview, name, tabdata)
if selected_pkg.type == "txp" then
if selected_pkg.enabled then
retval = retval ..
btn_style("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]"
else
retval = retval ..
btn_style("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]"
end
@ -151,6 +150,7 @@ local function get_formspec(tabview, name, tabdata)
if core.may_modify_path(selected_pkg.path) then
retval = retval ..
btn_style("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]"
end

View File

@ -15,9 +15,6 @@
--with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
local esc = core.formspec_escape
local defaulttexturedir = esc(defaulttexturedir)
--------------------------------------------------------------------------------
local multicraft_developers = {
@ -106,6 +103,7 @@ local previous_contributors = {
"Jeija <jeija@mesecons.net> [HTTP, particles]",
}
local esc = core.formspec_escape
local function buildCreditList(source)
local ret = {}
for i = 1, #source do
@ -119,7 +117,7 @@ return {
caption = "", -- fgettext("Credits"),
cbf_formspec = function(tabview, name, tabdata)
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 .. "]" ..
"label[1.3,-0.25;" ..
"MultiCraft Open Source, ver. " .. version.string .. "\n" ..
@ -127,14 +125,12 @@ return {
"License: GNU LGPLv3.0+ and CC BY-SA 4.0\n" ..
"Created and Powered by Minetest Engine, ver. 5.4.1]" ..
"style[homepage;padding=-5;bgimg=" .. defaulttexturedir ..
"select_btn.png;bgimg_middle=10]" ..
"image_button[9.5,-0.2;2.6,0.8;;homepage;Home Page;true;false]" ..
"style[privacy;padding=-5;bgimg=" .. defaulttexturedir ..
"select_btn.png;bgimg_middle=10]" ..
"image_button[9.5,0.65;2.6,0.8;;privacy;Privacy Policy;true;false]" ..
btn_style("homepage") ..
"image_button[9.5,-0.2;2.6,0.85;;homepage;Home Page;true;false]" ..
btn_style("privacy") ..
"image_button[9.5,0.6;2.6,0.85;;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]" ..
"tablecolumns[color;text]" ..
"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
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 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"
end
local space = small_screen and ("\n"):rep(3) or ("\n"):rep(5)
local retval =
"style[world_delete;fgimg=" .. defaulttexturedir ..
"world_delete.png;fgimg_hovered=" .. defaulttexturedir .. "world_delete_hover.png]" ..
"style[world_delete;fgimg=" .. defaulttexturedir_esc ..
"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]" ..
"tooltip[world_delete;".. fgettext("Delete") .. "]" ..
"style[world_create;fgimg=" .. defaulttexturedir ..
"world_new.png;fgimg_hovered=" .. defaulttexturedir .. "world_new_hover.png]" ..
"style[world_create;fgimg=" .. defaulttexturedir_esc ..
"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]" ..
"tooltip[world_create;".. fgettext("New") .. "]" ..
"tooltip[world_create;".. fgettext("New") .. "]"
"style[play;fgimg=" .. defaulttexturedir .. "btn_play.png;fgimg_hovered=" ..
defaulttexturedir .. "btn_play_hover.png]" ..
"image_button[6.72,1.43;4.96,1.41;;play;;true;false]" ..
local world = menudata.worldlist:get_list()[index]
local game = world and pkgmgr.find_by_gameid(world.gameid)
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") .. "]" ..
"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]" ..
"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]" ..
"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]" ..
"table[0,0;6.28,4.64;sp_worlds;" .. menu_render_worldlist() .. ";" .. index .. "]"
if tab_data.hidden then
retval = retval ..
"style[switch_local_default;fgimg=" .. defaulttexturedir .. "switch_local_default.png;fgimg_hovered=" ..
defaulttexturedir .. "switch_local_default_hover.png]" ..
"style[switch_local_default;fgimg=" .. defaulttexturedir_esc .. "switch_local_default.png;fgimg_hovered=" ..
defaulttexturedir_esc .. "switch_local_default_hover.png]" ..
"image_button[10.6,-0.1;1.5,1.5;;switch_local_default;;true;false]"
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")
if enable_server then
retval = retval ..
"checkbox[6.6,5;cb_server;".. fgettext("Create Server") ..";" ..
dump(enable_server) .. "]"
end
if enable_server then
if core.settings:get_bool("server_announce") then
retval = retval ..
"checkbox[9.3,5;cb_server_announce;" .. fgettext("Announce Server") .. ";true]"
@ -180,7 +183,7 @@ local function get_formspec(_, _, tab_data)
return retval
end
local function main_button_handler(this, fields, name)
local function main_button_handler(this, fields, name, tab_data)
assert(name == "local")
local world_doubleclick = false
@ -243,6 +246,22 @@ local function main_button_handler(this, fields, name)
if world then
local game = pkgmgr.find_by_gameid(world.gameid)
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
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
this:set_tab("content")
else
local dlg = create_store_dlg()
local dlg = create_store_dlg("game")
dlg:set_parent(this)
this:hide()
dlg:show()

View File

@ -18,8 +18,7 @@
local lang = core.settings:get("language")
if not lang or lang == "" then lang = os.getenv("LANG") end
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 default_worlds = {
{name = "World 1", mg_name = "v7p", seed = "15823438331521897617"},
@ -30,6 +29,8 @@ local default_worlds = {
}
local function create_default_worlds()
if #menudata.worldlist:get_list() > 0 then return end
local _, gameindex = pkgmgr.find_by_gameid("default")
if not gameindex or gameindex == 0 then return end
@ -62,7 +63,7 @@ end
local checked_worlds = false
local function get_formspec(this)
-- 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()
end
checked_worlds = true
@ -86,40 +87,43 @@ local function get_formspec(this)
creative_bg = "creative_bg_" .. lang .. ".png"
end
local space = small_screen and ("\n"):rep(3) or ("\n"):rep(5)
local retval =
"style[world_delete;fgimg=" .. defaulttexturedir ..
"world_delete.png;fgimg_hovered=" .. defaulttexturedir .. "world_delete_hover.png]" ..
"style[world_delete;fgimg=" .. defaulttexturedir_esc ..
"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]" ..
"tooltip[world_delete;".. fgettext("Delete") .. "]" ..
"style[world_create;fgimg=" .. defaulttexturedir ..
"world_new.png;fgimg_hovered=" .. defaulttexturedir .. "world_new_hover.png]" ..
"style[world_create;fgimg=" .. defaulttexturedir_esc ..
"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]" ..
"tooltip[world_create;".. fgettext("New") .. "]" ..
"style[play;fgimg=" .. defaulttexturedir .. "btn_play.png;fgimg_hovered=" ..
defaulttexturedir .. "btn_play_hover.png]" ..
"image_button[6.72,1.43;4.96,1.41;;play;;true;false]" ..
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") .. "]" ..
"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]" ..
"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]" ..
"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]" ..
"table[0,0;6.28,4.64;sp_worlds;" .. menu_render_worldlist() .. ";" .. index .. "]" ..
"style[switch_local;fgimg=" .. defaulttexturedir .. "switch_local.png;fgimg_hovered=" ..
defaulttexturedir .. "switch_local_hover.png]" ..
"style[switch_local;fgimg=" .. defaulttexturedir_esc .. "switch_local.png;fgimg_hovered=" ..
defaulttexturedir_esc .. "switch_local_hover.png]" ..
"image_button[10.6,-0.1;1.5,1.5;;switch_local;;true;false]"
if PLATFORM == "Android" then
retval = retval ..
"image_button[6.6,-0.1;1.5,1.5;" ..
defaulttexturedir .. "gift_btn.png;upgrade;;true;false;" ..
defaulttexturedir .. "gift_btn_pressed.png]"
defaulttexturedir_esc .. "gift_btn.png;upgrade;;true;false;" ..
defaulttexturedir_esc .. "gift_btn_pressed.png]"
end
local enable_server = core.settings:get_bool("enable_server")
@ -138,7 +142,7 @@ local function get_formspec(this)
retval = retval ..
-- Name / Password
"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") .. ":]"
end

View File

@ -19,8 +19,8 @@
local password_tmp = ""
local esc = core.formspec_escape
local defaulttexturedir = esc(defaulttexturedir)
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)
-- Update the cached supported proto info,
@ -46,41 +46,52 @@ local function get_formspec(tabview, name, tabdata)
local retval =
-- Search
"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]" ..
"field[0.25,5.2;5.75,1;Dte_search;;" .. esc(tabdata.search_for) .. "]" ..
"image_button[5.6,4.93;0.83,0.83;" .. defaulttexturedir ..
"field[0.25,5.25;5.7,0.83;Dte_search;;" .. esc(tabdata.search_for) .. "]" ..
btn_style("btn_mp_search") ..
"image_button[5.6,4.93;0.83,0.83;" .. defaulttexturedir_esc ..
"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]" ..
-- 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) .. "]" ..
-- 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")) .. "]" ..
-- 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
"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
"style[btn_mp_connect;fgimg=" .. defaulttexturedir ..
"btn_play.png;fgimg_hovered=" .. defaulttexturedir .. "btn_play_hover.png]" ..
"image_button[8.8,4.9;3.3,0.9;;btn_mp_connect;;true;false]" ..
"tooltip[btn_mp_connect;".. fgettext("Connect") .. "]"
-- Password
retval = retval .. "pwdfield[10.45,1.7;1.95,0.5;te_pwd;" ..
fgettext("Password") .. ":" .. ";" .. esc(password_tmp) .. "]"
btn_style("btn_mp_connect") ..
"style[btn_mp_connect;font_size=*" .. (small_screen and 1.5 or 2) .. "]" ..
"image_button[8.8,4.88;3.3,0.9;;btn_mp_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]" ..
"tooltip[btn_mp_connect;" .. fgettext("Connect") .. "]"
if tabdata.selected and selected then
if gamedata.fav then
retval = retval ..
"style[btn_delete_favorite;fgimg=" .. defaulttexturedir ..
"trash.png;fgimg_hovered=" .. defaulttexturedir .. "trash_hover.png]" ..
"image_button[7.1,4.93;0.83,0.83;;btn_delete_favorite;;true;false]"
btn_style("btn_delete_favorite", "red") ..
"image_button[7.1,4.93;0.83,0.83;" .. defaulttexturedir_esc ..
"trash.png;btn_delete_favorite;;true;false;" .. defaulttexturedir_esc .. "trash_pressed.png]" ..
"tooltip[btn_delete_favorite;" .. fgettext("Del. Favorite") .. "]"
end
if selected.description then
retval = retval .. "textarea[7.5,2.2;4.8,3;;" ..
@ -91,7 +102,7 @@ local function get_formspec(tabview, name, tabdata)
--favorites
retval = retval ..
"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]" ..
"tablecolumns[" ..
image_column(fgettext("Favorite")) .. ",align=center;" ..

View File

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

View File

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

View File

@ -4351,15 +4351,18 @@ void Game::showPauseMenu()
#ifdef __IOS__
ypos += 0.5f;
#endif
const bool high_dpi = RenderingEngine::isHighDpi();
const std::string x2 = high_dpi ? ".x2" : "";
std::ostringstream os;
os << "formspec_version[1]" << SIZE_TAG
<< "no_prepend[]"
<< "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:hovered;bgimg=gui_button_hovered.png]"
<< "style_type[image_button_exit,image_button:pressed;bgimg=gui_button_pressed.png]"
<< "style_type[image_button_exit,image_button;bgimg=gui/gui_button" << x2 <<
".png;bgimg_middle=" << (high_dpi ? "48" : "32") << ";padding=" << (high_dpi ? "-30" : "-20") << "]"
<< "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;"
<< 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(confirm_pw);
const bool high_dpi = RenderingEngine::isHighDpi();
const std::string x2 = high_dpi ? ".x2" : "";
std::ostringstream os;
os << "formspec_version[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,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 << "]"
<< "style_type[image_button_exit,image_button;bgimg=gui_button.png;bgimg_middle=20;padding=-10]"
<< "style_type[image_button_exit,image_button:hovered;bgimg=gui_button_hovered.png]"
<< "style_type[image_button_exit,image_button:pressed;bgimg=gui_button_pressed.png]"
<< "style_type[image_button_exit,image_button;bgimg=gui/gui_button" << x2
<< ".png;bgimg_middle=" << (high_dpi ? "48" : "32") << ";padding=" << (high_dpi ? "-30" : "-20") << "]"
<< "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_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();
}
#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 float getDisplayDensity();
static v2u32 getDisplaySize();
static bool isHighDpi();
bool setupTopLevelWindow(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"))
game_release = conf.getS32("release");
bool moddable = true;
if (conf.exists("moddable"))
moddable = conf.getBool("moddable");
std::string menuicon_path;
#ifndef SERVER
menuicon_path = getImagePath(
game_path + DIR_DELIM + "menu" + DIR_DELIM + "icon.png");
#endif
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)

View File

@ -35,6 +35,7 @@ struct SubgameSpec
std::string gamemods_path;
std::set<std::string> addon_mods_paths;
std::string menuicon_path;
bool moddable;
SubgameSpec(const std::string &id = "", const std::string &path = "",
const std::string &gamemods_path = "",
@ -42,11 +43,12 @@ struct SubgameSpec
std::set<std::string>(),
const std::string &name = "",
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),
name(name), author(author), release(release), path(path),
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/fontengine.h"
#include "client/renderingengine.h"
#include "debug.h"
#include "irrlichttypes_extrabloated.h"
#include "util/string.h"
@ -75,20 +76,22 @@ public:
static std::array<StyleSpec, NUM_STATES> getButtonStyle(const std::string texture_path = "") {
std::array<StyleSpec, NUM_STATES> ret;
const bool high_dpi = RenderingEngine::isHighDpi();
const std::string x2 = high_dpi ? ".x2" : "";
StyleSpec btn_spec;
btn_spec.set(BGIMG, texture_path + "gui_button.png");
btn_spec.set(BGIMG_MIDDLE, "20");
btn_spec.set(BGIMG, texture_path + "gui/gui_button" + x2 + ".png");
btn_spec.set(BGIMG_MIDDLE, high_dpi ? "48" : "32");
btn_spec.set(BORDER, "false");
btn_spec.set(PADDING, "-10");
btn_spec.set(PADDING, high_dpi ? "-30" : "-20");
ret[STATE_DEFAULT] = btn_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;
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;
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->setDrawBorder(style.getBool(StyleSpec::BORDER, true));
e->setOverrideColor(style.getColor(StyleSpec::TEXTCOLOR, video::SColor(0xFFFFFFFF)));
if (style.get(StyleSpec::BGCOLOR, "") == "transparent") {
e->setDrawBackground(false);
}
e->setOverrideFont(style.getFont());
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_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_newtable(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