Commit 5659b1f5 authored by Ivaria's avatar Ivaria
Browse files

Fall back to old custom minimap icon if LDB doesn't load for whatever reason

parent b2c5b9c1
VuhDoMinimap = {
["Create"] = function(self, someModSettings, someInitSettings)
if VuhDoMinimapButton then return; end
local tFrame = CreateFrame("Button", "VuhDoMinimapButton", Minimap);
tFrame:SetWidth(31);
tFrame:SetHeight(31);
tFrame:SetFrameStrata("LOW");
tFrame:SetToplevel(true);
tFrame:SetHighlightTexture("Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight");
tFrame:SetPoint("TOPLEFT", Minimap, "TOPLEFT");
local tIcon = tFrame:CreateTexture("VuhDoMinimapButtonIcon", "BACKGROUND");
tIcon:SetTexture(VUHDO_STANDARD_ICON);
tIcon:SetWidth(20);
tIcon:SetHeight(20);
tIcon:SetPoint("TOPLEFT", tFrame, "TOPLEFT", 7, -5);
local tOverlay = tFrame:CreateTexture("VuhDoMinimapButtonOverlay", "OVERLAY");
tOverlay:SetTexture("Interface\\Minimap\\MiniMap-TrackingBorder");
tOverlay:SetWidth(53);
tOverlay:SetHeight(53);
tOverlay:SetPoint("TOPLEFT", tFrame, "TOPLEFT")
tFrame:RegisterForClicks("LeftButtonUp", "RightButtonUp");
tFrame:SetScript("OnClick", self.OnClick);
tFrame:SetScript("OnMouseDown", self.OnMouseDown);
tFrame:SetScript("OnMouseUp", self.OnMouseUp);
tFrame:SetScript("OnEnter", self.OnEnter);
tFrame:SetScript("OnLeave", self.OnLeave);
tFrame:RegisterForDrag("LeftButton");
tFrame:SetScript("OnDragStart", self.OnDragStart);
tFrame:SetScript("OnDragStop", self.OnDragStop);
if not someModSettings["position"] then
someModSettings["drag"] = someInitSettings["drag"];
someModSettings["position"] = someInitSettings["position"];
end
tFrame["modSettings"] = someModSettings;
self:Move();
end,
["Move"] = function(self)
local tXPos, tYPos;
local tAngle = VuhDoMinimapButton["modSettings"]["position"];
--[[if (VuhDoMinimapButton["modSettings"]["drag"] == "SQUARE") then
tXPos = 110 * cos(tAngle);
tYPos = 110 * sin(tAngle);
tXPos = math.max(-82, math.min(tXPos, 84));
tYPos = math.max(-86, math.min(tYPos, 82));
else]]
tXPos = 80 * cos(tAngle);
tYPos = 80 * sin(tAngle);
--end
VuhDoMinimapButton:SetPoint("TOPLEFT", "Minimap", "TOPLEFT", 54 - tXPos, tYPos - 54);
end,
-- Internal functions: do not call anything below here
["OnMouseDown"] = function(self)
_G[self:GetName().."Icon"]:SetTexCoord(0, 1, 0, 1);
end,
["OnMouseUp"] = function(self)
_G[self:GetName().."Icon"]:SetTexCoord(0.05, 0.95, 0.05, 0.95);
end,
["OnEnter"] = function(self)
if not GameTooltip:IsForbidden() then
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent);
GameTooltip:AddLine("VuhDo");
GameTooltip:AddLine(VUHDO_I18N_MM_TOOLTIP, 0.8, 0.8, 0.8, 1);
GameTooltip:Show();
end
end,
["OnLeave"] = function(self)
if not GameTooltip:IsForbidden() then
GameTooltip:Hide()
end
end,
["OnDragStart"] = function(self)
self:LockHighlight();
self:SetScript("OnUpdate", VuhDoMinimap.OnUpdate);
end,
["OnDragStop"] = function(self)
self:SetScript("OnUpdate", nil);
self:UnlockHighlight();
end,
["OnUpdate"] = function(self)
local tXPos, tYPos = GetCursorPosition();
local tXMin, tYMin = Minimap:GetLeft(), Minimap:GetBottom();
tXPos = tXMin - tXPos / Minimap:GetEffectiveScale() + 70;
tYPos = tYPos / Minimap:GetEffectiveScale() - tYMin - 70;
self["modSettings"]["position"] = math.deg(math.atan2(tYPos, tXPos));
VuhDoMinimap:Move();
end,
["OnClick"] = function(self, aButtonName)
if "LeftButton" == aButtonName then
VUHDO_slashCmd("opt");
elseif "RightButton" == aButtonName then
ToggleDropDownMenu(1, nil, VuhDoMinimapDropDown, "VuhDoMinimapButton", 0, -5);
end
end
}
......@@ -9,6 +9,8 @@
## DefaultState: Enabled
## LoadOnDemand: 0
MyMinimapButton.lua
VuhDo.xml
Libs\AceAddon-3.0\AceAddon-3.0.xml
......
local _;
-- For initializing the minimap
VUHDO_MM_SETTINGS = { };
VUHDO_MM_LAYOUT = {
drag = "CIRCLE",
position = 0,
};
VUHDO_LibSharedMedia = LibStub("LibSharedMedia-3.0");
VUHDO_LibDataBroker = LibStub("LibDataBroker-1.1", true);
VUHDO_LibDBIcon = LibStub("LibDBIcon-1.0");
......@@ -103,6 +111,10 @@ function VUHDO_initFuBar()
end
end
if not VUHDO_LibDataBroker or not VUHDO_LibDBIcon then
VuhDoMinimap:Create(VUHDO_MM_SETTINGS, VUHDO_MM_LAYOUT);
end
-- Native FuBar
if LibStub:GetLibrary("LibFuBarPlugin-3.0", true)
and IsAddOnLoaded("FuBar")
......@@ -224,10 +236,14 @@ end
--
function VUHDO_initShowMinimap()
if VUHDO_CONFIG["SHOW_MINIMAP"] then
VUHDO_LibDBIcon:Show("VuhDo");
if not VUHDO_LibDataBroker or not VUHDO_LibDBIcon then
VuhDoMinimapButton:SetShown(VUHDO_CONFIG["SHOW_MINIMAP"]);
else
VUHDO_LibDBIcon:Hide("VuhDo");
if VUHDO_CONFIG["SHOW_MINIMAP"] then
VUHDO_LibDBIcon:Show("VuhDo");
else
VUHDO_LibDBIcon:Hide("VuhDo");
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment