From 06e6ccd60bb8206bb0f456d598cf6a4d5b638dc4 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Fri, 6 Sep 2019 21:13:00 +0100 Subject: [PATCH] Added toolbar --- docs/addons/Advanced-Start.html | 3 +- docs/addons/Chat-Popups.html | 3 +- docs/addons/Chat-Reply.html | 3 +- docs/addons/Compilatron.html | 3 +- docs/addons/Damage-Popups.html | 3 +- docs/addons/Death-Logger.html | 3 +- docs/addons/Discord-Alerts.html | 3 +- docs/addons/Player-Colours.html | 3 +- docs/addons/Pollution-Grading.html | 3 +- docs/addons/Scorched-Earth.html | 3 +- docs/addons/Spawn-Area.html | 3 +- docs/commands/Admin-Chat.html | 3 +- docs/commands/Bonus.html | 3 +- docs/commands/Cheat-Mode.html | 3 +- docs/commands/Clear-Inventory.html | 3 +- docs/commands/Debug.html | 3 +- docs/commands/Find.html | 3 +- docs/commands/Help.html | 3 +- docs/commands/Home.html | 3 +- docs/commands/Interface.html | 3 +- docs/commands/Jail.html | 3 +- docs/commands/Kill.html | 3 +- docs/commands/Me.html | 3 +- docs/commands/Rainbow.html | 3 +- docs/commands/Repair.html | 3 +- docs/commands/Reports.html | 3 +- docs/commands/Roles.html | 3 +- docs/commands/Spawn.html | 3 +- docs/commands/Tag.html | 3 +- docs/commands/Teleport.html | 3 +- docs/commands/Warnings.html | 3 +- docs/configs/Advanced-Start.html | 3 +- docs/configs/Bonuses.html | 3 +- docs/configs/Chat-Reply.html | 3 +- docs/configs/Commands-Auth-Admin.html | 3 +- docs/configs/Commands-Auth-Roles.html | 3 +- .../Commands-Auth-Runtime-Disable.html | 3 +- docs/configs/Commands-Parse-Roles.html | 3 +- docs/configs/Commands-Parse.html | 3 +- docs/configs/Compilatron.html | 3 +- docs/configs/Death-Logger.html | 3 +- docs/configs/Discord-Alerts.html | 3 +- docs/configs/File-Loader.html | 3 +- docs/configs/Permission-Groups.html | 3 +- docs/configs/Player-List.html | 3 +- docs/configs/Pollution-Grading.html | 3 +- docs/configs/Popup-Messages.html | 3 +- docs/configs/Preset-Player-Colours.html | 3 +- docs/configs/Repair.html | 3 +- docs/configs/Rockets.html | 3 +- docs/configs/Roles.html | 3 +- docs/configs/Science.html | 3 +- docs/configs/Scorched-Earth.html | 3 +- docs/configs/Spawn-Area.html | 3 +- docs/configs/Tasks.html | 3 +- docs/configs/Warnings.html | 3 +- docs/configs/Warps.html | 3 +- docs/control/Jail.html | 3 +- docs/control/Production.html | 3 +- docs/control/Reports.html | 3 +- docs/control/Rockets.html | 3 +- docs/control/Tasks.html | 3 +- docs/control/Warnings.html | 3 +- docs/control/Warps.html | 3 +- docs/core/Commands.html | 3 +- docs/core/Common-Library.html | 3 +- docs/core/Gui.html | 72 +- docs/core/Permissions-Groups.html | 3 +- docs/core/Roles.html | 3 +- docs/core/Store.html | 3 +- docs/core/Sudo.html | 3 +- docs/core/Toolbar.html | 1638 +++++++++++++++++ docs/guis/Player-List.html | 3 +- docs/guis/Rocket-Info.html | 3 +- docs/guis/Science-Info.html | 3 +- docs/guis/Task-List.html | 3 +- docs/guis/Warps-List.html | 3 +- docs/index.html | 6 +- docs/modules/control.html | 3 +- .../utils.alien_evolution_progress.html | 3 +- docs/modules/utils.core.html | 3 +- docs/modules/utils.debug.html | 3 +- docs/modules/utils.dump_env.html | 3 +- docs/modules/utils.event.html | 3 +- docs/modules/utils.event_core.html | 3 +- docs/modules/utils.math.html | 3 +- docs/modules/utils.recipe_locker.html | 3 +- docs/modules/utils.state_machine.html | 3 +- docs/modules/utils.table.html | 3 +- docs/modules/utils.task.html | 3 +- docs/modules/utils.timestamp.html | 3 +- docs/topics/license.html | 3 +- docs/topics/readme.md.html | 3 +- expcore/gui/concepts/button.lua | 14 +- expcore/gui/core.lua | 1 + expcore/gui/prototype.lua | 38 +- expcore/gui/test.lua | 57 +- expcore/toolbar.lua | 469 +++++ utils/event_core.lua | 2 +- 99 files changed, 2463 insertions(+), 104 deletions(-) create mode 100644 docs/core/Toolbar.html create mode 100644 expcore/toolbar.lua diff --git a/docs/addons/Advanced-Start.html b/docs/addons/Advanced-Start.html index 31d501d2..355bc495 100644 --- a/docs/addons/Advanced-Start.html +++ b/docs/addons/Advanced-Start.html @@ -74,6 +74,7 @@ + @@ -348,7 +349,7 @@ generated by LDoc diff --git a/docs/addons/Chat-Popups.html b/docs/addons/Chat-Popups.html index 0b71ec19..6a9a5437 100644 --- a/docs/addons/Chat-Popups.html +++ b/docs/addons/Chat-Popups.html @@ -74,6 +74,7 @@ + @@ -349,7 +350,7 @@ generated by LDoc diff --git a/docs/addons/Chat-Reply.html b/docs/addons/Chat-Reply.html index 0f83ae72..ba20d5c1 100644 --- a/docs/addons/Chat-Reply.html +++ b/docs/addons/Chat-Reply.html @@ -74,6 +74,7 @@ + @@ -376,7 +377,7 @@ generated by LDoc diff --git a/docs/addons/Compilatron.html b/docs/addons/Compilatron.html index 6340ad99..c9aa9a5a 100644 --- a/docs/addons/Compilatron.html +++ b/docs/addons/Compilatron.html @@ -75,6 +75,7 @@ + @@ -585,7 +586,7 @@ generated by LDoc diff --git a/docs/addons/Damage-Popups.html b/docs/addons/Damage-Popups.html index cf61c396..9768b669 100644 --- a/docs/addons/Damage-Popups.html +++ b/docs/addons/Damage-Popups.html @@ -74,6 +74,7 @@ + @@ -349,7 +350,7 @@ generated by LDoc diff --git a/docs/addons/Death-Logger.html b/docs/addons/Death-Logger.html index 58ecdcf1..781142d9 100644 --- a/docs/addons/Death-Logger.html +++ b/docs/addons/Death-Logger.html @@ -74,6 +74,7 @@ + @@ -404,7 +405,7 @@ generated by LDoc diff --git a/docs/addons/Discord-Alerts.html b/docs/addons/Discord-Alerts.html index 62e674db..7a218c04 100644 --- a/docs/addons/Discord-Alerts.html +++ b/docs/addons/Discord-Alerts.html @@ -74,6 +74,7 @@ + @@ -460,7 +461,7 @@ generated by LDoc diff --git a/docs/addons/Player-Colours.html b/docs/addons/Player-Colours.html index 9fdcc3ea..6ef982b9 100644 --- a/docs/addons/Player-Colours.html +++ b/docs/addons/Player-Colours.html @@ -74,6 +74,7 @@ + @@ -404,7 +405,7 @@ generated by LDoc diff --git a/docs/addons/Pollution-Grading.html b/docs/addons/Pollution-Grading.html index 05cfe35c..46544811 100644 --- a/docs/addons/Pollution-Grading.html +++ b/docs/addons/Pollution-Grading.html @@ -74,6 +74,7 @@ + @@ -320,7 +321,7 @@ generated by LDoc diff --git a/docs/addons/Scorched-Earth.html b/docs/addons/Scorched-Earth.html index 13a983b4..88da4c0a 100644 --- a/docs/addons/Scorched-Earth.html +++ b/docs/addons/Scorched-Earth.html @@ -74,6 +74,7 @@ + @@ -404,7 +405,7 @@ generated by LDoc diff --git a/docs/addons/Spawn-Area.html b/docs/addons/Spawn-Area.html index 6a4b845e..2faa81dc 100644 --- a/docs/addons/Spawn-Area.html +++ b/docs/addons/Spawn-Area.html @@ -74,6 +74,7 @@ + @@ -376,7 +377,7 @@ generated by LDoc diff --git a/docs/commands/Admin-Chat.html b/docs/commands/Admin-Chat.html index 0dac6823..54195af8 100644 --- a/docs/commands/Admin-Chat.html +++ b/docs/commands/Admin-Chat.html @@ -84,6 +84,7 @@ + @@ -388,7 +389,7 @@ generated by LDoc diff --git a/docs/commands/Bonus.html b/docs/commands/Bonus.html index e208eee3..450e04f6 100644 --- a/docs/commands/Bonus.html +++ b/docs/commands/Bonus.html @@ -84,6 +84,7 @@ + @@ -500,7 +501,7 @@ generated by LDoc diff --git a/docs/commands/Cheat-Mode.html b/docs/commands/Cheat-Mode.html index 10c20a38..7a662f0a 100644 --- a/docs/commands/Cheat-Mode.html +++ b/docs/commands/Cheat-Mode.html @@ -84,6 +84,7 @@ + @@ -361,7 +362,7 @@ generated by LDoc diff --git a/docs/commands/Clear-Inventory.html b/docs/commands/Clear-Inventory.html index 6cf02737..62f59464 100644 --- a/docs/commands/Clear-Inventory.html +++ b/docs/commands/Clear-Inventory.html @@ -84,6 +84,7 @@ + @@ -388,7 +389,7 @@ generated by LDoc diff --git a/docs/commands/Debug.html b/docs/commands/Debug.html index 5f227660..74239e71 100644 --- a/docs/commands/Debug.html +++ b/docs/commands/Debug.html @@ -84,6 +84,7 @@ + @@ -365,7 +366,7 @@ generated by LDoc diff --git a/docs/commands/Find.html b/docs/commands/Find.html index 9cfff9a3..84387d0a 100644 --- a/docs/commands/Find.html +++ b/docs/commands/Find.html @@ -84,6 +84,7 @@ + @@ -360,7 +361,7 @@ generated by LDoc diff --git a/docs/commands/Help.html b/docs/commands/Help.html index 31462e7e..21b3aeaa 100644 --- a/docs/commands/Help.html +++ b/docs/commands/Help.html @@ -84,6 +84,7 @@ + @@ -404,7 +405,7 @@ generated by LDoc diff --git a/docs/commands/Home.html b/docs/commands/Home.html index e1982d23..d8637e6f 100644 --- a/docs/commands/Home.html +++ b/docs/commands/Home.html @@ -84,6 +84,7 @@ + @@ -458,7 +459,7 @@ generated by LDoc diff --git a/docs/commands/Interface.html b/docs/commands/Interface.html index 524a642d..224c35ee 100644 --- a/docs/commands/Interface.html +++ b/docs/commands/Interface.html @@ -84,6 +84,7 @@ + @@ -416,7 +417,7 @@ generated by LDoc diff --git a/docs/commands/Jail.html b/docs/commands/Jail.html index f2dd5d21..432028b8 100644 --- a/docs/commands/Jail.html +++ b/docs/commands/Jail.html @@ -84,6 +84,7 @@ + @@ -611,7 +612,7 @@ generated by LDoc diff --git a/docs/commands/Kill.html b/docs/commands/Kill.html index 75caf805..1d35117f 100644 --- a/docs/commands/Kill.html +++ b/docs/commands/Kill.html @@ -84,6 +84,7 @@ + @@ -389,7 +390,7 @@ generated by LDoc diff --git a/docs/commands/Me.html b/docs/commands/Me.html index 254bda70..aebe8ab4 100644 --- a/docs/commands/Me.html +++ b/docs/commands/Me.html @@ -84,6 +84,7 @@ + @@ -360,7 +361,7 @@ generated by LDoc diff --git a/docs/commands/Rainbow.html b/docs/commands/Rainbow.html index cbd8265f..37baf73b 100644 --- a/docs/commands/Rainbow.html +++ b/docs/commands/Rainbow.html @@ -84,6 +84,7 @@ + @@ -388,7 +389,7 @@ generated by LDoc diff --git a/docs/commands/Repair.html b/docs/commands/Repair.html index 8d24324b..8b302752 100644 --- a/docs/commands/Repair.html +++ b/docs/commands/Repair.html @@ -83,6 +83,7 @@ + @@ -321,7 +322,7 @@ generated by LDoc diff --git a/docs/commands/Reports.html b/docs/commands/Reports.html index e5a9c808..dc80bff6 100644 --- a/docs/commands/Reports.html +++ b/docs/commands/Reports.html @@ -84,6 +84,7 @@ + @@ -585,7 +586,7 @@ generated by LDoc diff --git a/docs/commands/Roles.html b/docs/commands/Roles.html index d49d1007..da4ffc81 100644 --- a/docs/commands/Roles.html +++ b/docs/commands/Roles.html @@ -84,6 +84,7 @@ + @@ -557,7 +558,7 @@ generated by LDoc diff --git a/docs/commands/Spawn.html b/docs/commands/Spawn.html index f1204717..738a91ee 100644 --- a/docs/commands/Spawn.html +++ b/docs/commands/Spawn.html @@ -84,6 +84,7 @@ + @@ -389,7 +390,7 @@ generated by LDoc diff --git a/docs/commands/Tag.html b/docs/commands/Tag.html index d9c0085b..eb224a4e 100644 --- a/docs/commands/Tag.html +++ b/docs/commands/Tag.html @@ -84,6 +84,7 @@ + @@ -443,7 +444,7 @@ generated by LDoc diff --git a/docs/commands/Teleport.html b/docs/commands/Teleport.html index 51598a49..0641f54e 100644 --- a/docs/commands/Teleport.html +++ b/docs/commands/Teleport.html @@ -84,6 +84,7 @@ + @@ -484,7 +485,7 @@ generated by LDoc diff --git a/docs/commands/Warnings.html b/docs/commands/Warnings.html index d9581ee8..33a5203a 100644 --- a/docs/commands/Warnings.html +++ b/docs/commands/Warnings.html @@ -84,6 +84,7 @@ + @@ -569,7 +570,7 @@ generated by LDoc diff --git a/docs/configs/Advanced-Start.html b/docs/configs/Advanced-Start.html index af6026bb..054b7703 100644 --- a/docs/configs/Advanced-Start.html +++ b/docs/configs/Advanced-Start.html @@ -89,6 +89,7 @@ + @@ -506,7 +507,7 @@ generated by LDoc diff --git a/docs/configs/Bonuses.html b/docs/configs/Bonuses.html index 5c009894..a11c7015 100644 --- a/docs/configs/Bonuses.html +++ b/docs/configs/Bonuses.html @@ -81,6 +81,7 @@ + @@ -237,7 +238,7 @@ generated by LDoc diff --git a/docs/configs/Chat-Reply.html b/docs/configs/Chat-Reply.html index b23c07d5..9ffe93c5 100644 --- a/docs/configs/Chat-Reply.html +++ b/docs/configs/Chat-Reply.html @@ -90,6 +90,7 @@ + @@ -485,7 +486,7 @@ generated by LDoc diff --git a/docs/configs/Commands-Auth-Admin.html b/docs/configs/Commands-Auth-Admin.html index 73b6cd28..dea29ffd 100644 --- a/docs/configs/Commands-Auth-Admin.html +++ b/docs/configs/Commands-Auth-Admin.html @@ -89,6 +89,7 @@ + @@ -294,7 +295,7 @@ generated by LDoc diff --git a/docs/configs/Commands-Auth-Roles.html b/docs/configs/Commands-Auth-Roles.html index b23d64fe..a344862c 100644 --- a/docs/configs/Commands-Auth-Roles.html +++ b/docs/configs/Commands-Auth-Roles.html @@ -89,6 +89,7 @@ + @@ -320,7 +321,7 @@ generated by LDoc diff --git a/docs/configs/Commands-Auth-Runtime-Disable.html b/docs/configs/Commands-Auth-Runtime-Disable.html index 7f3c116b..dff32e2e 100644 --- a/docs/configs/Commands-Auth-Runtime-Disable.html +++ b/docs/configs/Commands-Auth-Runtime-Disable.html @@ -90,6 +90,7 @@ + @@ -442,7 +443,7 @@ generated by LDoc diff --git a/docs/configs/Commands-Parse-Roles.html b/docs/configs/Commands-Parse-Roles.html index 5a0b454f..60343ebc 100644 --- a/docs/configs/Commands-Parse-Roles.html +++ b/docs/configs/Commands-Parse-Roles.html @@ -89,6 +89,7 @@ + @@ -354,7 +355,7 @@ generated by LDoc diff --git a/docs/configs/Commands-Parse.html b/docs/configs/Commands-Parse.html index 66516970..1361775e 100644 --- a/docs/configs/Commands-Parse.html +++ b/docs/configs/Commands-Parse.html @@ -89,6 +89,7 @@ + @@ -338,7 +339,7 @@ see ./expcore/commands.lua for more details

