Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 21 additions & 33 deletions libs/Krowi_WorldMapButtons-1.4/Krowi_WorldMapButtons-1.4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,35 @@
the copyright holders.
]]

local lib, oldminor = LibStub:NewLibrary('Krowi_WorldMapButtons-1.4', 7);
local lib, oldminor = LibStub:NewLibrary('Krowi_WorldMapButtons-1.4', 8);

if not lib then
return;
end

local version = (GetBuildInfo());
local major = string.match(version, "(%d+)%.(%d+)%.(%d+)(%w?)");
lib.IsClassic = major == "1";
lib.IsTbcClassic = major == "2";
lib.IsWrathClassic = major == "3";
lib.HasNoOverlay = lib.IsClassic or lib.IsTbcClassic or lib.IsWrathClassic;
lib.IsDragonflight = major == "10";
lib.IsTheWarWithin = major == "11";
lib.IsMainline = lib.IsDragonflight or lib.IsTheWarWithin;

local AddButton;
major = tonumber(major);
lib.HasNoOverlay = major <= 3;
lib.IsMainline = major >= 11;

lib.XOffset, lib.YOffset = 4, -2;

function lib:SetOffsets(xOffset, yOffset)
self.XOffset = xOffset or self.XOffset;
self.YOffset = yOffset or self.YOffset;
end

function lib.SetPoints()
local xOffset = lib.XOffset;
local xOffset, yOffset = lib.XOffset, lib.YOffset;
for _, button in next, lib.Buttons do
if button:IsShown() then
button:SetPoint("TOPRIGHT", button.relativeFrame, -xOffset, lib.YOffset);
xOffset = xOffset + 32;
button:SetPoint("TOPRIGHT", button.relativeFrame, -xOffset, yOffset);
if lib.IsMainline then
yOffset = yOffset - 32;
else
xOffset = xOffset + 32;
end
end
end
end
Expand All @@ -67,10 +66,6 @@ local function HookDefaultButtons()
f.KrowiWorldMapButtonsIndex = #lib.Buttons;
tinsert(lib.Buttons, f);
end
if WorldMapShowLegendButtonMixin and f.OnLoad == WorldMapShowLegendButtonMixin.OnLoad then
f.KrowiWorldMapButtonsIndex = #lib.Buttons;
tinsert(lib.Buttons, f);
end
end

lib.HookedDefaultButtons = true;
Expand All @@ -85,10 +80,15 @@ local function PatchWrathClassic()
PatchWrathClassic = function() end;
end

function AddButton(button)
local xOffset = 4 + #lib.Buttons * 32;
button:SetPoint("TOPRIGHT", WorldMapFrame:GetCanvasContainer(), "TOPRIGHT", -xOffset, -2);
local function AddButton(button)
local xOffset, yOffset;
if lib.IsMainline then
yOffset = lib.YOffset - #lib.Buttons * 32;
else
xOffset = lib.XOffset + #lib.Buttons * 32;
end
button.relativeFrame = WorldMapFrame:GetCanvasContainer();
button:SetPoint("TOPRIGHT", button.relativeFrame, lib.IsMainline and -lib.XOffset or -xOffset, lib.IsMainline and yOffset or lib.YOffset);
hooksecurefunc(WorldMapFrame, lib.HasNoOverlay and "OnMapChanged" or "RefreshOverlayFrames", function()
button:Refresh();
lib.SetPoints();
Expand Down Expand Up @@ -132,16 +132,4 @@ if oldminor and oldminor == 3 then
button:SetFrameStrata("TOOLTIP");
end
end
end

if oldminor and oldminor < 7 then
if lib.HookedDefaultButtons and WorldMapFrame.overlayFrames and WorldMapShowLegendButtonMixin then
-- Add the Legend button to the hooked set
for _, f in next, WorldMapFrame.overlayFrames do
if f.OnLoad == WorldMapShowLegendButtonMixin.OnLoad then
f.KrowiWorldMapButtonsIndex = #lib.Buttons;
tinsert(lib.Buttons, f);
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--
<!--
Krowi's World Map Buttons License
Copyright ©2020 The contents of this library, excluding third-party resources, are
copyrighted to their authors with all rights reserved.
Expand Down