TotemPlates compatible with:

- Plater
- KUI Nameplates
- NeatPlates
- TidyPlates ThreatPlates
- TukUI
- ElvUI
This commit is contained in:
Sumsebrum 2021-06-15 17:09:25 +02:00
parent 2be103fb88
commit b363df73a3

View File

@ -236,12 +236,26 @@ function TotemPlates:Initialize()
--GetCVar("nameplateShowFriendlyTotems") --GetCVar("nameplateShowFriendlyTotems")
--SetCVar("nameplateShowFriendlyTotems", true); --SetCVar("nameplateShowFriendlyTotems", true);
end end
self.addon = "Blizzard"
--NeatPlates if (IsAddOnLoaded("Plater")) then
--ELVUI self.addon = "Plater"
--Plater elseif (IsAddOnLoaded("Kui_Nameplates")) then
--KUI self.addon = "Kui_Nameplates"
--threatplates elseif (IsAddOnLoaded("NeatPlates")) then
self.addon = "NeatPlates"
elseif (IsAddOnLoaded("TidyPlates_ThreatPlates")) then
self.addon = "TidyPlates_ThreatPlates"
elseif (IsAddOnLoaded("Tukui")) then
local _, C, _ = Tukui:unpack()
if C.NamePlates.Enable then
self.addon = "Tukui"
end
elseif (IsAddOnLoaded("ElvUI")) then
local E = unpack(ElvUI)
if E.private.nameplates.enable then
self.addon = "ElvUI"
end
end
end end
function TotemPlates:PLAYER_ENTERING_WORLD() function TotemPlates:PLAYER_ENTERING_WORLD()
@ -282,6 +296,44 @@ end
--------------------------------------------------- ---------------------------------------------------
-- TotemPlates Frame
---------------------------------------------------
function TotemPlates:CreateTotemFrame(nameplate)
nameplate.gladdyTotemFrame = CreateFrame("Frame")
nameplate.gladdyTotemFrame:SetIgnoreParentAlpha(true)
nameplate.gladdyTotemFrame:SetWidth(Gladdy.db.npTotemPlatesSize * Gladdy.db.npTotemPlatesWidthFactor)
nameplate.gladdyTotemFrame:SetHeight(Gladdy.db.npTotemPlatesSize)
nameplate.gladdyTotemFrame.totemIcon = nameplate.gladdyTotemFrame:CreateTexture(nil, "BACKGROUND")
nameplate.gladdyTotemFrame.totemIcon:SetMask("Interface\\AddOns\\Gladdy\\Images\\mask")
nameplate.gladdyTotemFrame.totemIcon:ClearAllPoints()
nameplate.gladdyTotemFrame.totemIcon:SetPoint("TOPLEFT", nameplate.gladdyTotemFrame, "TOPLEFT")
nameplate.gladdyTotemFrame.totemIcon:SetPoint("BOTTOMRIGHT", nameplate.gladdyTotemFrame, "BOTTOMRIGHT")
nameplate.gladdyTotemFrame.totemBorder = nameplate.gladdyTotemFrame:CreateTexture(nil, "BORDER")
nameplate.gladdyTotemFrame.totemBorder:ClearAllPoints()
nameplate.gladdyTotemFrame.totemBorder:SetPoint("TOPLEFT", nameplate.gladdyTotemFrame, "TOPLEFT")
nameplate.gladdyTotemFrame.totemBorder:SetPoint("BOTTOMRIGHT", nameplate.gladdyTotemFrame, "BOTTOMRIGHT")
nameplate.gladdyTotemFrame.totemBorder:SetTexture(Gladdy.db.npTotemPlatesBorderStyle)
nameplate.gladdyTotemFrame.totemName = nameplate.gladdyTotemFrame:CreateFontString(nil, "OVERLAY")
nameplate.gladdyTotemFrame.totemName:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.npTremorFont), Gladdy.db.npTremorFontSize, "OUTLINE")
nameplate.gladdyTotemFrame.totemName:SetPoint("TOP", nameplate.gladdyTotemFrame, "BOTTOM", Gladdy.db.npTremorFontXOffset, Gladdy.db.npTremorFontYOffset)
nameplate.gladdyTotemFrame.selectionHighlight = nameplate.gladdyTotemFrame:CreateTexture(nil, "OVERLAY")
nameplate.gladdyTotemFrame.selectionHighlight:SetTexture("Interface/TargetingFrame/UI-TargetingFrame-BarFill")
nameplate.gladdyTotemFrame.selectionHighlight:SetAlpha(0)
nameplate.gladdyTotemFrame.selectionHighlight:SetBlendMode("ADD")
nameplate.gladdyTotemFrame.selectionHighlight:SetIgnoreParentAlpha(true)
nameplate.gladdyTotemFrame.selectionHighlight:SetPoint("TOPLEFT", nameplate.gladdyTotemFrame, "TOPLEFT", Gladdy.db.npTotemPlatesSize/16, -Gladdy.db.npTotemPlatesSize/16)
nameplate.gladdyTotemFrame.selectionHighlight:SetPoint("BOTTOMRIGHT", nameplate.gladdyTotemFrame, "BOTTOMRIGHT", -Gladdy.db.npTotemPlatesSize/16, Gladdy.db.npTotemPlatesSize/16)
nameplate.gladdyTotemFrame:SetScript('OnUpdate', TotemPlates.OnUpdate)
nameplate.gladdyTotemFrame:SetScript("OnHide", function(self)
self.parent = nil
self:SetParent(nil)
end)
end
---------------------------------------------------
-- Nameplate functions -- Nameplate functions
--------------------------------------------------- ---------------------------------------------------
@ -292,6 +344,38 @@ function TotemPlates:PLAYER_TARGET_CHANGED()
end end
end end
function TotemPlates:ToggleAddon(nameplate, show)
if not show then
if self.addon == "Blizzard" then
nameplate.UnitFrame:Hide()
elseif self.addon == "Plater" then
nameplate.unitFrame:Hide()
elseif self.addon == "Kui_Nameplates" then
nameplate.kui:Hide()
elseif self.addon == "NeatPlates" then
nameplate.extended:Hide()
nameplate.carrier:Hide()
elseif self.addon == "TidyPlates_ThreatPlates" then
nameplate.TPFrame:Hide()
elseif self.addon == "Tukui" or self.addon == "ElvUI" then
if nameplate.unitFrame then
nameplate.unitFrame:Hide()
end
end
end
end
function TotemPlates.OnUpdate(self)
if (UnitIsUnit("mouseover", self.unitID) or UnitIsUnit("target", self.unitID)) then
self.selectionHighlight:SetAlpha(.25)
else
self.selectionHighlight:SetAlpha(0)
end
if (TotemPlates.addon == "Tukui" or TotemPlates.addon == "ElvUI") and self.parent and self.parent.unitFrame then
self.parent.unitFrame:Hide()
end
end
function TotemPlates:NAME_PLATE_UNIT_ADDED(...) function TotemPlates:NAME_PLATE_UNIT_ADDED(...)
local unitID = ... local unitID = ...
local isEnemy = UnitIsEnemy("player", unitID) local isEnemy = UnitIsEnemy("player", unitID)
@ -309,28 +393,12 @@ function TotemPlates:NAME_PLATE_UNIT_ADDED(...)
local nameplate = C_NamePlate.GetNamePlateForUnit(unitID) local nameplate = C_NamePlate.GetNamePlateForUnit(unitID)
local totemDataEntry = localizedTotemData["default"][totemName] or localizedTotemData["frFR"][totemName] or localizedTotemData["ruRU"][totemName] local totemDataEntry = localizedTotemData["default"][totemName] or localizedTotemData["frFR"][totemName] or localizedTotemData["ruRU"][totemName]
if totemDataEntry and Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].enabled then-- modify this nameplates if totemDataEntry and Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].enabled then-- modify this nameplates
if #self.totemPlateCache > 0 then if #self.totemPlateCache > 0 then
nameplate.gladdyTotemFrame = tremove(self.totemPlateCache, #self.totemPlateCache) nameplate.gladdyTotemFrame = tremove(self.totemPlateCache, #self.totemPlateCache)
else else
nameplate.gladdyTotemFrame = CreateFrame("Frame", nil) self:CreateTotemFrame(nameplate)
nameplate.gladdyTotemFrame:SetIgnoreParentAlpha(true)
nameplate.gladdyTotemFrame:SetWidth(Gladdy.db.npTotemPlatesSize * Gladdy.db.npTotemPlatesWidthFactor)
nameplate.gladdyTotemFrame:SetHeight(Gladdy.db.npTotemPlatesSize)
nameplate.gladdyTotemFrame.totemIcon = nameplate.gladdyTotemFrame:CreateTexture(nil, "BACKGROUND")
nameplate.gladdyTotemFrame.totemIcon:SetMask("Interface\\AddOns\\Gladdy\\Images\\mask")
nameplate.gladdyTotemFrame.totemIcon:ClearAllPoints()
nameplate.gladdyTotemFrame.totemIcon:SetPoint("TOPLEFT", nameplate.gladdyTotemFrame, "TOPLEFT")
nameplate.gladdyTotemFrame.totemIcon:SetPoint("BOTTOMRIGHT", nameplate.gladdyTotemFrame, "BOTTOMRIGHT")
nameplate.gladdyTotemFrame.totemBorder = nameplate.gladdyTotemFrame:CreateTexture(nil, "BORDER")
nameplate.gladdyTotemFrame.totemBorder:ClearAllPoints()
nameplate.gladdyTotemFrame.totemBorder:SetPoint("TOPLEFT", nameplate.gladdyTotemFrame, "TOPLEFT")
nameplate.gladdyTotemFrame.totemBorder:SetPoint("BOTTOMRIGHT", nameplate.gladdyTotemFrame, "BOTTOMRIGHT")
nameplate.gladdyTotemFrame.totemBorder:SetTexture(Gladdy.db.npTotemPlatesBorderStyle)
nameplate.gladdyTotemFrame.totemName = nameplate.gladdyTotemFrame:CreateFontString(nil, "OVERLAY")
nameplate.gladdyTotemFrame.totemName:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.npTremorFont), Gladdy.db.npTremorFontSize, "OUTLINE")
nameplate.gladdyTotemFrame.totemName:SetPoint("TOP", nameplate.gladdyTotemFrame, "BOTTOM", Gladdy.db.npTremorFontXOffset, Gladdy.db.npTremorFontYOffset)
end end
nameplate.gladdyTotemFrame.unitID = unitID
nameplate.gladdyTotemFrame.totemDataEntry = totemDataEntry nameplate.gladdyTotemFrame.totemDataEntry = totemDataEntry
nameplate.gladdyTotemFrame.parent = nameplate nameplate.gladdyTotemFrame.parent = nameplate
nameplate.gladdyTotemFrame:SetParent(nameplate) nameplate.gladdyTotemFrame:SetParent(nameplate)
@ -342,20 +410,10 @@ function TotemPlates:NAME_PLATE_UNIT_ADDED(...)
Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].color.b, Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].color.b,
Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].color.a) Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].color.a)
nameplate.gladdyTotemFrame.totemName:SetText(Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].customText or "") nameplate.gladdyTotemFrame.totemName:SetText(Gladdy.db.npTotemColors["totem" .. totemDataEntry.id].customText or "")
nameplate.gladdyTotemFrame.parent = nameplate
nameplate.gladdyTotemFrame:Show() nameplate.gladdyTotemFrame:Show()
TotemPlates:SetTotemAlpha(nameplate.gladdyTotemFrame, unitID) TotemPlates:SetTotemAlpha(nameplate.gladdyTotemFrame, unitID)
self:ToggleAddon(nameplate, false)
nameplate.UnitFrame:SetAlpha(0)
nameplate.UnitFrame.selectionHighlight:ClearAllPoints()
nameplate.UnitFrame.selectionHighlight:SetPoint("TOPLEFT", nameplate.gladdyTotemFrame, "TOPLEFT", Gladdy.db.npTotemPlatesSize/16, -Gladdy.db.npTotemPlatesSize/16)
nameplate.UnitFrame.selectionHighlight:SetPoint("BOTTOMRIGHT", nameplate.gladdyTotemFrame, "BOTTOMRIGHT", -Gladdy.db.npTotemPlatesSize/16, Gladdy.db.npTotemPlatesSize/16)
nameplate.UnitFrame:SetScript("OnHide", function(unitFrame)
unitFrame:SetAlpha(1)
unitFrame.selectionHighlight:ClearAllPoints()
unitFrame.selectionHighlight:SetPoint("TOPLEFT", unitFrame.healthBar.barTexture, "TOPLEFT")
unitFrame.selectionHighlight:SetPoint("BOTTOMRIGHT", unitFrame.healthBar.barTexture, "BOTTOMRIGHT")
unitFrame:SetScript("OnHide", nil)
end)
self.activeTotemNameplates[unitID] = nameplate self.activeTotemNameplates[unitID] = nameplate
end end
end end