Commit 38d39e88 authored by Tukz's avatar Tukz
Browse files

Add ThreatBar

parent f931dc89
......@@ -2079,7 +2079,9 @@ end
local Misc = function(self)
local Window = self:CreateWindow("Misc")
Window:CreateSection("Threat")
Window:CreateSwitch("Misc", "ThreatBar", "Enable Threat Bar")
Window:CreateSection("World Map")
Window:CreateSwitch("Misc", "WorldMapEnable", "Enable our custom world map")
Window:CreateSwitch("Misc", "FadeWorldMapWhileMoving", "Fade world map while moving?")
......
......@@ -96,6 +96,7 @@ C["Loot"] = {
}
C["Misc"] = {
["ThreatBar"] = true,
["WorldMapEnable"] = true,
["ExperienceEnable"] = true,
["ErrorFilterEnable"] = true,
......
......@@ -132,6 +132,7 @@ function Loading:OnEvent(event)
T["Miscellaneous"]["GuildNamesByClassColor"]:Enable()
T["Miscellaneous"]["WhoNamesByClassColor"]:Enable()
T["Miscellaneous"]["Keybinds"]:Enable()
T["Miscellaneous"]["ThreatBar"]:Enable()
T["Auras"]:Enable()
T["Maps"]["Minimap"]:Enable()
T["Maps"]["Zonemap"]:Enable()
......
......@@ -49,6 +49,7 @@
<Script file="Miscellaneous\GuildNamesByClassColor.lua"/>
<Script file="Miscellaneous\WhoNamesByClassColor.lua"/>
<Script file="Miscellaneous\Keybinds.lua"/>
<Script file="Miscellaneous\ThreatBar.lua"/>
<!-- Auras -->
<Include file="Auras\Templates.xml"/>
......
local T, C, L = select(2, ...):unpack()
local Miscellaneous = T["Miscellaneous"]
local format = string.format
local floor = math.floor
local UnitName = UnitName
local ThreatBar = CreateFrame("StatusBar", nil, UIParent)
function ThreatBar:OnEvent(event)
local Party = GetNumGroupMembers()
local Raid = GetNumGroupMembers()
local Pet = HasPetUI()
if (event == "PLAYER_ENTERING_WORLD" or event == "PLAYER_DEAD") then
self:Hide()
elseif (event == "PLAYER_REGEN_ENABLED") then
self:Hide()
elseif (event == "PLAYER_REGEN_DISABLED") then
if (Party > 0 or Raid > 0 or Pet) then
self:Show()
else
self:Show()
end
end
end
function ThreatBar:OnUpdate()
local GetColor = T.ColorGradient
if UnitAffectingCombat("player") then
local _, _, ThreatPercent = UnitDetailedThreatSituation("player", "target")
local ThreatValue = ThreatPercent or 0
local Text = self.Text
local Title = self.Title
local Dead = UnitIsDead("player")
self:SetValue(ThreatValue)
Text:SetText(floor(ThreatValue) .. "%")
Title:SetText((UnitName("target") and UnitName("target") .. ":") or "")
local R, G, B = GetColor(ThreatValue, 100, 0,.8,0,.8,.8,0,.8,0,0)
self:SetStatusBarColor(R, G, B)
if Dead then
self:SetAlpha(0)
elseif (ThreatValue > 0) then
self:SetAlpha(1)
else
self:SetAlpha(0)
end
end
end
function ThreatBar:Create()
self:SetParent(T["Panels"].DataTextRight)
self:Point("TOPLEFT", 2, -2)
self:Point("BOTTOMRIGHT", -2, 2)
self:SetFrameLevel(T["Panels"].DataTextRight:GetFrameLevel() + 2)
self:SetFrameStrata("HIGH")
self:SetStatusBarTexture(C.Medias.Normal)
self:SetMinMaxValues(0, 100)
self:SetAlpha(0)
self.Text = self:CreateFontString(nil, "OVERLAY")
self.Text:SetFont(C.Medias.Font, 12)
self.Text:Point("RIGHT", self, -30, 0)
self.Text:SetShadowColor(0, 0, 0)
self.Text:SetShadowOffset(1.25, -1.25)
self.Title = self:CreateFontString(nil, "OVERLAY")
self.Title:SetFont(C.Medias.Font, 12)
self.Title:Point("LEFT", self, 30, 0)
self.Title:SetShadowColor(0, 0, 0)
self.Title:SetShadowOffset(1.25, -1.25)
self.Background = self:CreateTexture(nil, "BORDER")
self.Background:Point("TOPLEFT", self, 0, 0)
self.Background:Point("BOTTOMRIGHT", self, 0, 0)
self.Background:SetColorTexture(0.15, 0.15, 0.15)
self:SetScript("OnShow", function(self)
self:SetScript("OnUpdate", self.OnUpdate)
end)
self:SetScript("OnHide", function(self)
self:SetScript("OnUpdate", nil)
end)
self:RegisterEvent("PLAYER_DEAD")
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("PLAYER_REGEN_ENABLED")
self:RegisterEvent("PLAYER_REGEN_DISABLED")
self:SetScript("OnEvent", self.OnEvent)
end
function ThreatBar:Enable()
if not C.Misc.ThreatBar then
return
end
self:Create()
end
Miscellaneous.ThreatBar = ThreatBar
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment