From 5a9392f10885280e8bd3e87ff2c6590fc82982b2 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Sun, 21 Jul 2019 20:28:28 +0100 Subject: [PATCH] Added Tasks to control --- doc/control/Jail.html | 3 +- doc/control/Production.html | 3 +- doc/control/Reports.html | 3 +- doc/control/Tasks.html | 998 ++++++++++++++++++ doc/control/Warnings.html | 3 +- doc/index.html | 7 +- doc/modules/config._file_loader.html | 3 +- doc/modules/config.action_buttons.html | 3 +- doc/modules/config.advanced_start.html | 3 +- doc/modules/config.bonuses.html | 3 +- doc/modules/config.chat_reply.html | 3 +- doc/modules/config.death_logger.html | 3 +- doc/modules/config.discord_alerts.html | 3 +- .../config.expcore-commands.auth_admin.html | 3 +- .../config.expcore-commands.auth_roles.html | 3 +- ...expcore-commands.auth_runtime_disable.html | 3 +- ...config.expcore-commands.parse_general.html | 3 +- .../config.expcore-commands.parse_roles.html | 3 +- doc/modules/config.permission_groups.html | 3 +- doc/modules/config.popup_messages.html | 3 +- doc/modules/config.rockets.html | 3 +- doc/modules/config.roles.html | 3 +- doc/modules/config.scorched_earth.html | 3 +- doc/modules/config.spawn_area.html | 3 +- doc/modules/config.warnings.html | 3 +- doc/modules/config.warps.html | 3 +- doc/modules/control.html | 3 +- doc/modules/expcore.commands.html | 3 +- doc/modules/expcore.common.html | 3 +- doc/modules/expcore.gui.concepts.center.html | 3 +- doc/modules/expcore.gui.concepts.left.html | 3 +- doc/modules/expcore.gui.concepts.popups.html | 3 +- doc/modules/expcore.gui.concepts.toolbar.html | 3 +- doc/modules/expcore.gui.core.html | 3 +- doc/modules/expcore.gui.elements.buttons.html | 3 +- .../expcore.gui.elements.checkboxs.html | 3 +- .../expcore.gui.elements.dropdown.html | 3 +- .../expcore.gui.elements.elem-button.html | 3 +- .../expcore.gui.elements.progress-bar.html | 3 +- doc/modules/expcore.gui.elements.slider.html | 3 +- doc/modules/expcore.gui.elements.text.html | 3 +- doc/modules/expcore.gui.html | 3 +- doc/modules/expcore.gui.instances.html | 3 +- doc/modules/expcore.gui.prototype.html | 3 +- doc/modules/expcore.gui.test.html | 3 +- doc/modules/expcore.permission_groups.html | 3 +- doc/modules/expcore.roles.html | 3 +- doc/modules/expcore.store.html | 3 +- doc/modules/expcore.sudo.html | 3 +- .../modules.addons.advanced-start.html | 3 +- doc/modules/modules.addons.chat-popups.html | 3 +- doc/modules/modules.addons.damage-popups.html | 3 +- doc/modules/modules.gui.player-list.html | 3 +- doc/modules/modules.gui.rocket-info.html | 3 +- doc/modules/modules.gui.science-info.html | 3 +- doc/modules/modules.gui.task-list.html | 3 +- .../utils.alien_evolution_progress.html | 3 +- doc/modules/utils.core.html | 3 +- doc/modules/utils.debug.html | 3 +- doc/modules/utils.event.html | 3 +- doc/modules/utils.event_core.html | 3 +- doc/modules/utils.math.html | 3 +- doc/modules/utils.recipe_locker.html | 3 +- doc/modules/utils.state_machine.html | 3 +- doc/modules/utils.table.html | 3 +- doc/modules/utils.task.html | 3 +- doc/modules/utils.timestamp.html | 3 +- doc/topics/license.html | 3 +- doc/topics/readme.md.html | 3 +- modules/control/tasks.lua | 180 ++++ modules/gui/task-list.lua | 86 +- 71 files changed, 1333 insertions(+), 139 deletions(-) create mode 100644 doc/control/Tasks.html create mode 100644 modules/control/tasks.lua diff --git a/doc/control/Jail.html b/doc/control/Jail.html index d9623087..ad4f9c45 100644 --- a/doc/control/Jail.html +++ b/doc/control/Jail.html @@ -55,6 +55,7 @@ + @@ -1161,7 +1162,7 @@ generated by LDoc diff --git a/doc/control/Production.html b/doc/control/Production.html index 96469f11..9ed008fd 100644 --- a/doc/control/Production.html +++ b/doc/control/Production.html @@ -55,6 +55,7 @@ + @@ -1276,7 +1277,7 @@ generated by LDoc diff --git a/doc/control/Reports.html b/doc/control/Reports.html index 70203f0c..19b67119 100644 --- a/doc/control/Reports.html +++ b/doc/control/Reports.html @@ -55,6 +55,7 @@ + @@ -1025,7 +1026,7 @@ generated by LDoc diff --git a/doc/control/Tasks.html b/doc/control/Tasks.html new file mode 100644 index 00000000..99b1a5b8 --- /dev/null +++ b/doc/control/Tasks.html @@ -0,0 +1,998 @@ + + + + + + + + Tasks control + + + + + + + +
+
+ + + + + + + +
+ + + + + + + + +

Tasks control

+

Control Module - Tasks + - Stores tasks for each force.

+

+ + + + + + +

Usage

+