generated by LDoc diff --git a/docs/configs/Compilatron.html b/docs/configs/Compilatron.html index e636d935..37ca361d 100644 --- a/docs/configs/Compilatron.html +++ b/docs/configs/Compilatron.html @@ -89,6 +89,7 @@ + @@ -354,7 +355,7 @@ generated by LDoc diff --git a/docs/configs/Death-Logger.html b/docs/configs/Death-Logger.html index 63adb104..c8c36fab 100644 --- a/docs/configs/Death-Logger.html +++ b/docs/configs/Death-Logger.html @@ -89,6 +89,7 @@ + @@ -416,7 +417,7 @@ generated by LDoc diff --git a/docs/configs/Discord-Alerts.html b/docs/configs/Discord-Alerts.html index cb86d84e..233d45df 100644 --- a/docs/configs/Discord-Alerts.html +++ b/docs/configs/Discord-Alerts.html @@ -81,6 +81,7 @@ + @@ -237,7 +238,7 @@ generated by LDoc diff --git a/docs/configs/File-Loader.html b/docs/configs/File-Loader.html index e3cb46f4..aba7b05d 100644 --- a/docs/configs/File-Loader.html +++ b/docs/configs/File-Loader.html @@ -81,6 +81,7 @@ + @@ -240,7 +241,7 @@ generated by LDoc diff --git a/docs/configs/Permission-Groups.html b/docs/configs/Permission-Groups.html index 8dfe6166..8656a1f1 100644 --- a/docs/configs/Permission-Groups.html +++ b/docs/configs/Permission-Groups.html @@ -89,6 +89,7 @@ + @@ -295,7 +296,7 @@ generated by LDoc diff --git a/docs/configs/Player-List.html b/docs/configs/Player-List.html index 0027c816..239f7169 100644 --- a/docs/configs/Player-List.html +++ b/docs/configs/Player-List.html @@ -90,6 +90,7 @@ + @@ -812,7 +813,7 @@ generated by LDoc diff --git a/docs/configs/Pollution-Grading.html b/docs/configs/Pollution-Grading.html index 14621d46..3603fe03 100644 --- a/docs/configs/Pollution-Grading.html +++ b/docs/configs/Pollution-Grading.html @@ -89,6 +89,7 @@ + @@ -384,7 +385,7 @@ generated by LDoc diff --git a/docs/configs/Popup-Messages.html b/docs/configs/Popup-Messages.html index 65851fdb..be1095c3 100644 --- a/docs/configs/Popup-Messages.html +++ b/docs/configs/Popup-Messages.html @@ -89,6 +89,7 @@ + @@ -414,7 +415,7 @@ generated by LDoc diff --git a/docs/configs/Preset-Player-Colours.html b/docs/configs/Preset-Player-Colours.html index b8e9a7f2..133879c0 100644 --- a/docs/configs/Preset-Player-Colours.html +++ b/docs/configs/Preset-Player-Colours.html @@ -89,6 +89,7 @@ + @@ -324,7 +325,7 @@ generated by LDoc diff --git a/docs/configs/Repair.html b/docs/configs/Repair.html index d8468dde..88f593ff 100644 --- a/docs/configs/Repair.html +++ b/docs/configs/Repair.html @@ -89,6 +89,7 @@ + @@ -414,7 +415,7 @@ generated by LDoc diff --git a/docs/configs/Rockets.html b/docs/configs/Rockets.html index 4d7c8aa1..35df56b4 100644 --- a/docs/configs/Rockets.html +++ b/docs/configs/Rockets.html @@ -89,6 +89,7 @@ + @@ -834,7 +835,7 @@ generated by LDoc diff --git a/docs/configs/Roles.html b/docs/configs/Roles.html index 0414689b..c57368c1 100644 --- a/docs/configs/Roles.html +++ b/docs/configs/Roles.html @@ -89,6 +89,7 @@ + @@ -292,7 +293,7 @@ generated by LDoc diff --git a/docs/configs/Science.html b/docs/configs/Science.html index 2c7f4bf0..f52b2fbe 100644 --- a/docs/configs/Science.html +++ b/docs/configs/Science.html @@ -89,6 +89,7 @@ + @@ -354,7 +355,7 @@ generated by LDoc diff --git a/docs/configs/Scorched-Earth.html b/docs/configs/Scorched-Earth.html index 7b1c22e4..b7af3a39 100644 --- a/docs/configs/Scorched-Earth.html +++ b/docs/configs/Scorched-Earth.html @@ -89,6 +89,7 @@ + @@ -388,7 +389,7 @@ generated by LDoc diff --git a/docs/configs/Spawn-Area.html b/docs/configs/Spawn-Area.html index a7012781..6853d015 100644 --- a/docs/configs/Spawn-Area.html +++ b/docs/configs/Spawn-Area.html @@ -89,6 +89,7 @@ + @@ -744,7 +745,7 @@ generated by LDoc diff --git a/docs/configs/Tasks.html b/docs/configs/Tasks.html index 5b9b0515..cd84fc0c 100644 --- a/docs/configs/Tasks.html +++ b/docs/configs/Tasks.html @@ -89,6 +89,7 @@ + @@ -384,7 +385,7 @@ generated by LDoc diff --git a/docs/configs/Warnings.html b/docs/configs/Warnings.html index 3db69aec..d298e402 100644 --- a/docs/configs/Warnings.html +++ b/docs/configs/Warnings.html @@ -89,6 +89,7 @@ + @@ -355,7 +356,7 @@ generated by LDoc diff --git a/docs/configs/Warps.html b/docs/configs/Warps.html index afe2df6d..ccdb5910 100644 --- a/docs/configs/Warps.html +++ b/docs/configs/Warps.html @@ -89,6 +89,7 @@ + @@ -684,7 +685,7 @@ generated by LDoc diff --git a/docs/control/Jail.html b/docs/control/Jail.html index 2bf7eb2b..3858e706 100644 --- a/docs/control/Jail.html +++ b/docs/control/Jail.html @@ -73,6 +73,7 @@ + @@ -1208,7 +1209,7 @@ generated by LDoc diff --git a/docs/control/Production.html b/docs/control/Production.html index 389e1d52..9eab886b 100644 --- a/docs/control/Production.html +++ b/docs/control/Production.html @@ -73,6 +73,7 @@ + @@ -1329,7 +1330,7 @@ generated by LDoc diff --git a/docs/control/Reports.html b/docs/control/Reports.html index 8c602cfd..d7397705 100644 --- a/docs/control/Reports.html +++ b/docs/control/Reports.html @@ -73,6 +73,7 @@ + @@ -1110,7 +1111,7 @@ generated by LDoc diff --git a/docs/control/Rockets.html b/docs/control/Rockets.html index 549afdb6..9f196c46 100644 --- a/docs/control/Rockets.html +++ b/docs/control/Rockets.html @@ -72,6 +72,7 @@ + @@ -984,7 +985,7 @@ generated by LDoc diff --git a/docs/control/Tasks.html b/docs/control/Tasks.html index c6c98a92..fb62ed5f 100644 --- a/docs/control/Tasks.html +++ b/docs/control/Tasks.html @@ -72,6 +72,7 @@ + @@ -1039,7 +1040,7 @@ generated by LDoc diff --git a/docs/control/Warnings.html b/docs/control/Warnings.html index f13263e7..0343a416 100644 --- a/docs/control/Warnings.html +++ b/docs/control/Warnings.html @@ -72,6 +72,7 @@ + @@ -1465,7 +1466,7 @@ generated by LDoc diff --git a/docs/control/Warps.html b/docs/control/Warps.html index 7a808d9e..b11de74d 100644 --- a/docs/control/Warps.html +++ b/docs/control/Warps.html @@ -73,6 +73,7 @@ + @@ -1413,7 +1414,7 @@ generated by LDoc diff --git a/docs/core/Commands.html b/docs/core/Commands.html index b7665406..e72da3ba 100644 --- a/docs/core/Commands.html +++ b/docs/core/Commands.html @@ -61,6 +61,7 @@ + @@ -1972,7 +1973,7 @@ generated by LDoc diff --git a/docs/core/Common-Library.html b/docs/core/Common-Library.html index 704bb0b4..5d3f775f 100644 --- a/docs/core/Common-Library.html +++ b/docs/core/Common-Library.html @@ -57,6 +57,7 @@ + @@ -2746,7 +2747,7 @@ Common.table_insert(tbl,50,tbl2) generated by LDoc diff --git a/docs/core/Gui.html b/docs/core/Gui.html index 7001ba8e..861627e8 100644 --- a/docs/core/Gui.html +++ b/docs/core/Gui.html @@ -66,6 +66,7 @@ + @@ -501,6 +502,10 @@ button:clone('CustomButton') Used to copy all the settings from one concept to another and removing links to the orginal + Prototype:define_clone(clone_callback) + Use to add your own callbacks to the clone function, for example adding to a local table + + Prototype:change_name([new_name=self.name]) Used internally to save concept names to the core gui module @@ -3468,6 +3473,71 @@ button:change_name('Not Button') Gui.get_concept('Button'):clone('CustomButton') + +
+
+
+ # + Prototype:define_clone(clone_callback) +
+
+
+
+ +

