From 0900fe13ea3f2eb4f3b6b5c12532ab4f909319bf Mon Sep 17 00:00:00 2001 From: badgamernl Date: Mon, 17 Aug 2020 23:04:20 +0200 Subject: [PATCH] Added Autofill toolbar button - May needs to be changed to have a left flow with option; --- config/_file_loader.lua | 1 + config/gui/autofill.lua | 7 +++++++ locale/en/gui.cfg | 3 +++ modules/gui/autofill.lua | 31 +++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 config/gui/autofill.lua create mode 100644 modules/gui/autofill.lua diff --git a/config/_file_loader.lua b/config/_file_loader.lua index be200bf3..12550b98 100644 --- a/config/_file_loader.lua +++ b/config/_file_loader.lua @@ -61,6 +61,7 @@ return { 'modules.gui.player-list', 'modules.gui.server-ups', 'modules.commands.debug', + 'modules.gui.autofill', --- Config Files 'config.expcore.command_auth_admin', -- commands tagged with admin_only are blocked for non admins diff --git a/config/gui/autofill.lua b/config/gui/autofill.lua new file mode 100644 index 00000000..c75cc208 --- /dev/null +++ b/config/gui/autofill.lua @@ -0,0 +1,7 @@ +--- This file contains all the different settings for the autofill system and gui +-- @config Autofill + +return { + -- General config + icon = 'item/piercing-rounds-magazine', --- @setting icon that will be used for the toolbar +} \ No newline at end of file diff --git a/locale/en/gui.cfg b/locale/en/gui.cfg index aaec09be..de1ff1e5 100644 --- a/locale/en/gui.cfg +++ b/locale/en/gui.cfg @@ -81,6 +81,9 @@ edit-tooltip=Currently being edited by: __1__ edit-tooltip-none=Currently being edited by: Nobody discard-tooltip=Remove task +[autofill] +main-tooltip=Autofill toggle + [warp-list] main-caption=Warp List main-tooltip=Warp List; Must be within __1__ tiles to use diff --git a/modules/gui/autofill.lua b/modules/gui/autofill.lua new file mode 100644 index 00000000..ac49ac09 --- /dev/null +++ b/modules/gui/autofill.lua @@ -0,0 +1,31 @@ +--[[-- Gui Module - Autofill + - Adds a button to enable Autofill + @gui Autofill + @alias autofill +]] + +local Gui = require 'expcore.gui' --- @dep expcore.gui +local Global = require 'utils.global' --- @dep utils.global +local config = require 'config.gui.autofill' --- @dep config.gui.autofill + +--- Table that stores if autofill is enabled or not +local autofill_enabled = {} +Global.register(autofill_enabled, function(tbl) + autofill_enabled = tbl +end) + +--- Button on the top flow used to toggle autofill +local toolbar_autofill_toggle +toolbar_autofill_toggle = Gui.toolbar_button(config.icon, {'autofill.main-tooltip'}) +:on_click(function(player) + local top_flow = Gui.get_top_flow(player) + local element = top_flow[toolbar_autofill_toggle.name] + if not autofill_enabled[player.name] then + autofill_enabled[player.name] = true + player.print("true") + else + autofill_enabled[player.name] = false + player.print("false") + end + Gui.toolbar_button_style(element, autofill_enabled[player.name]) +end) \ No newline at end of file