diff options
Diffstat (limited to 'builtin/mainmenu')
-rw-r--r-- | builtin/mainmenu/dlg_contentstore.lua | 8 | ||||
-rw-r--r-- | builtin/mainmenu/dlg_settings_advanced.lua | 30 | ||||
-rw-r--r-- | builtin/mainmenu/init.lua | 1 | ||||
-rw-r--r-- | builtin/mainmenu/pkgmgr.lua | 56 | ||||
-rw-r--r-- | builtin/mainmenu/tab_content.lua | 88 | ||||
-rw-r--r-- | builtin/mainmenu/tab_credits.lua | 11 |
6 files changed, 185 insertions, 9 deletions
diff --git a/builtin/mainmenu/dlg_contentstore.lua b/builtin/mainmenu/dlg_contentstore.lua index 6525f6013..b3616bfc8 100644 --- a/builtin/mainmenu/dlg_contentstore.lua +++ b/builtin/mainmenu/dlg_contentstore.lua @@ -40,8 +40,8 @@ local num_per_page = 5 local filter_type = 1 local filter_types_titles = { fgettext("All packages"), - fgettext("Games"), - fgettext("Mods"), +-- fgettext("Games"), + fgettext("Clientmods"), fgettext("Texture packs"), } @@ -50,7 +50,7 @@ local download_queue = {} local filter_types_type = { nil, - "game", +-- "game", "mod", "txp", } @@ -254,7 +254,7 @@ end function store.update_paths() local mod_hash = {} pkgmgr.refresh_globals() - for _, mod in pairs(pkgmgr.global_mods:get_list()) do + for _, mod in pairs(pkgmgr.clientmods:get_list()) do if mod.author then mod_hash[mod.author:lower() .. "/" .. mod.name] = mod end diff --git a/builtin/mainmenu/dlg_settings_advanced.lua b/builtin/mainmenu/dlg_settings_advanced.lua index c16e4aad0..d82ae6263 100644 --- a/builtin/mainmenu/dlg_settings_advanced.lua +++ b/builtin/mainmenu/dlg_settings_advanced.lua @@ -400,6 +400,36 @@ local function parse_config_file(read_all, parse_mods) file:close() end end + + -- Parse clientmods + local clientmods_category_initialized = false + local clientmods = {} + get_mods(core.get_clientmodpath(), clientmods) + for _, clientmod in ipairs(clientmods) do + local path = clientmod.path .. DIR_DELIM .. FILENAME + local file = io.open(path, "r") + if file then + if not clientmods_category_initialized then + fgettext_ne("Clientmods") -- not used, but needed for xgettext + table.insert(settings, { + name = "Clientmods", + level = 0, + type = "category", + }) + clientmods_category_initialized = true + end + + table.insert(settings, { + name = clientmod.name, + level = 1, + type = "category", + }) + + parse_single_file(file, path, read_all, settings, 2, false) + + file:close() + end + end end return settings diff --git a/builtin/mainmenu/init.lua b/builtin/mainmenu/init.lua index 96d02d06c..b7e867d2e 100644 --- a/builtin/mainmenu/init.lua +++ b/builtin/mainmenu/init.lua @@ -114,3 +114,4 @@ local function init_globals() end init_globals() + diff --git a/builtin/mainmenu/pkgmgr.lua b/builtin/mainmenu/pkgmgr.lua index 5b8807310..d4acb2b6a 100644 --- a/builtin/mainmenu/pkgmgr.lua +++ b/builtin/mainmenu/pkgmgr.lua @@ -592,7 +592,7 @@ function pkgmgr.install_dir(type, path, basename, targetpath) clean_path = get_last_folder(cleanup_path(basefolder.path)) end if clean_path then - targetpath = core.get_modpath() .. DIR_DELIM .. clean_path + targetpath = core.get_clientmodpath() .. DIR_DELIM .. clean_path else return nil, fgettext("Install Mod: Unable to find suitable folder name for modpack $1", @@ -619,7 +619,7 @@ function pkgmgr.install_dir(type, path, basename, targetpath) end if targetfolder ~= nil and pkgmgr.isValidModname(targetfolder) then - targetpath = core.get_modpath() .. DIR_DELIM .. targetfolder + targetpath = core.get_clientmodpath() .. DIR_DELIM .. targetfolder else return nil, fgettext("Install Mod: Unable to find real mod name for: $1", path) end @@ -671,6 +671,54 @@ function pkgmgr.install(type, modfilename, basename, dest) end -------------------------------------------------------------------------------- +function pkgmgr.prepareclientmodlist(data) + local retval = {} + + local clientmods = {} + + --read clientmods + local modpath = core.get_clientmodpath() + + if modpath ~= nil and + modpath ~= "" then + get_mods(modpath,clientmods) + end + + for i=1,#clientmods,1 do + clientmods[i].type = "mod" + clientmods[i].loc = "global" + clientmods[i].is_clientside = true + retval[#retval + 1] = clientmods[i] + end + + --read mods configuration + local filename = modpath .. + DIR_DELIM .. "mods.conf" + + local conffile = Settings(filename) + + for key,value in pairs(conffile:to_table()) do + if key:sub(1, 9) == "load_mod_" then + key = key:sub(10) + local element = nil + for i=1,#retval,1 do + if retval[i].name == key and + not retval[i].is_modpack then + element = retval[i] + break + end + end + if element ~= nil then + element.enabled = value ~= "false" and value ~= "nil" and value + else + core.log("info", "Clientmod: " .. key .. " " .. dump(value) .. " but not found") + end + end + end + + return retval +end + function pkgmgr.preparemodlist(data) local retval = {} @@ -813,6 +861,10 @@ function pkgmgr.refresh_globals() pkgmgr.comparemod, is_equal, nil, {}) pkgmgr.global_mods:add_sort_mechanism("alphabetic", sort_mod_list) pkgmgr.global_mods:set_sortmode("alphabetic") + pkgmgr.clientmods = filterlist.create(pkgmgr.prepareclientmodlist, + pkgmgr.comparemod, is_equal, nil, {}) + pkgmgr.clientmods:add_sort_mechanism("alphabetic", sort_mod_list) + pkgmgr.clientmods:set_sortmode("alphabetic") end -------------------------------------------------------------------------------- diff --git a/builtin/mainmenu/tab_content.lua b/builtin/mainmenu/tab_content.lua index 336730bf4..a76fee864 100644 --- a/builtin/mainmenu/tab_content.lua +++ b/builtin/mainmenu/tab_content.lua @@ -19,6 +19,10 @@ local packages_raw local packages +local function modname_valid(name) + return not name:find("[^a-z0-9_]") +end + -------------------------------------------------------------------------------- local function get_formspec(tabview, name, tabdata) if pkgmgr.global_mods == nil then @@ -33,6 +37,7 @@ local function get_formspec(tabview, name, tabdata) table.insert_all(packages_raw, pkgmgr.games) table.insert_all(packages_raw, pkgmgr.get_texture_packs()) table.insert_all(packages_raw, pkgmgr.global_mods:get_list()) + table.insert_all(packages_raw, pkgmgr.clientmods:get_list()) local function get_data() return packages_raw @@ -45,6 +50,38 @@ local function get_formspec(tabview, name, tabdata) packages = filterlist.create(get_data, pkgmgr.compare_package, is_equal, nil, {}) + + local filename = core.get_clientmodpath() .. DIR_DELIM .. "mods.conf" + + local conffile = Settings(filename) + local mods = conffile:to_table() + + for i = 1, #packages_raw do + local mod = packages_raw[i] + if mod.is_clientside and not mod.is_modpack then + if modname_valid(mod.name) then + conffile:set("load_mod_" .. mod.name, + mod.enabled and "true" or "false") + elseif mod.enabled then + gamedata.errormessage = fgettext_ne("Failed to enable clientmo" .. + "d \"$1\" as it contains disallowed characters. " .. + "Only characters [a-z0-9_] are allowed.", + mod.name) + end + mods["load_mod_" .. mod.name] = nil + end + end + + -- Remove mods that are not present anymore + for key in pairs(mods) do + if key:sub(1, 9) == "load_mod_" then + conffile:remove(key) + end + end + + if not conffile:write() then + core.log("error", "Failed to write clientmod config file") + end end if tabdata.selected_pkg == nil then @@ -94,9 +131,21 @@ local function get_formspec(tabview, name, tabdata) if selected_pkg.type == "mod" then if selected_pkg.is_modpack then - retval = retval .. - "button[8.65,4.65;3.25,1;btn_mod_mgr_rename_modpack;" .. - fgettext("Rename") .. "]" + if selected_pkg.is_clientside then + if pkgmgr.is_modpack_entirely_enabled({list = packages}, selected_pkg.name) then + retval = retval .. + "button[8.65,4.65;3.25,1;btn_mod_mgr_mp_disable;" .. + fgettext("Disable modpack") .. "]" + else + retval = retval .. + "button[8.65,4.65;3.25,1;btn_mod_mgr_mp_enable;" .. + fgettext("Enable modpack") .. "]" + end + else + retval = retval .. + "button[8.65,4.65;3.25,1;btn_mod_mgr_rename_modpack;" .. + fgettext("Rename") .. "]" + end else --show dependencies desc = desc .. "\n\n" @@ -117,6 +166,17 @@ local function get_formspec(tabview, name, tabdata) "\n" .. toadd_soft end end + if selected_pkg.is_clientside then + if selected_pkg.enabled then + retval = retval .. + "button[8.65,4.65;3.25,1;btn_mod_mgr_disable_mod;" .. + fgettext("Disable") .. "]" + else + retval = retval .. + "button[8.65,4.65;3.25,1;btn_mod_mgr_enable_mod;" .. + fgettext("Enable") .. "]" + end + end end else @@ -150,6 +210,28 @@ local function handle_buttons(tabview, fields, tabname, tabdata) if fields["pkglist"] ~= nil then local event = core.explode_table_event(fields["pkglist"]) tabdata.selected_pkg = event.row + local mod = packages:get_list()[tabdata.selected_pkg] + + if event.type == "DCL" and mod.is_clientside then + pkgmgr.enable_mod({data = {list = packages, selected_mod = tabdata.selected_pkg}}) + packages = nil + end + return true + end + + if fields.btn_mod_mgr_mp_enable ~= nil or + fields.btn_mod_mgr_mp_disable ~= nil then + pkgmgr.enable_mod({data = {list = packages, selected_mod = tabdata.selected_pkg}}, + fields.btn_mod_mgr_mp_enable ~= nil) + packages = nil + return true + end + + if fields.btn_mod_mgr_enable_mod ~= nil or + fields.btn_mod_mgr_disable_mod ~= nil then + pkgmgr.enable_mod({data = {list = packages, selected_mod = tabdata.selected_pkg}}, + fields.btn_mod_mgr_enable_mod ~= nil) + packages = nil return true end diff --git a/builtin/mainmenu/tab_credits.lua b/builtin/mainmenu/tab_credits.lua index c2b7e503a..617823319 100644 --- a/builtin/mainmenu/tab_credits.lua +++ b/builtin/mainmenu/tab_credits.lua @@ -16,6 +16,15 @@ --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -------------------------------------------------------------------------------- +local dragonfire_team = { + "Elias Fleckenstein [Main Developer]", + "cora [Core Developer]", + "emilia [Core Developer]", + "oneplustwo [Developer]", + "joshia_wi [Developer]", + "Code-Sploit [Developer]", + "DerZombiiie [User Support]", +} local core_developers = { "Perttu Ahola (celeron55) <celeron55@gmail.com>", @@ -106,6 +115,8 @@ return { "tablecolumns[color;text]" .. "tableoptions[background=#00000000;highlight=#00000000;border=false]" .. "table[3.5,-0.25;8.5,6.05;list_credits;" .. + "#FFFF00," .. fgettext("Dragonfire Team") .. ",," .. + buildCreditList(dragonfire_team) .. ",,," .. "#FFFF00," .. fgettext("Core Developers") .. ",," .. buildCreditList(core_developers) .. ",,," .. "#FFFF00," .. fgettext("Active Contributors") .. ",," .. |