Use to add your own callbacks to the clone function, for example adding to a local table

+

+ + + Parameters: + +
    + + + + + +
  • + + clone_callback + + : + + (function) + + the function which is called with the concept to have something done to it + +
  • + + +
+ + + + + Returns: +
    +
  • + (table) + self to allow chaining +
  • +
+ + + + + + + + Usage: +
-- Adding concept to a local table
+local buttons = {}
+local button =
+Gui.get_concept('Button')
+:define_clone(function(concept)
+    buttons[concept.name] = concept
+end)
+ +
@@ -4970,7 +5040,7 @@ Gui.get_concept('CustomButton') generated by LDoc diff --git a/docs/core/Permissions-Groups.html b/docs/core/Permissions-Groups.html index d6cfd67e..e10f905a 100644 --- a/docs/core/Permissions-Groups.html +++ b/docs/core/Permissions-Groups.html @@ -60,6 +60,7 @@ + @@ -1432,7 +1433,7 @@ generated by LDoc diff --git a/docs/core/Roles.html b/docs/core/Roles.html index 90aaa30a..40948b8d 100644 --- a/docs/core/Roles.html +++ b/docs/core/Roles.html @@ -64,6 +64,7 @@ + @@ -3152,7 +3153,7 @@ generated by LDoc diff --git a/docs/core/Store.html b/docs/core/Store.html index c426c2a9..e56e6911 100644 --- a/docs/core/Store.html +++ b/docs/core/Store.html @@ -57,6 +57,7 @@ + @@ -1145,7 +1146,7 @@ Store.register(team_scores,function(value,key) generated by LDoc diff --git a/docs/core/Sudo.html b/docs/core/Sudo.html index cb87e968..4f88af42 100644 --- a/docs/core/Sudo.html +++ b/docs/core/Sudo.html @@ -57,6 +57,7 @@ + @@ -544,7 +545,7 @@ generated by LDoc diff --git a/docs/core/Toolbar.html b/docs/core/Toolbar.html new file mode 100644 index 00000000..0da30385 --- /dev/null +++ b/docs/core/Toolbar.html @@ -0,0 +1,1638 @@ + + + + + + + + Toolbar core + + + + + + + +
+
+ + + + + + + +
+ + + + + + + + +

Toolbar core

+

Core Module - Toolbar

+

+ + + + + + + + + + + + + +

Dependencies

+ + + + + + + + + + + + + + + + + + + +
expcore.gui
expcore.roles
utils.event
utils.game
mod-gui
+ + +

Permissions

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

Buttons

+ + + + + + + + + + + + + + + + + + + + +
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-buttonThe base element to be used with the toolbar, others can be used but this is recomented
+ + +

Frames

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
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-frameThe 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
+ + +

Other Elements

+ + + + + + + + + + + + + + + + +
toolbarThe main toolbar element, draws, updates, and controls the other concepts
toolbar-toggleButton which toggles the the visible state of all toolbar buttons, triggers on_button_update
toolbar-clearButton which hides all visible toolbar frames, triggers on_hide_frames
+ + +
+ + +

Dependencies

+
+
+
+
+ # + expcore.gui +
+
+
+
+ + + + + + + + + + + + + + + +
+
+
+
+ # + expcore.roles +
+
+
+
+ + + + + + + + + + + + + + + +
+
+
+
+ # + utils.event +
+
+
+
+ + + + + + + + + + + + + + + +
+
+
+
+ # + utils.game +
+
+
+
+ + + + + + + + + + + + + + + +
+
+
+
+ # + mod-gui +
+
+
+
+ + + + + + + + + + + + + + + +
+
+

Permissions

+
+
+
+
+ # + 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

+

+ + + Parameters: + +
    + + + + + +
  • + + player + + : + + (LuaPlayer) + + the player you want ot test is allowed to use this button + +
  • + + + + + +
  • + + concept_name + + : + + (string) + + the name of the button concept that you want to see if the player is allowed to use + +
  • + + +
+ + + + + Returns: +
    +
  • + (boolean) + true if the player is allowed to use it +
  • +
+ + + + + + + + Usage: +
-- Test if a player can use 'test-player-list'
+local allowed = Toolbar.allowed(game.player,'test-player-list')
+ + +
+
+
+
+ # + 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

+

+ + + Parameters: + +
    + + + + + +
  • + + concept_name + + : + + (string) + + the name of the concept that will point to this alias + +
  • + + + + + +
  • + + alias + + : + + (string) + + the permission string that will be tested when this concept is used with Toolbar.allowed + +
  • + + +
+ + + + + + + + + + + + Usage: +
-- Adding an alias for the 'test-player-list' concept
+Toolbar.set_permission_alias('test-player-list','gui/player-list')
+ + +
+
+

Buttons

+
+
+
+
+ # + 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

+

+ + + Parameters: + +
    + + + + + +
  • + + concept + + : + + (table) + + the gui concept that you want to add to the button area + +
  • + + +
+ + + + + + + + + + + + Usage: +
-- Adding a basic button to the toolbar
+local new_button =
+Gui.clone_concept('button','new-button')
+:set_caption('Click Me')
+:on_click(function(event)
+    event.player.print('You Clicked Me!!')
+end)
+
+Toolbar.add_button_concept(new_button)
+ + +
+
+
+
+ # + update_buttons(player) +
+
+
+
+ +

Updates all the buttons for a player, this means hide and show buttons based on permissions

+

+ + + Parameters: + +
    + + + + + +
  • + + player + + : + + (LuaPlayer) + + the player to update the toolbar buttons for + +
  • + + +
+ + + + + + + + + + + + Usage: +
-- Updating your toolbar
+Toolbar.update_buttons(player)
+ + +
+
+
+
+ # + get_visible_buttons(player) +
+
+
+
+ +

Returns an array of buttons names that the given player is able to see, returns none if toolbar hidden

+

+ + + Parameters: + +
    + + + + + +
  • + + player + + : + + (LuaPlayer) + + the player you want to get the visible buttons of + +
  • + + +
+ + + + + Returns: +
    +
  • + (table) + an array of names of the visible buttons +
  • +
+ + + + + + + + Usage: +
-- Get a list of all your visible buttons
+Toolbar.get_visible_buttons(game.player)
+ + +
+
+
+
+ # + toolbar-button +
+
+
+
+ +

The base element to be used with the toolbar, others can be used but this is recomented

+

+ + + Properties / Events: + +
    + + + + + +
  • + + permission_alias + + : + + (string) + + the alias used with Toolbar.allowed + +
  • + + +
+ + + + + + + + + + + + Usage: +
-- Adding a basic button to the toolbar, note no need to call Toolbar.add_button_concept
+Gui.clone_concept('toolbar-button','new-button')
+:set_caption('Click Me')
+:on_click(function(event)
+    event.player.print('You Clicked Me!!')
+end)
+ + +
+
+

Frames

+
+
+
+
+ # + add_frame_concept(concept) +
+
+
+
+ +

Adds a frame concept to the toolbar frame area, this will not add a button to the toolbar

+

+ + + Parameters: + +
    + + + + + +
  • + + concept + + : + + (table) + + the gui concept that you want to add to the toolbar frame area + +
  • + + +
+ + + + + + + + + + + + Usage: +
-- Adding a basic frame to the frame area
+local new_frame =
+Gui.clone_concept('frame','new_frame')
+:set_title('Test')
+
+Toolbar.add_frame_concept(new_frame)
+ + +
+
+
+
+ # + hide_frames(player) +
+
+
+
+ +

Hides all the frames for a player

+

+ + + Parameters: + +
    + + + + + +
  • + + player + + : + + (LuaPlayer) + + the player to hide the frames for + +
  • + + +
+ + + + + + + + + + + + Usage: +
-- Hiding all your frames
+Toolbar.hide_frames(game.player)
+ + +
+
+
+
+ # + get_visible_frames(player) +
+
+
+
+ +

Gets an array of the names of all the visible frames for a player

+

+ + + Parameters: + +
    + + + + + +
  • + + player + + : + + (LuaPlayer) + + the player that you want to get the visible frames of + +
  • + + +
+ + + + + Returns: +
    +
  • + (table) + an array of names of the visible frames for the given player +
  • +
+ + + + + + + + Usage: +
-- Get all your visible frames
+Toolbar.get_visible_frames(game.player)
+ + +
+
+
+
+ # + toolbar-frame +
+
+
+
+ +

The base toolbar frame, others can be used but this is recomented

+

+ + + Properties / Events: + +
    + + + + + +
  • + + on_update + + : + + + fired when the frame is to have its content updated + +
  • + + + + + +
  • + + open_by_default + + : + + (boolean) + + weather the frame should be open when a player first joins + +
  • + + + + + +
  • + + use_container + + : + + (boolean) + + true by default and will place a container inside the frame for content + +
  • + + + + + +
  • + + direction + + : + + (string) + + the direction that the items in the frame are added + +
  • + + +
+ + + + + + + + + + + + Usage: +
-- Adding a basic player list
+local player_list =
+Gui.clone_concept('toolbar-frame','player_list')
+: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)
+ + +
+
+
+
+ # + Toolbar.frame:get_content(player) +
+
+
+
+ +

