More spelling fixes
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
CenterFrames.redraw_frame(player,name) --- Draws the center frame for a player, if already open then will destroy it and redraw
|
||||
CenterFrames.toggle_frame(player,name,state) --- Toggles if the frame is currently open or not, will open if closed and close if open
|
||||
|
||||
CenterFrames.new_frame(permision_name) --- Sets the frame to be the current active gui when opened and closes all other frames
|
||||
CenterFrames.new_frame(permission_name) --- Sets the frame to be the current active gui when opened and closes all other frames
|
||||
CenterFrames._prototype:on_draw(player,frame) --- Use to draw your elements onto the new frame
|
||||
CenterFrames._prototype:set_auto_focus(state) --- Sets the frame to be the current active gui when opened and closes all other frames
|
||||
CenterFrames._prototype:draw_frame(player) --- Draws this frame to the player, if already open does nothing (will call on_draw to draw to the frame)
|
||||
@@ -87,10 +87,10 @@ function CenterFrames.toggle_frame(player,name,state)
|
||||
end
|
||||
|
||||
--- Creates a new center frame define
|
||||
-- @tparam string permision_name the name that can be used with the permision system
|
||||
-- @tparam string permission_name the name that can be used with the permission system
|
||||
-- @treturn table the new center frame define
|
||||
function CenterFrames.new_frame(permision_name)
|
||||
local self = Toolbar.new_button(permision_name)
|
||||
function CenterFrames.new_frame(permission_name)
|
||||
local self = Toolbar.new_button(permission_name)
|
||||
|
||||
self:on_click(function(player,element)
|
||||
self:toggle_frame(player)
|
||||
|
||||
@@ -29,16 +29,16 @@
|
||||
LeftFrames.get_flow(player) --- Gets the left frame flow for a player
|
||||
LeftFrames.get_frame(name,player) --- Gets one frame from the left flow by its name
|
||||
LeftFrames.get_open(player) --- Gets all open frames for a player, if non are open it will remove the close all button
|
||||
LeftFrames.toggle_frame(name,player,state) --- Toggles the visiblty of a left frame, or sets its visiblty state
|
||||
LeftFrames.toggle_frame(name,player,state) --- Toggles the visibility of a left frame, or sets its visibility state
|
||||
|
||||
LeftFrames.new_frame(permision_name) --- Creates a new left frame define
|
||||
LeftFrames.new_frame(permission_name) --- Creates a new left frame define
|
||||
LeftFrames._prototype:set_open_by_default(state) --- Sets if the frame is visible when a player joins, can also be a function to return a boolean
|
||||
LeftFrames._prototype:set_direction(direction) --- Sets the direction of the frame, either vertical or horizontal
|
||||
LeftFrames._prototype:get_frame(player) --- Gets the frame for this define from the left frame flow
|
||||
LeftFrames._prototype:is_open(player) --- Returns if the player currently has this define visible
|
||||
LeftFrames._prototype:toggle(player) --- Toggles the visiblty of the left frame
|
||||
LeftFrames._prototype:toggle(player) --- Toggles the visibility of the left frame
|
||||
|
||||
LeftFrames._prototype:update(player) --- Updates the contents of the left frame, first tries update callback, oter wise will clear and redraw
|
||||
LeftFrames._prototype:update(player) --- Updates the contents of the left frame, first tries update callback, other wise will clear and redraw
|
||||
LeftFrames._prototype:update_all(update_offline) --- Updates the frame for all players, see update
|
||||
LeftFrames._prototype:redraw(player) --- Redraws the frame by calling on_draw, will always clear the frame
|
||||
LeftFrames._prototype:redraw_all(update_offline) --- Redraws the frame for all players, see redraw
|
||||
@@ -106,11 +106,11 @@ function LeftFrames.get_open(player)
|
||||
return open
|
||||
end
|
||||
|
||||
--- Toggles the visiblty of a left frame, or sets its visiblty state
|
||||
--- Toggles the visibility of a left frame, or sets its visibility state
|
||||
-- @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
|
||||
-- @tparam[opt] boolean state when given will be the state that the visibility is set to
|
||||
-- @treturn boolean the new state of the visibility
|
||||
function LeftFrames.toggle_frame(name,player,state)
|
||||
local define = LeftFrames.frames[name]
|
||||
if not define then
|
||||
@@ -130,10 +130,10 @@ function LeftFrames.toggle_frame(name,player,state)
|
||||
end
|
||||
|
||||
--- Creates a new left frame define
|
||||
-- @tparam string permision_name the name that can be used with the permision system
|
||||
-- @tparam string permission_name the name that can be used with the permission system
|
||||
-- @treturn table the new left frame define
|
||||
function LeftFrames.new_frame(permision_name)
|
||||
local self = Toolbar.new_button(permision_name)
|
||||
function LeftFrames.new_frame(permission_name)
|
||||
local self = Toolbar.new_button(permission_name)
|
||||
|
||||
local mt = getmetatable(self)
|
||||
mt.__index = LeftFrames._prototype
|
||||
@@ -151,7 +151,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] ?boolean|function state the default state of the visiblty, can be a function
|
||||
-- @tparam[opt=true] ?boolean|function state the default state of the visibility, 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
|
||||
@@ -167,7 +167,7 @@ function LeftFrames._prototype:set_open_by_default(state)
|
||||
end
|
||||
|
||||
--- Sets the direction of the frame, either vertical or horizontal
|
||||
-- @tparam string direction the direction to have the elements be added to thef frame
|
||||
-- @tparam string direction the direction to have the elements be added to the frame
|
||||
function LeftFrames._prototype:set_direction(direction)
|
||||
self.direction = direction
|
||||
return self
|
||||
@@ -221,9 +221,9 @@ function LeftFrames._prototype:is_open(player)
|
||||
return frame and frame.visible or false
|
||||
end
|
||||
|
||||
--- Toggles the visiblty of the left frame
|
||||
--- Toggles the visibility of the left frame
|
||||
-- @tparam LuaPlayer player the player to toggle the frame of
|
||||
-- @treturn boolean the new state of the visiblity
|
||||
-- @treturn boolean the new state of the visibility
|
||||
function LeftFrames._prototype:toggle(player)
|
||||
local frame = self:get_frame(player)
|
||||
Gui.toggle_visible(frame)
|
||||
@@ -231,7 +231,7 @@ function LeftFrames._prototype:toggle(player)
|
||||
return frame.visible
|
||||
end
|
||||
|
||||
--- Updates the contents of the left frame, first tries update callback, oter wise will clear and redraw
|
||||
--- Updates the contents of the left frame, first tries update callback, other wise will clear and redraw
|
||||
-- @tparam LuaPlayer player the player to update the frame of
|
||||
function LeftFrames._prototype:update(player)
|
||||
local frame = self:get_frame(player)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
PopupFrames.get_flow(player) --- Gets the left flow that contains the popup frames
|
||||
PopupFrames.open(define_name,player,open_time,...) --- Opens a popup for the player, can give the amount of time it is open as well as params for the draw function
|
||||
|
||||
PopupFrames.close_progress --- Progress bar which when depleaded will close the popup frame
|
||||
PopupFrames.close_progress --- Progress bar which when depleted will close the popup frame
|
||||
PopupFrames.close_button --- A button which can be used to close the gui before the timer runs out
|
||||
|
||||
PopupFrames.new_popup(name) --- Creates a new popup frame define
|
||||
@@ -34,17 +34,17 @@ Global.register(PopupFrames.paused_popups,function(tbl)
|
||||
PopupFrames.paused_popups = tbl
|
||||
end)
|
||||
|
||||
--- Sets the state of the element in the pasued list, nil or true
|
||||
--- Sets the state of the element in the paused list, nil or true
|
||||
-- @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 function set_paused_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
|
||||
--- Gets the state of the element in the paused list, nil or true
|
||||
-- @tparam LuaGuiElement element the element to get the state of
|
||||
local function get_pasued_state(element)
|
||||
local function get_paused_state(element)
|
||||
local name = element.player_index..':'..element.index
|
||||
return PopupFrames.paused_popups[name]
|
||||
end
|
||||
@@ -75,11 +75,11 @@ end
|
||||
local function close_popup(element)
|
||||
local frame = element.parent.parent.parent
|
||||
if not frame or not frame.valid then return end
|
||||
set_pasued_state(element.parent[PopupFrames.close_progress:uid()])
|
||||
set_paused_state(element.parent[PopupFrames.close_progress:uid()])
|
||||
frame.destroy()
|
||||
end
|
||||
|
||||
--- Progress bar which when depleaded will close the popup frame
|
||||
--- Progress bar which when depleted will close the popup frame
|
||||
PopupFrames.close_progress =
|
||||
ProgressBar.new_progressbar()
|
||||
:use_count_down()
|
||||
@@ -100,20 +100,20 @@ end)
|
||||
--- When the progress bar is clicked it will pause its progress, or resume if previously paused
|
||||
Gui.on_click(PopupFrames.close_progress:uid(),function(event)
|
||||
local element = event.element
|
||||
if get_pasued_state(element) then
|
||||
set_pasued_state(element)
|
||||
if get_paused_state(element) then
|
||||
set_paused_state(element)
|
||||
else
|
||||
set_pasued_state(element,true)
|
||||
set_paused_state(element,true)
|
||||
end
|
||||
end)
|
||||
|
||||
--- When the parent flow of the progress bar is clicked it will pause its progress, or resume if previously paused
|
||||
Gui.on_click(PopupFrames.close_frame_name,function(event)
|
||||
local element = event.element[PopupFrames.close_progress:uid()]
|
||||
if get_pasued_state(element) then
|
||||
set_pasued_state(element)
|
||||
if get_paused_state(element) then
|
||||
set_paused_state(element)
|
||||
else
|
||||
set_pasued_state(element,true)
|
||||
set_paused_state(element,true)
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -214,9 +214,9 @@ Event.add(defines.events.on_player_created,function(event)
|
||||
}
|
||||
end)
|
||||
|
||||
--- Every tick any, not pasued, progress bars will go down by one tick
|
||||
--- Every tick any, not paused, progress bars will go down by one tick
|
||||
Event.add(defines.events.on_tick,PopupFrames.close_progress:event_countdown(function(element)
|
||||
return not get_pasued_state(element)
|
||||
return not get_paused_state(element)
|
||||
end))
|
||||
|
||||
return PopupFrames
|
||||
@@ -22,17 +22,17 @@ local Game = require 'utils.game'
|
||||
local mod_gui = require 'mod-gui'
|
||||
|
||||
local Toolbar = {
|
||||
permisison_names = {},
|
||||
permission_names = {},
|
||||
buttons = {}
|
||||
}
|
||||
|
||||
function Toolbar.allowed(player,define_name)
|
||||
local permisison_name = Toolbar.permisison_names[define_name] or define_name
|
||||
return Roles.player_allowed(player,permisison_name)
|
||||
local permission_name = Toolbar.permission_names[define_name] or define_name
|
||||
return Roles.player_allowed(player,permission_name)
|
||||
end
|
||||
|
||||
function Toolbar.permission_alias(define_name,permisison_name)
|
||||
Toolbar.permisison_names[define_name] = permisison_name
|
||||
function Toolbar.permission_alias(define_name,permission_name)
|
||||
Toolbar.permission_names[define_name] = permission_name
|
||||
end
|
||||
|
||||
--- Adds a new button to the toolbar
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
Gui.set_padding(element,up,down,left,right) --- Sets the padding for a gui element
|
||||
Gui.set_padding_style(style,up,down,left,right) --- Sets the padding for a gui style
|
||||
Gui.create_alignment(element,flow_name) --- Allows the creation of a right align flow to place elements into
|
||||
Gui.destory_if_valid(element) --- Destroies an element but tests for it being present and valid first
|
||||
Gui.destroy_if_valid(element) --- Destroies an element but tests for it being present and valid first
|
||||
Gui.create_scroll_table(element,table_size,maximal_height,name) --- Creates a scroll area with a table inside, table can be any size
|
||||
Gui.create_header(element,caption,tooltip,right_align,name) --- Creates a header section with a label and button area
|
||||
]]
|
||||
@@ -288,7 +288,7 @@ end
|
||||
--- Destroies an element but tests for it being present and valid first
|
||||
-- @tparam LuaGuiElement element the element to be destroied
|
||||
-- @treturn boolean true if it was destoried
|
||||
function Gui.destory_if_valid(element)
|
||||
function Gui.destroy_if_valid(element)
|
||||
if element and element.valid then
|
||||
element.destroy()
|
||||
return true
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
Button._prototype:on_left_click(player,element) --- Registers a handler for when the button is clicked with the left mouse button
|
||||
Button._prototype:on_right_click(player,element) --- Registers a handler for when the button is clicked with the right mouse button
|
||||
|
||||
Button._prototype:set_sprites(sprite,hovered_sprite,clicked_sprite) --- Adds sprites to a button making it a spirte button
|
||||
Button._prototype:set_sprites(sprite,hovered_sprite,clicked_sprite) --- Adds sprites to a button making it a sprite button
|
||||
Button._prototype:set_click_filter(filter,...) --- Adds a click / mouse button filter to the button
|
||||
Button._prototype:set_key_filter(filter,...) --- Adds a control key filter to the button
|
||||
|
||||
@@ -66,7 +66,7 @@ function Button.new_button(name)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Adds sprites to a button making it a spirte button
|
||||
--- Adds sprites to a button making it a sprite 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
|
||||
@@ -103,7 +103,7 @@ end
|
||||
|
||||
--- Adds a control key filter to the button
|
||||
-- @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
|
||||
-- @tparam[opt] table ... when filter is not a you can add the control keys 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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
--- Gui class define for checkboxs and radiobuttons
|
||||
--- Gui class define for checkbox and radiobuttons
|
||||
--[[
|
||||
>>>> Using an option set
|
||||
An option set is a set of radio buttons where only one of them can be active at a time, this means that when one
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
Note that these radiobuttons can still have on_element_update events but this may result in a double trigger of events as
|
||||
the option set update is always triggered; also add_store cant be used as the option set acts as the store however get
|
||||
and set store will still work but will effect the option set rather than the indivual radiobuttons.
|
||||
and set store will still work but will effect the option set rather than the individual radiobuttons.
|
||||
|
||||
>>>> Functions
|
||||
Checkbox.new_checkbox(name) --- Creates a new checkbox element define
|
||||
@@ -38,10 +38,10 @@
|
||||
Checkbox._prototype_radiobutton:on_store_update(callback) --- Registers a handler for when the stored value updates
|
||||
Checkbox._prototype_radiobutton:add_as_option(option_set,option_name) --- Adds this radiobutton to be an option in the given option set (only one can be true at a time)
|
||||
|
||||
Checkbox.new_option_set(name,callback,categorize) --- Registers a new option set that can be linked to radiobutotns (only one can be true at a time)
|
||||
Checkbox.new_option_set(name,callback,categorize) --- Registers a new option set that can be linked to radiobutton (only one can be true at a time)
|
||||
Checkbox.draw_option_set(name,element) --- Draws all radiobuttons that are part of an option set at once (Gui.draw will not work)
|
||||
|
||||
Checkbox.reset_radiobutton(element,exclude,recursive) --- Sets all radiobutotn in a element to false (unless excluded) and can act recursivly
|
||||
Checkbox.reset_radiobutton(element,exclude,recursive) --- Sets all radiobutton in a element to false (unless excluded) and can act recursively
|
||||
|
||||
Other functions present from expcore.gui.core
|
||||
]]
|
||||
@@ -131,7 +131,7 @@ end
|
||||
|
||||
--- Adds this radiobutton to be an option in the given option set (only one can be true at a time)
|
||||
-- @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
|
||||
-- @tparam string option_name the name of this option that will be used to identify it
|
||||
-- @treturn self the define to allow chaining
|
||||
function Checkbox._prototype_radiobutton:add_as_option(option_set,option_name)
|
||||
self.option_set = option_set
|
||||
@@ -166,9 +166,9 @@ function Checkbox._prototype_radiobutton:set_store(category,value,internal)
|
||||
return Store.set(location,category,value)
|
||||
end
|
||||
|
||||
--- Registers a new option set that can be linked to radiobutotns (only one can be true at a time)
|
||||
--- Registers a new option set that can be linked to radiobuttons (only one can be true at a time)
|
||||
-- @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
|
||||
-- @tparam function callback the update callback when the value of the option set changes
|
||||
-- callback param - value string - the new selected option for this option set
|
||||
-- callback param - category string - the category that updated if categorize was used
|
||||
-- @tparam function categorize the function used to convert an element into a string
|
||||
@@ -208,7 +208,7 @@ function Checkbox.draw_option_set(name,element)
|
||||
|
||||
end
|
||||
|
||||
--- Sets all radiobutotn in a element to false (unless excluded) and can act recursivly
|
||||
--- Sets all radiobutton in a element to false (unless excluded) and can act recursively
|
||||
-- @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
|
||||
@@ -1,4 +1,4 @@
|
||||
--- Gui class define for dropdowns and list boxs
|
||||
--- Gui class define for dropdowns and list box
|
||||
--[[
|
||||
>>>> Functions
|
||||
Dropdown.new_dropdown(name) --- Creates a new dropdown element define
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
--- Gui element define for progess bars
|
||||
--- Gui element define for progress bars
|
||||
--[[
|
||||
>>>> Functions
|
||||
ProgressBar.set_maximum(element,amount,count_down) --- Sets the maximum value that represents the end value of the progress bar
|
||||
ProgressBar.increment(element,amount) --- Increases the value of the progressbar, if a define is given all of its instances are incremented
|
||||
ProgressBar.decrement(element,amount) --- Decreases the value of the progressbar, if a define is given all of its instances are decresed
|
||||
ProgressBar.increment(element,amount) --- Increases the value of the progressbar, if a define is given all of its instances have incremented
|
||||
ProgressBar.decrement(element,amount) --- Decreases the value of the progressbar, if a define is given all of its instances have decremented
|
||||
|
||||
ProgressBar.new_progressbar(name) --- Creates a new progressbar element define
|
||||
ProgressBar._prototype:set_maximum(amount,count_down) --- Sets the maximum value that represents the end value of the progress bar
|
||||
@@ -15,10 +15,10 @@
|
||||
ProgressBar._prototype:add_element(element,maximum) --- Adds an element into the list of instances that will are waiting to complete, does not work with store
|
||||
ProgressBar._prototype:reset_element(element) --- Resets an element, or its store, to be back at the start, either 1 or 0
|
||||
|
||||
ProgressBar._prototype:on_complete(callback) --- Triggers when a progress bar element compeltes (hits 0 or 1)
|
||||
ProgressBar._prototype:on_complete(callback) --- Triggers when a progress bar element completes (hits 0 or 1)
|
||||
ProgressBar._prototype:on_complete(callback) --- Triggers when a store value completes (hits 0 or 1)
|
||||
ProgressBar._prototype:event_counter(filter) --- Event handler factory that counts up by 1 every time the event triggeres, can filter which elements are incremented
|
||||
ProgressBar._prototype:event_countdown(filter) --- Event handler factory that counts down by 1 every time the event triggeres, can filter which elements are decremented
|
||||
ProgressBar._prototype:event_counter(filter) --- Event handler factory that counts up by 1 every time the event triggers, can filter which elements have incremented
|
||||
ProgressBar._prototype:event_countdown(filter) --- Event handler factory that counts down by 1 every time the event triggers, can filter which elements have decremented
|
||||
]]
|
||||
local Gui = require 'expcore.gui.core'
|
||||
local Prototype = require 'expcore.gui.prototype'
|
||||
@@ -52,7 +52,7 @@ end
|
||||
|
||||
local ProgressBar = {
|
||||
unregistered={}, -- elements with no callbacks
|
||||
independent={}, -- elements with a link to a deinfe
|
||||
independent={}, -- elements with a link to a define
|
||||
_prototype=Prototype.extend{
|
||||
on_complete = Prototype.event,
|
||||
on_store_complete = Prototype.event,
|
||||
@@ -84,7 +84,7 @@ end
|
||||
|
||||
--- Gets the element data, used when there is no define
|
||||
-- @tparam LuaGuiElement element the element to get the data of
|
||||
-- @treturn table the element data simialr to define
|
||||
-- @treturn table the element data similar to define
|
||||
local function get_element(element)
|
||||
if not element.valid then return end
|
||||
local name = element.player_index..':'..element.index
|
||||
@@ -102,7 +102,7 @@ function ProgressBar.set_maximum(element,amount)
|
||||
|
||||
local define = get_define(element)
|
||||
if define then
|
||||
define:set_deafult_maximum(amount)
|
||||
define:set_default_maximum(amount)
|
||||
|
||||
else
|
||||
local element_data = get_element(element)
|
||||
@@ -122,7 +122,7 @@ function ProgressBar.set_maximum(element,amount)
|
||||
end
|
||||
end
|
||||
|
||||
--- Increases the value of the progressbar, if a define is given all of its instances are incremented
|
||||
--- Increases the value of the progressbar, if a define is given all of its instances have incremented
|
||||
-- @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)
|
||||
@@ -149,7 +149,7 @@ function ProgressBar.increment(element,amount)
|
||||
end
|
||||
end
|
||||
|
||||
--- Decreases the value of the progressbar, if a define is given all of its instances are decresed
|
||||
--- Decreases the value of the progressbar, if a define is given all of its instances have decremented
|
||||
-- @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)
|
||||
@@ -178,7 +178,7 @@ end
|
||||
|
||||
--- Creates a new progressbar element define
|
||||
-- @tparam[opt] string name the optional debug name that can be added
|
||||
-- @treturn table the new progressbar elemente define
|
||||
-- @treturn table the new progressbar element define
|
||||
function ProgressBar.new_progressbar(name)
|
||||
|
||||
local self = Gui.new_define(ProgressBar._prototype,name)
|
||||
@@ -349,8 +349,8 @@ function ProgressBar._prototype:reset_element(element)
|
||||
end
|
||||
end
|
||||
|
||||
--- Event handler factory that counts up by 1 every time the event triggeres, can filter which elements are incremented
|
||||
-- @tparam[opt] function filter when given will use filtered incerement
|
||||
--- Event handler factory that counts up by 1 every time the event triggers, can filter which elements have incremented
|
||||
-- @tparam[opt] function filter when given will use filtered increment
|
||||
-- @treturn function the event handler
|
||||
function ProgressBar._prototype:event_counter(filter)
|
||||
if type(filter) == 'function' then
|
||||
@@ -364,8 +364,8 @@ function ProgressBar._prototype:event_counter(filter)
|
||||
end
|
||||
end
|
||||
|
||||
--- Event handler factory that counts down by 1 every time the event triggeres, can filter which elements are decremented
|
||||
-- @tparam[opt] function filter when given will use filtered decerement
|
||||
--- Event handler factory that counts down by 1 every time the event triggers, can filter which elements have decremented
|
||||
-- @tparam[opt] function filter when given will use filtered decrement
|
||||
-- @treturn function the event handler
|
||||
function ProgressBar._prototype:event_countdown(filter)
|
||||
if type(filter) == 'function' then
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
--- Gui class define for silders
|
||||
--- Gui class define for sliders
|
||||
--[[
|
||||
>>>> Functions
|
||||
Slider.new_slider(name) --- Creates a new slider element define
|
||||
@@ -128,7 +128,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 LuaGuiElement element the parent element that the lable will be drawn to
|
||||
-- @tparam LuaGuiElement element the parent element that the label 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'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
--- Gui class define for text fields and text boxs
|
||||
--- Gui class define for text fields and text boxes
|
||||
--[[
|
||||
>>>> Functions
|
||||
Text.new_text_field(name) --- Creates a new text field element define
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
--- This file is a breakout from core which forcues on instance management of defines
|
||||
--[[
|
||||
>>>> Using registered instance groups
|
||||
The main use of this module is to register a group of elements refered here as "instances of an element define" in which
|
||||
The main use of this module is to register a group of elements referred here as "instances of an element define" in which
|
||||
is meant that you define the name of a group of drawn elements that are really just multiple versions of a single element.
|
||||
For example this might be that you have one label in multiple places (either for one player or many) and you want to update
|
||||
the caption of all of them at once; this is where this module comes it.
|
||||
|
||||
First you must register the way that the intances are stored and under what name, using Instances.register you will give the
|
||||
name of the collective group of instances followed by an optional categorise function which allows varients to be stored under one
|
||||
First you must register the way that the instances are stored and under what name, using Instances.register you will give the
|
||||
name of the collective group of instances followed by an optional categorise function which allows variants to be stored under one
|
||||
name (like one for each force or player)
|
||||
|
||||
-- categorise works in the same way as store categorise
|
||||
-- so the function will worl here but no value is stored only gui elements
|
||||
-- so the function will world here but no value is stored only gui elements
|
||||
Instances.register('score',Gui.categorize_by_force)
|
||||
|
||||
Then when you draw the new element to a gui you will want to add the element to the group:
|
||||
@@ -26,13 +26,13 @@
|
||||
element.caption = 0
|
||||
end)
|
||||
|
||||
Note that if you dont give a categorise function then you dont need to give a category when getting the elements.
|
||||
Note that if you don't give a categorise function then you don't need to give a category when getting the elements.
|
||||
|
||||
>>>> Using unregistered instance groups
|
||||
When using a registered group and the functions that go with them it is much simpler to use and more importantly includes error checking
|
||||
for valid instance group names; the down side is that the group must be registered which can only be done during startup and not during runtime.
|
||||
To counter this there are two functions simlair to those above in order to add and get instances but may lead to errors not being noticed due to
|
||||
the error interal error checking being skiped to allow it to work.
|
||||
for valid instance group names; the down side is that the group must be registered which can only be done during start-up and not during runtime.
|
||||
To counter this there are two functions similar to those above in order to add and get instances but may lead to errors not being noticed due to
|
||||
the error internal error checking being skipped to allow it to work.
|
||||
|
||||
The main difference between the two groups of functions is that the category must always be present even if is nil; example below shows how a
|
||||
instance group would work when registered vs unregistered:
|
||||
@@ -50,7 +50,7 @@
|
||||
element.caption = '0'
|
||||
end) -- gets all instances from the player force and sets the caption to 0
|
||||
|
||||
-- Registered without category; note that category can just be igroned
|
||||
-- Registered without category; note that category can just be ignored
|
||||
Instances.register('score') -- all instances will be under one group with no categories
|
||||
Instances.add_element('score',new_element) -- adds the new element to the instance list
|
||||
Instances.apply_to_elements('score',function(element)
|
||||
@@ -64,7 +64,7 @@
|
||||
end) -- gets all instances and sets the element caption to 0
|
||||
|
||||
>>>> Functions
|
||||
Instances.has_categories(name) --- Returns if a instnace group has a categorise function; must be registerd
|
||||
Instances.has_categories(name) --- Returns if a instance group has a categorise function; must be registered
|
||||
Instances.is_registered(name) --- Returns if the given name is a registered instance group
|
||||
Instances.register(name,categorise) --- Registers the name of an instance group to allow for storing element instances
|
||||
|
||||
@@ -85,7 +85,7 @@ Global.register(Instances.data,function(tbl)
|
||||
Instances.data = tbl
|
||||
end)
|
||||
|
||||
--- Returns if a instnace group has a categorise function; must be registerd
|
||||
--- Returns if a instance group has a categorise function; must be registered
|
||||
-- @tparam string name the name of the instance group
|
||||
-- @treturn boolean true if there is a categorise function
|
||||
function Instances.has_categories(name)
|
||||
@@ -104,7 +104,7 @@ end
|
||||
-- @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
|
||||
-- @treturn string the name that was added so it can be used as a variable
|
||||
function Instances.register(name,categorise)
|
||||
if _LIFECYCLE ~= _STAGE.control then
|
||||
return error('Can only be called during the control stage', 2)
|
||||
@@ -127,7 +127,7 @@ end
|
||||
-- @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)
|
||||
return error('Invalid name for instance group: '..name,2)
|
||||
end
|
||||
|
||||
if Instances.has_categories(name) then
|
||||
@@ -145,7 +145,7 @@ end
|
||||
-- @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
|
||||
return error('Inavlid name for instance group: '..name,2)
|
||||
return error('Invalid name for instance group: '..name,2)
|
||||
end
|
||||
|
||||
if Instances.has_categories(name) then
|
||||
@@ -158,12 +158,12 @@ end
|
||||
--- Gets all valid element instances and has the option of running a callback on those that are valid
|
||||
-- @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
|
||||
-- @tparam[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
|
||||
function Instances.get_valid_elements(name,category,callback)
|
||||
if not Instances.categorise[name] then
|
||||
return error('Inavlid name for instance group: '..name,2)
|
||||
return error('Invalid name for instance group: '..name,2)
|
||||
end
|
||||
|
||||
category = category or callback
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
Prototype:set_caption(value) --- Sets the caption for the element define
|
||||
Prototype:set_tooltip(value) --- Sets the tooltip for the element define
|
||||
Prototype:set_style(style,callback) --- Sets the style for the element define
|
||||
Prototype:set_embeded_flow(state) --- Sets the element to be drawn inside a nameless flow, can be given a name using a function
|
||||
Prototype:set_embedded_flow(state) --- Sets the element to be drawn inside a nameless flow, can be given a name using a function
|
||||
|
||||
Prototype:set_pre_authenticator --- Sets an authenticator that blocks the draw function if check fails
|
||||
Prototype:set_post_authenticator --- Sets an authenticator that disables the element if check fails
|
||||
@@ -80,10 +80,10 @@ end
|
||||
function Constructor.store(sync,callback)
|
||||
--- Adds a store for the define that is shared between all instances of the define in the same category, categorize is a function that returns a string
|
||||
-- @tparam self table the gui define being acted on
|
||||
-- @tparam[opt] string location a unique location identifier, when omited a uid location will be used, use when sync is set to true
|
||||
-- @tparam[opt] function categorize function used to determine the category of a LuaGuiElement, when omited all share one single category
|
||||
-- @tparam[opt] string location a unique location identifier, when omitted a uid location will be used, use when sync is set to true
|
||||
-- @tparam[opt] function categorize function used to determine the category of a LuaGuiElement, when omitted all share one single category
|
||||
-- categorize param - LuaGuiElement element - 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
|
||||
-- categorize return - string - a deterministic string that references to a category such as player name or force name
|
||||
-- @treturn self the element define to allow chaining
|
||||
return function(self,location,categorize)
|
||||
if self.store then return end
|
||||
@@ -134,8 +134,8 @@ function Constructor.setter(value_type,key,second_key)
|
||||
end
|
||||
|
||||
return function(self,value)
|
||||
local vtype = type(value)
|
||||
if vtype ~= value_type and (not locale or vtype ~= 'string') then
|
||||
local v_type = type(value)
|
||||
if v_type ~= value_type and (not locale or v_type ~= 'string') then
|
||||
error(display_message,2)
|
||||
end
|
||||
|
||||
@@ -213,11 +213,11 @@ end
|
||||
--- Sets the element to be drawn inside a nameless flow, can be given a name using a function
|
||||
-- @tparam state ?boolean|function when true a padless flow is created to contain the element
|
||||
-- @treturn self the element define to allow chaining
|
||||
function Prototype:set_embeded_flow(state)
|
||||
function Prototype:set_embedded_flow(state)
|
||||
if state == false or type(state) == 'function' then
|
||||
self.embeded_flow = state
|
||||
self.embedded_flow = state
|
||||
else
|
||||
self.embeded_flow = true
|
||||
self.embedded_flow = true
|
||||
end
|
||||
return self
|
||||
end
|
||||
@@ -249,12 +249,12 @@ function Prototype:draw_to(element,...)
|
||||
if not self.pre_authenticator(player,self.name) then return end
|
||||
end
|
||||
|
||||
if self.embeded_flow then
|
||||
local embeded_name
|
||||
if type(self.embeded_flow) == 'function' then
|
||||
embeded_name = self.embeded_flow(element,...)
|
||||
if self.embedded_flow then
|
||||
local embedded_name
|
||||
if type(self.embedded_flow) == 'function' then
|
||||
embedded_name = self.embedded_flow(element,...)
|
||||
end
|
||||
element = element.add{type='flow',name=embeded_name}
|
||||
element = element.add{type='flow',name=embedded_name}
|
||||
element.style.padding = 0
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
--- This file creates a teste gui that is used to test every input method
|
||||
-- note that this does not cover every permutation only features in indepentance
|
||||
--- This file creates a test gui that is used to test every input method
|
||||
-- note that this does not cover every permutation only features in independence
|
||||
-- for example store in most cases is just by player name, but other store methods are tested with checkbox
|
||||
local Gui = require 'expcore.gui'
|
||||
local format_chat_colour,table_keys = ext_require('expcore.common','format_chat_colour','table_keys')
|
||||
@@ -223,7 +223,7 @@ end)
|
||||
|
||||
local checkbox_force =
|
||||
Gui.new_checkbox('test-checkbox-store-force')
|
||||
:set_tooltip('Checkboc store force')
|
||||
:set_tooltip('Checkbox store force')
|
||||
:set_caption('Checkbox Store Force')
|
||||
:add_store(Gui.categorize_by_force)
|
||||
:on_element_update(function(player,element,state)
|
||||
@@ -239,7 +239,7 @@ Gui.new_checkbox('test-checkbox-store-player')
|
||||
player.print('Checkbox store player: '..tostring(state))
|
||||
end)
|
||||
|
||||
tests.Checkboxs = {
|
||||
tests.Checkboxes = {
|
||||
['Local']=checkbox_local,
|
||||
['Game store']=checkbox_game,
|
||||
['Force store']=checkbox_force,
|
||||
@@ -425,7 +425,7 @@ Gui.new_list_box('test-list-box-store')
|
||||
player.print('Dropdown store: '..tostring(value))
|
||||
end)
|
||||
|
||||
tests["List Boxs"] = {
|
||||
tests["List Boxes"] = {
|
||||
['Local']=list_box_local,
|
||||
['Player']=list_box_player
|
||||
}
|
||||
@@ -442,7 +442,7 @@ tests["List Boxs"] = {
|
||||
|
||||
local slider_local_default =
|
||||
Gui.new_slider('test-slider-local-default')
|
||||
:set_tooltip('Silder local default')
|
||||
:set_tooltip('Slider local default')
|
||||
:on_element_update(function(player,element,value,percent)
|
||||
player.print('Slider local default: '..tostring(math.round(value))..' '..tostring(math.round(percent,1)))
|
||||
end)
|
||||
@@ -450,7 +450,7 @@ end)
|
||||
|
||||
local slider_player_default =
|
||||
Gui.new_slider('test-slider-store-default')
|
||||
:set_tooltip('Silder store default')
|
||||
:set_tooltip('Slider store default')
|
||||
:add_store(Gui.categorize_by_player)
|
||||
:on_element_update(function(player,element,value,percent)
|
||||
player.print('Slider store default: '..tostring(math.round(value))..' '..tostring(math.round(percent,1)))
|
||||
@@ -458,7 +458,7 @@ end)
|
||||
|
||||
local slider_static =
|
||||
Gui.new_slider('test-slider-static-range')
|
||||
:set_tooltip('Silder static range')
|
||||
:set_tooltip('Slider static range')
|
||||
:set_range(5,50)
|
||||
:on_element_update(function(player,element,value,percent)
|
||||
player.print('Slider static range: '..tostring(math.round(value))..' '..tostring(math.round(percent,1)))
|
||||
@@ -466,7 +466,7 @@ end)
|
||||
|
||||
local slider_dynamic =
|
||||
Gui.new_slider('test-slider-dynamic-range')
|
||||
:set_tooltip('Silder dynamic range')
|
||||
:set_tooltip('Slider dynamic range')
|
||||
:set_range(function(player,element)
|
||||
return player.index - 5
|
||||
end,function(player,element)
|
||||
@@ -478,7 +478,7 @@ end)
|
||||
|
||||
local label_slider_local =
|
||||
Gui.new_slider('test-slider-local-label')
|
||||
:set_tooltip('Silder local label')
|
||||
:set_tooltip('Slider local label')
|
||||
:enable_auto_draw_label()
|
||||
:on_element_update(function(player,element,value,percent)
|
||||
player.print('Slider local label: '..tostring(math.round(value))..' '..tostring(math.round(percent,1)))
|
||||
@@ -486,7 +486,7 @@ end)
|
||||
|
||||
local label_slider_player =
|
||||
Gui.new_slider('test-slider-store-label')
|
||||
:set_tooltip('Silder store label')
|
||||
:set_tooltip('Slider store label')
|
||||
:enable_auto_draw_label()
|
||||
:add_store(Gui.categorize_by_player)
|
||||
:on_element_update(function(player,element,value,percent)
|
||||
@@ -610,7 +610,7 @@ tests["Elem Buttons"] = {
|
||||
Progress bar tests
|
||||
> Simple -- Progress bar that fills every 2 seconds
|
||||
> Store -- Progress bar that fills every 5 seconds with synced value
|
||||
> Reverce -- Progress bar that decreases every 2 seconds
|
||||
> Reverse -- Progress bar that decreases every 2 seconds
|
||||
]]
|
||||
|
||||
local progressbar_one =
|
||||
@@ -651,5 +651,5 @@ end)
|
||||
tests["Progress Bars"] = {
|
||||
['Simple']=progressbar_one,
|
||||
['Store']=progressbar_two,
|
||||
['Reverce']=progressbar_three
|
||||
['Reverse']=progressbar_three
|
||||
}
|
||||
Reference in New Issue
Block a user