+    -- import the module from the control modules
+    local Tasks = require 'modules.control.tasks'
+
+    -- To create a new task all you need is the name of the force you want to add the task to
+    -- you can give a place to add it but this is optional
+    Tasks.new_task('player')
+
+    -- You can then update this task to what ever value that you want
+    -- the task id is returned by new_task, or within an update handler
+    -- if a player name is not given that it will assume '<server>'
+    Tasks.update_task(task_id,'My number one task!','Cooldude2606')
+
+    -- You can then remove the task and all data linked with it
+    Tasks.remove_task(task_id)
+
+    -- set_editing and is_editing may be used to block other or provide warnings
+    -- none of this is enforced by this module and so you must do so in your own module
+    Tasks.set_editing(task_id,'Cooldude2606',true)
+ + + + + + + +

Dependencies

+ + + + + + + + + + + + + + + + +
expcore.storeAllows storing of task ids
utils.globalAllows storing in the global table
utils.tokenAllows non conflicting task ids
+ + +

Getters

+ + + + + + + + + + + + + + + + + + + + +
get_task(task_id)Gets the task stored at this id
get_details(task_id)Gets the task details stored at this id
get_force_tasks(force_name)Gets the task ids for a force
is_editing(task_id, player_name)Gets if a player is currently editing this task
+ + +

Setters

+ + + + + + + + + + + + + + + + + + + + + + + + +
add_handler(callback)Adds a new handler for when a task is updated
new_task(force_name[, task_number][, player_name])Adds a new task for a force, with option to place it in a certain order
remove_task(task_id)Removes a task and all data linked with it
update_task(task_id, task[, player_name='server'])Updates a task message
set_editing(task_id, player_name[, state])Sets a player to be editing this task, used with is_editing
+ + +
+ + +

Dependencies

+
+
+
+
+ # + expcore.store +
+
+
+
+ +

Allows storing of task ids

+

+ + + + + + + + + + + + + + +
+
+
+
+ # + utils.global +
+
+
+
+ +

Allows storing in the global table

+

+ + + + + + + + + + + + + + +
+
+
+
+ # + utils.token +
+
+
+
+ +

Allows non conflicting task ids

+

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

Getters

+
+
+
+
+ # + get_task(task_id) +
+
+
+
+ +

Gets the task stored at this id

+

+ + + Parameters: + +
    + + + + + +
  • + + task_id + + : + + (string) + + the uid of the task you want to get + +
  • + + +
+ + + + + Returns: +
    +
  • + (string) + the task message that was stored here +
  • +
+ + + + + + + + + +
+
+
+
+ # + get_details(task_id) +
+
+
+
+ +

Gets the task details stored at this id

+

+ + + Parameters: + +
    + + + + + +
  • + + task_id + + : + + (string) + + the uid of the task you want to get + +
  • + + +
+ + + + + Returns: +
    +
  • + (table) + the task details that was stored here +
  • +
+ + + + + + + + + +
+
+
+
+ # + get_force_tasks(force_name) +
+
+
+
+ +

Gets the task ids for a force

+

+ + + Parameters: + +
    + + + + + +
  • + + force_name + + : + + (string) + + the name of the force that you want the ids for + +
  • + + +
+ + + + + Returns: +
    +
  • + (table) + an array of all the task ids +
  • +
+ + + + + + + + + +
+
+
+
+ # + is_editing(task_id, player_name) +
+
+
+
+ +

Gets if a player is currently editing this task

+

+ + + Parameters: + +
    + + + + + +
  • + + task_id + + : + + (string) + + the uid of the task you want to check + +
  • + + + + + +
  • + + player_name + + : + + (string) + + the name of the player that you want to check + +
  • + + +
+ + + + + Returns: +
    +
  • + (boolean) + weather the player is currently editing this task +
  • +
+ + + + + + + + + +
+
+

Setters

+
+
+
+
+ # + add_handler(callback) +
+
+
+
+ +

Adds a new handler for when a task is updated

+

+ + + Parameters: + +
    + + + + + +
  • + + callback + + : + + (function) + + the callback which is ran when a task is updated + +
  • + + +
+ + + + + Returns: +
    +
  • + (boolean) + true if the callback was added +
  • +
+ + + + + + + + + +
+
+
+
+ # + new_task(force_name[, task_number][, player_name]) +
+
+
+
+ +

Adds a new task for a force, with option to place it in a certain order

+

+ + + Parameters: + +
    + + + + + +
  • + + force_name + + : + + (string) + + the name of the force to add the task for + +
  • + + + + + +
  • + + task_number + + : + + (number) + + the order place to add the task to, adds to end if omited + + (optional) +
  • + + + + + +
  • + + player_name + + : + + (string) + + when given this player will be added to the editing list + + (optional) +
  • + + +
+ + + + + Returns: +
    +
  • + (string) + the uid of the task which was created +
  • +
+ + + + + + + + + +
+
+
+
+ # + remove_task(task_id) +
+
+
+
+ +

Removes a task and all data linked with it

+

+ + + Parameters: + +
    + + + + + +
  • + + task_id + + : + + (string) + + the uid of the task which you want to remove + +
  • + + +
+ + + + + + + + + + + + + +
+
+
+
+ # + update_task(task_id, task[, player_name='server']) +
+
+
+
+ +

Updates a task message

+

+ + + Parameters: + +
    + + + + + +
  • + + task_id + + : + + (string) + + the uid of the task that you want to update + +
  • + + + + + +
  • + + task + + : + + (string) + + the message that you want to change the task to + +
  • + + + + + +
  • + + player_name + + : + + (string) + + the name of the player who made the edit + + (default: 'server') +
  • + + +
+ + + + + + + + + + + + + +
+
+
+
+ # + set_editing(task_id, player_name[, state]) +
+
+
+
+ +

Sets a player to be editing this task, used with is_editing

+

