Initial Commit
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
--[[
|
||||
-- Kui_Nameplates
|
||||
-- By Kesava at curse.com
|
||||
-- All rights reserved
|
||||
-- Backported by: Kader at github.com/bkader
|
||||
--
|
||||
-- Modifications for plates while in an arena
|
||||
]]
|
||||
local addon = LibStub("AceAddon-3.0"):GetAddon("KuiNameplates")
|
||||
local mod = addon:NewModule("Arena", addon.Prototype, "AceEvent-3.0")
|
||||
local L = LibStub("AceLocale-3.0"):GetLocale("KuiNameplates")
|
||||
|
||||
mod.uiName = L["Arena modifications"]
|
||||
|
||||
local UnitExists, UnitName = UnitExists, UnitName
|
||||
local in_arena
|
||||
|
||||
function mod:IsArenaPlate(frame)
|
||||
if frame.friend then
|
||||
frame.level:SetText()
|
||||
return
|
||||
end
|
||||
|
||||
for i = 1, 5 do
|
||||
if UnitExists("arena" .. i) and frame.name.text == UnitName("arena" .. i) then
|
||||
frame.level:SetText(i)
|
||||
return
|
||||
elseif UnitExists("arenapet" .. i) and frame.name.text == UnitName("arenapet" .. i) then
|
||||
frame.level:SetText(i .. "*")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- unhandled name
|
||||
frame.level:SetText()
|
||||
end
|
||||
|
||||
function mod:PostShow(msg, frame)
|
||||
if in_arena and not frame.friend then
|
||||
self:IsArenaPlate(frame)
|
||||
frame.level:SetWidth(0)
|
||||
frame.level:Show()
|
||||
end
|
||||
end
|
||||
|
||||
function mod:UNIT_NAME_UPDATE(event, unit)
|
||||
if not strfind(unit, "^arena") then
|
||||
return
|
||||
end
|
||||
|
||||
local frame = addon:GetUnitPlate(unit)
|
||||
if not frame or frame.friend then
|
||||
return
|
||||
end
|
||||
|
||||
self:IsArenaPlate(frame)
|
||||
frame.level:SetWidth(0)
|
||||
frame.level:Show()
|
||||
end
|
||||
|
||||
function mod:CheckArena()
|
||||
local in_instance, instance_type = IsInInstance()
|
||||
if in_instance and instance_type == "arena" then
|
||||
in_arena = true
|
||||
self:RegisterMessage("KuiNameplates_PostShow", "PostShow")
|
||||
self:RegisterEvent("UNIT_NAME_UPDATE")
|
||||
else
|
||||
in_arena = nil
|
||||
self:UnregisterMessage("KuiNameplates_PostShow", "PostShow")
|
||||
self:UnregisterEvent("UNIT_NAME_UPDATE")
|
||||
end
|
||||
end
|
||||
|
||||
function mod:OnInitialize()
|
||||
self:SetEnabledState(true)
|
||||
end
|
||||
|
||||
function mod:OnEnable()
|
||||
self:RegisterEvent("PLAYER_ENTERING_WORLD", "CheckArena")
|
||||
self:RegisterEvent("ZONE_CHANGED_NEW_AREA", "CheckArena")
|
||||
end
|
||||
|
||||
function mod:OnDisable()
|
||||
self:UnregisterAllEvents()
|
||||
end
|
||||
@@ -0,0 +1,230 @@
|
||||
--[[
|
||||
-- Kui_Nameplates
|
||||
-- By Kesava at curse.com
|
||||
-- All rights reserved
|
||||
-- Backported by: Kader at https://github.com/bkader
|
||||
]]
|
||||
local addon = LibStub("AceAddon-3.0"):GetAddon("KuiNameplates")
|
||||
local mod = addon:NewModule("CastWarnings", addon.Prototype, "AceEvent-3.0")
|
||||
local kui = LibStub("Kui-1.0")
|
||||
local L = LibStub("AceLocale-3.0"):GetLocale("KuiNameplates")
|
||||
|
||||
mod.uiName = L["Cast warnings"]
|
||||
|
||||
-- combat log events to listen to for cast warnings/healing
|
||||
local warningEvents = {
|
||||
["SPELL_CAST_START"] = true,
|
||||
["SPELL_CAST_SUCCESS"] = true,
|
||||
["SPELL_INTERRUPT"] = true,
|
||||
["SPELL_HEAL"] = true,
|
||||
["SPELL_PERIODIC_HEAL"] = true
|
||||
}
|
||||
|
||||
-- spell school colors
|
||||
local schoolcolors = {
|
||||
[1] = {a = 1.00, r = 1.00, g = 1.00, b = 0.00}, -- Physical
|
||||
[2] = {a = 1.00, r = 1.00, g = 0.90, b = 0.50}, -- Holy
|
||||
[4] = {a = 1.00, r = 1.00, g = 0.50, b = 0.00}, -- Fire
|
||||
[8] = {a = 1.00, r = 0.30, g = 1.00, b = 0.30}, -- Nature
|
||||
[16] = {a = 1.00, r = 0.50, g = 1.00, b = 1.00}, -- Frost
|
||||
[20] = {a = 1.00, r = 0.50, g = 1.00, b = 1.00}, -- Frostfire
|
||||
[32] = {a = 1.00, r = 0.50, g = 0.50, b = 1.00}, -- Shadow
|
||||
[64] = {a = 1.00, r = 1.00, g = 0.50, b = 1.00} -- Arcane
|
||||
}
|
||||
|
||||
-- wrapper for kui.framefade;
|
||||
-- reimplementing previous behaviour from animation groups
|
||||
local function FadeFrame(self, from, to, duration, end_delay, callback)
|
||||
kui.frameFadeRemoveFrame(self)
|
||||
|
||||
self:Show()
|
||||
self:SetAlpha(from)
|
||||
|
||||
kui.frameFade(self, {
|
||||
mode = "OUT",
|
||||
startAlpha = from,
|
||||
endAlpha = to,
|
||||
timeToFade = duration,
|
||||
fadeHoldTime = end_delay,
|
||||
finishedFunc = function(self)
|
||||
if to == 0 then
|
||||
self:Hide()
|
||||
else
|
||||
self:SetAlpha(to)
|
||||
end
|
||||
|
||||
if callback then
|
||||
callback(self)
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
------------------------------------------------------------- Frame functions --
|
||||
local function SetCastWarning(self, spellName, spellSchool)
|
||||
self.castWarning:Stop()
|
||||
|
||||
if spellName == nil then
|
||||
-- hide the warning instantly
|
||||
self.castWarning:SetText()
|
||||
self.castWarning:Hide()
|
||||
else
|
||||
local col = schoolcolors[spellSchool] or {r = 1, g = 1, b = 1}
|
||||
|
||||
self.castWarning:SetText(spellName)
|
||||
self.castWarning:SetTextColor(col.r, col.g, col.b)
|
||||
self.castWarning:Fade()
|
||||
end
|
||||
end
|
||||
|
||||
local function SetIncomingWarning(self, amount)
|
||||
if amount == 0 then
|
||||
return
|
||||
end
|
||||
self.incWarning:Stop()
|
||||
|
||||
if amount > 0 then
|
||||
-- healing
|
||||
amount = "+" .. amount
|
||||
self.incWarning:SetTextColor(0, 1, 0)
|
||||
else
|
||||
-- damage (nyi)
|
||||
self.incWarning:SetTextColor(1, 0, 0)
|
||||
end
|
||||
|
||||
self.incWarning:SetText(amount)
|
||||
self.incWarning:Fade()
|
||||
end
|
||||
|
||||
-------------------------------------------------------------- Event handlers --
|
||||
function mod:COMBAT_LOG_EVENT_UNFILTERED(_, castTime, event, guid, name, _, targetGUID, targetName, _, _, spellName, spellSchool, amount)
|
||||
if not (guid and targetGUID) then
|
||||
return
|
||||
end
|
||||
|
||||
if warningEvents[event] then
|
||||
if event == "SPELL_HEAL" or event == "SPELL_PERIODIC_HEAL" then
|
||||
-- fetch the spell's target's nameplate
|
||||
guid, name = targetGUID, targetName
|
||||
end
|
||||
|
||||
if self.db.profile.useNames and name then
|
||||
name = name and name:gsub("%-.+$", "") -- remove realm names
|
||||
else
|
||||
name = nil
|
||||
end
|
||||
|
||||
local f = addon:GetNameplate(guid, name)
|
||||
if f then
|
||||
if not f.castWarning or f.trivial then
|
||||
return
|
||||
end
|
||||
if event == "SPELL_HEAL" or event == "SPELL_PERIODIC_HEAL" then
|
||||
-- display heal warning
|
||||
f:SetIncomingWarning(amount)
|
||||
elseif event == "SPELL_INTERRUPT" then
|
||||
-- hide the warning
|
||||
f:SetCastWarning(nil)
|
||||
else
|
||||
-- or display it for this spell
|
||||
f:SetCastWarning(spellName, spellSchool)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------- Create --
|
||||
function mod:CreateCastWarnings(msg, frame)
|
||||
-- casting spell name
|
||||
frame.castWarning = frame:CreateFontString(frame.overlay, {size = "spellName", outline = "OUTLINE"})
|
||||
frame.castWarning:Hide()
|
||||
frame.castWarning:SetPoint("BOTTOM", frame.name, "TOP", 0, 1)
|
||||
|
||||
frame.castWarning.Fade = function(self)
|
||||
FadeFrame(self, 1, 0, 3)
|
||||
end
|
||||
frame.castWarning.Stop = function(self)
|
||||
kui.frameFadeRemoveFrame(self)
|
||||
end
|
||||
|
||||
-- incoming healing
|
||||
frame.incWarning = frame:CreateFontString(frame.overlay, {size = "small", outline = "OUTLINE"})
|
||||
frame.incWarning:Hide()
|
||||
frame.incWarning:SetPoint("TOP", frame.name, "BOTTOM", 0, -3)
|
||||
|
||||
frame.incWarning.Fade = function(self, full)
|
||||
if full then
|
||||
FadeFrame(self, 0.5, 0, 0.5)
|
||||
else
|
||||
FadeFrame(self, 1, 0.5, 0.5, 0.5, function(self) self:Fade(true) end)
|
||||
end
|
||||
end
|
||||
frame.incWarning.Stop = function(self)
|
||||
kui.frameFadeRemoveFrame(self)
|
||||
end
|
||||
|
||||
-- handlers
|
||||
frame.SetCastWarning = SetCastWarning
|
||||
frame.SetIncomingWarning = SetIncomingWarning
|
||||
end
|
||||
|
||||
function mod:Hide(msg, frame)
|
||||
if frame.castWarning then
|
||||
frame.castWarning:Stop()
|
||||
frame.castWarning:SetText()
|
||||
frame.castWarning:Hide()
|
||||
|
||||
frame.incWarning:Stop()
|
||||
frame.incWarning:SetText()
|
||||
frame.incWarning:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------- Post db change functions --
|
||||
mod:AddConfigChanged("warnings", function(v) mod:Toggle(v) end)
|
||||
-------------------------------------------------------------------- Register --
|
||||
function mod:GetOptions()
|
||||
return {
|
||||
warnings = {
|
||||
type = "toggle",
|
||||
name = L["Show cast warnings"],
|
||||
desc = L["Display cast and healing warnings on plates"],
|
||||
order = 1,
|
||||
disabled = false
|
||||
},
|
||||
useNames = {
|
||||
type = "toggle",
|
||||
name = L["Use names for warnings"],
|
||||
desc = L["Use character names to decide which frame to display warnings on. May increase memory usage and may cause warnings to be displayed on incorrect frames when there are many units with the same name. Reccommended on for PvP, off for PvE."],
|
||||
order = 2
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
function mod:OnInitialize()
|
||||
self.db = addon.db:RegisterNamespace(self.moduleName, {profile = {warnings = false, useNames = false}})
|
||||
|
||||
addon:InitModuleOptions(self)
|
||||
mod:SetEnabledState(self.db.profile.warnings)
|
||||
end
|
||||
|
||||
function mod:OnEnable()
|
||||
self:RegisterMessage("KuiNameplates_PostCreate", "CreateCastWarnings")
|
||||
self:RegisterMessage("KuiNameplates_PostHide", "Hide")
|
||||
|
||||
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
|
||||
|
||||
for _, frame in pairs(addon.frameList) do
|
||||
if not frame.castWarning then
|
||||
self:CreateCastWarnings(nil, frame.kui)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mod:OnDisable()
|
||||
self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
|
||||
|
||||
for _, frame in pairs(addon.frameList) do
|
||||
self:Hide(nil, frame.kui)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,432 @@
|
||||
--[[
|
||||
-- Kui_Nameplates
|
||||
-- By Kesava at curse.com
|
||||
-- All rights reserved
|
||||
-- Backported by: Kader at github.com/bkader
|
||||
]]
|
||||
local kui = LibStub("Kui-1.0")
|
||||
local addon = LibStub("AceAddon-3.0"):GetAddon("KuiNameplates")
|
||||
local mod = addon:NewModule("Castbar", addon.Prototype, "AceEvent-3.0")
|
||||
local L = LibStub("AceLocale-3.0"):GetLocale("KuiNameplates")
|
||||
|
||||
mod.uiName = L["Cast bars"]
|
||||
|
||||
local format = format
|
||||
local function ResetFade(f)
|
||||
if not f or not f.castbar then
|
||||
return
|
||||
end
|
||||
|
||||
kui.frameFadeRemoveFrame(f.castbar)
|
||||
f.castbar.shield:Hide()
|
||||
f.castbar:Hide()
|
||||
f.castbar:SetAlpha(1)
|
||||
end
|
||||
|
||||
local sizes = {}
|
||||
|
||||
local function SetCVars()
|
||||
-- force these to true as the module hides them anyway
|
||||
SetCVar("showVKeyCastbar", 1)
|
||||
end
|
||||
------------------------------------------------------------- Script handlers --
|
||||
local function OnDefaultCastbarShow(self)
|
||||
if not mod.enabledState then
|
||||
return
|
||||
end
|
||||
|
||||
local f = self:GetParent().kui
|
||||
ResetFade(f)
|
||||
|
||||
if mod:FrameIsIgnored(f) then
|
||||
return
|
||||
end
|
||||
|
||||
if f.castbar.name and f.castbar.spellName then
|
||||
f.castbar.name:SetText(f.castbar.spellName)
|
||||
end
|
||||
|
||||
-- is cast uninterruptible?
|
||||
if f.shield:IsShown() then
|
||||
f.castbar.bar:SetStatusBarColor(unpack(mod.db.profile.display.shieldbarcolour))
|
||||
f.castbar.shield:Show()
|
||||
else
|
||||
f.castbar.bar:SetStatusBarColor(unpack(mod.db.profile.display.barcolour))
|
||||
f.castbar.shield:Hide()
|
||||
end
|
||||
|
||||
if f.trivial then
|
||||
-- hide text & icon
|
||||
if f.castbar.icon or f.castbar.curr then
|
||||
f.castbar.curr:Hide()
|
||||
end
|
||||
else
|
||||
if f.castbar.icon then
|
||||
f.castbar.icon.tex:SetTexture(f.spell:GetTexture())
|
||||
f.castbar.icon:Show()
|
||||
end
|
||||
|
||||
if f.castbar.curr then
|
||||
f.castbar.curr:Show()
|
||||
end
|
||||
end
|
||||
-- castbar is shown on first update
|
||||
end
|
||||
local function OnDefaultCastbarHide(self)
|
||||
local f = self:GetParent().kui
|
||||
if f.castbar:IsShown() then
|
||||
kui.frameFade(
|
||||
f.castbar,
|
||||
{
|
||||
mode = "OUT",
|
||||
timeToFade = .5,
|
||||
startAlpha = 1,
|
||||
endAlpha = 0,
|
||||
finishedFunc = function()
|
||||
ResetFade(f)
|
||||
end
|
||||
}
|
||||
)
|
||||
|
||||
if f.castbar.name then
|
||||
f.castbar.spellName = nil
|
||||
f.castbar.name:SetText("")
|
||||
end
|
||||
|
||||
if f.castbar.icon then
|
||||
f.castbar.icon.tex:SetTexture(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
local function OnDefaultCastbarUpdate(self, elapsed)
|
||||
if not mod.enabledState then
|
||||
return
|
||||
end
|
||||
|
||||
local f = self:GetParent().kui
|
||||
|
||||
if mod:FrameIsIgnored(f) then
|
||||
return
|
||||
end
|
||||
|
||||
local min, max = self:GetMinMaxValues()
|
||||
|
||||
if f.castbar.curr then
|
||||
f.castbar.curr:SetText(format("%.1f", self:GetValue()))
|
||||
end
|
||||
|
||||
if f.castbar.name and f.castbar.spellName then
|
||||
f.castbar.name:SetText(f.castbar.spellName)
|
||||
end
|
||||
|
||||
f.castbar.bar:SetMinMaxValues(min, max)
|
||||
f.castbar.bar:SetValue(self:GetValue())
|
||||
|
||||
if f.shield:IsShown() then
|
||||
f.castbar.bar:SetStatusBarColor(unpack(mod.db.profile.display.shieldbarcolour))
|
||||
f.castbar.shield:Show()
|
||||
else
|
||||
f.castbar.bar:SetStatusBarColor(unpack(mod.db.profile.display.barcolour))
|
||||
f.castbar.shield:Hide()
|
||||
end
|
||||
|
||||
if f.trivial then
|
||||
-- hide text & icon
|
||||
if f.castbar.icon or f.castbar.curr then
|
||||
f.castbar.curr:Hide()
|
||||
end
|
||||
else
|
||||
if f.castbar.icon then
|
||||
f.castbar.icon.tex:SetTexture(f.spell:GetTexture())
|
||||
f.castbar.icon:Show()
|
||||
end
|
||||
|
||||
if f.castbar.curr then
|
||||
f.castbar.curr:Show()
|
||||
end
|
||||
end
|
||||
|
||||
f.castbar:Show()
|
||||
end
|
||||
local function OnDefaultCastbarEvent(self, event, unit, spellName, spellRank)
|
||||
if event == "UNIT_SPELLCAST_START" or event == "UNIT_SPELLCAST_CHANNEL_START" then
|
||||
local frame = addon:GetUnitPlate(unit)
|
||||
if frame and frame.castbar then
|
||||
frame.castbar.spellName = spellName
|
||||
end
|
||||
end
|
||||
end
|
||||
---------------------------------------------------------------------- create --
|
||||
-- update castbar height and icon size
|
||||
local function UpdateCastbar(frame)
|
||||
if not frame.castbar then
|
||||
return
|
||||
end
|
||||
|
||||
if frame.castbar.bg then
|
||||
frame.castbar.bg:SetHeight(sizes.cbheight)
|
||||
end
|
||||
|
||||
if frame.castbar.icon then
|
||||
frame.castbar.icon.bg:SetSize(sizes.icon, sizes.icon)
|
||||
end
|
||||
end
|
||||
function mod:CreateCastbar(frame)
|
||||
if frame.castbar then
|
||||
return
|
||||
end
|
||||
-- container ---------------------------------------------------------------
|
||||
frame.castbar = CreateFrame("Frame", nil, frame)
|
||||
frame.castbar:SetFrameLevel(1)
|
||||
frame.castbar:Hide()
|
||||
|
||||
-- background --------------------------------------------------------------
|
||||
frame.castbar.bg = frame.castbar:CreateTexture(nil, "ARTWORK", nil, 1)
|
||||
frame.castbar.bg:SetTexture(kui.m.t.solid)
|
||||
frame.castbar.bg:SetVertexColor(0, 0, 0, 0.8)
|
||||
|
||||
frame.castbar.bg:SetPoint("TOPLEFT", frame.bg.fill, "BOTTOMLEFT", 0, -1)
|
||||
frame.castbar.bg:SetPoint("TOPRIGHT", frame.bg.fill, "BOTTOMRIGHT", 0, 0)
|
||||
|
||||
-- cast bar ------------------------------------------------------------
|
||||
frame.castbar.bar = CreateFrame("StatusBar", nil, frame.castbar)
|
||||
frame.castbar.bar:SetStatusBarTexture(addon.bartexture)
|
||||
frame.castbar.bar:GetStatusBarTexture():SetDrawLayer("ARTWORK", 2)
|
||||
|
||||
frame.castbar.bar:SetPoint("TOPLEFT", frame.castbar.bg, "TOPLEFT", 1, -1)
|
||||
frame.castbar.bar:SetPoint("BOTTOMLEFT", frame.castbar.bg, "BOTTOMLEFT", 1, 1)
|
||||
frame.castbar.bar:SetPoint("RIGHT", frame.castbar.bg, "RIGHT", -1, 0)
|
||||
|
||||
frame.castbar.bar:SetMinMaxValues(0, 1)
|
||||
|
||||
-- spark
|
||||
frame.castbar.spark = frame.castbar.bar:CreateTexture(nil, "ARTWORK")
|
||||
frame.castbar.spark:SetDrawLayer("ARTWORK", 6)
|
||||
frame.castbar.spark:SetVertexColor(1, 1, 0.8)
|
||||
frame.castbar.spark:SetTexture("Interface\\AddOns\\Kui_Nameplates\\Media\\t\\spark")
|
||||
frame.castbar.spark:SetPoint("TOP", frame.castbar.bar:GetRegions(), "TOPRIGHT", 0, 3)
|
||||
frame.castbar.spark:SetPoint("BOTTOM", frame.castbar.bar:GetRegions(), "BOTTOMRIGHT", 0, -3)
|
||||
frame.castbar.spark:SetWidth(6)
|
||||
|
||||
-- uninterruptible cast shield -----------------------------------------
|
||||
frame.castbar.shield = frame.castbar.bar:CreateTexture(nil, "ARTWORK")
|
||||
frame.castbar.shield:SetTexture("Interface\\AddOns\\Kui_Nameplates\\Media\\Shield")
|
||||
frame.castbar.shield:SetTexCoord(0, 0.84375, 0, 1)
|
||||
frame.castbar.shield:SetVertexColor(0.5, 0.5, 0.7)
|
||||
|
||||
frame.castbar.shield:SetSize(sizes.shield * .84375, sizes.shield)
|
||||
frame.castbar.shield:SetPoint("LEFT", frame.castbar.bg, -7, 0)
|
||||
|
||||
frame.castbar.shield:SetBlendMode("BLEND")
|
||||
frame.castbar.shield:SetDrawLayer("ARTWORK", 7)
|
||||
|
||||
frame.castbar.shield:Hide()
|
||||
|
||||
-- cast bar text -------------------------------------------------------
|
||||
if self.db.profile.display.spellname then
|
||||
frame.castbar.name = frame:CreateFontString(frame.castbar.bar, {size = "small"})
|
||||
frame.castbar.name:SetPoint("TOP", frame.castbar.bar, "BOTTOM", 0, -3)
|
||||
end
|
||||
|
||||
if self.db.profile.display.casttime then
|
||||
frame.castbar.curr = frame:CreateFontString(frame.castbar.bar, {size = "small"})
|
||||
frame.castbar.curr:SetPoint("LEFT", frame.castbar.bg, "RIGHT", 2, 0)
|
||||
end
|
||||
|
||||
if self.db.profile.display.spellicon then
|
||||
frame.castbar.icon = CreateFrame("Frame", nil, frame.castbar)
|
||||
|
||||
frame.castbar.icon.bg = frame.castbar:CreateTexture(nil, "BACKGROUND")
|
||||
frame.castbar.icon.bg:SetTexture(kui.m.t.solid)
|
||||
frame.castbar.icon.bg:SetVertexColor(0, 0, 0, 0)
|
||||
frame.castbar.icon.bg:SetPoint("TOPRIGHT", frame.health, "TOPLEFT", -2, 1)
|
||||
|
||||
frame.castbar.icon.tex = frame.castbar:CreateTexture(nil, "ARTWORK")
|
||||
frame.castbar.icon.tex:SetPoint("TOPLEFT", frame.castbar.icon.bg, "TOPLEFT", 1, -1)
|
||||
frame.castbar.icon.tex:SetPoint("BOTTOMRIGHT", frame.castbar.icon.bg, "BOTTOMRIGHT", -1, 1)
|
||||
end
|
||||
|
||||
UpdateCastbar(frame)
|
||||
|
||||
-- scripts -------------------------------------------------------------
|
||||
frame.oldCastbar:HookScript("OnShow", OnDefaultCastbarShow)
|
||||
frame.oldCastbar:HookScript("OnHide", OnDefaultCastbarHide)
|
||||
frame.oldCastbar:HookScript("OnUpdate", OnDefaultCastbarUpdate)
|
||||
frame.castbar:RegisterEvent("UNIT_SPELLCAST_START")
|
||||
frame.castbar:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START")
|
||||
frame.castbar:SetScript("OnEvent", OnDefaultCastbarEvent)
|
||||
|
||||
if frame.oldCastbar:IsVisible() then
|
||||
OnDefaultCastbarShow(frame.oldCastbar)
|
||||
end
|
||||
end
|
||||
------------------------------------------------------------------------ Hide --
|
||||
function mod:HideCastbar(frame)
|
||||
ResetFade(frame)
|
||||
end
|
||||
------------------------------------------------------------------- Functions --
|
||||
function mod:FrameIsIgnored(frame)
|
||||
return frame.castbar_ignore_frame or (frame.friend and not self.db.profile.onfriendly)
|
||||
end
|
||||
function mod:IgnoreFrame(frame)
|
||||
frame.castbar_ignore_frame = (frame.castbar_ignore_frame and frame.castbar_ignore_frame + 1 or 1)
|
||||
|
||||
if frame.castbar and frame.castbar:IsShown() then
|
||||
ResetFade(frame)
|
||||
end
|
||||
end
|
||||
function mod:UnignoreFrame(frame)
|
||||
frame.castbar_ignore_frame = (frame.castbar_ignore_frame and frame.castbar_ignore_frame - 1 or nil)
|
||||
if frame.castbar_ignore_frame and frame.castbar_ignore_frame <= 0 then
|
||||
frame.castbar_ignore_frame = nil
|
||||
end
|
||||
end
|
||||
---------------------------------------------------- Post db change functions --
|
||||
mod:AddConfigChanged(
|
||||
"enabled",
|
||||
function(v)
|
||||
mod:Toggle(v)
|
||||
end
|
||||
)
|
||||
mod:AddConfigChanged(
|
||||
{"display", "shieldbarcolour"},
|
||||
nil,
|
||||
function(f, v)
|
||||
f.castbar.shield:SetVertexColor(unpack(v))
|
||||
end
|
||||
)
|
||||
mod:AddConfigChanged(
|
||||
{"display", "cbheight"},
|
||||
function()
|
||||
sizes.cbheight = mod.db.profile.display.cbheight
|
||||
sizes.icon = addon.db.profile.general.hheight + sizes.cbheight + 1
|
||||
end,
|
||||
UpdateCastbar
|
||||
)
|
||||
mod:AddGlobalConfigChanged("addon", {"general", "hheight"}, mod.configChangedFuncs.display.cbheight.ro, UpdateCastbar)
|
||||
-------------------------------------------------------------------- Register --
|
||||
function mod:GetOptions()
|
||||
return {
|
||||
enabled = {
|
||||
type = "toggle",
|
||||
name = L["Enable cast bar"],
|
||||
desc = L["Show cast bars (at all)"],
|
||||
order = 0,
|
||||
disabled = false
|
||||
},
|
||||
onfriendly = {
|
||||
type = "toggle",
|
||||
name = L["Show friendly cast bars"],
|
||||
desc = L["Show cast bars on friendly nameplates"],
|
||||
order = 10,
|
||||
disabled = function()
|
||||
return not self.db.profile.enabled
|
||||
end
|
||||
},
|
||||
display = {
|
||||
type = "group",
|
||||
name = L["Display"],
|
||||
inline = true,
|
||||
order = 20,
|
||||
disabled = function()
|
||||
return not self.db.profile.enabled
|
||||
end,
|
||||
args = {
|
||||
casttime = {
|
||||
type = "toggle",
|
||||
name = L["Show cast time"],
|
||||
desc = L["Show cast time and time remaining"],
|
||||
order = 20
|
||||
},
|
||||
spellname = {
|
||||
type = "toggle",
|
||||
name = L["Show spell name"],
|
||||
order = 15
|
||||
},
|
||||
spellicon = {
|
||||
type = "toggle",
|
||||
name = L["Show spell icon"],
|
||||
order = 10
|
||||
},
|
||||
barcolour = {
|
||||
type = "color",
|
||||
name = L["Bar colour"],
|
||||
desc = L["The colour of the cast bar during interruptible casts"],
|
||||
order = 0
|
||||
},
|
||||
shieldbarcolour = {
|
||||
type = "color",
|
||||
name = L["Uninterruptible colour"],
|
||||
desc = L["The colour of the cast bar and shield during UNinterruptible casts."],
|
||||
order = 5
|
||||
},
|
||||
cbheight = {
|
||||
type = "range",
|
||||
name = L["Height"],
|
||||
desc = L["The height of castbars on nameplates. Also affects the size of the spell icon."],
|
||||
order = 25,
|
||||
step = 1,
|
||||
min = 3,
|
||||
softMax = 20,
|
||||
max = 100
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
function mod:OnInitialize()
|
||||
self.db =
|
||||
addon.db:RegisterNamespace(
|
||||
self.moduleName,
|
||||
{
|
||||
profile = {
|
||||
enabled = true,
|
||||
onfriendly = true,
|
||||
display = {
|
||||
casttime = false,
|
||||
spellname = true,
|
||||
spellicon = true,
|
||||
cbheight = 5,
|
||||
barcolour = {.43, 0.47, 0.55, 1},
|
||||
shieldbarcolour = {.8, 0.1, 0.1, 1}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
addon:InitModuleOptions(self)
|
||||
self:SetEnabledState(self.db.profile.enabled)
|
||||
|
||||
sizes = {cbheight = self.db.profile.display.cbheight, shield = 16}
|
||||
|
||||
self.configChangedFuncs.display.cbheight.ro(sizes.cbheight)
|
||||
|
||||
-- handle default interface cvars & checkboxes
|
||||
InterfaceOptionsCombatPanel:HookScript(
|
||||
"OnShow",
|
||||
function()
|
||||
InterfaceOptionsCombatPanelEnemyCastBarsOnNameplates:SetChecked(true)
|
||||
InterfaceOptionsCombatPanelEnemyCastBarsOnNameplates:Disable()
|
||||
end
|
||||
)
|
||||
InterfaceOptionsFrame:HookScript(
|
||||
"OnHide",
|
||||
function()
|
||||
SetCVars()
|
||||
end
|
||||
)
|
||||
|
||||
SetCVars()
|
||||
end
|
||||
function mod:OnEnable()
|
||||
for _, frame in pairs(addon.frameList) do
|
||||
if not frame.kui or not frame.kui.castbar then
|
||||
self:CreateCastbar(frame.kui)
|
||||
end
|
||||
end
|
||||
end
|
||||
function mod:OnDisable()
|
||||
for _, frame in pairs(addon.frameList) do
|
||||
self:HideCastbar(frame.kui)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,116 @@
|
||||
--[[
|
||||
-- Kui_Nameplates
|
||||
-- By Kesava at curse.com
|
||||
-- All rights reserved
|
||||
-- Backported by: Kader at https://github.com/bkader
|
||||
--
|
||||
-- Provides class colours for friendly targets
|
||||
]]
|
||||
local addon = LibStub("AceAddon-3.0"):GetAddon("KuiNameplates")
|
||||
local mod = addon:NewModule("ClassColours", addon.Prototype, "AceEvent-3.0")
|
||||
local L = LibStub("AceLocale-3.0"):GetLocale("KuiNameplates")
|
||||
|
||||
local select, GetPlayerInfoByGUID, tinsert = select, GetPlayerInfoByGUID, tinsert
|
||||
|
||||
local cc_table
|
||||
|
||||
mod.uiName = L["Class colours"]
|
||||
|
||||
local function SetCVars()
|
||||
SetCVar("ShowClassColorInNameplate", mod.db.profile.enemy and 1 or 0)
|
||||
end
|
||||
-- functions ###################################################################
|
||||
function mod:SetClassColour(frame, cc)
|
||||
frame.name.class_coloured = true
|
||||
frame.name:SetTextColor(cc.r, cc.g, cc.b)
|
||||
end
|
||||
-- message handlers ############################################################
|
||||
function mod:GUIDAssumed(msg, f)
|
||||
if not (f.friend and f.player and f.guid) then
|
||||
return
|
||||
end
|
||||
local class = select(2, GetPlayerInfoByGUID(f.guid))
|
||||
if not class then
|
||||
return
|
||||
end
|
||||
|
||||
self:SetClassColour(f, cc_table[class])
|
||||
end
|
||||
function mod:PostShow(msg, f)
|
||||
if not (f.friend and f.player) then
|
||||
return
|
||||
end
|
||||
-- a friendly player; make their name slightly gray
|
||||
-- will be overwritten when GUIDStored/Assumed fires
|
||||
f.name:SetTextColor(.7, .7, .7)
|
||||
end
|
||||
function mod:PostHide(msg, f)
|
||||
f.name.class_coloured = nil
|
||||
f.name:SetTextColor(1, 1, 1, 1)
|
||||
end
|
||||
-- config changed hooks ########################################################
|
||||
mod:AddConfigChanged(
|
||||
"friendly",
|
||||
function(v)
|
||||
if v then
|
||||
mod:Enable()
|
||||
else
|
||||
mod:Disable()
|
||||
end
|
||||
end,
|
||||
function(f, v)
|
||||
if v then
|
||||
mod:PostShow(nil, f)
|
||||
else
|
||||
mod:PostHide(nil, f)
|
||||
end
|
||||
end
|
||||
)
|
||||
mod:AddConfigChanged("enemy", function(v) SetCVars() end)
|
||||
-- config hooks ################################################################
|
||||
function mod:GetOptions()
|
||||
return {
|
||||
friendly = {
|
||||
type = "toggle",
|
||||
name = L["Class colour friendly player names"],
|
||||
desc = L["Class colour the names of friendly players and dim the names of friendly players with no class information. Note that friendly players will only become class coloured once you mouse over their frames, at which point their class will be cached."],
|
||||
width = "double",
|
||||
order = 10
|
||||
},
|
||||
enemy = {
|
||||
type = "toggle",
|
||||
name = L["Class colour hostile players' health bars"],
|
||||
desc = L["Class colour the health bars of hostile players, where they are attackable. This is a default interface option."],
|
||||
width = "double",
|
||||
order = 20
|
||||
}
|
||||
}
|
||||
end
|
||||
function mod:OnInitialize()
|
||||
cc_table = CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS
|
||||
self.db = addon.db:RegisterNamespace(self.moduleName, {profile = {friendly = true, enemy = true}})
|
||||
|
||||
addon:InitModuleOptions(self)
|
||||
self:SetEnabledState(self.db.profile.friendly)
|
||||
|
||||
-- handle default interface cvars & checkboxes
|
||||
InterfaceOptionsCombatPanel:HookScript("OnShow", function()
|
||||
InterfaceOptionsCombatPanelNameplateClassColors:Disable()
|
||||
InterfaceOptionsCombatPanelNameplateClassColors:SetChecked(mod.db.profile.enemy)
|
||||
InterfaceOptionsCombatPanelNameplateClassColors.Enable = function() return end
|
||||
end)
|
||||
InterfaceOptionsFrame:HookScript("OnHide", function() SetCVars() end)
|
||||
SetCVars()
|
||||
end
|
||||
function mod:OnEnable()
|
||||
self:RegisterMessage("KuiNameplates_GUIDAssumed", "GUIDAssumed")
|
||||
self:RegisterMessage("KuiNameplates_GUIDStored", "GUIDAssumed")
|
||||
self:RegisterMessage("KuiNameplates_PostShow", "PostShow")
|
||||
self:RegisterMessage("KuiNameplates_PostHide", "PostHide")
|
||||
end
|
||||
function mod:OnDisable()
|
||||
self:UnregisterMessage("KuiNameplates_GUIDAssumed")
|
||||
self:UnregisterMessage("KuiNameplates_GUIDStored")
|
||||
self:UnregisterMessage("KuiNameplates_PostShow")
|
||||
self:UnregisterMessage("KuiNameplates_PostHide")
|
||||
end
|
||||
@@ -0,0 +1,203 @@
|
||||
--[[
|
||||
-- Kui_Nameplates
|
||||
-- By Kesava at curse.com
|
||||
-- All rights reserved
|
||||
-- Backported by: Kader at https://github.com/bkader
|
||||
]]
|
||||
local addon = LibStub("AceAddon-3.0"):GetAddon("KuiNameplates")
|
||||
local mod = addon:NewModule("ComboPoints", addon.Prototype, "AceEvent-3.0")
|
||||
local L = LibStub("AceLocale-3.0"):GetLocale("KuiNameplates")
|
||||
local _
|
||||
|
||||
mod.uiName = L["Combo points"]
|
||||
|
||||
local ICON_SPACING = -1
|
||||
|
||||
local anticipationWasActive
|
||||
|
||||
local colours = {
|
||||
full = {1, 1, .1},
|
||||
partial = {.79, .55, .18},
|
||||
anti = {1, .3, .3},
|
||||
glowFull = {1, 1, .1, .6},
|
||||
glowPartial = {0, 0, 0, .3},
|
||||
glowAnti = {1, .1, .1, .8}
|
||||
}
|
||||
local sizes = {}
|
||||
local defaultSizes = {}
|
||||
|
||||
local function ComboPointsUpdate(self)
|
||||
if self.points and self.points > 0 then
|
||||
if self.points == 5 then
|
||||
self.colour = colours.full
|
||||
self.glowColour = colours.glowFull
|
||||
else
|
||||
self.colour = colours.partial
|
||||
self.glowColour = colours.glowPartial
|
||||
end
|
||||
|
||||
for i = 1, 5 do
|
||||
if i <= self.points then
|
||||
self[i]:SetAlpha(1)
|
||||
else
|
||||
self[i]:SetAlpha(.3)
|
||||
end
|
||||
|
||||
self[i]:SetVertexColor(unpack(self.colour))
|
||||
self.glows[i]:SetVertexColor(unpack(self.glowColour))
|
||||
end
|
||||
|
||||
self:Show()
|
||||
elseif self:IsShown() then
|
||||
self:Hide()
|
||||
end
|
||||
end
|
||||
-------------------------------------------------------------- Event handlers --
|
||||
function mod:UNIT_COMBO_POINTS(event, unit)
|
||||
-- only works for player > target
|
||||
if unit ~= "player" then
|
||||
return
|
||||
end
|
||||
|
||||
local f = addon:GetUnitPlate("target")
|
||||
|
||||
if f and f.combopoints then
|
||||
local points = GetComboPoints("player", "target")
|
||||
f.combopoints.points = points
|
||||
f.combopoints:Update()
|
||||
|
||||
if points > 0 then
|
||||
-- clear points on other frames
|
||||
for _, frame in pairs(addon.frameList) do
|
||||
if frame.kui.combopoints and frame.kui ~= f then
|
||||
self:HideComboPoints(nil, frame.kui)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
---------------------------------------------------------------------- Target --
|
||||
function mod:OnFrameTarget(msg, frame, is_target)
|
||||
if is_target then
|
||||
self:UNIT_COMBO_POINTS(nil, "player")
|
||||
end
|
||||
end
|
||||
---------------------------------------------------------------------- Create --
|
||||
function mod:CreateComboPoints(msg, frame)
|
||||
-- create combo point icons
|
||||
frame.combopoints = CreateFrame("Frame", nil, frame.overlay)
|
||||
frame.combopoints.glows = {}
|
||||
frame.combopoints:Hide()
|
||||
|
||||
local pcp
|
||||
for i = 0, 4 do
|
||||
-- create individual combo point icons
|
||||
-- size and position of first icon is set in ScaleComboPoints
|
||||
local cp = frame.combopoints:CreateTexture(nil, "ARTWORK")
|
||||
cp:SetDrawLayer("ARTWORK", 2)
|
||||
cp:SetTexture("Interface\\AddOns\\Kui_Nameplates\\Media\\combopoint-round")
|
||||
|
||||
if i > 0 then
|
||||
cp:SetPoint("LEFT", pcp, "RIGHT", ICON_SPACING, 0)
|
||||
end
|
||||
|
||||
tinsert(frame.combopoints, i + 1, cp)
|
||||
pcp = cp
|
||||
|
||||
-- and their glows
|
||||
local glow = frame.combopoints:CreateTexture(nil, "ARTWORK")
|
||||
|
||||
glow:SetDrawLayer("ARTWORK", 1)
|
||||
glow:SetTexture("Interface\\AddOns\\Kui_Nameplates\\Media\\combopoint-glow")
|
||||
glow:SetPoint("CENTER", cp)
|
||||
|
||||
tinsert(frame.combopoints.glows, i + 1, glow)
|
||||
end
|
||||
|
||||
self:ScaleComboPoints(frame)
|
||||
frame.combopoints.Update = ComboPointsUpdate
|
||||
end
|
||||
-- update/set frame sizes ------------------------------------------------------
|
||||
function mod:ScaleComboPoints(frame)
|
||||
for i, cp in ipairs(frame.combopoints) do
|
||||
cp:SetSize(sizes.combopoints, sizes.combopoints)
|
||||
|
||||
if i == 1 then
|
||||
-- place first icon to offset others to center
|
||||
cp:SetPoint("BOTTOM", frame.overlay, "BOTTOM", -(sizes.combopoints + ICON_SPACING) * 2, -3)
|
||||
end
|
||||
|
||||
frame.combopoints.glows[i]:SetSize(sizes.combopoints + 8, sizes.combopoints + 8)
|
||||
end
|
||||
end
|
||||
------------------------------------------------------------------------ Hide --
|
||||
function mod:HideComboPoints(msg, frame)
|
||||
if frame.combopoints then
|
||||
frame.combopoints.points = nil
|
||||
frame.combopoints:Update()
|
||||
end
|
||||
end
|
||||
---------------------------------------------------- Post db change functions --
|
||||
mod:AddConfigChanged("enabled", function(v) mod:Toggle(v) end)
|
||||
mod:AddConfigChanged(
|
||||
"scale",
|
||||
function(v)
|
||||
sizes.combopoints = defaultSizes.combopoints * v
|
||||
end,
|
||||
function(f, v)
|
||||
mod:ScaleComboPoints(f)
|
||||
end
|
||||
)
|
||||
-------------------------------------------------------------------- Register --
|
||||
function mod:GetOptions()
|
||||
return {
|
||||
enabled = {
|
||||
type = "toggle",
|
||||
name = L["Show combo points"],
|
||||
desc = L["Show combo points on the target"],
|
||||
order = 0
|
||||
},
|
||||
scale = {
|
||||
type = "range",
|
||||
name = L["Icon scale"],
|
||||
desc = L["The scale of the combo point icons and glow"],
|
||||
order = 5,
|
||||
min = 0.1,
|
||||
softMin = 0.5,
|
||||
softMax = 2
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
function mod:OnInitialize()
|
||||
self.db = addon.db:RegisterNamespace(self.moduleName, {profile = {enabled = true, scale = 1}})
|
||||
defaultSizes.combopoints = 6.5
|
||||
|
||||
-- scale size with user option
|
||||
self.configChangedFuncs.scale.ro(self.db.profile.scale)
|
||||
|
||||
addon:InitModuleOptions(self)
|
||||
mod:SetEnabledState(self.db.profile.enabled)
|
||||
end
|
||||
|
||||
function mod:OnEnable()
|
||||
self:RegisterMessage("KuiNameplates_PostCreate", "CreateComboPoints")
|
||||
self:RegisterMessage("KuiNameplates_PostHide", "HideComboPoints")
|
||||
self:RegisterMessage("KuiNameplates_PostTarget", "OnFrameTarget")
|
||||
|
||||
self:RegisterEvent("UNIT_COMBO_POINTS")
|
||||
|
||||
for _, frame in pairs(addon.frameList) do
|
||||
if not frame.combopoints then
|
||||
self:CreateComboPoints(nil, frame.kui)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mod:OnDisable()
|
||||
self:UnregisterEvent("UNIT_COMBO_POINTS")
|
||||
|
||||
for _, frame in pairs(addon.frameList) do
|
||||
self:HideComboPoints(nil, frame.kui)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,102 @@
|
||||
--[[
|
||||
-- Kui_Nameplates
|
||||
-- By Kesava at curse.com
|
||||
-- Backported by: Kader at https://github.com/bkader
|
||||
--
|
||||
-- changes colour of health bars based on health percentage
|
||||
]]
|
||||
local addon = LibStub("AceAddon-3.0"):GetAddon("KuiNameplates")
|
||||
local mod = addon:NewModule("LowHealthColours", addon.Prototype, "AceEvent-3.0")
|
||||
local L = LibStub("AceLocale-3.0"):GetLocale("KuiNameplates")
|
||||
|
||||
mod.uiName = L["Low health colour"]
|
||||
|
||||
local LOW_HEALTH_COLOR, PRIORITY, OVER_CLASSCOLOUR
|
||||
|
||||
local function OnHealthValueChanged(oldHealth, current)
|
||||
local frame = oldHealth:GetParent().kui
|
||||
|
||||
if (frame.tapped) or (not OVER_CLASSCOLOUR and frame.player and not frame.friend) then
|
||||
-- don't show on enemy players or tapped units
|
||||
return
|
||||
end
|
||||
|
||||
local percent = frame.health.percent
|
||||
|
||||
if percent <= addon.db.profile.general.lowhealthval then
|
||||
frame:SetHealthColour(PRIORITY, unpack(LOW_HEALTH_COLOR))
|
||||
frame.stuckLowHealth = true
|
||||
elseif frame.stuckLowHealth then
|
||||
frame:SetHealthColour(false)
|
||||
frame.stuckLowHealth = nil
|
||||
end
|
||||
end
|
||||
|
||||
function mod:PostCreate(msg, frame)
|
||||
frame.oldHealth:HookScript("OnValueChanged", OnHealthValueChanged)
|
||||
end
|
||||
|
||||
function mod:PostShow(msg, frame)
|
||||
-- call our hook onshow, too
|
||||
OnHealthValueChanged(frame.oldHealth, frame.oldHealth:GetValue())
|
||||
end
|
||||
|
||||
-- config changed hooks ########################################################
|
||||
mod:AddConfigChanged("enabled", function(v) mod:Toggle(v) end)
|
||||
mod:AddConfigChanged("colour", function(v) LOW_HEALTH_COLOR = v end)
|
||||
mod:AddConfigChanged("over_tankmode", function(v) PRIORITY = v and 15 or 5 end)
|
||||
mod:AddConfigChanged("over_classcolour", function(v) OVER_CLASSCOLOUR = v end)
|
||||
-- config hooks ################################################################
|
||||
function mod:GetOptions()
|
||||
return {
|
||||
enabled = {
|
||||
type = "toggle",
|
||||
name = L["Change colour of health bars at low health"],
|
||||
desc = L['Change the colour of low health units\' health bars. "Low health" is determined by the "Low health value" option under "General display".'],
|
||||
width = "double",
|
||||
order = 10
|
||||
},
|
||||
over_tankmode = {
|
||||
type = "toggle",
|
||||
name = L["Override tank mode"],
|
||||
desc = L["When using tank mode, allow the low health colour to override tank mode colouring"],
|
||||
order = 20
|
||||
},
|
||||
over_classcolour = {
|
||||
type = "toggle",
|
||||
name = L["Show on enemy players"],
|
||||
desc = L["Show on enemy players - i.e. override class colours"],
|
||||
order = 30
|
||||
},
|
||||
colour = {
|
||||
type = "color",
|
||||
name = L["Low health colour"],
|
||||
desc = L["The colour to use"],
|
||||
order = 40
|
||||
}
|
||||
}
|
||||
end
|
||||
function mod:OnInitialize()
|
||||
self.db = addon.db:RegisterNamespace(self.moduleName, {profile = {
|
||||
enabled = true,
|
||||
over_tankmode = false,
|
||||
over_classcolour = true,
|
||||
colour = {1, 1, .85}
|
||||
}})
|
||||
|
||||
addon:InitModuleOptions(self)
|
||||
|
||||
LOW_HEALTH_COLOR = self.db.profile.colour
|
||||
PRIORITY = self.db.profile.over_tankmode and 15 or 5
|
||||
OVER_CLASSCOLOUR = self.db.profile.over_classcolour
|
||||
|
||||
self:SetEnabledState(self.db.profile.enabled)
|
||||
end
|
||||
function mod:OnEnable()
|
||||
self:RegisterMessage("KuiNameplates_PostCreate", "PostCreate")
|
||||
self:RegisterMessage("KuiNameplates_PostShow", "PostShow")
|
||||
end
|
||||
function mod:OnDisable()
|
||||
self:UnregisterMessage("KuiNameplates_PostCreate", "PostCreate")
|
||||
self:UnregisterMessage("KuiNameplates_PostShow", "PostShow")
|
||||
end
|
||||
@@ -0,0 +1,338 @@
|
||||
--[[
|
||||
-- Kui_Nameplates
|
||||
-- By Kesava at curse.com
|
||||
-- All rights reserved.
|
||||
-- Backported by: Kader at https://github.com/bkader
|
||||
]]
|
||||
local addon = LibStub("AceAddon-3.0"):GetAddon("KuiNameplates")
|
||||
local mod = addon:NewModule("NameOnly", addon.Prototype, "AceEvent-3.0")
|
||||
local L = LibStub("AceLocale-3.0"):GetLocale("KuiNameplates")
|
||||
|
||||
mod.uiName = L["Name-only display"]
|
||||
|
||||
local _
|
||||
local len = string.len
|
||||
local utf8sub = LibStub("Kui-1.0").utf8sub
|
||||
local orig_SetName
|
||||
|
||||
local colour_friendly
|
||||
|
||||
local PositionRaidIcon = {
|
||||
function(f) return f.icon:SetPoint("RIGHT", f.name, "LEFT", -2, 2) end,
|
||||
function(f) return f.icon:SetPoint("BOTTOM", f.name, "TOP", 0, 8) end,
|
||||
function(f) return f.icon:SetPoint("LEFT", f.name, "RIGHT", 0, 2) end,
|
||||
function(f) return f.icon:SetPoint("TOP", f.name, "BOTTOM", -1, -8) end
|
||||
}
|
||||
|
||||
-- mod functions ###############################################################
|
||||
local function UpdateDisplay(f)
|
||||
f:CreateFontString(f.name, {
|
||||
reset = true,
|
||||
size = f.trivial and "nameonlytrivial" or (f.player and "nameonlyplayer" or "nameonly"),
|
||||
shadow = true
|
||||
})
|
||||
|
||||
f.name:ClearAllPoints()
|
||||
f.name:SetWidth(0)
|
||||
f.name:SetWidth(f.name:GetStringWidth())
|
||||
|
||||
local sheight = f.name:GetStringHeight() / 2
|
||||
f.name:SetPoint("CENTER", 0.5, (sheight - floor(sheight) > 0.01) and 0 or 0.5)
|
||||
end
|
||||
|
||||
-- toggle nameonly mode on
|
||||
local function SwitchOn(f)
|
||||
if f.nameonly then
|
||||
return
|
||||
end
|
||||
f.nameonly = true
|
||||
|
||||
if not f.player and f.friend then
|
||||
-- color NPC names
|
||||
f.name:SetTextColor(unpack(colour_friendly))
|
||||
end
|
||||
|
||||
if mod.db.profile.display.hidecastbars then
|
||||
addon.Castbar:IgnoreFrame(f)
|
||||
end
|
||||
|
||||
f.name:SetParent(f)
|
||||
f.name:SetJustifyH("CENTER")
|
||||
|
||||
UpdateDisplay(f)
|
||||
|
||||
f.icon:SetParent(f)
|
||||
f.icon:ClearAllPoints()
|
||||
PositionRaidIcon[addon.db.profile.general.raidicon_side](f)
|
||||
|
||||
if f.castWarning then
|
||||
f.castWarning:SetParent(f)
|
||||
f.incWarning:SetParent(f)
|
||||
end
|
||||
|
||||
f.health:Hide()
|
||||
f.overlay:Hide()
|
||||
f.bg:Hide()
|
||||
end
|
||||
-- toggle nameonly mode off
|
||||
local function SwitchOff(f)
|
||||
if not f.nameonly then
|
||||
return
|
||||
end
|
||||
f.nameonly = nil
|
||||
|
||||
if not f.player then
|
||||
f.name:SetTextColor(1, 1, 1)
|
||||
end
|
||||
|
||||
if mod.db.profile.display.hidecastbars then
|
||||
addon.Castbar:UnignoreFrame(f)
|
||||
end
|
||||
|
||||
f:CreateFontString(f.name, {reset = true, size = "name"})
|
||||
f.name:SetParent(f.overlay)
|
||||
|
||||
f.health:Show()
|
||||
f.overlay:Show()
|
||||
f.bg:Show()
|
||||
|
||||
-- reposition name
|
||||
addon:UpdateName(f, f.trivial)
|
||||
|
||||
-- reposition raid icon
|
||||
addon:UpdateRaidIcon(f)
|
||||
|
||||
if f.castWarning then
|
||||
f.castWarning:SetParent(f.overlay)
|
||||
f.incWarning:SetParent(f.overlay)
|
||||
end
|
||||
|
||||
-- reset name text
|
||||
f:SetName()
|
||||
end
|
||||
-- SetName hook, to set name's colour based on health
|
||||
local function nameonly_SetName(f)
|
||||
orig_SetName(f)
|
||||
|
||||
if not f.nameonly then
|
||||
return
|
||||
end
|
||||
f.name:SetWidth(0)
|
||||
f.name:SetWidth(f.name:GetStringWidth())
|
||||
|
||||
if not f.health.curr then
|
||||
return
|
||||
end
|
||||
|
||||
local health_length = len(f.name.text) * (f.health.curr / f.health.max)
|
||||
f.name:SetText(utf8sub(f.name.text, 0, health_length) .. "|cff666666" .. utf8sub(f.name.text, health_length + 1))
|
||||
end
|
||||
local function HookSetName(f)
|
||||
orig_SetName = f.SetName
|
||||
f.SetName = nameonly_SetName
|
||||
end
|
||||
-- toggle name-only display mode
|
||||
local function UpdateNameOnly(f)
|
||||
if not mod.db.profile.enabled then
|
||||
return
|
||||
end
|
||||
|
||||
if f.kuiParent then
|
||||
-- resolve frame for oldHealth hook
|
||||
f = f.kuiParent.kui
|
||||
end
|
||||
|
||||
if (f.target or not f.friend) or (not mod.db.profile.display.ondamaged and f.health.curr < f.health.max) then
|
||||
SwitchOff(f)
|
||||
else
|
||||
SwitchOn(f)
|
||||
f:SetName()
|
||||
end
|
||||
end
|
||||
-- message listeners ###########################################################
|
||||
function mod:PostShow(msg, f)
|
||||
UpdateNameOnly(f)
|
||||
end
|
||||
function mod:PostHide(msg, f)
|
||||
SwitchOff(f)
|
||||
end
|
||||
function mod:PostCreate(msg, f)
|
||||
f.oldHealth:HookScript("OnValueChanged", UpdateNameOnly)
|
||||
f.nameonly_hooked = true
|
||||
|
||||
if self.db.profile.display.ondamaged and f.SetName ~= nameonly_SetName then
|
||||
HookSetName(f)
|
||||
end
|
||||
end
|
||||
function mod:PostTarget(msg, f)
|
||||
UpdateNameOnly(f)
|
||||
end
|
||||
-- post db change functions ####################################################
|
||||
local function UpdateFontSize()
|
||||
addon:RegisterFontSize("nameonly", tonumber(mod.db.profile.display.fontsize))
|
||||
addon:RegisterFontSize("nameonlyplayer", tonumber(mod.db.profile.display.fontsizeplayer))
|
||||
addon:RegisterFontSize("nameonlytrivial", tonumber(mod.db.profile.display.fontsizetrivial))
|
||||
end
|
||||
|
||||
mod:AddConfigChanged("enabled", function(v) mod:Toggle(v) end)
|
||||
mod:AddConfigChanged({"display", "ondamaged"}, nil, function(f)
|
||||
if not mod.db.profile.enabled then
|
||||
return
|
||||
elseif mod.configChangedFuncs.enabled.pf then
|
||||
mod.configChangedFuncs.enabled.pf(f, true)
|
||||
end
|
||||
end)
|
||||
mod:AddConfigChanged(
|
||||
{
|
||||
{"display", "fontsize"},
|
||||
{"display", "fontsizeplayer"},
|
||||
{"display", "fontsizetrivial"}
|
||||
},
|
||||
UpdateFontSize,
|
||||
function(f)
|
||||
if f.nameonly then
|
||||
UpdateDisplay(f)
|
||||
end
|
||||
end
|
||||
)
|
||||
mod:AddGlobalConfigChanged(
|
||||
"addon",
|
||||
{"fonts", "fontscale"},
|
||||
nil,
|
||||
function(f)
|
||||
if f.nameonly then
|
||||
UpdateDisplay(f)
|
||||
end
|
||||
end
|
||||
)
|
||||
-- initialise ##################################################################
|
||||
function mod:GetOptions()
|
||||
return {
|
||||
enabled = {
|
||||
type = "toggle",
|
||||
name = L["Only show name of friendly units"],
|
||||
desc = L["Change the layout of friendly nameplates so as to only show their names."],
|
||||
width = "double",
|
||||
order = 10
|
||||
},
|
||||
display = {
|
||||
type = "group",
|
||||
name = L["Display"],
|
||||
inline = true,
|
||||
order = 20,
|
||||
disabled = function()
|
||||
return not mod.db.profile.enabled
|
||||
end,
|
||||
args = {
|
||||
ondamaged = {
|
||||
type = "toggle",
|
||||
name = L["Even when damaged"],
|
||||
desc = L["Only show the name of damaged nameplates, too. Their name will be coloured as a percentage of health remaining."],
|
||||
order = 10
|
||||
},
|
||||
hidecastbars = {
|
||||
type = "toggle",
|
||||
name = L["Hide castbars"],
|
||||
desc = L["Hide castbars when in name-only display."],
|
||||
order = 20
|
||||
},
|
||||
fontsize = {
|
||||
type = "range",
|
||||
name = L["Font size"],
|
||||
desc = L['Font size used when in name-only display. This is affected by the standard "Font scale" option under "Fonts".'],
|
||||
order = 30,
|
||||
step = 1,
|
||||
min = 1,
|
||||
softMin = 1,
|
||||
softMax = 30,
|
||||
disabled = function() return addon.db.profile.fonts.options.onesize end
|
||||
},
|
||||
fontsizeplayer = {
|
||||
type = "range",
|
||||
name = L["Player font size"],
|
||||
order = 40,
|
||||
step = 1,
|
||||
min = 1,
|
||||
softMin = 1,
|
||||
softMax = 30,
|
||||
disabled = function() return addon.db.profile.fonts.options.onesize end
|
||||
},
|
||||
fontsizetrivial = {
|
||||
type = "range",
|
||||
name = L["Trivial font size"],
|
||||
order = 50,
|
||||
step = 1,
|
||||
min = 1,
|
||||
softMin = 1,
|
||||
softMax = 30,
|
||||
disabled = function() return addon.db.profile.fonts.options.onesize end
|
||||
}
|
||||
}
|
||||
},
|
||||
colours = {
|
||||
type = "group",
|
||||
name = L["NPC name colours"],
|
||||
inline = true,
|
||||
order = 30,
|
||||
disabled = function()
|
||||
return not mod.db.profile.enabled
|
||||
end,
|
||||
args = {
|
||||
friendly = {
|
||||
type = "color",
|
||||
name = L["Friendly"],
|
||||
order = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
function mod:configChangedListener()
|
||||
colour_friendly = self.db.profile.colours.friendly
|
||||
end
|
||||
function mod:OnInitialize()
|
||||
self.db = addon.db:RegisterNamespace(self.moduleName, {profile = {
|
||||
enabled = true,
|
||||
display = {
|
||||
ondamaged = false,
|
||||
hidecastbars = true,
|
||||
fontsize = 11,
|
||||
fontsizeplayer = 11,
|
||||
fontsizetrivial = 9
|
||||
},
|
||||
colours = {
|
||||
friendly = {.6, 1, 0.6}
|
||||
}
|
||||
}})
|
||||
|
||||
addon:InitModuleOptions(self)
|
||||
self:SetEnabledState(self.db.profile.enabled)
|
||||
end
|
||||
function mod:OnEnable()
|
||||
UpdateFontSize()
|
||||
|
||||
self:RegisterMessage("KuiNameplates_PostHide", "PostHide")
|
||||
self:RegisterMessage("KuiNameplates_PostShow", "PostShow")
|
||||
self:RegisterMessage("KuiNameplates_PostTarget", "PostTarget")
|
||||
self:RegisterMessage("KuiNameplates_PostCreate", "PostCreate")
|
||||
|
||||
for _, frame in pairs(addon.frameList) do
|
||||
if frame.kui then
|
||||
if not frame.kui.nameonly_hooked then
|
||||
self:PostCreate(nil, frame.kui)
|
||||
end
|
||||
|
||||
UpdateNameOnly(frame.kui)
|
||||
end
|
||||
end
|
||||
end
|
||||
function mod:OnDisable()
|
||||
self:UnregisterMessage("KuiNameplates_PostHide", "PostHide")
|
||||
self:UnregisterMessage("KuiNameplates_PostShow", "PostShow")
|
||||
self:UnregisterMessage("KuiNameplates_PostTarget", "PostTarget")
|
||||
self:UnregisterMessage("KuiNameplates_PostCreate", "PostCreate")
|
||||
|
||||
for _, frame in pairs(addon.frameList) do
|
||||
SwitchOff(frame.kui)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,358 @@
|
||||
--[[
|
||||
-- Kui_Nameplates
|
||||
-- By Kesava at curse.com
|
||||
-- All rights reserved
|
||||
-- Backported by: Kader at https://github.com/bkader
|
||||
]]
|
||||
local addon = LibStub("AceAddon-3.0"):GetAddon("KuiNameplates")
|
||||
local mod = addon:NewModule("TankMode", addon.Prototype, "AceEvent-3.0")
|
||||
local L = LibStub("AceLocale-3.0"):GetLocale("KuiNameplates")
|
||||
|
||||
local class, tankmode = select(2, UnitClass("player")), nil
|
||||
|
||||
local profile_tankmode
|
||||
|
||||
mod.uiName = L["Threat"]
|
||||
|
||||
-------------------------------------------------------- threat bracket stuff --
|
||||
local function ShowThreatBrackets(frame, ...)
|
||||
if not frame.threatBrackets then
|
||||
return
|
||||
end
|
||||
if ... == false then
|
||||
frame.threatBrackets:Hide()
|
||||
else
|
||||
frame.threatBrackets:SetVertexColor(...)
|
||||
frame.threatBrackets:Show()
|
||||
end
|
||||
end
|
||||
do
|
||||
local brackets = {
|
||||
{"BOTTOMLEFT", nil, "TOPLEFT"},
|
||||
{"BOTTOMRIGHT", nil, "TOPRIGHT"},
|
||||
{"TOPLEFT", nil, "BOTTOMLEFT"},
|
||||
{"TOPRIGHT", nil, "BOTTOMRIGHT"}
|
||||
}
|
||||
|
||||
-- pixel positions
|
||||
local leftmost = 0.28125
|
||||
local bottommost = 0
|
||||
local default_size = 18
|
||||
local ratio = 2
|
||||
|
||||
local size, x_offset, y_offset
|
||||
|
||||
function mod:UpdateThreatBracketScaling()
|
||||
size = default_size * self.db.profile.brackets.scale
|
||||
x_offset = (size * ratio) * leftmost
|
||||
y_offset = floor((size * bottommost) - 2)
|
||||
end
|
||||
|
||||
function mod:CreateThreatBrackets(frame)
|
||||
local tb = CreateFrame("Frame", nil, frame.health)
|
||||
tb:SetFrameLevel(1) -- same as castbar/healthbar
|
||||
tb:Hide()
|
||||
|
||||
for k, v in ipairs(brackets) do
|
||||
local b = tb:CreateTexture(nil, "ARTWORK", nil, -1)
|
||||
b:SetTexture("Interface\\AddOns\\Kui_Nameplates\\Media\\threat-bracket")
|
||||
tb[k] = b
|
||||
end
|
||||
|
||||
tb.SetVertexColor = function(self, ...)
|
||||
for k, b in ipairs(self) do
|
||||
b:SetVertexColor(...)
|
||||
end
|
||||
end
|
||||
|
||||
frame.threatBrackets = tb
|
||||
|
||||
self:UpdateThreatBrackets(frame)
|
||||
end
|
||||
function mod:UpdateThreatBrackets(frame)
|
||||
-- apply scaling + positions to threat brackets on given frame
|
||||
if not frame.threatBrackets then
|
||||
return
|
||||
end
|
||||
for k, v in ipairs(brackets) do
|
||||
local b = frame.threatBrackets[k]
|
||||
b:SetSize(size * ratio, size)
|
||||
|
||||
if k % 2 == 0 then
|
||||
v[4] = x_offset - 1
|
||||
else
|
||||
v[4] = -x_offset
|
||||
end
|
||||
|
||||
if k <= 2 then
|
||||
v[5] = -y_offset
|
||||
else
|
||||
v[5] = y_offset - .5
|
||||
end
|
||||
|
||||
if k == 2 then
|
||||
b:SetTexCoord(1, 0, 0, 1)
|
||||
elseif k == 3 then
|
||||
b:SetTexCoord(0, 1, 1, 0)
|
||||
elseif k == 4 then
|
||||
b:SetTexCoord(1, 0, 1, 0)
|
||||
end
|
||||
|
||||
v[2] = frame.health
|
||||
b:SetPoint(unpack(v))
|
||||
end
|
||||
end
|
||||
end
|
||||
--------------------------------------------------------- tank mode functions --
|
||||
do
|
||||
local function getTalentpointsSpent(spellID)
|
||||
local spellName = GetSpellInfo(spellID)
|
||||
for tabIndex = 1, GetNumTalentTabs() do
|
||||
for talentID = 1, GetNumTalents(tabIndex) do
|
||||
local name, _, _, _, spent = GetTalentInfo(tabIndex, talentID)
|
||||
if (name == spellName) then
|
||||
return spent
|
||||
end
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
local function IsDeathKnightTank()
|
||||
-- idea taken from addon 'ElitistJerks'
|
||||
local tankTalents =
|
||||
(getTalentpointsSpent(16271) >= 5 and 1 or 0) + -- Anticipation
|
||||
(getTalentpointsSpent(49042) >= 5 and 1 or 0) + -- Toughness
|
||||
(getTalentpointsSpent(55225) >= 5 and 1 or 0) -- Blade Barrier
|
||||
return tankTalents >= 2
|
||||
end
|
||||
|
||||
local function IsDruidTank()
|
||||
-- idea taken from addon 'ElitistJerks'
|
||||
local tankTalents =
|
||||
(getTalentpointsSpent(57881) >= 2 and 1 or 0) + -- Natural Reaction
|
||||
(getTalentpointsSpent(16929) >= 3 and 1 or 0) + -- Thick Hide
|
||||
(getTalentpointsSpent(61336) >= 1 and 1 or 0) + -- Survival Instincts
|
||||
(getTalentpointsSpent(57877) >= 3 and 1 or 0) -- Protector of the Pack
|
||||
return tankTalents >= 3
|
||||
end
|
||||
|
||||
local function IsTank()
|
||||
return (class == "WARRIOR" and select(3, GetTalentTabInfo(3)) >= 51) or
|
||||
(class == "DEATHKNIGHT" and IsDeathKnightTank()) or
|
||||
(class == "PALADIN" and select(3, GetTalentTabInfo(2)) >= 51) or
|
||||
(class == "DRUID" and select(3, GetTalentTabInfo(2)) >= 51 and IsDruidTank())
|
||||
end
|
||||
|
||||
local function IsHealer()
|
||||
return (class == "PALADIN" and select(3, GetTalentTabInfo(1)) >= 51) or
|
||||
(class == "SHAMAN" and select(3, GetTalentTabInfo(3)) >= 51) or
|
||||
(class == "DRUID" and select(3, GetTalentTabInfo(3)) >= 51) or
|
||||
(class == "PRIEST" and select(3, GetTalentTabInfo(3)) < 51)
|
||||
end
|
||||
|
||||
function mod:Update()
|
||||
if profile_tankmode.enabled == 1 then
|
||||
-- smart - judge by spec
|
||||
local spec = GetActiveTalentGroup()
|
||||
local role
|
||||
|
||||
if class == "WARRIOR" and GetShapeshiftForm() ~= 2 then
|
||||
-- no tank for gladiator stance
|
||||
role = nil
|
||||
elseif IsTank() then
|
||||
role = "TANK"
|
||||
elseif IsHealer() then
|
||||
role = "HEALER"
|
||||
else
|
||||
role = "DAMAGER"
|
||||
end
|
||||
|
||||
if role == "TANK" then
|
||||
tankmode = true
|
||||
else
|
||||
tankmode = false
|
||||
end
|
||||
else
|
||||
tankmode = (profile_tankmode.enabled == 3)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mod:Toggle()
|
||||
if profile_tankmode.enabled == 1 then
|
||||
-- smart tank mode, listen for spec changes
|
||||
self:RegisterEvent("PLAYER_TALENT_UPDATE", "Update")
|
||||
|
||||
-- on a warrior, watch for gladiator stance
|
||||
if class == "WARRIOR" then
|
||||
self:RegisterEvent("UPDATE_SHAPESHIFT_FORM", "Update")
|
||||
end
|
||||
else
|
||||
self:UnregisterEvent("PLAYER_TALENT_UPDATE")
|
||||
self:UnregisterEvent("UPDATE_SHAPESHIFT_FORM")
|
||||
end
|
||||
|
||||
self:Update()
|
||||
end
|
||||
|
||||
function mod:ThreatUpdate(frame)
|
||||
frame.hasThreat = true
|
||||
-- we are holding threat if the default glow is red
|
||||
frame.holdingThreat = frame.glow.r > .9 and (frame.glow.g + frame.glow.b) < .1
|
||||
|
||||
if not frame.targetGlow or not frame.target then
|
||||
if tankmode then
|
||||
-- set glow to tank colour unless this is the current target
|
||||
frame:SetGlowColour(unpack(profile_tankmode.glowcolour))
|
||||
else
|
||||
-- not in tank mode; set glow to default ui's colour
|
||||
frame:SetGlowColour(frame.glow.r, frame.glow.g, frame.glow.b)
|
||||
end
|
||||
end
|
||||
|
||||
if tankmode then
|
||||
-- also change health bar colour in tank mode
|
||||
if frame.holdingThreat then
|
||||
frame:SetHealthColour(10, unpack(profile_tankmode.barcolour))
|
||||
ShowThreatBrackets(frame, unpack(profile_tankmode.barcolour))
|
||||
else
|
||||
-- losing/gaining threat
|
||||
frame:SetHealthColour(10, unpack(profile_tankmode.midcolour))
|
||||
ShowThreatBrackets(frame, unpack(profile_tankmode.midcolour))
|
||||
end
|
||||
else
|
||||
-- not in tank mode; use default glow colour for brackets, too
|
||||
ShowThreatBrackets(frame, frame.glow.r, frame.glow.g, frame.glow.b)
|
||||
end
|
||||
end
|
||||
function mod:ThreatClear(frame)
|
||||
frame:SetHealthColour(false)
|
||||
ShowThreatBrackets(frame, false)
|
||||
end
|
||||
-------------------------------------------------------------------- messages --
|
||||
function mod:PostCreate(msg, f)
|
||||
self:CreateThreatBrackets(f)
|
||||
end
|
||||
function mod:PostHide(msg, f)
|
||||
ShowThreatBrackets(f, false)
|
||||
end
|
||||
---------------------------------------------------- Post db change functions --
|
||||
mod:AddConfigChanged("enabled", function() mod:Toggle() end)
|
||||
mod:AddConfigChanged(
|
||||
{"brackets", "scale"},
|
||||
function()
|
||||
mod:UpdateThreatBracketScaling()
|
||||
end,
|
||||
function(f)
|
||||
mod:UpdateThreatBrackets(f)
|
||||
end
|
||||
)
|
||||
-------------------------------------------------------------------- Register --
|
||||
function mod:GetOptions()
|
||||
return {
|
||||
tankmode = {
|
||||
type = "group",
|
||||
name = L["Tank mode"],
|
||||
inline = true,
|
||||
order = 10,
|
||||
disabled = function(info)
|
||||
return mod.db.profile.tankmode.enabled == 2
|
||||
end,
|
||||
args = {
|
||||
enabled = {
|
||||
type = "select",
|
||||
name = L["Enable tank mode"],
|
||||
desc = L['Change the colour of a plate\'s health bar and border when you have threat on its unit.\n\nSelecting "Smart" (default) will automatically enable or disable tank mode based on your current specialisation\'s role.'],
|
||||
values = {"Smart", "Disabled", "Enabled"},
|
||||
order = 0,
|
||||
width = "double",
|
||||
disabled = false
|
||||
},
|
||||
barcolour = {
|
||||
type = "color",
|
||||
name = L["Bar colour"],
|
||||
desc = L["The bar colour to use when you have threat"],
|
||||
order = 10,
|
||||
width = "half"
|
||||
},
|
||||
midcolour = {
|
||||
type = "color",
|
||||
name = L["Transitional colour"],
|
||||
desc = L["The bar colour to use when you are losing or gaining threat."],
|
||||
order = 20,
|
||||
width = "half"
|
||||
},
|
||||
glowcolour = {
|
||||
type = "color",
|
||||
name = L["Glow colour"],
|
||||
desc = L["The glow (border) colour to use when you have threat"],
|
||||
hasAlpha = true,
|
||||
order = 30,
|
||||
width = "half"
|
||||
}
|
||||
}
|
||||
},
|
||||
brackets = {
|
||||
type = "group",
|
||||
name = L["Threat brackets"],
|
||||
inline = true,
|
||||
order = 20,
|
||||
disabled = function(info)
|
||||
return not mod.db.profile.brackets.enable_brackets
|
||||
end,
|
||||
args = {
|
||||
enable_brackets = {
|
||||
type = "toggle",
|
||||
name = L["Show threat brackets"],
|
||||
desc = L["Show threat brackets when you have threat on a nameplate. Kind of like target arrows, but for threat. In tank mode they will inherit the bar colour set above. Otherwise they will use the default glow colour."],
|
||||
order = 10,
|
||||
disabled = false
|
||||
},
|
||||
scale = {
|
||||
type = "range",
|
||||
name = L["Threat bracket scale"],
|
||||
desc = L["The scale of the threat bracket textures"],
|
||||
order = 20,
|
||||
min = 0.1,
|
||||
softMin = 0.5,
|
||||
softMax = 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
function mod:configChangedListener()
|
||||
profile_tankmode = self.db.profile.tankmode
|
||||
end
|
||||
|
||||
function mod:OnInitialize()
|
||||
self.db = addon.db:RegisterNamespace(self.moduleName, {profile = {
|
||||
tankmode = {
|
||||
enabled = 1,
|
||||
barcolour = {.2, .9, .1},
|
||||
midcolour = {1, .5, 0},
|
||||
glowcolour = {1, 0, 0, 1}
|
||||
},
|
||||
brackets = {
|
||||
enable_brackets = true,
|
||||
scale = 1
|
||||
}
|
||||
}})
|
||||
|
||||
addon:InitModuleOptions(self)
|
||||
self:UpdateThreatBracketScaling()
|
||||
self:SetEnabledState(true)
|
||||
end
|
||||
|
||||
function mod:OnEnable()
|
||||
class = select(2, UnitClass("player"))
|
||||
|
||||
if self.db.profile.brackets.enable_brackets then
|
||||
self:RegisterMessage("KuiNameplates_PostCreate", "PostCreate")
|
||||
self:RegisterMessage("KuiNameplates_PostHide", "PostHide")
|
||||
end
|
||||
|
||||
self:Toggle()
|
||||
end
|
||||
@@ -0,0 +1,57 @@
|
||||
--[[
|
||||
-- Kui_Nameplates
|
||||
-- By Kesava at curse.com
|
||||
-- All rights reserved
|
||||
-- Backported by: Kader at https://github.com/bkader
|
||||
]]
|
||||
local addon = LibStub("AceAddon-3.0"):GetAddon("KuiNameplates")
|
||||
local mod = addon:NewModule("TargetArrows", "AceEvent-3.0")
|
||||
|
||||
local arrowSize
|
||||
|
||||
-- messages ####################################################################
|
||||
function mod:PostCreate(msg, f)
|
||||
local ta = CreateFrame("Frame", nil, f)
|
||||
ta:SetFrameLevel(1) -- same as castbar/healthbar
|
||||
|
||||
ta.left = ta:CreateTexture(nil, "ARTWORK", nil, -1)
|
||||
ta.left:SetTexture("Interface\\AddOns\\Kui_Nameplates\\Media\\target-arrow")
|
||||
ta.left:SetPoint("RIGHT", f.overlay, "LEFT", 14, -1)
|
||||
ta.left:SetSize(arrowSize, arrowSize)
|
||||
|
||||
ta.right = ta:CreateTexture(nil, "ARTWORK", nil, -1)
|
||||
ta.right:SetTexture("Interface\\AddOns\\Kui_Nameplates\\Media\\target-arrow")
|
||||
ta.right:SetPoint("LEFT", f.overlay, "RIGHT", -14, -1)
|
||||
ta.right:SetTexCoord(1, 0, 0, 1)
|
||||
ta.right:SetSize(arrowSize, arrowSize)
|
||||
|
||||
ta.left:SetVertexColor(unpack(addon.db.profile.general.targetglowcolour))
|
||||
ta.right:SetVertexColor(unpack(addon.db.profile.general.targetglowcolour))
|
||||
|
||||
ta:Hide()
|
||||
f.targetArrows = ta
|
||||
end
|
||||
function mod:PostHide(msg, f)
|
||||
f.targetArrows:Hide()
|
||||
end
|
||||
function mod:PostTarget(msg, f, is_target)
|
||||
if not f.targetArrows then
|
||||
return
|
||||
end
|
||||
if is_target then
|
||||
f.targetArrows:Show()
|
||||
else
|
||||
f.targetArrows:Hide()
|
||||
end
|
||||
end
|
||||
-- register ####################################################################
|
||||
function mod:OnInitialize()
|
||||
self:SetEnabledState(addon.db.profile.general.targetarrows)
|
||||
end
|
||||
function mod:OnEnable()
|
||||
arrowSize = floor(addon.sizes.tex.targetArrow)
|
||||
|
||||
self:RegisterMessage("KuiNameplates_PostCreate", "PostCreate")
|
||||
self:RegisterMessage("KuiNameplates_PostTarget", "PostTarget")
|
||||
self:RegisterMessage("KuiNameplates_PostHide", "PostHide")
|
||||
end
|
||||
Reference in New Issue
Block a user