test nameplate

This commit is contained in:
Bunny67
2018-07-28 13:10:20 +03:00
parent 362eae4448
commit 4384d79397
4 changed files with 281 additions and 107 deletions
+10 -35
View File
@@ -102,40 +102,13 @@ end
function mod:UpdateElement_Health(frame) function mod:UpdateElement_Health(frame)
local health = frame.oldHealthBar:GetValue() local health = frame.oldHealthBar:GetValue()
local _, maxHealth = frame.oldHealthBar:GetMinMaxValues() local _, maxHealth = frame.oldHealthBar:GetMinMaxValues()
frame.HealthBar:SetMinMaxValues(0, maxHealth) frame.HealthBar:SetMinMaxValues(0, maxHealth)
frame.HealthBar:SetValue(health) frame.HealthBar:SetValue(health)
--frame:GetParent().UnitFrame.FlashTexture:Point("TOPRIGHT", frame.HealthBar:GetStatusBarTexture(), "TOPRIGHT") --idk why this fixes this
if self.db.units[frame.UnitType].healthbar.text.enable then if self.db.units[frame.UnitType].healthbar.text.enable then
if maxHealth ~= 100 then frame.HealthBar.text:SetText(E:GetFormattedText(self.db.units[frame.UnitType].healthbar.text.format, health, maxHealth))
frame.HealthBar.text:SetText(E:GetFormattedText(self.db.units[frame.UnitType].healthbar.text.format, health, maxHealth))
else
local newMaxHealth
if frame.unit == "target" then
--health, maxHealth = LMH:GetUnitHealth("target")
else
local level = self:UnitLevel(frame)
if level == "??" then
level = UnitLevel("player") + 3
end
if frame.UnitType == "FRIENDLY_PLAYER" or frame.UnitType == "ENEMY_PLAYER" then
-- newMaxHealth = LMH:GetMaxHP(frame.UnitName, tonumber(level), "pc")
elseif frame.UnitType == "FRIENDLY_NPC" or frame.UnitType == "ENEMY_NPC" then
-- newMaxHealth = LMH:GetMaxHP(frame.UnitName, tonumber(level), "npc", GetInstanceDifficulty())
else
-- newMaxHealth = LMH:GetMaxHP(frame.UnitName, tonumber(level))
end
if newMaxHealth then
health = newMaxHealth / 100 * health
maxHealth = newMaxHealth
end
end
frame.HealthBar.text:SetText(E:GetFormattedText(self.db.units[frame.UnitType].healthbar.text.format, health, maxHealth))
end
else else
frame.HealthBar.text:SetText("") frame.HealthBar.text:SetText("")
end end
@@ -145,6 +118,9 @@ function mod:ConfigureElement_HealthBar(frame, configuring)
local healthBar = frame.HealthBar local healthBar = frame.HealthBar
healthBar:SetPoint("TOP", frame, "CENTER", 0, self.db.units[frame.UnitType].castbar.height + 3) healthBar:SetPoint("TOP", frame, "CENTER", 0, self.db.units[frame.UnitType].castbar.height + 3)
frame:SetWidth(self.db.clickableWidth + ((E.PixelMode and 2) or 6))
frame:SetHeight(self.db.clickableHeight + self.db.units[frame.UnitType].castbar.height + 3)
if frame.isTarget and self.db.useTargetScale then if frame.isTarget and self.db.useTargetScale then
healthBar:SetHeight(self.db.units[frame.UnitType].healthbar.height * ((frame.CustomScale and frame.CustomScale * self.db.targetScale) or self.db.targetScale)) healthBar:SetHeight(self.db.units[frame.UnitType].healthbar.height * ((frame.CustomScale and frame.CustomScale * self.db.targetScale) or self.db.targetScale))
healthBar:SetWidth(self.db.units[frame.UnitType].healthbar.width * ((frame.CustomScale and frame.CustomScale * self.db.targetScale) or self.db.targetScale)) healthBar:SetWidth(self.db.units[frame.UnitType].healthbar.width * ((frame.CustomScale and frame.CustomScale * self.db.targetScale) or self.db.targetScale))
@@ -165,16 +141,15 @@ end
function mod:ConstructElement_HealthBar(parent) function mod:ConstructElement_HealthBar(parent)
local frame = CreateFrame("StatusBar", nil, parent) local frame = CreateFrame("StatusBar", nil, parent)
self:StyleFrame(frame) self:StyleFrame(frame)
--[[
frame:SetScript("OnSizeChanged", function() frame:SetScript("OnSizeChanged", function()
parent:SetWidth(this:GetWidth())
parent:SetHeight(this:GetHeight())
local health = this:GetValue() local health = this:GetValue()
local _, maxHealth = this:GetMinMaxValues() local _, maxHealth = this:GetMinMaxValues()
if health > maxHealth or health < 0 then return end
this:GetStatusBarTexture():SetPoint("TOPRIGHT", -(this:GetWidth() * ((maxHealth - health) / maxHealth)), 0) this:GetStatusBarTexture():SetPoint("TOPRIGHT", -(this:GetWidth() * ((maxHealth - health) / maxHealth)), 0)
end) end)
]]
frame.text = frame:CreateFontString(nil, "OVERLAY") frame.text = frame:CreateFontString(nil, "OVERLAY")
frame.scale = CreateAnimationGroup(frame) frame.scale = CreateAnimationGroup(frame)
+47 -39
View File
@@ -1,6 +1,6 @@
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local mod = E:NewModule("NamePlates", "AceHook-3.0", "AceEvent-3.0", "AceTimer-3.0"); local mod = E:NewModule("NamePlates", "AceHook-3.0", "AceEvent-3.0", "AceTimer-3.0");
--local CC = E:GetModule("ClassCache"); local CC = E:GetModule("ClassCache");
--Cache global variables --Cache global variables
--Lua functions --Lua functions
@@ -325,21 +325,9 @@ function mod:RoundColors(r, g, b)
end end
function mod:UnitClass(name, type) function mod:UnitClass(name, type)
--[[if E.private.general.classCache then if E.private.general.classCache then
if type == "FRIENDLY_PLAYER" then return CC:GetClassByName(name)
local _, class = UnitClass(name) end
if class then
return class
else
local name, realm = split("-", name)
return CC:GetClassByName(name, realm)
end
end
else
if type == "FRIENDLY_PLAYER" then
return select(2, UnitClass(name))
end
end--]]
end end
function mod:UnitDetailedThreatSituation(frame) function mod:UnitDetailedThreatSituation(frame)
@@ -386,9 +374,15 @@ function mod:GetUnitInfo(frame)
end end
end end
function mod:OnShow(self) function mod:OnShow(self, isUpdate)
self:SetWidth(0.01) if mod.db.motionType == "OVERLAP" then
self:SetHeight(0.01) self:SetWidth(0.001)
self:SetHeight(0.001)
end
if not isUpdate then
self.UnitFrame.moveUp:Play()
end
mod.VisiblePlates[self.UnitFrame] = true mod.VisiblePlates[self.UnitFrame] = true
@@ -498,7 +492,7 @@ end
function mod:UpdateAllFrame(frame) function mod:UpdateAllFrame(frame)
mod:OnHide(frame:GetParent()) mod:OnHide(frame:GetParent())
mod:OnShow(frame:GetParent()) mod:OnShow(frame:GetParent(), true)
end end
function mod:ConfigureAll() function mod:ConfigureAll()
@@ -556,14 +550,23 @@ function mod:UpdateElement_All(frame, noTargetFrame, filterIgnore)
end end
end end
function mod:AnimatedHide()
local num = 0
for frame in pairs(mod.VisiblePlates) do
frame.moveDown:Play()
num = num + 1
end
if num < 1 then
end
end
local plateID = 0 local plateID = 0
function mod:OnCreated(frame) function mod:OnCreated(frame)
plateID = plateID + 1 plateID = plateID + 1
local HealthBar = frame:GetChildren() local HealthBar = frame:GetChildren()
local Border, Highlight, Name, Level, BossIcon, RaidIcon = frame:GetRegions() local Border, Highlight, Name, Level, BossIcon, RaidIcon = frame:GetRegions()
frame.UnitFrame = CreateFrame("Button", format("ElvUI_NamePlate%d", plateID), frame) frame.UnitFrame = CreateFrame("Button", format("ElvUI_NamePlate%d", plateID), frame)
E:Size(frame.UnitFrame, 100, 20)
frame.UnitFrame:SetPoint("CENTER", 0, 0) frame.UnitFrame:SetPoint("CENTER", 0, 0)
frame.UnitFrame.plateID = plateID frame.UnitFrame.plateID = plateID
@@ -572,6 +575,26 @@ function mod:OnCreated(frame)
frame:Click() frame:Click()
end) end)
frame.UnitFrame.moveUp = CreateAnimationGroup(frame.UnitFrame)
local moveUp = frame.UnitFrame.moveUp:CreateAnimation("Move")
moveUp:SetDuration(0)
moveUp:SetOffset(0, -35)
moveUp:SetOrder(1)
moveUp = frame.UnitFrame.moveUp:CreateAnimation("Move")
moveUp:SetDuration(0.5)
moveUp:SetOffset(0, 35)
moveUp:SetSmoothing("Out")
moveUp:SetOrder(2)
frame.UnitFrame.moveDown = CreateAnimationGroup(frame.UnitFrame)
local moveDown = frame.UnitFrame.moveDown:CreateAnimation("Move")
moveDown:SetDuration(0.1)
moveDown:SetOffset(0, -35)
moveDown:SetSmoothing("In")
moveDown:SetScript("OnFinished", function(self)
self:Reset()
end)
frame.UnitFrame.HealthBar = self:ConstructElement_HealthBar(frame.UnitFrame) frame.UnitFrame.HealthBar = self:ConstructElement_HealthBar(frame.UnitFrame)
frame.UnitFrame.Level = self:ConstructElement_Level(frame.UnitFrame) frame.UnitFrame.Level = self:ConstructElement_Level(frame.UnitFrame)
frame.UnitFrame.Name = self:ConstructElement_Name(frame.UnitFrame) frame.UnitFrame.Name = self:ConstructElement_Name(frame.UnitFrame)
@@ -602,8 +625,8 @@ function mod:OnCreated(frame)
self:OnShow(frame) self:OnShow(frame)
HookScript(frame, "OnShow", function() self:OnShow(this) end) frame:SetScript("OnShow", function() self:OnShow(this) end)
HookScript(frame, "OnHide", function() self:OnHide(this) end) frame:SetScript("OnHide", function() self:OnHide(this) end)
HookScript(HealthBar, "OnValueChanged", self.UpdateElement_HealthOnValueChanged) HookScript(HealthBar, "OnValueChanged", self.UpdateElement_HealthOnValueChanged)
@@ -630,21 +653,6 @@ function mod:QueueObject(object)
object:Hide() object:Hide()
end end
function mod:GetChildren(...)
local count = WorldGetNumChildren(WorldFrame)
if count ~= numChildren then
local frame, region
for i = numChildren + 1, count do
frame = arg[i]
region = frame:GetRegions()
if not mod.CreatedPlates[frame] and region and region:GetObjectType() == "Texture" and region:GetTexture() == BORDER then
mod:OnCreated(frame)
end
numChildren = count
end
end
end
function mod:OnUpdate() function mod:OnUpdate()
local count = WorldGetNumChildren(WorldFrame) local count = WorldGetNumChildren(WorldFrame)
if count ~= numChildren then if count ~= numChildren then
+7
View File
@@ -161,6 +161,13 @@ P["nameplates"] = {
}, },
}, },
["clickableWidth"] = 150,
["clickableHeight"] = 12,
["clickThrough"] = {
["friendly"] = false,
["enemy"] = false,
},
["units"] = { ["units"] = {
["FRIENDLY_PLAYER"] = { ["FRIENDLY_PLAYER"] = {
["healthbar"] = { ["healthbar"] = {
+217 -33
View File
@@ -533,8 +533,79 @@ E.Options.args.nameplate = {
type = "header", type = "header",
name = L["Shortcuts"] name = L["Shortcuts"]
}, },
spacer1 = {
order = 4,
type = "description",
name = " ",
},
generalShortcut = {
order = 5,
type = "execute",
name = L["General"],
buttonElvUI = true,
func = function() ACD:SelectGroup("ElvUI", "nameplate", "generalGroup", "general") end,
disabled = function() return not E.NamePlates; end,
},
fontsShortcut = {
order = 6,
type = "execute",
name = L["Fonts"],
buttonElvUI = true,
func = function() ACD:SelectGroup("ElvUI", "nameplate", "generalGroup", "fontGroup") end,
disabled = function() return not E.NamePlates; end,
},
spacer2 = {
order = 7,
type = "description",
name = " ",
},
friendlyPlayerShortcut = {
order = 8,
type = "execute",
name = L["Friendly Player Frames"],
buttonElvUI = true,
func = function() ACD:SelectGroup("ElvUI", "nameplate", "friendlyPlayerGroup") end,
disabled = function() return not E.NamePlates; end,
},
enemyPlayerShortcut = {
order = 9,
type = "execute",
name = L["Enemy Player Frames"],
buttonElvUI = true,
func = function() ACD:SelectGroup("ElvUI", "nameplate", "enemyPlayerGroup") end,
disabled = function() return not E.NamePlates; end,
},
spacer5 = {
order = 10,
type = "description",
name = " ",
},
friendlyNPCShortcut = {
order = 11,
type = "execute",
name = L["Friendly NPC Frames"],
buttonElvUI = true,
func = function() ACD:SelectGroup("ElvUI", "nameplate", "friendlyNPCGroup") end,
disabled = function() return not E.NamePlates; end,
},
enemyNPCShortcut = {
order = 12,
type = "execute",
name = L["Enemy NPC Frames"],
buttonElvUI = true,
func = function() ACD:SelectGroup("ElvUI", "nameplate", "enemyNPCGroup") end,
disabled = function() return not E.NamePlates; end,
},
--[[ filtersShortcut = {
order = 13,
type = "execute",
name = L["Style Filter"],
buttonElvUI = true,
func = function() ACD:SelectGroup("ElvUI", "nameplate", "filters") end,
disabled = function() return not E.NamePlates; end,
},]]
generalGroup = { generalGroup = {
order = 20, order = 14,
type = "group", type = "group",
name = GENERAL, name = GENERAL,
childGroups = "tab", childGroups = "tab",
@@ -550,43 +621,26 @@ E.Options.args.nameplate = {
type = "select", type = "select",
dialogControl = "LSM30_Statusbar", dialogControl = "LSM30_Statusbar",
name = L["StatusBar Texture"], name = L["StatusBar Texture"],
values = AceGUIWidgetLSMlists.statusbar, values = AceGUIWidgetLSMlists.statusbar
}, },
useTargetGlow = { motionType = {
order = 2, order = 1,
type = "toggle", type = "select",
name = L["Use Target Glow"], name = "UNIT_NAMEPLATES_TYPES",
}, desc = L["Set to either stack nameplates vertically or allow them to overlap."],
useTargetScale = { values = {
order = 3, ["STACKED"] = "STACKED",
type = "toggle", ["OVERLAP"] = "OVERLAP"
name = L["Use Target Scale"], },
desc = L["Enable/Disable the scaling of targetted nameplates."], set = function(info, value) E.db.nameplates.motionType = value; E:StaticPopup_Show("CONFIG_RL") end,
},
targetScale = {
order = 4,
type = "range",
name = L["Target Scale"],
desc = L["Scale of the nameplate that is targetted."],
min = 0.3, max = 2, step = 0.01,
isPercent = true,
disabled = function() return E.db.nameplates.useTargetScale ~= true end,
},
nonTargetTransparency = {
name = L["Non-Target Transparency"],
desc = L["Set the transparency level of nameplates that are not the target nameplate."],
type = "range",
min = 0, max = 1, step = 0.01,
isPercent = true,
order = 8,
}, },
lowHealthThreshold = { lowHealthThreshold = {
order = 9, order = 2,
name = L["Low Health Threshold"], name = L["Low Health Threshold"],
desc = L["Make the unitframe glow yellow when it is below this percent of health, it will glow red when the health value is half of this value."], desc = L["Make the unitframe glow yellow when it is below this percent of health, it will glow red when the health value is half of this value."],
type = "range", type = "range",
isPercent = true, isPercent = true,
min = 0, max = 1, step = 0.01, min = 0, max = 1, step = 0.01
}, },
showEnemyCombat = { showEnemyCombat = {
order = 10, order = 10,
@@ -618,12 +672,142 @@ E.Options.args.nameplate = {
NP:PLAYER_REGEN_ENABLED() NP:PLAYER_REGEN_ENABLED()
end end
}, },
clickableWidth = {
order = 10,
type = "range",
name = L["Clickable Width"],
desc = L["Controls how big of an area on the screen will accept clicks to target unit."],
min = 50, max = 200, step = 1,
set = function(info, value) E.db.nameplates.clickableWidth = value; E:StaticPopup_Show("CONFIG_RL") end,
},
clickableHeight = {
order = 11,
type = "range",
name = L["Clickable Height"],
desc = L["Controls how big of an area on the screen will accept clicks to target unit."],
min = 10, max = 75, step = 1,
set = function(info, value) E.db.nameplates.clickableHeight = value; E:StaticPopup_Show("CONFIG_RL") end,
},
resetFilters = {
order = 12,
name = L["Reset Aura Filters"],
type = "execute",
func = function(info)
E:StaticPopup_Show("RESET_NP_AF") --reset nameplate aurafilters
end,
},
nameColoredGlow = {
order = 13,
type = "toggle",
name = L["Name Colored Glow"],
desc = L["Use the Name Color of the unit for the Name Glow."],
},
comboPoints = { comboPoints = {
order = 12, order = 12,
type = "toggle", type = "toggle",
name = L["Combobar"] name = L["Combobar"]
} },
} targetedNamePlate = {
order = 14,
type = "group",
guiInline = true,
name = L["Targeted Nameplate"],
get = function(info) return E.db.nameplates[ info[getn(info)] ] end,
set = function(info, value) E.db.nameplates[ info[getn(info)] ] = value; NP:ConfigureAll() end,
args = {
useTargetScale = {
order = 1,
type = "toggle",
name = L["Use Target Scale"],
desc = L["Enable/Disable the scaling of targetted nameplates."],
},
targetScale = {
order = 2,
type = "range",
isPercent = true,
name = L["Target Scale"],
desc = L["Scale of the nameplate that is targetted."],
min = 0.3, max = 2, step = 0.01,
disabled = function() return E.db.nameplates.useTargetScale ~= true end,
},
nonTargetTransparency = {
order = 3,
type = "range",
isPercent = true,
name = L["Non-Target Transparency"],
desc = L["Set the transparency level of nameplates that are not the target nameplate."],
min = 0, max = 1, step = 0.01,
},
spacer1 = {
order = 4,
type = 'description',
name = ' ',
},
glowColor = {
name = L["Target Indicator Color"],
type = 'color',
order = 5,
hasAlpha = true,
get = function(info)
local t = E.db.nameplates.glowColor
local d = P.nameplates.glowColor
return t.r, t.g, t.b, t.a, d.r, d.g, d.b, d.a
end,
set = function(info, r, g, b, a)
local t = E.db.nameplates.glowColor
t.r, t.g, t.b, t.a = r, g, b, a
NP:ConfigureAll()
end,
},
targetGlow = {
order = 6,
type = "select",
--customWidth = 225,
name = L["Target Indicator"],
get = function(info) return E.db.nameplates.targetGlow end,
set = function(info, value) E.db.nameplates.targetGlow = value; NP:ConfigureAll() end,
values = {
['none'] = NONE,
['style1'] = L["Border Glow"],
['style2'] = L["Background Glow"],
['style3'] = L["Top Arrow"],
['style4'] = L["Side Arrows"],
['style5'] = L["Border Glow"].." + "..L["Top Arrow"],
['style6'] = L["Background Glow"].." + "..L["Top Arrow"],
['style7'] = L["Border Glow"].." + "..L["Side Arrows"],
['style8'] = L["Background Glow"].." + "..L["Side Arrows"],
},
},
alwaysShowTargetHealth = {
order = 7,
type = "toggle",
name = L["Always Show Target Health"],
-- customWidth = 200,
},
},
},
clickThrough = {
order = 15,
type = "group",
guiInline = true,
name = L["Click Through"],
get = function(info) return E.db.nameplates.clickThrough[ info[getn(info)] ] end,
args = {
friendly = {
order = 2,
type = "toggle",
name = L["Friendly"],
--set = function(info, value) E.db.nameplates.clickThrough.friendly = value; NP:SetNamePlateFriendlyClickThrough() end,
},
enemy = {
order = 3,
type = "toggle",
name = L["Enemy"],
--set = function(info, value) E.db.nameplates.clickThrough.enemy = value; NP:SetNamePlateEnemyClickThrough() end,
},
},
},
},
}, },
fontGroup = { fontGroup = {
order = 100, order = 100,