mirror of
https://github.com/minetest/minetest.git
synced 2025-04-16 23:30:06 +02:00
Fix unnecessary content refreshing (#14705)
This commit is contained in:
@ -133,6 +133,8 @@ local function start_install(package, reason)
|
|||||||
conf:set("release", package.release)
|
conf:set("release", package.release)
|
||||||
conf:write()
|
conf:write()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
pkgmgr.reload_by_type(package.type)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -146,7 +148,6 @@ local function start_install(package, reason)
|
|||||||
|
|
||||||
start_install(next.package, next.reason)
|
start_install(next.package, next.reason)
|
||||||
end
|
end
|
||||||
|
|
||||||
ui.update()
|
ui.update()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -427,8 +428,9 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function contentdb.update_paths()
|
function contentdb.update_paths()
|
||||||
|
pkgmgr.load_all()
|
||||||
|
|
||||||
local mod_hash = {}
|
local mod_hash = {}
|
||||||
pkgmgr.refresh_globals()
|
|
||||||
for _, mod in pairs(pkgmgr.global_mods:get_list()) do
|
for _, mod in pairs(pkgmgr.global_mods:get_list()) do
|
||||||
local cdb_id = pkgmgr.get_contentdb_id(mod)
|
local cdb_id = pkgmgr.get_contentdb_id(mod)
|
||||||
if cdb_id then
|
if cdb_id then
|
||||||
@ -437,7 +439,6 @@ function contentdb.update_paths()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local game_hash = {}
|
local game_hash = {}
|
||||||
pkgmgr.update_gamelist()
|
|
||||||
for _, game in pairs(pkgmgr.games) do
|
for _, game in pairs(pkgmgr.games) do
|
||||||
local cdb_id = pkgmgr.get_contentdb_id(game)
|
local cdb_id = pkgmgr.get_contentdb_id(game)
|
||||||
if cdb_id then
|
if cdb_id then
|
||||||
@ -446,7 +447,7 @@ function contentdb.update_paths()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local txp_hash = {}
|
local txp_hash = {}
|
||||||
for _, txp in pairs(pkgmgr.get_texture_packs()) do
|
for _, txp in pairs(pkgmgr.texture_packs) do
|
||||||
local cdb_id = pkgmgr.get_contentdb_id(txp)
|
local cdb_id = pkgmgr.get_contentdb_id(txp)
|
||||||
if cdb_id then
|
if cdb_id then
|
||||||
txp_hash[contentdb.aliases[cdb_id] or cdb_id] = txp
|
txp_hash[contentdb.aliases[cdb_id] or cdb_id] = txp
|
||||||
|
@ -110,7 +110,7 @@ pkgmgr = {}
|
|||||||
-- @param modpack Currently processing modpack or nil/"" if none (recursion)
|
-- @param modpack Currently processing modpack or nil/"" if none (recursion)
|
||||||
function pkgmgr.get_mods(path, virtual_path, listing, modpack)
|
function pkgmgr.get_mods(path, virtual_path, listing, modpack)
|
||||||
local mods = core.get_dir_list(path, true)
|
local mods = core.get_dir_list(path, true)
|
||||||
|
local added = {}
|
||||||
for _, name in ipairs(mods) do
|
for _, name in ipairs(mods) do
|
||||||
if name:sub(1, 1) ~= "." then
|
if name:sub(1, 1) ~= "." then
|
||||||
local mod_path = path .. DIR_DELIM .. name
|
local mod_path = path .. DIR_DELIM .. name
|
||||||
@ -120,6 +120,7 @@ function pkgmgr.get_mods(path, virtual_path, listing, modpack)
|
|||||||
parent_dir = path,
|
parent_dir = path,
|
||||||
}
|
}
|
||||||
listing[#listing + 1] = toadd
|
listing[#listing + 1] = toadd
|
||||||
|
added[#added + 1] = toadd
|
||||||
|
|
||||||
-- Get config file
|
-- Get config file
|
||||||
local mod_conf
|
local mod_conf
|
||||||
@ -150,8 +151,6 @@ function pkgmgr.get_mods(path, virtual_path, listing, modpack)
|
|||||||
toadd.virtual_path = mod_virtual_path
|
toadd.virtual_path = mod_virtual_path
|
||||||
toadd.type = "mod"
|
toadd.type = "mod"
|
||||||
|
|
||||||
pkgmgr.update_translations({ toadd })
|
|
||||||
|
|
||||||
-- Check modpack.txt
|
-- Check modpack.txt
|
||||||
-- Note: modpack.conf is already checked above
|
-- Note: modpack.conf is already checked above
|
||||||
local modpackfile = io.open(mod_path .. DIR_DELIM .. "modpack.txt")
|
local modpackfile = io.open(mod_path .. DIR_DELIM .. "modpack.txt")
|
||||||
@ -171,6 +170,8 @@ function pkgmgr.get_mods(path, virtual_path, listing, modpack)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
pkgmgr.update_translations(added)
|
||||||
|
|
||||||
if not modpack then
|
if not modpack then
|
||||||
-- Sort all when the recursion is done
|
-- Sort all when the recursion is done
|
||||||
table.sort(listing, function(a, b)
|
table.sort(listing, function(a, b)
|
||||||
@ -180,12 +181,13 @@ function pkgmgr.get_mods(path, virtual_path, listing, modpack)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
function pkgmgr.get_texture_packs()
|
function pkgmgr.reload_texture_packs()
|
||||||
local txtpath = core.get_texturepath()
|
local txtpath = core.get_texturepath()
|
||||||
local txtpath_system = core.get_texturepath_share()
|
local txtpath_system = core.get_texturepath_share()
|
||||||
local retval = {}
|
local retval = {}
|
||||||
|
|
||||||
load_texture_packs(txtpath, retval)
|
load_texture_packs(txtpath, retval)
|
||||||
|
|
||||||
-- on portable versions these two paths coincide. It avoids loading the path twice
|
-- on portable versions these two paths coincide. It avoids loading the path twice
|
||||||
if txtpath ~= txtpath_system then
|
if txtpath ~= txtpath_system then
|
||||||
load_texture_packs(txtpath_system, retval)
|
load_texture_packs(txtpath_system, retval)
|
||||||
@ -197,11 +199,13 @@ function pkgmgr.get_texture_packs()
|
|||||||
return a.title:lower() < b.title:lower()
|
return a.title:lower() < b.title:lower()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
return retval
|
pkgmgr.texture_packs = retval
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
function pkgmgr.get_all()
|
function pkgmgr.get_all()
|
||||||
|
pkgmgr.load_all()
|
||||||
|
|
||||||
local result = {}
|
local result = {}
|
||||||
|
|
||||||
for _, mod in pairs(pkgmgr.global_mods:get_list()) do
|
for _, mod in pairs(pkgmgr.global_mods:get_list()) do
|
||||||
@ -210,7 +214,7 @@ function pkgmgr.get_all()
|
|||||||
for _, game in pairs(pkgmgr.games) do
|
for _, game in pairs(pkgmgr.games) do
|
||||||
result[#result + 1] = game
|
result[#result + 1] = game
|
||||||
end
|
end
|
||||||
for _, txp in pairs(pkgmgr.get_texture_packs()) do
|
for _, txp in pairs(pkgmgr.texture_packs) do
|
||||||
result[#result + 1] = txp
|
result[#result + 1] = txp
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -288,7 +292,7 @@ end
|
|||||||
function pkgmgr.render_packagelist(render_list, use_technical_names, with_icon)
|
function pkgmgr.render_packagelist(render_list, use_technical_names, with_icon)
|
||||||
if not render_list then
|
if not render_list then
|
||||||
if not pkgmgr.global_mods then
|
if not pkgmgr.global_mods then
|
||||||
pkgmgr.refresh_globals()
|
pkgmgr.reload_global_mods()
|
||||||
end
|
end
|
||||||
render_list = pkgmgr.global_mods
|
render_list = pkgmgr.global_mods
|
||||||
end
|
end
|
||||||
@ -549,6 +553,7 @@ function pkgmgr.get_worldconfig(worldpath)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
-- Caller is responsible for reloading content types (see reload_by_type)
|
||||||
function pkgmgr.install_dir(expected_type, path, basename, targetpath)
|
function pkgmgr.install_dir(expected_type, path, basename, targetpath)
|
||||||
assert(type(expected_type) == "string")
|
assert(type(expected_type) == "string")
|
||||||
assert(type(path) == "string")
|
assert(type(path) == "string")
|
||||||
@ -615,12 +620,6 @@ function pkgmgr.install_dir(expected_type, path, basename, targetpath)
|
|||||||
fgettext_ne("Failed to install $1 to $2", basename, targetpath)
|
fgettext_ne("Failed to install $1 to $2", basename, targetpath)
|
||||||
end
|
end
|
||||||
|
|
||||||
if basefolder.type == "game" then
|
|
||||||
pkgmgr.update_gamelist()
|
|
||||||
else
|
|
||||||
pkgmgr.refresh_globals()
|
|
||||||
end
|
|
||||||
|
|
||||||
return targetpath, nil
|
return targetpath, nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -742,7 +741,7 @@ function pkgmgr.comparemod(elem1,elem2)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
function pkgmgr.refresh_globals()
|
function pkgmgr.reload_global_mods()
|
||||||
local function is_equal(element,uid) --uid match
|
local function is_equal(element,uid) --uid match
|
||||||
if element.name == uid then
|
if element.name == uid then
|
||||||
return true
|
return true
|
||||||
@ -774,7 +773,7 @@ function pkgmgr.get_game_mods(gamespec, retval)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
function pkgmgr.update_gamelist()
|
function pkgmgr.reload_games()
|
||||||
pkgmgr.games = core.get_games()
|
pkgmgr.games = core.get_games()
|
||||||
table.sort(pkgmgr.games, function(a, b)
|
table.sort(pkgmgr.games, function(a, b)
|
||||||
return a.title:lower() < b.title:lower()
|
return a.title:lower() < b.title:lower()
|
||||||
@ -782,6 +781,32 @@ function pkgmgr.update_gamelist()
|
|||||||
pkgmgr.update_translations(pkgmgr.games)
|
pkgmgr.update_translations(pkgmgr.games)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
function pkgmgr.reload_by_type(type)
|
||||||
|
if type == "game" then
|
||||||
|
pkgmgr.reload_games()
|
||||||
|
elseif type == "txp" then
|
||||||
|
pkgmgr.reload_texture_packs()
|
||||||
|
elseif type == "mod" or type == "modpack" then
|
||||||
|
pkgmgr.reload_global_mods()
|
||||||
|
else
|
||||||
|
error("Unknown package type: " .. type)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
function pkgmgr.load_all()
|
||||||
|
if not pkgmgr.global_mods then
|
||||||
|
pkgmgr.reload_global_mods()
|
||||||
|
end
|
||||||
|
if not pkgmgr.games then
|
||||||
|
pkgmgr.reload_games()
|
||||||
|
end
|
||||||
|
if not pkgmgr.texture_packs then
|
||||||
|
pkgmgr.reload_texture_packs()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
function pkgmgr.update_translations(list)
|
function pkgmgr.update_translations(list)
|
||||||
for _, item in ipairs(list) do
|
for _, item in ipairs(list) do
|
||||||
@ -831,4 +856,4 @@ end
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- read initial data
|
-- read initial data
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
pkgmgr.update_gamelist()
|
pkgmgr.reload_games()
|
||||||
|
@ -46,6 +46,9 @@ local function reset()
|
|||||||
function core.get_texturepath()
|
function core.get_texturepath()
|
||||||
return txp_dir
|
return txp_dir
|
||||||
end
|
end
|
||||||
|
function core.get_texturepath_share()
|
||||||
|
return txp_dir
|
||||||
|
end
|
||||||
function core.get_modpath()
|
function core.get_modpath()
|
||||||
return mods_dir
|
return mods_dir
|
||||||
end
|
end
|
||||||
@ -59,13 +62,6 @@ local function reset()
|
|||||||
setfenv(loadfile("builtin/common/misc_helpers.lua"), env)()
|
setfenv(loadfile("builtin/common/misc_helpers.lua"), env)()
|
||||||
setfenv(loadfile("builtin/mainmenu/content/pkgmgr.lua"), env)()
|
setfenv(loadfile("builtin/mainmenu/content/pkgmgr.lua"), env)()
|
||||||
|
|
||||||
function env.pkgmgr.update_gamelist()
|
|
||||||
table.insert(calls, { "update_gamelist" })
|
|
||||||
end
|
|
||||||
function env.pkgmgr.refresh_globals()
|
|
||||||
table.insert(calls, { "refresh_globals" })
|
|
||||||
end
|
|
||||||
|
|
||||||
function env.assert_calls(list)
|
function env.assert_calls(list)
|
||||||
assert.are.same(list, calls)
|
assert.are.same(list, calls)
|
||||||
end
|
end
|
||||||
@ -113,7 +109,6 @@ describe("install_dir", function()
|
|||||||
env.assert_calls({
|
env.assert_calls({
|
||||||
{ "delete_dir", mods_dir .. "/mymod" },
|
{ "delete_dir", mods_dir .. "/mymod" },
|
||||||
{ "copy_dir", "/tmp/123", mods_dir .. "/mymod", false },
|
{ "copy_dir", "/tmp/123", mods_dir .. "/mymod", false },
|
||||||
{ "refresh_globals" },
|
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -129,7 +124,6 @@ describe("install_dir", function()
|
|||||||
env.assert_calls({
|
env.assert_calls({
|
||||||
{ "delete_dir", mods_dir .. "/mymod" },
|
{ "delete_dir", mods_dir .. "/mymod" },
|
||||||
{ "copy_dir", "/tmp/123", mods_dir .. "/mymod", false },
|
{ "copy_dir", "/tmp/123", mods_dir .. "/mymod", false },
|
||||||
{ "refresh_globals" },
|
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -145,7 +139,6 @@ describe("install_dir", function()
|
|||||||
env.assert_calls({
|
env.assert_calls({
|
||||||
{ "delete_dir", games_dir .. "/mygame" },
|
{ "delete_dir", games_dir .. "/mygame" },
|
||||||
{ "copy_dir", "/tmp/123", games_dir .. "/mygame", false },
|
{ "copy_dir", "/tmp/123", games_dir .. "/mygame", false },
|
||||||
{ "update_gamelist" },
|
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -161,7 +154,6 @@ describe("install_dir", function()
|
|||||||
env.assert_calls({
|
env.assert_calls({
|
||||||
{ "delete_dir", mods_dir .. "/123" },
|
{ "delete_dir", mods_dir .. "/123" },
|
||||||
{ "copy_dir", "/tmp/123", mods_dir .. "/123", false },
|
{ "copy_dir", "/tmp/123", mods_dir .. "/123", false },
|
||||||
{ "refresh_globals" },
|
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -188,7 +180,6 @@ describe("install_dir", function()
|
|||||||
env.assert_calls({
|
env.assert_calls({
|
||||||
{ "delete_dir", "/tmp/alt-target" },
|
{ "delete_dir", "/tmp/alt-target" },
|
||||||
{ "copy_dir", "/tmp/123", "/tmp/alt-target", false },
|
{ "copy_dir", "/tmp/123", "/tmp/alt-target", false },
|
||||||
{ "refresh_globals" },
|
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -238,6 +229,5 @@ describe("install_dir", function()
|
|||||||
path, message = env.pkgmgr.install_dir("txp", "/tmp/123", "name", nil)
|
path, message = env.pkgmgr.install_dir("txp", "/tmp/123", "name", nil)
|
||||||
assert.is._not._nil(path)
|
assert.is._not._nil(path)
|
||||||
assert.is._nil(message)
|
assert.is._nil(message)
|
||||||
|
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@ -72,9 +72,6 @@ end
|
|||||||
|
|
||||||
|
|
||||||
local function has_packages_from_cdb()
|
local function has_packages_from_cdb()
|
||||||
pkgmgr.refresh_globals()
|
|
||||||
pkgmgr.update_gamelist()
|
|
||||||
|
|
||||||
for _, content in pairs(pkgmgr.get_all()) do
|
for _, content in pairs(pkgmgr.get_all()) do
|
||||||
if pkgmgr.get_contentdb_id(content) then
|
if pkgmgr.get_contentdb_id(content) then
|
||||||
return true
|
return true
|
||||||
@ -127,9 +124,6 @@ function update_detector.get_all()
|
|||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
|
|
||||||
pkgmgr.refresh_globals()
|
|
||||||
pkgmgr.update_gamelist()
|
|
||||||
|
|
||||||
local ret = {}
|
local ret = {}
|
||||||
local all_content = pkgmgr.get_all()
|
local all_content = pkgmgr.get_all()
|
||||||
for _, content in ipairs(all_content) do
|
for _, content in ipairs(all_content) do
|
||||||
|
@ -37,11 +37,7 @@ local function delete_content_buttonhandler(this, fields)
|
|||||||
gamedata.errormessage = fgettext_ne("pkgmgr: failed to delete \"$1\"", this.data.content.path)
|
gamedata.errormessage = fgettext_ne("pkgmgr: failed to delete \"$1\"", this.data.content.path)
|
||||||
end
|
end
|
||||||
|
|
||||||
if this.data.content.type == "game" then
|
pkgmgr.reload_by_type(this.data.content.type)
|
||||||
pkgmgr.update_gamelist()
|
|
||||||
else
|
|
||||||
pkgmgr.refresh_globals()
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
gamedata.errormessage = fgettext_ne("pkgmgr: invalid path \"$1\"", this.data.content.path)
|
gamedata.errormessage = fgettext_ne("pkgmgr: invalid path \"$1\"", this.data.content.path)
|
||||||
end
|
end
|
||||||
|
@ -45,7 +45,7 @@ local function rename_modpack_buttonhandler(this, fields)
|
|||||||
local oldpath = this.data.mod.path
|
local oldpath = this.data.mod.path
|
||||||
local targetpath = this.data.mod.parent_dir .. DIR_DELIM .. fields["te_modpack_name"]
|
local targetpath = this.data.mod.parent_dir .. DIR_DELIM .. fields["te_modpack_name"]
|
||||||
os.rename(oldpath, targetpath)
|
os.rename(oldpath, targetpath)
|
||||||
pkgmgr.refresh_globals()
|
pkgmgr.reload_global_mods()
|
||||||
pkgmgr.selected_mod = pkgmgr.global_mods:get_current_index(
|
pkgmgr.selected_mod = pkgmgr.global_mods:get_current_index(
|
||||||
pkgmgr.global_mods:raw_index_by_uid(fields["te_modpack_name"]))
|
pkgmgr.global_mods:raw_index_by_uid(fields["te_modpack_name"]))
|
||||||
|
|
||||||
|
@ -22,16 +22,27 @@ local component_funcs = dofile(core.get_mainmenu_path() .. DIR_DELIM ..
|
|||||||
local shadows_component = dofile(core.get_mainmenu_path() .. DIR_DELIM ..
|
local shadows_component = dofile(core.get_mainmenu_path() .. DIR_DELIM ..
|
||||||
"settings" .. DIR_DELIM .. "shadows_component.lua")
|
"settings" .. DIR_DELIM .. "shadows_component.lua")
|
||||||
|
|
||||||
|
local loaded = false
|
||||||
local full_settings = settingtypes.parse_config_file(false, true)
|
local full_settings
|
||||||
local info_icon_path = core.formspec_escape(defaulttexturedir .. "settings_info.png")
|
local info_icon_path = core.formspec_escape(defaulttexturedir .. "settings_info.png")
|
||||||
local reset_icon_path = core.formspec_escape(defaulttexturedir .. "settings_reset.png")
|
local reset_icon_path = core.formspec_escape(defaulttexturedir .. "settings_reset.png")
|
||||||
|
|
||||||
local all_pages = {}
|
local all_pages = {}
|
||||||
local page_by_id = {}
|
local page_by_id = {}
|
||||||
local filtered_pages = all_pages
|
local filtered_pages = all_pages
|
||||||
local filtered_page_by_id = page_by_id
|
local filtered_page_by_id = page_by_id
|
||||||
|
|
||||||
|
|
||||||
|
local function get_setting_info(name)
|
||||||
|
for _, entry in ipairs(full_settings) do
|
||||||
|
if entry.type ~= "category" and entry.name == name then
|
||||||
|
return entry
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local function add_page(page)
|
local function add_page(page)
|
||||||
assert(type(page.id) == "string")
|
assert(type(page.id) == "string")
|
||||||
assert(type(page.title) == "string")
|
assert(type(page.title) == "string")
|
||||||
@ -46,49 +57,6 @@ local function add_page(page)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local change_keys = {
|
|
||||||
query_text = "Controls",
|
|
||||||
requires = {
|
|
||||||
keyboard_mouse = true,
|
|
||||||
},
|
|
||||||
get_formspec = function(self, avail_w)
|
|
||||||
local btn_w = math.min(avail_w, 3)
|
|
||||||
return ("button[0,0;%f,0.8;btn_change_keys;%s]"):format(btn_w, fgettext("Controls")), 0.8
|
|
||||||
end,
|
|
||||||
on_submit = function(self, fields)
|
|
||||||
if fields.btn_change_keys then
|
|
||||||
core.show_keys_menu()
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
add_page({
|
|
||||||
id = "accessibility",
|
|
||||||
title = fgettext_ne("Accessibility"),
|
|
||||||
content = {
|
|
||||||
"language",
|
|
||||||
{ heading = fgettext_ne("General") },
|
|
||||||
"font_size",
|
|
||||||
"chat_font_size",
|
|
||||||
"gui_scaling",
|
|
||||||
"hud_scaling",
|
|
||||||
"show_nametag_backgrounds",
|
|
||||||
{ heading = fgettext_ne("Chat") },
|
|
||||||
"console_height",
|
|
||||||
"console_alpha",
|
|
||||||
"console_color",
|
|
||||||
{ heading = fgettext_ne("Controls") },
|
|
||||||
"autojump",
|
|
||||||
"safe_dig_and_place",
|
|
||||||
{ heading = fgettext_ne("Movement") },
|
|
||||||
"arm_inertia",
|
|
||||||
"view_bobbing_amount",
|
|
||||||
"fall_bobbing_amount",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
local function load_settingtypes()
|
local function load_settingtypes()
|
||||||
local page = nil
|
local page = nil
|
||||||
local section = nil
|
local section = nil
|
||||||
@ -129,31 +97,70 @@ local function load_settingtypes()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
load_settingtypes()
|
|
||||||
|
|
||||||
table.insert(page_by_id.controls_keyboard_and_mouse.content, 1, change_keys)
|
|
||||||
do
|
local function load()
|
||||||
|
if loaded then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
loaded = true
|
||||||
|
|
||||||
|
full_settings = settingtypes.parse_config_file(false, true)
|
||||||
|
|
||||||
|
local change_keys = {
|
||||||
|
query_text = "Controls",
|
||||||
|
requires = {
|
||||||
|
keyboard_mouse = true,
|
||||||
|
},
|
||||||
|
get_formspec = function(self, avail_w)
|
||||||
|
local btn_w = math.min(avail_w, 3)
|
||||||
|
return ("button[0,0;%f,0.8;btn_change_keys;%s]"):format(btn_w, fgettext("Controls")), 0.8
|
||||||
|
end,
|
||||||
|
on_submit = function(self, fields)
|
||||||
|
if fields.btn_change_keys then
|
||||||
|
core.show_keys_menu()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
add_page({
|
||||||
|
id = "accessibility",
|
||||||
|
title = fgettext_ne("Accessibility"),
|
||||||
|
content = {
|
||||||
|
"language",
|
||||||
|
{ heading = fgettext_ne("General") },
|
||||||
|
"font_size",
|
||||||
|
"chat_font_size",
|
||||||
|
"gui_scaling",
|
||||||
|
"hud_scaling",
|
||||||
|
"show_nametag_backgrounds",
|
||||||
|
{ heading = fgettext_ne("Chat") },
|
||||||
|
"console_height",
|
||||||
|
"console_alpha",
|
||||||
|
"console_color",
|
||||||
|
{ heading = fgettext_ne("Controls") },
|
||||||
|
"autojump",
|
||||||
|
"safe_dig_and_place",
|
||||||
|
{ heading = fgettext_ne("Movement") },
|
||||||
|
"arm_inertia",
|
||||||
|
"view_bobbing_amount",
|
||||||
|
"fall_bobbing_amount",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
load_settingtypes()
|
||||||
|
|
||||||
|
table.insert(page_by_id.controls_keyboard_and_mouse.content, 1, change_keys)
|
||||||
|
do
|
||||||
local content = page_by_id.graphics_and_audio_shaders.content
|
local content = page_by_id.graphics_and_audio_shaders.content
|
||||||
local idx = table.indexof(content, "enable_dynamic_shadows")
|
local idx = table.indexof(content, "enable_dynamic_shadows")
|
||||||
table.insert(content, idx, shadows_component)
|
table.insert(content, idx, shadows_component)
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local function get_setting_info(name)
|
|
||||||
for _, entry in ipairs(full_settings) do
|
|
||||||
if entry.type ~= "category" and entry.name == name then
|
|
||||||
return entry
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
-- These must not be translated, as they need to show in the local
|
||||||
end
|
-- language no matter the user's current language.
|
||||||
|
-- This list must be kept in sync with src/unsupported_language_list.txt.
|
||||||
|
get_setting_info("language").option_labels = {
|
||||||
-- These must not be translated, as they need to show in the local
|
|
||||||
-- language no matter the user's current language.
|
|
||||||
-- This list must be kept in sync with src/unsupported_language_list.txt.
|
|
||||||
get_setting_info("language").option_labels = {
|
|
||||||
[""] = fgettext_ne("(Use system language)"),
|
[""] = fgettext_ne("(Use system language)"),
|
||||||
--ar = " [ar]", blacklisted
|
--ar = " [ar]", blacklisted
|
||||||
be = "Беларуская [be]",
|
be = "Беларуская [be]",
|
||||||
@ -214,7 +221,8 @@ get_setting_info("language").option_labels = {
|
|||||||
vi = "Tiếng Việt [vi]",
|
vi = "Tiếng Việt [vi]",
|
||||||
zh_CN = "中文 (简体) [zh_CN]",
|
zh_CN = "中文 (简体) [zh_CN]",
|
||||||
zh_TW = "正體中文 (繁體) [zh_TW]",
|
zh_TW = "正體中文 (繁體) [zh_TW]",
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- See if setting matches keywords
|
-- See if setting matches keywords
|
||||||
@ -734,6 +742,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function create_settings_dlg()
|
function create_settings_dlg()
|
||||||
|
load()
|
||||||
local dlg = dialog_create("dlg_settings", get_formspec, buttonhandler, eventhandler)
|
local dlg = dialog_create("dlg_settings", get_formspec, buttonhandler, eventhandler)
|
||||||
|
|
||||||
dlg.data.page_id = update_filtered_pages("")
|
dlg.data.page_id = update_filtered_pages("")
|
||||||
|
@ -439,9 +439,9 @@ function settingtypes.parse_config_file(read_all, parse_mods)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Parse mods
|
-- Parse mods
|
||||||
|
pkgmgr.load_all()
|
||||||
local mods_category_initialized = false
|
local mods_category_initialized = false
|
||||||
local mods = {}
|
local mods = pkgmgr.global_mods:get_list()
|
||||||
pkgmgr.get_mods(core.get_modpath(), "mods", mods)
|
|
||||||
table.sort(mods, function(a, b) return a.name < b.name end)
|
table.sort(mods, function(a, b) return a.name < b.name end)
|
||||||
|
|
||||||
for _, mod in ipairs(mods) do
|
for _, mod in ipairs(mods) do
|
||||||
|
@ -29,16 +29,11 @@ end
|
|||||||
local packages_raw, packages
|
local packages_raw, packages
|
||||||
|
|
||||||
local function update_packages()
|
local function update_packages()
|
||||||
if not pkgmgr.global_mods then
|
pkgmgr.load_all()
|
||||||
pkgmgr.refresh_globals()
|
|
||||||
end
|
|
||||||
if not pkgmgr.games then
|
|
||||||
pkgmgr.update_gamelist()
|
|
||||||
end
|
|
||||||
|
|
||||||
packages_raw = {}
|
packages_raw = {}
|
||||||
table.insert_all(packages_raw, pkgmgr.games)
|
table.insert_all(packages_raw, pkgmgr.games)
|
||||||
table.insert_all(packages_raw, pkgmgr.get_texture_packs())
|
table.insert_all(packages_raw, pkgmgr.texture_packs)
|
||||||
table.insert_all(packages_raw, pkgmgr.global_mods:get_list())
|
table.insert_all(packages_raw, pkgmgr.global_mods:get_list())
|
||||||
|
|
||||||
local function get_data()
|
local function get_data()
|
||||||
@ -207,6 +202,7 @@ local function handle_doubleclick(pkg)
|
|||||||
core.settings:set("texture_path", pkg.path)
|
core.settings:set("texture_path", pkg.path)
|
||||||
end
|
end
|
||||||
packages = nil
|
packages = nil
|
||||||
|
pkgmgr.reload_texture_packs()
|
||||||
|
|
||||||
mm_game_theme.init()
|
mm_game_theme.init()
|
||||||
mm_game_theme.set_engine()
|
mm_game_theme.set_engine()
|
||||||
@ -271,6 +267,7 @@ local function handle_buttons(tabview, fields, tabname, tabdata)
|
|||||||
|
|
||||||
core.settings:set("texture_path", txp_path)
|
core.settings:set("texture_path", txp_path)
|
||||||
packages = nil
|
packages = nil
|
||||||
|
pkgmgr.reload_texture_packs()
|
||||||
|
|
||||||
mm_game_theme.init()
|
mm_game_theme.init()
|
||||||
mm_game_theme.set_engine()
|
mm_game_theme.set_engine()
|
||||||
|
Reference in New Issue
Block a user