From a80d0bf99dca5efbd0838aecf3a6ce6c80323d08 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Fri, 30 Aug 2019 17:13:22 +0100 Subject: [PATCH] Added dropboxs --- 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 | 202 +++- docs/core/Gui.html | 979 +++++++++++++++++- docs/core/Permissions-Groups.html | 2 +- docs/core/Roles.html | 2 +- docs/core/Store.html | 2 +- docs/core/Sudo.html | 2 +- docs/guis/Player-List.html | 2 +- docs/guis/Rocket-Info.html | 2 +- docs/guis/Science-Info.html | 2 +- docs/guis/Task-List.html | 2 +- docs/guis/Warps-List.html | 2 +- docs/index.html | 2 +- docs/modules/control.html | 2 +- .../utils.alien_evolution_progress.html | 2 +- docs/modules/utils.core.html | 2 +- docs/modules/utils.debug.html | 2 +- docs/modules/utils.dump_env.html | 2 +- docs/modules/utils.event.html | 2 +- docs/modules/utils.event_core.html | 2 +- docs/modules/utils.math.html | 2 +- docs/modules/utils.recipe_locker.html | 2 +- docs/modules/utils.state_machine.html | 2 +- docs/modules/utils.table.html | 2 +- docs/modules/utils.task.html | 2 +- docs/modules/utils.timestamp.html | 2 +- docs/topics/license.html | 2 +- docs/topics/readme.md.html | 2 +- expcore/common.lua | 63 ++ expcore/gui.lua | 1 + expcore/gui/concepts/dropdown.lua | 131 +++ expcore/gui/core.lua | 120 ++- expcore/gui/prototype.lua | 26 +- expcore/gui/test.lua | 73 ++ 98 files changed, 1651 insertions(+), 124 deletions(-) create mode 100644 expcore/gui/concepts/dropdown.lua diff --git a/docs/addons/Advanced-Start.html b/docs/addons/Advanced-Start.html index d6ab1816..92c6497c 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 8c885493..42997dda 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 50dfd2ad..0a6b6ddc 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 e4eab2e0..2cc828e8 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 e50155aa..69ec2d40 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 8970acbb..056e1548 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 b05ac7c8..afaf1aa9 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 ed5370b4..96e16e4e 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 f1d7bf9b..25c8042d 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 23b5351c..c539351c 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 93872520..c6d8352f 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 40edeb39..66ef4df0 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 0deb5862..41475286 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 6c005bbc..54cb0aae 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 64d9dfec..2225157c 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 06376fb9..4c0cd4d9 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 f42df5a9..4080a3bf 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 7e82f0a8..513a6f82 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 7c80c5c3..a9874512 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 1f44c8dd..5d1c33ce 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 ff0aecf6..bc53ef73 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 38fb1fe0..3939bda4 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 8cc80724..96da4255 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 1927d1ac..581d5060 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 3660e26e..45930e07 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 c49f3872..56c18b1c 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 9707b658..43a2dbe2 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 397f2426..fbbfe78a 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 2c1ba971..01adb40e 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 553f1e62..8ae94c19 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 1125bfad..b557bcae 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 849de043..0932b727 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 620c2178..d382d1cd 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 3ef52e69..fd54f747 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 e1920f1b..cd9471b3 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 4f971a75..fe734ead 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 0f55e71e..27b6926f 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 1c0ba9d7..8dcd4f0d 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 f8330810..a97660c0 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 26f9f2db..a9868baf 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 9aaf420f..8963df56 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 99074842..e1a09d00 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 ea16c004..14fbb6ac 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 8157e15b..d94d6f00 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 61c55556..6d8cb490 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 de328a2d..aa41c026 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 e6732afc..2779dde6 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 684fb639..80d4629f 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 f75f6df3..6d9511ad 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 35a10a75..de5e9399 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 3be5369a..a3da2d55 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 c06b2601..9b681ba8 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 e930a001..22567624 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 cb2aaf64..7909f109 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 154b9675..ac93d06c 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 f7f4798f..2930dbb9 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 4c1fae81..f27de952 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 3bb24976..8efd8a05 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 bf1ddd05..923cd2c3 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 e05e2c9e..776785df 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 150aa0cd..47f09a09 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 688c1ffb..e5b584bc 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 aaaf4a61..778c0d42 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 feb78238..5a77b232 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 973cd124..d6d5eead 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 864a3443..402b618c 100644 --- a/docs/core/Common-Library.html +++ b/docs/core/Common-Library.html @@ -361,6 +361,14 @@ get_file_path([offset=0]) Returns a desync safe file path for the current file + + array_insert(tbl[, start_index], values) + Much faster method for inserting items into an array + + + table_insert(tbl[, start_index], tbl2) + Much faster method for inserting keys into a table + @@ -2464,6 +2472,198 @@ + +
+
+
+ # + array_insert(tbl[, start_index], values) +
+
+
+
+ +

