This commit is contained in:
Gonçalo Correia 2026-05-12 16:20:52 +01:00
parent a4b2e69cc8
commit ffc693a63c
4 changed files with 487 additions and 241 deletions

View file

@ -6,11 +6,14 @@ AltSystem.State = {
selectedSkillIndex = 1,
selectedSkillName = nil, -- skill name used to restore selection across sessions
selectedItemIndex = 1, -- 1 = No item
selectedDefenseIndex = 1, -- 1 = Base armor
selectedDefenseIndex = 1, -- 1 = No Armor
shieldEnabled = false,
petSummonEnabled = false,
announceEnabled = false,
announceChannelIndex = 1, -- 1 = Emote, 2 = Party, 3 = Raid, 4 = Guild
rollType = "attack", -- "attack" or "defense"
announceOptionIndex = 1, -- 1 = Self Roll, 2+ = channel from AnnounceChannels
rollLog = {}, -- array of { text = "...", timestamp = time() }, max 100, not persisted
}
-- Channel definitions for announcing rolls
@ -35,12 +38,6 @@ end)
function AltSystem:Init()
-- Load saved settings
AltSystemDB = AltSystemDB or {}
if AltSystemDB.announceEnabled ~= nil then
AltSystem.State.announceEnabled = AltSystemDB.announceEnabled
end
if AltSystemDB.announceChannelIndex then
AltSystem.State.announceChannelIndex = AltSystemDB.announceChannelIndex
end
if AltSystemDB.petSummonEnabled ~= nil then
AltSystem.State.petSummonEnabled = AltSystemDB.petSummonEnabled
end
@ -56,6 +53,28 @@ function AltSystem:Init()
if AltSystemDB.selectedSkillName then
AltSystem.State.selectedSkillName = AltSystemDB.selectedSkillName
end
if AltSystemDB.rollType then
AltSystem.State.rollType = AltSystemDB.rollType
end
-- Migrate from old announce settings or load new announceOptionIndex
if AltSystemDB.announceOptionIndex then
AltSystem.State.announceOptionIndex = AltSystemDB.announceOptionIndex
elseif AltSystemDB.announceEnabled ~= nil then
-- Backwards compat: derive from old announceEnabled + announceChannelIndex
if AltSystemDB.announceEnabled and AltSystemDB.announceChannelIndex then
AltSystem.State.announceOptionIndex = AltSystemDB.announceChannelIndex + 1
else
AltSystem.State.announceOptionIndex = 1
end
end
-- Derive announceEnabled and announceChannelIndex from announceOptionIndex
if AltSystem.State.announceOptionIndex > 1 then
AltSystem.State.announceEnabled = true
AltSystem.State.announceChannelIndex = AltSystem.State.announceOptionIndex - 1
else
AltSystem.State.announceEnabled = false
AltSystem.State.announceChannelIndex = 1
end
-- Register slash command /altsystem
SLASH_ALTSYSTEM1 = "/altsystem"
@ -68,13 +87,13 @@ function AltSystem:Init()
saveFrame:RegisterEvent("PLAYER_LOGOUT")
saveFrame:SetScript("OnEvent", function()
AltSystemDB = AltSystemDB or {}
AltSystemDB.announceEnabled = AltSystem.State.announceEnabled
AltSystemDB.announceChannelIndex = AltSystem.State.announceChannelIndex
AltSystemDB.announceOptionIndex = AltSystem.State.announceOptionIndex
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
AltSystemDB.rollType = AltSystem.State.rollType
end)
-- Build the main frame now that saved variables are loaded