From 15e143afb0364f816a1033868b2501c9a9e69fda Mon Sep 17 00:00:00 2001 From: Xertis <118364459+Xertis@users.noreply.github.com> Date: Fri, 21 Feb 2025 19:59:57 +0300 Subject: [PATCH] bug fix content_menu.xml.lua --- res/layouts/pages/content_menu.xml.lua | 38 +++++++++++++++++++------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/res/layouts/pages/content_menu.xml.lua b/res/layouts/pages/content_menu.xml.lua index 3a1cea300..767db495a 100644 --- a/res/layouts/pages/content_menu.xml.lua +++ b/res/layouts/pages/content_menu.xml.lua @@ -9,7 +9,7 @@ local CONFIG_NAMES = { "config" } -function on_open(params) +function on_open() refresh() end @@ -115,18 +115,36 @@ local function create_config(i, config, name, path) create_label(nil, '', 0) end - -local function load_config_file(path) - local function valid_name(file_name) - for _, name in ipairs(CONFIG_NAMES) do - if string.find(file_name, name) then - return true - end +local function valid_name(file_name) + for _, name in ipairs(CONFIG_NAMES) do + if string.find(file_name, name) then + return true end + end - return false + return false +end + +local function has_valid_config(id) + if not file.exists("config:" .. id) then + return end + local files = file.list("config:" .. id) + + for _, file_name in ipairs(files) do + local name = file_name:match("([^/]+)%.([^%.]+)$") + + if valid_name(name) then + return true + end + end + + return false +end + +local function load_config_file(path) + local extension = path:match("^.+%.(.+)$") local name = path:match("([^/]+)%.([^%.]+)$") @@ -202,7 +220,7 @@ function open_pack(id) document.configs.visible = false document.content_info.visible = true - if valid_configs("config:" .. id) then document.open_config.enabled = true else document.open_config.enabled = false end + if has_valid_config(id) then document.open_config.enabled = true else document.open_config.enabled = false end if packinfo['dependencies'] == nil then document.dependencies.text = 'None' else document.dependencies.text = table.tostring(packinfo['dependencies']) end if packinfo['creator'] == '' then document.author.text = 'None' else document.author.text = packinfo['creator'] end