From cb59cc05379b3b159b3d97e1e2e04b528bdf591a Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Tue, 27 Aug 2019 21:08:48 +0100 Subject: [PATCH] Button docs --- 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/config.ld | 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 | 2 +- docs/core/Gui.html | 694 +++++++++++++++++- 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/gui.lua | 7 +- expcore/gui/concepts/button.lua | 58 ++ expcore/gui/concepts/frame.lua | 24 + expcore/gui/core.lua | 13 +- expcore/gui/prototype.lua | 41 +- expcore/gui/test.lua | 99 ++- 99 files changed, 982 insertions(+), 138 deletions(-) create mode 100644 expcore/gui/concepts/button.lua create mode 100644 expcore/gui/concepts/frame.lua diff --git a/docs/addons/Advanced-Start.html b/docs/addons/Advanced-Start.html index 29b030ea..9bfb5db8 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 729893a0..ef85f4de 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 1e856b8f..e234a42b 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 5aae0a19..5e3e8756 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 e4b67042..f344f291 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 4cf1acfd..1bab19c6 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 0b836551..46d083f3 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 e7f8df76..2864df66 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 10a168f1..d9dbd853 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 38130265..76fb3326 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 0e7e5b27..249c3594 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 76b7a927..62b42001 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 87956b1c..1bcd987d 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 e1423804..3bacbf7a 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 54f08873..1d6df6d3 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 11c0c3e7..9bde1796 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 a12b13bf..cf16472c 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 563e5eed..2ae4c965 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 0d208a2e..f2daf409 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 d7ed49ae..f6338385 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 445572af..022cbac6 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 11f47477..c23a8a8f 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 7c57749b..8bba6d29 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 2b976778..026f097c 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 6b28834e..54cd982c 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 f144b25a..708e8b36 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 5332aba1..d19f1fbe 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 507f63c1..4a8091cc 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 0d4b6f40..8301531e 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 6a947dd1..eb3517a2 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 93d4c25c..7413701a 100644 --- a/docs/commands/Warnings.html +++ b/docs/commands/Warnings.html @@ -569,7 +569,7 @@ generated by LDoc diff --git a/docs/config.ld b/docs/config.ld index 7573fa6d..d3b5fe24 100644 --- a/docs/config.ld +++ b/docs/config.ld @@ -23,8 +23,8 @@ new_type("gui", "Guis", true) new_type("config", "Configs", true, "Settings") new_type("dep", "Dependencies", false) -new_type("element", "Elements", false) new_type("setting", "Settings", false) +new_type("element", "Elements", false, "Properties / Events") new_type("event", "Events", false, "Event Parameters") new_type("command", "Commands", false, "Command Parameters") diff --git a/docs/configs/Advanced-Start.html b/docs/configs/Advanced-Start.html index 1b9f695a..288e352a 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 d9e819ed..38426477 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 a9bb8b8e..5e821e91 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 1dbe5aa9..90881d2b 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 37c7cd4f..3222992f 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 ed6b5013..9b18b862 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 7f2f664c..646e2983 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 1088875e..884ccbb3 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 eff5b319..763a5a9c 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 a36763e7..b7f20311 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 707ef9e0..2f153869 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 014a6eb1..ac84fc48 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 a73c2fd9..30cf06a8 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 8549d098..4c029621 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 bbbfd915..0e254751 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 32e29c71..7071d49f 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 c8bf9fbf..410b72ab 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 e1a9a323..10368fd8 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 62eb1728..7744dcc6 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 874df6b8..7153c5fa 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 e859f833..2a2736dc 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 85d2ef15..3208835a 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 2e155710..e12a5a6e 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 f3c900cb..9cc43e14 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 c0ea648d..9320be9a 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 733ce562..16a4f5b8 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 7d265c02..9fdc593a 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 6f029de5..0a7c702f 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 6be2fb65..995f2cdd 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 7c71c6cf..1d7bb90c 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 60b19b90..749a9d9e 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 9e9d84c0..795dc72e 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 ee053dfd..0c606d3e 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 69af7268..0acf379e 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 4cb1b6be..49ed7f75 100644 --- a/docs/core/Common-Library.html +++ b/docs/core/Common-Library.html @@ -2480,7 +2480,7 @@ generated by LDoc diff --git a/docs/core/Gui.html b/docs/core/Gui.html index fd557709..62ed7797 100644 --- a/docs/core/Gui.html +++ b/docs/core/Gui.html @@ -41,9 +41,12 @@ @@ -203,9 +206,12 @@ @@ -248,6 +254,31 @@ Gui.new_concept('Button') properties.image = value properties.caption = nil properties.type = 'sprite-button' +end) +:define_draw(function(properties,parent,element) + -- Note that element might be nil if this is the first draw function + -- in this case button is a new concept so we know this is the first function and element is nil + if properties.type == 'button' then + element = parent.add{ + type = properties.type, + name = properties.name, + caption = properties.caption, + tooltip = properties.tooltip + } + + else + element = parent.add{ + type = properties.type, + name = properties.name, + sprite = properties.sprite, + tooltip = properties.tooltip + } + + end + + -- We must return the element or what we want to be seen as the instance, this is so other draw functions have access to it + -- for example if our custom button defined a draw function to change the font color to red + return element end)
-- Makeing a alternative button based on the first
 local custom_button =
