Added util methods

- Remove button from pre-existing menu
- Remove all spaces from menu
- Get index of button
This commit is contained in:
WantedDV 2023-04-11 15:16:45 -02:30
parent 149de6e77e
commit 0323addc87

View File

@ -16,6 +16,28 @@ local SetButtonState = function(button, state)
end end
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) local AddButton = function(controller, options, button, isLargeButton, index)
if button == nil then if button == nil then
return return
@ -125,5 +147,8 @@ return {
AddButton = AddButton, AddButton = AddButton,
AddLargeButton = AddLargeButton, AddLargeButton = AddLargeButton,
AddSmallButton = AddSmallButton, AddSmallButton = AddSmallButton,
AddSpacer = AddSpacer AddSpacer = AddSpacer,
RemoveButton = RemoveButton,
RemoveSpaces = RemoveSpaces,
GetButtonIndex = GetButtonIndex
} }