diff --git a/Core.lua b/Core.lua index a2118e3..fff36a1 100644 --- a/Core.lua +++ b/Core.lua @@ -12,14 +12,11 @@ AltSystem.State = { -- Initialization on ADDON_LOADED local frame = CreateFrame("Frame") frame:RegisterEvent("ADDON_LOADED") -frame:RegisterEvent("PLAYER_LOGIN") frame:SetScript("OnEvent", function(self, event, arg1) if event == "ADDON_LOADED" and arg1 == "AltSystem" then AltSystem:Init() - elseif event == "PLAYER_LOGIN" then - AltSystem:RegisterTRP3Button() - AltSystem:RegisterMinimapButton() + AltSystem:RegisterTRP3Module() end end) @@ -43,55 +40,44 @@ function AltSystem:ToggleWindow() end end --- TRP3 toolbar button registration +-- 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 = "Interface\\Icons\\INV_Misc_Dice_02", + icon = "Interface\\Icons\\INV_Misc_Dice_01", tooltip = "AltSystem", tooltipSub = "Open the AltSystem rolling window", onClick = function() AltSystem:ToggleWindow() end, + visible = 1, } TRP3_API.toolbar.toolbarAddButton(toolbarButton) end end --- Minimap button using LibDBIcon (lightweight fallback if not available) -function AltSystem:RegisterMinimapButton() - -- Simple minimap button without external libraries - local minimapButton = CreateFrame("Button", "AltSystemMinimapButton", Minimap) - minimapButton:SetSize(32, 32) - minimapButton:SetFrameStrata("MEDIUM") - minimapButton:SetFrameLevel(8) - minimapButton:SetPoint("TOPLEFT", Minimap, "TOPLEFT", 2, -2) - - local icon = minimapButton:CreateTexture(nil, "ARTWORK") - icon:SetTexture("Interface\\Icons\\INV_Misc_Dice_02") - icon:SetSize(20, 20) - icon:SetPoint("CENTER") - - local border = minimapButton:CreateTexture(nil, "OVERLAY") - border:SetTexture("Interface\\Minimap\\MiniMap-TrackingBorder") - border:SetSize(54, 54) - border:SetPoint("TOPLEFT", -2, 2) - - minimapButton:SetHighlightTexture("Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight") - - minimapButton:SetScript("OnClick", function() - AltSystem:ToggleWindow() - end) - - minimapButton:SetScript("OnEnter", function(self) - GameTooltip:SetOwner(self, "ANCHOR_LEFT") - GameTooltip:AddLine("AltSystem") - GameTooltip:AddLine("Click to toggle the rolling window", 1, 1, 1) - GameTooltip:Show() - end) - - minimapButton:SetScript("OnLeave", function() - GameTooltip:Hide() - end) -end