From ea0fdd6bcea3a17db02ed3aec6c8c0c2a5536f14 Mon Sep 17 00:00:00 2001 From: Migdyn Date: Sun, 9 Oct 2022 01:29:36 -0400 Subject: [PATCH] Added a new server category (BEST SERVERS) --- builtin/mainmenu/init.lua | 4 +++- builtin/mainmenu/tab_beta.lua | 2 +- builtin/mainmenu/tab_online.lua | 22 +++++++++++++++++----- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/builtin/mainmenu/init.lua b/builtin/mainmenu/init.lua index 039c922..0ed271e 100644 --- a/builtin/mainmenu/init.lua +++ b/builtin/mainmenu/init.lua @@ -113,7 +113,7 @@ local function init_globals() tv_main:set_fixed_size(false) - tv_main:set_tab(tabs.beta) + tv_main:set_tab(tabs.about) -- In case the folder of the last selected game has been deleted, @@ -132,3 +132,5 @@ local function init_globals() end init_globals() + + diff --git a/builtin/mainmenu/tab_beta.lua b/builtin/mainmenu/tab_beta.lua index 1ef76ed..78da918 100644 --- a/builtin/mainmenu/tab_beta.lua +++ b/builtin/mainmenu/tab_beta.lua @@ -31,7 +31,7 @@ return { "style[label_button;border=false]" .. "button[0.1,4;8.3,1.5;online_play;Play on-line (real people, not bots)]" .. "button[0.1,6;8.3,1.5;local_play;Play locally]" .. - "button[0.1,8;8.3,1.5;xtreemcoins;Get XtreemCoins]" + "button[0.1,8;8.3,1.5;xtreemcoins;Get XtreemCoins (Android only)]" return fs, "size[15.5,10.1,false]real_coordinates[true]" diff --git a/builtin/mainmenu/tab_online.lua b/builtin/mainmenu/tab_online.lua index ad5f79e..a426442 100644 --- a/builtin/mainmenu/tab_online.lua +++ b/builtin/mainmenu/tab_online.lua @@ -17,16 +17,24 @@ local function get_sorted_servers() local servers = { + best = {}, fav = {}, public = {}, incompatible = {} } + local favs = serverlistmgr.get_favorites() local taken_favs = {} local result = menudata.search_result or serverlistmgr.servers for _, server in ipairs(result) do server.is_favorite = false + + if server.address == "testing.cubesoftware.xyz" then + server.is_favorite = true + table.insert(servers.best, server) + end + for index, fav in ipairs(favs) do if server.address == fav.address and server.port == fav.port then taken_favs[index] = true @@ -153,11 +161,12 @@ local function get_formspec(tabview, name, tabdata) local servers = get_sorted_servers() local dividers = { + best = "7,#ff0000," .. fgettext("BEST SERVERS") .. ",,,0,0,,", fav = "5,#ffff00," .. fgettext("Favorites") .. ",,,0,0,,", public = "6,#4bdd42," .. fgettext("Public Servers") .. ",,,0,0,,", incompatible = "7,"..mt_color_grey.."," .. fgettext("Incompatible Servers") .. ",,,0,0,," } - local order = {"fav", "public", "incompatible"} + local order = {"best", "fav", "public", "incompatible"} tabdata.lookup = {} -- maps row number to server local rows = {} @@ -318,10 +327,13 @@ local function main_button_handler(tabview, fields, name, tabdata) local server = tabdata.lookup[idx] if not server then return end - serverlistmgr.delete_favorite(server) - -- the server at [idx+1] will be at idx once list is refreshed - set_selected_server(tabdata, idx, tabdata.lookup[idx+1]) - return true + if server.address == "testing.cubesoftware.xyz" then return + else + serverlistmgr.delete_favorite(server) + -- the server at [idx+1] will be at idx once list is refreshed + set_selected_server(tabdata, idx, tabdata.lookup[idx+1]) + return true + end end if fields.btn_mp_clear then