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

View File

@ -16,13 +16,11 @@
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--------------------------------------------------------------------------------
local password_save = core.settings:get_bool("password_save")
local password_tmp = ""
local esc = core.formspec_escape
local defaulttexturedir = esc(defaulttexturedir)
local lower = utf8.lower
local mobile = PLATFORM == "Android" or PLATFORM == "iOS"
local function get_formspec(tabview, name, tabdata)
-- Update the cached supported proto info,
@ -39,32 +37,6 @@ local function get_formspec(tabview, name, tabdata)
tabdata.search_for = ""
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 port = tonumber(core.settings:get("remote_port"))
if port and port ~= 30000 then
@ -73,7 +45,14 @@ local function get_formspec(tabview, name, tabdata)
local retval =
-- 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
"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]" ..
"tooltip[btn_mp_connect;".. fgettext("Connect") .. "]"
local pwd = password_save and core.settings:get("password") or password_tmp
-- Password
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 gamedata.fav then
@ -196,11 +174,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
end
if fields.te_pwd then
if password_save then
core.settings:set("password", fields.te_pwd)
else
password_tmp = fields.te_pwd
end
password_tmp = fields.te_pwd
end
if fields.favorites then
@ -304,10 +278,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
return true
end
if fields.btn_mp_refresh or fields.btn_mp_mobile then
if fields.btn_mp_mobile then
serverlistmgr.mobile_only = not serverlistmgr.mobile_only
end
if fields.btn_mp_refresh then
serverlistmgr.sync()
return true
end

View File

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