@@ -275,6 +306,50 @@ button:clone('CustomButton')
     
     
+    

Elements

+ + + + + + + + + + + + +
buttonThe basic button element
frameThe basic frame element
+ + +

Core

+ + + + + + + + + + + + + + + + + + + + + + + + +
require_concept(concept)Loads a concept from the concepts file, used internally
get_concept(name)Gets the gui concept with this name
Prototype:change_name([new_name=self.name])Used internally to save concept names to the core gui module
new_concept(name)Returns a new gui concept with no properties or events
clone_concept(name, new_name)Making anew concept based on the properties and drawing of another
+ +

Concept Base

@@ -284,6 +359,10 @@ button:clone('CustomButton') + + + + @@ -377,11 +456,490 @@ button:clone('CustomButton')
Used to copy all the settings from one concept to another and removing links to the orginal
Prototype:change_name([new_name=self.name])Used internally to save concept names to the core gui module
Prototype:new_event(event_name[, factorio_event][, event_condition]) Adds a new event trigger to the concept which can be linked to a factorio event
+ + +

Tests

+ + + + + + + + +
run_tests(player[, category])Runs a set of gui tests to ensure that the system is working

+

Elements

+
+
+
+
+ # + button +
+
+
+
+ +

The basic button element

+

+ + + Properties / Events: + +
    + + + + + +
  • + + on_click + + : + + + fired when the player clicks the button + +
  • + + + + + +
  • + + on_left_click + + : + + + fired when the player clicks with the right mouse button + +
  • + + + + + +
  • + + on_left_click + + : + + + fired when the player clicks with the right mouse button + +
  • + + + + + +
  • + + caption + + : + + (string or LocalisedString) + + the message that is shown on the button + +
  • + + + + + +
  • + + tooltip + + : + + (string or LocalisedString) + + the tooltip that shows when a player hovers over the button + +
  • + + + + + +
  • + + sprite + + : + + (SpritePath) + + upto three sprites in the order: default, hovered, clicked + +
  • + + +
+ + + + + + + + + + + + + +
+
+
+
+ # + frame +
+
+
+
+ +

The basic frame element

+

+ + + Properties / Events: + +
    + + + + + +
  • + + title + + : + + (string or LocalisedString) + + the title that will show in the frame + +
  • + + +
+ + + + + + + + + + + + + +
+
+

Core

+
+
+
+
+ # + require_concept(concept) +
+
+
+
+ +

Loads a concept from the concepts file, used internally

+

+ + + Parameters: + +
    + + + + + +
  • + + concept + + : + + (string) + + the name of the concept to require + +
  • + + +
+ + + + + + + + + + + + Usage: +
-- Load a base concept
+Gui.require_concept('frame')
+ + +
+
+
+
+ # + get_concept(name) +
+
+
+
+ +

Gets the gui concept with this name

+

+ + + Parameters: + +
    + + + + + +
  • + + name + + : + + (string) + + the name of the concept that you want to get + +
  • + + +
