From 71b0e16bd03ab4b9d73410c8b80141d79b36473d Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Sun, 1 Sep 2019 17:18:19 +0100 Subject: [PATCH] Added sliders --- docs/addons/Advanced-Start.html | 2 +- docs/addons/Chat-Popups.html | 2 +- docs/addons/Chat-Reply.html | 2 +- docs/addons/Compilatron.html | 2 +- docs/addons/Damage-Popups.html | 2 +- docs/addons/Death-Logger.html | 2 +- docs/addons/Discord-Alerts.html | 2 +- docs/addons/Player-Colours.html | 2 +- docs/addons/Pollution-Grading.html | 2 +- docs/addons/Scorched-Earth.html | 2 +- docs/addons/Spawn-Area.html | 2 +- docs/commands/Admin-Chat.html | 2 +- docs/commands/Bonus.html | 2 +- docs/commands/Cheat-Mode.html | 2 +- docs/commands/Clear-Inventory.html | 2 +- docs/commands/Debug.html | 2 +- docs/commands/Find.html | 2 +- docs/commands/Help.html | 2 +- docs/commands/Home.html | 2 +- docs/commands/Interface.html | 2 +- docs/commands/Jail.html | 2 +- docs/commands/Kill.html | 2 +- docs/commands/Me.html | 2 +- docs/commands/Rainbow.html | 2 +- docs/commands/Repair.html | 2 +- docs/commands/Reports.html | 2 +- docs/commands/Roles.html | 2 +- docs/commands/Spawn.html | 2 +- docs/commands/Tag.html | 2 +- docs/commands/Teleport.html | 2 +- docs/commands/Warnings.html | 2 +- docs/configs/Advanced-Start.html | 2 +- docs/configs/Bonuses.html | 2 +- docs/configs/Chat-Reply.html | 2 +- docs/configs/Commands-Auth-Admin.html | 2 +- docs/configs/Commands-Auth-Roles.html | 2 +- .../Commands-Auth-Runtime-Disable.html | 2 +- docs/configs/Commands-Parse-Roles.html | 2 +- docs/configs/Commands-Parse.html | 2 +- docs/configs/Compilatron.html | 2 +- docs/configs/Death-Logger.html | 2 +- docs/configs/Discord-Alerts.html | 2 +- docs/configs/File-Loader.html | 2 +- docs/configs/Permission-Groups.html | 2 +- docs/configs/Player-List.html | 2 +- docs/configs/Pollution-Grading.html | 2 +- docs/configs/Popup-Messages.html | 2 +- docs/configs/Preset-Player-Colours.html | 2 +- docs/configs/Repair.html | 2 +- docs/configs/Rockets.html | 2 +- docs/configs/Roles.html | 2 +- docs/configs/Science.html | 2 +- docs/configs/Scorched-Earth.html | 2 +- docs/configs/Spawn-Area.html | 2 +- docs/configs/Tasks.html | 2 +- docs/configs/Warnings.html | 2 +- docs/configs/Warps.html | 2 +- docs/control/Jail.html | 2 +- docs/control/Production.html | 2 +- docs/control/Reports.html | 2 +- docs/control/Rockets.html | 2 +- docs/control/Tasks.html | 2 +- docs/control/Warnings.html | 2 +- docs/control/Warps.html | 2 +- docs/core/Commands.html | 2 +- docs/core/Common-Library.html | 68 ++++++- docs/core/Gui.html | 174 ++++++++++++++++-- docs/core/Permissions-Groups.html | 2 +- docs/core/Roles.html | 2 +- docs/core/Store.html | 2 +- docs/core/Sudo.html | 2 +- docs/guis/Player-List.html | 2 +- docs/guis/Rocket-Info.html | 2 +- docs/guis/Science-Info.html | 2 +- docs/guis/Task-List.html | 2 +- docs/guis/Warps-List.html | 2 +- docs/index.html | 2 +- docs/modules/control.html | 2 +- .../utils.alien_evolution_progress.html | 2 +- docs/modules/utils.core.html | 2 +- docs/modules/utils.debug.html | 2 +- docs/modules/utils.dump_env.html | 2 +- docs/modules/utils.event.html | 2 +- docs/modules/utils.event_core.html | 2 +- docs/modules/utils.math.html | 2 +- docs/modules/utils.recipe_locker.html | 2 +- docs/modules/utils.state_machine.html | 2 +- docs/modules/utils.table.html | 2 +- docs/modules/utils.task.html | 2 +- docs/modules/utils.timestamp.html | 2 +- docs/topics/license.html | 2 +- docs/topics/readme.md.html | 2 +- expcore/common.lua | 18 ++ expcore/gui.lua | 1 + expcore/gui/concepts/checkbox.lua | 19 +- expcore/gui/concepts/dropdown.lua | 20 +- expcore/gui/concepts/elem_button.lua | 28 +-- expcore/gui/concepts/slider.lua | 75 ++++++++ expcore/gui/core.lua | 13 ++ expcore/gui/prototype.lua | 18 +- expcore/gui/test.lua | 96 ++++++++-- 101 files changed, 549 insertions(+), 161 deletions(-) create mode 100644 expcore/gui/concepts/slider.lua diff --git a/docs/addons/Advanced-Start.html b/docs/addons/Advanced-Start.html index fac87435..db08d972 100644 --- a/docs/addons/Advanced-Start.html +++ b/docs/addons/Advanced-Start.html @@ -348,7 +348,7 @@ generated by LDoc diff --git a/docs/addons/Chat-Popups.html b/docs/addons/Chat-Popups.html index fb1aed14..0dab0ebb 100644 --- a/docs/addons/Chat-Popups.html +++ b/docs/addons/Chat-Popups.html @@ -349,7 +349,7 @@ generated by LDoc diff --git a/docs/addons/Chat-Reply.html b/docs/addons/Chat-Reply.html index f67c7100..319b02b1 100644 --- a/docs/addons/Chat-Reply.html +++ b/docs/addons/Chat-Reply.html @@ -376,7 +376,7 @@ generated by LDoc diff --git a/docs/addons/Compilatron.html b/docs/addons/Compilatron.html index 1867f7c4..b91ba11d 100644 --- a/docs/addons/Compilatron.html +++ b/docs/addons/Compilatron.html @@ -585,7 +585,7 @@ generated by LDoc diff --git a/docs/addons/Damage-Popups.html b/docs/addons/Damage-Popups.html index 669a44a1..2fc16b82 100644 --- a/docs/addons/Damage-Popups.html +++ b/docs/addons/Damage-Popups.html @@ -349,7 +349,7 @@ generated by LDoc diff --git a/docs/addons/Death-Logger.html b/docs/addons/Death-Logger.html index a54f6e89..cd75a0ba 100644 --- a/docs/addons/Death-Logger.html +++ b/docs/addons/Death-Logger.html @@ -404,7 +404,7 @@ generated by LDoc diff --git a/docs/addons/Discord-Alerts.html b/docs/addons/Discord-Alerts.html index cdfd6557..2b7b0567 100644 --- a/docs/addons/Discord-Alerts.html +++ b/docs/addons/Discord-Alerts.html @@ -460,7 +460,7 @@ generated by LDoc diff --git a/docs/addons/Player-Colours.html b/docs/addons/Player-Colours.html index cbadfe62..d2bfde6a 100644 --- a/docs/addons/Player-Colours.html +++ b/docs/addons/Player-Colours.html @@ -404,7 +404,7 @@ generated by LDoc diff --git a/docs/addons/Pollution-Grading.html b/docs/addons/Pollution-Grading.html index 48e68d6e..e7098e3f 100644 --- a/docs/addons/Pollution-Grading.html +++ b/docs/addons/Pollution-Grading.html @@ -320,7 +320,7 @@ generated by LDoc diff --git a/docs/addons/Scorched-Earth.html b/docs/addons/Scorched-Earth.html index fea61aeb..e0ffa93c 100644 --- a/docs/addons/Scorched-Earth.html +++ b/docs/addons/Scorched-Earth.html @@ -404,7 +404,7 @@ generated by LDoc diff --git a/docs/addons/Spawn-Area.html b/docs/addons/Spawn-Area.html index cdc65900..bd36335a 100644 --- a/docs/addons/Spawn-Area.html +++ b/docs/addons/Spawn-Area.html @@ -376,7 +376,7 @@ generated by LDoc diff --git a/docs/commands/Admin-Chat.html b/docs/commands/Admin-Chat.html index 02095229..ab42bec5 100644 --- a/docs/commands/Admin-Chat.html +++ b/docs/commands/Admin-Chat.html @@ -388,7 +388,7 @@ generated by LDoc diff --git a/docs/commands/Bonus.html b/docs/commands/Bonus.html index 2c7f2f13..14323d1e 100644 --- a/docs/commands/Bonus.html +++ b/docs/commands/Bonus.html @@ -500,7 +500,7 @@ generated by LDoc diff --git a/docs/commands/Cheat-Mode.html b/docs/commands/Cheat-Mode.html index 5167e8a3..083b32fe 100644 --- a/docs/commands/Cheat-Mode.html +++ b/docs/commands/Cheat-Mode.html @@ -361,7 +361,7 @@ generated by LDoc diff --git a/docs/commands/Clear-Inventory.html b/docs/commands/Clear-Inventory.html index add5b72a..e5998899 100644 --- a/docs/commands/Clear-Inventory.html +++ b/docs/commands/Clear-Inventory.html @@ -388,7 +388,7 @@ generated by LDoc diff --git a/docs/commands/Debug.html b/docs/commands/Debug.html index aed6e1cd..290d58a9 100644 --- a/docs/commands/Debug.html +++ b/docs/commands/Debug.html @@ -365,7 +365,7 @@ generated by LDoc diff --git a/docs/commands/Find.html b/docs/commands/Find.html index 83f04b51..e466bfd8 100644 --- a/docs/commands/Find.html +++ b/docs/commands/Find.html @@ -360,7 +360,7 @@ generated by LDoc diff --git a/docs/commands/Help.html b/docs/commands/Help.html index 1ce2c9c7..f7e4975b 100644 --- a/docs/commands/Help.html +++ b/docs/commands/Help.html @@ -404,7 +404,7 @@ generated by LDoc diff --git a/docs/commands/Home.html b/docs/commands/Home.html index 620a6927..067a4076 100644 --- a/docs/commands/Home.html +++ b/docs/commands/Home.html @@ -458,7 +458,7 @@ generated by LDoc diff --git a/docs/commands/Interface.html b/docs/commands/Interface.html index a8be6f65..d280a73d 100644 --- a/docs/commands/Interface.html +++ b/docs/commands/Interface.html @@ -416,7 +416,7 @@ generated by LDoc diff --git a/docs/commands/Jail.html b/docs/commands/Jail.html index e7baa4a2..93a8b942 100644 --- a/docs/commands/Jail.html +++ b/docs/commands/Jail.html @@ -611,7 +611,7 @@ generated by LDoc diff --git a/docs/commands/Kill.html b/docs/commands/Kill.html index 01af9a7b..50690c73 100644 --- a/docs/commands/Kill.html +++ b/docs/commands/Kill.html @@ -389,7 +389,7 @@ generated by LDoc diff --git a/docs/commands/Me.html b/docs/commands/Me.html index a566461f..5b167987 100644 --- a/docs/commands/Me.html +++ b/docs/commands/Me.html @@ -360,7 +360,7 @@ generated by LDoc diff --git a/docs/commands/Rainbow.html b/docs/commands/Rainbow.html index 528dcb0a..ead5dc2e 100644 --- a/docs/commands/Rainbow.html +++ b/docs/commands/Rainbow.html @@ -388,7 +388,7 @@ generated by LDoc diff --git a/docs/commands/Repair.html b/docs/commands/Repair.html index 379eb796..f363411e 100644 --- a/docs/commands/Repair.html +++ b/docs/commands/Repair.html @@ -321,7 +321,7 @@ generated by LDoc diff --git a/docs/commands/Reports.html b/docs/commands/Reports.html index 823053bd..d234cfa7 100644 --- a/docs/commands/Reports.html +++ b/docs/commands/Reports.html @@ -585,7 +585,7 @@ generated by LDoc diff --git a/docs/commands/Roles.html b/docs/commands/Roles.html index f4b345cc..32d24195 100644 --- a/docs/commands/Roles.html +++ b/docs/commands/Roles.html @@ -557,7 +557,7 @@ generated by LDoc diff --git a/docs/commands/Spawn.html b/docs/commands/Spawn.html index fa096552..a88bdecf 100644 --- a/docs/commands/Spawn.html +++ b/docs/commands/Spawn.html @@ -389,7 +389,7 @@ generated by LDoc diff --git a/docs/commands/Tag.html b/docs/commands/Tag.html index 490b4d15..9438cddc 100644 --- a/docs/commands/Tag.html +++ b/docs/commands/Tag.html @@ -443,7 +443,7 @@ generated by LDoc diff --git a/docs/commands/Teleport.html b/docs/commands/Teleport.html index cbf8bca6..9478e557 100644 --- a/docs/commands/Teleport.html +++ b/docs/commands/Teleport.html @@ -484,7 +484,7 @@ generated by LDoc diff --git a/docs/commands/Warnings.html b/docs/commands/Warnings.html index 4cf981c7..2e0a0c76 100644 --- a/docs/commands/Warnings.html +++ b/docs/commands/Warnings.html @@ -569,7 +569,7 @@ generated by LDoc diff --git a/docs/configs/Advanced-Start.html b/docs/configs/Advanced-Start.html index 42e2964c..cbb5cc3d 100644 --- a/docs/configs/Advanced-Start.html +++ b/docs/configs/Advanced-Start.html @@ -506,7 +506,7 @@ generated by LDoc diff --git a/docs/configs/Bonuses.html b/docs/configs/Bonuses.html index 0537a1ae..eecdb55b 100644 --- a/docs/configs/Bonuses.html +++ b/docs/configs/Bonuses.html @@ -237,7 +237,7 @@ generated by LDoc diff --git a/docs/configs/Chat-Reply.html b/docs/configs/Chat-Reply.html index 78489463..77eac0c3 100644 --- a/docs/configs/Chat-Reply.html +++ b/docs/configs/Chat-Reply.html @@ -485,7 +485,7 @@ generated by LDoc diff --git a/docs/configs/Commands-Auth-Admin.html b/docs/configs/Commands-Auth-Admin.html index b5d967a2..f84fb637 100644 --- a/docs/configs/Commands-Auth-Admin.html +++ b/docs/configs/Commands-Auth-Admin.html @@ -294,7 +294,7 @@ generated by LDoc diff --git a/docs/configs/Commands-Auth-Roles.html b/docs/configs/Commands-Auth-Roles.html index e7b05121..dbe34891 100644 --- a/docs/configs/Commands-Auth-Roles.html +++ b/docs/configs/Commands-Auth-Roles.html @@ -320,7 +320,7 @@ generated by LDoc diff --git a/docs/configs/Commands-Auth-Runtime-Disable.html b/docs/configs/Commands-Auth-Runtime-Disable.html index 1efdf6ee..1531abfd 100644 --- a/docs/configs/Commands-Auth-Runtime-Disable.html +++ b/docs/configs/Commands-Auth-Runtime-Disable.html @@ -442,7 +442,7 @@ generated by LDoc diff --git a/docs/configs/Commands-Parse-Roles.html b/docs/configs/Commands-Parse-Roles.html index 9a3828fe..877f1556 100644 --- a/docs/configs/Commands-Parse-Roles.html +++ b/docs/configs/Commands-Parse-Roles.html @@ -354,7 +354,7 @@ generated by LDoc diff --git a/docs/configs/Commands-Parse.html b/docs/configs/Commands-Parse.html index 96d3023d..aedabc41 100644 --- a/docs/configs/Commands-Parse.html +++ b/docs/configs/Commands-Parse.html @@ -338,7 +338,7 @@ see ./expcore/commands.lua for more details