Much faster method for inserting items into an array

+

+ + + Parameters: + +
    + + + + + +
  • + + tbl + + : + + (table) + + the table that will have the values added to it + +
  • + + + + + +
  • + + start_index + + : + + (number) + + the index at which values will be added, nil means end of the array + + (optional) +
  • + + + + + +
  • + + values + + : + + (table) + + the new values that will be added to the table + +
  • + + +
+ + + + + Returns: +
    +
  • + (table) + the table that was passed as the first argument +
  • +
+ + + + + + + + Usage: +
-- Adding 1000 values into the middle of the array
+local tbl = {}
+local values = {}
+for i = 1,1000 do tbl[i] = i values[i] = i end
+Common.array_insert(tbl,500,values) -- around 0.4ms
+ + +
+
+
+
+ # + table_insert(tbl[, start_index], tbl2) +
+
+
+
+ +

Much faster method for inserting keys into a table

+

+ + + Parameters: + +
    + + + + + +
  • + + tbl + + : + + (table) + + the table that will have keys added to it + +
  • + + + + + +
  • + + start_index + + : + + (number) + + the index at which values will be added, nil means end of the array, numbered indexs only + + (optional) +
  • + + + + + +
  • + + tbl2 + + : + + (table) + + the table that may contain both string and numbered keys + +
  • + + +
+ + + + + Returns: +
    +
  • + (table) + the table passed as the first argument +
  • +
+ + + + + + + + Usage: +
-- Merging two tables
+local tbl = {}
+local tbl2 = {}
+for i = 1,100 do tbl[i] = i tbl['_'..i] = i tbl2[i] = i tbl2['__'..i] = i end
+Common.table_insert(tbl,50,tbl2)
+ +
@@ -2480,7 +2680,7 @@ generated by LDoc diff --git a/docs/core/Gui.html b/docs/core/Gui.html index d5aa237e..7fd92d98 100644 --- a/docs/core/Gui.html +++ b/docs/core/Gui.html @@ -42,10 +42,14 @@

Sections

@@ -207,10 +211,14 @@

Jump to Section

@@ -319,6 +327,10 @@ button:clone('CustomButton') The basic checkbox element + dropdown + The basic dropdown element + + frame The basic frame element @@ -326,7 +338,27 @@ button:clone('CustomButton') -

Core

+

Dropdowns

+ + + + + + + + + + + + + + + + +
set_dropdown_value(element, value)Selects the index of a dropdown with this value
get_dropdown_value(element)Gets the selected item value of a dropdown
add_dropdown_items(element[, start_index], new_items)Adds the given items into the list of items for this dropdown
+ + +

Concept Control

@@ -348,9 +380,53 @@ button:clone('CustomButton') - + + + + + +
clone_concept(name, new_name)Making anew concept based on the properties and drawing of anotherMake a new concept based on the properties and drawing of another
draw_concept(name, parent)Used to draw a concept to a parent element
+ + +

Element Control

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
get_player_from_element(element)Gets the player who owns this element
valid(element)Simple check for if an element is valid
destroy(element)Destroies and element if it is valid
toggle_enabled(element)Toggles the enabled state of an element
toggle_visible(element)Toggles the visible state of an element
set_padding(element[, up=0][, down=0][, left=0][, right=0])Sets the padding for a gui element
+ + +

Store Categories

+ + + + @@ -458,9 +534,17 @@ button:clone('CustomButton') + +
categorize_by_player(element) A categorize function to be used with add_store, each player has their own category
Prototype.update_data([category], update_callback) Updates the data that is stored for this category
+ + +

Concept Combined Instances

+ + + - + @@ -704,6 +788,119 @@ button:clone('CustomButton') + + + + + + + +
+
+
+ # + dropdown +
+
+
+
+ +

The basic dropdown element

+

