From b6311724874de7a4c131dce8ff0ca286fdfd041c Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 29 Aug 2019 18:20:44 +0100 Subject: [PATCH] Added checkboxs --- docs/addons/Advanced-Start.html | 2 +- docs/addons/Chat-Popups.html | 2 +- docs/addons/Chat-Reply.html | 2 +- docs/addons/Compilatron.html | 2 +- docs/addons/Damage-Popups.html | 2 +- docs/addons/Death-Logger.html | 2 +- docs/addons/Discord-Alerts.html | 2 +- docs/addons/Player-Colours.html | 2 +- docs/addons/Pollution-Grading.html | 2 +- docs/addons/Scorched-Earth.html | 2 +- docs/addons/Spawn-Area.html | 2 +- docs/commands/Admin-Chat.html | 2 +- docs/commands/Bonus.html | 2 +- docs/commands/Cheat-Mode.html | 2 +- docs/commands/Clear-Inventory.html | 2 +- docs/commands/Debug.html | 2 +- docs/commands/Find.html | 2 +- docs/commands/Help.html | 2 +- docs/commands/Home.html | 2 +- docs/commands/Interface.html | 2 +- docs/commands/Jail.html | 2 +- docs/commands/Kill.html | 2 +- docs/commands/Me.html | 2 +- docs/commands/Rainbow.html | 2 +- docs/commands/Repair.html | 2 +- docs/commands/Reports.html | 2 +- docs/commands/Roles.html | 2 +- docs/commands/Spawn.html | 2 +- docs/commands/Tag.html | 2 +- docs/commands/Teleport.html | 2 +- docs/commands/Warnings.html | 2 +- docs/configs/Advanced-Start.html | 2 +- docs/configs/Bonuses.html | 2 +- docs/configs/Chat-Reply.html | 2 +- docs/configs/Commands-Auth-Admin.html | 2 +- docs/configs/Commands-Auth-Roles.html | 2 +- .../Commands-Auth-Runtime-Disable.html | 2 +- docs/configs/Commands-Parse-Roles.html | 2 +- docs/configs/Commands-Parse.html | 2 +- docs/configs/Compilatron.html | 2 +- docs/configs/Death-Logger.html | 2 +- docs/configs/Discord-Alerts.html | 2 +- docs/configs/File-Loader.html | 2 +- docs/configs/Permission-Groups.html | 2 +- docs/configs/Player-List.html | 2 +- docs/configs/Pollution-Grading.html | 2 +- docs/configs/Popup-Messages.html | 2 +- docs/configs/Preset-Player-Colours.html | 2 +- docs/configs/Repair.html | 2 +- docs/configs/Rockets.html | 2 +- docs/configs/Roles.html | 2 +- docs/configs/Science.html | 2 +- docs/configs/Scorched-Earth.html | 2 +- docs/configs/Spawn-Area.html | 2 +- docs/configs/Tasks.html | 2 +- docs/configs/Warnings.html | 2 +- docs/configs/Warps.html | 2 +- docs/control/Jail.html | 2 +- docs/control/Production.html | 2 +- docs/control/Reports.html | 2 +- docs/control/Rockets.html | 2 +- docs/control/Tasks.html | 2 +- docs/control/Warnings.html | 2 +- docs/control/Warps.html | 2 +- docs/core/Commands.html | 2 +- docs/core/Common-Library.html | 2 +- docs/core/Gui.html | 426 +++++++++++++----- docs/core/Permissions-Groups.html | 2 +- docs/core/Roles.html | 2 +- docs/core/Store.html | 23 +- 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 | 1 + expcore/gui/concepts/checkbox.lua | 31 ++ expcore/gui/concepts/frame.lua | 4 +- expcore/gui/core.lua | 38 +- expcore/gui/prototype.lua | 95 ++-- expcore/gui/test.lua | 66 +++ expcore/store.lua | 25 +- 99 files changed, 626 insertions(+), 263 deletions(-) create mode 100644 expcore/gui/concepts/checkbox.lua diff --git a/docs/addons/Advanced-Start.html b/docs/addons/Advanced-Start.html index 9bfb5db8..d6ab1816 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 ef85f4de..8c885493 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 e234a42b..50dfd2ad 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 5e3e8756..e4eab2e0 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 f344f291..e50155aa 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 1bab19c6..8970acbb 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 46d083f3..b05ac7c8 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 2864df66..ed5370b4 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 d9dbd853..f1d7bf9b 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 76fb3326..23b5351c 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 249c3594..93872520 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 62b42001..40edeb39 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 1bcd987d..0deb5862 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 3bacbf7a..6c005bbc 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 1d6df6d3..64d9dfec 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 9bde1796..06376fb9 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 cf16472c..f42df5a9 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 2ae4c965..7e82f0a8 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 f2daf409..7c80c5c3 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 f6338385..1f44c8dd 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 022cbac6..ff0aecf6 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 c23a8a8f..38fb1fe0 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 8bba6d29..8cc80724 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 026f097c..1927d1ac 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 54cd982c..3660e26e 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 708e8b36..c49f3872 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 d19f1fbe..9707b658 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 4a8091cc..397f2426 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 8301531e..2c1ba971 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 eb3517a2..553f1e62 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 7413701a..1125bfad 100644 --- a/docs/commands/Warnings.html +++ b/docs/commands/Warnings.html @@ -569,7 +569,7 @@ generated by LDoc diff --git a/docs/configs/Advanced-Start.html b/docs/configs/Advanced-Start.html index 288e352a..849de043 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 38426477..620c2178 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 5e821e91..3ef52e69 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 90881d2b..e1920f1b 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 3222992f..4f971a75 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 9b18b862..0f55e71e 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 646e2983..1c0ba9d7 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 884ccbb3..f8330810 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 763a5a9c..26f9f2db 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 b7f20311..9aaf420f 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 2f153869..99074842 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 ac84fc48..ea16c004 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 30cf06a8..8157e15b 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 4c029621..61c55556 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 0e254751..de328a2d 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 7071d49f..e6732afc 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 410b72ab..684fb639 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 10368fd8..f75f6df3 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 7744dcc6..35a10a75 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 7153c5fa..3be5369a 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 2a2736dc..c06b2601 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 3208835a..e930a001 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 e12a5a6e..cb2aaf64 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 9cc43e14..154b9675 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 9320be9a..f7f4798f 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 16a4f5b8..4c1fae81 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 9fdc593a..3bb24976 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 0a7c702f..bf1ddd05 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 995f2cdd..e05e2c9e 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 1d7bb90c..150aa0cd 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 749a9d9e..688c1ffb 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 795dc72e..aaaf4a61 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 0c606d3e..feb78238 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 0acf379e..973cd124 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 49ed7f75..864a3443 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 62ed7797..d5aa237e 100644 --- a/docs/core/Gui.html +++ b/docs/core/Gui.html @@ -315,6 +315,10 @@ button:clone('CustomButton') The basic button element + checkbox + The basic checkbox element + + frame The basic frame element @@ -346,6 +350,18 @@ button:clone('CustomButton') clone_concept(name, new_name) Making anew concept based on the properties and drawing of another + + categorize_by_player(element) + A categorize function to be used with add_store, each player has their own category + + + categorize_by_force(element) + A categorize function to be used with add_store, each force has its own category + + + categorize_by_surface(element) + A categorize function to be used with add_store, each surface has its own category + @@ -443,16 +459,12 @@ button:clone('CustomButton') - - + + - - - - - - + +
Updates the data that is stored for this category
Prototype:define_combined_store([category_callback], get_callback, set_callback)Used to add a both instance and data stores which are linked together, new instances are synced to current value, changing one instances changes them allPrototype:define_combined_store([category_callback], sync_callback)Used to add a both instance and data stores which are linked together, new instances are synced to current value, changing one instance changes them all
Prototype.set_instance_from_store(the)Will set the state of an instance based on the value in the store
Prototype.set_store_from_instance(the)Will set the value in the store and update the other instances based on the instance givenPrototype.sync_instance(element)Will sync an instance to match the stored value based on the given sync callback
@@ -595,6 +607,103 @@ button:clone('CustomButton') + + + + + + + +
+
+
+ # + checkbox +
+
+
+
+ +

