From a6f99da4c50dab5dde36063538fc1e0bd4f127af Mon Sep 17 00:00:00 2001 From: evil_morfar <10189576+evil-morfar@users.noreply.github.com> Date: Tue, 7 May 2024 20:56:59 +0200 Subject: [PATCH] LibDialog fix Temporarily bumped major version until a fix is officially implemented --- Libs/LibDialog-1.0/LibDialog-1.0.lua | 39 +++++++++++++++++----------- Modules/History/CSVImport.lua | 2 +- Modules/Sync.lua | 2 +- Modules/TradeUI.lua | 2 +- Modules/votingFrame.lua | 2 +- Utils/popups.lua | 2 +- __tests/__load_libs.lua | 2 +- core.lua | 2 +- 8 files changed, 31 insertions(+), 22 deletions(-) diff --git a/Libs/LibDialog-1.0/LibDialog-1.0.lua b/Libs/LibDialog-1.0/LibDialog-1.0.lua index f9212d7a..c460db26 100644 --- a/Libs/LibDialog-1.0/LibDialog-1.0.lua +++ b/Libs/LibDialog-1.0/LibDialog-1.0.lua @@ -22,7 +22,7 @@ local table = _G.table -- Library namespace. ----------------------------------------------------------------------- local LibStub = _G.LibStub -local MAJOR = "LibDialog-1.0" +local MAJOR = "LibDialog-1.1" -- EDIT: Bump major until https://github.com/Torhal/LibDialog-1.0/issues/5 is implemented _G.assert(LibStub, MAJOR .. " requires LibStub") -- RCLC: Note bumped minor +1 to avoid incompabilities with old addons. @@ -128,6 +128,27 @@ local icon_heap = lib.icon_heap ----------------------------------------------------------------------- -- Helper functions. ----------------------------------------------------------------------- +local function _SetupAnchor(dialog) + local default_dialog + if _G.StaticPopup_DisplayedFrames then + default_dialog = _G.StaticPopup_DisplayedFrames[#_G.StaticPopup_DisplayedFrames] + elseif (_G.StaticPopup_HasDisplayedFrames and _G.StaticPopup_IsLastDisplayedFrame) then + if StaticPopup_HasDisplayedFrames() then + for idx = STATICPOPUP_NUMDIALOGS, 1, -1 do + local test_dialog = _G["StaticPopup" .. idx] + if StaticPopup_IsLastDisplayedFrame(test_dialog) then + default_dialog = test_dialog + end + end + end + end + if default_dialog then + dialog:SetPoint("TOP", default_dialog, "BOTTOM", 0, 0) + else + dialog:SetPoint("TOP", _G.UIParent, "TOP", 0, -135) + end +end + local function _ProcessQueue() if #active_dialogs == MAX_DIALOGS then return @@ -152,13 +173,7 @@ local function _RefreshDialogAnchors() current_dialog:ClearAllPoints() if index == 1 then - local default_dialog = _G.StaticPopup_DisplayedFrames[#_G.StaticPopup_DisplayedFrames] - - if default_dialog then - current_dialog:SetPoint("TOP", default_dialog, "BOTTOM", 0, 0) - else - current_dialog:SetPoint("TOP", _G.UIParent, "TOP", 0, -135) - end + _SetupAnchor(current_dialog) else current_dialog:SetPoint("TOP", active_dialogs[index - 1], "BOTTOM", 0, 0) end @@ -834,13 +849,7 @@ function lib:Spawn(reference, data) if #active_dialogs > 0 then dialog:SetPoint("TOP", active_dialogs[#active_dialogs], "BOTTOM", 0, 0) else - local default_dialog = _G.StaticPopup_DisplayedFrames[#_G.StaticPopup_DisplayedFrames] - - if default_dialog then - dialog:SetPoint("TOP", default_dialog, "BOTTOM", 0, 0) - else - dialog:SetPoint("TOP", _G.UIParent, "TOP", 0, -135) - end + _SetupAnchor(dialog) end active_dialogs[#active_dialogs + 1] = dialog dialog:Show() diff --git a/Modules/History/CSVImport.lua b/Modules/History/CSVImport.lua index 46acb380..42a9e9fc 100644 --- a/Modules/History/CSVImport.lua +++ b/Modules/History/CSVImport.lua @@ -3,7 +3,7 @@ local addon = select(2, ...) local His = addon:GetModule("RCLootHistory") --- @type RCLootCouncilLocale local L = LibStub("AceLocale-3.0"):GetLocale("RCLootCouncil") -local LibDialog = LibStub("LibDialog-1.0") +local LibDialog = LibStub("LibDialog-1.1") local private = { errorList = { -- [i] = {line, cause} diff --git a/Modules/Sync.lua b/Modules/Sync.lua index 58fb64cf..5cdf43c2 100644 --- a/Modules/Sync.lua +++ b/Modules/Sync.lua @@ -13,7 +13,7 @@ local addon = select(2, ...) ---@class Sync : AceSerializer-3.0 local sync = addon:NewModule("Sync", "AceSerializer-3.0") -local LibDialog = LibStub("LibDialog-1.0") +local LibDialog = LibStub("LibDialog-1.1") local LD = LibStub("LibDeflate") --- @type RCLootCouncilLocale local L = LibStub("AceLocale-3.0"):GetLocale("RCLootCouncil") diff --git a/Modules/TradeUI.lua b/Modules/TradeUI.lua index d1f4c10b..c9c3e907 100644 --- a/Modules/TradeUI.lua +++ b/Modules/TradeUI.lua @@ -16,7 +16,7 @@ addon.TradeUI = TradeUI -- Shorthand for easier access local ST = LibStub("ScrollingTable") --- @type RCLootCouncilLocale local L = LibStub("AceLocale-3.0"):GetLocale("RCLootCouncil") -local LibDialog = LibStub("LibDialog-1.0") +local LibDialog = LibStub("LibDialog-1.1") local _G = _G local Comms = addon.Require "Services.Comms" local PREFIX = addon.PREFIXES.MAIN diff --git a/Modules/votingFrame.lua b/Modules/votingFrame.lua index c579f436..ea75107d 100644 --- a/Modules/votingFrame.lua +++ b/Modules/votingFrame.lua @@ -25,7 +25,7 @@ local addon = select(2, ...) --- @class RCVotingFrame : AceTimer-3.0, AceEvent-3.0, AceBucket-3.0 local RCVotingFrame = addon:NewModule("RCVotingFrame", "AceTimer-3.0", "AceEvent-3.0", "AceBucket-3.0") -local LibDialog = LibStub("LibDialog-1.0") +local LibDialog = LibStub("LibDialog-1.1") --- @type RCLootCouncilLocale local L = LibStub("AceLocale-3.0"):GetLocale("RCLootCouncil") diff --git a/Utils/popups.lua b/Utils/popups.lua index a0f60a4d..c96722e2 100644 --- a/Utils/popups.lua +++ b/Utils/popups.lua @@ -4,7 +4,7 @@ --- @type RCLootCouncil local addon = select(2, ...) -local LibDialog = LibStub("LibDialog-1.0") +local LibDialog = LibStub("LibDialog-1.1") --- @type RCLootCouncilLocale local L = LibStub("AceLocale-3.0"):GetLocale("RCLootCouncil") diff --git a/__tests/__load_libs.lua b/__tests/__load_libs.lua index bc773958..3272a347 100644 --- a/__tests/__load_libs.lua +++ b/__tests/__load_libs.lua @@ -23,7 +23,7 @@ dofile "Libs/AceComm-3.0/ChatThrottleLib.lua" dofile "Libs/AceComm-3.0/AceComm-3.0.lua" dofile "Libs/AceSerializer-3.0/AceSerializer-3.0.lua" -dofile "Libs/LibDialog-1.0/LibDialog-1.0.lua" +dofile "Libs/LibDialog-1.0/LibDialog-1.1.lua" dofile "Libs/LibWindow-1.1/LibWindow-1.1.lua" dofile "Libs/lib-st/Core.lua" dofile "Libs/MSA-DropDownMenu-1.0/MSA-DropDownMenu-1.0.lua" diff --git a/core.lua b/core.lua index 13cd352e..1577c017 100644 --- a/core.lua +++ b/core.lua @@ -46,7 +46,7 @@ local addonname, addontable = ... --- @class RCLootCouncil : AceAddon-3.0, AceConsole-3.0, AceEvent-3.0, AceHook-3.0, AceTimer-3.0, AceBucket-3.0 _G.RCLootCouncil = LibStub("AceAddon-3.0"):NewAddon(addontable, addonname, "AceConsole-3.0", "AceEvent-3.0", "AceHook-3.0", "AceTimer-3.0", "AceBucket-3.0"); -local LibDialog = LibStub("LibDialog-1.0") +local LibDialog = LibStub("LibDialog-1.1") --- @type RCLootCouncilLocale local L = LibStub("AceLocale-3.0"):GetLocale("RCLootCouncil") local tooltipForParsing = CreateFrame("GameTooltip", "RCLootCouncil_Tooltip_Parse", nil, "GameTooltipTemplate")