mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-21 11:55:43 +02:00
Revert all commits up to (including) a704c04f
This commit is contained in:
@@ -16,15 +16,9 @@
|
||||
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
--------------------------------------------------------------------------------
|
||||
-- Global menu data
|
||||
--------------------------------------------------------------------------------
|
||||
---------------------------------------------------------------------------------
|
||||
menudata = {}
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Local cached values
|
||||
--------------------------------------------------------------------------------
|
||||
local min_supp_proto = core.get_min_supp_proto()
|
||||
local max_supp_proto = core.get_max_supp_proto()
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Menu helper functions
|
||||
--------------------------------------------------------------------------------
|
||||
@@ -48,25 +42,6 @@ function image_column(tooltip, flagname)
|
||||
"1=" .. core.formspec_escape(defaulttexturedir .. "server_flags_" .. flagname .. ".png")
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
function order_favorite_list(list)
|
||||
local res = {}
|
||||
--orders the favorite list after support
|
||||
for i=1,#list,1 do
|
||||
local fav = list[i]
|
||||
if is_server_protocol_compat(fav.proto_min, fav.proto_max) then
|
||||
table.insert(res, fav)
|
||||
end
|
||||
end
|
||||
for i=1,#list,1 do
|
||||
local fav = list[i]
|
||||
if not is_server_protocol_compat(fav.proto_min, fav.proto_max) then
|
||||
table.insert(res, fav)
|
||||
end
|
||||
end
|
||||
return res
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
function render_favorite(spec,render_details)
|
||||
local text = ""
|
||||
@@ -93,7 +68,6 @@ function render_favorite(spec,render_details)
|
||||
end
|
||||
|
||||
local details = ""
|
||||
local grey_out = not is_server_protocol_compat(spec.proto_max, spec.proto_min)
|
||||
|
||||
if spec.clients ~= nil and spec.clients_max ~= nil then
|
||||
local clients_color = ''
|
||||
@@ -113,17 +87,11 @@ function render_favorite(spec,render_details)
|
||||
clients_color = '#ffba97' -- 90-100%: orange
|
||||
end
|
||||
|
||||
if grey_out then
|
||||
clients_color = '#aaaaaa'
|
||||
end
|
||||
|
||||
details = details ..
|
||||
clients_color .. ',' ..
|
||||
render_client_count(spec.clients) .. ',' ..
|
||||
'/,' ..
|
||||
render_client_count(spec.clients_max) .. ','
|
||||
elseif grey_out then
|
||||
details = details .. '#aaaaaa,?,/,?,'
|
||||
else
|
||||
details = details .. ',?,/,?,'
|
||||
end
|
||||
@@ -146,7 +114,7 @@ function render_favorite(spec,render_details)
|
||||
details = details .. "0,"
|
||||
end
|
||||
|
||||
return details .. (grey_out and '#aaaaaa,' or ',') .. text
|
||||
return details .. text
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
@@ -227,7 +195,7 @@ function asyncOnlineFavourites()
|
||||
nil,
|
||||
function(result)
|
||||
if core.setting_getbool("public_serverlist") then
|
||||
menudata.favorites = order_favorite_list(result)
|
||||
menudata.favorites = result
|
||||
core.event_handler("Refresh")
|
||||
end
|
||||
end
|
||||
@@ -257,21 +225,3 @@ function text2textlist(xpos,ypos,width,height,tl_name,textlen,text,transparency)
|
||||
|
||||
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)))
|
||||
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)
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
@@ -16,9 +16,6 @@
|
||||
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
local function modname_valid(name)
|
||||
return not name:find("[^a-z0-9_]")
|
||||
end
|
||||
|
||||
local function get_formspec(data)
|
||||
|
||||
@@ -198,12 +195,10 @@ local function handle_buttons(this, fields)
|
||||
for i,mod in ipairs(rawlist) do
|
||||
if not mod.is_modpack and
|
||||
mod.typ ~= "game_mod" then
|
||||
if modname_valid(mod.name) then
|
||||
worldfile:set("load_mod_"..mod.name, tostring(mod.enabled))
|
||||
if mod.enabled then
|
||||
worldfile:set("load_mod_"..mod.name, "true")
|
||||
else
|
||||
if mod.enabled then
|
||||
gamedata.errormessage = fgettext_ne("Failed to enable mod \"$1\" as it contains disallowed characters. Only chararacters [a-z0-9_] are allowed.", mod.name)
|
||||
end
|
||||
worldfile:set("load_mod_"..mod.name, "false")
|
||||
end
|
||||
mods["load_mod_"..mod.name] = nil
|
||||
end
|
||||
|
@@ -90,8 +90,6 @@ local function create_world_buttonhandler(this, fields)
|
||||
|
||||
local message = nil
|
||||
|
||||
core.setting_set("fixed_map_seed", fields["te_seed"])
|
||||
|
||||
if not menudata.worldlist:uid_exists_raw(worldname) then
|
||||
core.setting_set("mg_name",fields["dd_mapgen"])
|
||||
message = core.create_world(worldname,gameindex)
|
||||
@@ -99,6 +97,8 @@ local function create_world_buttonhandler(this, fields)
|
||||
message = fgettext("A world named \"$1\" already exists", worldname)
|
||||
end
|
||||
|
||||
core.setting_set("fixed_map_seed", fields["te_seed"])
|
||||
|
||||
if message ~= nil then
|
||||
gamedata.errormessage = message
|
||||
else
|
||||
|
@@ -139,11 +139,7 @@ local function init_globals()
|
||||
tv_main:add(tab_credits)
|
||||
|
||||
tv_main:set_global_event_handler(main_event_handler)
|
||||
if PLATFORM ~= "Android" then
|
||||
tv_main:set_fixed_size(true)
|
||||
else
|
||||
tv_main:set_fixed_size(false)
|
||||
end
|
||||
tv_main:set_fixed_size(false)
|
||||
|
||||
if not (PLATFORM == "Android") then
|
||||
tv_main:set_tab(core.setting_get("maintab_LAST"))
|
||||
|
@@ -122,36 +122,35 @@ end
|
||||
function modstore.showdownloading(title)
|
||||
local new_dlg = dialog_create("store_downloading",
|
||||
function(data)
|
||||
return "size[6,2]label[0.25,0.75;" ..
|
||||
fgettext("Downloading $1, please wait...", data.title) .. "]"
|
||||
return "size[6,2]label[0.25,0.75;" .. fgettext("Downloading") ..
|
||||
" " .. data.title .. " " ..
|
||||
fgettext("please wait...") .. "]"
|
||||
end,
|
||||
function(this,fields)
|
||||
if fields["btn_hidden_close_download"] ~= nil then
|
||||
if fields["btn_hidden_close_download"].successfull then
|
||||
modstore.lastmodentry = fields["btn_hidden_close_download"]
|
||||
modstore.successfulldialog(this)
|
||||
modstore.successfulldialog()
|
||||
else
|
||||
this.parent:show()
|
||||
this:delete()
|
||||
modstore.lastmodtitle = ""
|
||||
end
|
||||
|
||||
this:delete()
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end,
|
||||
nil)
|
||||
nil,
|
||||
modstore.tv_store)
|
||||
|
||||
new_dlg:set_parent(modstore.tv_store)
|
||||
modstore.tv_store:hide()
|
||||
new_dlg.data.title = title
|
||||
new_dlg:show()
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- @function [parent=#modstore] successfulldialog
|
||||
function modstore.successfulldialog(downloading_dlg)
|
||||
function modstore.successfulldialog()
|
||||
local new_dlg = dialog_create("store_downloading",
|
||||
function(data)
|
||||
local retval = ""
|
||||
@@ -159,16 +158,18 @@ function modstore.successfulldialog(downloading_dlg)
|
||||
if modstore.lastmodentry ~= nil then
|
||||
retval = retval .. "label[0,0.25;" .. fgettext("Successfully installed:") .. "]"
|
||||
retval = retval .. "label[3,0.25;" .. modstore.lastmodentry.moddetails.title .. "]"
|
||||
|
||||
|
||||
retval = retval .. "label[0,0.75;" .. fgettext("Shortname:") .. "]"
|
||||
retval = retval .. "label[3,0.75;" .. core.formspec_escape(modstore.lastmodentry.moddetails.basename) .. "]"
|
||||
|
||||
end
|
||||
retval = retval .. "button[2.2,1.5;1.5,0.5;btn_confirm_mod_successfull;" .. fgettext("Ok") .. "]"
|
||||
return retval
|
||||
retval = retval .. "button[2.5,1.5;1,0.5;btn_confirm_mod_successfull;" .. fgettext("ok") .. "]"
|
||||
end,
|
||||
function(this,fields)
|
||||
if fields["btn_confirm_mod_successfull"] ~= nil then
|
||||
this.parent:show()
|
||||
downloading_dlg:delete()
|
||||
this:hide()
|
||||
this:delete()
|
||||
|
||||
return true
|
||||
@@ -176,10 +177,10 @@ function modstore.successfulldialog(downloading_dlg)
|
||||
|
||||
return false
|
||||
end,
|
||||
nil)
|
||||
nil,
|
||||
modstore.tv_store)
|
||||
|
||||
new_dlg:set_parent(modstore.tv_store)
|
||||
modstore.tv_store:hide()
|
||||
new_dlg.data.title = title
|
||||
new_dlg:show()
|
||||
end
|
||||
|
||||
@@ -216,9 +217,7 @@ function modstore.handle_buttons(parent, fields, name, data)
|
||||
end
|
||||
|
||||
if fields["btn_modstore_close"] then
|
||||
local maintab = ui.find_by_name("maintab")
|
||||
parent:hide()
|
||||
maintab:show()
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -229,7 +228,12 @@ function modstore.handle_buttons(parent, fields, name, data)
|
||||
for i=1,#modstore.modlist_unsorted.data,1 do
|
||||
if modstore.modlist_unsorted.data[i].id == modid then
|
||||
local moddetails = modstore.modlist_unsorted.data[i].details
|
||||
modstore.lastmodtitle = moddetails.title
|
||||
|
||||
if modstore.lastmodtitle ~= "" then
|
||||
modstore.lastmodtitle = modstore.lastmodtitle .. ", "
|
||||
end
|
||||
|
||||
modstore.lastmodtitle = modstore.lastmodtitle .. moddetails.title
|
||||
|
||||
if not core.handle_async(
|
||||
function(param)
|
||||
@@ -277,7 +281,7 @@ function modstore.handle_buttons(parent, fields, name, data)
|
||||
texturename = modstore.modlist_unsorted.data[i].texturename
|
||||
},
|
||||
function(result)
|
||||
--print("Result from async: " .. dump(result.successfull))
|
||||
print("Result from async: " .. dump(result.successfull))
|
||||
if result.successfull then
|
||||
modmgr.installmod(result.filename,result.moddetails.basename)
|
||||
os.remove(result.filename)
|
||||
@@ -295,7 +299,7 @@ function modstore.handle_buttons(parent, fields, name, data)
|
||||
print("ERROR: async event failed")
|
||||
gamedata.errormessage = "Failed to download " .. modstore.lastmodtitle
|
||||
end
|
||||
|
||||
parent:hide()
|
||||
modstore.showdownloading(modstore.lastmodtitle)
|
||||
return true
|
||||
end
|
||||
@@ -387,7 +391,7 @@ function modstore.getscreenshot(ypos,listentry)
|
||||
listentry.details.screenshot_url == "") then
|
||||
|
||||
if listentry.texturename == nil then
|
||||
listentry.texturename = defaulttexturedir .. "no_screenshot.png"
|
||||
listentry.texturename = modstore.basetexturedir .. "no_screenshot.png"
|
||||
end
|
||||
|
||||
return "image[0,".. ypos .. ";3,2;" ..
|
||||
|
@@ -57,7 +57,7 @@ local function get_formspec(tabview, name, tabdata)
|
||||
end
|
||||
|
||||
if modscreenshot == nil then
|
||||
modscreenshot = defaulttexturedir .. "no_screenshot.png"
|
||||
modscreenshot = modstore.basetexturedir .. "no_screenshot.png"
|
||||
end
|
||||
|
||||
retval = retval
|
||||
@@ -96,7 +96,7 @@ local function get_formspec(tabview, name, tabdata)
|
||||
else
|
||||
--show dependencies
|
||||
|
||||
retval = retval .. "," .. fgettext("Depends:") .. ","
|
||||
retval = retval .. ",Depends:,"
|
||||
|
||||
local toadd = modmgr.get_dependencies(selected_mod.path)
|
||||
|
||||
|
@@ -59,10 +59,9 @@ local function get_formspec(tabview, name, tabdata)
|
||||
"text,align=right;" .. -- clients
|
||||
"text,align=center,padding=0.25;" .. -- "/"
|
||||
"text,align=right,padding=0.25;" .. -- clients_max
|
||||
image_column(fgettext("Creative mode"), "creative") .. ",padding=1;" ..
|
||||
image_column(fgettext("Damage enabled"), "damage") .. ",padding=0.25;" ..
|
||||
image_column(fgettext("PvP enabled"), "pvp") .. ",padding=0.25;" ..
|
||||
"color,span=1;" ..
|
||||
image_column("Creative mode", "creative") .. ",padding=1;" ..
|
||||
image_column("Damage enabled", "damage") .. ",padding=0.25;" ..
|
||||
image_column("PvP enabled", "pvp") .. ",padding=0.25;" ..
|
||||
"text,padding=1]" -- name
|
||||
else
|
||||
retval = retval .. "tablecolumns[text]"
|
||||
@@ -89,6 +88,7 @@ end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
local function main_button_handler(tabview, fields, name, tabdata)
|
||||
|
||||
if fields["te_name"] ~= nil then
|
||||
gamedata.playername = fields["te_name"]
|
||||
core.setting_set("name", fields["te_name"])
|
||||
@@ -98,10 +98,6 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||
local event = core.explode_table_event(fields["favourites"])
|
||||
if event.type == "DCL" then
|
||||
if event.row <= #menudata.favorites then
|
||||
if not is_server_protocol_compat_or_error(menudata.favorites[event.row].proto_min,
|
||||
menudata.favorites[event.row].proto_max) then
|
||||
return true
|
||||
end
|
||||
gamedata.address = menudata.favorites[event.row].address
|
||||
gamedata.port = menudata.favorites[event.row].port
|
||||
gamedata.playername = fields["te_name"]
|
||||
@@ -193,7 +189,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||
local current_favourite = core.get_table_index("favourites")
|
||||
if current_favourite == nil then return end
|
||||
core.delete_favorite(current_favourite)
|
||||
menudata.favorites = order_favorite_list(core.get_favorites())
|
||||
menudata.favorites = core.get_favorites()
|
||||
tabdata.fav_selected = nil
|
||||
|
||||
core.setting_set("address","")
|
||||
@@ -202,9 +198,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||
return true
|
||||
end
|
||||
|
||||
if (fields["btn_mp_connect"] ~= nil or
|
||||
fields["key_enter"] ~= nil) and fields["te_address"] ~= nil and
|
||||
fields["te_port"] ~= nil then
|
||||
if fields["btn_mp_connect"] ~= nil or
|
||||
fields["key_enter"] ~= nil then
|
||||
|
||||
gamedata.playername = fields["te_name"]
|
||||
gamedata.password = fields["te_pwd"]
|
||||
@@ -219,11 +214,6 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||
|
||||
gamedata.servername = menudata.favorites[fav_idx].name
|
||||
gamedata.serverdescription = menudata.favorites[fav_idx].description
|
||||
|
||||
if not is_server_protocol_compat_or_error(menudata.favorites[fav_idx].proto_min,
|
||||
menudata.favorites[fav_idx].proto_max)then
|
||||
return true
|
||||
end
|
||||
else
|
||||
gamedata.servername = ""
|
||||
gamedata.serverdescription = ""
|
||||
|
@@ -42,10 +42,9 @@ local function get_formspec(tabview, name, tabdata)
|
||||
"text,align=right;" .. -- clients
|
||||
"text,align=center,padding=0.25;" .. -- "/"
|
||||
"text,align=right,padding=0.25;" .. -- clients_max
|
||||
image_column(fgettext("Creative mode"), "creative") .. ",padding=1;" ..
|
||||
image_column(fgettext("Damage enabled"), "damage") .. ",padding=0.25;" ..
|
||||
image_column(fgettext("PvP enabled"), "pvp") .. ",padding=0.25;" ..
|
||||
"color,span=1;" ..
|
||||
image_column("Creative mode", "creative") .. ",padding=1;" ..
|
||||
image_column("Damage enabled", "damage") .. ",padding=0.25;" ..
|
||||
image_column("PvP enabled", "pvp") .. ",padding=0.25;" ..
|
||||
"text,padding=1]" -- name
|
||||
else
|
||||
retval = retval .. "tablecolumns[text]"
|
||||
@@ -88,6 +87,7 @@ local function get_formspec(tabview, name, tabdata)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
local function main_button_handler(tabview, fields, name, tabdata)
|
||||
|
||||
if fields["btn_start_singleplayer"] then
|
||||
@@ -159,11 +159,6 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||
|
||||
gamedata.servername = menudata.favorites[fav_idx].name
|
||||
gamedata.serverdescription = menudata.favorites[fav_idx].description
|
||||
|
||||
if not is_server_protocol_compat_or_error(menudata.favorites[fav_idx].proto_min,
|
||||
menudata.favorites[fav_idx].proto_max) then
|
||||
return true
|
||||
end
|
||||
else
|
||||
gamedata.servername = ""
|
||||
gamedata.serverdescription = ""
|
||||
|
Reference in New Issue
Block a user