+ + + + + + + + + + + + Usage: +
-- Getting a gui concept
+local button = Gui.get_concept('Button')
+ + +
+
+
+
+ # + Prototype:change_name([new_name=self.name]) +
+
+
+
+ +

Used internally to save concept names to the core gui module

+

+ + + Parameters: + +
    + + + + + +
  • + + new_name + + : + + (string) + + the new name of the concept + + (default: self.name) +
  • + + +
+ + + + + + + + + + + + Usage: +
-- Internal Saving
+-- this is never needed to be done, internal use only!
+local button = Gui.get_concept('Button')
+button:change_name('Not Button')
+ + +
+
+
+
+ # + new_concept(name) +
+
+
+
+ +

Returns a new gui concept with no properties or events

+

+ + + Parameters: + +
    + + + + + +
  • + + name + + : + + (string) + + the name that you want this concept to have + +
  • + + +
+ + + + + + + + + + + + Usage: +
-- Making a new concept, see module usage
+local button = Gui.new_concept('Button')
+ + +
+
+
+
+ # + clone_concept(name, new_name) +
+
+
+
+ +

Making anew concept based on the properties and drawing of another

+

+ + + Parameters: + +
    + + + + + +
  • + + name + + : + + (string) + + the name of the concept that you want as the base + +
  • + + + + + +
  • + + new_name + + : + + (string) + + the name that you want the new concept to have + +
  • + + +
+ + + + + + + + + + + + Usage: +
-- Making a new concept from another, see module usage
+local custom_button = Gui.clone_concept('Button','CustomButton')
+ + +
+

Concept Base

@@ -444,6 +1002,62 @@ button:clone('CustomButton') Gui.get_concept('Button'):clone('CustomButton')
+ +
+
+
+ # + Prototype:change_name([new_name=self.name]) +
+
+
+
+ +

Used internally to save concept names to the core gui module

+

+ + + Parameters: + +
    + + + + + +
  • + + new_name + + : + + (string) + + the new name of the concept + + (default: self.name) +
  • + + +
