diff options
author | AFCMS <afcm.contact@gmail.com> | 2022-08-02 11:58:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-02 11:58:08 +0200 |
commit | 6ec6acc539321709ed8517f1a571777a04f5c24c (patch) | |
tree | 7b63437670a07e218e4af5ebe942e0e3130ec629 /builtin | |
parent | 839600ed703ccffbdb71bd2f04fb379d0920da95 (diff) | |
download | minetest-6ec6acc539321709ed8517f1a571777a04f5c24c.tar.gz minetest-6ec6acc539321709ed8517f1a571777a04f5c24c.tar.bz2 minetest-6ec6acc539321709ed8517f1a571777a04f5c24c.zip |
Add `minetest.settings` to CSM API and allow CSMs to provide `settingtypes.txt` (#12131)
Co-authored-by: sfan5 <sfan5@live.de>
Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/client/init.lua | 1 | ||||
-rw-r--r-- | builtin/client/misc.lua | 7 | ||||
-rw-r--r-- | builtin/mainmenu/dlg_settings_advanced.lua | 30 |
3 files changed, 38 insertions, 0 deletions
diff --git a/builtin/client/init.lua b/builtin/client/init.lua index 0133fc16d..3719a90ee 100644 --- a/builtin/client/init.lua +++ b/builtin/client/init.lua @@ -9,3 +9,4 @@ dofile(commonpath .. "mod_storage.lua") dofile(commonpath .. "chatcommands.lua") dofile(clientpath .. "chatcommands.lua") dofile(clientpath .. "death_formspec.lua") +dofile(clientpath .. "misc.lua") diff --git a/builtin/client/misc.lua b/builtin/client/misc.lua new file mode 100644 index 000000000..80e0f2904 --- /dev/null +++ b/builtin/client/misc.lua @@ -0,0 +1,7 @@ +function core.setting_get_pos(name) + local value = core.settings:get(name) + if not value then + return nil + end + return core.string_to_pos(value) +end diff --git a/builtin/mainmenu/dlg_settings_advanced.lua b/builtin/mainmenu/dlg_settings_advanced.lua index c395f0b08..69562e6a5 100644 --- a/builtin/mainmenu/dlg_settings_advanced.lua +++ b/builtin/mainmenu/dlg_settings_advanced.lua @@ -405,6 +405,36 @@ local function parse_config_file(read_all, parse_mods) file:close() end end + + -- Parse client mods + local clientmods_category_initialized = false + local clientmods = {} + get_mods(core.get_clientmodpath(), "clientmods", clientmods) + for _, mod in ipairs(clientmods) do + local path = mod.path .. DIR_DELIM .. FILENAME + local file = io.open(path, "r") + if file then + if not clientmods_category_initialized then + fgettext_ne("Client Mods") -- not used, but needed for xgettext + table.insert(settings, { + name = "Client Mods", + level = 0, + type = "category", + }) + clientmods_category_initialized = true + end + + table.insert(settings, { + name = mod.name, + level = 1, + type = "category", + }) + + parse_single_file(file, path, read_all, settings, 2, false) + + file:close() + end + end end return settings |