Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.

Commit b553dc2

Browse files
committed
Fixe Miss clicks on quest tracker and other UI elements according to the position of MB
1 parent d841c6e commit b553dc2

1 file changed

Lines changed: 180 additions & 0 deletions

File tree

Core/MultiBotEngine.lua

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ MultiBot.SelectToTarget = function(pParent, pIndex, pTexture, pAction, oTarget)
603603
local tButton = pParent.buttons[pIndex]
604604
tButton.setTexture(pTexture)
605605
tFrame:Hide()
606+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(tFrame) end
606607
return true
607608
end
608609

@@ -615,6 +616,7 @@ MultiBot.SelectToTargetButton = function(pParent, pIndex, pTexture, pAction, oTa
615616
tButton.doLeft = function(pButton) MultiBot.ActionToTarget(pAction, oTarget) end
616617
tButton.setTexture(pTexture)
617618
tFrame:Hide()
619+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(tFrame) end
618620
return true
619621
end
620622

@@ -624,6 +626,7 @@ MultiBot.SelectToGroupButtonWithTarget = function(pParent, pIndex, pTexture, pAc
624626
tButton.doLeft = function(pButton) if(MultiBot.isTarget()) then MultiBot.ActionToGroup(pAction) end end
625627
tButton.setTexture(pTexture)
626628
tFrame:Hide()
629+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(tFrame) end
627630
return true
628631
end
629632

@@ -633,6 +636,7 @@ MultiBot.SelectToGroupButton = function(pParent, pIndex, pTexture, pAction)
633636
tButton.doLeft = function(pButton) MultiBot.ActionToGroup(pAction) end
634637
tButton.setTexture(pTexture)
635638
tFrame:Hide()
639+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(tFrame) end
636640
return true
637641
end
638642

@@ -642,6 +646,7 @@ MultiBot.SelectToGroup = function(pParent, pIndex, pTexture, pAction)
642646
local tButton = pParent.buttons[pIndex]
643647
tButton.setTexture(pTexture)
644648
tFrame:Hide()
649+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(tFrame) end
645650
return true
646651
end
647652

@@ -653,16 +658,19 @@ MultiBot.Select = function(pParent, pIndex, pTexture)
653658
local tButton = pParent.buttons[pIndex]
654659
tButton.setTexture(pTexture)
655660
tFrame:Hide()
661+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(tFrame) end
656662
return true
657663
end
658664

659665
MultiBot.ShowHideSwitch = function(pFrame)
660666
if(pFrame:IsVisible()) then
661667
pFrame:Hide()
668+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(pFrame) end
662669
return false
663670
end
664671

665672
pFrame:Show()
673+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(pFrame) end
666674
return true
667675
end
668676

@@ -688,6 +696,114 @@ MultiBot.OnOffSwitch = function(pButton)
688696
return true
689697
end
690698

699+
-- CLICK BLOCKER --
700+
-- Fond invisible placé sous les barres de boutons (et leurs zones extensibles) afin
701+
-- d'empêcher les clics de "traverser" l'UI dans les espaces entre boutons.
702+
703+
MultiBot._clickBlockerQueue = MultiBot._clickBlockerQueue or {}
704+
705+
local function _mbQueueClickBlockerUpdate(f)
706+
if(not f or not f.clickBlocker) then return end
707+
MultiBot._clickBlockerQueue[f] = true
708+
709+
if(not MultiBot._clickBlockerTicker) then
710+
MultiBot._clickBlockerTicker = CreateFrame("Frame", nil, UIParent)
711+
MultiBot._clickBlockerTicker.running = false
712+
end
713+
714+
local t = MultiBot._clickBlockerTicker
715+
if(t.running) then return end
716+
717+
t.running = true
718+
t:SetScript("OnUpdate", function(self)
719+
self:SetScript("OnUpdate", nil)
720+
self.running = false
721+
722+
local queue = MultiBot._clickBlockerQueue
723+
MultiBot._clickBlockerQueue = {}
724+
for frame in pairs(queue) do
725+
if(MultiBot.UpdateClickBlocker) then
726+
MultiBot.UpdateClickBlocker(frame)
727+
end
728+
end
729+
end)
730+
end
731+
732+
-- Demande une mise à jour pour le frame et tous ses parents MultiBot.newFrame (cascade).
733+
function MultiBot.RequestClickBlockerUpdate(frame)
734+
local f = frame
735+
while(f) do
736+
_mbQueueClickBlockerUpdate(f)
737+
f = f.parent
738+
end
739+
end
740+
741+
-- Recalcule la zone à bloquer à partir des coordonnées réelles (écran) de tous les boutons visibles.
742+
function MultiBot.UpdateClickBlocker(frame)
743+
local cb = frame and frame.clickBlocker
744+
if(not cb) then return end
745+
746+
if(not frame:IsShown()) then
747+
cb:Hide()
748+
return
749+
end
750+
751+
local brx, bry = frame:GetRight(), frame:GetBottom()
752+
if(not brx or not bry) then
753+
cb:Hide()
754+
return
755+
end
756+
757+
local minL, maxR, minB, maxT
758+
759+
local function consider(l, r, b, t)
760+
if(not l or not r or not b or not t) then return end
761+
if(not minL or l < minL) then minL = l end
762+
if(not maxR or r > maxR) then maxR = r end
763+
if(not minB or b < minB) then minB = b end
764+
if(not maxT or t > maxT) then maxT = t end
765+
end
766+
767+
local function scan(f)
768+
if(not f or not f.IsShown or not f:IsShown()) then return end
769+
770+
if(f.buttons) then
771+
for _, b in pairs(f.buttons) do
772+
if(b and b.IsShown and b:IsShown()) then
773+
consider(b:GetLeft(), b:GetRight(), b:GetBottom(), b:GetTop())
774+
end
775+
end
776+
end
777+
778+
if(f.frames) then
779+
for _, sf in pairs(f.frames) do
780+
scan(sf)
781+
end
782+
end
783+
end
784+
785+
-- fallback minimal : la zone du frame lui-même
786+
consider(frame:GetLeft(), frame:GetRight(), frame:GetBottom(), frame:GetTop())
787+
scan(frame)
788+
789+
if(not minL or not maxR or not minB or not maxT) then
790+
cb:Hide()
791+
return
792+
end
793+
794+
local pad = 2
795+
local minX = (minL - brx) - pad
796+
local maxX = (maxR - brx) + pad
797+
local minY = (minB - bry) - pad
798+
local maxY = (maxT - bry) + pad
799+
800+
cb:ClearAllPoints()
801+
cb:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", maxX, minY)
802+
cb:SetPoint("TOPLEFT", frame, "BOTTOMRIGHT", minX, maxY)
803+
cb:SetFrameLevel(frame:GetFrameLevel())
804+
cb:Show()
805+
end
806+
691807
-- MULTIBOT:FRAME --
692808

693809
MultiBot.newFrame = function(pParent, pX, pY, pSize, oWidth, oHeight, oAlign)
@@ -712,6 +828,18 @@ MultiBot.newFrame = function(pParent, pX, pY, pSize, oWidth, oHeight, oAlign)
712828
frame.x = pX
713829
frame.y = pY
714830

831+
-- click blocker: absorbe les clics dans les espaces entre boutons
832+
frame.clickBlocker = CreateFrame("Frame", nil, frame)
833+
frame.clickBlocker:SetFrameLevel(frame:GetFrameLevel())
834+
frame.clickBlocker:EnableMouse(true)
835+
frame.clickBlocker.texture = frame.clickBlocker:CreateTexture(nil, "BACKGROUND")
836+
frame.clickBlocker.texture:SetAllPoints(frame.clickBlocker)
837+
frame.clickBlocker.texture:SetTexture("Interface\\Buttons\\WHITE8X8")
838+
frame.clickBlocker.texture:SetVertexColor(0, 0, 0, 0) -- fond totalement transparent
839+
frame.clickBlocker:SetAllPoints(frame)
840+
841+
frame:HookScript("OnShow", function() if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(frame) end end)
842+
frame:HookScript("OnHide", function() if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(frame) end end)
715843
-- ADD --
716844

717845
frame.addTexture = function(pTexture)
@@ -806,6 +934,7 @@ MultiBot.newFrame = function(pParent, pX, pY, pSize, oWidth, oHeight, oAlign)
806934
frame:SetPoint("BOTTOMRIGHT", x, y)
807935
frame.x = x
808936
frame.y = y
937+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(frame) end
809938
return frame
810939
end
811940

@@ -892,6 +1021,8 @@ MultiBot.newFrame = function(pParent, pX, pY, pSize, oWidth, oHeight, oAlign)
8921021
return frame
8931022
end
8941023

1024+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(frame) end
1025+
8951026
return frame
8961027
end
8971028

@@ -927,6 +1058,9 @@ MultiBot.newButton = function(pParent, pX, pY, pSize, pTexture, pTip, oTemplate)
9271058
button.tip = pTip
9281059
button.x = pX
9291060
button.y = pY
1061+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end
1062+
button:HookScript("OnShow", function() if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end end)
1063+
button:HookScript("OnHide", function() if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end end)
9301064

9311065
-- ADD --
9321066

@@ -942,6 +1076,7 @@ MultiBot.newButton = function(pParent, pX, pY, pSize, pTexture, pTip, oTemplate)
9421076
button:SetPoint("BOTTOMRIGHT", x, y)
9431077
button.x = x
9441078
button.y = y
1079+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end
9451080
return button
9461081
end
9471082

@@ -1096,6 +1231,16 @@ MultiBot.wowButton = function(pParent, pName, pX, pY, pWidth, pHeight, pSize)
10961231
button.y = pY
10971232
button.x = pX
10981233

1234+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end
1235+
1236+
button:HookScript("OnShow", function()
1237+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end
1238+
end)
1239+
1240+
button:HookScript("OnHide", function()
1241+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end
1242+
end)
1243+
10991244
-- GET --
11001245

11011246
button.getButton = function(pIndex)
@@ -1136,11 +1281,13 @@ MultiBot.wowButton = function(pParent, pName, pX, pY, pWidth, pHeight, pSize)
11361281

11371282
button.doHide = function()
11381283
button:Hide()
1284+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end
11391285
return button
11401286
end
11411287

11421288
button.doShow = function()
11431289
button:Show()
1290+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end
11441291
return button
11451292
end
11461293

@@ -1181,6 +1328,16 @@ MultiBot.movButton = function(pParent, pX, pY, pSize, pTip, oFrame)
11811328
button.x = pX
11821329
button.y = pY
11831330

1331+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end
1332+
1333+
button:HookScript("OnShow", function()
1334+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end
1335+
end)
1336+
1337+
button:HookScript("OnHide", function()
1338+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end
1339+
end)
1340+
11841341
-- EVENT --
11851342

11861343
button:SetScript("OnEnter", function()
@@ -1224,6 +1381,16 @@ MultiBot.boxButton = function(pParent, pX, pY, pSize, pState)
12241381
button.x = pX
12251382
button.y = pY
12261383

1384+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end
1385+
1386+
button:HookScript("OnShow", function()
1387+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end
1388+
end)
1389+
1390+
button:HookScript("OnHide", function()
1391+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end
1392+
end)
1393+
12271394
-- GET --
12281395

12291396
button.getButton = function(pIndex)
@@ -1250,11 +1417,13 @@ MultiBot.boxButton = function(pParent, pX, pY, pSize, pState)
12501417

12511418
button.doHide = function()
12521419
button:Hide()
1420+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end
12531421
return button
12541422
end
12551423

12561424
button.doShow = function()
12571425
button:Show()
1426+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end
12581427
return button
12591428
end
12601429

@@ -1275,6 +1444,17 @@ MultiBot.catButton = function(pParent, pX, pY, pWidth, pHeight)
12751444
button:SetSize(pWidth, pHeight)
12761445
button:Show()
12771446

1447+
button.parent = pParent
1448+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end
1449+
1450+
button:HookScript("OnShow", function()
1451+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end
1452+
end)
1453+
1454+
button:HookScript("OnHide", function()
1455+
if(MultiBot.RequestClickBlockerUpdate) then MultiBot.RequestClickBlockerUpdate(button.parent) end
1456+
end)
1457+
12781458
-- EVENT --
12791459

12801460
button:SetScript("OnClick", function()

0 commit comments

Comments
 (0)