Gets the content area of the frame concept for this player, each player only has one area

+

+ + + Parameters: + +
    + + + + + +
  • + + player + + : + + (LuaPlayer) + + the player that you want to get the frame content for + +
  • + + +
+ + + + + Returns: +
    +
  • + (LuaGuiElement) + the content area of this concept for this player +
  • +
+ + + + + + + + Usage: +
-- Get the content area of a concept
+local frame = player_list:get_content(game.player)
+ + +
+
+
+
+ # + Toolbar.frame:toggle_visible_state(player) +
+
+
+
+ +

Toggles the visibilty of this concept for the given player

+

+ + + Parameters: + +
    + + + + + +
  • + + player + + : + + (LuaPlayer) + + the player that you want to toggle the frame for + +
  • + + +
+ + + + + Returns: +
    +
  • + (boolean) + the new state of the visibilty of this concept for the player +
  • +
+ + + + + + + + Usage: +
-- Toggle the frame for your self
+player_list:toggle_visible_state(game.player)
+ + +
+
+
+
+ # + Toolbar.frame:get_visible_state(player) +
+
+
+
+ +

Gets the current visibilty state of this conept for this player

+

+ + + Parameters: + +
    + + + + + +
  • + + player + + : + + (LuaPlayer) + + the player that you want the visibilty state for + +
  • + + +
