First Test Success

This commit is contained in:
Cooldude2606
2019-08-27 19:23:25 +01:00
parent 6c39335b80
commit 32f41ff722
6 changed files with 207 additions and 16 deletions

View File

@@ -14,21 +14,53 @@ local Gui = {
concepts = {}
}
--[[-- Gets the gui concept with this name
@tparam string name the name of the concept that you want to get
@usage-- Getting a gui concept
local button = Gui.get_concept('Button')
]]
function Gui.get_concept(name)
return Gui.concepts[name] or error('Gui concept "'..name..'" is not defind',2)
end
--[[-- Used internally to save concept names to the core gui module
@function Prototype:change_name
@tparam[opt=self.name] string new_name the new name of the concept
@usage-- Internal Saving
-- this is never needed to be done, internal use only!
local button = Gui.get_concept('Button')
button:change_name('Not Button')
]]
function Prototype:change_name(new_name)
if new_name then
Gui.concepts[self.name] = nil
self.name = new_name
self.properties.name = new_name
end
Gui.concepts[self.name] = self
return self
end
--[[-- Returns a new gui concept with no properties or events
@tparam string name the name that you want this concept to have
@usage-- Making a new concept, see module usage
local button = Gui.new_concept('Button')
]]
function Gui.new_concept(name)
if Gui.concepts[name] then
error('Gui concept "'..name..'" is already defind',2)
end
local concept = Prototype:clone(name)
Gui.concepts[name] = concept
return concept
end
function Gui.get_concept(name)
return Gui.concepts[name] or error('Gui concept "'..name..'" is not defind',2)
return Prototype:clone(name)
end
--[[-- Making anew concept based on the properties and drawing of another
@tparam string name the name of the concept that you want as the base
@tparam string new_name the name that you want the new concept to have
@usage-- Making a new concept from another, see module usage
local custom_button = Gui.clone_concept('Button','CustomButton')
]]
function Gui.clone_concept(name,new_name)
local concept = Gui.concepts[name] or error('Gui concept "'..name..'" is not defind',2)
@@ -36,10 +68,7 @@ function Gui.clone_concept(name,new_name)
error('Gui concept "'..name..'" is already defind',2)
end
local new_concept = concept:clone(new_name)
Gui.concepts[new_name] = new_concept
return new_concept
return concept:clone(new_name)
end
return Gui