X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=builtin%2Fmainmenu%2Fcommon.lua;h=f4020aaaf00c5adc46f079aff4d1a424fe8234ca;hb=58babf8b1945f1a2db0180a4a3ed7b0d52872bef;hp=6126c61a41b213f7abe77291585fd4cef595a3ce;hpb=05f4e9ee08f93b17c3dbaf2b6a1022cc28a226ce;p=oweals%2Fminetest.git diff --git a/builtin/mainmenu/common.lua b/builtin/mainmenu/common.lua index 6126c61a4..f4020aaaf 100644 --- a/builtin/mainmenu/common.lua +++ b/builtin/mainmenu/common.lua @@ -224,10 +224,10 @@ function menu_handle_key_up_down(fields,textlist,settingname) configure_selected_world_params(newidx) end - + return true end - + return false end @@ -237,7 +237,7 @@ function asyncOnlineFavourites() if not menudata.public_known then menudata.public_known = {{ name = fgettext("Loading..."), - description = fgettext("Try reenabling public serverlist and check your internet connection.") + description = fgettext_ne("Try reenabling public serverlist and check your internet connection.") }} end menudata.favorites = menudata.public_known @@ -262,41 +262,86 @@ end -------------------------------------------------------------------------------- function text2textlist(xpos,ypos,width,height,tl_name,textlen,text,transparency) local textlines = core.splittext(text,textlen) - + local retval = "textlist[" .. xpos .. "," .. ypos .. ";" .. width .. "," .. height .. ";" .. tl_name .. ";" - + for i=1, #textlines, 1 do textlines[i] = textlines[i]:gsub("\r","") retval = retval .. core.formspec_escape(textlines[i]) .. "," end - + retval = retval .. ";0;" - + if transparency then retval = retval .. "true" end - + retval = retval .. "]" return retval end -------------------------------------------------------------------------------- -function is_server_protocol_compat(proto_min, proto_max) - return not ((min_supp_proto > (proto_max or 24)) or (max_supp_proto < (proto_min or 13))) +function is_server_protocol_compat(server_proto_min, server_proto_max) + return not ((min_supp_proto > (server_proto_max or 24)) or (max_supp_proto < (server_proto_min or 13))) end -------------------------------------------------------------------------------- -function is_server_protocol_compat_or_error(proto_min, proto_max) - if not is_server_protocol_compat(proto_min, proto_max) then - gamedata.errormessage = fgettext_ne("Protocol version mismatch, server " .. - ((proto_min ~= proto_max) and "supports protocols between $1 and $2" or "enforces protocol version $1") .. - ", we " .. - ((min_supp_proto ~= max_supp_proto) and "support protocols between version $3 and $4." or "only support protocol version $3"), - proto_min or 13, proto_max or 24, min_supp_proto, max_supp_proto) +function is_server_protocol_compat_or_error(server_proto_min, server_proto_max) + if not is_server_protocol_compat(server_proto_min, server_proto_max) then + local server_prot_ver_info + local client_prot_ver_info + if server_proto_min ~= server_proto_max then + server_prot_ver_info = fgettext_ne("Server supports protocol versions between $1 and $2. ", + server_proto_min or 13, server_proto_max or 24) + else + server_prot_ver_info = fgettext_ne("Server enforces protocol version $1. ", + server_proto_min or 13) + end + if min_supp_proto ~= max_supp_proto then + client_prot_ver_info= fgettext_ne("We support protocol versions between version $1 and $2.", + min_supp_proto, max_supp_proto) + else + client_prot_ver_info = fgettext_ne("We only support protocol version $1.", min_supp_proto) + end + gamedata.errormessage = fgettext_ne("Protocol version mismatch. ") + .. server_prot_ver_info + .. client_prot_ver_info return false end return true end +-------------------------------------------------------------------------------- +function menu_worldmt(selected, setting, value) + local world = menudata.worldlist:get_list()[selected] + if world then + local filename = world.path .. DIR_DELIM .. "world.mt" + local world_conf = Settings(filename) + + if value ~= nil then + if not world_conf:write() then + core.log("error", "Failed to write world config file") + end + world_conf:set(setting, value) + world_conf:write() + else + return world_conf:get(setting) + end + else + return nil + end +end + +function menu_worldmt_legacy(selected) + local modes_names = {"creative_mode", "enable_damage", "server_announce"} + for _, mode_name in pairs(modes_names) do + local mode_val = menu_worldmt(selected, mode_name) + if mode_val ~= nil then + core.setting_set(mode_name, mode_val) + else + menu_worldmt(selected, mode_name, core.setting_get(mode_name)) + end + end +end