mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Ldoc compliant
This commit is contained in:
@@ -167,7 +167,7 @@ Gui.defines = {} -- Stores the indivdual element definations
|
||||
Gui.names = {} -- Stores debug names to link to gui uids
|
||||
|
||||
--- Used internally to create new prototypes for element defines
|
||||
-- @tparam tbl table a table that will have functions added to it
|
||||
-- @tparam table tbl table a that will have functions added to it
|
||||
-- @treturn table the new table with the keys added to it
|
||||
function Gui._prototype_factory(tbl)
|
||||
for k,v in pairs(Gui._prototype) do
|
||||
@@ -177,12 +177,12 @@ function Gui._prototype_factory(tbl)
|
||||
end
|
||||
|
||||
--- Used internally to create event handler adders for element defines
|
||||
-- @tparam name string the key that the event will be stored under, should be the same as the event name
|
||||
-- @tparam string name the key that the event will be stored under, should be the same as the event name
|
||||
-- @treturn function the function that can be used to add an event handler
|
||||
function Gui._event_factory(name)
|
||||
--- Gui._prototype:on_event(callback)
|
||||
--- Add a hander to run on this event, replace event with the event, different classes have different events
|
||||
-- @tparam callback function the function that will be called on the event
|
||||
-- @tparam function callback the function that will be called on the event
|
||||
-- callback param - player LuaPlayer - the player who owns the gui element
|
||||
-- callback param - element LuaGuiElement - the element that caused the event
|
||||
-- callback param - value any - (not always present) the updated value for the element
|
||||
@@ -204,7 +204,7 @@ end
|
||||
function Gui._store_factory(callback)
|
||||
--- Gui._prototype:add_store(categorize)
|
||||
--- Adds a store location for the define that will save the state of the element, categorize is a function that returns a string
|
||||
-- @tparam[opt] categorize function if present will be called to convert an element into a category string
|
||||
-- @tparam[opt] function categorize if present will be called to convert an element into a category string
|
||||
-- categorize param - element LuaGuiElement - the element that needs to be converted
|
||||
-- categorize return - string - a determistic string that referses to a category such as player name or force name
|
||||
-- @treturn self the element define to allow chaining
|
||||
@@ -238,8 +238,8 @@ end
|
||||
function Gui._sync_store_factory(callback)
|
||||
--- Gui._prototype:add_sync_store(location,categorize)
|
||||
--- Adds a store location for the define that will sync between games, categorize is a function that returns a string
|
||||
-- @tparam location string a unique string location, unlike add_store a uid location should not be used to avoid migration problems
|
||||
-- @tparam[opt] categorize function if present will be called to convert an element into a category string
|
||||
-- @tparam string location string a unique location, unlike add_store a uid location should not be used to avoid migration problems
|
||||
-- @tparam[opt] function categorize if present will be called to convert an element into a category string
|
||||
-- categorize param - element LuaGuiElement - the element that needs to be converted
|
||||
-- categorize return - string - a determistic string that referses to a category such as player name or force name
|
||||
-- @treturn self the element define to allow chaining
|
||||
@@ -272,7 +272,7 @@ function Gui._sync_store_factory(callback)
|
||||
end
|
||||
|
||||
--- Used internally to create new element defines from a class prototype
|
||||
-- @tparam prototype table the class prototype that will be used for the element define
|
||||
-- @tparam table prototype the class prototype that will be used for the element define
|
||||
-- @treturn table the new element define with all functions accessed via __index metamethod
|
||||
function Gui._define_factory(prototype)
|
||||
local uid = Gui.uid_name()
|
||||
@@ -299,7 +299,7 @@ function Gui._prototype:uid()
|
||||
end
|
||||
|
||||
--- Sets a debug alias for the define
|
||||
-- @tparam name string the debug name for the element define that can be used to get this element define
|
||||
-- @tparam string name the debug name for the element define that can be used to get this element define
|
||||
-- @treturn self the element define to allow chaining
|
||||
function Gui._prototype:debug_name(name)
|
||||
self.debug_name = name
|
||||
@@ -307,7 +307,7 @@ function Gui._prototype:debug_name(name)
|
||||
end
|
||||
|
||||
--- Sets the caption for the element define
|
||||
-- @tparam caption string the caption that will be drawn with the element
|
||||
-- @tparam string caption the caption that will be drawn with the element
|
||||
-- @treturn self the element define to allow chaining
|
||||
function Gui._prototype:set_caption(caption)
|
||||
self.draw_data.caption = caption
|
||||
@@ -315,7 +315,7 @@ function Gui._prototype:set_caption(caption)
|
||||
end
|
||||
|
||||
--- Sets the tooltip for the element define
|
||||
-- @tparam tooltip string the tooltip that will be displayed for this element when drawn
|
||||
-- @tparam string tooltip the tooltip that will be displayed for this element when drawn
|
||||
-- @treturn self the element define to allow chaining
|
||||
function Gui._prototype:set_tooltip(tooltip)
|
||||
self.draw_data.tooltip = tooltip
|
||||
@@ -323,8 +323,8 @@ function Gui._prototype:set_tooltip(tooltip)
|
||||
end
|
||||
|
||||
--- Sets the style for the element define
|
||||
-- @tparam style string the style that will be used for this element when drawn
|
||||
-- @tapram[opt] callback function function is called when element is drawn to alter its style
|
||||
-- @tparam string style the style that will be used for this element when drawn
|
||||
-- @tparam[opt] callback function function is called when element is drawn to alter its style
|
||||
-- @treturn self the element define to allow chaining
|
||||
function Gui._prototype:set_style(style,callback)
|
||||
self.draw_data.style = style
|
||||
@@ -345,7 +345,7 @@ function Gui._prototype:set_embeded_flow(state)
|
||||
end
|
||||
|
||||
--- Sets an authenticator that blocks the draw function if check fails
|
||||
-- @tparam callback function the function that will be ran to test if the element should be drawn or not
|
||||
-- @tparam function callback the function that will be ran to test if the element should be drawn or not
|
||||
-- callback param - player LuaPlayer - the player that the element is being drawn to
|
||||
-- callback param - define_name string - the name of the define that is being drawn
|
||||
-- callback return - boolean - false will stop the element from being drawn
|
||||
@@ -360,7 +360,7 @@ function Gui._prototype:set_pre_authenticator(callback)
|
||||
end
|
||||
|
||||
--- Sets an authenticator that disables the element if check fails
|
||||
-- @tparam callback function the function that will be ran to test if the element should be enabled or not
|
||||
-- @tparam function callback the function that will be ran to test if the element should be enabled or not
|
||||
-- callback param - player LuaPlayer - the player that the element is being drawn to
|
||||
-- callback param - define_name string - the name of the define that is being drawn
|
||||
-- callback return - boolean - false will disable the element
|
||||
@@ -376,7 +376,7 @@ end
|
||||
|
||||
--- Draws the element using what is in the draw_data table, allows use of authenticator if present, registers new instances if store present
|
||||
-- the data with in the draw_data is set up through the use of all the other functions
|
||||
-- @tparam element LuaGuiElement the element that the define will draw a copy of its self onto
|
||||
-- @tparam LuaGuiElement element the element that the define will draw a copy of its self onto
|
||||
-- @treturn LuaGuiElement the new element that was drawn so styles can be applied
|
||||
function Gui._prototype:draw_to(element,...)
|
||||
if element[self.name] then return end
|
||||
@@ -415,7 +415,7 @@ function Gui._prototype:draw_to(element,...)
|
||||
end
|
||||
|
||||
--- Gets the value in this elements store, category needed if categorize function used
|
||||
-- @tparam category[opt] string the category to get such as player name or force name
|
||||
-- @tparam string category[opt] the category to get such as player name or force name
|
||||
-- @treturn any the value that is stored for this define
|
||||
function Gui._prototype:get_store(category)
|
||||
if not self.store then return end
|
||||
@@ -427,8 +427,8 @@ function Gui._prototype:get_store(category)
|
||||
end
|
||||
|
||||
--- Sets the value in this elements store, category needed if categorize function used
|
||||
-- @tparam category[opt] string the category to get such as player name or force name
|
||||
-- @tparam value any the value to set for this define, must be valid for its type ie boolean for checkbox etc
|
||||
-- @tparam string category[opt] the category to get such as player name or force name
|
||||
-- @tparam boolean any value the value to set for this define, must be valid for its type ie for checkbox etc
|
||||
-- @treturn boolean true if the value was set
|
||||
function Gui._prototype:set_store(category,value)
|
||||
if not self.store then return end
|
||||
@@ -441,7 +441,7 @@ end
|
||||
|
||||
--- Gets an element define give the uid, debug name or a copy of the element define
|
||||
-- @tparam name ?string|table the uid, debug name or define for the element define to get
|
||||
-- @tparam[opt] internal boolean when true the error trace is one level higher (used internally)
|
||||
-- @tparam[opt] boolean internal when true the error trace is one level higher (used internally)
|
||||
-- @treturn table the element define that was found or an error
|
||||
function Gui.get_define(name,internal)
|
||||
if type(name) == 'table' then
|
||||
@@ -465,7 +465,7 @@ end
|
||||
|
||||
--- Gets the value that is stored for a given element define, category needed if categorize function used
|
||||
-- @tparam name ?string|table the uid, debug name or define for the element define to get
|
||||
-- @tparam[opt] category string the category to get the value for
|
||||
-- @tparam[opt] string category the category to get the value for
|
||||
-- @treturn any the value that is stored for this define
|
||||
function Gui.get_store(name,category)
|
||||
local define = Gui.get_define(name,true)
|
||||
@@ -474,8 +474,8 @@ end
|
||||
|
||||
--- Sets the value stored for a given element define, category needed if categorize function used
|
||||
-- @tparam name ?string|table the uid, debug name or define for the element define to set
|
||||
-- @tparam[opt] category string the category to set the value for
|
||||
-- @tparam value any the value to set for the define, must be valid for its type ie boolean for a checkbox
|
||||
-- @tparam[opt] string category the category to set the value for
|
||||
-- @tparam boolean any value the value to set for the define, must be valid for its type ie for a checkbox
|
||||
-- @treturn boolean true if the value was set
|
||||
function Gui.set_store(name,category,value)
|
||||
local define = Gui.get_define(name,true)
|
||||
@@ -483,7 +483,7 @@ function Gui.set_store(name,category,value)
|
||||
end
|
||||
|
||||
--- A categorize function to be used with add_store, each player has their own value
|
||||
-- @tparam element LuaGuiElement the element that will be converted to a string
|
||||
-- @tparam LuaGuiElement element the element that will be converted to a string
|
||||
-- @treturn string the player's name who owns this element
|
||||
function Gui.player_store(element)
|
||||
local player = Game.get_player_by_index(element.player_index)
|
||||
@@ -491,7 +491,7 @@ function Gui.player_store(element)
|
||||
end
|
||||
|
||||
--- A categorize function to be used with add_store, each force has its own value
|
||||
-- @tparam element LuaGuiElement the element that will be converted to a string
|
||||
-- @tparam LuaGuiElement element the element that will be converted to a string
|
||||
-- @treturn string the player's force name who owns this element
|
||||
function Gui.force_store(element)
|
||||
local player = Game.get_player_by_index(element.player_index)
|
||||
@@ -499,7 +499,7 @@ function Gui.force_store(element)
|
||||
end
|
||||
|
||||
--- A categorize function to be used with add_store, each surface has its own value
|
||||
-- @tparam element LuaGuiElement the element that will be converted to a string
|
||||
-- @tparam LuaGuiElement element the element that will be converted to a string
|
||||
-- @treturn string the player's surface name who owns this element
|
||||
function Gui.surface_store(element)
|
||||
local player = Game.get_player_by_index(element.player_index)
|
||||
@@ -516,7 +516,7 @@ function Gui.draw(name,element,...)
|
||||
end
|
||||
|
||||
--- Will toggle the enabled state of an element
|
||||
-- @tparam element LuaGuiElement the gui element to toggle
|
||||
-- @tparam LuaGuiElement element the gui element to toggle
|
||||
-- @treturn boolean the new state that the element has
|
||||
function Gui.toggle_enable(element)
|
||||
if not element or not element.valid then return end
|
||||
@@ -529,7 +529,7 @@ function Gui.toggle_enable(element)
|
||||
end
|
||||
|
||||
--- Will toggle the visiblity of an element
|
||||
-- @tparam element LuaGuiElement the gui element to toggle
|
||||
-- @tparam LuaGuiElement element the gui element to toggle
|
||||
-- @treturn boolean the new state that the element has
|
||||
function Gui.toggle_visible(element)
|
||||
if not element or not element.valid then return end
|
||||
@@ -542,11 +542,11 @@ function Gui.toggle_visible(element)
|
||||
end
|
||||
|
||||
--- Sets the padding for a gui element
|
||||
-- @tparam element LuaGuiElement the element to set the padding for
|
||||
-- @tparam[opt=0] up number the amount of padding on the top
|
||||
-- @tparam[opt=0] down number the amount of padding on the bottom
|
||||
-- @tparam[opt=0] left number the amount of padding on the left
|
||||
-- @tparam[opt=0] right number the amount of padding on the right
|
||||
-- @tparam LuaGuiElement element the element to set the padding for
|
||||
-- @tparam[opt=0] number up the amount of padding on the top
|
||||
-- @tparam[opt=0] number down the amount of padding on the bottom
|
||||
-- @tparam[opt=0] number left the amount of padding on the left
|
||||
-- @tparam[opt=0] number right the amount of padding on the right
|
||||
function Gui.set_padding(element,up,down,left,right)
|
||||
local style = element.style
|
||||
style.top_padding = up or 0
|
||||
@@ -557,10 +557,10 @@ end
|
||||
|
||||
--- Sets the padding for a gui style
|
||||
-- @tparam element LuaStyle the element to set the padding for
|
||||
-- @tparam[opt=0] up number the amount of padding on the top
|
||||
-- @tparam[opt=0] down number the amount of padding on the bottom
|
||||
-- @tparam[opt=0] left number the amount of padding on the left
|
||||
-- @tparam[opt=0] right number the amount of padding on the right
|
||||
-- @tparam[opt=0] number up the amount of padding on the top
|
||||
-- @tparam[opt=0] number down the amount of padding on the bottom
|
||||
-- @tparam[opt=0] number left the amount of padding on the left
|
||||
-- @tparam[opt=0] number right the amount of padding on the right
|
||||
function Gui.set_padding_style(style,up,down,left,right)
|
||||
style.top_padding = up or 0
|
||||
style.bottom_padding = down or 0
|
||||
@@ -569,8 +569,8 @@ function Gui.set_padding_style(style,up,down,left,right)
|
||||
end
|
||||
|
||||
--- Allows the creation of a right align flow to place elements into
|
||||
-- @tparam element LuaGuiElement the element to add this flow to,
|
||||
-- @tparam[opt] flow_name string the name of the flow can be nil
|
||||
-- @tparam LuaGuiElement element the element to add this flow to,
|
||||
-- @tparam[opt] string flow_name the name of the flow can be nil
|
||||
-- @treturn LuaGuiElement the flow that was created
|
||||
function Gui.create_right_align(element,flow_name)
|
||||
local right_flow =
|
||||
@@ -585,7 +585,7 @@ function Gui.create_right_align(element,flow_name)
|
||||
end
|
||||
|
||||
--- Destroies an element but tests for it being present and valid first
|
||||
-- @tparam element LuaGuiElement the element to be destroied
|
||||
-- @tparam LuaGuiElement element the element to be destroied
|
||||
-- @treturn boolean true if it was destoried
|
||||
function Gui.destory_if_valid(element)
|
||||
if element and element.valid then
|
||||
|
||||
Reference in New Issue
Block a user