-- AltSystem Core -- Addon initialization, slash command registration, and TRP3 integration. AltSystem = AltSystem or {} AltSystem.State = { selectedSkillIndex = 1, selectedItemIndex = 1, -- 1 = No item selectedDefenseIndex = 1, -- 1 = Base armor shieldEnabled = false, } -- Initialization on ADDON_LOADED local frame = CreateFrame("Frame") frame:RegisterEvent("ADDON_LOADED") frame:SetScript("OnEvent", function(self, event, arg1) if event == "ADDON_LOADED" and arg1 == "AltSystem" then AltSystem:Init() AltSystem:RegisterTRP3Module() end end) function AltSystem:Init() -- Register slash command /altsystem SLASH_ALTSYSTEM1 = "/altsystem" SlashCmdList["ALTSYSTEM"] = function() AltSystem:ToggleWindow() end print("|cff00ccffAltSystem|r loaded. Type /altsystem to open.") end function AltSystem:ToggleWindow() if AltSystem.MainFrame then if AltSystem.MainFrame:IsShown() then AltSystem.MainFrame:Hide() else AltSystem.MainFrame:Show() end end end -- Register as a TRP3 module so our onStart runs in the correct lifecycle phase -- (after the toolbar module is initialized, but before WORKFLOW_ON_FINISH locks it) function AltSystem:RegisterTRP3Module() if not TRP3_API or not TRP3_API.module then return end local MODULE_STRUCTURE = { ["name"] = "AltSystem", ["description"] = "AltSystem rolling window toolbar button", ["version"] = 1.000, ["id"] = "altsystem_module", ["onStart"] = function() AltSystem:RegisterTRP3Button() end, ["minVersion"] = 3, ["requiredDeps"] = { {"trp3_tool_bar", 1}, }, } TRP3_API.module.registerModule(MODULE_STRUCTURE) end -- TRP3 toolbar button registration (called from the TRP3 module onStart) function AltSystem:RegisterTRP3Button() if TRP3_API and TRP3_API.toolbar then local toolbarButton = { id = "altsystem_toolbar_btn", icon = "INV_Misc_Dice_01", configText = "AltSystem", tooltip = "AltSystem", tooltipSub = "Open the AltSystem rolling window", onClick = function(_, _, button) if button == "LeftButton" then AltSystem:ToggleWindow() end end, visible = 1, } TRP3_API.toolbar.toolbarAddButton(toolbarButton) end end