Ldoc compliant

This commit is contained in:
Cooldude2606
2019-05-29 22:24:04 +01:00
parent 53f9c51c0e
commit e187059ae0
94 changed files with 15315 additions and 479 deletions

View File

@@ -25,7 +25,7 @@ local Button = {
}
--- Creates a new button element define
-- @tparam[opt] name string the optional debug name that can be added
-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new button element define
function Button.new_button(name)
@@ -68,9 +68,9 @@ function Button.new_button(name)
end
--- Adds sprites to a button making it a spirte button
-- @tparam sprite SpritePath the sprite path for the default sprite for the button
-- @tparam[opt] hovered_sprite SpritePath the sprite path for the sprite when the player hovers over the button
-- @tparam[opt] clicked_sprite SpritePath the sprite path for the sprite when the player clicks the button
-- @tparam SpritePath sprite the sprite path for the default sprite for the button
-- @tparam[opt] SpritePath hovered_sprite the sprite path for the sprite when the player hovers over the button
-- @tparam[opt] SpritePath clicked_sprite the sprite path for the sprite when the player clicks the button
-- @treturn self returns the button define to allow chaining
function Button._prototype:set_sprites(sprite,hovered_sprite,clicked_sprite)
self.draw_data.type = 'sprite-button'
@@ -81,8 +81,8 @@ function Button._prototype:set_sprites(sprite,hovered_sprite,clicked_sprite)
end
--- Adds a click / mouse button filter to the button
-- @tparam filter ?string|table either a table of mouse buttons or the first mouse button to filter, with a table true means allowed
-- @tparam[opt] ... when filter is not a table you can add the mouse buttons one after each other
-- @tparam table filter ?string|table either a of mouse buttons or the first mouse button to filter, with a table true means allowed
-- @tparam[opt] table ... when filter is not a you can add the mouse buttons one after each other
-- @treturn self returns the button define to allow chaining
function Button._prototype:set_click_filter(filter,...)
if type(filter) == 'string' then
@@ -103,8 +103,8 @@ function Button._prototype:set_click_filter(filter,...)
end
--- Adds a control key filter to the button
-- @tparam filter ?string|table either a table of control keys or the first control keys to filter, with a table true means allowed
-- @tparam[opt] ... when filter is not a table you can add the control keyss one after each other
-- @tparam table filter ?string|table either a of control keys or the first control keys to filter, with a table true means allowed
-- @tparam[opt] table ... when filter is not a you can add the control keyss one after each other
-- @treturn self returns the button define to allow chaining
function Button._prototype:set_key_filter(filter,...)
if type(filter) == 'string' then

View File

@@ -26,7 +26,7 @@ local CenterFrames = {
}
--- Gets the center flow for a player
-- @tparam player LuapPlayer the player to get the flow for
-- @tparam LuaPlayer player the player to get the flow for
-- @treturn LuaGuiElement the center flow
function CenterFrames.get_flow(player)
player = Game.get_player_from_any(player)
@@ -34,15 +34,15 @@ function CenterFrames.get_flow(player)
end
--- Clears the center flow for a player
-- @tparam player LuapPlayer the player to clear the flow for
-- @tparam LuaPlayer player the player to clear the flow for
function CenterFrames.clear_flow(player)
local flow = CenterFrames.get_flow(player)
flow.clear()
end
--- Draws the center frame for a player, if already open then will do nothing
-- @tparam player LuapPlayer the player that will have the frame drawn
-- @tparam name string the name of the hui that will drawn
-- @tparam LuaPlayer player the player that will have the frame drawn
-- @tparam string name the name of the hui that will drawn
-- @treturn LuaGuiElement the new frame that was made
function CenterFrames.draw_frame(player,name)
local define = Gui.get_define(name,true)
@@ -52,8 +52,8 @@ function CenterFrames.draw_frame(player,name)
end
--- Draws the center frame for a player, if already open then will destroy it and redraw
-- @tparam player LuapPlayer the player that will have the frame drawn
-- @tparam name string the name of the hui that will drawn
-- @tparam LuaPlayer player the player that will have the frame drawn
-- @tparam string name the name of the hui that will drawn
-- @treturn LuaGuiElement the new frame that was made
function CenterFrames.redraw_frame(player,name)
local define = Gui.get_define(name,true)
@@ -63,9 +63,9 @@ function CenterFrames.redraw_frame(player,name)
end
--- Toggles if the frame is currently open or not, will open if closed and close if open
-- @tparam player LuapPlayer the player that will have the frame toggled
-- @tparam name string the name of the hui that will be toggled
-- @tparam[opt] state boolean when set will force a state for the frame
-- @tparam LuaPlayer player the player that will have the frame toggled
-- @tparam string name the name of the hui that will be toggled
-- @tparam[opt] boolean state when set will force a state for the frame
-- @treturn boolean if the frame if no open or closed
function CenterFrames.toggle_frame(player,name,state)
local define = Gui.get_define(name,true)
@@ -86,7 +86,7 @@ function CenterFrames.toggle_frame(player,name,state)
end
--- Creates a new center frame define
-- @tparam permision_name string the name that can be used with the permision system
-- @tparam string permision_name the name that can be used with the permision system
-- @treturn table the new center frame define
function CenterFrames.new_frame(permision_name)
local self = Toolbar.new_button(permision_name)
@@ -108,7 +108,7 @@ function CenterFrames.new_frame(permision_name)
end
--- Sets the frame to be the current active gui when opened and closes all other frames
-- @tparam[opt=true] state boolean when true will auto close other frames and set this frame as player.opened
-- @tparam[opt=true] boolean state when true will auto close other frames and set this frame as player.opened
function CenterFrames._prototype:set_auto_focus(state)
if state == false then
self.auto_focus = false
@@ -118,7 +118,7 @@ function CenterFrames._prototype:set_auto_focus(state)
end
--- Draws this frame to the player, if already open does nothing (will call on_draw to draw to the frame)
-- @tparam player LuaPlayer the player to draw the frame for
-- @tparam LuaPlayer player the player to draw the frame for
-- @treturn LuaGuiElement the new frame that was drawn
function CenterFrames._prototype:draw_frame(player)
player = Game.get_player_from_any(player)
@@ -149,7 +149,7 @@ function CenterFrames._prototype:draw_frame(player)
end
--- Draws this frame to the player, if already open it will remove it and redraw it (will call on_draw to draw to the frame)
-- @tparam player LuaPlayer the player to draw the frame for
-- @tparam LuaPlayer player the player to draw the frame for
-- @treturn LuaGuiElement the new frame that was drawn
function CenterFrames._prototype:redraw_frame(player)
player = Game.get_player_from_any(player)
@@ -163,7 +163,7 @@ function CenterFrames._prototype:redraw_frame(player)
end
--- Toggles if the frame is open, if open it will close it and if closed it will open it
-- @tparam player LuaPlayer the player to draw the frame for
-- @tparam LuaPlayer player the player to draw the frame for
-- @treturn boolean with the gui frame is now open
function CenterFrames._prototype:toggle_frame(player)
player = Game.get_player_from_any(player)
@@ -179,7 +179,7 @@ function CenterFrames._prototype:toggle_frame(player)
end
--- Creates an event handler that will trigger one of its functions, use with Event.add
-- @tparam[opt=update] action string the action to take on this event
-- @tparam[opt=update] string action the action to take on this event
function CenterFrames._prototype:event_handler(action)
action = action or 'update'
return function(event)

View File

@@ -50,9 +50,9 @@ local Store = require 'expcore.store'
local Game = require 'utils.game'
--- Event call for on_checked_state_changed and store update
-- @tparam define table the define that this is acting on
-- @tparam element LuaGuiElement the element that triggered the event
-- @tparam value boolean the new state of the checkbox
-- @tparam table define the define that this is acting on
-- @tparam LuaGuiElement element the element that triggered the event
-- @tparam boolean value the new state of the checkbox
local function event_call(define,element,value)
if define.events.on_element_update then
local player = Game.get_player_by_index(element.player_index)
@@ -61,9 +61,9 @@ local function event_call(define,element,value)
end
--- Store call for store update
-- @tparam define table the define that this is acting on
-- @tparam element LuaGuiElement the element that triggered the event
-- @tparam value boolean the new state of the checkbox
-- @tparam table define the define that this is acting on
-- @tparam LuaGuiElement element the element that triggered the event
-- @tparam boolean value the new state of the checkbox
local function store_call(define,element,value)
element.state = value
event_call(define,element,value)
@@ -87,7 +87,7 @@ local Checkbox = {
}
--- Creates a new checkbox element define
-- @tparam[opt] name string the optional debug name that can be added
-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new checkbox element define
function Checkbox.new_checkbox(name)
@@ -131,7 +131,7 @@ function Checkbox.new_checkbox(name)
end
--- Creates a new radiobutton element define, has all functions checkbox has
-- @tparam[opt] name string the optional debug name that can be added
-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new button element define
function Checkbox.new_radiobutton(name)
local self = Checkbox.new_checkbox(name)
@@ -144,9 +144,9 @@ function Checkbox.new_radiobutton(name)
end
--- Adds this radiobutton to be an option in the given option set (only one can be true at a time)
-- @tparam option_set string the name of the option set to add this element to
-- @tparam option_name string the name of this option that will be used to idenitife it
-- @tparam self the define to allow chaining
-- @tparam string option_set the name of the option set to add this element to
-- @tparam string option_name the name of this option that will be used to idenitife it
-- @treturn self the define to allow chaining
function Checkbox._prototype_radiobutton:add_as_option(option_set,option_name)
self.option_set = option_set
self.option_name = option_name or self.name
@@ -160,7 +160,8 @@ function Checkbox._prototype_radiobutton:add_as_option(option_set,option_name)
end
--- Gets the stored value of the radiobutton or the option set if present
-- @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
-- @tparam boolean internal used to prevent stackover flow
-- @treturn any the value that is stored for this define
function Checkbox._prototype_radiobutton:get_store(category,internal)
if not self.store then return end
@@ -174,8 +175,9 @@ function Checkbox._prototype_radiobutton:get_store(category,internal)
end
--- Sets the stored value of the radiobutton or the option set if present
-- @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 value the value to set for this define, must be valid for its type ie for checkbox etc
-- @tparam boolean internal used to prevent stackover flow
-- @treturn boolean true if the value was set
function Checkbox._prototype_radiobutton:set_store(category,value,internal)
if not self.store then return end
@@ -189,11 +191,11 @@ function Checkbox._prototype_radiobutton:set_store(category,value,internal)
end
--- Registers a new option set that can be linked to radiobutotns (only one can be true at a time)
-- @tparam name string the name of the option set, must be unique
-- @tparam callback function the update callback when the value of the option set chagnes
-- @tparam string name the name of the option set, must be unique
-- @tparam function callback the update callback when the value of the option set chagnes
-- callback param - value string - the new selected option for this option set
-- callback param - category string - the category that updated if categorize was used
-- @tpram categorize function the function used to convert an element into a string
-- @tparam function categorize the function used to convert an element into a string
-- @treturn string the name of this option set to be passed to add_as_option
function Checkbox.new_option_set(name,callback,categorize)
@@ -216,8 +218,8 @@ function Checkbox.new_option_set(name,callback,categorize)
end
--- Draws all radiobuttons that are part of an option set at once (Gui.draw will not work)
-- @tparam name string the name of the option set to draw the radiobuttons of
-- @tparam element LuaGuiElement the parent element that the radiobuttons will be drawn to
-- @tparam string name the name of the option set to draw the radiobuttons of
-- @tparam LuaGuiElement element the parent element that the radiobuttons will be drawn to
function Checkbox.draw_option_set(name,element)
if not Checkbox.option_sets[name] then return end
local options = Checkbox.option_sets[name]
@@ -231,9 +233,9 @@ function Checkbox.draw_option_set(name,element)
end
--- Sets all radiobutotn in a element to false (unless excluded) and can act recursivly
-- @tparam element LuaGuiElement the root gui element to start setting radio buttons from
-- @tparam[opt] exclude ?string|table the name of the radiobutton to exclude or a table of radiobuttons where true will set the state true
-- @tparam[opt=false] recursive boolean if true will recur as much as possible, if a number will recur that number of times
-- @tparam LuaGuiElement element the root gui element to start setting radio buttons from
-- @tparam[opt] table exclude ?string|table the name of the radiobutton to exclude or a of radiobuttons where true will set the state true
-- @tparam[opt=false] ?number|boolean recursive if true will recur as much as possible, if a will recur that number of times
-- @treturn boolean true if successful
function Checkbox.reset_radiobuttons(element,exclude,recursive)
if not element or not element.valid then return end

View File

@@ -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

View File

@@ -20,9 +20,9 @@ local Gui = require 'expcore.gui.core'
local Game = require 'utils.game'
--- Event call for on_selection_state_changed and store update
-- @tparam define table the define that this is acting on
-- @tparam element LuaGuiElement the element that triggered the event
-- @tparam value string the new option for the dropdown
-- @tparam table define the define that this is acting on
-- @tparam LuaGuiElement element the element that triggered the event
-- @tparam string value the new option for the dropdown
local function event_call(define,element,value)
local player = Game.get_player_by_index(element.player_index)
@@ -35,11 +35,11 @@ local function event_call(define,element,value)
end
end
--- Store call for store update
-- @tparam define table the define that this is acting on
-- @tparam element LuaGuiElement the element that triggered the event
-- @tparam value string the new option for the dropdown
local _select_value
--- Store call for store update
-- @tparam table define the define that this is acting on
-- @tparam LuaGuiElement element the element that triggered the event
-- @tparam string value the new option for the dropdown
local function store_call(define,element,value)
_select_value(element,value)
event_call(define,element,value)
@@ -55,7 +55,7 @@ local Dropdown = {
}
--- Creates a new dropdown element define
-- @tparam[opt] name string the optional debug name that can be added
-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new dropdown element define
function Dropdown.new_dropdown(name)
@@ -103,7 +103,7 @@ function Dropdown.new_dropdown(name)
end
--- Creates a new list box element define
-- @tparam[opt] name string the optional debug name that can be added
-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new list box element define
function Dropdown.new_list_box(name)
local self = Dropdown.new_dropdown(name)
@@ -113,8 +113,8 @@ function Dropdown.new_list_box(name)
end
--- Adds new static options to the dropdown which will trigger the general callback
-- @tparam options ?string|table either a table of option strings or the first option string, with a table values are the options
-- @tparam[opt] ... when options is not a table you can add the options one after each other
-- @tparam table options ?string|table either a of option strings or the first option string, with a table values are the options
-- @tparam[opt] table ... when options is not a you can add the options one after each other
-- @tparam self the define to allow chaining
function Dropdown._prototype:new_static_options(options,...)
if type(options) == 'string' then
@@ -131,11 +131,11 @@ end
Dropdown._prototype.add_options = Dropdown._prototype.new_static_options
--- Adds a callback which should return a table of values to be added as options for the dropdown (appended after static options)
-- @tparam callback function the function that will run to get the options for the dropdown
-- @tparam function callback the function that will run to get the options for the dropdown
-- callback param - player LuaPlayer - the player that the element is being drawn to
-- callback param - element LuaGuiElement - the element that is being drawn
-- callback return - table - the values of this table will be appended to the static options of the dropdown
-- @tparam self the define to allow chaining
-- @treturn self the define to allow chaining
function Dropdown._prototype:new_dynamic_options(callback)
if type(callback) ~= 'function' then
return error('Dynamic options callback must be a function',2)
@@ -146,12 +146,12 @@ end
Dropdown._prototype.add_dynamic = Dropdown._prototype.new_dynamic_options
--- Adds a case specific callback which will only run when that option is selected (general case still triggered)
-- @tparam option string the name of the option to trigger the callback on; if not already added then will be added as an option
-- @tparam callback function the function that will be called when that option is selected
-- @tparam string option the name of the option to trigger the callback on; if not already added then will be added as an option
-- @tparam function callback the function that will be called when that option is selected
-- callback param - player LuaPlayer - the player who owns the gui element
-- callback param - element LuaGuiElement - the element which is being effected
-- callback param - value string - the new option that has been selected
-- @tparam self the define to allow chaining
-- @treturn self the define to allow chaining
function Dropdown._prototype:add_option_callback(option,callback)
if not self.option_callbacks then self.option_callbacks = {} end
if not self.options then self.options = {} end
@@ -165,8 +165,8 @@ function Dropdown._prototype:add_option_callback(option,callback)
end
--- Selects the option from a dropdown or list box given the value rather than key
-- @tparam element LuaGuiElement the element that contains the option
-- @tparam value string the option to select from the dropdown
-- @tparam LuaGuiElement element the element that contains the option
-- @tparam string value the option to select from the dropdown
-- @treturn number the key where the value was
function Dropdown.select_value(element,value)
for k,item in pairs(element.items) do
@@ -179,7 +179,7 @@ end
_select_value = Dropdown.select_value
--- Returns the currently selected value rather than index
-- @tparam element LuaGuiElement the gui element that you want to get the value of
-- @tparam LuaGuiElement element the gui element that you want to get the value of
-- @treturn string the value that is currently selected
function Dropdown.get_selected_value(element)
local index = element.selected_index

View File

@@ -15,9 +15,9 @@ local Gui = require 'expcore.gui.core'
local Game = require 'utils.game'
--- Event call for on_elem_changed and store update
-- @tparam define table the define that this is acting on
-- @tparam element LuaGuiElement the element that triggered the event
-- @tparam value string the new value for the elem button
-- @tparam table define the define that this is acting on
-- @tparam LuaGuiElement element the element that triggered the event
-- @tparam string value the new value for the elem button
local function event_call(define,element,value)
local player = Game.get_player_by_index(element.player_index)
@@ -28,12 +28,12 @@ local function event_call(define,element,value)
end
--- Store call for store update
-- @tparam define table the define that this is acting on
-- @tparam element LuaGuiElement the element that triggered the event
-- @tparam value string the new value for the elem button
local function store_call(self,element,value)
-- @tparam table define the define that this is acting on
-- @tparam LuaGuiElement element the element that triggered the event
-- @tparam string value the new value for the elem button
local function store_call(define,element,value)
element.elem_value = value
event_call(self,element,value)
event_call(define,element,value)
end
local ElemButton = {
@@ -46,7 +46,7 @@ local ElemButton = {
}
--- Creates a new elem button element define
-- @tparam[opt] name string the optional debug name that can be added
-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new elem button element define
function ElemButton.new_elem_button(name)
@@ -90,7 +90,7 @@ function ElemButton.new_elem_button(name)
end
--- Sets the type of the elem button, the type is required so this must be called at least once
-- @tparam type string the type that this elem button is see factorio api
-- @tparam string type the type that this elem button is see factorio api
-- @treturn the element define to allow for chaining
function ElemButton._prototype:set_type(type)
self.draw_data.elem_type = type
@@ -98,7 +98,7 @@ function ElemButton._prototype:set_type(type)
end
--- Sets the default value for the elem button, this may be a function or a string
-- @tparam value ?string|function a string will be a static default and a function will be called when drawn to get the default
-- @tparam ?string|function value string a will be a static default and a function will be called when drawn to get the default
-- @treturn the element define to allow for chaining
function ElemButton._prototype:set_default(value)
self.default = value

View File

@@ -86,22 +86,22 @@ Global.register(Instances.data,function(tbl)
end)
--- Returns if a instnace group has a categorise function; must be registerd
-- @tparam name string the name of the instance group
-- @tparam string name the name of the instance group
-- @treturn boolean true if there is a categorise function
function Instances.has_categories(name)
return type(Instances.categorise[name]) == 'function'
end
--- Returns if the given name is a registered instance group
-- @tparam name string the name of the instance group you are testing
-- @tparam string name the name of the instance group you are testing
-- @treturn boolean true if the name is registered
function Instances.is_registered(name)
return Instances.categorise[name] ~= nil
end
--- Registers the name of an instance group to allow for storing element instances
-- @tparam name string the name of the instance group; must to unique
-- @tparam[opt] categorise function function used to turn the element into a string
-- @tparam string name the name of the instance group; must to unique
-- @tparam[opt] function categorise function used to turn the element into a string
-- categorise param - element LuaGuiElement - the gui element to be turned into a string
-- categorise return - string - the category that the element will be added to like the player's name or force's name
-- @treturn string the name that was added so it can be used as a varible
@@ -123,8 +123,8 @@ function Instances.register(name,categorise)
end
--- Adds an element to the instance group under the correct category; must be registered
-- @tparam name string the name of the instance group to add the element to
-- @tparam element LuaGuiElement the element to add the the instance group
-- @tparam string name the name of the instance group to add the element to
-- @tparam LuaGuiElement element the element to add the the instance group
function Instances.add_element(name,element)
if not Instances.categorise[name] then
return error('Inavlid name for instance group: '..name,2)
@@ -140,8 +140,8 @@ function Instances.add_element(name,element)
end
--- Gets all element instances without first removing any invalid ones; used internally and must be registered
-- @tparam name string the name of the instance group to get the instances of
-- @tparam[opt] category string the category to get the instance from, not needed when no categorise function
-- @tparam string name the name of the instance group to get the instances of
-- @tparam[opt] string category the category to get the instance from, not needed when no categorise function
-- @treturn table the table of element instances of which some may be invalid
function Instances.get_elements_raw(name,category)
if not Instances.categorise[name] then
@@ -156,8 +156,8 @@ function Instances.get_elements_raw(name,category)
end
--- Gets all valid element instances and has the option of running a callback on those that are valid
-- @tparam name string the name of the instance group to get the instances of
-- @tparam[opt] category string the category to get the instances of, not needed when no categorise function
-- @tparam string name the name of the instance group to get the instances of
-- @tparam[opt] string category the category to get the instances of, not needed when no categorise function
-- @tparan[opt] callback function when given the callback will be ran on all valid elements
-- callback param - element LuaGuiElement - the current valid element
-- @treturn table the table of element instances with all invalid ones removed
@@ -185,9 +185,9 @@ Instances.get_elements = Instances.get_valid_elements
Instances.apply_to_elements = Instances.get_valid_elements
--- A version of add_element that does not require the group to be registered
-- @tparam name string the name of the instance group to add the element to
-- @tparam string name the name of the instance group to add the element to
-- @tparam category ?string|nil the category to add the element to, can be nil but must still be given
-- @tparam element LuaGuiElement the element to add to the instance group
-- @tparam LuaGuiElement element the element to add to the instance group
function Instances.unregistered_add_element(name,category,element)
if not Instances.data[name] then Instances.data[name] = {} end
if category then
@@ -199,9 +199,9 @@ function Instances.unregistered_add_element(name,category,element)
end
--- A version of get_elements that does not require the group to be registered
-- @tparam name string the name of the instance group to get the instances of
-- @tparam string name the name of the instance group to get the instances of
-- @tparam category ?string|nil the category to get the instances of, can be nil but must still be given
-- @tparam[opt] callback function when given will be called on all valid instances
-- @tparam[opt] function callback when given will be called on all valid instances
-- callback param - element LuaGuiElement - the current valid element
-- @treturn table the table of element instances with all invalid ones removed
function Instances.unregistered_get_elements(name,category,callback)

View File

@@ -66,7 +66,7 @@ setmetatable(LeftFrames._prototype, {
})
--- Gets the left frame flow for a player
-- @tparam player LuaPlayer the player to get the flow of
-- @tparam LuaPlayer player the player to get the flow of
-- @treturn LuaGuiElement the left frame flow for the player
function LeftFrames.get_flow(player)
player = Game.get_player_from_any(player)
@@ -74,8 +74,8 @@ function LeftFrames.get_flow(player)
end
--- Gets one frame from the left flow by its name
-- @tparam name string the name of the gui frame to get
-- @tparam player LuaPlayer the player to get the frame of
-- @tparam string name the name of the gui frame to get
-- @tparam LuaPlayer player the player to get the frame of
-- @treturn LuaGuiElement the frame in the left frame flow with that name
function LeftFrames.get_frame(name,player)
local define = LeftFrames.frames[name]
@@ -86,7 +86,7 @@ function LeftFrames.get_frame(name,player)
end
--- Gets all open frames for a player, if non are open it will remove the close all button
-- @tparam player LuaPlayer the player to get the flow of
-- @tparam LuaPlayer player the player to get the flow of
-- @treturn table contains all the open (and registered) frames for the player
function LeftFrames.get_open(player)
local open = {}
@@ -104,9 +104,9 @@ function LeftFrames.get_open(player)
end
--- Toggles the visiblty of a left frame, or sets its visiblty state
-- @tparam name string the name of the gui frame to toggle
-- @tparam player LuaPlayer the player to get the frame of
-- @tparam[opt] state boolean when given will be the state that the visiblty is set to
-- @tparam string name the name of the gui frame to toggle
-- @tparam LuaPlayer player the player to get the frame of
-- @tparam[opt] boolean state when given will be the state that the visiblty is set to
-- @treturn boolean the new state of the visiblity
function LeftFrames.toggle_frame(name,player,state)
local define = LeftFrames.frames[name]
@@ -127,7 +127,7 @@ function LeftFrames.toggle_frame(name,player,state)
end
--- Creates a new left frame define
-- @tparam permision_name string the name that can be used with the permision system
-- @tparam string permision_name the name that can be used with the permision system
-- @treturn table the new left frame define
function LeftFrames.new_frame(permision_name)
@@ -147,7 +147,7 @@ function LeftFrames.new_frame(permision_name)
end
--- Sets if the frame is visible when a player joins, can also be a function to return a boolean
-- @tparam[opt=true] state ?boolean|function the default state of the visiblty, can be a function
-- @tparam[opt=true] ?boolean|function state the default state of the visiblty, can be a function
-- state param - player LuaPlayer - the player that has joined the game
-- state param - define_name string - the define name for the frame
-- state return - boolean - false will hide the frame
@@ -163,14 +163,14 @@ function LeftFrames._prototype:set_open_by_default(state)
end
--- Sets the direction of the frame, either vertical or horizontal
-- @tparam direction string the direction to have the elements be added to thef frame
-- @tparam string direction the direction to have the elements be added to thef frame
function LeftFrames._prototype:set_direction(direction)
self.direction = direction
return self
end
--- Gets the frame for this define from the left frame flow
-- @tparam player LuaPlayer the player to get the frame of
-- @tparam LuaPlayer player the player to get the frame of
-- @treturn LuaGuiElement the frame in the left frame flow for this define
function LeftFrames._prototype:get_frame(player)
local flow = LeftFrames.get_flow(player)
@@ -180,7 +180,7 @@ function LeftFrames._prototype:get_frame(player)
end
--- Returns if the player currently has this define visible
-- @tparam player LuaPlayer the player to get the frame of
-- @tparam LuaPlayer player the player to get the frame of
-- @treturn boolean true if it is open/visible
function LeftFrames._prototype:is_open(player)
local frame = self:get_frame(player)
@@ -188,7 +188,7 @@ function LeftFrames._prototype:is_open(player)
end
--- Toggles the visiblty of the left frame
-- @tparam player LuaPlayer the player to toggle the frame of
-- @tparam LuaPlayer player the player to toggle the frame of
-- @treturn boolean the new state of the visiblity
function LeftFrames._prototype:toggle(player)
local frame = self:get_frame(player)
@@ -198,7 +198,7 @@ function LeftFrames._prototype:toggle(player)
end
--- Updates the contents of the left frame, first tries update callback, oter wise will clear and redraw
-- @tparam player LuaPlayer the player to update the frame of
-- @tparam LuaPlayer player the player to update the frame of
function LeftFrames._prototype:update(player)
local frame = self:get_frame(player)
if self.events.on_update then
@@ -210,7 +210,7 @@ function LeftFrames._prototype:update(player)
end
--- Updates the frame for all players, see update
-- @tparam[opt=false] update_offline boolean when true will update the frame for offline players
-- @tparam[opt=false] boolean update_offline when true will update the frame for offline players
function LeftFrames._prototype:update_all(update_offline)
local players = update_offline == true and game.players or game.connected_players
for _,player in pairs(players) do
@@ -219,7 +219,7 @@ function LeftFrames._prototype:update_all(update_offline)
end
--- Redraws the frame by calling on_draw, will always clear the frame
-- @tparam player LuaPlayer the player to update the frame of
-- @tparam LuaPlayer player the player to update the frame of
function LeftFrames._prototype:redraw(player)
local frame = self:get_frame(player)
frame.clear()
@@ -229,7 +229,7 @@ function LeftFrames._prototype:redraw(player)
end
--- Redraws the frame for all players, see redraw
-- @tparam[opt=false] update_offline boolean when true will update the frame for offline players
-- @tparam[opt=false] boolean update_offline when true will update the frame for offline players
function LeftFrames._prototype:redraw_all(update_offline)
local players = update_offline == true and game.players or game.connected_players
for _,player in pairs(players) do
@@ -238,7 +238,7 @@ function LeftFrames._prototype:redraw_all(update_offline)
end
--- Creates an event handler that will trigger one of its functions, use with Event.add
-- @tparam[opt=update] action string the action to take on this event
-- @tparam[opt=update] string action the action to take on this event
function LeftFrames._prototype:event_handler(action)
action = action or 'update'
return function(event)

View File

@@ -34,22 +34,22 @@ Global.register(PopupFrames.paused_popups,function(tbl)
end)
--- Sets the state of the element in the pasued list, nil or true
-- @tparam element LuaGuiElement the element to set the state of
-- @tparam[opt] state boolean the state to set it to, true will pause the the progress bar
-- @tparam LuaGuiElement element the element to set the state of
-- @tparam[opt] boolean state the state to set it to, true will pause the the progress bar
local function set_pasued_state(element,state)
local name = element.player_index..':'..element.index
PopupFrames.paused_popups[name] = state
end
--- Gets the state of the element in the pasued list, nil or true
-- @tparam element LuaGuiElement the element to get the state of
-- @tparam LuaGuiElement element the element to get the state of
local function get_pasued_state(element)
local name = element.player_index..':'..element.index
return PopupFrames.paused_popups[name]
end
--- Gets the left flow that contains the popup frames
-- @tparam player LuaPlayer the player to get the flow for
-- @tparam LuaPlayer player the player to get the flow for
-- @treturn LuaGuiElement the left flow that contains the popup frames
function PopupFrames.get_flow(player)
player = Game.get_player_from_any(player)
@@ -58,10 +58,10 @@ function PopupFrames.get_flow(player)
end
--- Opens a popup for the player, can give the amount of time it is open as well as params for the draw function
-- @tparam define_name string the name of the define that you want to open for the player
-- @tparam player LuaPlayer the player to open the popup for
-- @tparam[opt] open_time number the minimum number of ticks you want the popup open for, 0 means no limit, nil will take default
-- @tparam ... any the other params that you want to pass to your on_draw event
-- @tparam string define_name the name of the define that you want to open for the player
-- @tparam LuaPlayer player the player to open the popup for
-- @tparam[opt] number open_time the minimum number of ticks you want the popup open for, 0 means no limit, nil will take default
-- @tparam any ... the other params that you want to pass to your on_draw event
-- @treturn LuaGuiElement the frame that was drawn, the inner gui flow which contains the content
function PopupFrames.open(define_name,player,open_time,...)
local define = Gui.get_define(define_name,true)
@@ -70,7 +70,7 @@ function PopupFrames.open(define_name,player,open_time,...)
end
--- Closes the popup, is called by progress bar and close button
-- @tparam element LuaGuiElement either the progress bar or the close button
-- @tparam LuaGuiElement element either the progress bar or the close button
local function close_popup(element)
local frame = element.parent.parent.parent
if not frame or not frame.valid then return end
@@ -117,7 +117,7 @@ Gui.on_click(PopupFrames.close_frame_name,function(event)
end)
--- Creates a new popup frame define
-- @tparam[opt] name string the optional debug name that can be added
-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new popup frame define
function PopupFrames.new_popup(name)
local self = Gui._define_factory(PopupFrames._prototype)
@@ -182,7 +182,7 @@ function PopupFrames.new_popup(name)
end
--- Sets the default open time for the popup, will be used if non is provided with open
-- @tparam amount number the number of ticks, by default, the popup will be open for
-- @tparam number amount the number of ticks, by default, the popup will be open for
-- @treturn table the define to allow for chaining
function PopupFrames._prototype:set_default_open_time(amount)
self.default_open_time = amount
@@ -190,9 +190,9 @@ function PopupFrames._prototype:set_default_open_time(amount)
end
--- Opens this define for a player, can be given open time and any other params for the draw function
-- @tparam player LuaPlayer the player to open the popup for
-- @tparam[opt] open_time number the minimum number of ticks you want the popup open for, 0 means no limit, nil will take default
-- @tparam ... any the other params that you want to pass to your on_draw event
-- @tparam LuaPlayer player the player to open the popup for
-- @tparam[opt] number open_time the minimum number of ticks you want the popup open for, 0 means no limit, nil will take default
-- @tparam any ... the other params that you want to pass to your on_draw event
-- @treturn LuaGuiElement the frame that was drawn, the inner gui flow which contains the content
function PopupFrames._prototype:open(player,open_time,...)
open_time = open_time or self.default_open_time or 0

View File

@@ -25,8 +25,8 @@ local Global = require 'utils.global'
local Game = require 'utils.game'
--- Event call for when the value is outside the range 0-1
-- @tparam define table the define that this is acting on
-- @tparam element LuaGuiElement the element that triggered the event
-- @tparam table define the define that this is acting on
-- @tparam LuaGuiElement element the element that triggered the event
local function event_call(define,element)
local player = Game.get_player_by_index(element.player_index)
@@ -39,8 +39,9 @@ local function event_call(define,element)
end
--- Store call for store update
-- @tparam define table the define that this is acting on
-- @tparam element LuaGuiElement the element that triggered the event
-- @tparam table define the define that this is acting on
-- @tparam LuaGuiElement element the element that triggered the event
-- @tparam number value the new value for the progress bar
local function store_call(define,element,value)
if value then
element.value = value
@@ -71,7 +72,7 @@ Global.register({
end)
--- Gets the define data, cant use Gui.get_define as it would error
-- @tparam define ?table|string the define to get
-- @tparam ?table|string define the define to get
-- @treturn table the define or nil
local function get_define(define)
if type(define) == 'table' then
@@ -84,7 +85,7 @@ local function get_define(define)
end
--- Gets the element data, used when there is no define
-- @tparam element LuaGuiElement
-- @tparam LuaGuiElement element the element to get the data of
-- @treturn table the element data simialr to define
local function get_element(element)
if not element.valid then return end
@@ -96,8 +97,8 @@ local function get_element(element)
end
--- Sets the maximum value that represents the end value of the progress bar
-- @tparam element ?LuaGuiElement|string either a gui element or a registered define
-- @tparam amount number the amount to have set as the maximum
-- @tparam ?LuaGuiElement|string element either a gui element or a registered define
-- @tparam number amount the amount to have set as the maximum
function ProgressBar.set_maximum(element,amount)
amount = amount > 0 and amount or error('amount must be greater than 0')
@@ -124,8 +125,8 @@ function ProgressBar.set_maximum(element,amount)
end
--- Increases the value of the progressbar, if a define is given all of its instances are incremented
-- @tapram element ?LuaGuiElement|string either a gui element or a registered define
-- @tparam[opt=1] amount number the amount to increase the progressbar by
-- @tparam ?LuaGuiElement|string element either a gui element or a registered define
-- @tparam[opt=1] number amount the amount to increase the progressbar by
function ProgressBar.increment(element,amount)
amount = type(amount) == 'number' and amount or 1
@@ -151,8 +152,8 @@ function ProgressBar.increment(element,amount)
end
--- Decreases the value of the progressbar, if a define is given all of its instances are decresed
-- @tapram element ?LuaGuiElement|string either a gui element or a registered define
-- @tparam[opt=1] amount number the amount to decrease the progressbar by
-- @tparam ?LuaGuiElement|string element either a gui element or a registered define
-- @tparam[opt=1] number amount the amount to decrease the progressbar by
function ProgressBar.decrement(element,amount)
amount = type(amount) == 'number' and amount or 1
@@ -178,7 +179,7 @@ function ProgressBar.decrement(element,amount)
end
--- Creates a new progressbar element define
-- @tparam[opt] name string the optional debug name that can be added
-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new progressbar elemente define
function ProgressBar.new_progressbar(name)
local self = Gui._define_factory(ProgressBar._prototype)
@@ -220,7 +221,7 @@ function ProgressBar.new_progressbar(name)
end
--- Sets the maximum value that represents the end value of the progress bar
-- @tparam amount number the amount to have set as the maximum
-- @tparam number amount the amount to have set as the maximum
-- @treturn table the define to allow chaining
function ProgressBar._prototype:set_default_maximum(amount)
amount = amount > 0 and amount or error('amount must be greater than 0')
@@ -229,7 +230,7 @@ function ProgressBar._prototype:set_default_maximum(amount)
end
--- Will set the progress bar to start at 1 and trigger when it hits 0
-- @tparam[opt=true] state boolean when true the bar will start filled, to be used with decrease
-- @tparam[opt=true] boolean state when true the bar will start filled, to be used with decrease
-- @treturn table the define to allow chaining
function ProgressBar._prototype:use_count_down(state)
if state == false then
@@ -241,9 +242,10 @@ function ProgressBar._prototype:use_count_down(state)
end
--- Main logic for changing the value of a progress bar, this only applies when its a registered define
-- @tparam self table the define that is being changed
-- @tparam amount number the amount which it is being changed by, may be negative
-- @tparam[opt] category string the category to use with store
-- @tparam table self the define that is being changed
-- @tparam number amount the amount which it is being changed by, may be negative
-- @tparam[opt] string category the category to use with store
-- @tparam[opt] function filter when given the filter must return true for the value of the element to be changed
local function change_value_prototype(self,amount,category,filter)
local function reset_store()
@@ -298,32 +300,32 @@ local function change_value_prototype(self,amount,category,filter)
end
--- Increases the value of the progressbar
-- @tparam[opt=1] amount number the amount to increase the progressbar by
-- @tparam[opt] category string the category that is used with a store
-- @tparam[opt=1] number amount the amount to increase the progressbar by
-- @tparam[opt] string category the category that is used with a store
function ProgressBar._prototype:increment(amount,category)
amount = type(amount) == 'number' and amount or 1
change_value_prototype(self,amount,category)
end
--- Increases the value of the progressbar, if the filter condition is met, does not work with store
-- @tparam[opt=1] amount number the amount to increase the progressbar by
-- @tparam[opt] category string the category that is used with a store
-- @tparam[opt=1] number amount the amount to increase the progressbar by
-- @tparam function filter the filter to be used
function ProgressBar._prototype:increment_filtered(amount,filter)
amount = type(amount) == 'number' and amount or 1
change_value_prototype(self,amount,nil,filter)
end
--- Decreases the value of the progressbar
-- @tparam[opt=1] amount number the amount to decrease the progressbar by
-- @tparam[opt] category string the category that is used with a store
-- @tparam[opt=1] number amount the amount to decrease the progressbar by
-- @tparam[opt] string category the category that is used with a store
function ProgressBar._prototype:decrement(amount,category)
amount = type(amount) == 'number' and amount or 1
change_value_prototype(self,-amount,category)
end
--- Decreases the value of the progressbar, if the filter condition is met, does not work with store
-- @tparam[opt=1] amount number the amount to decrease the progressbar by
-- @tparam[opt] category string the category that is used with a store
-- @tparam[opt=1] number amount the amount to decrease the progressbar by
-- @tparam function filter the filter to be used
function ProgressBar._prototype:decrement_filtered(amount,filter)
amount = type(amount) == 'number' and amount or 1
change_value_prototype(self,-amount,nil,filter)
@@ -331,8 +333,8 @@ end
--- Adds an element into the list of instances that will are waiting to complete, does not work with store
-- note use store if you want persistent data, this only stores the elements not the values which they have
-- @tparam element LuaGuiElement the element that you want to add into the waiting to complete list
-- @tparam[opt] maximum number the maximum for this element if not given the default for this define is used
-- @tparam LuaGuiElement element the element that you want to add into the waiting to complete list
-- @tparam[opt] number maximum the maximum for this element if not given the default for this define is used
function ProgressBar._prototype:add_element(element,maximum)
if self.store then return end
if not ProgressBar.independent[self.name] then
@@ -345,7 +347,7 @@ function ProgressBar._prototype:add_element(element,maximum)
end
--- Resets an element, or its store, to be back at the start, either 1 or 0
-- @tparam element LuaGuiElement the element that you want to reset the progress of
-- @tparam LuaGuiElement element the element that you want to reset the progress of
function ProgressBar._prototype:reset_element(element)
if not element or not element.valid then return end
local value = self.count_down and 1 or 0
@@ -358,7 +360,7 @@ function ProgressBar._prototype:reset_element(element)
end
--- Event handler factory that counts up by 1 every time the event triggeres, can filter which elements are incremented
-- @tparam[opt] filter function when given will use filtered incerement
-- @tparam[opt] function filter when given will use filtered incerement
-- @treturn function the event handler
function ProgressBar._prototype:event_counter(filter)
if type(filter) == 'function' then
@@ -373,7 +375,7 @@ function ProgressBar._prototype:event_counter(filter)
end
--- Event handler factory that counts down by 1 every time the event triggeres, can filter which elements are decremented
-- @tparam[opt] filter function when given will use filtered decerement
-- @tparam[opt] function filter when given will use filtered decerement
-- @treturn function the event handler
function ProgressBar._prototype:event_countdown(filter)
if type(filter) == 'function' then

View File

@@ -18,9 +18,9 @@ local Instances = require 'expcore.gui.instances'
local Game = require 'utils.game'
--- Event call for on_value_changed and store update
-- @tparam define table the define that this is acting on
-- @tparam element LuaGuiElement the element that triggered the event
-- @tparam value number the new value for the slider
-- @tparam table define the define that this is acting on
-- @tparam LuaGuiElement element the element that triggered the event
-- @tparam number value the new value for the slider
local function event_call(define,element,value)
local player = Game.get_player_by_index(element.player_index)
@@ -43,9 +43,9 @@ local function event_call(define,element,value)
end
--- Store call for store update
-- @tparam define table the define that this is acting on
-- @tparam element LuaGuiElement the element that triggered the event
-- @tparam value number the new value for the slider
-- @tparam table define the define that this is acting on
-- @tparam LuaGuiElement element the element that triggered the event
-- @tparam number value the new value for the slider
local function store_call(define,element,value)
element.slider_value = value
event_call(define,element,value)
@@ -61,7 +61,7 @@ local Slider = {
}
--- Creates a new slider element define
-- @tparam[opt] name string the optional debug name that can be added
-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new slider element define
function Slider.new_slider(name)
@@ -116,7 +116,7 @@ function Slider.new_slider(name)
end
--- Adds notches to the slider
-- @tparam[opt] state boolean when true will draw notches onto the slider
-- @tparam[opt] boolean state when true will draw notches onto the slider
function Slider._prototype:use_notches(state)
if state == false then
self.draw_data.style = nil
@@ -127,8 +127,8 @@ function Slider._prototype:use_notches(state)
end
--- Sets the range of a slider, if not used will use default values for a slider
-- @tparam[opt] min number the minimum value that the slider can take
-- @tparam[opt] max number the maximum value that the slider can take
-- @tparam[opt] number min the minimum value that the slider can take
-- @tparam[opt] number max the maximum value that the slider can take
-- @treturn self the define to allow chaining
function Slider._prototype:set_range(min,max)
self.min = min
@@ -146,7 +146,7 @@ function Slider._prototype:set_range(min,max)
end
--- Draws a new label and links its value to the value of this slider, if no store then it will only show one value per player
-- @tparam element LuaGuiElement the parent element that the lable will be drawn to
-- @tparam LuaGuiElement element the parent element that the lable will be drawn to
-- @treturn LuaGuiElement the new label element so that styles can be applied
function Slider._prototype:draw_label(element)
local name = self.name..'-label'
@@ -173,7 +173,7 @@ function Slider._prototype:draw_label(element)
end
--- Enables auto draw of the label, the label will share the same parent element as the slider
-- @tparam[opt=true] state boolean when false will disable the auto draw of the label
-- @tparam[opt=true] boolean state when false will disable the auto draw of the label
-- @treturn self the define to allow chaining
function Slider._prototype:enable_auto_draw_label(state)
if state == false then

View File

@@ -18,9 +18,9 @@ local Gui = require 'expcore.gui.core'
local Game = require 'utils.game'
--- Event call for on_text_changed and store update
-- @tparam define table the define that this is acting on
-- @tparam element LuaGuiElement the element that triggered the event
-- @tparam value string the new text for the text field
-- @tparam table define the define that this is acting on
-- @tparam LuaGuiElement element the element that triggered the event
-- @tparam string value the new text for the text field
local function event_call(define,element,value)
local player = Game.get_player_by_index(element.player_index)
@@ -31,12 +31,12 @@ local function event_call(define,element,value)
end
--- Store call for store update
-- @tparam define table the define that this is acting on
-- @tparam element LuaGuiElement the element that triggered the event
-- @tparam value string the new text for the text field
local function store_call(self,element,value)
-- @tparam table define the define that this is acting on
-- @tparam LuaGuiElement element the element that triggered the event
-- @tparam string value the new text for the text field
local function store_call(define,element,value)
element.text = value
event_call(self,element,value)
event_call(define,element,value)
end
local Text = {
@@ -55,7 +55,7 @@ local Text = {
}
--- Creates a new text field element define
-- @tparam[opt] name string the optional debug name that can be added
-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new text field element define
function Text.new_text_field(name)
@@ -105,7 +105,7 @@ function Text.new_text_field(name)
end
--- Creates a new text box element define
-- @tparam[opt] name string the optional debug name that can be added
-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new text box element define
function Text.new_text_box(name)
local self = Text.new_text_field(name)
@@ -118,7 +118,7 @@ function Text.new_text_box(name)
end
--- Sets the text box to be selectable
-- @tparam[opt=true] state boolean when false will set the state to false
-- @tparam[opt=true] boolean state when false will set the state to false
-- @treturn self table the define to allow for chaining
function Text._prototype_box:set_selectable(state)
if state == false then
@@ -130,7 +130,7 @@ function Text._prototype_box:set_selectable(state)
end
--- Sets the text box to have word wrap
-- @tparam[opt=true] state boolean when false will set the state to false
-- @tparam[opt=true] boolean state when false will set the state to false
-- @treturn self table the define to allow for chaining
function Text._prototype_box:set_word_wrap(state)
if state == false then
@@ -142,7 +142,7 @@ function Text._prototype_box:set_word_wrap(state)
end
--- Sets the text box to be read only
-- @tparam[opt=true] state boolean when false will set the state to false
-- @tparam[opt=true] boolean state when false will set the state to false
-- @treturn self table the define to allow for chaining
function Text._prototype_box:set_read_only(state)
if state == false then

View File

@@ -36,7 +36,7 @@ function Toolbar.permission_alias(define_name,permisison_name)
end
--- Adds a new button to the toolbar
-- @tparam[opt] name string when given allows an alias to the button for the permission system
-- @tparam[opt] string name when given allows an alias to the button for the permission system
-- @treturn table the button define
function Toolbar.new_button(name)
local button =
@@ -51,7 +51,7 @@ function Toolbar.new_button(name)
end
--- Adds an existing buttton to the toolbar
-- @tparam button table the button define for the button to be added
-- @tparam table button the button define for the button to be added
function Toolbar.add_button(button)
table.insert(Toolbar.buttons,button)
Gui.allow_player_to_toggle_top_element_visibility(button.name)
@@ -66,7 +66,7 @@ function Toolbar.add_button(button)
end
--- Updates the player's toolbar with an new buttons or expected change in auth return
-- @tparam player LuaPlayer the player to update the toolbar for
-- @tparam LuaPlayer player the player to update the toolbar for
function Toolbar.update(player)
local top = Gui.get_top_element_flow(player)
if not top then return end