+ + + Properties / Events: + +
    + + + + + +
  • + + on_selection_change + + : + + + fired when the selected value is changed + +
  • + + + + + +
  • + + default_selection + + : + + (string or Conepts.LocalisedString) + + the option which is selected by default + +
  • + + + + + +
  • + + use_list_box + + : + + (boolean) + + when true a list box will be used rather than a dropdown menu + +
  • + + + + + +
  • + + static_items + + : + + (nil or table) + + when called with a table the values will be added as items for the dropdown, if called with nil then all items are cleared + +
  • + + + + + +
  • + + dynamic_items + + : + + (function) + + the given function will be called to return a list of items and optional start index to add items to the dropdown when it is first drawn + +
  • + + +
+ + + + + + + @@ -762,7 +959,241 @@ button:clone('CustomButton')
-

Core

+

Dropdowns

+
+
+
+
+ # + set_dropdown_value(element, value) +
+
+
+
+ +

Selects the index of a dropdown with this value

+

+ + + Parameters: + +
    + + + + + +
  • + + element + + : + + (LuaGuiElement) + + the dropdown that you want to set the selection for + +
  • + + + + + +
  • + + value + + : + + (string or Conepts.LocalisedString) + + the value that you want selected + +
  • + + +
+ + + + + Returns: +
    +
  • + (boolean) + if an item with this value was found +
  • +
+ + + + + + + + Usage: +
-- Selecting the item with the value 'foo'
+Gui.set_dropdown_value(element,'foo')
+ + +
+
+
+
+ # + get_dropdown_value(element) +
+
+
+
+ +

Gets the selected item value of a dropdown

+

+ + + Parameters: + +
    + + + + + +
  • + + element + + : + + (LuaGuiElement) + + the dropdown that you want the selected value of + +
  • + + +
+ + + + + Returns: +
    +
  • + (string or Conepts.LocalisedString) + the value that is currently selected +
  • +
+ + + + + + + + Usage: +
-- Getting the selected value
+local selected_value = Gui.get_dropdown_value(element)
+ + +
+
+
+
+ # + add_dropdown_items(element[, start_index], new_items) +
+
+
+
+ +

Adds the given items into the list of items for this dropdown

+

+ + + Parameters: + +
    + + + + + +
  • + + element + + : + + (LuaGuiElement) + + the dropdown that you want to add the items to + +
  • + + + + + +
  • + + start_index + + : + + (number) + + the index at which the items will be added, if not given appened to the end + + (optional) +
  • + + + + + +
  • + + new_items + + : + + (table) + + the list of new items that you want to add + +
  • + + +
+ + + + + Returns: +
    +
  • + (table) + the list of items that the element now has +
  • +
+ + + + + + + + Usage: +
-- Add the items 'foo' and 'bar' to the end
+Gui.add_dropdown_items(element,{'foo','bar'})
+
-- Add the items 'foo' and 'bar' to the start
+Gui.add_dropdown_items(element,1,{'foo','bar'})
+ + +
+
+

Concept Control

@@ -989,7 +1420,7 @@ button:change_name('Not Button')
-

Making anew concept based on the properties and drawing of another

+

Make a new concept based on the properties and drawing of another

@@ -1051,6 +1482,513 @@ button:change_name('Not Button')
+ # + draw_concept(name, parent) +
+
+
+
+ +

Used to draw a concept to a parent element

+

+ + + Parameters: + +
    + + + + + +
  • + + name + + : + + (string) + + the name of the concept that you want to draw + +
  • + + + + + +
  • + + parent + + : + + (LuaGuiElement) + + the element that will act as a parent for the new element + +
  • + + +
+ + + + + Returns: + + + + + + + + + Usage: +
-- Drawing a new element
+Gui.draw_concept('Button',element)
+ + +
+
+

Element Control

+
+
+
+
+ # + get_player_from_element(element) +
+
+
+
+ +

Gets the player who owns this element

+

+ + + Parameters: + +
    + + + + + +
  • + + element + + : + + (LuaGuiElement) + + the element that you want to get the player of + +
  • + + +
+ + + + + Returns: +
    +
  • + (LuaPlayer) + the player who owns this element +
  • +
+ + + + + + + + Usage: +
-- Getting the player of an element
+local player = Gui.get_player_from_element(element)
+ + +
+
+
+
+ # + valid(element) +
+
+
+
+ +

Simple check for if an element is valid

+

