Remember user selections across frame instances

This commit is contained in:
Gonçalo Correia 2026-05-11 13:59:44 +01:00
parent 5b36bfdb1b
commit c27a6cd033
3 changed files with 39 additions and 6 deletions

View file

@ -4,6 +4,7 @@
AltSystem = AltSystem or {}
AltSystem.State = {
selectedSkillIndex = 1,
selectedSkillName = nil, -- skill name used to restore selection across sessions
selectedItemIndex = 1, -- 1 = No item
selectedDefenseIndex = 1, -- 1 = Base armor
shieldEnabled = false,
@ -43,6 +44,18 @@ function AltSystem:Init()
if AltSystemDB.petSummonEnabled ~= nil then
AltSystem.State.petSummonEnabled = AltSystemDB.petSummonEnabled
end
if AltSystemDB.shieldEnabled ~= nil then
AltSystem.State.shieldEnabled = AltSystemDB.shieldEnabled
end
if AltSystemDB.selectedItemIndex then
AltSystem.State.selectedItemIndex = AltSystemDB.selectedItemIndex
end
if AltSystemDB.selectedDefenseIndex then
AltSystem.State.selectedDefenseIndex = AltSystemDB.selectedDefenseIndex
end
if AltSystemDB.selectedSkillName then
AltSystem.State.selectedSkillName = AltSystemDB.selectedSkillName
end
-- Register slash command /altsystem
SLASH_ALTSYSTEM1 = "/altsystem"
@ -58,8 +71,15 @@ function AltSystem:Init()
AltSystemDB.announceEnabled = AltSystem.State.announceEnabled
AltSystemDB.announceChannelIndex = AltSystem.State.announceChannelIndex
AltSystemDB.petSummonEnabled = AltSystem.State.petSummonEnabled
AltSystemDB.shieldEnabled = AltSystem.State.shieldEnabled
AltSystemDB.selectedItemIndex = AltSystem.State.selectedItemIndex
AltSystemDB.selectedDefenseIndex = AltSystem.State.selectedDefenseIndex
AltSystemDB.selectedSkillName = AltSystem.State.selectedSkillName
end)
-- Build the main frame now that saved variables are loaded
AltSystem:CreateMainFrame()
print("|cff00ccffAltSystem|r loaded. Type /altsystem to open.")
end