mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 08:24:44 +00:00
test nameplate
This commit is contained in:
@@ -1,39 +1,124 @@
|
||||
local E, L, V, P, G = unpack(ElvUI)
|
||||
local mod = E:GetModule("NamePlates")
|
||||
local LSM = LibStub("LibSharedMedia-3.0")
|
||||
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local mod = E:GetModule("NamePlates");
|
||||
local LSM = LibStub("LibSharedMedia-3.0");
|
||||
|
||||
--Cache global variables
|
||||
--Lua functions
|
||||
--WoW API / Variables
|
||||
local CreateFrame = CreateFrame
|
||||
|
||||
--[[
|
||||
Target Glow Style Option Variables
|
||||
style1 - Border
|
||||
style2 - Background
|
||||
style3 - Top Arrow Only
|
||||
style4 - Side Arrows Only
|
||||
style5 - Border + Top Arrow
|
||||
style6 - Background + Top Arrow
|
||||
style7 - Border + Side Arrows
|
||||
style8 - Background + Side Arrows
|
||||
]]
|
||||
|
||||
function mod:UpdatePoisiton_Arrow(frame, shouldShow)
|
||||
if frame.TopArrow and (shouldShow ~= 2) and (self.db.targetGlow == "style3" or self.db.targetGlow == "style5" or self.db.targetGlow == "style6") then -- top arrow
|
||||
local topArrowSpace = -3
|
||||
if self.db.units[frame.UnitType].showName and (frame.Name:GetText() ~= nil and frame.Name:GetText() ~= "") then
|
||||
topArrowSpace = self.db.fontSize + topArrowSpace
|
||||
end
|
||||
frame.TopArrow:SetPoint("BOTTOM", frame.HealthBar, "TOP", 0, topArrowSpace)
|
||||
|
||||
if shouldShow then
|
||||
frame.TopArrow:Show()
|
||||
end
|
||||
end
|
||||
|
||||
if (frame.LeftArrow and frame.RightArrow) and (shouldShow ~= 2) and (self.db.targetGlow == "style4" or self.db.targetGlow == "style7" or self.db.targetGlow == "style8") then -- side arrows
|
||||
frame.RightArrow:SetPoint("RIGHT", frame.HealthBar, "LEFT", 3, 0)
|
||||
frame.LeftArrow:SetPoint("LEFT", frame.HealthBar, "RIGHT", -3, 0)
|
||||
|
||||
if shouldShow then
|
||||
frame.RightArrow:Show()
|
||||
frame.LeftArrow:Show()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mod:UpdatePosition_Glow(frame, shouldShow)
|
||||
local castBar = frame.CastBar and frame.CastBar:IsShown() and frame.CastBar
|
||||
local iconPosition = castBar and (castBar.Icon and castBar.Icon:IsShown()) and (frame.UnitType and self.db.units[frame.UnitType].castbar.iconPosition)
|
||||
|
||||
if frame.Glow and (self.db.targetGlow == "style1" or self.db.targetGlow == "style5" or self.db.targetGlow == "style7") then -- original glow
|
||||
local offset = (E.PixelMode and E.mult*6) or E.mult*8 -- edgeSize is 6 (not attached to the backdrop needs +1 for pixel mode or +3 for non pixel mode)
|
||||
if self.db.units[frame.UnitType].castbar.offset < 4 then
|
||||
E:SetOutside(frame.Glow, (iconPosition == "LEFT" and castBar.Icon) or frame.HealthBar, offset, offset, (iconPosition == "RIGHT" and castBar.Icon) or castBar)
|
||||
else
|
||||
E:SetOutside(frame.Glow, frame.HealthBar, offset, offset)
|
||||
end
|
||||
|
||||
if shouldShow then
|
||||
frame.Glow:Show()
|
||||
end
|
||||
end
|
||||
|
||||
if frame.Glow2 and (self.db.targetGlow == "style2" or self.db.targetGlow == "style6" or self.db.targetGlow == "style8") then -- new background glow
|
||||
local scale = 1
|
||||
if self.db.useTargetScale then
|
||||
if self.db.targetScale >= 0.75 then
|
||||
scale = self.db.targetScale
|
||||
else
|
||||
scale = 0.75
|
||||
end
|
||||
end
|
||||
|
||||
local size = (E.Border+14+(castBar and 3 or 0))*scale
|
||||
frame.Glow2:SetPoint("TOPLEFT", (iconPosition == "LEFT" and castBar.Icon) or frame.HealthBar, "TOPLEFT", -(size*2), size)
|
||||
frame.Glow2:SetPoint("BOTTOMRIGHT", (iconPosition == "RIGHT" and castBar.Icon) or castBar or frame.HealthBar, "BOTTOMRIGHT", size*2, -size)
|
||||
|
||||
if shouldShow then
|
||||
frame.Glow2:Show()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mod:UpdateElement_Glow(frame)
|
||||
if frame.TopArrow:IsShown() then frame.TopArrow:Hide() end
|
||||
if frame.LeftArrow:IsShown() then frame.LeftArrow:Hide() end
|
||||
if frame.RightArrow:IsShown() then frame.RightArrow:Hide() end
|
||||
if frame.Glow2:IsShown() then frame.Glow2:Hide() end
|
||||
if frame.Glow:IsShown() then frame.Glow:Hide() end
|
||||
if not frame.HealthBar:IsShown() then return end
|
||||
|
||||
local r, g, b, shouldShow
|
||||
if frame.isTarget and self.db.useTargetGlow then
|
||||
r, g, b = 1, 1, 1
|
||||
shouldShow = true
|
||||
else
|
||||
local shouldShow, r, g, b, a = 0
|
||||
if frame.isTarget and self.db.targetGlow ~= "none" then
|
||||
r, g, b, a = self.db.glowColor.r, self.db.glowColor.g, self.db.glowColor.b, self.db.glowColor.a
|
||||
shouldShow = 1
|
||||
elseif self.db.lowHealthThreshold > 0 then
|
||||
local health = frame.oldHealthBar:GetValue()
|
||||
local _, maxHealth = frame.oldHealthBar:GetMinMaxValues()
|
||||
local perc = health / maxHealth
|
||||
if perc <= self.db.lowHealthThreshold then
|
||||
if perc <= self.db.lowHealthThreshold / 2 then
|
||||
r, g, b = 1, 0, 0
|
||||
r, g, b, a = 1, 0, 0, 1
|
||||
else
|
||||
r, g, b = 1, 1, 0
|
||||
r, g, b, a = 1, 1, 0, 1
|
||||
end
|
||||
|
||||
shouldShow = true
|
||||
shouldShow = 2
|
||||
end
|
||||
end
|
||||
|
||||
if shouldShow then
|
||||
frame.Glow:Show()
|
||||
if r ~= frame.Glow.r or g ~= frame.Glow.g or b ~= frame.Glow.b then
|
||||
frame.Glow:SetBackdropBorderColor(r, g, b)
|
||||
frame.Glow.r, frame.Glow.g, frame.Glow.b = r, g, b
|
||||
if shouldShow ~= 0 then
|
||||
self:UpdatePosition_Glow(frame, shouldShow)
|
||||
self:UpdatePoisiton_Arrow(frame, shouldShow)
|
||||
|
||||
if frame.Glow and (r ~= frame.Glow.r or g ~= frame.Glow.g or b ~= frame.Glow.b or a ~= frame.Glow.a) then
|
||||
frame.Glow:SetBackdropBorderColor(r, g, b, a)
|
||||
frame.Glow2:SetVertexColor(r, g, b, a)
|
||||
frame.TopArrow:SetVertexColor(r, g, b, a)
|
||||
frame.LeftArrow:SetVertexColor(r, g, b, a)
|
||||
frame.RightArrow:SetVertexColor(r, g, b, a)
|
||||
frame.Glow.r, frame.Glow.g, frame.Glow.b, frame.Glow.a = r, g, b, a
|
||||
end
|
||||
elseif frame.Glow:IsShown() then
|
||||
frame.Glow:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -44,13 +129,34 @@ end
|
||||
function mod:ConstructElement_Glow(frame)
|
||||
local f = CreateFrame("Frame", nil, frame)
|
||||
f:SetFrameLevel(frame.HealthBar:GetFrameLevel() - 1)
|
||||
E:SetOutside(f, frame.HealthBar, 3, 3)
|
||||
f:SetBackdrop({
|
||||
edgeFile = LSM:Fetch("border", "ElvUI GlowBorder"), edgeSize = E:Scale(3),
|
||||
insets = {left = E:Scale(5), right = E:Scale(5), top = E:Scale(5), bottom = E:Scale(5)}
|
||||
})
|
||||
|
||||
f:SetScale(E.PixelMode and 1.5 or 2)
|
||||
f:SetBackdrop({edgeFile = LSM:Fetch("border", "ElvUI GlowBorder"), edgeSize = E:Scale(6)})
|
||||
f:Hide()
|
||||
|
||||
local glow = frame:CreateTexture(nil, "BACKGROUND")
|
||||
glow:SetTexture([[Interface\AddOns\ElvUI\media\textures\spark.tga]])
|
||||
glow:Hide()
|
||||
frame.Glow2 = glow
|
||||
|
||||
local top = frame:CreateTexture(nil, "BACKGROUND")
|
||||
top:SetTexture([[Interface\AddOns\ElvUI\media\textures\nameplateTargetIndicator.tga]])
|
||||
top:SetWidth(45)
|
||||
top:SetHeight(45)
|
||||
top:Hide()
|
||||
frame.TopArrow = top
|
||||
|
||||
local left = frame:CreateTexture(nil, "BACKGROUND")
|
||||
left:SetTexture([[Interface\AddOns\ElvUI\media\textures\nameplateTargetIndicatorLeft.tga]])
|
||||
left:SetWidth(45)
|
||||
left:SetHeight(45)
|
||||
left:Hide()
|
||||
frame.LeftArrow = left
|
||||
|
||||
local right = frame:CreateTexture(nil, "BACKGROUND")
|
||||
right:SetTexture([[Interface\AddOns\ElvUI\media\textures\nameplateTargetIndicatorRight.tga]])
|
||||
right:SetWidth(45)
|
||||
right:SetHeight(45)
|
||||
right:Hide()
|
||||
frame.RightArrow = right
|
||||
|
||||
return f
|
||||
end
|
||||
@@ -165,7 +165,15 @@ end
|
||||
function mod:ConstructElement_HealthBar(parent)
|
||||
local frame = CreateFrame("StatusBar", nil, parent)
|
||||
self:StyleFrame(frame)
|
||||
frame:SetFrameLevel(parent:GetFrameLevel())
|
||||
|
||||
frame:SetScript("OnSizeChanged", function()
|
||||
parent:SetWidth(this:GetWidth())
|
||||
parent:SetHeight(this:GetHeight())
|
||||
|
||||
local health = this:GetValue()
|
||||
local _, maxHealth = this:GetMinMaxValues()
|
||||
this:GetStatusBarTexture():SetPoint("TOPRIGHT", -(this:GetWidth() * ((maxHealth - health) / maxHealth)), 0)
|
||||
end)
|
||||
|
||||
frame.text = frame:CreateFontString(nil, "OVERLAY")
|
||||
frame.scale = CreateAnimationGroup(frame)
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local mod = E:GetModule("NamePlates");
|
||||
local LSM = LibStub("LibSharedMedia-3.0");
|
||||
|
||||
--Cache global variables
|
||||
--Lua functions
|
||||
--WoW API / Variables
|
||||
|
||||
function mod:UpdateElement_Highlight(frame)
|
||||
if frame:IsShown() and frame.isMouseover and (frame.NameOnlyChanged or (not self.db.units[frame.UnitType].healthbar.enable and self.db.units[frame.UnitType].showName)) and not frame.isTarget then
|
||||
frame.Name.NameOnlyGlow:Show()
|
||||
frame.Highlight:Show()
|
||||
elseif frame:IsShown() and frame.isMouseover and (not frame.NameOnlyChanged or self.db.units[frame.UnitType].healthbar.enable) and not frame.isTarget then
|
||||
frame.Highlight.texture:ClearAllPoints()
|
||||
frame.Highlight.texture:SetPoint("TOPLEFT", frame.HealthBar, "TOPLEFT")
|
||||
frame.Highlight.texture:SetPoint("BOTTOMRIGHT", frame.HealthBar:GetStatusBarTexture(), "BOTTOMRIGHT")
|
||||
frame.Highlight.texture:Show()
|
||||
frame.Highlight:Show()
|
||||
else
|
||||
frame.Name.NameOnlyGlow:Hide()
|
||||
frame.Highlight.texture:Hide()
|
||||
frame.Highlight:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function mod:ConfigureElement_Highlight(frame)
|
||||
if not self.db.units[frame.UnitType].healthbar.enable then return end
|
||||
frame.Highlight.texture:SetTexture(LSM:Fetch("statusbar", self.db.statusbar))
|
||||
end
|
||||
|
||||
function mod:ConstructElement_Highlight(frame)
|
||||
local f = CreateFrame("Frame", nil, frame)
|
||||
f.texture = frame.HealthBar:CreateTexture(nil, "ARTWORK")
|
||||
f.texture:SetVertexColor(1, 1, 1, 0.3)
|
||||
f.texture:Hide()
|
||||
|
||||
f:SetScript("OnHide", function()
|
||||
frame.Name.NameOnlyGlow:Hide()
|
||||
frame.Highlight.texture:Hide()
|
||||
end)
|
||||
|
||||
return f
|
||||
end
|
||||
@@ -8,4 +8,5 @@
|
||||
<Script file="Name.lua"/>
|
||||
<Script file="RaidIcon.lua"/>
|
||||
<Script file="HealerIcon.lua"/>
|
||||
<Script file="Highlight.lua"/>
|
||||
</Ui>
|
||||
@@ -36,6 +36,12 @@ function mod:UpdateElement_Name(frame)
|
||||
else
|
||||
frame.Name:SetTextColor(1, 1, 1)
|
||||
end
|
||||
|
||||
if self.db.nameColoredGlow then
|
||||
frame.Name.NameOnlyGlow:SetVertexColor(r - 0.1, g - 0.1, b - 0.1, 1)
|
||||
else
|
||||
frame.Name.NameOnlyGlow:SetVertexColor(self.db.glowColor.r, self.db.glowColor.g, self.db.glowColor.b, self.db.glowColor.a)
|
||||
end
|
||||
end
|
||||
|
||||
function mod:ConfigureElement_Name(frame)
|
||||
@@ -44,7 +50,7 @@ function mod:ConfigureElement_Name(frame)
|
||||
name:SetJustifyH("LEFT")
|
||||
name:SetJustifyV("BOTTOM")
|
||||
name:ClearAllPoints()
|
||||
if self.db.units[frame.UnitType].healthbar.enable or frame.isTarget then
|
||||
if(self.db.units[frame.UnitType].healthbar.enable or (self.db.alwaysShowTargetHealth and frame.isTarget)) then
|
||||
name:SetJustifyH("LEFT")
|
||||
name:SetPoint("BOTTOMLEFT", frame.HealthBar, "TOPLEFT", 0, E.Border*2)
|
||||
name:SetPoint("BOTTOMRIGHT", frame.Level, "BOTTOMLEFT")
|
||||
@@ -58,6 +64,15 @@ end
|
||||
|
||||
function mod:ConstructElement_Name(frame)
|
||||
local name = frame:CreateFontString(nil, "OVERLAY")
|
||||
name:SetFont(LSM:Fetch("font", self.db.font), self.db.fontSize, self.db.fontOutline)
|
||||
|
||||
local g = frame:CreateTexture(nil, "BACKGROUND")
|
||||
g:SetTexture([[Interface\AddOns\ElvUI\media\textures\spark.tga]])
|
||||
g:Hide()
|
||||
g:SetPoint("TOPLEFT", name, -20, 8)
|
||||
g:SetPoint("BOTTOMRIGHT", name, 20, -8)
|
||||
|
||||
name.NameOnlyGlow = g
|
||||
|
||||
return name
|
||||
end
|
||||
Reference in New Issue
Block a user