+ + + Parameters: + +
    + + + + + +
  • + + element + + : + + (LuaGuiElement) + + the element that you want to check is valid + +
  • + + +
+ + + + + Returns: +
    +
  • + (boolean) + true if the element is valid +
  • +
+ + + + + + + + Usage: +
-- Return if not valid
+if not Gui.valid(element) then return end
+ + +
+
+
+
+ # + destroy(element) +
+
+
+
+ +

Destroies and element if it is valid

+

+ + + Parameters: + +
    + + + + + +
  • + + element + + : + + (LuaGuiElement) + + the element that you want to destroy + +
  • + + +
+ + + + + Returns: +
    +
  • + (boolean) + true if the element was valid and was destoried +
  • +
+ + + + + + + + Usage: +
-- Destoring an element
+Gui.destroy(element)
+ + +
+
+
+
+ # + toggle_enabled(element) +
+
+
+
+ +

Toggles the enabled state of an element

+

+ + + Parameters: + +
    + + + + + +
  • + + element + + : + + (LuaGuiElement) + + the element that you want to toggle the enabled state of + +
  • + + +
+ + + + + Returns: +
    +
  • + (boolean) + the new enabled state of the element +
  • +
+ + + + + + + + Usage: +
-- Toggle the enabled state of an element
+Gui.toggle_enabled(element)
+ + +
+
+
+
+ # + toggle_visible(element) +
+
+
+
+ +

Toggles the visible state of an element

+

+ + + Parameters: + +
    + + + + + +
  • + + element + + : + + (LuaGuiElement) + + the element that you want to toggle the visible state of + +
  • + + +
+ + + + + Returns: +
    +
  • + (boolean) + the new visible state of the element +
  • +
+ + + + + + + + Usage: +
-- Toggle the visible state of an element
+Gui.toggle_visible(element)
+ + +
+
+
+
+ # + set_padding(element[, up=0][, down=0][, left=0][, right=0]) +
+
+
+
+ +

Sets the padding for a gui element

+

+ + + Parameters: + +
    + + + + + +
  • + + element + + : + + (LuaGuiElement) + + the element to set the padding for + +
  • + + + + + +
  • + + up + + : + + (number or boolean) + + the amount of padding on the top, true leaves unchanged + + (default: 0) +
  • + + + + + +
  • + + down + + : + + (number or boolean) + + the amount of padding on the bottom, true leaves unchanged + + (default: 0) +
  • + + + + + +
  • + + left + + : + + (number or boolean) + + the amount of padding on the left, true leaves unchanged + + (default: 0) +
  • + + + + + +
  • + + right + + : + + (number or boolean) + + the amount of padding on the right, true leaves unchanged + + (default: 0) +
  • + + +
+ + + + + + + + + + + + Usage: +
-- Remove all padding of an element
+Gui.set_padding(element)
+
-- Remove side padding but keep vertical padding
+Gui.set_padding(element,true,true)
+
-- Remove all padding but set right to 2
+Gui.set_padding(element,false,false,false,2)
+ + +
+
+

Store Categories