generated by LDoc diff --git a/docs/configs/Compilatron.html b/docs/configs/Compilatron.html index df1dfd7c..49196ffd 100644 --- a/docs/configs/Compilatron.html +++ b/docs/configs/Compilatron.html @@ -354,7 +354,7 @@ generated by LDoc diff --git a/docs/configs/Death-Logger.html b/docs/configs/Death-Logger.html index 05bd91dd..6696e94b 100644 --- a/docs/configs/Death-Logger.html +++ b/docs/configs/Death-Logger.html @@ -416,7 +416,7 @@ generated by LDoc diff --git a/docs/configs/Discord-Alerts.html b/docs/configs/Discord-Alerts.html index a917fb49..28f5b906 100644 --- a/docs/configs/Discord-Alerts.html +++ b/docs/configs/Discord-Alerts.html @@ -237,7 +237,7 @@ generated by LDoc diff --git a/docs/configs/File-Loader.html b/docs/configs/File-Loader.html index 63292dc1..1a46e4cf 100644 --- a/docs/configs/File-Loader.html +++ b/docs/configs/File-Loader.html @@ -240,7 +240,7 @@ generated by LDoc diff --git a/docs/configs/Permission-Groups.html b/docs/configs/Permission-Groups.html index 34f79892..22eb6228 100644 --- a/docs/configs/Permission-Groups.html +++ b/docs/configs/Permission-Groups.html @@ -295,7 +295,7 @@ generated by LDoc diff --git a/docs/configs/Player-List.html b/docs/configs/Player-List.html index 51bae4fd..cf496eff 100644 --- a/docs/configs/Player-List.html +++ b/docs/configs/Player-List.html @@ -812,7 +812,7 @@ generated by LDoc diff --git a/docs/configs/Pollution-Grading.html b/docs/configs/Pollution-Grading.html index 94422ee0..a82ddebe 100644 --- a/docs/configs/Pollution-Grading.html +++ b/docs/configs/Pollution-Grading.html @@ -384,7 +384,7 @@ generated by LDoc diff --git a/docs/configs/Popup-Messages.html b/docs/configs/Popup-Messages.html index 16b8eff8..659d3f76 100644 --- a/docs/configs/Popup-Messages.html +++ b/docs/configs/Popup-Messages.html @@ -414,7 +414,7 @@ generated by LDoc diff --git a/docs/configs/Preset-Player-Colours.html b/docs/configs/Preset-Player-Colours.html index b8ca80a1..5e487dad 100644 --- a/docs/configs/Preset-Player-Colours.html +++ b/docs/configs/Preset-Player-Colours.html @@ -324,7 +324,7 @@ generated by LDoc diff --git a/docs/configs/Repair.html b/docs/configs/Repair.html index d0bf54de..2fcc9ed7 100644 --- a/docs/configs/Repair.html +++ b/docs/configs/Repair.html @@ -414,7 +414,7 @@ generated by LDoc diff --git a/docs/configs/Rockets.html b/docs/configs/Rockets.html index 3bd16022..58b57990 100644 --- a/docs/configs/Rockets.html +++ b/docs/configs/Rockets.html @@ -834,7 +834,7 @@ generated by LDoc diff --git a/docs/configs/Roles.html b/docs/configs/Roles.html index 7c8665c8..55823fe3 100644 --- a/docs/configs/Roles.html +++ b/docs/configs/Roles.html @@ -292,7 +292,7 @@ generated by LDoc diff --git a/docs/configs/Science.html b/docs/configs/Science.html index 4a829958..1d26d319 100644 --- a/docs/configs/Science.html +++ b/docs/configs/Science.html @@ -354,7 +354,7 @@ generated by LDoc diff --git a/docs/configs/Scorched-Earth.html b/docs/configs/Scorched-Earth.html index 3ee50e94..424aec99 100644 --- a/docs/configs/Scorched-Earth.html +++ b/docs/configs/Scorched-Earth.html @@ -388,7 +388,7 @@ generated by LDoc diff --git a/docs/configs/Spawn-Area.html b/docs/configs/Spawn-Area.html index a320c897..5f2d3c3a 100644 --- a/docs/configs/Spawn-Area.html +++ b/docs/configs/Spawn-Area.html @@ -744,7 +744,7 @@ generated by LDoc diff --git a/docs/configs/Tasks.html b/docs/configs/Tasks.html index e3b6d034..a2e222bc 100644 --- a/docs/configs/Tasks.html +++ b/docs/configs/Tasks.html @@ -384,7 +384,7 @@ generated by LDoc diff --git a/docs/configs/Warnings.html b/docs/configs/Warnings.html index 2e3b3df7..a8ffe551 100644 --- a/docs/configs/Warnings.html +++ b/docs/configs/Warnings.html @@ -355,7 +355,7 @@ generated by LDoc diff --git a/docs/configs/Warps.html b/docs/configs/Warps.html index f32aafed..cb16c531 100644 --- a/docs/configs/Warps.html +++ b/docs/configs/Warps.html @@ -684,7 +684,7 @@ generated by LDoc diff --git a/docs/control/Jail.html b/docs/control/Jail.html index a5cfdf31..7af5c571 100644 --- a/docs/control/Jail.html +++ b/docs/control/Jail.html @@ -1208,7 +1208,7 @@ generated by LDoc diff --git a/docs/control/Production.html b/docs/control/Production.html index 07b51b32..def7e25c 100644 --- a/docs/control/Production.html +++ b/docs/control/Production.html @@ -1329,7 +1329,7 @@ generated by LDoc diff --git a/docs/control/Reports.html b/docs/control/Reports.html index 677291b4..822446ea 100644 --- a/docs/control/Reports.html +++ b/docs/control/Reports.html @@ -1110,7 +1110,7 @@ generated by LDoc diff --git a/docs/control/Rockets.html b/docs/control/Rockets.html index e765ea4d..f8ca492e 100644 --- a/docs/control/Rockets.html +++ b/docs/control/Rockets.html @@ -984,7 +984,7 @@ generated by LDoc diff --git a/docs/control/Tasks.html b/docs/control/Tasks.html index f7d7e25b..c9a71a5d 100644 --- a/docs/control/Tasks.html +++ b/docs/control/Tasks.html @@ -1039,7 +1039,7 @@ generated by LDoc diff --git a/docs/control/Warnings.html b/docs/control/Warnings.html index 9109db95..4b8ebd2d 100644 --- a/docs/control/Warnings.html +++ b/docs/control/Warnings.html @@ -1465,7 +1465,7 @@ generated by LDoc diff --git a/docs/control/Warps.html b/docs/control/Warps.html index e40b5944..f0a6938d 100644 --- a/docs/control/Warps.html +++ b/docs/control/Warps.html @@ -1413,7 +1413,7 @@ generated by LDoc diff --git a/docs/core/Commands.html b/docs/core/Commands.html index 552f913d..fb2c4ff5 100644 --- a/docs/core/Commands.html +++ b/docs/core/Commands.html @@ -1972,7 +1972,7 @@ generated by LDoc diff --git a/docs/core/Common-Library.html b/docs/core/Common-Library.html index fd82f345..1f26b637 100644 --- a/docs/core/Common-Library.html +++ b/docs/core/Common-Library.html @@ -369,6 +369,10 @@ table_insert(tbl[, start_index], tbl2) Much faster method for inserting keys into a table + + resolve_value(value) + Used to resolve a value that could also be a function returning that value + @@ -2664,6 +2668,68 @@ Common.array_insert(tbl,500,values) -- around 50,tbl2) + +
+
+
+ # + resolve_value(value) +
+
+
+
+ +

