aboutsummaryrefslogtreecommitdiff
path: root/builtin/mainmenu
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/mainmenu')
-rw-r--r--builtin/mainmenu/common.lua5
-rw-r--r--builtin/mainmenu/dlg_contentstore.lua1
-rw-r--r--builtin/mainmenu/dlg_create_world.lua12
-rw-r--r--builtin/mainmenu/dlg_settings_advanced.lua42
-rw-r--r--builtin/mainmenu/pkgmgr.lua7
-rw-r--r--builtin/mainmenu/tab_local.lua4
-rw-r--r--builtin/mainmenu/tab_online.lua6
-rw-r--r--builtin/mainmenu/tab_settings.lua2
-rw-r--r--builtin/mainmenu/tab_simple_main.lua8
-rw-r--r--builtin/mainmenu/textures.lua40
10 files changed, 63 insertions, 64 deletions
diff --git a/builtin/mainmenu/common.lua b/builtin/mainmenu/common.lua
index cc61fe0ad..782d6973f 100644
--- a/builtin/mainmenu/common.lua
+++ b/builtin/mainmenu/common.lua
@@ -93,9 +93,9 @@ function render_serverlist_row(spec, is_favorite)
end
end
- local details = ""
local grey_out = not is_server_protocol_compat(spec.proto_min, spec.proto_max)
+ local details
if is_favorite then
details = "1,"
else
@@ -118,11 +118,11 @@ function render_serverlist_row(spec, is_favorite)
end
if spec.clients and spec.clients_max then
- local clients_color = ''
local clients_percent = 100 * spec.clients / spec.clients_max
-- Choose a color depending on how many clients are connected
-- (relatively to clients_max)
+ local clients_color
if grey_out then clients_color = '#aaaaaa'
elseif spec.clients == 0 then clients_color = '' -- 0 players: default/white
elseif clients_percent <= 60 then clients_color = '#a1e587' -- 0-60%: green
@@ -171,6 +171,7 @@ os.tempfolder = function()
local filetocheck = os.tmpname()
os.remove(filetocheck)
+ -- luacheck: ignore
-- https://blogs.msdn.microsoft.com/vcblog/2014/06/18/c-runtime-crt-features-fixes-and-breaking-changes-in-visual-studio-14-ctp1/
-- The C runtime (CRT) function called by os.tmpname is tmpnam.
-- Microsofts tmpnam implementation in older CRT / MSVC releases is defective.
diff --git a/builtin/mainmenu/dlg_contentstore.lua b/builtin/mainmenu/dlg_contentstore.lua
index 568d37ee6..3bc5f60bb 100644
--- a/builtin/mainmenu/dlg_contentstore.lua
+++ b/builtin/mainmenu/dlg_contentstore.lua
@@ -270,7 +270,6 @@ function store.load()
assert(core.create_dir(tmpdir))
local base_url = core.settings:get("contentdb_url")
- local show_nonfree = core.settings:get_bool("show_nonfree_packages")
local url = base_url ..
"/api/packages/?type=mod&type=game&type=txp&protocol_version=" ..
core.get_max_supp_proto()
diff --git a/builtin/mainmenu/dlg_create_world.lua b/builtin/mainmenu/dlg_create_world.lua
index c701f094e..f0ade0021 100644
--- a/builtin/mainmenu/dlg_create_world.lua
+++ b/builtin/mainmenu/dlg_create_world.lua
@@ -24,10 +24,10 @@ local function create_world_formspec(dialogdata)
local current_mg = core.settings:get("mg_name")
local gameid = core.settings:get("menu_last_game")
- local game, gameidx = nil , 0
+ local gameidx = 0
if gameid ~= nil then
- game, gameidx = pkgmgr.find_by_gameid(gameid)
-
+ _, gameidx = pkgmgr.find_by_gameid(gameid)
+
if gameidx == nil then
gameidx = 0
end
@@ -82,7 +82,7 @@ local function create_world_formspec(dialogdata)
"button[3.25,6;2.5,0.5;world_create_confirm;" .. fgettext("Create") .. "]" ..
"button[5.75,6;2.5,0.5;world_create_cancel;" .. fgettext("Cancel") .. "]"
-
+
if #pkgmgr.games == 0 then
retval = retval .. "box[2,4;8,1;#ff8800]label[2.25,4;" ..
fgettext("You have no games installed.") .. "]label[2.25,4.4;" ..
@@ -111,10 +111,10 @@ local function create_world_buttonhandler(this, fields)
local random_world_name = "Unnamed" .. random_number
worldname = random_world_name
end
- local message = nil
core.settings:set("fixed_map_seed", fields["te_seed"])
+ local message
if not menudata.worldlist:uid_exists_raw(worldname) then
core.settings:set("mg_name",fields["dd_mapgen"])
message = core.create_world(worldname,gameindex)
@@ -165,6 +165,6 @@ function create_create_world_dlg(update_worldlistfilter)
create_world_buttonhandler,
nil)
retval.update_worldlist_filter = update_worldlistfilter
-
+
return retval
end
diff --git a/builtin/mainmenu/dlg_settings_advanced.lua b/builtin/mainmenu/dlg_settings_advanced.lua
index bff36d8cb..67e8c9ede 100644
--- a/builtin/mainmenu/dlg_settings_advanced.lua
+++ b/builtin/mainmenu/dlg_settings_advanced.lua
@@ -148,9 +148,9 @@ local function parse_setting_line(settings, line, read_all, base_level, allow_se
local values = {}
local ti = 1
local index = 1
- for line in default:gmatch("[+-]?[%d.-e]+") do -- All numeric characters
- index = default:find("[+-]?[%d.-e]+", index) + line:len()
- table.insert(values, line)
+ for match in default:gmatch("[+-]?[%d.-e]+") do -- All numeric characters
+ index = default:find("[+-]?[%d.-e]+", index) + match:len()
+ table.insert(values, match)
ti = ti + 1
if ti > 9 then
break
@@ -322,17 +322,20 @@ end
-- read_all: whether to ignore certain setting types for GUI or not
-- parse_mods: whether to parse settingtypes.txt in mods and games
local function parse_config_file(read_all, parse_mods)
- local builtin_path = core.get_builtin_path() .. FILENAME
- local file = io.open(builtin_path, "r")
local settings = {}
- if not file then
- core.log("error", "Can't load " .. FILENAME)
- return settings
- end
- parse_single_file(file, builtin_path, read_all, settings, 0, true)
+ do
+ local builtin_path = core.get_builtin_path() .. FILENAME
+ local file = io.open(builtin_path, "r")
+ if not file then
+ core.log("error", "Can't load " .. FILENAME)
+ return settings
+ end
+
+ parse_single_file(file, builtin_path, read_all, settings, 0, true)
- file:close()
+ file:close()
+ end
if parse_mods then
-- Parse games
@@ -344,7 +347,7 @@ local function parse_config_file(read_all, parse_mods)
local file = io.open(path, "r")
if file then
if not games_category_initialized then
- local translation = fgettext_ne("Games"), -- not used, but needed for xgettext
+ fgettext_ne("Games") -- not used, but needed for xgettext
table.insert(settings, {
name = "Games",
level = 0,
@@ -377,7 +380,7 @@ local function parse_config_file(read_all, parse_mods)
local file = io.open(path, "r")
if file then
if not mods_category_initialized then
- local translation = fgettext_ne("Mods"), -- not used, but needed for xgettext
+ fgettext_ne("Mods") -- not used, but needed for xgettext
table.insert(settings, {
name = "Mods",
level = 0,
@@ -753,7 +756,7 @@ local function create_change_setting_formspec(dialogdata)
" (" .. setting.name .. ")"
end
- local comment_text = ""
+ local comment_text
if setting.comment == "" then
comment_text = fgettext_ne("(No description of setting given)")
else
@@ -918,7 +921,7 @@ local function handle_change_setting_buttons(this, fields)
return false
end
-local function create_settings_formspec(tabview, name, tabdata)
+local function create_settings_formspec(tabview, _, tabdata)
local formspec = "size[12,5.4;true]" ..
"tablecolumns[color;tree;text,width=28;text]" ..
"tableoptions[background=#00000000;border=false]" ..
@@ -950,7 +953,7 @@ local function create_settings_formspec(tabview, name, tabdata)
formspec = formspec .. "," .. (current_level + 1) .. "," .. core.formspec_escape(name) .. ","
.. value .. ","
- elseif entry.type == "key" then
+ elseif entry.type == "key" then --luacheck: ignore
-- ignore key settings, since we have a special dialog for them
elseif entry.type == "noise_params_2d" or entry.type == "noise_params_3d" then
@@ -1029,8 +1032,8 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
if fields["btn_edit"] or list_enter then
local setting = settings[selected_setting]
if setting and setting.type ~= "category" then
- local edit_dialog = dialog_create("change_setting", create_change_setting_formspec,
- handle_change_setting_buttons)
+ local edit_dialog = dialog_create("change_setting",
+ create_change_setting_formspec, handle_change_setting_buttons)
edit_dialog:set_parent(this)
this:hide()
edit_dialog:show()
@@ -1076,4 +1079,5 @@ end
-- For RUN_IN_PLACE the generated files may appear in the 'bin' folder.
-- See comment and alternative line at the end of 'generate_from_settingtypes.lua'.
---assert(loadfile(core.get_builtin_path().."mainmenu"..DIR_DELIM.."generate_from_settingtypes.lua"))(parse_config_file(true, false))
+--assert(loadfile(core.get_builtin_path().."mainmenu"..DIR_DELIM..
+-- "generate_from_settingtypes.lua"))(parse_config_file(true, false))
diff --git a/builtin/mainmenu/pkgmgr.lua b/builtin/mainmenu/pkgmgr.lua
index dee4dabbb..b9b612963 100644
--- a/builtin/mainmenu/pkgmgr.lua
+++ b/builtin/mainmenu/pkgmgr.lua
@@ -285,8 +285,6 @@ function pkgmgr.identify_modname(modpath,filename)
end
--------------------------------------------------------------------------------
function pkgmgr.render_packagelist(render_list)
- local retval = ""
-
if render_list == nil then
if pkgmgr.global_mods == nil then
pkgmgr.refresh_globals()
@@ -295,7 +293,6 @@ function pkgmgr.render_packagelist(render_list)
end
local list = render_list:get_list()
- local last_modpack = nil
local retval = {}
for i, v in ipairs(list) do
local color = ""
@@ -465,7 +462,7 @@ function pkgmgr.install_dir(type, path, basename, targetpath)
else
return nil,
fgettext("Install Mod: Unable to find suitable folder name for modpack $1",
- modfilename)
+ path)
end
end
elseif basefolder.type == "mod" then
@@ -490,7 +487,7 @@ function pkgmgr.install_dir(type, path, basename, targetpath)
if targetfolder ~= nil and pkgmgr.isValidModname(targetfolder) then
targetpath = core.get_modpath() .. DIR_DELIM .. targetfolder
else
- return nil, fgettext("Install Mod: Unable to find real mod name for: $1", modfilename)
+ return nil, fgettext("Install Mod: Unable to find real mod name for: $1", path)
end
end
diff --git a/builtin/mainmenu/tab_local.lua b/builtin/mainmenu/tab_local.lua
index 15ef96dc8..0969bccfb 100644
--- a/builtin/mainmenu/tab_local.lua
+++ b/builtin/mainmenu/tab_local.lua
@@ -21,7 +21,7 @@ local current_game, singleplayer_refresh_gamebar
if enable_gamebar then
function current_game()
local last_game_id = core.settings:get("menu_last_game")
- local game, index = pkgmgr.find_by_gameid(last_game_id)
+ local game = pkgmgr.find_by_gameid(last_game_id)
return game
end
@@ -222,7 +222,7 @@ local function main_button_handler(this, fields, name, tabdata)
--update last game
local world = menudata.worldlist:get_raw_element(gamedata.selected_world)
if world then
- local game, index = pkgmgr.find_by_gameid(world.gameid)
+ local game = pkgmgr.find_by_gameid(world.gameid)
core.settings:set("menu_last_game", game.id)
end
diff --git a/builtin/mainmenu/tab_online.lua b/builtin/mainmenu/tab_online.lua
index c632039fc..8733f7618 100644
--- a/builtin/mainmenu/tab_online.lua
+++ b/builtin/mainmenu/tab_online.lua
@@ -20,7 +20,7 @@ local function get_formspec(tabview, name, tabdata)
-- Update the cached supported proto info,
-- it may have changed after a change by the settings menu.
common_update_cached_supp_proto()
- local fav_selected = nil
+ local fav_selected
if menudata.search_result then
fav_selected = menudata.search_result[tabdata.fav_selected]
else
@@ -273,8 +273,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
for k = 1, #keywords do
local keyword = keywords[k]
if server.name then
- local name = server.name:lower()
- local _, count = name:gsub(keyword, keyword)
+ local sername = server.name:lower()
+ local _, count = sername:gsub(keyword, keyword)
found = found + count * 4
end
diff --git a/builtin/mainmenu/tab_settings.lua b/builtin/mainmenu/tab_settings.lua
index 75d7ceee8..1e5264904 100644
--- a/builtin/mainmenu/tab_settings.lua
+++ b/builtin/mainmenu/tab_settings.lua
@@ -148,11 +148,9 @@ local function dlg_confirm_reset_btnhandler(this, fields, dialogdata)
core.create_world("singleplayerworld", 1)
worldlist = core.get_worlds()
- found_singleplayerworld = false
for i = 1, #worldlist do
if worldlist[i].name == "singleplayerworld" then
- found_singleplayerworld = true
gamedata.worldindex = i
end
end
diff --git a/builtin/mainmenu/tab_simple_main.lua b/builtin/mainmenu/tab_simple_main.lua
index de4ae1751..7ec95158a 100644
--- a/builtin/mainmenu/tab_simple_main.lua
+++ b/builtin/mainmenu/tab_simple_main.lua
@@ -188,10 +188,10 @@ local function main_button_handler(tabview, fields, name, tabdata)
core.settings:set("address", fields.te_address)
core.settings:set("remote_port", fields.te_port)
-
- core.start()
- return true
- end
+
+ core.start()
+ return true
+ end
if fields.btn_config_sp_world then
local configdialog = create_configure_world_dlg(1)
diff --git a/builtin/mainmenu/textures.lua b/builtin/mainmenu/textures.lua
index 68b05dc18..a3acbbdec 100644
--- a/builtin/mainmenu/textures.lua
+++ b/builtin/mainmenu/textures.lua
@@ -23,9 +23,9 @@ function mm_texture.init()
mm_texture.defaulttexturedir = core.get_texturepath() .. DIR_DELIM .. "base" ..
DIR_DELIM .. "pack" .. DIR_DELIM
mm_texture.basetexturedir = mm_texture.defaulttexturedir
-
+
mm_texture.texturepack = core.settings:get("texture_path")
-
+
mm_texture.gameid = nil
end
@@ -39,7 +39,7 @@ function mm_texture.update(tab,gamedetails)
if gamedetails == nil then
return
end
-
+
mm_texture.update_game(gamedetails)
end
@@ -48,18 +48,18 @@ function mm_texture.reset()
mm_texture.gameid = nil
local have_bg = false
local have_overlay = mm_texture.set_generic("overlay")
-
+
if not have_overlay then
have_bg = mm_texture.set_generic("background")
end
-
+
mm_texture.clear("header")
mm_texture.clear("footer")
core.set_clouds(false)
-
+
mm_texture.set_generic("footer")
mm_texture.set_generic("header")
-
+
if not have_bg then
if core.settings:get_bool("menu_clouds") then
core.set_clouds(true)
@@ -74,30 +74,30 @@ function mm_texture.update_game(gamedetails)
if mm_texture.gameid == gamedetails.id then
return
end
-
+
local have_bg = false
local have_overlay = mm_texture.set_game("overlay",gamedetails)
-
+
if not have_overlay then
have_bg = mm_texture.set_game("background",gamedetails)
end
-
+
mm_texture.clear("header")
mm_texture.clear("footer")
core.set_clouds(false)
-
+
if not have_bg then
-
+
if core.settings:get_bool("menu_clouds") then
core.set_clouds(true)
else
mm_texture.set_dirt_bg()
end
end
-
+
mm_texture.set_game("footer",gamedetails)
mm_texture.set_game("header",gamedetails)
-
+
mm_texture.gameid = gamedetails.id
end
@@ -116,7 +116,7 @@ function mm_texture.set_generic(identifier)
return true
end
end
-
+
if mm_texture.defaulttexturedir ~= nil then
local path = mm_texture.defaulttexturedir .. DIR_DELIM .."menu_" ..
identifier .. ".png"
@@ -124,13 +124,13 @@ function mm_texture.set_generic(identifier)
return true
end
end
-
+
return false
end
--------------------------------------------------------------------------------
function mm_texture.set_game(identifier, gamedetails)
-
+
if gamedetails == nil then
return false
end
@@ -142,7 +142,7 @@ function mm_texture.set_game(identifier, gamedetails)
return true
end
end
-
+
-- Find out how many randomized textures the game provides
local n = 0
local filename
@@ -167,7 +167,7 @@ function mm_texture.set_game(identifier, gamedetails)
if core.set_background(identifier, path) then
return true
end
-
+
return false
end
@@ -178,7 +178,7 @@ function mm_texture.set_dirt_bg()
return true
end
end
-
+
-- Use universal fallback texture in textures/base/pack
local minimalpath = defaulttexturedir .. "menu_bg.png"
core.set_background("background", minimalpath, true, 128)