mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 12:31:41 +09:00
Added local function
This commit is contained in:
@@ -5,9 +5,19 @@ local Gui = require './core'
|
|||||||
local Button = {
|
local Button = {
|
||||||
config={},
|
config={},
|
||||||
clean_names={},
|
clean_names={},
|
||||||
_prototype = Gui._extend_prototype{}
|
_prototype=Gui._extend_prototype{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local function get_config(name)
|
||||||
|
local config = Button.config[name]
|
||||||
|
if not config and Button.clean_names[name] then
|
||||||
|
return Button.config[Button.clean_names[name]]
|
||||||
|
elseif not config then
|
||||||
|
return error('Invalid name for checkbox, name not found.',3)
|
||||||
|
end
|
||||||
|
return config
|
||||||
|
end
|
||||||
|
|
||||||
function Button.new_button(name)
|
function Button.new_button(name)
|
||||||
local uid = Gui.uid_name()
|
local uid = Gui.uid_name()
|
||||||
Button.config[uid] = setmetatable({
|
Button.config[uid] = setmetatable({
|
||||||
@@ -16,21 +26,15 @@ function Button.new_button(name)
|
|||||||
style=mod_gui.button_style,
|
style=mod_gui.button_style,
|
||||||
type='button'
|
type='button'
|
||||||
},{__index=Button._prototype})
|
},{__index=Button._prototype})
|
||||||
Button.clean_names[uid]=name
|
if name then
|
||||||
Button.clean_names[name]=uid
|
Button.clean_names[uid]=name
|
||||||
|
Button.clean_names[name]=uid
|
||||||
|
end
|
||||||
return Button.config[uid]
|
return Button.config[uid]
|
||||||
end
|
end
|
||||||
|
|
||||||
function Button.draw_button(name,element)
|
function Button.draw_button(name,element)
|
||||||
local button = Button.config[name]
|
local button = get_config(name)
|
||||||
if not button then
|
|
||||||
button = Button.clean_names[name]
|
|
||||||
if not button then
|
|
||||||
return error('Button with uid: '..name..' does not exist')
|
|
||||||
else
|
|
||||||
button = Button.config[button]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return button:draw_to(element)
|
return button:draw_to(element)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user