+ + + + + Returns: +
    +
  • + (boolean) + the current visiblity state of this concept to the player +
  • +
+ + + + + + + + Usage: +
-- Getting the current visiblity state
+ + +
+
+
+
+ # + Toolbar.frame:update(player[, event]) +
+
+
+
+ +

Triggers an update of the content within the concept for this player, uses on_update handlers

+

+ + + Parameters: + +
    + + + + + +
  • + + player + + : + + (LuaPlayer) + + the player to update the concept content for + +
  • + + + + + +
  • + + event + + : + + (table) + + the event data that you want to pass to the update handlers + + (optional) +
  • + + +
+ + + + + + + + + + + + Usage: +
-- Updating the frame for your player
+player_list:update(game.player)
+ + +
+
+
+
+ # + Toolbar.frame:update_all([event]) +
+
+
+
+ +

Triggers an update of the content with in this frame for all players

+

+ + + Parameters: + +
    + + + + + +
  • + + event + + : + + (table) + + the event data that you want to pass to the update handlers + + (optional) +
  • + + +
+ + + + + + + + + + + + Usage: +
-- Update the grame for all players
+player_list:update_all()
+ + +
+
+

Other Elements

+
+
+
+
+ # + toolbar +
+
+
+
+ +

The main toolbar element, draws, updates, and controls the other concepts

+

+ + + Properties / Events: + +
    + + + + + +
  • + + on_button_update + + : + + + fired when the buttons are updated for a player + +
  • + + + + + +
  • + + on_hide_frames + + : + + + fired when the frames are hidden for a player + +
  • + + +
+ + + + + + + + + + + + + +
+
+
+
+ # + 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

+

+ + + + + + + + + + + + + + +
+
+ + + +
+
+
+ + + + diff --git a/docs/guis/Player-List.html b/docs/guis/Player-List.html index 85e9bd5b..439db206 100644 --- a/docs/guis/Player-List.html +++ b/docs/guis/Player-List.html @@ -69,6 +69,7 @@ + @@ -626,7 +627,7 @@ generated by LDoc diff --git a/docs/guis/Rocket-Info.html b/docs/guis/Rocket-Info.html index 4f70f60a..0f113473 100644 --- a/docs/guis/Rocket-Info.html +++ b/docs/guis/Rocket-Info.html @@ -69,6 +69,7 @@ + @@ -629,7 +630,7 @@ generated by LDoc diff --git a/docs/guis/Science-Info.html b/docs/guis/Science-Info.html index db01d658..b26e1560 100644 --- a/docs/guis/Science-Info.html +++ b/docs/guis/Science-Info.html @@ -69,6 +69,7 @@ + @@ -449,7 +450,7 @@ generated by LDoc diff --git a/docs/guis/Task-List.html b/docs/guis/Task-List.html index da16f049..f6d43bb5 100644 --- a/docs/guis/Task-List.html +++ b/docs/guis/Task-List.html @@ -69,6 +69,7 @@ + @@ -632,7 +633,7 @@ generated by LDoc diff --git a/docs/guis/Warps-List.html b/docs/guis/Warps-List.html index 293094c5..545bb8b4 100644 --- a/docs/guis/Warps-List.html +++ b/docs/guis/Warps-List.html @@ -69,6 +69,7 @@ + @@ -837,7 +838,7 @@ generated by LDoc diff --git a/docs/index.html b/docs/index.html index 2d5a06dd..372ce97b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -78,6 +78,10 @@ Core Module - Sudo - An extention of task and token to allow a single require to register and run functions bypassing all permissions. + + Toolbar + Core Module - Toolbar +

