From b61ede7d81793cb93f44c7848920bb461ba5291e Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Fri, 21 Feb 2025 19:20:36 +0100 Subject: [PATCH] Workflow --- src/elements/Button.lua | 2 ++ tools/generate-config.lua | 44 ++++++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/elements/Button.lua b/src/elements/Button.lua index 997cc96..25ec372 100644 --- a/src/elements/Button.lua +++ b/src/elements/Button.lua @@ -1,6 +1,8 @@ local elementManager = require("elementManager") local VisualElement = elementManager.getElement("VisualElement") local getCenteredPosition = require("libraries/utils").getCenteredPosition +---@cofnigDescription This is a button. It is a visual element that can be clicked. +---@configDefault true --- This is the button class. It is a visual element that can be clicked. ---@class Button : VisualElement diff --git a/tools/generate-config.lua b/tools/generate-config.lua index a96c3e6..316c758 100644 --- a/tools/generate-config.lua +++ b/tools/generate-config.lua @@ -63,42 +63,48 @@ local function parseFile(filePath) end local function categorizeFile(path) - if path:match("^elements/") then + -- Relativen Pfad verwenden + if path:match("/elements/") then return "elements", "UI Elements" - elseif path:match("^plugins/") then + elseif path:match("/plugins/") then return "plugins", "Plugins" - elseif path:match("^libraries/") then + elseif path:match("/libraries/") then return "libraries", "Libraries" - else + elseif path:match("^src/[^/]+%.lua$") then return "core", "Core Files" end + return "other", "Other Files" end -local function scanDirectory(baseDir) +local function scanDirectory(srcPath) local files = {} - -- Liste aller zu scannenden Ordner - local dirs = { - baseDir .. "/elements", - baseDir .. "/plugins", - baseDir .. "/libraries", - baseDir -- für Core-Files - } - - for _, dir in ipairs(dirs) do - for entry in io.popen('ls -1 "' .. dir .. '"'):lines() do + local basePath = srcPath:match("^(.+)/$") or srcPath + + -- Rekursive Funktion zum Scannen von Ordnern + local function scanRecursive(dir) + local pipe = io.popen('dir "' .. dir .. '" /b') + if not pipe then return end + + for entry in pipe:lines() do + local fullPath = dir .. "\\" .. entry + if entry:match("%.lua$") then - local fullPath = dir .. "/" .. entry local config = parseFile(fullPath) if config then config.name = entry:gsub("%.lua$", "") - -- Relativen Pfad erstellen - config.path = fullPath:gsub("^" .. baseDir .. "/", "") + -- Relativen Pfad mit Forward Slashes erstellen + config.path = fullPath:gsub("^" .. basePath .. "\\", ""):gsub("\\", "/") files[fullPath] = config end + elseif io.popen('dir "' .. fullPath .. '" /ad'):read("*l") then + -- Rekursiv in Unterordner gehen + scanRecursive(fullPath) end end + pipe:close() end - + + scanRecursive(basePath) return files end