diff --git a/src/init.lua b/src/init.lua index a7a5347..a746eff 100644 --- a/src/init.lua +++ b/src/init.lua @@ -14,11 +14,12 @@ local store = require "store" local class = require "class" local mount = require "mount" local signal = require "signal" --- local lang = require "lang" +local lang = require "lang" -- submodule local _,advancedTween = pcall(require,"libs.AdvancedTween") local _,round = pcall(require,"libs.round") +local _,customWarn = pcall(require,"libs.customWarn") local idSpace = {} @@ -38,10 +39,7 @@ function module.Init(id) local this = {__type = "quad_module_init"} this.require = require - this.warn = function(err) - warn(tostring(err)) - print(debug.traceback()) - end + this.warn = customWarn or warn this.Round = type(round) == "table" and round ---@type quad_module_round this.Tween = type(advancedTween) == "table" and advancedTween ---@type quad_module_tween this.Signal = signal.init(this) ---@type quad_module_signal @@ -50,6 +48,7 @@ function module.Init(id) this.Store = store.init(this) ---@type quad_module_store this.Mount = mount.init(this) ---@type quad_module_mount this.Class = class.init(this) ---@type quad_module_class + this.Lang = lang.init(this) ---@type quad_module_lang -- save if id then diff --git a/src/lang.lua b/src/lang.lua new file mode 100644 index 0000000..50a3274 --- /dev/null +++ b/src/lang.lua @@ -0,0 +1,11 @@ +local module = {} + +function module.init(shared) + ---@class quad_module_lang + local new = {} + + return new +end + +return module + diff --git a/src/libs/customWarn.lua b/src/libs/customWarn.lua new file mode 100644 index 0000000..8b0c7cd --- /dev/null +++ b/src/libs/customWarn.lua @@ -0,0 +1,4 @@ +return function(err) + warn(tostring(err)) + print(debug.traceback()) +end diff --git a/src/style.lua b/src/style.lua index f1e2e7c..e633e63 100644 --- a/src/style.lua +++ b/src/style.lua @@ -1,74 +1,74 @@ -local module = {}; -local insert = table.insert; +local module = {} +local insert = table.insert ---@param shared quad_export ---@return quad_module_style function module.init(shared) - local warn = shared.warn; + local warn = shared.warn ---@class quad_module_style - local new = {__type = "quad_module_style"}; + local new = {__type = "quad_module_style"} - local styles = {}; - new.Styles = styles; + local styles = {} + new.Styles = styles ---@class quad_style - local styleClass = {__type = "quad_style"}; - styleClass.__index = styleClass; + local styleClass = {__type = "quad_style"} + styleClass.__index = styleClass function new.New(props) - return setmetatable(props,styleClass); + return setmetatable(props,styleClass) end - local newStyle = new.New; + local newStyle = new.New setmetatable(new,{ ---@return quad_style __call = function (_,styleTable) if type(styleTable) == "string" then return function (nstyleTable) - local this = newStyle(nstyleTable); - styles[styleTable] = this; - return this; + local this = newStyle(nstyleTable) + styles[styleTable] = this + return this end end - return newStyle(styleTable); + return newStyle(styleTable) end - }); + }) local function recursionStyleParse(style,parseTable) for _,value in ipairs(parseTable) do if value == style then - warn("[Quad] infinity recursion detected on parsing style. ignored recursion"); - return; + warn("[Quad] infinity recursion detected on parsing style. ignored recursion") + return end end - insert(parseTable,style); + insert(parseTable,style) for key,value in pairs(style) do if type(key) == "number" and type(value) == "table" and value.__type == "quad_style" then - recursionStyleParse(value,parseTable); + recursionStyleParse(value,parseTable) end end end - local parsed = {}; + local parsed = {} function new.ParseStyles(style) do -- check cache - local cached = parsed[style]; - if cached then return cached; end + local cached = parsed[style] + if cached then return cached end end -- type check if type(style) ~= "table" or style.__type ~= "quad_style" then - error(("Unknown type type '%s:%s' got"):format(tostring(style),tostring(type(style)))); + error(("Unknown type type '%s:%s' got"):format(tostring(style),tostring(type(style)))) end local this = {} - recursionStyleParse(style,this); + recursionStyleParse(style,this) - parsed[style] = this; - return this; + parsed[style] = this + return this end - return new; + return new end -return module; +return module diff --git a/src/types.lua b/src/types.lua index aedae9c..76df3c3 100644 --- a/src/types.lua +++ b/src/types.lua @@ -175,27 +175,32 @@ export type module_tween = { } ------------------- --- module_signal +-- module_round ------------------- -export type round = { +export type module_round = { SetRound: (ImageFrame:ImageLabel|ImageButton,RoundSize:number)->(ImageLabel|ImageButton); SetOutline: (ImageFrame:ImageLabel|ImageButton,RoundSize:number)->(ImageLabel|ImageButton); GetRound: (ImageFrame:ImageLabel|ImageButton)->number; GetOutline: (ImageFrame:ImageLabel|ImageButton)->number; } +------------------- +-- module_signal +------------------- +export type module_lang = {} + ------------------- -- module ------------------- export type module_exported = { - Round: round; + Signal: module_signal; + Round: module_round; Tween: module_tween; Style: module_style; Event: module_event; Store: module_store; Mount: module_mount; Class: module_class; - Signal: module_signal; Lang: module_lang; } export type module = {