+ + + + + + + + + + + + Usage: +
-- Internal Saving
+-- this is never needed to be done, internal use only!
+local button = Gui.get_concept('Button')
+button:change_name('Not Button')
+ +
@@ -934,6 +1548,7 @@ Gui.get_concept('Button') :define_draw(function(properties,parent,element) -- Note that element might be nil if this is the first draw function -- for this example we assume button was cloned from Prototype and so has no other draw functions defined + -- this means that there is no element yet and what we return will be the first time the element is returned -- although not shown here you also can recive any extra arguments here from the call to draw if properties.type == 'button' then element = parent.draw{ @@ -953,8 +1568,8 @@ Gui.get_concept('Button') end - -- We must return the element or what we want to be seen as the instance - -- this is so other draw functions have access to it, say if our custom button defined a draw function to change the font color to red + -- We must return the element or what we want to be seen as the instance, this is so other draw functions have access to it + -- for example if our custom button defined a draw function to change the font color to red return element end) @@ -1871,6 +2486,79 @@ Gui.get_concept('CustomButton') custom_button.set_store_from_instance(element) + + +

Tests

+
+
+
+
+ # + run_tests(player[, category]) +
+
+
+
+ +

Runs a set of gui tests to ensure that the system is working

+

+ + + Parameters: + +
    + + + + + +
  • + + player + + : + + (LuaPlayer) + + the player that the guis are made for and who recives the results + +
  • + + + + + +
  • + + category + + : + + (string) + + when given only tests in this category are ran + + (optional) +
  • + + +
+ + + + + + + + + + + + Usage: +
-- Run all gui tests
+Gui.run_tests(game.player)
+ +
@@ -1887,7 +2575,7 @@ Gui.get_concept('CustomButton') generated by LDoc diff --git a/docs/core/Permissions-Groups.html b/docs/core/Permissions-Groups.html index 4befca44..e05ed687 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 a2bef34f..5b989791 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 6026f246..937ec539 100644 --- a/docs/core/Store.html +++ b/docs/core/Store.html @@ -1128,7 +1128,7 @@ Store.register(team_scores,function(value,key) generated by LDoc diff --git a/docs/core/Sudo.html b/docs/core/Sudo.html index b037fbf6..aabdfb54 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 8aa3ef94..3a76fdcc 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 49db82bf..d5144327 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 1d910135..2e733887 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 8b3221fb..a3fa28cb 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 0a12a90f..4d84021e 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 bd8cb83a..d55abbff 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 c79d10b4..b1e1a273 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 a8dd8517..e70f53cf 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 d3329c77..2eafdc25 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 5e50472a..e5bab76d 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 ef683374..f86ef92c 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 9f27e495..edf052c2 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 d369a623..74fd5324 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 78cd66e7..8898c3e4 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 dc87e650..b3a13c92 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 394ccfb3..a780a4d1 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 406abc06..6c086a80 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 e70b97ec..b6ca1a92 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 54faeee6..46b83cfd 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 79b030c8..beee1b37 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 419754b9..8c8c821c 100644 --- a/docs/topics/readme.md.html +++ b/docs/topics/readme.md.html @@ -332,7 +332,7 @@ generated by LDoc diff --git a/expcore/gui.lua b/expcore/gui.lua index 7ab0bdd3..a384e8bd 100644 --- a/expcore/gui.lua +++ b/expcore/gui.lua @@ -21,7 +21,7 @@ end) -- Note that element might be nil if this is the first draw function -- in this case button is a new concept so we know this is the first function and element is nil if properties.type == 'button' then - element = parent.draw{ + element = parent.add{ type = properties.type, name = properties.name, caption = properties.caption, @@ -29,7 +29,7 @@ end) } else - element = parent.draw{ + element = parent.add{ type = properties.type, name = properties.name, sprite = properties.sprite, @@ -67,4 +67,7 @@ custom_button:draw(game.player.gui.left) local Gui = require 'expcore.gui.core' +Gui.require_concept('frame') +Gui.require_concept('button') + return Gui \ No newline at end of file diff --git a/expcore/gui/concepts/button.lua b/expcore/gui/concepts/button.lua new file mode 100644 index 00000000..cecc257c --- /dev/null +++ b/expcore/gui/concepts/button.lua @@ -0,0 +1,58 @@ +--[[-- Core Module - Gui + @module Gui + @alias Gui +]] + +local Gui = require 'expcore.gui.core' + +--[[-- The basic button element +@element button +@param on_click fired when the player clicks the button +@param on_left_click fired when the player clicks with the left mouse button +@param on_left_click fired when the player clicks with the right mouse button +@tparam ?string|Concepts.LocalisedString caption the message that is shown on the button +@tparam ?string|Concepts.LocalisedString tooltip the tooltip that shows when a player hovers over the button +@tparam SpritePath sprite upto three sprites in the order: default, hovered, clicked +]] +Gui.new_concept('button') +:new_event('on_click',defines.events.on_gui_click) +:new_event('on_left_click',defines.events.on_gui_click,function(event) + return event.mouse_button == defines.mouse_button_type.left +end) +:new_event('on_right_click',defines.events.on_gui_click,function(event) + return event.mouse_button == defines.mouse_button_type.right +end) +:new_property('tooltip') +:new_property('caption',nil,function(properties,value) + properties.caption = value + properties.type = 'button' +end) +:new_property('sprite',nil,function(properties,value,hovered_sprite,clicked_sprite) + properties.sprite = value + properties.hovered_sprite = hovered_sprite + properties.clicked_sprite = clicked_sprite + properties.type = 'sprite-button' +end) +:define_draw(function(properties,parent,element) + if properties.type == 'button' then + element = parent.add{ + name = properties.name, + type = properties.type, + caption = properties.caption, + 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, + tooltip = properties.tooltip + } + + end + + return element +end) \ No newline at end of file diff --git a/expcore/gui/concepts/frame.lua b/expcore/gui/concepts/frame.lua new file mode 100644 index 00000000..c484cbe8 --- /dev/null +++ b/expcore/gui/concepts/frame.lua @@ -0,0 +1,24 @@ +--[[-- Core Module - Gui + @module Gui + @alias Gui +]] + +local Gui = require 'expcore.gui.core' + +--[[-- The basic frame element +@element frame +@tparam ?string|Concepts.LocalisedString title the title that will show in the frame +]] +Gui.new_concept('frame') +:new_property('title',function(properties,value) + properties.title = value +end) +:define_draw(function(properties,parent,element) + element = parent.add{ + name = properties.name, + type = 'frame', + caption = properties.title + } + + return element +end) \ No newline at end of file diff --git a/expcore/gui/core.lua b/expcore/gui/core.lua index 07a69097..5ce2ec2a 100644 --- a/expcore/gui/core.lua +++ b/expcore/gui/core.lua @@ -14,6 +14,15 @@ local Gui = { concepts = {} } +--[[-- Loads a concept from the concepts file, used internally +@tparam string concept the name of the concept to require +@usage-- Load a base concept +Gui.require_concept('frame') +]] +function Gui.require_concept(concept) + require('expcore.gui.concepts.'..concept) +end + --[[-- Gets the gui concept with this name @tparam string name the name of the concept that you want to get @usage-- Getting a gui concept @@ -64,8 +73,8 @@ local custom_button = Gui.clone_concept('Button','CustomButton') function Gui.clone_concept(name,new_name) local concept = Gui.concepts[name] or error('Gui concept "'..name..'" is not defind',2) - if Gui.concepts[name] then - error('Gui concept "'..name..'" is already defind',2) + if Gui.concepts[new_name] then + error('Gui concept "'..new_name..'" is already defind',2) end return concept:clone(new_name) diff --git a/expcore/gui/prototype.lua b/expcore/gui/prototype.lua index 79128ef8..575ae9b6 100644 --- a/expcore/gui/prototype.lua +++ b/expcore/gui/prototype.lua @@ -76,22 +76,24 @@ local Factorio_Events = {} local Prototype = { draw_callbacks = {}, properties = {}, + factorio_events = {}, events = {} } --- Acts as a gernal handler for any factorio event local function factorio_event_handler(event) local element = event.element + local event_handlers = Factorio_Events[event.name] if element then if not element.valid then return end - local concept_name = element.name - local concept_event = Factorio_Events[event.name][concept_name] - concept_event[1]:raise_event(concept_event[2],event,true) + local concept_event_raise = event_handlers[element.name] + if concept_event_raise then + concept_event_raise(event) + end else - local events_handlers = Factorio_Events[event.name] - for _,concept_event in pairs(events_handlers) do - concept_event[1]:raise_event(concept_event[2],event,true) + for _,concept_event_raise in pairs(event_handlers) do + concept_event_raise(event) end end @@ -110,6 +112,7 @@ function Prototype:clone(concept_name) -- Replace name of the concept concept.name = concept_name concept.properties.name = concept_name + concept:change_name() -- Remove all event handlers that were copied concept.events = {} @@ -117,6 +120,14 @@ function Prototype:clone(concept_name) concept.events[event_name] = {} end + -- Remakes even handlers for factorio + concept.factorio_events = {} + for event_name,factorio_event in pairs(self.factorio_events) do + Factorio_Events[factorio_event][concept.name] = function(event) + concept:raise_event(event_name,event,true) + end + end + -- Remove all refrences to an instance store if concept.instance_store then concept.instance_store = nil @@ -142,9 +153,6 @@ function Prototype:clone(concept_name) concept.set_store_from_instance = nil end - -- Sets the concept name - concept:change_name() - return concept end @@ -201,19 +209,24 @@ end) end local handlers = concept.events[event_name] - handlers[#handlers] = handler + handlers[#handlers+1] = handler return concept end -- Adds the factorio event handler if this event is linked to one if factorio_event then + self.factorio_events[event_name] = factorio_event self.events[event_name].factorio_handler = event_condition + if not Factorio_Events[factorio_event] then Factorio_Events[factorio_event] = {} Event.add(factorio_event,factorio_event_handler) end - Factorio_Events[factorio_event][self.name] = {self,event_name} + + Factorio_Events[factorio_event][self.name] = function(event) + self:raise_event(event_name,event,true) + end end return self @@ -259,7 +272,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 - print('Gui event handler error with '..self.name..'/'..event_name..': '..err) + error('Gui event handler error with '..self.name..'/'..event_name..': '..err) end end end @@ -314,7 +327,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 - print('Gui property handler error with '..concept.name..'/'..property_name..': '..err) + error('Gui property handler error with '..concept.name..'/'..property_name..': '..err) end else -- Otherwise just update the key @@ -392,7 +405,7 @@ function Prototype:draw(parent_element,...) if success and rtn then element = rtn elseif not success then - print('Gui draw handler error with '..self.name..': '..rtn) + error('Gui draw handler error with '..self.name..': '..rtn) end end diff --git a/expcore/gui/test.lua b/expcore/gui/test.lua index fd6d6796..a4b8f56a 100644 --- a/expcore/gui/test.lua +++ b/expcore/gui/test.lua @@ -3,15 +3,40 @@ @alias Gui ]] -local Gui = require 'expcore.gui' +--- Tests. +-- functions used to test +-- @section tests +local Gui = require 'expcore.gui' +local Game = require 'utils.game' -- @dep utils.game + +local test_prefix = '__GUI_TEST_' local tests = {} +local function TEST(str) return test_prefix..str end + +--[[ +The main test frame +]] + +local test_frame = +Gui.clone_concept('frame',TEST 'test_frame') +:set_title('Gui Tests') +:define_draw(function(properties,parent,element) + for category, _ in pairs(tests) do + element.add{ + type = 'flow', + name = category, + direction = 'vertical' + } + end +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 @usage-- Run all gui tests -Gui.run_tests(Gui.test_string_return(game.print)) +Gui.run_tests(game.player) ]] function Gui.run_tests(player,category) local results = { @@ -42,18 +67,20 @@ function Gui.run_tests(player,category) return results end + local frame = player.gui.center[test_frame.name] or test_frame:draw(player.gui.center) local cat_tests = tests[category] results.total = #cat_tests local output = player.print - for test_name, callback in pairs(cat_tests) do - local success, err = pcall(callback,player) + for test_name, concept in pairs(cat_tests) do + local success, err = pcall(concept.draw,concept,frame[category]) if success then results.passed = results.passed + 1 else - results.erorrs[test_name] = err + results.errors[test_name] = err + results.failed = results.failed + 1 output(string.format('Test "%s / %s" failed:\n%s',category,test_name,err)) end @@ -65,29 +92,51 @@ function Gui.run_tests(player,category) end --[[ -Basic frame creation +Buttons ]] -local test_frame = -Gui.new_concept('test_frame') -:define_draw(function(properties,parent,element) - element = - parent.add{ - name = properties.name, - type = 'frame', - caption = 'Gui Tests' - } - - element.add{ - type = 'label', - caption = 'Hello, World!' - } - - return element +local basic_button = +Gui.clone_concept('button',TEST 'basic_button') +:set_caption('Basic Button') +:set_tooltip('Basic button') +:on_click(function(event) + event.player.print('You pressed basic button!') end) -tests.Frame = { - ['Draw Frame'] = function(player) - test_frame:draw(player.gui.center) +local sprite_button = +Gui.clone_concept('button',TEST 'sprite_button') +:set_sprite('utility/warning_icon') +:set_tooltip('Sprite button') +:on_click(function(event) + event.player.print('You pressed sprite button!') +end) + +local multi_sprite_button = +Gui.clone_concept('button',TEST 'multi_sprite_button') +:set_sprite('utility/warning_icon','utility/warning','utility/warning_white') +:set_tooltip('Multi-sprite button') +:on_click(function(event) + event.player.print('You pressed multi sprite button!') +end) + +local admin_button = +Gui.clone_concept('button',TEST 'admin_button') +:set_caption('Admin Button') +:set_tooltip('Admin button') +:define_draw(function(properties,parent,element) + local player = Game.get_player_by_index(element.player_index) + if not player.admin then + element.enabled = false + element.tooltip = 'You must be admin to press this button' end +end) +:on_click(function(event) + event.player.print('You pressed admin button!') +end) + +tests.Buttons = { + ['Basic Button'] = basic_button, + ['Sprite Button'] = sprite_button, + ['Multi Sprite Button'] = multi_sprite_button, + ['Admin Button'] = admin_button, } \ No newline at end of file