From bd1abc70d2567f625f4a22e91365fb3133fddd5c Mon Sep 17 00:00:00 2001 From: Scott Ingram Date: Sat, 18 Mar 2023 11:31:24 -0700 Subject: [PATCH 1/5] Create README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..97b5fde --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# FloFlyout +wow addon to provide custom flyout menus - created by Boboseb From b11264f21ff2ea14e2bce7567ada7336ccc206e0 Mon Sep 17 00:00:00 2001 From: Scott Ingram Date: Tue, 4 Apr 2023 10:22:29 -0700 Subject: [PATCH 2/5] fix for issue #5 - flyouts don't turn on/off when the user turns its action bar on/off --- FloFlyout.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/FloFlyout.lua b/FloFlyout.lua index 79f1bda..d019a76 100755 --- a/FloFlyout.lua +++ b/FloFlyout.lua @@ -128,6 +128,8 @@ function FloFlyout_OnLoad(self) self:RegisterEvent("UPDATE_BINDINGS") self:RegisterEvent("ACTIONBAR_SLOT_CHANGED") + EventRegistry:RegisterCallback("ActionBarShownSettingUpdated", function() FloFlyout:ApplyConfig() end , FloFlyout); + _classicUI = _G["ClassicUI"] if _classicUI then DEFAULT_CHAT_FRAME:AddMessage( NAME.." : |cffd78900ClassicUI v".._classicUI.VERSION.."|r detected." ) From 21aadd63a4d8d8dda741ce935702c1f71d5a4cb2 Mon Sep 17 00:00:00 2001 From: Scott Ingram Date: Fri, 7 Apr 2023 17:54:10 -0700 Subject: [PATCH 3/5] fix for issue #7 - openers on the primary action bar vanish --- FloFlyout.lua | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/FloFlyout.lua b/FloFlyout.lua index d019a76..c360c04 100755 --- a/FloFlyout.lua +++ b/FloFlyout.lua @@ -127,6 +127,7 @@ function FloFlyout_OnLoad(self) self:RegisterEvent("PLAYER_ALIVE") self:RegisterEvent("UPDATE_BINDINGS") self:RegisterEvent("ACTIONBAR_SLOT_CHANGED") + self:RegisterEvent("CURSOR_CHANGED") EventRegistry:RegisterCallback("ActionBarShownSettingUpdated", function() FloFlyout:ApplyConfig() end , FloFlyout); @@ -221,11 +222,47 @@ function FloFlyout_OnEvent(self, event, arg1, ...) elseif event == "PLAYER_SPECIALIZATION_CHANGED" then FloFlyout:ApplyConfig() + + elseif event == "CURSOR_CHANGED" then + FloFlyout:FixOpenerStrata(arg1, ...) else end end +function FloFlyout:FixOpenerStrata(isDefault, ...) + --local newCursorType, oldCursorType = ... + --print("-*-FixOpenerStrata-*- ... isDefault =",isDefault, "newCursorType =", newCursorType, "oldCursorType =", oldCursorType, "opener = ",opener) + if isDefault then + self:NormalizeOpenerStrata() + else + self:ElevateOpenerStrata() + end +end + +function FloFlyout:ElevateOpenerStrata() + self:ApplyOperationToAllOpenerInstances(function(opener) + opener:SetFrameStrata("TOOLTIP") + end) +end + +function FloFlyout:NormalizeOpenerStrata() + self:ApplyOperationToAllOpenerInstances(function(opener) + opener:SetFrameStrata("MEDIUM") + end) +end + +function FloFlyout:ApplyOperationToAllOpenerInstances(callback) + for btnName, openerObj in pairs(self.openers) do + callback(openerObj, btnName) + end +end + +function FloFlyout:ApplyOperationToAllOpenerInstancesUnlessInCombat(callback) + if InCombatLockdown() then return end + self:ApplyOperationToAllOpenerInstances(callback) +end + function FloFlyoutFrame_OnEvent(self, event, ...) if event == "SPELL_UPDATE_COOLDOWN" then local i = 1 From a90dd81d95abb752acf018cc60aaf55cf83db15e Mon Sep 17 00:00:00 2001 From: Scott Ingram Date: Fri, 7 Apr 2023 19:23:21 -0700 Subject: [PATCH 4/5] fix for issue #7 - openers on the primary action bar vanish - addendum: oops, didn't fix the case when a new opener is created and dropped onto an already occupied btn slot --- FloFlyout.lua | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/FloFlyout.lua b/FloFlyout.lua index c360c04..4dd139c 100755 --- a/FloFlyout.lua +++ b/FloFlyout.lua @@ -230,9 +230,13 @@ function FloFlyout_OnEvent(self, event, arg1, ...) end end +local STRATA_DEFAULT = "MEDIUM" +local STRATA_MAX = "TOOLTIP" + function FloFlyout:FixOpenerStrata(isDefault, ...) --local newCursorType, oldCursorType = ... --print("-*-FixOpenerStrata-*- ... isDefault =",isDefault, "newCursorType =", newCursorType, "oldCursorType =", oldCursorType, "opener = ",opener) + -- KNOWN BUG: the Bliz CURSOR_CHANGED event lies when you drop a spell on another spell: it reports isDefault==true which is wrong if isDefault then self:NormalizeOpenerStrata() else @@ -242,13 +246,13 @@ end function FloFlyout:ElevateOpenerStrata() self:ApplyOperationToAllOpenerInstances(function(opener) - opener:SetFrameStrata("TOOLTIP") + opener:SetFrameStrata(STRATA_MAX) end) end function FloFlyout:NormalizeOpenerStrata() self:ApplyOperationToAllOpenerInstances(function(opener) - opener:SetFrameStrata("MEDIUM") + opener:SetFrameStrata(STRATA_DEFAULT) end) end @@ -639,7 +643,16 @@ function FloFlyout:CreateOpener(name, idFlyout, actionId, direction, actionButto end end end - opener:SetFrameStrata("MEDIUM") + + local strata + local thingOnCursor = GetCursorInfo() + if thingOnCursor then + strata = STRATA_MAX + else + strata = STRATA_DEFAULT + end + + opener:SetFrameStrata(strata) opener:SetFrameLevel(100) opener:SetToplevel(true) From d835a342c799ec9b95ed2df12b3f12f0dec4cbe6 Mon Sep 17 00:00:00 2001 From: Scott Ingram Date: Sun, 9 Apr 2023 10:46:32 -0700 Subject: [PATCH 5/5] re-fix for issue #7 and issue #9 - openers on the primary action bar vanish - REVAMP! Found a much better way involving setting the opener Frame's parent. Also, shrank the code a lot. For issue #9, I ask the bar object itself for the correct direction. --- FloFlyout.lua | 203 ++++++++++++++++---------------------------------- 1 file changed, 64 insertions(+), 139 deletions(-) diff --git a/FloFlyout.lua b/FloFlyout.lua index 4dd139c..72e5ad7 100755 --- a/FloFlyout.lua +++ b/FloFlyout.lua @@ -1,6 +1,8 @@ -- This Source Code Form is subject to the terms of the Mozilla Public -- License, v. 2.0. If a copy of the MPL was not distributed with this file, -- You can obtain one at http://mozilla.org/MPL/2.0/. +local MY_NAME, MY_GLOBALS = ... +local DEBUG = MY_GLOBALS.DEBUG -- my debugging routines that I don't check-in ------------------------------------------------------------------------------- -- Constants @@ -12,6 +14,25 @@ local SPELLFLYOUT_DEFAULT_SPACING = 4 local SPELLFLYOUT_INITIAL_SPACING = 7 local SPELLFLYOUT_FINAL_SPACING = 4 local STRIPE_COLOR = {r=0.9, g=0.9, b=1} +local STRATA_DEFAULT = "MEDIUM" +local STRATA_MAX = "TOOLTIP" +local BLIZ_BAR_METADATA = { + [1] = {name="Action", visibleIf="bar:1,nobonusbar:1,nobonusbar:2,nobonusbar:3,nobonusbar:4"}, -- primary "ActionBar" - page #1 - no stance/shapeshift --- ff: actionBarPage = 1 + [2] = {name="Action", visibleIf="bar:2"}, -- primary "ActionBar" - page #2 (regardless of stance/shapeshift) --- ff: actionBarPage = 2 + [3] = {name="MultiBarRight", classicType=2}, -- config UI -> Action Bars -> checkbox #4 + [4] = {name="MultiBarLeft", classicType=2}, -- config UI -> Action Bars -> checkbox #5 + [5] = {name="MultiBarBottomRight", classicType=1}, -- config UI -> Action Bars -> checkbox #3 + [6] = {name="MultiBarBottomLeft", classicType=1}, -- config UI -> Action Bars -> checkbox #2 + [7] = {name="Action", visibleIf="bar:1,bonusbar:1"}, -- primary "ActionBar" - page #1 - bonusbar 1 - druid CAT + [8] = {name="Action", visibleIf="bar:1,bonusbar:2"}, -- primary "ActionBar" - page #1 - bonusbar 2 - unknown? + [9] = {name="Action", visibleIf="bar:1,bonusbar:3"}, -- primary "ActionBar" - page #1 - bonusbar 3 - druid BEAR + [10] = {name="Action", visibleIf="bar:1,bonusbar:4"}, -- primary "ActionBar" - page #1 - bonusbar 4 - druid MOONKIN + [11] = {name="Action", visibleIf="bar:1,bonusbar:5"}, -- primary "ActionBar" - page #1 - bonusbar 5 - dragon riding + [12] = {name="Action", visibleIf="bar:1,bonusbar:6"--[[just a guess]]}, -- unknown? + [13] = {name="MultiBar5"}, -- config UI -> Action Bars -> checkbox #6 + [14] = {name="MultiBar6"}, -- config UI -> Action Bars -> checkbox #7 + [15] = {name="MultiBar7"}, -- config UI -> Action Bars -> checkbox #8 +} ------------------------------------------------------------------------------- -- Variables @@ -127,9 +148,6 @@ function FloFlyout_OnLoad(self) self:RegisterEvent("PLAYER_ALIVE") self:RegisterEvent("UPDATE_BINDINGS") self:RegisterEvent("ACTIONBAR_SLOT_CHANGED") - self:RegisterEvent("CURSOR_CHANGED") - - EventRegistry:RegisterCallback("ActionBarShownSettingUpdated", function() FloFlyout:ApplyConfig() end , FloFlyout); _classicUI = _G["ClassicUI"] if _classicUI then @@ -151,7 +169,7 @@ function FloFlyout_OnEvent(self, event, arg1, ...) FloFlyout:ApplyConfig() end - --elseif event == "SPELL_UPDATE_COOLDOWN" or event == "ACTIONBAR_UPDATE_USABLE" then + --elseif event == "SPELL_UPDATE_COOLDOWN" or event == "ACTIONBAR_UPDATE_USABLE" then elseif event == "ADDON_LOADED" and arg1 == NAME then @@ -166,7 +184,7 @@ function FloFlyout_OnEvent(self, event, arg1, ...) end FloFlyoutConfigFlyoutFrame.IsConfig = true - + for _, flyout in ipairs(FloFlyout.config.flyouts) do if flyout.actionTypes == nil then flyout.actionTypes = {} @@ -178,7 +196,7 @@ function FloFlyout_OnEvent(self, event, arg1, ...) flyout.mountIndex = {} end if flyout.spellNames == nil then - flyout.spellNames = {} + flyout.spellNames = {} end end @@ -223,42 +241,8 @@ function FloFlyout_OnEvent(self, event, arg1, ...) elseif event == "PLAYER_SPECIALIZATION_CHANGED" then FloFlyout:ApplyConfig() - elseif event == "CURSOR_CHANGED" then - FloFlyout:FixOpenerStrata(arg1, ...) - else - - end -end - -local STRATA_DEFAULT = "MEDIUM" -local STRATA_MAX = "TOOLTIP" - -function FloFlyout:FixOpenerStrata(isDefault, ...) - --local newCursorType, oldCursorType = ... - --print("-*-FixOpenerStrata-*- ... isDefault =",isDefault, "newCursorType =", newCursorType, "oldCursorType =", oldCursorType, "opener = ",opener) - -- KNOWN BUG: the Bliz CURSOR_CHANGED event lies when you drop a spell on another spell: it reports isDefault==true which is wrong - if isDefault then - self:NormalizeOpenerStrata() else - self:ElevateOpenerStrata() - end -end -function FloFlyout:ElevateOpenerStrata() - self:ApplyOperationToAllOpenerInstances(function(opener) - opener:SetFrameStrata(STRATA_MAX) - end) -end - -function FloFlyout:NormalizeOpenerStrata() - self:ApplyOperationToAllOpenerInstances(function(opener) - opener:SetFrameStrata(STRATA_DEFAULT) - end) -end - -function FloFlyout:ApplyOperationToAllOpenerInstances(callback) - for btnName, openerObj in pairs(self.openers) do - callback(openerObj, btnName) end end @@ -332,72 +316,29 @@ function FloFlyout:GetName(actionType, data) end end -function FloFlyout:BindFlyoutToAction(idFlyout, idAction) - - local direction, actionButton, actionBarPage, bonusBar, typeActionButton - typeActionButton = 0 - direction = "UP" - - if idAction <= 12 then - bonusBar = 0 - actionBarPage = 1 - actionButton = _G["ActionButton"..idAction] - elseif idAction <= 24 then - actionBarPage = 2 - actionButton = _G["ActionButton"..(idAction - 12)] - elseif idAction <= 36 then - if MultiBar3_IsVisible() then - actionButton = _G["MultiBarRightButton"..(idAction - 24)] - direction = "LEFT" - typeActionButton = 2 - else - actionBarPage = 3 - actionButton = _G["ActionButton"..(idAction - 24)] - end - elseif idAction <= 48 then - if MultiBar4_IsVisible() then - actionButton = _G["MultiBarLeftButton"..(idAction - 36)] - direction = "LEFT" - typeActionButton = 2 - else - actionBarPage = 4 - actionButton = _G["ActionButton"..(idAction - 36)] - end - elseif idAction <= 60 then - if MultiBar2_IsVisible() then - actionButton = _G["MultiBarBottomRightButton"..(idAction - 48)] - typeActionButton = 1 - else - actionBarPage = 5 - actionButton = _G["ActionButton"..(idAction - 48)] - end - elseif idAction <= 72 then - if MultiBar1_IsVisible() then - actionButton = _G["MultiBarBottomLeftButton"..(idAction - 60)] - typeActionButton = 1 - else - actionBarPage = 6 - actionButton = _G["ActionButton"..(idAction - 60)] - end - elseif idAction <= 84 then - bonusBar = 1 - actionBarPage = 1 - actionButton = _G["ActionButton"..(idAction - 72)] - elseif idAction <= 96 then - bonusBar = 2 - actionBarPage = 1 - actionButton = _G["ActionButton"..(idAction - 84)] - elseif idAction <= 108 then - bonusBar = 3 - actionBarPage = 1 - actionButton = _G["ActionButton"..(idAction - 96)] - elseif idAction <= 120 then - bonusBar = 4 - actionBarPage = 1 - actionButton = _G["ActionButton"..(idAction - 108)] - end - - FloFlyout:CreateOpener("FloFlyoutOpener"..idAction, idFlyout, idAction, direction, actionButton, actionBarPage, bonusBar, typeActionButton) +function FloFlyout:BindFlyoutToAction(ffUniqueId, slotIndex) + -- examine the action/bonus/multi bar + local barNum = ActionButtonUtil.GetPageForSlot(slotIndex) + local blizBarDef = BLIZ_BAR_METADATA[barNum] + assert(blizBarDef, "No "..MY_NAME.." config defined for button bar #"..barNum) -- in case Blizzard adds more bars, complain here clearly. + local blizBarName = blizBarDef.name + local visibleIf = blizBarDef.visibleIf + local typeActionButton = blizBarDef.classicType -- for WoW classic + + -- examine the button + local btnNum = (slotIndex % NUM_ACTIONBAR_BUTTONS) -- defined in bliz internals ActionButtonUtil.lua + if (btnNum == 0) then btnNum = NUM_ACTIONBAR_BUTTONS end -- button #12 divided by 12 is 1 remainder 0. Thus, treat a 0 as a 12 + local btnName = blizBarName .. "Button" .. btnNum + local btnObj = _G[btnName] -- grab the button object from Blizzard's GLOBAL dumping ground + + -- ask the bar instance what direction to fly + local barObj = btnObj and btnObj.bar + local direction = barObj and barObj:GetSpellFlyoutDirection() or "UP" -- TODO: fix bug where edit-mode -> change direction doesn't automatically update existing openers + + --local foo = btnObj and "FOUND" or "NiL" + --print ("###--->>> ffUniqueId =", ffUniqueId, "barNum =",barNum, "slotId = ", slotIndex, "btnObj =",foo, "blizBarName = ",blizBarName, "btnName =",btnName, "btnNum =",btnNum, "direction =",direction, "visibleIf =", visibleIf) + + FloFlyout:CreateOpener(slotIndex, ffUniqueId, direction, btnObj, visibleIf, typeActionButton) end local function Opener_OnReceiveDrag(self) @@ -420,6 +361,7 @@ local function Opener_OnDragStart(self) end local function Opener_UpdateFlyout(self) + -- print("========== Opener_UpdateFlyout()") this is being called continuously while a flyout exists on any bar -- Update border and determine arrow position local arrowDistance; -- Update border @@ -619,10 +561,11 @@ local snippet_Opener_Click = [=[ end ]=] -function FloFlyout:CreateOpener(name, idFlyout, actionId, direction, actionButton, actionBarPage, bonusBar, typeActionButton) +function FloFlyout:CreateOpener(actionId, idFlyout, direction, actionButton, visibleIf, typeActionButton) local flyoutConf = self.config.flyouts[idFlyout] - local opener = self.openers[name] or CreateFrame("CheckButton", name, UIParent, "ActionButtonTemplate, SecureHandlerClickTemplate") + local name = "FloFlyoutOpener"..actionId + local opener = self.openers[name] or CreateFrame("CheckButton", name, actionButton, "ActionButtonTemplate, SecureHandlerClickTemplate") self.openers[name] = opener opener.flyoutId = idFlyout opener.actionId = actionId @@ -644,15 +587,7 @@ function FloFlyout:CreateOpener(name, idFlyout, actionId, direction, actionButto end end - local strata - local thingOnCursor = GetCursorInfo() - if thingOnCursor then - strata = STRATA_MAX - else - strata = STRATA_DEFAULT - end - - opener:SetFrameStrata(strata) + opener:SetFrameStrata(STRATA_DEFAULT) opener:SetFrameLevel(100) opener:SetToplevel(true) @@ -693,18 +628,8 @@ function FloFlyout:CreateOpener(name, idFlyout, actionId, direction, actionButto icon:SetTexture(texture) end - local stateCondition = "nopetbattle,nooverridebar,novehicleui,nopossessbar" - if actionBarPage then - stateCondition = ",bar:"..actionBarPage - end - if bonusBar then - if bonusBar == 0 then - stateCondition = stateCondition..",nobonusbar:1,nobonusbar:2,nobonusbar:3,nobonusbar:4" - else - stateCondition = stateCondition..",bonusbar:"..bonusBar - end - end - if stateCondition ~= "" then + if visibleIf then + local stateCondition = "nopetbattle,nooverridebar,novehicleui,nopossessbar," .. visibleIf RegisterStateDriver(opener, "visibility", "["..stateCondition.."] show; hide") else opener:Show() @@ -904,7 +829,7 @@ function FloFlyoutButton_OnReceiveDrag(self) if oldMountIndex == nil then PickupSpell(oldActionData) else - C_MountJournal.Pickup(oldMountIndex) + C_MountJournal.Pickup(oldMountIndex) end elseif oldActionType == "item" then PickupItem(oldActionData) @@ -1127,11 +1052,11 @@ function FloFlyout.ConfigPane_Update() texture = FloFlyout:GetTexture(flyout.actionTypes[1], flyout.spells[1]) end if texture then - if(type(texture) == "number") then - button.icon:SetTexture(texture); - else - button.icon:SetTexture("INTERFACE\\ICONS\\"..texture); - end + if(type(texture) == "number") then + button.icon:SetTexture(texture); + else + button.icon:SetTexture("INTERFACE\\ICONS\\"..texture); + end else button.icon:SetTexture("Interface\\Icons\\INV_Misc_QuestionMark") end @@ -1176,7 +1101,7 @@ function FloFlyout.ConfigPane_Update() buttons[i].BgBottom:Hide() buttons[i].BgMiddle:SetPoint("BOTTOM") end - + if (i+scrollOffset)%2 == 0 then buttons[i].Stripe:SetTexture(STRIPE_COLOR.r, STRIPE_COLOR.g, STRIPE_COLOR.b) buttons[i].Stripe:SetAlpha(0.1) @@ -1278,7 +1203,7 @@ function RecalculateFloFlyoutConfigDialogPopup(iconTexture) popup:SetSelection(false, 1) end - --[[ + --[[ Scroll and ensure that any selected equipment shows up in the list. When we first press "save", we want to make sure any selected equipment set shows up in the list, so that the user can just make his changes and press Okay to overwrite. @@ -1315,7 +1240,7 @@ function RecalculateFloFlyoutConfigDialogPopup(iconTexture) end --[[ -RefreshFlyoutIconInfo() counts how many uniquely textured spells the player has in the current flyout. +RefreshFlyoutIconInfo() counts how many uniquely textured spells the player has in the current flyout. ]] function FloFlyout.RefreshFlyoutIconInfo() FC_ICON_FILENAMES = {} @@ -1428,7 +1353,7 @@ function FloFlyoutConfigPopupButton_OnClick(self, button, down) local popup = FloFlyoutConfigDialogPopup local offset = FauxScrollFrame_GetOffset(FloFlyoutConfigDialogPopupScrollFrame) or 0 popup.selectedIcon = (offset * NUM_FLYOUT_ICONS_PER_ROW) + self:GetID() - popup.selectedTexture = nil + popup.selectedTexture = nil FloFlyoutConfigDialogPopup_Update() FloFlyout.ConfigDialogPopupOkay_Update() end