Added drop downs and list boxes

This commit is contained in:
Cooldude2606
2019-05-13 23:19:06 +01:00
parent c36550816c
commit 0bd4170629
6 changed files with 241 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
local Gui = require 'expcore.gui'
local format_chat_colour = ext_require('expcore.common','format_chat_colour')
local format_chat_colour,table_keys = ext_require('expcore.common','format_chat_colour','table_keys')
local Colors = require 'resources.color_presets'
local Game = require 'utils.game'
local clean_stack_trace = ext_require('modules.commands.interface','clean_stack_trace')
@@ -86,22 +86,22 @@ end)
tests['Checkbox local'] = Gui.new_checkbox('test checkbox local')
:set_caption('Checkbox Local')
:on_state_change(function(player,element)
player.print('Checkbox local: '..tostring(element.state))
:on_state_change(function(player,element,state)
player.print('Checkbox local: '..tostring(state))
end)
tests['Checkbox store game'] = Gui.new_checkbox('test checkbox store game')
:set_caption('Checkbox Store Game')
:add_store()
:on_state_change(function(player,element)
player.print('Checkbox store game: '..tostring(element.state))
:on_state_change(function(player,element,state)
player.print('Checkbox store game: '..tostring(state))
end)
tests['Checkbox store player'] = Gui.new_checkbox('test checkbox store player')
:set_caption('Checkbox Store Player')
:add_store(categozie_by_player)
:on_state_change(function(player,element)
player.print('Checkbox store player: '..tostring(element.state))
:on_state_change(function(player,element,state)
player.print('Checkbox store player: '..tostring(state))
end)
tests['Checkbox store force'] = Gui.new_checkbox('test checkbox store force')
@@ -110,21 +110,21 @@ tests['Checkbox store force'] = Gui.new_checkbox('test checkbox store force')
local player = Game.get_player_by_index(element.player_index)
return player.force.name
end)
:on_state_change(function(player,element)
player.print('Checkbox store force: '..tostring(element.state))
:on_state_change(function(player,element,state)
player.print('Checkbox store force: '..tostring(state))
end)
tests['Radiobutton local'] = Gui.new_radiobutton('test radiobutton local')
:set_caption('Radiobutton Local')
:on_state_change(function(player,element)
player.print('Radiobutton local: '..tostring(element.state))
:on_state_change(function(player,element,state)
player.print('Radiobutton local: '..tostring(state))
end)
tests['Radiobutton store player'] = Gui.new_radiobutton('test radiobutton store player')
:set_caption('Radiobutton Store Player')
:add_store(categozie_by_player)
:on_state_change(function(player,element)
player.print('Radiobutton store player: '..tostring(element.state))
:on_state_change(function(player,element,state)
player.print('Radiobutton store player: '..tostring(state))
end)
local test_option_set = Gui.new_radiobutton_option_set('gui.test.share',function(value,category)
@@ -134,20 +134,100 @@ end,categozie_by_player)
tests['Radiobutton option one'] = Gui.new_radiobutton('test radiobutton option one')
:set_caption('Radiobutton Option One')
:add_as_option(test_option_set,'One')
:on_state_change(function(player,element)
player.print('Radiobutton option one: '..tostring(element.state))
:on_state_change(function(player,element,state)
player.print('Radiobutton option one: '..tostring(state))
end)
tests['Radiobutton option two'] = Gui.new_radiobutton('test radiobutton option two')
:set_caption('Radiobutton Option Two')
:add_as_option(test_option_set,'Two')
:on_state_change(function(player,element)
player.print('Radiobutton option two: '..tostring(element.state))
:on_state_change(function(player,element,state)
player.print('Radiobutton option two: '..tostring(state))
end)
tests['Radiobutton option three'] = Gui.new_radiobutton('test radiobutton option three')
:set_caption('Radiobutton Option Three')
:add_as_option(test_option_set,'Three')
:on_state_change(function(player,element)
player.print('Radiobutton option three: '..tostring(element.state))
:on_state_change(function(player,element,state)
player.print('Radiobutton option three: '..tostring(state))
end)
tests['Dropdown local static general'] = Gui.new_dropdown('test dropdown local static general')
:set_tooltip('Dropdown Local Static General')
:add_options('One','Two','Three','Four')
:on_selection(function(player,element,value)
player.print('Dropdown local static general: '..tostring(value))
end)
tests['Dropdown player static general'] = Gui.new_dropdown('test dropdown player static general')
:set_tooltip('Dropdown Player Static General')
:add_options('One','Two','Three','Four')
:add_store(categozie_by_player)
:on_selection(function(player,element,value)
player.print('Dropdown player static general: '..tostring(value))
end)
local function print_option_selected_1(player,element,value)
player.print('Dropdown local static case (case): '..tostring(value))
end
tests['Dropdown local static case'] = Gui.new_dropdown('test dropdown local static case')
:set_tooltip('Dropdown Local Static Case')
:add_options('One','Two')
:add_option_callback('One',print_option_selected_1)
:add_option_callback('Two',print_option_selected_1)
:add_option_callback('Three',print_option_selected_1)
:add_option_callback('Four',print_option_selected_1)
:on_selection(function(player,element,value)
player.print('Dropdown local static case (general): '..tostring(value))
end)
local function print_option_selected_2(player,element,value)
player.print('Dropdown player static case (case): '..tostring(value))
end
tests['Dropdown player static case'] = Gui.new_dropdown('test dropdown player static case')
:set_tooltip('Dropdown Player Static Case')
:add_store(categozie_by_player)
:add_options('One','Two')
:add_option_callback('One',print_option_selected_2)
:add_option_callback('Two',print_option_selected_2)
:add_option_callback('Three',print_option_selected_2)
:add_option_callback('Four',print_option_selected_2)
:on_selection(function(player,element,value)
player.print('Dropdown player static case (general): '..tostring(value))
end)
tests['Dropdown local dynamic general'] = Gui.new_dropdown('test dropdown local dynamic general')
:set_tooltip('Dropdown Local Dynamic General')
:add_options('Static')
:add_dynamic(function(player,element)
return table_keys(Colors)
end)
:on_selection(function(player,element,value)
player.print('Dropdown local dynamic general: '..tostring(value))
end)
tests['Dropdown player dynamic general'] = Gui.new_dropdown('test dropdown player dynamic general')
:set_tooltip('Dropdown Player Dynamic General')
:add_options('Static')
:add_dynamic(function(player,element)
return table_keys(Colors)
end)
:add_store(categozie_by_player)
:on_selection(function(player,element,value)
player.print('Dropdown player dynamic general: '..tostring(value))
end)
tests['List box local static general'] = Gui.new_list_box('test list box local static general')
:set_tooltip('List Box Local Static General')
:add_options('One','Two','Three','Four')
:on_selection(function(player,element,value)
player.print('Dropdown local static general: '..tostring(value))
end)
tests['List box player static general'] = Gui.new_list_box('test list box player static general')
:set_tooltip('List Box Player Static General')
:add_options('One','Two','Three','Four')
:add_store(categozie_by_player)
:on_selection(function(player,element,value)
player.print('Dropdown player static general: '..tostring(value))
end)