Addons

@@ -510,7 +514,7 @@ see ./expcore/commands.lua for more detailsgenerated by LDoc diff --git a/docs/modules/control.html b/docs/modules/control.html index 377e2e4d..6d625e00 100644 --- a/docs/modules/control.html +++ b/docs/modules/control.html @@ -76,6 +76,7 @@ + @@ -351,7 +352,7 @@ generated by LDoc diff --git a/docs/modules/utils.alien_evolution_progress.html b/docs/modules/utils.alien_evolution_progress.html index cb214d8e..1cfaeb22 100644 --- a/docs/modules/utils.alien_evolution_progress.html +++ b/docs/modules/utils.alien_evolution_progress.html @@ -77,6 +77,7 @@ + @@ -419,7 +420,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 4f6a5936..9dda491f 100644 --- a/docs/modules/utils.core.html +++ b/docs/modules/utils.core.html @@ -78,6 +78,7 @@ + @@ -1164,7 +1165,7 @@ generated by LDoc diff --git a/docs/modules/utils.debug.html b/docs/modules/utils.debug.html index 967c465d..b3c9bca3 100644 --- a/docs/modules/utils.debug.html +++ b/docs/modules/utils.debug.html @@ -76,6 +76,7 @@ + @@ -654,7 +655,7 @@ generated by LDoc diff --git a/docs/modules/utils.dump_env.html b/docs/modules/utils.dump_env.html index 5d97b286..b4da436e 100644 --- a/docs/modules/utils.dump_env.html +++ b/docs/modules/utils.dump_env.html @@ -76,6 +76,7 @@ + @@ -323,7 +324,7 @@ generated by LDoc diff --git a/docs/modules/utils.event.html b/docs/modules/utils.event.html index ef1fb0ef..13a7680e 100644 --- a/docs/modules/utils.event.html +++ b/docs/modules/utils.event.html @@ -77,6 +77,7 @@ + @@ -1292,7 +1293,7 @@ generated by LDoc diff --git a/docs/modules/utils.event_core.html b/docs/modules/utils.event_core.html index c7c8acd0..90ced63a 100644 --- a/docs/modules/utils.event_core.html +++ b/docs/modules/utils.event_core.html @@ -76,6 +76,7 @@ + @@ -434,7 +435,7 @@ generated by LDoc diff --git a/docs/modules/utils.math.html b/docs/modules/utils.math.html index c653377a..b4f8fd77 100644 --- a/docs/modules/utils.math.html +++ b/docs/modules/utils.math.html @@ -76,6 +76,7 @@ + @@ -338,7 +339,7 @@ generated by LDoc diff --git a/docs/modules/utils.recipe_locker.html b/docs/modules/utils.recipe_locker.html index 0a43c0e9..34d5d12a 100644 --- a/docs/modules/utils.recipe_locker.html +++ b/docs/modules/utils.recipe_locker.html @@ -77,6 +77,7 @@ + @@ -441,7 +442,7 @@ generated by LDoc diff --git a/docs/modules/utils.state_machine.html b/docs/modules/utils.state_machine.html index fc44bc7b..d3325639 100644 --- a/docs/modules/utils.state_machine.html +++ b/docs/modules/utils.state_machine.html @@ -77,6 +77,7 @@ + @@ -752,7 +753,7 @@ generated by LDoc diff --git a/docs/modules/utils.table.html b/docs/modules/utils.table.html index 1a9ef65d..c76d0411 100644 --- a/docs/modules/utils.table.html +++ b/docs/modules/utils.table.html @@ -78,6 +78,7 @@ + @@ -1382,7 +1383,7 @@ generated by LDoc diff --git a/docs/modules/utils.task.html b/docs/modules/utils.task.html index 3d86cca1..ce165620 100644 --- a/docs/modules/utils.task.html +++ b/docs/modules/utils.task.html @@ -77,6 +77,7 @@ + @@ -651,7 +652,7 @@ generated by LDoc diff --git a/docs/modules/utils.timestamp.html b/docs/modules/utils.timestamp.html index e5be71ff..5c227954 100644 --- a/docs/modules/utils.timestamp.html +++ b/docs/modules/utils.timestamp.html @@ -76,6 +76,7 @@ + @@ -442,7 +443,7 @@ generated by LDoc diff --git a/docs/topics/license.html b/docs/topics/license.html index 2e77eb29..757e9dcd 100644 --- a/docs/topics/license.html +++ b/docs/topics/license.html @@ -57,6 +57,7 @@ + @@ -789,7 +790,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 50cc7c47..1d767ad7 100644 --- a/docs/topics/readme.md.html +++ b/docs/topics/readme.md.html @@ -57,6 +57,7 @@ + @@ -332,7 +333,7 @@ generated by LDoc diff --git a/expcore/gui/concepts/button.lua b/expcore/gui/concepts/button.lua index ce79e6a6..196cc117 100644 --- a/expcore/gui/concepts/button.lua +++ b/expcore/gui/concepts/button.lua @@ -50,21 +50,21 @@ end) properties.type = 'sprite-button' end) :define_draw(function(properties,parent,element) - if properties.type == 'button' then + if properties.type == 'sprite-button' then element = parent.add{ name = properties.name, - type = properties.type, - caption = properties.caption, + type = 'sprite-button', + sprite = properties.sprite, + hovered_sprite = properties.hovered_sprite, + clicked_sprite = properties.clicked_sprite, tooltip = properties.tooltip } else element = parent.add{ name = properties.name, - type = properties.type, - sprite = properties.sprite, - hovered_sprite = properties.hovered_sprite, - clicked_sprite = properties.clicked_sprite, + type = 'button', + caption = properties.caption, tooltip = properties.tooltip } diff --git a/expcore/gui/core.lua b/expcore/gui/core.lua index 08bec3d2..e45101f9 100644 --- a/expcore/gui/core.lua +++ b/expcore/gui/core.lua @@ -188,6 +188,7 @@ function Gui.set_padding(element,up,down,left,right) end --[[ Used to check a property exists and if it is a function then call the function +@function Gui.resolve_property @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 diff --git a/expcore/gui/prototype.lua b/expcore/gui/prototype.lua index 5fb2629e..cac0d37e 100644 --- a/expcore/gui/prototype.lua +++ b/expcore/gui/prototype.lua @@ -75,6 +75,7 @@ local Game = require 'utils.game' -- @dep utils.game local Factorio_Events = {} local Prototype = { draw_callbacks = {}, + clone_callbacks = {}, properties = {}, factorio_events = {}, events = {} @@ -159,9 +160,40 @@ function Prototype:clone(concept_name) concept.set_store_from_instance = nil end + -- Loop over all the clone defines, element is updated when a value is returned + for _,clone_callback in pairs(concept.clone_callbacks) do + local success, rtn = pcall(clone_callback,concept) + if not success then + error('Gui clone handler error with '..concept.name..':\n\t'..rtn) + end + end + return concept end +--[[-- Use to add your own callbacks to the clone function, for example adding to a local table +@tparam function clone_callback the function which is called with the concept to have something done to it +@treturn table self to allow chaining +@usage-- Adding concept to a local table +local buttons = {} +local button = +Gui.get_concept('Button') +:define_clone(function(concept) + buttons[concept.name] = concept +end) +]] +function Prototype:define_clone(clone_callback) + -- Check that it is a function that is being added + if type(clone_callback) ~= 'function' then + error('Draw define must be a function',2) + end + + -- Add the draw function + self.clone_callbacks[#self.clone_callbacks+1] = clone_callback + + return self +end + --[[-- Used internally to save concept names to the core gui module @function Prototype:change_name @tparam[opt=self.name] string new_name the new name of the concept @@ -280,7 +312,7 @@ function Prototype:raise_event(event_name,event,from_factorio) for _,handler in ipairs(handlers) do local success, err = pcall(handler,event) if not success then - error('Gui event handler error with '..self.name..'/'..event_name..': '..err) + error('Gui event handler error with '..self.name..'/'..event_name..':\n\t'..err) end end end @@ -335,7 +367,7 @@ Gui.get_concept('CustomButton') -- Call the setter method to update values if present local success, err = pcall(setter_callback,concept.properties,value,...) if not success then - error('Gui property handler error with '..concept.name..'/'..property_name..': '..err) + error('Gui property handler error with '..concept.name..'/'..property_name..':\n\t'..err) end else -- Otherwise just update the key @@ -413,7 +445,7 @@ function Prototype:draw(parent_element,...) if success and rtn then element = rtn elseif not success then - error('Gui draw handler error with '..self.name..': '..rtn) + error('Gui draw handler error with '..self.name..':\n\t'..rtn) end end diff --git a/expcore/gui/test.lua b/expcore/gui/test.lua index afee4f8f..776bfa59 100644 --- a/expcore/gui/test.lua +++ b/expcore/gui/test.lua @@ -8,7 +8,9 @@ -- @section tests local Gui = require 'expcore.gui' -local Game = require 'utils.game' -- @dep utils.game +local Game = require 'utils.game' +local Event = require 'utils.event' +require 'expcore.toolbar' local test_prefix = '__GUI_TEST_' local tests = {} @@ -32,6 +34,59 @@ Gui.clone_concept('frame',TEST 'test_frame') end end) +Gui.clone_concept('toolbar-button',TEST 'run_test_button') +:set_permission_alias('gui-test') +:set_caption('Element Tests') +:on_click(function(event) + local player = event.player + if not Gui.destroy(player.gui.center[test_frame.name]) then + Gui.run_tests(event.player) + end +end) + +local test_left_frame = +Gui.clone_concept('toolbar-frame',TEST 'player_list') +:set_permission_alias('gui-test') +:set_caption('Frame Test Left') +: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) + +Event.add(defines.events.on_player_joined_game,function(event) + test_left_frame:update_all(event) +end) +Event.add(defines.events.on_player_left_game,function(event) + test_left_frame:update_all(event) +end) + --[[-- Runs a set of gui tests to ensure that the system is working @tparam LuaPlayer player the player that the guis are made for and who recives the results @tparam[opt] string category when given only tests in this category are ran diff --git a/expcore/toolbar.lua b/expcore/toolbar.lua new file mode 100644 index 00000000..a601a7ab --- /dev/null +++ b/expcore/toolbar.lua @@ -0,0 +1,469 @@ +--[[-- Core Module - Toolbar + @core Toolbar + @alias Toolbar +]] + +local Gui = require 'expcore.gui' --- @dep expcore.gui +local Roles = require 'expcore.roles' --- @dep expcore.roles +local Event = require 'utils.event' --- @dep utils.event +local Game = require 'utils.game' --- @dep utils.game +local mod_gui = require 'mod-gui' --- @dep mod-gui + +local toolbar_toggle_concept +local toolbar_hide_concept +local toolbar_concept +local Toolbar = { + button_concepts = {}, + frame_concepts = {}, + permissions = {} +} + +Gui.Toolbar = Toolbar + +--- Permissions. +-- Functions to do with deciding which player can do what +-- @section permissions + +--[[-- 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 +@tparam LuaPlayer player the player you want ot test is allowed to use this button +@tparam string concept_name the name of the button concept that you want to see if the player is allowed to use +@treturn boolean true if the player is allowed to use it +@usage-- Test if a player can use 'test-player-list' +local allowed = Toolbar.allowed(game.player,'test-player-list') +]] +function Toolbar.allowed(player,concept_name) + local permission = Toolbar.permissions[concept_name] or concept_name + return Roles.player_allowed(player,permission) +end + +--[[-- Use to add an alias for the allowed test, alias is what is tested for rather than the concept name +@tparam string concept_name the name of the concept that will point to this alias +@tparam string alias the permission string that will be tested when this concept is used with Toolbar.allowed +@usage-- Adding an alias for the 'test-player-list' concept +Toolbar.set_permission_alias('test-player-list','gui/player-list') +]] +function Toolbar.set_permission_alias(concept_name,alias) + Toolbar.permissions[concept_name] = alias +end + +--- Buttons. +-- All function to do with the toolbar buttons +-- @section buttons + +--[[-- Adds a concept to be drawn to the button area and allows it to be toggled with the toggle toolbar button +@tparam table concept the gui concept that you want to add to the button area +@usage-- Adding a basic button to the toolbar +local new_button = +Gui.clone_concept('button','new-button') +:set_caption('Click Me') +:on_click(function(event) + event.player.print('You Clicked Me!!') +end) + +Toolbar.add_button_concept(new_button) +]] +function Toolbar.add_button_concept(concept) + local concepts = Toolbar.button_concepts + concepts[#concepts+1] = concept +end + +--[[-- Updates all the buttons for a player, this means hide and show buttons based on permissions +@tparam LuaPlayer player the player to update the toolbar buttons for +@usage-- Updating your toolbar +Toolbar.update_buttons(player) +]] +function Toolbar.update_buttons(player) + toolbar_concept:raise_event('on_button_update',{ + player_index = player.index + }) +end + +--[[-- Returns an array of buttons names that the given player is able to see, returns none if toolbar hidden +@tparam LuaPlayer player the player you want to get the visible buttons of +@treturn table an array of names of the visible buttons +@usage-- Get a list of all your visible buttons +Toolbar.get_visible_buttons(game.player) +]] +function Toolbar.get_visible_buttons(player) + local rtn = {} + local top_flow = mod_gui.get_button_flow(player) + + for _,concept in pairs(Toolbar.button_concepts) do + local element = top_flow[concept.name] + if element.visible then + rtn[#rtn+1] = element.name + end + end + + return rtn +end + +--[[-- The base element to be used with the toolbar, others can be used but this is recomented +@element toolbar-button +@tparam string permission_alias the alias used with Toolbar.allowed +@usage-- Adding a basic button to the toolbar, note no need to call Toolbar.add_button_concept +Gui.clone_concept('toolbar-button','new-button') +:set_caption('Click Me') +:on_click(function(event) + event.player.print('You Clicked Me!!') +end) +]] +Toolbar.button = +Gui.clone_concept('button','toolbar-button') +:new_property('permission_alias',nil,function(properties,value) + Toolbar.set_permission_alias(properties.name,value) +end) +:define_clone(Toolbar.add_button_concept) +:define_draw(function(properties,parent,element) + element.style = mod_gui.button_style +end) + +--- Frames. +-- Functions to do with the toolbar frames +-- @section frames + +--[[-- Adds a frame concept to the toolbar frame area, this will not add a button to the toolbar +@tparam table concept the gui concept that you want to add to the toolbar frame area +@usage-- Adding a basic frame to the frame area +local new_frame = +Gui.clone_concept('frame','new_frame') +:set_title('Test') + +Toolbar.add_frame_concept(new_frame) +]] +function Toolbar.add_frame_concept(concept) + local concepts = Toolbar.frame_concepts + concepts[#concepts+1] = concept +end + +--[[-- Hides all the frames for a player +@tparam LuaPlayer player the player to hide the frames for +@usage-- Hiding all your frames +Toolbar.hide_frames(game.player) +]] +function Toolbar.hide_frames(player) + toolbar_concept:raise_event('on_hide_frames',{ + player_index = player.index + }) +end + +--[[-- Gets an array of the names of all the visible frames for a player +@tparam LuaPlayer player the player that you want to get the visible frames of +@treturn table an array of names of the visible frames for the given player +@usage-- Get all your visible frames +Toolbar.get_visible_frames(game.player) +]] +function Toolbar.get_visible_frames(player) + local rtn = {} + local left_flow = mod_gui.get_frame_flow(player) + + for _,concept in pairs(Toolbar.frame_concepts) do + local element = left_flow[concept.name..'-frame'] + if element.visible then + rtn[#rtn+1] = element.name + end + end + + left_flow[toolbar_hide_concept.name].visible = #rtn > 0 + + return rtn +end + +--[[-- The base toolbar frame, others can be used but this is recomented +@element toolbar-frame +@param on_update fired when the frame is to have its content updated +@tparam boolean open_by_default weather the frame should be open when a player first joins +@tparam boolean use_container true by default and will place a container inside the frame for content +@tparam string direction the direction that the items in the frame are added +@usage-- Adding a basic player list +local player_list = +Gui.clone_concept('toolbar-frame','player_list') +: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) +]] +Toolbar.frame = +Gui.clone_concept('toolbar-button','toolbar-frame') +:new_property('open_by_default',false) +:new_property('use_container',true) +:new_property('direction','horizontal') +:new_event('on_update') +:define_clone(function(concept) + Toolbar.add_frame_concept(concept) + concept:on_click(function(event) + event.concept:toggle_visible_state(event.player) + end) +end) +:define_draw(function(properties,parent,element) + -- Add the base frame element, the button is already drawn to parent + local player = Gui.get_player_from_element(element) + local left_flow = mod_gui.get_frame_flow(player) + local frame = left_flow.add{ + name = properties.name..'-frame', + type = 'frame', + direction = properties.direction + } + + frame.style.padding = 2 + + -- Add and return the container if a container is used + if properties.use_container then + local container = + frame.add{ + name = 'container', + type = 'frame', + direction = properties.direction, + style = 'window_content_frame_packed' + } + Gui.set_padding(container) + + return container + + end + + return frame +end) + +--[[-- Gets the content area of the frame concept for this player, each player only has one area +@tparam LuaPlayer player the player that you want to get the frame content for +@treturn LuaGuiElement the content area of this concept for this player +@usage-- Get the content area of a concept +local frame = player_list:get_content(game.player) +]] +function Toolbar.frame:get_content(player) + local left_flow = mod_gui.get_frame_flow(player) + local frame = left_flow[self.name..'-frame'] + return frame.container or frame +end + +--[[-- Toggles the visibilty of this concept for the given player +@tparam LuaPlayer player the player that you want to toggle the frame for +@treturn boolean the new state of the visibilty of this concept for the player +@usage-- Toggle the frame for your self +player_list:toggle_visible_state(game.player) +]] +function Toolbar.frame:toggle_visible_state(player) + local left_flow = mod_gui.get_frame_flow(player) + local frame = left_flow[self.name..'-frame'] + if frame.visible then + frame.visible = false + Toolbar.get_visible_frames(player) + return false + else + frame.visible = true + Toolbar.get_visible_frames(player) + return true + end +end + +--[[-- Gets the current visibilty state of this conept for this player +@tparam LuaPlayer player the player that you want the visibilty state for +@treturn boolean the current visiblity state of this concept to the player +@usage-- Getting the current visiblity state +player_list:get_visible_state(player)]] +function Toolbar.frame:get_visible_state(player) + local left_flow = mod_gui.get_frame_flow(player) + return left_flow[self.name..'-frame'].visible +end + +--[[-- Triggers an update of the content within the concept for this player, uses on_update handlers +@tparam LuaPlayer player the player to update the concept content for +@tparam[opt] table event the event data that you want to pass to the update handlers +@usage-- Updating the frame for your player +player_list:update(game.player) +]] +function Toolbar.frame:update(player,event) + event = event or {} + event.player_index = player.index + event.element = self:get_content(player) + self:raise_event('on_update',event) +end + +--[[-- Triggers an update of the content with in this frame for all players +@tparam[opt] table event the event data that you want to pass to the update handlers +@usage-- Update the grame for all players +player_list:update_all() +]] +function Toolbar.frame:update_all(event) + local players = event.update_offline == true and game.players or game.connected_players + for _,player in pairs(players) do + self:update(player) + end +end + +--- Other Elements. +-- All the other elements that are used to make this work +-- @section elements + +--[[-- The main toolbar element, draws, updates, and controls the other concepts +@element toolbar +@param on_button_update fired when the buttons are updated for a player +@param on_hide_frames fired when the frames are hidden for a player +]] +toolbar_concept = +Gui.new_concept('toolbar') +:define_draw(function(properties,player) + -- Get the main flows + local top_flow = mod_gui.get_button_flow(player) + if not top_flow then return end + local left_flow = mod_gui.get_frame_flow(player) + if not left_flow then return end + + -- Draw toggle buttons first + toolbar_toggle_concept:draw(top_flow) + toolbar_hide_concept:draw(left_flow) + + -- Draw all the buttons and frames + local done = {} + for _,concept in pairs(Toolbar.button_concepts) do + done[concept.name] = true + concept:draw(top_flow) + top_flow[concept.name].visible = Toolbar.allowed(player,concept.name) + + local frame = left_flow[concept.name..'-frame'] + if frame then + frame.visible = Gui.resolve_property(concept.properties.open_by_default,frame) + end + end + + -- Draws frames that did not have buttons + for _,concept in pairs(Toolbar.frame_concepts) do + if not done[concept.name] then + concept:draw(left_flow) + local frame = left_flow[concept.name..'-frame'] + if frame then + frame.visible = Gui.resolve_property(concept.properties.open_by_default,frame) + end + end + end + + -- Toggle the clear toobar if needed + Toolbar.get_visible_frames(player) + +end) +:new_event('on_button_update') +:on_button_update(function(event) + -- Get the top flow + local player = event.player + local top_flow = mod_gui.get_button_flow(player) + if not top_flow then return end + + -- Set the visiblity of the elements + local visible = top_flow[toolbar_toggle_concept.name].caption == '<' + for _,concept in pairs(Toolbar.button_concepts) do + local element = top_flow[concept.name] + if Gui.valid(element) then + element.visible = visible and Toolbar.allowed(player,concept.name) + end + end + +end) +:new_event('on_hide_frames') +:on_hide_frames(function(event) + -- Get the left flow + local player = event.player + local left_flow = mod_gui.get_frame_flow(player) + if not left_flow then return end + + -- Set the visiblity of the elements + left_flow[toolbar_hide_concept.name].visible = false + for _,concept in pairs(Toolbar.frame_concepts) do + local element = left_flow[concept.name..'-frame'] + if Gui.valid(element) then element.visible = false end + end +end) + +--- Used so toggle and hide can have the same look as each other +local function toolbar_button_draw(properties,parent,element) + element.style = mod_gui.button_style + local style = element.style + style.width = 18 + style.height = 36 + style.padding = 0 + style.left_padding = 1 + style.font = 'default-small-bold' +end + +--[[-- Button which toggles the the visible state of all toolbar buttons, triggers on_button_update +@element toolbar-toggle +]] +toolbar_toggle_concept = +Gui.clone_concept('button','toolbar-toggle') +:set_caption('<') +:set_tooltip{'gui_util.button_tooltip'} +:define_draw(toolbar_button_draw) +:on_click(function(event) + local element = event.element + element.caption = element.caption == '<' and '>' or '<' + toolbar_concept:raise_event('on_button_update',{ + player_index = event.player_index + }) +end) + +--[[-- Button which hides all visible toolbar frames, triggers on_hide_frames +@element toolbar-clear +]] +toolbar_hide_concept = +Gui.clone_concept('button','toolbar-clear') +:set_caption('<') +:set_tooltip{'expcore-gui.left-button-tooltip'} +:define_draw(toolbar_button_draw) +:on_click(function(event) + event.element.visible = false + toolbar_concept:raise_event('on_hide_frames',{ + player_index = event.player_index + }) +end) + +--- When there is a new player they will have the toolbar update +Event.add(defines.events.on_player_created,function(event) + local player = Game.get_player_by_index(event.player_index) + toolbar_concept:draw(player) +end) + +--- When a player gets a new role they will have the toolbar updated +Event.add(Roles.events.on_role_assigned,function(event) + toolbar_concept:raise_event('on_button_update',{ + player_index = event.player_index + }) +end) + +--- When a player loses a role they will have the toolbar updated +Event.add(Roles.events.on_role_unassigned,function(event) + toolbar_concept:raise_event('on_button_update',{ + player_index = event.player_index + }) +end) + +return Toolbar \ No newline at end of file diff --git a/utils/event_core.lua b/utils/event_core.lua index 364e3134..b34715e1 100644 --- a/utils/event_core.lua +++ b/utils/event_core.lua @@ -27,7 +27,7 @@ local function call_handlers(handlers, event) local handler = handlers[i] local success, error = pcall(handler, event) if not success then - log(error) + log('\n\t'..error) end end end