Drop the `mobile_friendly` server feature (#79)

master
Maksym H 2022-07-28 17:53:11 +02:00 committed by GitHub
parent e22b748ce9
commit 1c19f6069f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 54 deletions

View File

@ -18,30 +18,24 @@
serverlistmgr = {} serverlistmgr = {}
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
serverlistmgr.mobile_only = PLATFORM == "Android" or PLATFORM == "iOS"
local function order_server_list(list) local function order_server_list(list)
local res = {} local res = {}
local non_mobile_servers = {}
local mobile = serverlistmgr.mobile_only
-- orders the multicraft list before 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 mobile and not fav.mobile_friendly then if fav.server_id == "multicraft" then
non_mobile_servers[("%s:%s"):format(fav.address, fav.port)] = fav
elseif fav.server_id == "multicraft" then
res[#res + 1] = fav res[#res + 1] = fav
end end
end end
for i = 1, #list do for i = 1, #list do
local fav = list[i] local fav = list[i]
if (mobile and fav.mobile_friendly or not mobile) and if is_server_protocol_compat(fav.proto_min, fav.proto_max) and
is_server_protocol_compat(fav.proto_min, fav.proto_max) and
fav.server_id ~= "multicraft" then fav.server_id ~= "multicraft" then
res[#res + 1] = fav res[#res + 1] = fav
end end
end end
return res, non_mobile_servers return res
end end
local public_downloading = false local public_downloading = false
@ -75,10 +69,11 @@ function serverlistmgr.sync()
local serverlist = core.settings:get("serverlist_url") local serverlist = core.settings:get("serverlist_url")
local address = ("%s/list%s"):format(serverlist, local address = ("%s/list%s"):format(serverlist,
serverlist == minetest.decode_base64("c2VydmVycy5tdWx0aWNyYWZ0Lndvcmxk") and "_prod" or "") serverlist == minetest.decode_base64("c2VydmVycy5tdWx0aWNyYWZ0Lndvcmxk") and "_prod" or "")
local url = ("%s?proto_version_min=%d&proto_version_max=%d"):format( local url = ("%s?proto_version_min=%d&proto_version_max=%d&platform=%s"):format(
address, address,
core.get_min_supp_proto(), core.get_min_supp_proto(),
core.get_max_supp_proto()) core.get_max_supp_proto(),
PLATFORM)
local response = http.fetch_sync({ url = url }) local response = http.fetch_sync({ url = url })
if not response.succeeded then if not response.succeeded then
@ -91,10 +86,9 @@ function serverlistmgr.sync()
nil, nil,
function(result) function(result)
public_downloading = nil public_downloading = nil
local favs, non_mobile_servers = order_server_list(result) local favs = order_server_list(result)
if favs[1] then if favs[1] then
serverlistmgr.servers = favs serverlistmgr.servers = favs
serverlistmgr.non_mobile_servers = non_mobile_servers
end end
core.event_handler("Refresh") core.event_handler("Refresh")
end end

View File

@ -16,13 +16,11 @@
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local password_save = core.settings:get_bool("password_save")
local password_tmp = "" local password_tmp = ""
local esc = core.formspec_escape local esc = core.formspec_escape
local defaulttexturedir = esc(defaulttexturedir) local defaulttexturedir = esc(defaulttexturedir)
local lower = utf8.lower local lower = utf8.lower
local mobile = PLATFORM == "Android" or PLATFORM == "iOS"
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,
@ -39,32 +37,6 @@ local function get_formspec(tabview, name, tabdata)
tabdata.search_for = "" tabdata.search_for = ""
end end
local search_panel
if mobile then
search_panel =
"formspec_version[3]" ..
"image[-0.1,4.9;6.05,0.89;" .. defaulttexturedir .. "desc_bg.png;32]" ..
"style[Dte_search;border=false;bgcolor=transparent]" ..
"field[0.25,5.2;4.97,1;Dte_search;;" .. esc(tabdata.search_for) .. "]" ..
"image_button[4.85,4.93;0.83,0.83;" .. defaulttexturedir ..
"search.png;btn_mp_search;;true;false]" ..
"image_button[5.6,4.93;0.83,0.83;" .. defaulttexturedir ..
"refresh.png;btn_mp_refresh;;true;false]" ..
"image_button[6.35,4.93;0.83,0.83;" .. defaulttexturedir ..
(serverlistmgr.mobile_only and "online_mobile" or "online_pc") .. ".png" ..
";btn_mp_mobile;;true;false]"
else
search_panel =
"formspec_version[3]" ..
"image[-0.1,4.9;7,0.89;" .. defaulttexturedir .. "desc_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 ..
"search.png;btn_mp_search;;true;false]" ..
"image_button[6.35,4.93;0.83,0.83;" .. defaulttexturedir ..
"refresh.png;btn_mp_refresh;;true;false]"
end
local address = core.settings:get("address") local address = core.settings:get("address")
local port = tonumber(core.settings:get("remote_port")) local port = tonumber(core.settings:get("remote_port"))
if port and port ~= 30000 then if port and port ~= 30000 then
@ -73,7 +45,14 @@ local function get_formspec(tabview, name, tabdata)
local retval = local retval =
-- Search -- Search
search_panel .. "formspec_version[3]" ..
"image[-0.1,4.9;7,0.89;" .. defaulttexturedir .. "desc_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 ..
"search.png;btn_mp_search;;true;false]" ..
"image_button[6.35,4.93;0.83,0.83;" .. defaulttexturedir ..
"refresh.png;btn_mp_refresh;;true;false]" ..
-- Address / Port -- Address / Port
"field[7.4,0.55;5,0.5;te_address;" .. fgettext("Address / Port") .. ":" .. ";" .. "field[7.4,0.55;5,0.5;te_address;" .. fgettext("Address / Port") .. ":" .. ";" ..
@ -92,10 +71,9 @@ local function get_formspec(tabview, name, tabdata)
"image_button[8.8,4.9;3.3,0.9;;btn_mp_connect;;true;false]" .. "image_button[8.8,4.9;3.3,0.9;;btn_mp_connect;;true;false]" ..
"tooltip[btn_mp_connect;".. fgettext("Connect") .. "]" "tooltip[btn_mp_connect;".. fgettext("Connect") .. "]"
local pwd = password_save and core.settings:get("password") or password_tmp
-- Password -- Password
retval = retval .. "pwdfield[10.45,1.7;1.95,0.5;te_pwd;" .. retval = retval .. "pwdfield[10.45,1.7;1.95,0.5;te_pwd;" ..
fgettext("Password") .. ":" .. ";" .. esc(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
@ -196,11 +174,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
end end
if fields.te_pwd then if fields.te_pwd then
if password_save then password_tmp = fields.te_pwd
core.settings:set("password", fields.te_pwd)
else
password_tmp = fields.te_pwd
end
end end
if fields.favorites then if fields.favorites then
@ -304,10 +278,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
return true return true
end end
if fields.btn_mp_refresh or fields.btn_mp_mobile then if fields.btn_mp_refresh then
if fields.btn_mp_mobile then
serverlistmgr.mobile_only = not serverlistmgr.mobile_only
end
serverlistmgr.sync() serverlistmgr.sync()
return true return true
end end

View File

@ -670,7 +670,6 @@ void set_default_settings()
} }
settings->setDefault("debug_log_level", "none"); settings->setDefault("debug_log_level", "none");
settings->setDefault("password_save", "true");
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
settings->setDefault("device_is_tablet", "true"); settings->setDefault("device_is_tablet", "true");

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 219 B