Used to resolve a value that could also be a function returning that value

+

+ + + Parameters: + +
    + + + + + +
  • + + value + + : + + (any) + + the value which you want to test is not nil and if it is a function then call the function + +
  • + + +
+ + + + + Returns: +
    +
  • + (any) + the value given or returned by value if it is a function +
  • +
+ + + + + + + + Usage: +
-- Default value handling
+-- if default value is not a function then it is returned
+-- if it is a function then it is called with the first argument being self
+local value = Common.resolve_value(self.defaut_value,self)
+ +
@@ -2680,7 +2746,7 @@ Common.table_insert(tbl,50,tbl2) generated by LDoc diff --git a/docs/core/Gui.html b/docs/core/Gui.html index 23c3bc23..55190867 100644 --- a/docs/core/Gui.html +++ b/docs/core/Gui.html @@ -344,6 +344,10 @@ button:clone('CustomButton') progress_bar The basic checkbox element + + slider + The basic slider element + @@ -777,7 +781,7 @@ Gui.clone_concept('button','spr
  • - on_state_change + on_state_changed : @@ -822,6 +826,22 @@ Gui.clone_concept('button','spr +
  • + + default + + : + + (boolean or function) + + the default state of this checkbox, or a function which returns the default state + +
  • + + + + +
  • use_radio @@ -853,7 +873,7 @@ Gui.clone_concept('button','spr Gui.clone_concept('checkbox','basic_checkbox') :set_caption('Basic Checkbox') :set_tooltip('Basic checkbox') -:on_state_change(function(event) +:on_state_changed(function(event) event.player.print('Basic checkbox is now: '..tostring(event.element.state)) end) @@ -883,7 +903,7 @@ Gui.clone_concept('checkbox','b
  • - on_selection_change + on_selection_changed : @@ -898,7 +918,7 @@ Gui.clone_concept('checkbox','b
  • - default_selection + default : @@ -974,7 +994,7 @@ Gui.clone_concept('checkbox','b local static_dropdown = Gui.clone_concept('dropdown','static_dropdown') :set_static_items{'Option 1','Option 2','Option 3'} -:on_selection_change(function(event) +:on_selection_changed(function(event) local value = Gui.get_dropdown_value(event.element) event.player.print('Static dropdown is now: '..value) end) @@ -988,7 +1008,7 @@ Gui.clone_concept('dropdown','d end return items end) -:on_selection_change(function(event) +:on_selection_changed(function(event) local value = Gui.get_dropdown_value(event.element) event.player.print('Dynamic dropdown is now: '..value) end) @@ -1019,7 +1039,7 @@ Gui.clone_concept('dropdown','d
  • - on_selection_change + on_selection_changed : @@ -1034,7 +1054,7 @@ Gui.clone_concept('dropdown','d
  • - default_selection + default : @@ -1077,7 +1097,7 @@ Gui.clone_concept('dropdown','d
    -- Making a basic elem button
     local basic_elem_button =
     Gui.clone_concept('elem_button','basic_elembutton')
    -:on_selection_change(function(event)
    +:on_selection_changed(function(event)
         event.player.print('Basic elem button is now: '..event.element.elem_value)
     end)
    @@ -1286,6 +1306,136 @@ Gui.clone_concept('progress_bar',end) + +
    +
    +
    + # + slider +
    +
    +
    +
    + +

    The basic slider element

    +

    + + + Properties / Events: + +
      + + + + + +
    • + + on_value_changed + + : + + + fired when the value of the slider is changed + +
    • + + + + + +
    • + + value_step + + : + + (number) + + the minimum amount by which the value of the slider can be changed + +
    • + + + + + +
    • + + default + + : + + (number or function) + + the default value of the slider or a function which returns the default value + +
    • + + + + + +
    • + + discrete_slider + + : + + (boolean) + + makes this slider a discrete slider (at time of writing unsure what this is) + +
    • + + + + + +
    • + + range + + : + + (number or function) + + accepts two params the minimum and the maximum for this slider, or a single function to return both + +
    • + + +
    + + + + + + + + + + + + Usage: +
    -- Making a basic slider
    +local basic_slider =
    +Gui.clone_concept('slider','basic_slider')
    +:set_range(1,10)
    +:on_value_changed(function(event)
    +    event.player.print('Basic slider is now: '..event.element.slider_value)
    +end)
    +
    -- Making a discrete_slider
    +local discrete_slider =
    +Gui.clone_concept('slider','discrete_slider')
    +:set_range(1,10)
    +:set_value_step(1)
    +:set_discrete_slider(true)
    +:on_value_changed(function(event)
    +    event.player.print('Interval slider is now: '..event.element.slider_value)
    +end)
    + +

    Dropdowns

    @@ -4285,12 +4435,12 @@ custom_button.update_data(1,fu Gui.get_concept('checkbox'):clone('my_checkbox') :set_caption('My Checkbox') :set_tooltip('Clicking this check box will change it for everyone') -:on_state_change(function(event) +:on_state_changed(function(event) local element = event.element event.concept.set_data(element,element.state) -- Update the stored data to trigger an update of all other instances end) :define_combined_store(function(element,state) -- We could add a category function here if we wanted to - element.state = state or false -- When you sync an instance this is what is called + element.state = state or false -- Note that the value passed may be nil if there is no stored value and no default set end) @@ -4440,7 +4590,7 @@ Gui.get_concept('CustomButton') generated by LDoc diff --git a/docs/core/Permissions-Groups.html b/docs/core/Permissions-Groups.html index 71ae873e..88c9d301 100644 --- a/docs/core/Permissions-Groups.html +++ b/docs/core/Permissions-Groups.html @@ -1432,7 +1432,7 @@ generated by LDoc diff --git a/docs/core/Roles.html b/docs/core/Roles.html index 86992767..939c59a1 100644 --- a/docs/core/Roles.html +++ b/docs/core/Roles.html @@ -3152,7 +3152,7 @@ generated by LDoc diff --git a/docs/core/Store.html b/docs/core/Store.html index 7efa78fb..e518d5a6 100644 --- a/docs/core/Store.html +++ b/docs/core/Store.html @@ -1145,7 +1145,7 @@ Store.register(team_scores,function(value,key) generated by LDoc diff --git a/docs/core/Sudo.html b/docs/core/Sudo.html index b05c3b4d..36b4a432 100644 --- a/docs/core/Sudo.html +++ b/docs/core/Sudo.html @@ -544,7 +544,7 @@ generated by LDoc diff --git a/docs/guis/Player-List.html b/docs/guis/Player-List.html index e12e78e5..6c70132d 100644 --- a/docs/guis/Player-List.html +++ b/docs/guis/Player-List.html @@ -626,7 +626,7 @@ generated by LDoc diff --git a/docs/guis/Rocket-Info.html b/docs/guis/Rocket-Info.html index 43160544..ab679073 100644 --- a/docs/guis/Rocket-Info.html +++ b/docs/guis/Rocket-Info.html @@ -629,7 +629,7 @@ generated by LDoc diff --git a/docs/guis/Science-Info.html b/docs/guis/Science-Info.html index 1a8c6e7c..c59424c9 100644 --- a/docs/guis/Science-Info.html +++ b/docs/guis/Science-Info.html @@ -449,7 +449,7 @@ generated by LDoc diff --git a/docs/guis/Task-List.html b/docs/guis/Task-List.html index 224ac51e..bb660351 100644 --- a/docs/guis/Task-List.html +++ b/docs/guis/Task-List.html @@ -632,7 +632,7 @@ generated by LDoc diff --git a/docs/guis/Warps-List.html b/docs/guis/Warps-List.html index 099c1978..66885bbe 100644 --- a/docs/guis/Warps-List.html +++ b/docs/guis/Warps-List.html @@ -837,7 +837,7 @@ generated by LDoc diff --git a/docs/index.html b/docs/index.html index 6a63a39c..7ed6c8dd 100644 --- a/docs/index.html +++ b/docs/index.html @@ -510,7 +510,7 @@ see ./expcore/commands.lua for more details generated by LDoc diff --git a/docs/modules/control.html b/docs/modules/control.html index e147afc2..5723e3d4 100644 --- a/docs/modules/control.html +++ b/docs/modules/control.html @@ -351,7 +351,7 @@ generated by LDoc diff --git a/docs/modules/utils.alien_evolution_progress.html b/docs/modules/utils.alien_evolution_progress.html index 6d93ca08..8de5f2be 100644 --- a/docs/modules/utils.alien_evolution_progress.html +++ b/docs/modules/utils.alien_evolution_progress.html @@ -419,7 +419,7 @@ fraction will decide a chance to spawn. 1 alien for 2 spawner's will have 50% on generated by LDoc diff --git a/docs/modules/utils.core.html b/docs/modules/utils.core.html index 702fd931..738a0e75 100644 --- a/docs/modules/utils.core.html +++ b/docs/modules/utils.core.html @@ -1164,7 +1164,7 @@ generated by LDoc diff --git a/docs/modules/utils.debug.html b/docs/modules/utils.debug.html index 56614959..c560bc9d 100644 --- a/docs/modules/utils.debug.html +++ b/docs/modules/utils.debug.html @@ -654,7 +654,7 @@ generated by LDoc diff --git a/docs/modules/utils.dump_env.html b/docs/modules/utils.dump_env.html index 4b36cbfc..74e7ec8a 100644 --- a/docs/modules/utils.dump_env.html +++ b/docs/modules/utils.dump_env.html @@ -323,7 +323,7 @@ generated by LDoc diff --git a/docs/modules/utils.event.html b/docs/modules/utils.event.html index 71a4e2ad..0f324e4b 100644 --- a/docs/modules/utils.event.html +++ b/docs/modules/utils.event.html @@ -1292,7 +1292,7 @@ generated by LDoc diff --git a/docs/modules/utils.event_core.html b/docs/modules/utils.event_core.html index 3eeb9117..c2a42b72 100644 --- a/docs/modules/utils.event_core.html +++ b/docs/modules/utils.event_core.html @@ -434,7 +434,7 @@ generated by LDoc diff --git a/docs/modules/utils.math.html b/docs/modules/utils.math.html index 69f8200f..b53b1a2c 100644 --- a/docs/modules/utils.math.html +++ b/docs/modules/utils.math.html @@ -338,7 +338,7 @@ generated by LDoc diff --git a/docs/modules/utils.recipe_locker.html b/docs/modules/utils.recipe_locker.html index bbc2686b..6ba6a2cc 100644 --- a/docs/modules/utils.recipe_locker.html +++ b/docs/modules/utils.recipe_locker.html @@ -441,7 +441,7 @@ generated by LDoc diff --git a/docs/modules/utils.state_machine.html b/docs/modules/utils.state_machine.html index 7a91a65a..a7c7ae1c 100644 --- a/docs/modules/utils.state_machine.html +++ b/docs/modules/utils.state_machine.html @@ -752,7 +752,7 @@ generated by LDoc diff --git a/docs/modules/utils.table.html b/docs/modules/utils.table.html index 5952d586..71fdfc28 100644 --- a/docs/modules/utils.table.html +++ b/docs/modules/utils.table.html @@ -1382,7 +1382,7 @@ generated by LDoc diff --git a/docs/modules/utils.task.html b/docs/modules/utils.task.html index 9f7f258d..c5a2596d 100644 --- a/docs/modules/utils.task.html +++ b/docs/modules/utils.task.html @@ -651,7 +651,7 @@ generated by LDoc diff --git a/docs/modules/utils.timestamp.html b/docs/modules/utils.timestamp.html index d0cb161c..2a54826a 100644 --- a/docs/modules/utils.timestamp.html +++ b/docs/modules/utils.timestamp.html @@ -442,7 +442,7 @@ generated by LDoc diff --git a/docs/topics/license.html b/docs/topics/license.html index 1c917750..927f857f 100644 --- a/docs/topics/license.html +++ b/docs/topics/license.html @@ -789,7 +789,7 @@ Public License instead of this License. But first, please read generated by LDoc diff --git a/docs/topics/readme.md.html b/docs/topics/readme.md.html index abe6555d..9ced810b 100644 --- a/docs/topics/readme.md.html +++ b/docs/topics/readme.md.html @@ -332,7 +332,7 @@ generated by LDoc diff --git a/expcore/common.lua b/expcore/common.lua index d465e4d8..81192344 100644 --- a/expcore/common.lua +++ b/expcore/common.lua @@ -682,4 +682,22 @@ function Common.table_insert(tbl,start_index,tbl2) return tbl end +--[[-- Used to resolve a value that could also be a function returning that value +@tparam any value the value which you want to test is not nil and if it is a function then call the function +@treturn any the value given or returned by value if it is a function +@usage-- Default value handling +-- if default value is not a function then it is returned +-- if it is a function then it is called with the first argument being self +local value = Common.resolve_value(self.defaut_value,self) +]] +function Common.resolve_value(value,...) + if value then + if type(value) == 'function' then + return value(...) + else + return value + end + end +end + return Common \ No newline at end of file diff --git a/expcore/gui.lua b/expcore/gui.lua index ae17446b..7f28c635 100644 --- a/expcore/gui.lua +++ b/expcore/gui.lua @@ -73,5 +73,6 @@ Gui.require_concept('checkbox') Gui.require_concept('dropdown') Gui.require_concept('elem_button') Gui.require_concept('progress_bar') +Gui.require_concept('slider') return Gui \ No newline at end of file diff --git a/expcore/gui/concepts/checkbox.lua b/expcore/gui/concepts/checkbox.lua index a9f43a1f..0de6befc 100644 --- a/expcore/gui/concepts/checkbox.lua +++ b/expcore/gui/concepts/checkbox.lua @@ -7,33 +7,42 @@ local Gui = require 'expcore.gui.core' --[[-- The basic checkbox element @element checkbox -@param on_state_change fired when the state of the element is changed +@param on_state_changed fired when the state of the element is changed @tparam ?string|Concepts.LocalisedString caption the message that is shown next to the checkbox @tparam ?string|Concepts.LocalisedString tooltip the tooltip that shows when a player hovers over the checkbox +@tparam ?boolean|function default the default state of this checkbox, or a function which returns the default state @tparam boolean use_radio setting to true will use radio buttons rather than checkboxs @usage-- Making a basic checkbox local basic_checkbox = Gui.clone_concept('checkbox','basic_checkbox') :set_caption('Basic Checkbox') :set_tooltip('Basic checkbox') -:on_state_change(function(event) +:on_state_changed(function(event) event.player.print('Basic checkbox is now: '..tostring(event.element.state)) end) ]] Gui.new_concept('checkbox') -:new_event('on_state_change',defines.events.on_gui_checked_state_changed) +:new_event('on_state_changed',defines.events.on_gui_checked_state_changed) :new_property('tooltip') :new_property('caption') -:new_property('default_state',false) +:new_property('default',false) :new_property('use_radio',false) :define_draw(function(properties,parent,element) + local default = properties.default + local state = type(default) == 'boolean' and default + element = parent.add{ name = properties.name, type = properties.use_radio and 'radiobutton' or 'checkbox', caption = properties.caption, tooltip = properties.tooltip, - state = properties.default_state + state = state } + default = Gui.resolve_property(default,element) + if default and default ~= state then + element.state = default + end + return element end) \ No newline at end of file diff --git a/expcore/gui/concepts/dropdown.lua b/expcore/gui/concepts/dropdown.lua index ee3f8346..c4e651df 100644 --- a/expcore/gui/concepts/dropdown.lua +++ b/expcore/gui/concepts/dropdown.lua @@ -8,8 +8,8 @@ local array_insert = ext_require('expcore.common','array_insert') --[[-- The basic dropdown element @element dropdown -@param on_selection_change fired when the selected value is changed -@tparam ?string|Concepts.LocalisedString|function default_selection the option which is selected by default, or a function which returns the default +@param on_selection_changed fired when the selected value is changed +@tparam ?string|Concepts.LocalisedString|function default the option which is selected by default, or a function which returns the default @tparam boolean use_list_box when true a list box will be used rather than a dropdown menu @tparam ?nil|table static_items when called with a table the values will be added as items for the dropdown, if called with nil then all items are cleared @tparam function dynamic_items the given function will be called to return a list of items and optional start index to add items to the dropdown when it is first drawn @@ -17,7 +17,7 @@ local array_insert = ext_require('expcore.common','array_insert') local static_dropdown = Gui.clone_concept('dropdown','static_dropdown') :set_static_items{'Option 1','Option 2','Option 3'} -:on_selection_change(function(event) +:on_selection_changed(function(event) local value = Gui.get_dropdown_value(event.element) event.player.print('Static dropdown is now: '..value) end) @@ -31,14 +31,14 @@ Gui.clone_concept('dropdown','dynamic_dropdown') end return items end) -:on_selection_change(function(event) +:on_selection_changed(function(event) local value = Gui.get_dropdown_value(event.element) event.player.print('Dynamic dropdown is now: '..value) end) ]] Gui.new_concept('dropdown') -:new_event('on_selection_change',defines.events.on_gui_selection_state_changed) -:new_property('default_selection') +:new_event('on_selection_changed',defines.events.on_gui_selection_state_changed) +:new_property('default') :new_property('use_list_box',false) :new_property('static_items',nil,function(properties,value,start_index) if not value then @@ -87,12 +87,8 @@ end) end end - if properties.default_selection then - local default = properties.default_selection - if type(default) == 'function' then - default = default(element) - end - + local default = Gui.resolve_property(properties.default,element) + if default then Gui.set_dropdown_value(element,default) end diff --git a/expcore/gui/concepts/elem_button.lua b/expcore/gui/concepts/elem_button.lua index cbbd0753..6b51fbf1 100644 --- a/expcore/gui/concepts/elem_button.lua +++ b/expcore/gui/concepts/elem_button.lua @@ -7,42 +7,30 @@ local Gui = require 'expcore.gui.core' --[[-- The basic dropdown element @element elem_button -@param on_selection_change fired when the selected value is changed -@tparam ?string|Concepts.SignalID|function default_selection the option which is selected by default, or a function which returns the default +@param on_selection_changed fired when the selected value is changed +@tparam ?string|Concepts.SignalID|function default the option which is selected by default, or a function which returns the default @tparam string elem_type the type of elem selection that this is, default is item selection @usage-- Making a basic elem button local basic_elem_button = Gui.clone_concept('elem_button','basic_elembutton') -:on_selection_change(function(event) +:on_selection_changed(function(event) event.player.print('Basic elem button is now: '..event.element.elem_value) end) ]] Gui.new_concept('elem_button') -:new_event('on_selection_change',defines.events.on_gui_elem_changed) -:new_property('default_selection') +:new_event('on_selection_changed',defines.events.on_gui_elem_changed) +:new_property('default') :new_property('elem_type','item') -:define_draw(function(properties,parent,element,selection) +:define_draw(function(properties,parent,element) element = parent.add{ name = properties.name, type = 'choose-elem-button', elem_type = properties.elem_type } - if properties.default_selection and not selection then - local default = properties.default_selection - if type(default) == 'function' then - default = default(element) - end - + local default = Gui.resolve_property(properties.default,element) + if default then element.elem_value = default - - elseif selection then - if type(selection) == 'function' then - selection = selection(element) - end - - element.elem_value = selection - end return element diff --git a/expcore/gui/concepts/slider.lua b/expcore/gui/concepts/slider.lua new file mode 100644 index 00000000..b58792d3 --- /dev/null +++ b/expcore/gui/concepts/slider.lua @@ -0,0 +1,75 @@ +--[[-- Core Module - Gui + @module Gui + @alias Gui +]] + +local Gui = require 'expcore.gui.core' + +--[[-- The basic slider element +@element slider +@param on_value_changed fired when the value of the slider is changed +@tparam number value_step the minimum amount by which the value of the slider can be changed +@tparam ?number|function default the default value of the slider or a function which returns the default value +@tparam boolean discrete_slider makes this slider a discrete slider (at time of writing unsure what this is) +@tparam ?number|function range accepts two params the minimum and the maximum for this slider, or a single function to return both +@usage-- Making a basic slider +local basic_slider = +Gui.clone_concept('slider','basic_slider') +:set_range(1,10) +:on_value_changed(function(event) + event.player.print('Basic slider is now: '..event.element.slider_value) +end) +@usage-- Making a discrete_slider +local discrete_slider = +Gui.clone_concept('slider','discrete_slider') +:set_range(1,10) +:set_value_step(1) +:set_discrete_slider(true) +:on_value_changed(function(event) + event.player.print('Interval slider is now: '..event.element.slider_value) +end) +]] +Gui.new_concept('slider') +:new_event('on_value_changed',defines.events.on_gui_value_changed) +:new_property('value_step') +:new_property('default') +:new_property('discrete_slider',false) +:new_property('range',nil,function(properties,minimum,maximum) + if type(minimum) == 'function' then + properties.range = minimum + else + properties.minimum = minimum + properties.maximum = maximum + end +end) +:define_draw(function(properties,parent,element) + local default = properties.default + local value = type(default) == 'number' and default + local value_step = properties.value_step + + element = parent.add{ + name = properties.name, + type = 'slider', + caption = properties.caption, + minimum_value = properties.minimum, + maximum_value = properties.maximum, + discrete_slider = properties.discrete_slider, + discrete_values = value_step ~= nil, + value_step = value_step, + value = value + } + + local min, max = Gui.resolve_property(properties.range,element) + if min or max then + min = min or element.get_slider_minimum() + max = max or element.get_slider_maximum() + element.set_slider_minimum_maximum(min,max) + end + + default = Gui.resolve_property(default,element) + if default and default ~= value then + element.slider_value = default + end + + return element +end) \ No newline at end of file diff --git a/expcore/gui/core.lua b/expcore/gui/core.lua index 6329550f..08bec3d2 100644 --- a/expcore/gui/core.lua +++ b/expcore/gui/core.lua @@ -4,6 +4,7 @@ ]] local Game = require 'utils.game' -- @dep utils.game +local resolve_value = ext_require('expcore.common','resolve_value') -- @dep expcore.common local Prototype = require 'expcore.gui.prototype' local Gui = { @@ -186,6 +187,18 @@ function Gui.set_padding(element,up,down,left,right) style.right_padding = right == true and style.top_padding or right or 0 end +--[[ Used to check a property exists and if it is a function then call the function +@tparam any value the value that you are testing exists and call if its a function +@tparam LuaGuiElement element the element that is passed to the function if it is a function +@treturn any the value or what it returns if it is a function +@usage-- Getting the default value +local default = Gui.resolve_property(properties.default,element) +if default then + element.value = default +end +]] +Gui.resolve_property = resolve_value + --- Store Categories. -- Functions that are common types of categories -- @section store-categories diff --git a/expcore/gui/prototype.lua b/expcore/gui/prototype.lua index 2f08e255..5fb2629e 100644 --- a/expcore/gui/prototype.lua +++ b/expcore/gui/prototype.lua @@ -517,12 +517,13 @@ end) for key,instance in pairs(instances) do if not instance or not instance.valid then instances[key] = nil - end - if args then - update_callback(instance,unpack(args)) else - update_callback(instance,...) + if args then + update_callback(instance,unpack(args)) + else + update_callback(instance,...) + end end end end @@ -647,12 +648,12 @@ local custom_button = Gui.get_concept('checkbox'):clone('my_checkbox') :set_caption('My Checkbox') :set_tooltip('Clicking this check box will change it for everyone') -:on_state_change(function(event) +:on_state_changed(function(event) local element = event.element event.concept.set_data(element,element.state) -- Update the stored data to trigger an update of all other instances end) :define_combined_store(function(element,state) -- We could add a category function here if we wanted to - element.state = state or false -- When you sync an instance this is what is called + element.state = state or false -- Note that the value passed may be nil if there is no stored value and no default set end) ]] function Prototype:define_combined_store(category_callback,sync_callback) @@ -679,8 +680,11 @@ Gui.get_concept('CustomButton') -- Used internally when first draw and automatically when the store updates custom_button.sync_instance(element) ]] + local properties = self.properties function self.sync_instance(element) - sync_callback(element,self.get_data(element)) + local default = properties.default + local value = self.get_data(element) or type(default) == 'function' and default(element) or default + sync_callback(element,value) end return self diff --git a/expcore/gui/test.lua b/expcore/gui/test.lua index f28b4e93..f6d74988 100644 --- a/expcore/gui/test.lua +++ b/expcore/gui/test.lua @@ -157,7 +157,7 @@ local basic_checkbox = Gui.clone_concept('checkbox',TEST 'basic_checkbox') :set_caption('Basic Checkbox') :set_tooltip('Basic checkbox') -:on_state_change(function(event) +:on_state_changed(function(event) event.player.print('Basic checkbox is now: '..tostring(event.element.state)) end) @@ -165,7 +165,7 @@ local game_checkbox = Gui.clone_concept('checkbox',TEST 'game_checkbox') :set_caption('Game Stored Checkbox') :set_tooltip('Game stored checkbox') -:on_state_change(function(event) +:on_state_changed(function(event) local element = event.element event.concept.set_data(element,element.state) -- Update other instances event.player.print('Game stored checkbox is now: '..tostring(element.state)) @@ -178,7 +178,7 @@ local force_checkbox = Gui.clone_concept('checkbox',TEST 'force_checkbox') :set_caption('Force Stored Checkbox') :set_tooltip('Force stored checkbox') -:on_state_change(function(event) +:on_state_changed(function(event) local element = event.element event.concept.set_data(element,element.state) -- Update other instances event.player.print('Force stored checkbox is now: '..tostring(element.state)) @@ -191,7 +191,7 @@ local player_checkbox = Gui.clone_concept('checkbox',TEST 'player_checkbox') :set_caption('Player Stored Checkbox') :set_tooltip('Player stored checkbox') -:on_state_change(function(event) +:on_state_changed(function(event) local element = event.element event.concept.set_data(element,element.state) -- Update other instances event.player.print('Player stored checkbox is now: '..tostring(element.state)) @@ -218,7 +218,7 @@ Dropdowns local static_dropdown = Gui.clone_concept('dropdown',TEST 'static_dropdown') :set_static_items{'Option 1','Option 2','Option 3'} -:on_selection_change(function(event) +:on_selection_changed(function(event) local value = Gui.get_dropdown_value(event.element) event.player.print('Static dropdown is now: '..value) end) @@ -234,7 +234,7 @@ Gui.clone_concept('dropdown',TEST 'dynamic_dropdown') end return items end) -:on_selection_change(function(event) +:on_selection_changed(function(event) local value = Gui.get_dropdown_value(event.element) event.player.print('Dynamic dropdown is now: '..value) end) @@ -242,7 +242,7 @@ end) local static_player_dropdown = Gui.clone_concept('dropdown',TEST 'static_player_dropdown') :set_static_items{'Option 1','Option 2','Option 3'} -:on_selection_change(function(event) +:on_selection_changed(function(event) local element = event.element local value = Gui.get_dropdown_value(element) event.concept.set_data(element,value) @@ -263,7 +263,7 @@ Gui.clone_concept('dropdown',TEST 'dynamic_player_dropdown') end return items end) -:on_selection_change(function(event) +:on_selection_changed(function(event) local element = event.element local value = Gui.get_dropdown_value(element) event.concept.set_data(element,value) @@ -290,7 +290,7 @@ local static_listbox = Gui.clone_concept('dropdown',TEST 'static_listbox') :set_use_list_box(true) :set_static_items{'Option 1','Option 2','Option 3'} -:on_selection_change(function(event) +:on_selection_changed(function(event) local value = Gui.get_dropdown_value(event.element) event.player.print('Static listbox is now: '..value) end) @@ -299,7 +299,7 @@ local static_player_listbox = Gui.clone_concept('dropdown',TEST 'static_player_listbox') :set_use_list_box(true) :set_static_items{'Option 1','Option 2','Option 3'} -:on_selection_change(function(event) +:on_selection_changed(function(event) local element = event.element local value = Gui.get_dropdown_value(element) event.concept.set_data(element,value) @@ -323,15 +323,15 @@ Elem Buttons local basic_elem_button = Gui.clone_concept('elem_button',TEST 'basic_elembutton') -:on_selection_change(function(event) +:on_selection_changed(function(event) event.player.print('Basic elem button is now: '..event.element.elem_value) end) local default_selection_elem_button = Gui.clone_concept('elem_button',TEST 'default_selection_elem_button') :set_elem_type('signal') -:set_default_selection{type='virtual',name='signal-info'} -:on_selection_change(function(event) +:set_default{type='virtual',name='signal-info'} +:on_selection_changed(function(event) local value = event.element.elem_value event.player.print('Default selection elem button is now: '..value.type..'/'..value.name) end) @@ -339,7 +339,7 @@ end) local player_elem_button = Gui.clone_concept('elem_button',TEST 'player_elem_button') :set_elem_type('technology') -:on_selection_change(function(event) +:on_selection_changed(function(event) local element = event.element local value = element.elem_value event.concept.set_data(element,value) @@ -446,4 +446,72 @@ tests['Progress Bars'] = { ['Game Instance Progress Bar'] = game_progress_bar, ['Force Instance Progress Bar'] = force_instance_progress_bar, ['Force Stored Progress Bar'] = force_stored_progress_bar +} + +--[[ +Sliders +> Basic Slider -- Just a basic slider with range 1 to 10 +> Interval Slider -- Same as above but can only be intergers +> Discrete Slider -- A discrete slider +> Dynamic Slider -- A slider which has a dynamic range +> Player Stored Slider -- Slider which stores the value per player, also goes 1 to 10 +]] + +local basic_slider = +Gui.clone_concept('slider',TEST 'basic_slider') +:set_range(1,10) +:on_value_changed(function(event) + event.player.print('Basic slider is now: '..event.element.slider_value) +end) + +local interval_slider = +Gui.clone_concept('slider',TEST 'interval_slider') +:set_range(1,10) +:set_value_step(1) +:on_value_changed(function(event) + event.player.print('Interval slider is now: '..event.element.slider_value) +end) + +local discrete_slider = +Gui.clone_concept('slider',TEST 'discrete_slider') +:set_range(1,10) +:set_value_step(1) +:set_discrete_slider(true) +:on_value_changed(function(event) + event.player.print('Discrete slider is now: '..event.element.slider_value) +end) + +local dynamic_slider = +Gui.clone_concept('slider',TEST 'dynamic_slider') +:set_range(function(element) + local player = Gui.get_player_from_element(element) + return 1, player.name:len() +end) +:set_value_step(1) +:set_discrete_slider(true) +:on_value_changed(function(event) + event.player.print('Dynamic slider is now: '..event.element.slider_value) +end) + +local player_slider = +Gui.clone_concept('slider',TEST 'player_slider') +:set_range(1,10) +:set_value_step(1) +:set_discrete_slider(true) +:on_value_changed(function(event) + local element = event.element + local value = element.slider_value + event.concept.set_data(element,value) + event.player.print('Player stored slider is now: '..value) +end) +:define_combined_store(Gui.categorize_by_player,function(element,value) + element.slider_value = value or 0 +end) + +tests.Sliders = { + ['Basic Slider'] = basic_slider, + ['Interval Slider'] = interval_slider, + ['Discrete Slider'] = discrete_slider, + ['Dynamic Slider'] = dynamic_slider, + ['Player Stored Slider'] = player_slider } \ No newline at end of file