Core Module - Toolbar
expcore.gui |
expcore.roles |
utils.event |
utils.game |
mod-gui |
Gui.concept.button |
allowed(player, concept_name) | Used to test if a player is allowed to use a button on the toolbar, if you are not using expcore.roles then change this function |
set_permission_alias(concept_name, alias) | Use to add an alias for the allowed test, alias is what is tested for rather than the concept name |
add_button_concept(concept) | Adds a concept to be drawn to the button area and allows it to be toggled with the toggle toolbar button |
update_buttons(player) | Updates all the buttons for a player, this means hide and show buttons based on permissions |
get_visible_buttons(player) | Returns an array of buttons names that the given player is able to see, returns none if toolbar hidden |
toolbar-button | The base element to be used with the toolbar, others can be used but this is recomented |
add_frame_concept(concept) | Adds a frame concept to the toolbar frame area, this will not add a button to the toolbar |
hide_frames(player) | Hides all the frames for a player |
get_visible_frames(player) | Gets an array of the names of all the visible frames for a player |
toolbar-frame | The base toolbar frame, others can be used but this is recomented |
Toolbar.frame:get_content(player) | Gets the content area of the frame concept for this player, each player only has one area |
Toolbar.frame:toggle_visible_state(player) | Toggles the visibilty of this concept for the given player |
Toolbar.frame:get_visible_state(player) | Gets the current visibilty state of this conept for this player |
Toolbar.frame:update(player[, event]) | Triggers an update of the content within the concept for this player, uses on_update handlers |
Toolbar.frame:update_all([event]) | Triggers an update of the content with in this frame for all players |
toolbar | The main toolbar element, draws, updates, and controls the other concepts |
toolbar-toggle | Button which toggles the the visible state of all toolbar buttons, triggers on_button_update |
toolbar-clear | Button which hides all visible toolbar frames, triggers on_hide_frames |
Used to test if a player is allowed to use a button on the toolbar, if you are not using expcore.roles then change this function
Parameters:-- Test if a player can use 'test-player-list'
local allowed = Toolbar.allowed(game.player,'test-player-list')
Use to add an alias for the allowed test, alias is what is tested for rather than the concept name
Parameters:-- Adding an alias for the 'test-player-list' concept
Toolbar.set_permission_alias('test-player-list','gui/player-list')
Adds a concept to be drawn to the button area and allows it to be toggled with the toggle toolbar button
Parameters:-- Adding a basic button to the toolbar
local new_button =
Gui.new_concept('button')
:set_caption('Click Me')
:on_click(function(event)
event.player.print('You Clicked Me!!')
end)
Toolbar.add_button_concept(new_button)
Updates all the buttons for a player, this means hide and show buttons based on permissions
Parameters:-- Updating your toolbar
Toolbar.update_buttons(player)
Returns an array of buttons names that the given player is able to see, returns none if toolbar hidden
Parameters:-- Get a list of all your visible buttons
Toolbar.get_visible_buttons(game.player)
The base element to be used with the toolbar, others can be used but this is recomented
Properties / Events:-- Adding a basic button to the toolbar, note no need to call Toolbar.add_button_concept
Gui.new_concept('toolbar-button')
:set_caption('Click Me')
:on_click(function(event)
event.player.print('You Clicked Me!!')
end)
Adds a frame concept to the toolbar frame area, this will not add a button to the toolbar
Parameters:-- Adding a basic frame to the frame area
local new_frame =
Gui.new_concept('frame')
:set_title('Test')
Toolbar.add_frame_concept(new_frame)
Hides all the frames for a player
Parameters:-- Hiding all your frames
Toolbar.hide_frames(game.player)
Gets an array of the names of all the visible frames for a player
Parameters:-- Get all your visible frames
Toolbar.get_visible_frames(game.player)
The base toolbar frame, others can be used but this is recomented
Properties / Events:-- Adding a basic player list
local player_list =
Gui.new_concept('toolbar-frame')
:set_permission_alias('player_list')
:set_caption('Player List')
:toggle_with_click()
:define_draw(function(properties,parent,element)
local list_area =
element.add{
name = 'scroll',
type = 'scroll-pane',
direction = 'vertical',
horizontal_scroll_policy = 'never',
vertical_scroll_policy = 'auto-and-reserve-space'
}
Gui.set_padding(list_area,1,1,2,2)
list_area.style.horizontally_stretchable = true
list_area.style.maximal_height = 200
for _,player in pairs(game.connected_players) do
list_area.add{
type='label',
caption=player.name
}
end
end)
:on_update(function(event)
local list_area = event.element.scroll
list_area.clear()
for _,player in pairs(game.connected_players) do
list_area.add{
type='label',
caption=player.name
}
end
end)
Gets the content area of the frame concept for this player, each player only has one area
Parameters:-- Get the content area of a concept
local frame = player_list:get_content(game.player)
Toggles the visibilty of this concept for the given player
Parameters:-- Toggle the frame for your self
player_list:toggle_visible_state(game.player)
Gets the current visibilty state of this conept for this player
Parameters:-- Getting the current visiblity state
Triggers an update of the content within the concept for this player, uses on_update handlers
Parameters:-- Updating the frame for your player
player_list:update(game.player)
Triggers an update of the content with in this frame for all players
Parameters:-- Update the grame for all players
player_list:update_all()
The main toolbar element, draws, updates, and controls the other concepts
Properties / Events:Button which toggles the the visible state of all toolbar buttons, triggers on_button_update
Button which hides all visible toolbar frames, triggers on_hide_frames