The basic checkbox element

+

+ + + Properties / Events: + +
    + + + + + +
  • + + on_state_change + + : + + + fired when the state of the element is changed + +
  • + + + + + +
  • + + caption + + : + + (string or LocalisedString) + + the message that is shown next to the checkbox + +
  • + + + + + +
  • + + tooltip + + : + + (string or LocalisedString) + + the tooltip that shows when a player hovers over the checkbox + +
  • + + + + + +
  • + + use_radio + + : + + (boolean) + + setting to true will use radio buttons rather than checkboxs + +
  • + + +
+ + + + + + + @@ -938,6 +1047,189 @@ button:change_name('Not Button') local custom_button = Gui.clone_concept('Button','CustomButton') +
+
+
+
+ # + categorize_by_player(element) +
+
+
+
+ +

A categorize function to be used with add_store, each player has their own category

+

+ + + Parameters: + +
    + + + + + +
  • + + element + + : + + (LuaGuiElement) + + the element that will be converted to a string + +
  • + + +
+ + + + + Returns: +
    +
  • + (string) + the player's name who owns this element +
  • +
+ + + + + + + + Usage: +
-- Storing data on a per player basis, can be used with instances
+Gui.get_concept('CustomButton')
+:define_data_store(Gui.categorize_by_player)
+ + +
+
+
+
+ # + categorize_by_force(element) +
+
+
+
+ +

