Commit 99e604a1 authored by Ivaria's avatar Ivaria
Browse files

Migrate minimap icon to LibDBIcon (fixes SexyMap compatibility)

parent 66b5b229
......@@ -17,6 +17,7 @@ externals:
Libs/UTF8: svn://svn.wowace.com/wow/utf8/mainline/trunk
Libs/LibCompress: svn://svn.wowace.com/wow/libcompress/mainline/trunk
Libs/LibBase64-1.0: git://git.wowace.com/wow/libbase64-1-0/mainline.git
Libs/LibDBIcon-1.0: svn://svn.wowace.com/wow/libdbicon-1-0/mainline/trunk
VuhDoOptions/Libs/ChatThrottleLib: svn://svn.wowace.com/wow/chatthrottlelib/mainline/trunk
......
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,8 +9,6 @@
## DefaultState: Enabled
## LoadOnDemand: 0
MyMinimapButton.lua
VuhDo.xml
Libs\AceAddon-3.0\AceAddon-3.0.xml
......
......@@ -9,7 +9,8 @@
<Script file="Libs\UTF8\utf8.lua" />
<Script file="Libs\LibCompress\LibCompress.lua" />
<Script file="Libs\LibBase64-1.0\LibBase64-1.0.lua" />
<Script file="Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua" />
<Script file="VuhDoLocalization_en.lua" />
<Script file="VuhDoLocalization_de.lua" />
<Script file="VuhDoLocalization_fr.lua" />
......
......@@ -2,6 +2,8 @@ local _;
VUHDO_LibSharedMedia = LibStub("LibSharedMedia-3.0");
VUHDO_LibDataBroker = LibStub("LibDataBroker-1.1", true);
VUHDO_LibDBIcon = LibStub("LibDBIcon-1.0");
VUHDO_LibButtonFacade = nil;
VUHDO_LibCompress = LibStub:GetLibrary("LibCompress");
......@@ -76,9 +78,9 @@ end
function VUHDO_initFuBar()
-- libDataBroker
if VUHDO_LibDataBroker then
VUHDO_LibDataBroker:NewDataObject("VuhDo", {
local minimapObject = VUHDO_LibDataBroker:NewDataObject("VuhDo", {
type = "launcher",
icon = "Interface\\AddOns\\VuhDo\\Images\\VuhDo",
icon = VUHDO_STANDARD_ICON,
OnClick = function(aClickedFrame, aButton)
if aButton == "RightButton" then
ToggleDropDownMenu(1, nil, VuhDoMinimapDropDown, aClickedFrame:GetName(), 0, -5);
......@@ -91,7 +93,12 @@ function VUHDO_initFuBar()
aTooltip:AddLine(VUHDO_I18N_BROKER_TOOLTIP_1)
aTooltip:AddLine(VUHDO_I18N_BROKER_TOOLTIP_2)
end,
})
});
-- Minimap icon provided by LibDBIcon
if VUHDO_LibDBIcon then
VUHDO_LibDBIcon:Register("VuhDo", minimapObject);
end
end
-- Native FuBar
......@@ -106,7 +113,7 @@ function VUHDO_initFuBar()
VuhDo:SetFuBarOption("hasNoColor", true);
VuhDo:SetFuBarOption("cannotDetachTooltip", true);
VuhDo:SetFuBarOption("hideWithoutStandby", true);
VuhDo:SetFuBarOption("iconPath", "Interface\\AddOns\\VuhDo\\Images\\VuhDo");
VuhDo:SetFuBarOption("iconPath", VUHDO_STANDARD_ICON);
VuhDo:SetFuBarOption("hasIcon", true);
VuhDo:SetFuBarOption("defaultPosition", "RIGHT");
VuhDo:SetFuBarOption("tooltipHiddenWhenEmpty", true);
......@@ -200,3 +207,25 @@ function VUHDO_initButtonFacade(anInstance)
VUHDO_LibButtonFacade:Group("VuhDo", VUHDO_I18N_HOTS);
end
end
--
function VUHDO_initMinimap()
VUHDO_initShowMinimap();
end
--
function VUHDO_initShowMinimap()
if VUHDO_CONFIG["SHOW_MINIMAP"] then
VUHDO_LibDBIcon:Show("VuhDo");
else
VUHDO_LibDBIcon:Hide("VuhDo");
end
end
local _;
VUHDO_MM_SETTINGS = { };
local VUHDO_MENU_UNIT = nil;
......@@ -394,18 +393,3 @@ function VUHDO_minimapItemSelected(_, anId)
VUHDO_slashCmd(tCmd);
end
--
function VUHDO_initMinimap()
VuhDoMinimap:Create(VUHDO_MM_SETTINGS, VUHDO_MM_LAYOUT);
VUHDO_initShowMinimap();
end
--
function VUHDO_initShowMinimap()
VuhDoMinimapButton:SetShown(VUHDO_CONFIG["SHOW_MINIMAP"]);
end
......@@ -53,14 +53,6 @@ VUHDO_HEADER_TEXTS = {
-- For initializing the minimap
VUHDO_MM_LAYOUT = {
drag = "CIRCLE",
position = 0,
};
--
VUHDO_CUSTOM_ICONS = {
{ VUHDO_I18N_CUSTOM_ICON_NONE, nil }, -- 1
......
......@@ -18,6 +18,7 @@ Bugfixes:
Improvements:
-- Migrate minimap icon to LibDBIcon (fixes SexyMap compat)
--------------------------------------------------------------
......
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