+
+
+
+
# categorize_by_player(element)
@@ -2561,6 +3499,9 @@ custom_button.update_data(1,fu +
+

Concept Combined Instances

+
@@ -2571,7 +3512,7 @@ custom_button.update_data(1,fu
-

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

+

Used to add a both instance and data store which are linked together, new instances are synced to the current value, changing the stored value will change all instances

@@ -2608,7 +3549,7 @@ custom_button.update_data(1,fu (function) - the function which is called to update an instance to match the store + the function which is called to update an instance to match the store, this is called on all instances when concept.set_data or update_data is used @@ -2633,15 +3574,17 @@ custom_button.update_data(1,fu Usage: -
-- Adding a way to sync enabled state bettween all instances, more useful for things that arnt buttons
+    
-- Adding a check box which is a "global setting" synced between all players
 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,value)
-    element.enabled = value -- We will use custom_button.set_data(element,value) to trigger this
+Gui.get_concept('checkbox'):clone('my_checkbox')
+:set_caption('My Checkbox')
+:set_tooltip('Clicking this check box will change it for everyone')
+:on_state_change(function(event)
+    local element = event.element
+    event.concept.set_data(element,element.state) -- Update the stored data to trigger an update of all other instances
+end)
+:define_combined_store(function(element,state) -- We could add a category function here if we wanted to
+    element.state = state or false -- When you sync an instance this is what is called
 end)
@@ -2791,7 +3734,7 @@ Gui.get_concept('CustomButton') generated by LDoc
diff --git a/docs/core/Permissions-Groups.html b/docs/core/Permissions-Groups.html index 8ce273b6..321c7219 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 5b5c68f6..f051b7ee 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 63540b54..64239e4a 100644 --- a/docs/core/Store.html +++ b/docs/core/Store.html @@ -1145,7 +1145,7 @@ Store.register(team_scores,function(value,key) generated by LDoc diff --git a/docs/core/Sudo.html b/docs/core/Sudo.html index 57736aad..36408431 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 8d4129f6..4b079ad5 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 23ed9247..a18b977b 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 f4127fd6..096a9a61 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 305f0f51..adee14e8 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 b61a8cca..9908cbc0 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 1889fd98..bd77e448 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 ffd338ea..c3f18211 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 05bd835e..46a4497e 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 7f806539..e7420999 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 9f62d759..0f4c0a43 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 598c3b07..2c13b76c 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 3a7dfed7..6a9981fa 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 128f1be8..d52e1d2c 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 cede62e3..46f3910a 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 7b96850e..29e7512b 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 a8970284..fe3678b5 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 c531c9d0..d48d0e5a 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 ab702921..1a27b68d 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 5ed19e98..ee47361f 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 b04afc2a..1d25c8c5 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 d7486452..f68e0370 100644 --- a/docs/topics/readme.md.html +++ b/docs/topics/readme.md.html @@ -332,7 +332,7 @@ generated by LDoc diff --git a/expcore/common.lua b/expcore/common.lua index 8efb7d1b..d465e4d8 100644 --- a/expcore/common.lua +++ b/expcore/common.lua @@ -619,4 +619,67 @@ function Common.get_file_path(offset) return debug.getinfo(offset+2, 'S').source:match('^.+/currently%-playing/(.+)$'):sub(1, -5) end +--[[-- Much faster method for inserting items into an array +@tparam table tbl the table that will have the values added to it +@tparam[opt] number start_index the index at which values will be added, nil means end of the array +@tparam table values the new values that will be added to the table +@treturn table the table that was passed as the first argument +@usage-- Adding 1000 values into the middle of the array +local tbl = {} +local values = {} +for i = 1,1000 do tbl[i] = i values[i] = i end +Common.array_insert(tbl,500,values) -- around 0.4ms +]] +function Common.array_insert(tbl,start_index,values) + if not values then + values = start_index + start_index = nil + end + + if start_index then + local starting_length = #tbl + local adding_length = #values + local move_to = start_index+adding_length+1 + for offset = 0, starting_length-start_index do + tbl[move_to+offset] = tbl[starting_length+offset] + end + start_index = start_index-1 + else + start_index = #tbl + end + + for offset, item in ipairs(values) do + tbl[start_index+offset] = item + end + + return tbl +end + +--[[-- Much faster method for inserting keys into a table +@tparam table tbl the table that will have keys added to it +@tparam[opt] number start_index the index at which values will be added, nil means end of the array, numbered indexs only +@tparam table tbl2 the table that may contain both string and numbered keys +@treturn table the table passed as the first argument +@usage-- Merging two tables +local tbl = {} +local tbl2 = {} +for i = 1,100 do tbl[i] = i tbl['_'..i] = i tbl2[i] = i tbl2['__'..i] = i end +Common.table_insert(tbl,50,tbl2) +]] +function Common.table_insert(tbl,start_index,tbl2) + if not tbl2 then + tbl2 = start_index + start_index = nil + end + + Common.array_insert(tbl,start_index,tbl2) + for key, value in pairs(tbl2) do + if not tonumber(key) then + tbl[key] = value + end + end + + return tbl +end + return Common \ No newline at end of file diff --git a/expcore/gui.lua b/expcore/gui.lua index af80dc5b..4777854e 100644 --- a/expcore/gui.lua +++ b/expcore/gui.lua @@ -70,5 +70,6 @@ local Gui = require 'expcore.gui.core' Gui.require_concept('frame') Gui.require_concept('button') Gui.require_concept('checkbox') +Gui.require_concept('dropdown') return Gui \ No newline at end of file diff --git a/expcore/gui/concepts/dropdown.lua b/expcore/gui/concepts/dropdown.lua new file mode 100644 index 00000000..39064587 --- /dev/null +++ b/expcore/gui/concepts/dropdown.lua @@ -0,0 +1,131 @@ +--[[-- Core Module - Gui + @module Gui + @alias Gui +]] + +local Gui = require 'expcore.gui.core' +local array_insert = ext_require('expcore.common','array_insert') + +--[[-- The basic dropdown element +@element dropdown +@param on_selection_change fired when the selected value is changed +@tparam ?string|Conepts.LocalisedString default_selection the option which is selected by default +@tparam boolean use_list_box when true a list box will be used rather than a dropdown menu +@tparam ?nil|table static_items when called with a table the values will be added as items for the dropdown, if called with nil then all items are cleared +@tparam function dynamic_items the given function will be called to return a list of items and optional start index to add items to the dropdown when it is first drawn +]] +Gui.new_concept('dropdown') +:new_event('on_selection_change',defines.events.on_gui_selection_state_changed) +:new_property('default_selection') +:new_property('use_list_box',false) +:new_property('static_items',nil,function(properties,value,start_index) + if not value then + properties.items = {} + end + + if type(value) ~= 'table' then + value = {value} + end + + local items = properties.items + if not items then + properties.items = value + return + end + + array_insert(items,start_index,value) +end) +:new_property('dynamic_items',nil,function(properties,value) + if type(value) ~= 'function' then + error('Dynamic items must be a function') + end + + local items = properties.dynamic_items + if not items then + properties.dynamic_items = {value} + return + end + + items[#items+1] = value +end) +:define_draw(function(properties,parent,element,new_items) + local items = new_items or {} + array_insert(items,1,properties.items or {}) + + element = parent.add{ + name = properties.name, + type = properties.use_list_box and 'list-box' or 'drop-down', + items = items + } + + if properties.dynamic_items then + for _,callback in pairs(properties.dynamic_items) do + local dynamic_items, start_index = callback(element) + Gui.add_dropdown_items(element,start_index,dynamic_items) + end + end + + if properties.default_selection then + local default = properties.default_selection + if type(default) == 'function' then + default = default(element) + end + + Gui.set_dropdown_value(element,default) + end + + return element +end) + +--- Dropdowns. +-- functions used with dropdowns +-- @section dropdowns + +--[[-- Selects the index of a dropdown with this value +@tparam LuaGuiElement element the dropdown that you want to set the selection for +@tparam ?string|Conepts.LocalisedString value the value that you want selected +@treturn boolean if an item with this value was found +@usage-- Selecting the item with the value 'foo' +Gui.set_dropdown_value(element,'foo') +]] +function Gui.set_dropdown_value(element,value) + for index, item in pairs(element.items) do + if item == value then + element.selected_index = index + return true + end + end + return false +end + +--[[-- Gets the selected item value of a dropdown +@tparam LuaGuiElement element the dropdown that you want the selected value of +@treturn ?string|Conepts.LocalisedString the value that is currently selected +@usage-- Getting the selected value +local selected_value = Gui.get_dropdown_value(element) +]] +function Gui.get_dropdown_value(element) + return element.items[element.selected_index] +end + +--[[-- Adds the given items into the list of items for this dropdown +@tparam LuaGuiElement element the dropdown that you want to add the items to +@tparam[opt] number start_index the index at which the items will be added, if not given appened to the end +@tparam table new_items the list of new items that you want to add +@treturn table the list of items that the element now has +@usage-- Add the items 'foo' and 'bar' to the end +Gui.add_dropdown_items(element,{'foo','bar'}) +@usage-- Add the items 'foo' and 'bar' to the start +Gui.add_dropdown_items(element,1,{'foo','bar'}) +]] +function Gui.add_dropdown_items(element,start_index,new_items) + if not new_items then + new_items = start_index + start_index = nil + end + + local items = element.items + element.items = array_insert(items,start_index,new_items) + + return items +end \ No newline at end of file diff --git a/expcore/gui/core.lua b/expcore/gui/core.lua index 03a50a2e..6329550f 100644 --- a/expcore/gui/core.lua +++ b/expcore/gui/core.lua @@ -3,10 +3,6 @@ @alias Gui ]] ---- Core. --- Functions that act as a landing point for the other funtions --- @section core - local Game = require 'utils.game' -- @dep utils.game local Prototype = require 'expcore.gui.prototype' @@ -14,6 +10,10 @@ local Gui = { concepts = {} } +--- Concept Control. +-- Functions that act as a landing point for the other funtions +-- @section concept-control + --[[-- Loads a concept from the concepts file, used internally @tparam string concept the name of the concept to require @usage-- Load a base concept @@ -64,7 +64,7 @@ function Gui.new_concept(name) return Prototype:clone(name) end ---[[-- Making anew concept based on the properties and drawing of another +--[[-- Make a new concept based on the properties and drawing of another @tparam string name the name of the concept that you want as the base @tparam string new_name the name that you want the new concept to have @usage-- Making a new concept from another, see module usage @@ -80,6 +80,116 @@ function Gui.clone_concept(name,new_name) return concept:clone(new_name) end +--[[-- Used to draw a concept to a parent element +@tparam string name the name of the concept that you want to draw +@tparam LuaGuiElement parent the element that will act as a parent for the new element +@treturn LuaGuiElement the element that was created +@usage-- Drawing a new element +Gui.draw_concept('Button',element) +]] +function Gui.draw_concept(name,parent,...) + local concept = Gui.concepts[name] or error('Gui concept "'..name..'" is not defind',2) + + return concept:draw(parent,...) +end + +--- Element Control. +-- Functions that aim to making working with gui elements easier +-- @section element-control + +--[[-- Gets the player who owns this element +@tparam LuaGuiElement element the element that you want to get the player of +@treturn LuaPlayer the player who owns this element +@usage-- Getting the player of an element +local player = Gui.get_player_from_element(element) +]] +function Gui.get_player_from_element(element) + return Game.get_player_by_index(element.player_index) +end + +--[[-- Simple check for if an element is valid +@tparam LuaGuiElement element the element that you want to check is valid +@treturn boolean true if the element is valid +@usage-- Return if not valid +if not Gui.valid(element) then return end +]] +function Gui.valid(element) + return element and element.valid or false +end + +--[[-- Destroies and element if it is valid +@tparam LuaGuiElement element the element that you want to destroy +@treturn boolean true if the element was valid and was destoried +@usage-- Destoring an element +Gui.destroy(element) +]] +function Gui.destroy(element) + if element and element.valid then + element.destroy() + return true + end + return false +end + +--[[-- Toggles the enabled state of an element +@tparam LuaGuiElement element the element that you want to toggle the enabled state of +@treturn boolean the new enabled state of the element +@usage-- Toggle the enabled state of an element +Gui.toggle_enabled(element) +]] +function Gui.toggle_enabled(element) + if not element or not element.valid then return end + if not element.enabled then + element.enabled = true + return true + else + element.enabled = false + return false + end +end + +--[[-- Toggles the visible state of an element +@tparam LuaGuiElement element the element that you want to toggle the visible state of +@treturn boolean the new visible state of the element +@usage-- Toggle the visible state of an element +Gui.toggle_visible(element) +]] +function Gui.toggle_visible(element) + if not element or not element.valid then return end + if not element.visible then + element.visible = true + return true + else + element.visible = false + return false + end +end + +--[[-- Sets the padding for a gui element +@tparam LuaGuiElement element the element to set the padding for +@tparam[opt=0] ?number|boolean up the amount of padding on the top, true leaves unchanged +@tparam[opt=0] ?number|boolean down the amount of padding on the bottom, true leaves unchanged +@tparam[opt=0] ?number|boolean left the amount of padding on the left, true leaves unchanged +@tparam[opt=0] ?number|boolean right the amount of padding on the right, true leaves unchanged +@usage-- Remove all padding of an element +Gui.set_padding(element) +@usage-- Remove side padding but keep vertical padding +Gui.set_padding(element,true,true) +@usage-- Remove all padding but set right to 2 +Gui.set_padding(element,false,false,false,2) +]] +function Gui.set_padding(element,up,down,left,right) + local style = element.style + style.top_padding = up == true and style.top_padding or up or 0 + style.bottom_padding = down == true and style.top_padding or down or 0 + style.left_padding = left == true and style.top_padding or left or 0 + style.right_padding = right == true and style.top_padding or right or 0 +end + +--- Store Categories. +-- Functions that are common types of categories +-- @section store-categories + --[[-- 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 diff --git a/expcore/gui/prototype.lua b/expcore/gui/prototype.lua index 29426934..ee3db3c5 100644 --- a/expcore/gui/prototype.lua +++ b/expcore/gui/prototype.lua @@ -634,19 +634,25 @@ 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 instance changes them all +--- Concept Combined Instances. +-- Functions that are used to make store concept instances and data +-- @section concept-instances + +--[[-- Used to add a both instance and data store which are linked together, new instances are synced to the current value, changing the stored value will change all 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 -@tparam function sync_callback the function which is called to update an instance to match the store +@tparam function sync_callback the function which is called to update an instance to match the store, this is called on all instances when concept.set_data or update_data is used @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 +@usage-- Adding a check box which is a "global setting" synced between all players 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,value) - element.enabled = value -- We will use custom_button.set_data(element,value) to trigger this +Gui.get_concept('checkbox'):clone('my_checkbox') +:set_caption('My Checkbox') +:set_tooltip('Clicking this check box will change it for everyone') +:on_state_change(function(event) + local element = event.element + event.concept.set_data(element,element.state) -- Update the stored data to trigger an update of all other instances +end) +:define_combined_store(function(element,state) -- We could add a category function here if we wanted to + element.state = state or false -- When you sync an instance this is what is called end) ]] function Prototype:define_combined_store(category_callback,sync_callback) diff --git a/expcore/gui/test.lua b/expcore/gui/test.lua index f246cd70..b1f0aa25 100644 --- a/expcore/gui/test.lua +++ b/expcore/gui/test.lua @@ -205,4 +205,77 @@ tests.Checkboxs = { ['Game Stored Checkbox'] = game_checkbox, ['Force Stored Checkbox'] = force_checkbox, ['Player Stored Checkbox'] = player_checkbox +} + +--[[ +Dropdowns +> Static Dropdown -- Simple dropdown with all options being static +> Dynamic Dropdown -- Dropdown which has items based on when it is drawn +> Static Player Stored Dropdown -- Dropdown where the values is synced for each player +> Dynamic Player Stored Dropdown -- Same as above but now with dynamic options +]] + +local static_dropdown = +Gui.clone_concept('dropdown',TEST 'static_dropdown') +:set_static_items{'Option 1','Option 2','Option 3'} +:on_selection_change(function(event) + local value = Gui.get_dropdown_value(event.element) + event.player.print('Static dropdown is now: '..value) +end) + +local dynamic_dropdown = +Gui.clone_concept('dropdown',TEST 'dynamic_dropdown') +:set_dynamic_items(function(element) + local items = {} + for concept_name,_ in pairs(Gui.concepts) do + if concept_name:len() < 16 then + items[#items+1] = concept_name + end + end + return items +end) +:on_selection_change(function(event) + local value = Gui.get_dropdown_value(event.element) + event.player.print('Dynamic dropdown is now: '..value) +end) + +local static_player_dropdown = +Gui.clone_concept('dropdown',TEST 'static_player_dropdown') +:set_static_items{'Option 1','Option 2','Option 3'} +:on_selection_change(function(event) + local element = event.element + local value = Gui.get_dropdown_value(element) + event.concept.set_data(element,value) + event.player.print('Static player stored dropdown is now: '..value) +end) +:define_combined_store(Gui.categorize_by_player,function(element,value) + Gui.set_dropdown_value(element,value) +end) + +local dynamic_player_dropdown = +Gui.clone_concept('dropdown',TEST 'dynamic_player_dropdown') +:set_dynamic_items(function(element) + local items = {} + for concept_name,_ in pairs(Gui.concepts) do + if concept_name:len() < 16 then + items[#items+1] = concept_name + end + end + return items +end) +:on_selection_change(function(event) + local element = event.element + local value = Gui.get_dropdown_value(element) + event.concept.set_data(element,value) + event.player.print('Dynamic player dropdown is now: '..value) +end) +:define_combined_store(Gui.categorize_by_player,function(element,value) + Gui.set_dropdown_value(element,value) +end) + +tests.Dropdowns = { + ['Static Dropdown'] = static_dropdown, + ['Dynamic Dropdown'] = dynamic_dropdown, + ['Static Player Stored Dropdown'] = static_player_dropdown, + ['Dynamic Player Stored Dropdown'] = dynamic_player_dropdown } \ No newline at end of file
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 instance changes them allUsed to add a both instance and data store which are linked together, new instances are synced to the current value, changing the stored value will change all instances
Prototype.sync_instance(element)