A categorize function to be used with add_store, each force has its own category

+

+ + + Parameters: + +
    + + + + + +
  • + + element + + : + + (LuaGuiElement) + + the element that will be converted to a string + +
  • + + +
+ + + + + Returns: +
    +
  • + (string) + the player's force name who owns this element +
  • +
+ + + + + + + + Usage: +
-- Storing data on a per force basis, can be used with instances
+Gui.get_concept('CustomButton')
+:define_data_store(Gui.categorize_by_force)
+ + +
+
+
+
+ # + categorize_by_surface(element) +
+
+
+
+ +

A categorize function to be used with add_store, each surface has its own category

+

+ + + Parameters: + +
    + + + + + +
  • + + element + + : + + (LuaGuiElement) + + the element that will be converted to a string + +
  • + + +
+ + + + + Returns: +
    +
  • + (string) + the player's surface name who owns this element +
  • +
+ + + + + + + + Usage: +
-- Storing data on a per surface basis, can be used with instances
+Gui.get_concept('CustomButton')
+:define_data_store(Gui.categorize_by_surface)
+ +

Concept Base

@@ -1137,7 +1429,7 @@ button:change_name('Not Button') @@ -1201,7 +1493,7 @@ Gui.get_concept('Button'):clone(
  • (GuiConcept) - to allow chaing of functions + to allow chaining of functions
  • @@ -1392,7 +1684,7 @@ Gui.get_concept('CustomButton') @@ -1464,7 +1756,7 @@ Gui.get_concept('Button') @@ -1531,7 +1823,7 @@ Gui.get_concept('CustomButton') @@ -1687,7 +1979,7 @@ Gui.get_concept('CustomButton') @@ -1968,7 +2260,7 @@ custom_button.update_instances(1,GuiConcept) - to allow chaing of functions + to allow chaining of functions @@ -2273,13 +2565,13 @@ custom_button.update_data(1,fu
    # - Prototype:define_combined_store([category_callback], get_callback, set_callback) + Prototype:define_combined_store([category_callback], sync_callback)
    -

    Used to add a both instance and data stores which are linked together, new instances are synced to current value, changing one instances changes them all

    +

    Used to add a both instance and data stores which are linked together, new instances are synced to current value, changing one instance changes them all

    @@ -2310,29 +2602,13 @@ custom_button.update_data(1,fu
  • - get_callback + sync_callback : (function) - the function which is called when you set the store from an instance - -
  • - - - - - -
  • - - set_callback - - : - - (function) - - the function which is called when you update an instance using the value in the store + the function which is called to update an instance to match the store
  • @@ -2346,7 +2622,7 @@ custom_button.update_data(1,fu
    • (GuiConcept) - to allow chaing of functions + to allow chaining of functions
    @@ -2357,18 +2633,15 @@ custom_button.update_data(1,fu Usage: -
    -- Adding a way to sync captions bettween all instances, more useful for things that arnt buttons
    +    
    -- Adding a way to sync enabled state bettween all instances, more useful for things that arnt buttons
     local custom_button =
     Gui.get_concept('CustomButton')
     :define_combined_store(
     function(element)
         return element.player_index -- The data is stored based on player id
     end,
    -function(element)
    -   return element.caption -- We want to store the caption
    -end,
     function(element,value)
    -    element.caption = value -- This is the inverse of above
    +    element.enabled = value -- We will use custom_button.set_data(element,value) to trigger this
     end)
    @@ -2376,14 +2649,14 @@ Gui.get_concept('CustomButton')
    - # - Prototype.set_instance_from_store(the) + # + Prototype.sync_instance(element)
    -

    Will set the state of an instance based on the value in the store

    +

    Will sync an instance to match the stored value based on the given sync callback

    @@ -2397,13 +2670,13 @@ Gui.get_concept('CustomButton')
  • - the + element : (LuaGuiElement) - element that you want to have update + the element that you want to have update
  • @@ -2426,64 +2699,7 @@ Gui.get_concept('CustomButton') Gui.get_concept('CustomButton') -- Used internally when first draw and automatically when the store updates -custom_button.set_instance_from_store(element)
    - - -
    -
    -
    -
    - # - Prototype.set_store_from_instance(the) -
    -
    -
    -
    - -

    Will set the value in the store and update the other instances based on the instance given

    -

    - - - Parameters: - -
      - - - - - -
    • - - the - - : - - (LuaGuiElement) - - element that you want to use to update the store - -
    • - - -
    - - - - - - - - - - - - Usage: -
    -- Setting the stored value to be the same as the caption for this element
    -local custom_button =
    -Gui.get_concept('CustomButton')
    -
    --- You may want to use this with gui events
    -custom_button.set_store_from_instance(element)
    +custom_button.sync_instance(element)
    @@ -2575,7 +2791,7 @@ Gui.get_concept('CustomButton') generated by LDoc diff --git a/docs/core/Permissions-Groups.html b/docs/core/Permissions-Groups.html index e05ed687..8ce273b6 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 5b989791..5b5c68f6 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 937ec539..63540b54 100644 --- a/docs/core/Store.html +++ b/docs/core/Store.html @@ -309,7 +309,7 @@ Store.register(team_scores,function(value,key) Gets the value stored at a location, this location must be registered - set(location[, key], value[, from_sync=false]) + set(location[, key], value[, from_sync=false][, from_internal=false]) Sets the value at a location, this location must be registered @@ -619,7 +619,7 @@ Store.register(team_scores,function(value,key)
    # - set(location[, key], value[, from_sync=false]) + set(location[, key], value[, from_sync=false][, from_internal=false])
    @@ -700,6 +700,23 @@ Store.register(team_scores,function(value,key) + + + +
  • + + from_internal + + : + + (boolean) + + set this true to add one to the error stack offset + + (default: false) +
  • + + @@ -1128,7 +1145,7 @@ Store.register(team_scores,function(value,key) generated by LDoc diff --git a/docs/core/Sudo.html b/docs/core/Sudo.html index aabdfb54..57736aad 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 3a76fdcc..8d4129f6 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 d5144327..23ed9247 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 2e733887..f4127fd6 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 a3fa28cb..305f0f51 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 4d84021e..b61a8cca 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 d55abbff..1889fd98 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 b1e1a273..ffd338ea 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 e70f53cf..05bd835e 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 2eafdc25..7f806539 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 e5bab76d..9f62d759 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 f86ef92c..598c3b07 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 edf052c2..3a7dfed7 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 74fd5324..128f1be8 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 8898c3e4..cede62e3 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 b3a13c92..7b96850e 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 a780a4d1..a8970284 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 6c086a80..c531c9d0 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 b6ca1a92..ab702921 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 46b83cfd..5ed19e98 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 beee1b37..b04afc2a 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 8c8c821c..d7486452 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 a384e8bd..af80dc5b 100644 --- a/expcore/gui.lua +++ b/expcore/gui.lua @@ -69,5 +69,6 @@ local Gui = require 'expcore.gui.core' Gui.require_concept('frame') Gui.require_concept('button') +Gui.require_concept('checkbox') return Gui \ No newline at end of file diff --git a/expcore/gui/concepts/checkbox.lua b/expcore/gui/concepts/checkbox.lua new file mode 100644 index 00000000..050887ab --- /dev/null +++ b/expcore/gui/concepts/checkbox.lua @@ -0,0 +1,31 @@ +--[[-- Core Module - Gui + @module Gui + @alias Gui +]] + +local Gui = require 'expcore.gui.core' + +--[[-- The basic checkbox element +@element checkbox +@param on_state_change fired when the state of the element is changed +@tparam ?string|Concepts.LocalisedString caption the message that is shown next to the checkbox +@tparam ?string|Concepts.LocalisedString tooltip the tooltip that shows when a player hovers over the checkbox +@tparam boolean use_radio setting to true will use radio buttons rather than checkboxs +]] +Gui.new_concept('checkbox') +:new_event('on_state_change',defines.events.on_gui_checked_state_changed) +:new_property('tooltip') +:new_property('caption') +:new_property('default_state',false) +:new_property('use_radio',false) +:define_draw(function(properties,parent,element) + element = parent.add{ + name = properties.name, + type = properties.use_radio and 'radiobutton' or 'checkbox', + caption = properties.caption, + tooltip = properties.tooltip, + state = properties.default_state + } + + return element +end) \ No newline at end of file diff --git a/expcore/gui/concepts/frame.lua b/expcore/gui/concepts/frame.lua index c484cbe8..87c649ac 100644 --- a/expcore/gui/concepts/frame.lua +++ b/expcore/gui/concepts/frame.lua @@ -10,9 +10,7 @@ local Gui = require 'expcore.gui.core' @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) +:new_property('title') :define_draw(function(properties,parent,element) element = parent.add{ name = properties.name, diff --git a/expcore/gui/core.lua b/expcore/gui/core.lua index 5ce2ec2a..03a50a2e 100644 --- a/expcore/gui/core.lua +++ b/expcore/gui/core.lua @@ -7,7 +7,7 @@ -- Functions that act as a landing point for the other funtions -- @section core -local Event = require 'utils.event' -- @dep utils.event +local Game = require 'utils.game' -- @dep utils.game local Prototype = require 'expcore.gui.prototype' local Gui = { @@ -80,4 +80,40 @@ function Gui.clone_concept(name,new_name) return concept:clone(new_name) end +--[[-- A categorize function to be used with add_store, each player has their own category +@tparam LuaGuiElement element the element that will be converted to a string +@treturn string the player's name who owns this element +@usage-- Storing data on a per player basis, can be used with instances +Gui.get_concept('CustomButton') +:define_data_store(Gui.categorize_by_player) +]] +function Gui.categorize_by_player(element) + local player = Game.get_player_by_index(element.player_index) + return player.name +end + +--[[-- A categorize function to be used with add_store, each force has its own category +@tparam LuaGuiElement element the element that will be converted to a string +@treturn string the player's force name who owns this element +@usage-- Storing data on a per force basis, can be used with instances +Gui.get_concept('CustomButton') +:define_data_store(Gui.categorize_by_force) +]] +function Gui.categorize_by_force(element) + local player = Game.get_player_by_index(element.player_index) + return player.force.name +end + +--[[-- A categorize function to be used with add_store, each surface has its own category +@tparam LuaGuiElement element the element that will be converted to a string +@treturn string the player's surface name who owns this element +@usage-- Storing data on a per surface basis, can be used with instances +Gui.get_concept('CustomButton') +:define_data_store(Gui.categorize_by_surface) +]] +function Gui.categorize_by_surface(element) + local player = Game.get_player_by_index(element.player_index) + return player.surface.name +end + return Gui \ No newline at end of file diff --git a/expcore/gui/prototype.lua b/expcore/gui/prototype.lua index 575ae9b6..6e4f94b5 100644 --- a/expcore/gui/prototype.lua +++ b/expcore/gui/prototype.lua @@ -148,8 +148,8 @@ function Prototype:clone(concept_name) end -- Remove all refrences to a combined store - if concept.set_instance_from_store then - concept.set_instance_from_store = nil + if concept.sync_instance then + concept.sync_instance = nil concept.set_store_from_instance = nil end @@ -175,7 +175,7 @@ end @tparam string event_name the name of the event to add, must be unique, recomented to start with "on_" @tparam[opt] defines.events factorio_event when given will fire the custom event when the factorio event is raised @tparam[opt] function event_condition used to filter when a factorio event triggers the custom event; if the event contains a reference to an element then names are automatically filtered -@treturn GuiConcept to allow chaing of functions +@treturn GuiConcept to allow chaining of functions @usage-- Adds an on_admin_clicked event to fire when ever an admin clicks the button local custom_button = Gui.get_concept('Button'):clone('CustomButton') @@ -192,7 +192,7 @@ function Prototype:new_event(event_name,factorio_event,event_condition) --[[-- Adds a custom event handler, replace with the name of the event @function Prototype:on_custom_event @tparam function handler the function which will recive the event -@treturn GuiConcept to allow chaing of functions +@treturn GuiConcept to allow chaining of functions @usage-- When an admin clicks the button a message is printed local custom_button = Gui.get_concept('CustomButton') @@ -281,7 +281,7 @@ end @tparam string property_name the name of the new property, must be unique @tparam any default the default value for this property, although not strictly required is is strongly recomented @tparam[opt] function setter_callback this function is called when set is called, if not provided then key in concept.properties is updated to new value -@treturn GuiConcept to allow chaing of functions +@treturn GuiConcept to allow chaining of functions @usage-- Adding caption, sprite, and tooltip to the base button concept local button = Gui.get_concept('Button') @@ -309,7 +309,7 @@ function Prototype:new_property(property_name,default,setter_callback) --[[-- Sets a new value for a property, triggers setter method if provided, replace with property name @function Prototype:set_custom_property @tparam any value the value that you want to set for this property -@treturn GuiConcept to allow chaing of functions +@treturn GuiConcept to allow chaining of functions @usage-- Setting the caption on the base button concept after a cloning local custom_button = Gui.get_concept('Button') @@ -342,7 +342,7 @@ end --[[-- Used to define how the concept is turned into an ingame element or "instance" as we may refer to them @tparam function draw_callback the function that will be called to draw/update the instance; this function must return the instance or the new acting instance -@treturn GuiConcept to allow chaing of functions +@treturn GuiConcept to allow chaining of functions @usage-- Adding the draw define for the base button concept, we then return the element local button = Gui.get_concept('Button') @@ -415,8 +415,8 @@ function Prototype:draw(parent_element,...) end -- Syncs the instance if there is a combined store - if self.set_instance_from_store then - self.set_instance_from_store(element) + if self.sync_instance then + self.sync_instance(element) end return element @@ -428,7 +428,7 @@ end --[[-- Adds an instance store to the concept; when a new instance is made it is stored so you can access it later @tparam[opt] function category_callback when given will act as a way to turn an element into a string to act as a key; keys returned can over lap -@treturn GuiConcept to allow chaing of functions +@treturn GuiConcept to allow chaining of functions @usage-- Allowing storing instances of the custom button; stored by the players index -- Note even thou this is a copy of Button; if Button had an instance store it would not be cloned over local custom_button = @@ -442,7 +442,11 @@ function Prototype:define_instance_store(category_callback) local valid_category = category_callback and type(category_callback) == 'function' local function get_category(category) - return valid_category and type(category) == 'table' and category_callback(category) or category + if type(category) == 'table' and type(category.__self) == 'userdata' then + return valid_category and category_callback(category) or nil + else + return category + end end --[[-- Gets all insatnces in a category, category may be nil to return all @@ -494,9 +498,9 @@ custom_button.update_instances(1,function(element) end) ]] function self.update_instances(category,update_callback,...) - local arg1 + local args if type(category) == 'function' then - arg1 = update_callback + args = {update_callback,...} update_callback = category category = nil end @@ -507,7 +511,11 @@ end) instances[key] = nil end - update_callback(instance,arg1,...) + if args then + update_callback(instance,unpack(args)) + else + update_callback(instance,...) + end end end @@ -520,7 +528,7 @@ end --[[-- Adds a data store to this concept which allows you to store synced/percistent data between instances @tparam[opt] function category_callback when given will act as a way to turn an element into a string to act as a key; keys returned can over lap -@treturn GuiConcept to allow chaing of functions +@treturn GuiConcept to allow chaining of functions @usage-- Adding a way to store data for this concept; each player has their own store -- Note even thou this is a copy of Button; if Button had an data store it would not be cloned over local custom_button = @@ -540,7 +548,11 @@ function Prototype:define_data_store(category_callback) local valid_category = category_callback and type(category_callback) == 'function' local function get_category(category) - return valid_category and type(category) == 'table' and category_callback(category) or category + if type(category) == 'table' and type(category.__self) == 'userdata' then + return valid_category and category_callback(category) or nil + else + return category + end end --[[-- Gets the data that is stored for this category @@ -614,66 +626,47 @@ end) -- player index 1 return self end ---[[-- Used to add a both instance and data stores which are linked together, new instances are synced to current value, changing one instances changes them all +--[[-- Used to add a both instance and data stores which are linked together, new instances are synced to current value, changing one instance changes them all @tparam[opt] function category_callback when given will act as a way to turn an element into a string to act as a key; keys returned can over lap -@tparam function get_callback the function which is called when you set the store from an instance -@tparam function set_callback the function which is called when you update an instance using the value in the store -@treturn GuiConcept to allow chaing of functions -@usage-- Adding a way to sync captions bettween all instances, more useful for things that arnt buttons +@tparam function sync_callback the function which is called to update an instance to match the store +@treturn GuiConcept to allow chaining of functions +@usage-- Adding a way to sync enabled state bettween all instances, more useful for things that arnt buttons local custom_button = Gui.get_concept('CustomButton') :define_combined_store( function(element) return element.player_index -- The data is stored based on player id end, -function(element) - return element.caption -- We want to store the caption -end, function(element,value) - element.caption = value -- This is the inverse of above + element.enabled = value -- We will use custom_button.set_data(element,value) to trigger this end) ]] -function Prototype:define_combined_store(category_callback,get_callback,set_callback) - if set_callback == nil then - set_callback = get_callback - get_callback = category_callback +function Prototype:define_combined_store(category_callback,sync_callback) + if sync_callback == nil then + sync_callback = category_callback category_callback = nil end self:define_data_store(category_callback) - self:define_instance_Store(category_callback) + self:define_instance_store(category_callback) -- Will update all instances when the data store updates self:on_data_store_update(function(event) - self.update_instances(event.category,set_callback,event.value) + self.update_instances(event.category,sync_callback,event.value) end) ---[[-- Will set the state of an instance based on the value in the store -@function Prototype.set_instance_from_store -@tparam LuaGuiElement the element that you want to have update +--[[-- Will sync an instance to match the stored value based on the given sync callback +@function Prototype.sync_instance +@tparam LuaGuiElement element the element that you want to have update @usage-- Setting the caption of this element to be the same as the stored value local custom_button = Gui.get_concept('CustomButton') -- Used internally when first draw and automatically when the store updates -custom_button.set_instance_from_store(element) +custom_button.sync_instance(element) ]] - function self.set_instance_from_store(element) - set_callback(element,self.get_data(element)) - end - ---[[-- Will set the value in the store and update the other instances based on the instance given -@function Prototype.set_store_from_instance -@tparam LuaGuiElement the element that you want to use to update the store -@usage-- Setting the stored value to be the same as the caption for this element -local custom_button = -Gui.get_concept('CustomButton') - --- You may want to use this with gui events -custom_button.set_store_from_instance(element) -]] - function self.set_store_from_instance(element) - self.set_data(element,get_callback(element)) + function self.sync_instance(element) + sync_callback(element,self.get_data(element)) end return self diff --git a/expcore/gui/test.lua b/expcore/gui/test.lua index a4b8f56a..77877f95 100644 --- a/expcore/gui/test.lua +++ b/expcore/gui/test.lua @@ -93,6 +93,10 @@ end --[[ Buttons +> Basic Button -- Button with a caption and a tooltip +> Sprite Button -- Button with a single sprite and a tooltip +> Multi Sprite Button -- Button with three sprites and a tooltip +> Admin Button -- Button which is disabled if the player is not an admin ]] local basic_button = @@ -139,4 +143,66 @@ tests.Buttons = { ['Sprite Button'] = sprite_button, ['Multi Sprite Button'] = multi_sprite_button, ['Admin Button'] = admin_button, +} + +--[[ +Checkboxs +> Basic Checkbox -- Simple checkbox that can be toggled +> Game Stored Checkbox -- Checkbox which syncs its state between all players +> Force Stored Checkbox -- Checkbox which syncs its state with all players on the same force +> Player Stored Checkbox -- Checkbox that stores its state between re-draws +]] + +local basic_checkbox = +Gui.clone_concept('checkbox',TEST 'basic_checkbox') +:set_caption('Basic Checkbox') +:set_tooltip('Basic checkbox') +:on_state_change(function(event) + event.player.print('Basic checkbox is now: '..tostring(event.element.state)) +end) + +local game_checkbox = +Gui.clone_concept('checkbox',TEST 'game_checkbox') +:set_caption('Game Stored Checkbox') +:set_tooltip('Game stored checkbox') +:on_state_change(function(event) + local element = event.element + event.concept.set_data(element,element.state) -- Update other instances + event.player.print('Game stored checkbox is now: '..tostring(element.state)) +end) +:define_combined_store(function(element,state) + element.state = state or false +end) + +local force_checkbox = +Gui.clone_concept('checkbox',TEST 'force_checkbox') +:set_caption('Force Stored Checkbox') +:set_tooltip('Force stored checkbox') +:on_state_change(function(event) + local element = event.element + event.concept.set_data(element,element.state) -- Update other instances + event.player.print('Force stored checkbox is now: '..tostring(element.state)) +end) +:define_combined_store(function(element,state) + element.state = state or false +end) + +local player_checkbox = +Gui.clone_concept('checkbox',TEST 'player_checkbox') +:set_caption('Player Stored Checkbox') +:set_tooltip('Player stored checkbox') +:on_state_change(function(event) + local element = event.element + event.concept.set_data(element,element.state) -- Update other instances + event.player.print('Player stored checkbox is now: '..tostring(element.state)) +end) +:define_combined_store(function(element,state) + element.state = state or false +end) + +tests.Checkboxs = { + ['Basic Checkbox'] = basic_checkbox, + ['Game Stored Checkbox'] = game_checkbox, + ['Force Stored Checkbox'] = force_checkbox, + ['Player Stored Checkbox'] = player_checkbox } \ No newline at end of file diff --git a/expcore/store.lua b/expcore/store.lua index 44f29767..9358f0e3 100644 --- a/expcore/store.lua +++ b/expcore/store.lua @@ -122,14 +122,15 @@ end -- @tparam[opt] string key the key location if used -- @tparam any value the new value to set at the location, value may be reverted if there is a watch callback, cant be nil -- @tparam[opt=false] boolean from_sync set this true to avoid an output to the sync file +-- @tparam[opt=false] boolean from_internal set this true to add one to the error stack offset -- @treturn boolean true if it was successful -function Store.set(location,key,value,from_sync) - if not Store.callbacks[location] then - return error('Location is not registered', 2) +function Store.set(location,key,value,from_sync,from_internal) + if not Store.registered[location] then + return error('Location is not registered', from_internal and 3 or 2) end - if key == nil or value == nil then - value = key or value + if value == nil then + value = key key = nil end @@ -163,20 +164,24 @@ end function Store.update(location,key,update_callback,...) local value = Store.get(location,key) - local arg1 + local args if type(key) == 'function' then - arg1 = update_callback + args = {update_callback,...} update_callback = key key = nil end local rtn if update_callback and type(update_callback) == 'function' then - rtn = update_callback(value,key,arg1,...) + if args then + rtn = udpate_callback(value,key,unpack(args)) + else + rtn = update_callback(value,key,...) + end end if rtn then - Store.set(location,key,rtn) + Store.set(location,key,rtn,nil,true) else script.raise_event(Store.events.on_value_changed,{ tick=game.tick, @@ -204,7 +209,7 @@ function Store.update_all(location,update_callback,...) end if rtn then - Store.set(location,key,rtn) + Store.set(location,key,rtn,nil,true) else script.raise_event(Store.events.on_value_changed,{ tick=game.tick,