+ + + Parameters: + +
    + + + + + +
  • + + task_id + + : + + (string) + + the uid of the task that you want to editing for + +
  • + + + + + +
  • + + player_name + + : + + (string) + + the name of the player you want to set editing for + +
  • + + + + + +
  • + + state + + : + + (boolean) + + the new state to set editing to + + (optional) +
  • + + +
+ + + + + + + + + + + + + +
+
+ + + +
+
+
+ + + + diff --git a/doc/control/Warnings.html b/doc/control/Warnings.html index ad54c40d..591baa1b 100644 --- a/doc/control/Warnings.html +++ b/doc/control/Warnings.html @@ -54,6 +54,7 @@ + @@ -1418,7 +1419,7 @@ generated by LDoc diff --git a/doc/index.html b/doc/index.html index 2f1bd13c..e9655050 100644 --- a/doc/index.html +++ b/doc/index.html @@ -60,6 +60,11 @@ - Adds a way to report players and store report messages. + Tasks + Control Module - Tasks + - Stores tasks for each force. + + Warnings Control Module - Warnings - Adds a way to give and remove warnings to players. @@ -386,7 +391,7 @@ generated by LDoc diff --git a/doc/modules/config._file_loader.html b/doc/modules/config._file_loader.html index e45bf570..65a02b9a 100644 --- a/doc/modules/config._file_loader.html +++ b/doc/modules/config._file_loader.html @@ -112,6 +112,7 @@ + @@ -181,7 +182,7 @@ generated by LDoc diff --git a/doc/modules/config.action_buttons.html b/doc/modules/config.action_buttons.html index 9f8cd67c..925b8ee8 100644 --- a/doc/modules/config.action_buttons.html +++ b/doc/modules/config.action_buttons.html @@ -112,6 +112,7 @@ + @@ -182,7 +183,7 @@ generated by LDoc diff --git a/doc/modules/config.advanced_start.html b/doc/modules/config.advanced_start.html index 35002e99..101947cb 100644 --- a/doc/modules/config.advanced_start.html +++ b/doc/modules/config.advanced_start.html @@ -112,6 +112,7 @@ + @@ -178,7 +179,7 @@ generated by LDoc diff --git a/doc/modules/config.bonuses.html b/doc/modules/config.bonuses.html index 9357c133..d563a677 100644 --- a/doc/modules/config.bonuses.html +++ b/doc/modules/config.bonuses.html @@ -112,6 +112,7 @@ + @@ -178,7 +179,7 @@ generated by LDoc diff --git a/doc/modules/config.chat_reply.html b/doc/modules/config.chat_reply.html index 93ca50ab..3a386346 100644 --- a/doc/modules/config.chat_reply.html +++ b/doc/modules/config.chat_reply.html @@ -112,6 +112,7 @@ + @@ -178,7 +179,7 @@ generated by LDoc diff --git a/doc/modules/config.death_logger.html b/doc/modules/config.death_logger.html index 3afffecb..86e4c6ac 100644 --- a/doc/modules/config.death_logger.html +++ b/doc/modules/config.death_logger.html @@ -112,6 +112,7 @@ + @@ -180,7 +181,7 @@ generated by LDoc diff --git a/doc/modules/config.discord_alerts.html b/doc/modules/config.discord_alerts.html index 428ad476..703540ea 100644 --- a/doc/modules/config.discord_alerts.html +++ b/doc/modules/config.discord_alerts.html @@ -112,6 +112,7 @@ + @@ -178,7 +179,7 @@ generated by LDoc diff --git a/doc/modules/config.expcore-commands.auth_admin.html b/doc/modules/config.expcore-commands.auth_admin.html index 8fe3a0bf..8836a4c3 100644 --- a/doc/modules/config.expcore-commands.auth_admin.html +++ b/doc/modules/config.expcore-commands.auth_admin.html @@ -112,6 +112,7 @@ + @@ -180,7 +181,7 @@ generated by LDoc diff --git a/doc/modules/config.expcore-commands.auth_roles.html b/doc/modules/config.expcore-commands.auth_roles.html index 8f12223e..3f91f6cc 100644 --- a/doc/modules/config.expcore-commands.auth_roles.html +++ b/doc/modules/config.expcore-commands.auth_roles.html @@ -112,6 +112,7 @@ + @@ -178,7 +179,7 @@ generated by LDoc diff --git a/doc/modules/config.expcore-commands.auth_runtime_disable.html b/doc/modules/config.expcore-commands.auth_runtime_disable.html index a083d17b..7b6d4728 100644 --- a/doc/modules/config.expcore-commands.auth_runtime_disable.html +++ b/doc/modules/config.expcore-commands.auth_runtime_disable.html @@ -112,6 +112,7 @@ + @@ -179,7 +180,7 @@ generated by LDoc diff --git a/doc/modules/config.expcore-commands.parse_general.html b/doc/modules/config.expcore-commands.parse_general.html index 6d096641..78105732 100644 --- a/doc/modules/config.expcore-commands.parse_general.html +++ b/doc/modules/config.expcore-commands.parse_general.html @@ -112,6 +112,7 @@ + @@ -182,7 +183,7 @@ generated by LDoc diff --git a/doc/modules/config.expcore-commands.parse_roles.html b/doc/modules/config.expcore-commands.parse_roles.html index c13160a5..0468d949 100644 --- a/doc/modules/config.expcore-commands.parse_roles.html +++ b/doc/modules/config.expcore-commands.parse_roles.html @@ -112,6 +112,7 @@ + @@ -178,7 +179,7 @@ generated by LDoc diff --git a/doc/modules/config.permission_groups.html b/doc/modules/config.permission_groups.html index 35ccf13f..9cffe3c0 100644 --- a/doc/modules/config.permission_groups.html +++ b/doc/modules/config.permission_groups.html @@ -112,6 +112,7 @@ + @@ -181,7 +182,7 @@ generated by LDoc diff --git a/doc/modules/config.popup_messages.html b/doc/modules/config.popup_messages.html index 04b2f383..10125ac4 100644 --- a/doc/modules/config.popup_messages.html +++ b/doc/modules/config.popup_messages.html @@ -112,6 +112,7 @@ + @@ -178,7 +179,7 @@ generated by LDoc diff --git a/doc/modules/config.rockets.html b/doc/modules/config.rockets.html index 5f7b3940..376adb6d 100644 --- a/doc/modules/config.rockets.html +++ b/doc/modules/config.rockets.html @@ -120,6 +120,7 @@ + @@ -267,7 +268,7 @@ generated by LDoc diff --git a/doc/modules/config.roles.html b/doc/modules/config.roles.html index f6da5f49..9deddbdd 100644 --- a/doc/modules/config.roles.html +++ b/doc/modules/config.roles.html @@ -112,6 +112,7 @@ + @@ -178,7 +179,7 @@ generated by LDoc diff --git a/doc/modules/config.scorched_earth.html b/doc/modules/config.scorched_earth.html index 7243d5f3..05be80a1 100644 --- a/doc/modules/config.scorched_earth.html +++ b/doc/modules/config.scorched_earth.html @@ -112,6 +112,7 @@ + @@ -178,7 +179,7 @@ generated by LDoc diff --git a/doc/modules/config.spawn_area.html b/doc/modules/config.spawn_area.html index a9e56975..481105d9 100644 --- a/doc/modules/config.spawn_area.html +++ b/doc/modules/config.spawn_area.html @@ -112,6 +112,7 @@ + @@ -178,7 +179,7 @@ generated by LDoc diff --git a/doc/modules/config.warnings.html b/doc/modules/config.warnings.html index 4a0abcbf..8b6301c6 100644 --- a/doc/modules/config.warnings.html +++ b/doc/modules/config.warnings.html @@ -112,6 +112,7 @@ + @@ -178,7 +179,7 @@ generated by LDoc diff --git a/doc/modules/config.warps.html b/doc/modules/config.warps.html index 4ab0f337..e1daa0f9 100644 --- a/doc/modules/config.warps.html +++ b/doc/modules/config.warps.html @@ -112,6 +112,7 @@ + @@ -178,7 +179,7 @@ generated by LDoc diff --git a/doc/modules/control.html b/doc/modules/control.html index 2b0a8faa..33844193 100644 --- a/doc/modules/control.html +++ b/doc/modules/control.html @@ -112,6 +112,7 @@ + @@ -181,7 +182,7 @@ generated by LDoc diff --git a/doc/modules/expcore.commands.html b/doc/modules/expcore.commands.html index 8ad73e0c..4c31a2f2 100644 --- a/doc/modules/expcore.commands.html +++ b/doc/modules/expcore.commands.html @@ -112,6 +112,7 @@ + @@ -182,7 +183,7 @@ generated by LDoc diff --git a/doc/modules/expcore.common.html b/doc/modules/expcore.common.html index df619b63..e31c5f07 100644 --- a/doc/modules/expcore.common.html +++ b/doc/modules/expcore.common.html @@ -120,6 +120,7 @@ + @@ -2265,7 +2266,7 @@ generated by LDoc diff --git a/doc/modules/expcore.gui.concepts.center.html b/doc/modules/expcore.gui.concepts.center.html index 8ee49171..70f42555 100644 --- a/doc/modules/expcore.gui.concepts.center.html +++ b/doc/modules/expcore.gui.concepts.center.html @@ -120,6 +120,7 @@ + @@ -923,7 +924,7 @@ generated by LDoc diff --git a/doc/modules/expcore.gui.concepts.left.html b/doc/modules/expcore.gui.concepts.left.html index 85a9072f..379a1f23 100644 --- a/doc/modules/expcore.gui.concepts.left.html +++ b/doc/modules/expcore.gui.concepts.left.html @@ -120,6 +120,7 @@ + @@ -1189,7 +1190,7 @@ generated by LDoc diff --git a/doc/modules/expcore.gui.concepts.popups.html b/doc/modules/expcore.gui.concepts.popups.html index b8201ba2..d2ce677d 100644 --- a/doc/modules/expcore.gui.concepts.popups.html +++ b/doc/modules/expcore.gui.concepts.popups.html @@ -121,6 +121,7 @@ + @@ -669,7 +670,7 @@ generated by LDoc diff --git a/doc/modules/expcore.gui.concepts.toolbar.html b/doc/modules/expcore.gui.concepts.toolbar.html index 95e47031..5bf59e25 100644 --- a/doc/modules/expcore.gui.concepts.toolbar.html +++ b/doc/modules/expcore.gui.concepts.toolbar.html @@ -120,6 +120,7 @@ + @@ -376,7 +377,7 @@ generated by LDoc diff --git a/doc/modules/expcore.gui.core.html b/doc/modules/expcore.gui.core.html index b5fda828..b44c870c 100644 --- a/doc/modules/expcore.gui.core.html +++ b/doc/modules/expcore.gui.core.html @@ -112,6 +112,7 @@ + @@ -181,7 +182,7 @@ generated by LDoc diff --git a/doc/modules/expcore.gui.elements.buttons.html b/doc/modules/expcore.gui.elements.buttons.html index 4bdd4416..9b91013f 100644 --- a/doc/modules/expcore.gui.elements.buttons.html +++ b/doc/modules/expcore.gui.elements.buttons.html @@ -120,6 +120,7 @@ + @@ -519,7 +520,7 @@ generated by LDoc diff --git a/doc/modules/expcore.gui.elements.checkboxs.html b/doc/modules/expcore.gui.elements.checkboxs.html index fc410d2e..c999b155 100644 --- a/doc/modules/expcore.gui.elements.checkboxs.html +++ b/doc/modules/expcore.gui.elements.checkboxs.html @@ -120,6 +120,7 @@ + @@ -837,7 +838,7 @@ generated by LDoc diff --git a/doc/modules/expcore.gui.elements.dropdown.html b/doc/modules/expcore.gui.elements.dropdown.html index b55272de..30597af7 100644 --- a/doc/modules/expcore.gui.elements.dropdown.html +++ b/doc/modules/expcore.gui.elements.dropdown.html @@ -120,6 +120,7 @@ + @@ -699,7 +700,7 @@ generated by LDoc diff --git a/doc/modules/expcore.gui.elements.elem-button.html b/doc/modules/expcore.gui.elements.elem-button.html index 73ed011e..f1c6593f 100644 --- a/doc/modules/expcore.gui.elements.elem-button.html +++ b/doc/modules/expcore.gui.elements.elem-button.html @@ -121,6 +121,7 @@ + @@ -395,7 +396,7 @@ generated by LDoc diff --git a/doc/modules/expcore.gui.elements.progress-bar.html b/doc/modules/expcore.gui.elements.progress-bar.html index 98cbaee5..c769c914 100644 --- a/doc/modules/expcore.gui.elements.progress-bar.html +++ b/doc/modules/expcore.gui.elements.progress-bar.html @@ -120,6 +120,7 @@ + @@ -1140,7 +1141,7 @@ generated by LDoc diff --git a/doc/modules/expcore.gui.elements.slider.html b/doc/modules/expcore.gui.elements.slider.html index 11f0858c..9e1c7fe9 100644 --- a/doc/modules/expcore.gui.elements.slider.html +++ b/doc/modules/expcore.gui.elements.slider.html @@ -120,6 +120,7 @@ + @@ -470,7 +471,7 @@ generated by LDoc diff --git a/doc/modules/expcore.gui.elements.text.html b/doc/modules/expcore.gui.elements.text.html index 1eac057c..7cc63511 100644 --- a/doc/modules/expcore.gui.elements.text.html +++ b/doc/modules/expcore.gui.elements.text.html @@ -120,6 +120,7 @@ + @@ -516,7 +517,7 @@ generated by LDoc diff --git a/doc/modules/expcore.gui.html b/doc/modules/expcore.gui.html index 60a00594..f40c4ecf 100644 --- a/doc/modules/expcore.gui.html +++ b/doc/modules/expcore.gui.html @@ -112,6 +112,7 @@ + @@ -179,7 +180,7 @@ generated by LDoc diff --git a/doc/modules/expcore.gui.instances.html b/doc/modules/expcore.gui.instances.html index 77efa0e8..52be8241 100644 --- a/doc/modules/expcore.gui.instances.html +++ b/doc/modules/expcore.gui.instances.html @@ -112,6 +112,7 @@ + @@ -179,7 +180,7 @@ generated by LDoc diff --git a/doc/modules/expcore.gui.prototype.html b/doc/modules/expcore.gui.prototype.html index 43fabdef..c2a17297 100644 --- a/doc/modules/expcore.gui.prototype.html +++ b/doc/modules/expcore.gui.prototype.html @@ -121,6 +121,7 @@ + @@ -1410,7 +1411,7 @@ generated by LDoc diff --git a/doc/modules/expcore.gui.test.html b/doc/modules/expcore.gui.test.html index 5422e9b1..08d6dc0e 100644 --- a/doc/modules/expcore.gui.test.html +++ b/doc/modules/expcore.gui.test.html @@ -112,6 +112,7 @@ + @@ -180,7 +181,7 @@ generated by LDoc diff --git a/doc/modules/expcore.permission_groups.html b/doc/modules/expcore.permission_groups.html index 4d39da49..b6c5b3a4 100644 --- a/doc/modules/expcore.permission_groups.html +++ b/doc/modules/expcore.permission_groups.html @@ -120,6 +120,7 @@ + @@ -1218,7 +1219,7 @@ generated by LDoc diff --git a/doc/modules/expcore.roles.html b/doc/modules/expcore.roles.html index cb7ff959..a615db33 100644 --- a/doc/modules/expcore.roles.html +++ b/doc/modules/expcore.roles.html @@ -120,6 +120,7 @@ + @@ -2690,7 +2691,7 @@ generated by LDoc diff --git a/doc/modules/expcore.store.html b/doc/modules/expcore.store.html index f31b0a8b..81ffe376 100644 --- a/doc/modules/expcore.store.html +++ b/doc/modules/expcore.store.html @@ -120,6 +120,7 @@ + @@ -765,7 +766,7 @@ generated by LDoc diff --git a/doc/modules/expcore.sudo.html b/doc/modules/expcore.sudo.html index c149e62e..98ac29e0 100644 --- a/doc/modules/expcore.sudo.html +++ b/doc/modules/expcore.sudo.html @@ -112,6 +112,7 @@ + @@ -179,7 +180,7 @@ generated by LDoc diff --git a/doc/modules/modules.addons.advanced-start.html b/doc/modules/modules.addons.advanced-start.html index 245a26b1..978deeac 100644 --- a/doc/modules/modules.addons.advanced-start.html +++ b/doc/modules/modules.addons.advanced-start.html @@ -112,6 +112,7 @@ + @@ -178,7 +179,7 @@ generated by LDoc diff --git a/doc/modules/modules.addons.chat-popups.html b/doc/modules/modules.addons.chat-popups.html index 252a3408..28a8c0db 100644 --- a/doc/modules/modules.addons.chat-popups.html +++ b/doc/modules/modules.addons.chat-popups.html @@ -112,6 +112,7 @@ + @@ -179,7 +180,7 @@ generated by LDoc diff --git a/doc/modules/modules.addons.damage-popups.html b/doc/modules/modules.addons.damage-popups.html index b4f59422..3d72477d 100644 --- a/doc/modules/modules.addons.damage-popups.html +++ b/doc/modules/modules.addons.damage-popups.html @@ -112,6 +112,7 @@ + @@ -179,7 +180,7 @@ generated by LDoc diff --git a/doc/modules/modules.gui.player-list.html b/doc/modules/modules.gui.player-list.html index f3f0393d..6c29676f 100644 --- a/doc/modules/modules.gui.player-list.html +++ b/doc/modules/modules.gui.player-list.html @@ -112,6 +112,7 @@ + @@ -178,7 +179,7 @@ generated by LDoc diff --git a/doc/modules/modules.gui.rocket-info.html b/doc/modules/modules.gui.rocket-info.html index 14166426..fa840f3a 100644 --- a/doc/modules/modules.gui.rocket-info.html +++ b/doc/modules/modules.gui.rocket-info.html @@ -120,6 +120,7 @@ + @@ -236,7 +237,7 @@ generated by LDoc diff --git a/doc/modules/modules.gui.science-info.html b/doc/modules/modules.gui.science-info.html index 139afbf9..768b8fbc 100644 --- a/doc/modules/modules.gui.science-info.html +++ b/doc/modules/modules.gui.science-info.html @@ -112,6 +112,7 @@ + @@ -178,7 +179,7 @@ generated by LDoc diff --git a/doc/modules/modules.gui.task-list.html b/doc/modules/modules.gui.task-list.html index aaf86258..441ada3f 100644 --- a/doc/modules/modules.gui.task-list.html +++ b/doc/modules/modules.gui.task-list.html @@ -112,6 +112,7 @@ + @@ -178,7 +179,7 @@ generated by LDoc diff --git a/doc/modules/utils.alien_evolution_progress.html b/doc/modules/utils.alien_evolution_progress.html index 0f397ea5..5a755f92 100644 --- a/doc/modules/utils.alien_evolution_progress.html +++ b/doc/modules/utils.alien_evolution_progress.html @@ -120,6 +120,7 @@ + @@ -263,7 +264,7 @@ fraction will decide a chance to spawn. 1 alien for 2 spawners will have 50% on generated by LDoc diff --git a/doc/modules/utils.core.html b/doc/modules/utils.core.html index e6a70362..ed4b920e 100644 --- a/doc/modules/utils.core.html +++ b/doc/modules/utils.core.html @@ -121,6 +121,7 @@ + @@ -970,7 +971,7 @@ generated by LDoc diff --git a/doc/modules/utils.debug.html b/doc/modules/utils.debug.html index 44eeeb11..21cbca24 100644 --- a/doc/modules/utils.debug.html +++ b/doc/modules/utils.debug.html @@ -120,6 +120,7 @@ + @@ -595,7 +596,7 @@ generated by LDoc diff --git a/doc/modules/utils.event.html b/doc/modules/utils.event.html index fcff8fa4..91796216 100644 --- a/doc/modules/utils.event.html +++ b/doc/modules/utils.event.html @@ -120,6 +120,7 @@ + @@ -1108,7 +1109,7 @@ generated by LDoc diff --git a/doc/modules/utils.event_core.html b/doc/modules/utils.event_core.html index 633fb342..19c1bce3 100644 --- a/doc/modules/utils.event_core.html +++ b/doc/modules/utils.event_core.html @@ -120,6 +120,7 @@ + @@ -375,7 +376,7 @@ generated by LDoc diff --git a/doc/modules/utils.math.html b/doc/modules/utils.math.html index acadd8c5..312b3480 100644 --- a/doc/modules/utils.math.html +++ b/doc/modules/utils.math.html @@ -120,6 +120,7 @@ + @@ -279,7 +280,7 @@ generated by LDoc diff --git a/doc/modules/utils.recipe_locker.html b/doc/modules/utils.recipe_locker.html index f3b36daa..e053bcb9 100644 --- a/doc/modules/utils.recipe_locker.html +++ b/doc/modules/utils.recipe_locker.html @@ -120,6 +120,7 @@ + @@ -260,7 +261,7 @@ generated by LDoc diff --git a/doc/modules/utils.state_machine.html b/doc/modules/utils.state_machine.html index 13adc7f5..c8a69a34 100644 --- a/doc/modules/utils.state_machine.html +++ b/doc/modules/utils.state_machine.html @@ -120,6 +120,7 @@ + @@ -652,7 +653,7 @@ generated by LDoc diff --git a/doc/modules/utils.table.html b/doc/modules/utils.table.html index fb703842..0755a4f3 100644 --- a/doc/modules/utils.table.html +++ b/doc/modules/utils.table.html @@ -121,6 +121,7 @@ + @@ -1282,7 +1283,7 @@ generated by LDoc diff --git a/doc/modules/utils.task.html b/doc/modules/utils.task.html index da2183dd..2b8fcbb0 100644 --- a/doc/modules/utils.task.html +++ b/doc/modules/utils.task.html @@ -120,6 +120,7 @@ + @@ -377,7 +378,7 @@ generated by LDoc diff --git a/doc/modules/utils.timestamp.html b/doc/modules/utils.timestamp.html index 4d2b4fb2..3ab4ce29 100644 --- a/doc/modules/utils.timestamp.html +++ b/doc/modules/utils.timestamp.html @@ -120,6 +120,7 @@ + @@ -383,7 +384,7 @@ generated by LDoc diff --git a/doc/topics/license.html b/doc/topics/license.html index 47d594ee..b3ae6425 100644 --- a/doc/topics/license.html +++ b/doc/topics/license.html @@ -53,6 +53,7 @@ + @@ -730,7 +731,7 @@ Public License instead of this License. But first, please read generated by LDoc diff --git a/doc/topics/readme.md.html b/doc/topics/readme.md.html index ae36365e..cc8ddc79 100644 --- a/doc/topics/readme.md.html +++ b/doc/topics/readme.md.html @@ -53,6 +53,7 @@ + @@ -270,7 +271,7 @@ generated by LDoc diff --git a/modules/control/tasks.lua b/modules/control/tasks.lua new file mode 100644 index 00000000..e755b141 --- /dev/null +++ b/modules/control/tasks.lua @@ -0,0 +1,180 @@ +--[[-- Control Module - Tasks + - Stores tasks for each force. + @control Tasks + @alias Tasks + + @usage + -- import the module from the control modules + local Tasks = require 'modules.control.tasks' + + -- To create a new task all you need is the name of the force you want to add the task to + -- you can give a place to add it but this is optional + Tasks.new_task('player') + + -- You can then update this task to what ever value that you want + -- the task id is returned by new_task, or within an update handler + -- if a player name is not given that it will assume '' + Tasks.update_task(task_id,'My number one task!','Cooldude2606') + + -- You can then remove the task and all data linked with it + Tasks.remove_task(task_id) + + -- set_editing and is_editing may be used to block other or provide warnings + -- none of this is enforced by this module and so you must do so in your own module + Tasks.set_editing(task_id,'Cooldude2606',true) + +]] + +--- Allows storing of task ids +-- @dep expcore.store +local Store = require 'expcore.store' +--- Allows storing in the global table +-- @dep utils.global +local Global = require 'utils.global' +--- Allows non conflicting task ids +-- @dep utils.token +local Token = require 'utils.token' + +local Tasks = { + store = 'gui.left.task-list.tasks', + handlers = {}, + details = {}, + forces = {} +} + +local task_details = Tasks.details +local force_tasks = Tasks.forces +Global.register({ + task_details=task_details, + force_tasks=force_tasks +},function(tbl) + task_details = tbl.task_details + force_tasks = tbl.force_tasks +end) + +local task_store = Tasks.store +Store.register(task_store,function(value,task_id) + local details = task_details[task_id] + local force = game.forces[details.force] + for _,handler in pairs(Tasks.handlers) do + handler(force,task_id) + end +end) + +--- Setters. +-- functions used to created and alter tasks +-- @section setters + +--- Adds a new handler for when a task is updated +-- @tparam function callback the callback which is ran when a task is updated +-- @treturn boolean true if the callback was added +function Tasks.add_handler(callback) + if type(callback) == 'function' then + table.insert(Tasks.handlers,callback) + return true + end + return false +end + +--- Adds a new task for a force, with option to place it in a certain order +-- @tparam string force_name the name of the force to add the task for +-- @tparam[opt] number task_number the order place to add the task to, adds to end if omited +-- @tparam[opt] string player_name when given this player will be added to the editing list +-- @treturn string the uid of the task which was created +function Tasks.new_task(force_name,task_number,player_name) + local task_id = tostring(Token.uid()) + + local tasks = force_tasks[force_name] + if not tasks then + force_tasks[force_name] = {} + tasks = force_tasks[force_name] + end + + if task_number then + table.insert(tasks,task_number,task_id) + else + table.insert(tasks,task_id) + end + + task_details[task_id] = { + task_id=task_id, + force=force_name, + last_edit_player='', + last_edit_time=game.tick, + editing={} + } + + if player_name then + task_details[task_id].editing[player_name] = true + end + + Store.set(task_store,task_id,'New Task') + + return task_id +end + +--- Removes a task and all data linked with it +-- @tparam string task_id the uid of the task which you want to remove +function Tasks.remove_task(task_id) + local details = task_details[task_id] + local force = details.force + Store.clear(task_store,task_id) + task_details[task_id] = nil + table.remove_element(force_tasks[force],task_id) +end + +--- Updates a task message +-- @tparam string task_id the uid of the task that you want to update +-- @tparam string task the message that you want to change the task to +-- @tparam[opt='server'] string player_name the name of the player who made the edit +function Tasks.update_task(task_id,task,player_name) + local details = task_details[task_id] + details.last_edit_player = player_name or '' + details.last_edit_player = game.tick + Store.set(task_store,task_id,task) +end + +--- Sets a player to be editing this task, used with is_editing +-- @tparam string task_id the uid of the task that you want to editing for +-- @tparam string player_name the name of the player you want to set editing for +-- @tparam[opt] boolean state the new state to set editing to +function Tasks.set_editing(task_id,player_name,state) + local details = task_details[task_id] + details.editing[player_name] = state +end + +--- Getters. +-- function used to get information about tasks +-- @section getters + +--- Gets the task stored at this id +-- @tparam string task_id the uid of the task you want to get +-- @treturn string the task message that was stored here +function Tasks.get_task(task_id) + return Store.get(task_store,task_id) +end + +--- Gets the task details stored at this id +-- @tparam string task_id the uid of the task you want to get +-- @treturn table the task details that was stored here +function Tasks.get_details(task_id) + return task_details[task_id] +end + +--- Gets the task ids for a force +-- @tparam string force_name the name of the force that you want the ids for +-- @treturn table an array of all the task ids +function Tasks.get_force_tasks(force_name) + return force_tasks[force_name] or {} +end + +--- Gets if a player is currently editing this task +-- @tparam string task_id the uid of the task you want to check +-- @tparam string player_name the name of the player that you want to check +-- @treturn boolean weather the player is currently editing this task +function Tasks.is_editing(task_id,player_name) + local details = task_details[task_id] + return details.editing[player_name] +end + +return Tasks \ No newline at end of file diff --git a/modules/gui/task-list.lua b/modules/gui/task-list.lua index 2a4a4374..ad6565e9 100644 --- a/modules/gui/task-list.lua +++ b/modules/gui/task-list.lua @@ -1,61 +1,15 @@ --- Adds a task list to the game which players can add remove and edit items on local Gui = require 'expcore.gui' -local Store = require 'expcore.store' -local Global = require 'utils.global' local Event = require 'utils.event' local Roles = require 'expcore.roles' -local Token = require 'utils.token' local config = require 'config.tasks' local format_time,table_keys = ext_require('expcore.common','format_time','table_keys') - -local task_store = 'gui.left.task-list.tasks' - -local task_details = {} -local force_tasks = {} -Global.register({ - task_details=task_details, - force_tasks=force_tasks -},function(tbl) - task_details = tbl.task_details - force_tasks = tbl.force_tasks -end) - ---- Adds a new task for this force with this players name attached -local function add_task(player,task_number) - local task_id = tostring(Token.uid()) - - if not force_tasks[player.force.name] then - force_tasks[player.force.name] = {} - end - if task_number then - table.insert(force_tasks[player.force.name],task_number,task_id) - else - table.insert(force_tasks[player.force.name],task_id) - end - - task_details[task_id] = { - task_id=task_id, - force=player.force.name, - last_edit_player=player.name, - last_edit_time=game.tick, - editing={[player.name]=true} - } - - Store.set(task_store,task_id,'New task') -end - ---- Removes all refrences to a task -local function remove_task(task_id) - local force_name = task_details[task_id].force - Store.clear(task_store,task_id) - task_details[task_id] = nil - table.remove_element(force_tasks[force_name],task_id) -end +local Tasks = require 'modules.control.tasks' --- If a player is allowed to use the edit buttons local function player_allowed_edit(player,task_id) if task_id then - local details = task_details[task_id] + local details = Tasks.get_details(task_id) if config.user_can_edit_own_tasks and details.last_edit_player == player.name then return true end @@ -88,7 +42,7 @@ Gui.new_button() style.width = 20 end) :on_click(function(player,element) - add_task(player) + Tasks.new_task(player.force.name,nil,player.name) end) --- Used to save changes to a task @@ -104,11 +58,8 @@ end) :on_click(function(player,element) local task_id = element.parent.name local task = element.parent.task.text - local details = task_details[task_id] - details.editing[player.name] = nil - details.last_edit_player = player.name - details.last_edit_time = game.tick - Store.set(task_store,task_id,task) + Tasks.set_editing(task_id,player.name) + Tasks.update_task(task_id,task,player.name) end) --- Used to cancel any changes you made to a task @@ -124,8 +75,7 @@ Gui.new_button() end) :on_click(function(player,element) local task_id = element.parent.name - local details = task_details[task_id] - details.editing[player.name] = nil + Tasks.set_editing(task_id,player.name) generate_task(player,element.parent.parent,task_id) end) @@ -141,7 +91,7 @@ Gui.new_button() end) :on_click(function(player,element) local task_id = element.parent.name - remove_task(task_id) + Tasks.remove_task(task_id) update_all() end) @@ -157,8 +107,7 @@ Gui.new_button() end) :on_click(function(player,element) local task_id = element.parent.name - local details = task_details[task_id] - details.editing[player.name] = true + Tasks.set_editing(task_id,player.name,true) generate_task(player,element.parent.parent.parent,task_id) end) @@ -175,12 +124,12 @@ end) >> discard_task ]] function generate_task(player,element,task_id) - local task = Store.get(task_store,task_id) - local details = task_details[task_id] - local editing = details.editing[player.name] + local task = Tasks.get_task(task_id) + local editing = Tasks.is_editing(task_id,player.name) + local details = Tasks.get_details(task_id) local last_edit_player = details.last_edit_player local last_edit_time = details.last_edit_time - local tasks = force_tasks[player.force.name] + local tasks = Tasks.get_force_tasks(player.force.name) local task_number = table.index_of(tasks, task_id) if not task then @@ -351,18 +300,16 @@ Gui.new_left_frame('gui/task-list') :set_open_by_default() :on_creation(function(player,element) local data_table = generate_container(player,element) - local force_name = player.force.name + local tasks = Tasks.get_force_tasks(player.force.name) - local tasks = force_tasks[force_name] or {} for _,task_id in pairs(tasks) do generate_task(player,data_table,task_id) end end) :on_update(function(player,element) local data_table = element.container.scroll.table - local force_name = player.force.name + local tasks = Tasks.get_force_tasks(player.force.name) - local tasks = force_tasks[force_name] or {} for _,task_id in pairs(tasks) do generate_task(player,data_table,task_id) end @@ -371,10 +318,7 @@ end) update_all = task_list 'update_all' --- When a new task is added it will udpate the task list for everyone on that force -Store.register(task_store,function(value,task_id) - local details = task_details[task_id] - local force = game.forces[details.force] - +Tasks.add_handler(function(force,task_id) for _,player in pairs(force.players) do local frame = task_list:get_frame(player) local element = frame.container.scroll.table