From 0323addc8760b968b5137bdc1161929d2b478f09 Mon Sep 17 00:00:00 2001 From: WantedDV <122710241+WantedDV@users.noreply.github.com> Date: Tue, 11 Apr 2023 15:16:45 -0230 Subject: [PATCH] Added util methods - Remove button from pre-existing menu - Remove all spaces from menu - Get index of button --- data/ui_scripts/frontend_menus/utils.lua | 27 +++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/data/ui_scripts/frontend_menus/utils.lua b/data/ui_scripts/frontend_menus/utils.lua index d8190895..78b18d65 100644 --- a/data/ui_scripts/frontend_menus/utils.lua +++ b/data/ui_scripts/frontend_menus/utils.lua @@ -16,6 +16,28 @@ local SetButtonState = function(button, state) end end +local RemoveButton = function(buttonTable, button) + for id, v in pairs(buttonTable) do + if buttonTable[id].optionDisplay == button.stringRef then + table.remove(buttonTable,id) + end + end +end + +local RemoveSpaces = function(buttonTable) + for id, v in pairs(buttonTable) do + buttonTable[id].isLastButtonInGroup = false + end +end + +local GetButtonIndex = function(buttonTable, button) + for id, v in pairs(buttonTable) do + if buttonTable[id].optionDisplay == button.stringRef then + return id + end + end +end + local AddButton = function(controller, options, button, isLargeButton, index) if button == nil then return @@ -125,5 +147,8 @@ return { AddButton = AddButton, AddLargeButton = AddLargeButton, AddSmallButton = AddSmallButton, - AddSpacer = AddSpacer + AddSpacer = AddSpacer, + RemoveButton = RemoveButton, + RemoveSpaces = RemoveSpaces, + GetButtonIndex = GetButtonIndex }