You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
164 lines
4.3 KiB
164 lines
4.3 KiB
|
5 years ago
|
local myname = ...
|
||
|
|
|
||
|
|
local core = LibStub("AceAddon-3.0"):GetAddon("SilverDragon")
|
||
|
|
local module = core:NewModule("VignetteStretch", "AceEvent-3.0")
|
||
|
|
local Debug = core.Debug
|
||
|
|
local ns = core.NAMESPACE
|
||
|
|
|
||
|
|
local HBD = LibStub("HereBeDragons-2.0")
|
||
|
|
local HBDPins = LibStub("HereBeDragons-Pins-2.0")
|
||
|
|
|
||
|
|
local compat_disabled
|
||
|
|
|
||
|
|
local db
|
||
|
|
function module:OnInitialize()
|
||
|
|
self.db = core.db:RegisterNamespace("VignetteStretch", {
|
||
|
|
profile = {
|
||
|
|
enabled = true,
|
||
|
|
types = {
|
||
|
|
vignettekill = true,
|
||
|
|
vignettekillelite = true,
|
||
|
|
vignetteloot = true,
|
||
|
|
vignettelootelite = true,
|
||
|
|
vignetteevent = true,
|
||
|
|
vignetteeventelite = true,
|
||
|
|
},
|
||
|
|
},
|
||
|
|
})
|
||
|
|
db = self.db.profile
|
||
|
|
|
||
|
|
compat_disabled = IsAddOnLoaded("MinimapRangeExtender")
|
||
|
|
self.compat_disabled = compat_disabled
|
||
|
|
|
||
|
|
self.pool = CreateFramePool("FRAME", Minimap, "SilverDragonVignetteStretchPinTemplate")
|
||
|
|
|
||
|
|
self:RegisterConfig()
|
||
|
|
end
|
||
|
|
|
||
|
|
function module:OnEnable()
|
||
|
|
self:RegisterEvent("VIGNETTE_MINIMAP_UPDATED")
|
||
|
|
self:RegisterEvent("VIGNETTES_UPDATED")
|
||
|
|
self:RegisterEvent("PLAYER_ENTERING_WORLD", "VIGNETTES_UPDATED")
|
||
|
|
|
||
|
|
self:VIGNETTES_UPDATED()
|
||
|
|
end
|
||
|
|
|
||
|
|
local vignetteIcons = {
|
||
|
|
-- [instanceid] = icon
|
||
|
|
}
|
||
|
|
|
||
|
|
function module:VIGNETTE_MINIMAP_UPDATED(event, instanceid, onMinimap, ...)
|
||
|
|
-- Debug("VIGNETTE_MINIMAP_UPDATED", instanceid, onMinimap, ...)
|
||
|
|
if not instanceid then
|
||
|
|
-- ...just in case
|
||
|
|
Debug("No Vignette instanceid")
|
||
|
|
return
|
||
|
|
end
|
||
|
|
|
||
|
|
local icon = vignetteIcons[instanceid]
|
||
|
|
if not icon then
|
||
|
|
return module:UpdateVignetteOnMinimap(instanceid)
|
||
|
|
end
|
||
|
|
|
||
|
|
if onMinimap then
|
||
|
|
icon.texture:Hide()
|
||
|
|
else
|
||
|
|
icon.texture:Show()
|
||
|
|
end
|
||
|
|
end
|
||
|
|
function module:VIGNETTES_UPDATED()
|
||
|
|
local vignetteids = C_VignetteInfo.GetVignettes()
|
||
|
|
-- Debug("VIGNETTES_UPDATED", #vignetteids)
|
||
|
|
|
||
|
|
for instanceid, icon in pairs(vignetteIcons) do
|
||
|
|
if not tContains(vignetteids, instanceid) or not db.types[icon.info.atlasName:lower()] or not db.enabled then
|
||
|
|
HBDPins:RemoveMinimapIcon(self, icon)
|
||
|
|
icon:Hide()
|
||
|
|
icon.info = nil
|
||
|
|
vignetteIcons[instanceid] = nil
|
||
|
|
self.pool:Release(icon)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
for i=1, #vignetteids do
|
||
|
|
self:UpdateVignetteOnMinimap(vignetteids[i])
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
function module:UpdateVignetteOnMinimap(instanceid)
|
||
|
|
if compat_disabled or not db.enabled then
|
||
|
|
return
|
||
|
|
end
|
||
|
|
-- Debug("considering vignette", instanceid)
|
||
|
|
local uiMapID = HBD:GetPlayerZone()
|
||
|
|
if not uiMapID then
|
||
|
|
return -- Debug("can't determine current zone")
|
||
|
|
end
|
||
|
|
local vignetteInfo = C_VignetteInfo.GetVignetteInfo(instanceid)
|
||
|
|
if not (vignetteInfo and vignetteInfo.vignetteGUID and vignetteInfo.atlasName) then
|
||
|
|
return -- Debug("vignette had no info")
|
||
|
|
end
|
||
|
|
if vignetteInfo.type ~= Enum.VignetteType.Normal then
|
||
|
|
return -- Debug("vignette isn't normal")
|
||
|
|
end
|
||
|
|
if not db.types[vignetteInfo.atlasName:lower()] then
|
||
|
|
return -- Debug("vignette type not enabled", vignetteInfo.atlasName)
|
||
|
|
end
|
||
|
|
local position = C_VignetteInfo.GetVignettePosition(vignetteInfo.vignetteGUID, uiMapID)
|
||
|
|
if not position then
|
||
|
|
return -- Debug("vignette had no position")
|
||
|
|
end
|
||
|
|
local x, y = position:GetXY()
|
||
|
|
|
||
|
|
local icon = vignetteIcons[instanceid]
|
||
|
|
if not icon then
|
||
|
|
icon = self.pool:Acquire()
|
||
|
|
icon.texture:SetAtlas(vignetteInfo.atlasName)
|
||
|
|
icon.texture:SetDesaturated(true)
|
||
|
|
vignetteIcons[instanceid] = icon
|
||
|
|
HBDPins:AddMinimapIconMap(self, icon, uiMapID, x, y, false, true)
|
||
|
|
icon.info = vignetteInfo
|
||
|
|
end
|
||
|
|
|
||
|
|
if vignetteInfo.onMinimap then
|
||
|
|
icon.texture:Hide()
|
||
|
|
else
|
||
|
|
icon.texture:Show()
|
||
|
|
end
|
||
|
|
|
||
|
|
self:UpdateEdge(icon)
|
||
|
|
end
|
||
|
|
|
||
|
|
function module:UpdateEdge(icon)
|
||
|
|
icon:SetAlpha(HBDPins:IsMinimapIconOnEdge(icon) and 0.6 or 1)
|
||
|
|
end
|
||
|
|
|
||
|
|
C_Timer.NewTicker(1, function(...)
|
||
|
|
for instanceid, icon in pairs(vignetteIcons) do
|
||
|
|
module:UpdateEdge(icon)
|
||
|
|
end
|
||
|
|
end)
|
||
|
|
|
||
|
|
SilverDragonVignetteStretchPinMixin = {}
|
||
|
|
function SilverDragonVignetteStretchPinMixin:OnLoad()
|
||
|
|
-- self:SetMovable(true)
|
||
|
|
-- self:RegisterForClicks("AnyUp", "AnyDown")
|
||
|
|
-- Debug("OnLoad")
|
||
|
|
end
|
||
|
|
function SilverDragonVignetteStretchPinMixin:OnMouseEnter()
|
||
|
|
-- TODO: see VignettePinMixin for PVP bounty vignettes if I want to handle this?
|
||
|
|
-- Debug("OnMouseEnter", self, self.info and self.info.name)
|
||
|
|
if not (self.info and self.info.name) then return end
|
||
|
|
if self:GetCenter() > UIParent:GetCenter() then
|
||
|
|
GameTooltip:SetOwner(self, "ANCHOR_LEFT")
|
||
|
|
else
|
||
|
|
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
|
||
|
|
end
|
||
|
|
GameTooltip_SetTitle(GameTooltip, self.info.name)
|
||
|
|
GameTooltip:Show()
|
||
|
|
end
|
||
|
|
function SilverDragonVignetteStretchPinMixin:OnMouseLeave()
|
||
|
|
GameTooltip:Hide()
|
||
|
|
end
|
||
|
|
|