diff --git a/Core/MultiBot.lua b/Core/MultiBot.lua index 6af2ad4..667ecc9 100644 --- a/Core/MultiBot.lua +++ b/Core/MultiBot.lua @@ -1,5 +1,12 @@ MultiBot = CreateFrame("Frame", nil, UIParent) +-- MASQUE INTEGRATION -- +MultiBot.Masque = { + IsLoaded = false, + Group = nil, + Buttons = {} +} + -- GM core -- MultiBot.GM = MultiBot.GM or false @@ -301,6 +308,75 @@ function MultiBot.ToggleFavorite(name) MultiBot.SetFavorite(name, not MultiBot.IsFavorite(name)) end +-- ============================================================================ +-- MASQUE INTEGRATION +-- ============================================================================ + +-- Initialize Masque support +function MultiBot.InitializeMasque() + if MultiBot.Masque.IsLoaded then return end + + local Masque = LibStub and LibStub("Masque", true) + if not Masque then + return + end + + -- Create MultiBot button group + MultiBot.Masque.Group = Masque:Group("MultiBot", "MultiBot Buttons") + MultiBot.Masque.IsLoaded = true + + -- Apply current skin to existing buttons + if MultiBot.Masque.Group then + for button, _ in pairs(MultiBot.Masque.Buttons) do + if button and button:IsObjectType("Button") then + MultiBot.Masque.Group:AddButton(button, { + Icon = button.icon, + Normal = button:GetNormalTexture(), + Pushed = button:GetPushedTexture(), + Highlight = button:GetHighlightTexture(), + Border = button.border + }) + end + end + end +end + +-- Register a button with Masque +function MultiBot.RegisterButtonWithMasque(button) + if not MultiBot.Masque.IsLoaded then + MultiBot.InitializeMasque() + end + + if not MultiBot.Masque.IsLoaded or not button then return end + + -- Store button reference + MultiBot.Masque.Buttons[button] = true + + -- Add to Masque group if available + if MultiBot.Masque.Group and button.icon then + MultiBot.Masque.Group:AddButton(button, { + Icon = button.icon, + Normal = button:GetNormalTexture(), + Pushed = button:GetPushedTexture(), + Highlight = button:GetHighlightTexture(), + Border = button.border + }) + end +end + +-- Unregister a button from Masque +function MultiBot.UnregisterButtonFromMasque(button) + if not MultiBot.Masque.IsLoaded or not button then return end + + -- Remove from tracking + MultiBot.Masque.Buttons[button] = nil + + -- Remove from Masque group + if MultiBot.Masque.Group then + MultiBot.Masque.Group:RemoveButton(button) + end +end + MultiBot.timer = {} MultiBot.timer.sort = {} MultiBot.timer.sort.elapsed = 0 @@ -3709,6 +3785,12 @@ MultiBot.tips.every.misc = "|cffff0000Left-click to toggle this menu|r\n".. "|cff999999(Execution order: System)|r" +--[[MultiBot.tips.every.pvp = +"Send PvP command to bot|cffffffff\n".. +"Display pvp bots informations.|r\n\n".. +"|cffff0000Left-click to send command|r\n".. +"|cff999999(Execution order: Bot)|r";--]] + MultiBot.tips.every.pvptitle = "MultiBot PvP Panel"; diff --git a/Core/MultiBotEngine.lua b/Core/MultiBotEngine.lua index ed3dcaa..69a7a0b 100644 --- a/Core/MultiBotEngine.lua +++ b/Core/MultiBotEngine.lua @@ -1061,6 +1061,11 @@ MultiBot.newButton = function(pParent, pX, pY, pSize, pTexture, pTip, oTemplate) button:HookScript("OnShow", function() if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end end) button:HookScript("OnHide", function() if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end end) + -- Register with Masque if available + if MultiBot.RegisterButtonWithMasque then + MultiBot.RegisterButtonWithMasque(button) + end + -- ADD -- button.addMacro = function(pType, pMacro) @@ -1082,7 +1087,10 @@ MultiBot.newButton = function(pParent, pX, pY, pSize, pTexture, pTip, oTemplate) button.setButton = function(texture, tip) local safe = MultiBot.SafeTexturePath(texture) button.icon:SetTexture(safe) - button.icon:SetAllPoints(button) + -- Only reset icon positioning if not managed by Masque + if not (MultiBot.Masque and MultiBot.Masque.IsLoaded and MultiBot.Masque.Buttons[button]) then + button.icon:SetAllPoints(button) + end button.texture = safe button.tip = tip return button @@ -1091,7 +1099,10 @@ MultiBot.newButton = function(pParent, pX, pY, pSize, pTexture, pTip, oTemplate) button.setTexture = function(texture) local safe = MultiBot.SafeTexturePath(texture) button.icon:SetTexture(safe) - button.icon:SetAllPoints(button) + -- Only reset icon positioning if not managed by Masque + if not (MultiBot.Masque and MultiBot.Masque.IsLoaded and MultiBot.Masque.Buttons[button]) then + button.icon:SetAllPoints(button) + end button.texture = safe return button end @@ -1181,22 +1192,26 @@ MultiBot.newButton = function(pParent, pX, pY, pSize, pTexture, pTip, oTemplate) end) button:SetScript("OnLeave", function() - button:SetPoint("BOTTOMRIGHT", button.x, button.y) - button:SetSize(button.size, button.size) - - button.border:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 2, -2) - button.border:SetSize(button.size + 4, button.size + 4) + -- Don't reset positioning if button is managed by Masque + if not (MultiBot.Masque and MultiBot.Masque.IsLoaded and MultiBot.Masque.Buttons[button]) then + button:SetPoint("BOTTOMRIGHT", button.x, button.y) + button:SetSize(button.size, button.size) + button.border:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 2, -2) + button.border:SetSize(button.size + 4, button.size + 4) + end if(type(button.tip) == "string") then GameTooltip:Hide() end if(type(button.tip) == "table") then button.tip:Hide() end end) button:SetScript("PostClick", function(pSelf, pEvent) - button:SetPoint("BOTTOMRIGHT", button.x - 1, button.y + 1) - button:SetSize(button.size - 2, button.size - 2) - - button.border:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 2, -2) - button.border:SetSize(button.size + 2, button.size + 2) + -- Don't modify positioning if button is managed by Masque + if not (MultiBot.Masque and MultiBot.Masque.IsLoaded and MultiBot.Masque.Buttons[button]) then + button:SetPoint("BOTTOMRIGHT", button.x - 1, button.y + 1) + button:SetSize(button.size - 2, button.size - 2) + button.border:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 2, -2) + button.border:SetSize(button.size + 2, button.size + 2) + end if(type(button.tip) == "string") then GameTooltip:Hide() end if(type(button.tip) == "table") then button.tip:Hide() end @@ -1205,6 +1220,14 @@ MultiBot.newButton = function(pParent, pX, pY, pSize, pTexture, pTip, oTemplate) if(pEvent == "LeftButton" and button.doLeft ~= nil) then button.doLeft(button) end end) + -- CLEANUP -- + button.cleanup = function() + if MultiBot.UnregisterButtonFromMasque then + MultiBot.UnregisterButtonFromMasque(button) + end + return button + end + return button end diff --git a/Core/MultiBotHandler.lua b/Core/MultiBotHandler.lua index 18b80b0..db4bcb1 100644 --- a/Core/MultiBotHandler.lua +++ b/Core/MultiBotHandler.lua @@ -137,6 +137,9 @@ MultiBot:SetScript("OnEvent", function() if MultiBot.EnsureFavorites then MultiBot.EnsureFavorites() end if MultiBot.UpdateFavoritesIndex then MultiBot.UpdateFavoritesIndex() end + -- Initialize Masque support + if MultiBot.InitializeMasque then MultiBot.InitializeMasque() end + -- [AJOUT] init config + applique timers + enregistre le panneau d'options if MultiBot.Config_Ensure then MultiBot.Config_Ensure() end if MultiBot.ApplyTimersToRuntime then MultiBot.ApplyTimersToRuntime() end