From 5390a4623da79c3d2060f58e9d428a00b9a3e5a1 Mon Sep 17 00:00:00 2001 From: Xinhuan Date: Fri, 31 Oct 2008 05:35:23 +0800 Subject: [PATCH] Add Show Aggro Bar option. --- Localization/deDE.lua | 5 +++ Localization/enUS.lua | 5 +++ Localization/frFR.lua | 5 +++ Localization/koKR.lua | 5 +++ Localization/zhCN.lua | 5 +++ Localization/zhTW.lua | 5 +++ Omen.lua | 102 ++++++++++++++++++++++++++++++++---------- 7 files changed, 109 insertions(+), 23 deletions(-) diff --git a/Localization/deDE.lua b/Localization/deDE.lua index 4770049..efcccb9 100644 --- a/Localization/deDE.lua +++ b/Localization/deDE.lua @@ -16,6 +16,7 @@ L["Threat [%]"] = "Bedrohung [%]" L["Threat"] = "Bedrohung" L["TPS"] = "BPS" L["Toggle Focus"] = true +L["> Pull Aggro <"] = true -- Warnings L["|cffff0000Error:|r Omen cannot use shake warning if you have turned on nameplates at least once since logging in."] = "|cffff0000Fehler:|r Omen kann keine Wackelwarnungen benutzen wenn Namensschilder aktiviert wurden seitdem Sie eingeloggt haben." @@ -145,6 +146,10 @@ L["Use Tank Bar color"] = true L["Use a different colored background for the tank's threat bar in Omen"] = true L["Tank Bar Color"] = true L["The background color for your tank's threat bar"] = true +L["Show Pull Aggro Bar"] = true +L["Show a bar for the amount of threat you will need to reach in order to pull aggro."] = true +L["Pull Aggro Bar Color"] = true +L["The background color for your Pull Aggro bar"] = true L["Use Class Colors"] = true L["Use standard class colors for the background color of threat bars"] = true L["Bar BG Color"] = true diff --git a/Localization/enUS.lua b/Localization/enUS.lua index a367293..59d24ae 100644 --- a/Localization/enUS.lua +++ b/Localization/enUS.lua @@ -16,6 +16,7 @@ L["Threat [%]"] = true L["Threat"] = true L["TPS"] = true L["Toggle Focus"] = true +L["> Pull Aggro <"] = true -- Warnings L["|cffff0000Error:|r Omen cannot use shake warning if you have turned on nameplates at least once since logging in."] = true @@ -145,6 +146,10 @@ L["Use Tank Bar color"] = true L["Use a different colored background for the tank's threat bar in Omen"] = true L["Tank Bar Color"] = true L["The background color for your tank's threat bar"] = true +L["Show Pull Aggro Bar"] = true +L["Show a bar for the amount of threat you will need to reach in order to pull aggro."] = true +L["Pull Aggro Bar Color"] = true +L["The background color for your Pull Aggro bar"] = true L["Use Class Colors"] = true L["Use standard class colors for the background color of threat bars"] = true L["Bar BG Color"] = true diff --git a/Localization/frFR.lua b/Localization/frFR.lua index a2d03f0..2af2ae4 100644 --- a/Localization/frFR.lua +++ b/Localization/frFR.lua @@ -16,6 +16,7 @@ L["Threat [%]"] = "Menace [%]" L["Threat"] = "Menace" L["TPS"] = "MPS" L["Toggle Focus"] = true +L["> Pull Aggro <"] = true -- Warnings L["|cffff0000Error:|r Omen cannot use shake warning if you have turned on nameplates at least once since logging in."] = "|cffff0000Erreur :|r Omen ne peut utiliser l'avertissement par secousse si vous avez activé les \"nameplates\" au moins une fois depuis votre connexion au jeu." @@ -145,6 +146,10 @@ L["Use Tank Bar color"] = true L["Use a different colored background for the tank's threat bar in Omen"] = true L["Tank Bar Color"] = true L["The background color for your tank's threat bar"] = true +L["Show Pull Aggro Bar"] = true +L["Show a bar for the amount of threat you will need to reach in order to pull aggro."] = true +L["Pull Aggro Bar Color"] = true +L["The background color for your Pull Aggro bar"] = true L["Use Class Colors"] = true L["Use standard class colors for the background color of threat bars"] = true L["Bar BG Color"] = true diff --git a/Localization/koKR.lua b/Localization/koKR.lua index ca16c06..9e1634c 100644 --- a/Localization/koKR.lua +++ b/Localization/koKR.lua @@ -16,6 +16,7 @@ L["Threat [%]"] = "위협 수준 [%]" L["Threat"] = "위협 수준" L["TPS"] = "TPS" L["Toggle Focus"] = "주시 대상 켜기/끄기" +L["> Pull Aggro <"] = true -- Warnings L["|cffff0000Error:|r Omen cannot use shake warning if you have turned on nameplates at least once since logging in."] = "|cffff0000오류:|r 만약 로그인 후 이름표 표시를 한번이라도 했다면 Omen의 진동 경고를 사용 할 수 없습니다." @@ -145,6 +146,10 @@ L["Use Tank Bar color"] = "방어전담 바 색상 사용" L["Use a different colored background for the tank's threat bar in Omen"] = "Omen에서 방어전담(탱커)의 위협 바에 다른 색상을 사용합니다." L["Tank Bar Color"] = "방어전담 바 색상" L["The background color for your tank's threat bar"] = "당신의 방어전담(탱커) 위협 바에 대한 배경 색상을 지정합니다." +L["Show Pull Aggro Bar"] = true +L["Show a bar for the amount of threat you will need to reach in order to pull aggro."] = true +L["Pull Aggro Bar Color"] = true +L["The background color for your Pull Aggro bar"] = true L["Use Class Colors"] = "직업 색상 사용" L["Use standard class colors for the background color of threat bars"] = "위협 바의 배경 색상을 기본 직업 색상으로 사용합니다." L["Bar BG Color"] = "배경 색상 바" diff --git a/Localization/zhCN.lua b/Localization/zhCN.lua index 2c14221..438a3ca 100644 --- a/Localization/zhCN.lua +++ b/Localization/zhCN.lua @@ -16,6 +16,7 @@ L["Threat [%]"] = "仇恨 [%]" L["Threat"] = "仇恨" L["TPS"] = "TPS" L["Toggle Focus"] = "开/关焦点" +L["> Pull Aggro <"] = true -- Warnings L["|cffff0000Error:|r Omen cannot use shake warning if you have turned on nameplates at least once since logging in."] = "|cffff0000错误:|r 如果您在登录后启动过一次姓名版,Omen 将无法使用震动警报功能。" @@ -145,6 +146,10 @@ L["Use Tank Bar color"] = true L["Use a different colored background for the tank's threat bar in Omen"] = true L["Tank Bar Color"] = true L["The background color for your tank's threat bar"] = true +L["Show Pull Aggro Bar"] = true +L["Show a bar for the amount of threat you will need to reach in order to pull aggro."] = true +L["Pull Aggro Bar Color"] = true +L["The background color for your Pull Aggro bar"] = true L["Use Class Colors"] = true L["Use standard class colors for the background color of threat bars"] = true L["Bar BG Color"] = true diff --git a/Localization/zhTW.lua b/Localization/zhTW.lua index 5b69ab5..d339f6d 100644 --- a/Localization/zhTW.lua +++ b/Localization/zhTW.lua @@ -16,6 +16,7 @@ L["Threat [%]"] = "仇恨 [%]" L["Threat"] = "仇恨" L["TPS"] = "TPS" L["Toggle Focus"] = "鎖定Focus" +L["> Pull Aggro <"] = true -- Warnings L["|cffff0000Error:|r Omen cannot use shake warning if you have turned on nameplates at least once since logging in."] = "|cffff0000Error:|r 如果您在登入後啟動過一次單位名牌, Omen將無法使用警報功能" @@ -145,6 +146,10 @@ L["Use Tank Bar color"] = true L["Use a different colored background for the tank's threat bar in Omen"] = true L["Tank Bar Color"] = true L["The background color for your tank's threat bar"] = true +L["Show Pull Aggro Bar"] = true +L["Show a bar for the amount of threat you will need to reach in order to pull aggro."] = true +L["Pull Aggro Bar Color"] = true +L["The background color for your Pull Aggro bar"] = true L["Use Class Colors"] = true L["Use standard class colors for the background color of threat bars"] = true L["Bar BG Color"] = true diff --git a/Omen.lua b/Omen.lua index 38d9c9c..fdf934f 100644 --- a/Omen.lua +++ b/Omen.lua @@ -129,6 +129,8 @@ local defaults = { UseTankBarColor = true, TankBarColor = {r = 1, g = 0, b = 0, a = 1,}, AlwaysShowSelf = true, + ShowAggroBar = true, + AggroBarColor = {r = 1, g = 0, b = 0, a = 1,}, }, ShowWith = { Pet = true, @@ -1100,6 +1102,8 @@ function Omen:UpdatePartyGUIDs() end end end + guidNameLookup["AGGRO"] = L["> Pull Aggro <"] + guidClassLookup["AGGRO"] = "AGGRO" end @@ -1144,6 +1148,7 @@ Returns the colors used in the UI to represent each major threat state. local threatTable -- Format: threatTable[guid] = threatValue local sortTable = {} -- Format: threatTable[i] = guid -- used for sorting by sortfunction() local tankGUID -- Used to store which unit is tanking and hence has 100% threat by definition +local topthreat -- Used to store the top threat value local lastWarn = { -- Used to store information for threat warnings threatpercent = 0, } @@ -1159,6 +1164,7 @@ local function updatethreat(unitid, mobunitid) if guid and not threatTable[guid] then local isTanking, state, scaledPercent, rawPercent, threatValue = UnitDetailedThreatSituation(unitid, mobunitid) threatTable[guid] = threatValue or -1 + if threatValue and threatValue > topthreat then topthreat = threatValue end if isTanking then tankGUID = guid end end end @@ -1187,12 +1193,15 @@ function Omen:FindThreatMob() self.unitID = nil end +local queried = false function Omen:UpdateBars() if not self.Anchor:IsShown() and not db.CollapseHide then return end -- TODO: Put a update throtle on this function - local mobGUID, mobTargetGUID + local dbBar = db.Bar + local mob, mobGUID, mobTargetGUID + topthreat = -1 if testMode then threatTable = newTable() @@ -1200,9 +1209,11 @@ function Omen:UpdateBars() threatTable[i] = i*5000 end tankGUID = 25 + topthreat = 25*5000 + mob = "" self.TitleText:SetText(L["Test Mode"]) else - local mob = self:FindThreatMob() + mob = self:FindThreatMob() if not mob then self:ClearAll() return @@ -1260,6 +1271,18 @@ function Omen:UpdateBars() updatethreat("mouseover", mob) updatethreat("mouseovertarget", mob) end + local tankThreat = tankGUID and threatTable[tankGUID] or mobTargetGUID and threatTable[mobTargetGUID] or topthreat + if dbBar.ShowAggroBar and tankThreat > 0 then + if GetItemInfo(37727) then -- 5 yards (Ruby Acorn - http://www.wowhead.com/?item=37727) + threatTable["AGGRO"] = tankThreat * (IsItemInRange(37727, mob) == 1 and 1.1 or 1.3) + else -- 9 yards compromise + threatTable["AGGRO"] = tankThreat * (CheckInteractDistance(mob, 3) and 1.1 or 1.3) + if not queried and not ItemRefTooltip:IsVisible() then + ItemRefTooltip:SetHyperlink("item:37727") + queried = true -- Only query once per session + end + end + end -- Sort the threatTable local i = 1 @@ -1283,12 +1306,10 @@ function Omen:UpdateBars() local inset = db.Background.BarInset * 2 local w = self.BarList:GetWidth() - inset local h = self.BarList:GetHeight() - inset - local topthreat = threatTable[sortTable[1]] - if topthreat == 0 then topthreat = 1 end - local tankThreat = threatTable[tankGUID or mobTargetGUID or sortTable[1]] - local dbBar = db.Bar + topthreat = threatTable[sortTable[1]] + if topthreat == 0 then topthreat = 1 end -- To avoid 0/0 division local showSelfYet = true - myGUID = UnitGUID("player") + local myGUID = UnitGUID("player") if dbBar.AlwaysShowSelf then -- Check if we're one of the bars to be displayed @@ -1317,7 +1338,7 @@ function Omen:UpdateBars() if i > numBars then break end local guid = sortTable[j] local class = guidClassLookup[guid] - local show = class == nil and dbBar.Classes["*NOTINPARTY*"] or dbBar.Classes[class] + local show = class == nil and dbBar.Classes["*NOTINPARTY*"] or class == "AGGRO" and dbBar.ShowAggroBar or dbBar.Classes[class] if dbBar.AlwaysShowSelf and i == numBars and not showSelfYet and guid ~= myGUID then show = false end @@ -1350,6 +1371,7 @@ function Omen:UpdateBars() -- Update the color of the bar local c = (guid == myGUID and dbBar.UseMyBarColor and dbBar.MyBarColor) or (guid == tankGUID and dbBar.UseTankBarColor and dbBar.TankBarColor) or + (guid == "AGGRO" and dbBar.AggroBarColor) or (dbBar.UseClassColors and (RAID_CLASS_COLORS[class] or (class == "PET" and pet_color))) or dbBar.BarColor bar.texture:SetVertexColor(c.r, c.g, c.b, c.a or 1) @@ -1434,8 +1456,15 @@ end function Omen:UpdateTPS() local numBars = #bars if testMode then - for i = 1, numBars do - bars[i].Text3:SetText(1300 - 50*i) + if db.Bar.ShowAggroBar then + bars[1].Text3:SetText("--") + for i = 2, numBars do + bars[i].Text3:SetText(1300 - 50*(i-1)) + end + else + for i = 1, numBars do + bars[i].Text3:SetText(1300 - 50*i) + end end return end @@ -1468,17 +1497,21 @@ function Omen:UpdateTPS() local bar = bars[i] if not bar:IsShown() then return end local guid = bar.guid - local baseThreat = threatStore[1][guid] - local secondThreat = threatStore[2][guid] - local finalThreat = threatStore[dataSize][guid] - if baseThreat and secondThreat and finalThreat then - -- Calculate TPS - local ratio = (startTime - threatStoreTime[1]) / (threatStoreTime[2] - threatStoreTime[1]) - local startThreat = (secondThreat - baseThreat) * ratio + baseThreat - bar.Text3:SetFormattedText("%d", (finalThreat - startThreat) / TPSWindow / 100) + if guid == "AGGRO" then + bar.Text3:SetText("--") else - -- We don't have enough data for this unit - bar.Text3:SetText("??") + local baseThreat = threatStore[1][guid] + local secondThreat = threatStore[2][guid] + local finalThreat = threatStore[dataSize][guid] + if baseThreat and secondThreat and finalThreat then + -- Calculate TPS + local ratio = (startTime - threatStoreTime[1]) / (threatStoreTime[2] - threatStoreTime[1]) + local startThreat = (secondThreat - baseThreat) * ratio + baseThreat + bar.Text3:SetFormattedText("%d", (finalThreat - startThreat) / TPSWindow / 100) + else + -- We don't have enough data for this unit + bar.Text3:SetText("??") + end end end end @@ -2174,15 +2207,38 @@ local options = { end, disabled = function() return not db.Bar.UseTankBarColor end, }, - UseClassColors = { + ShowAggroBar = { type = "toggle", order = 17, + name = L["Show Pull Aggro Bar"], + desc = L["Show a bar for the amount of threat you will need to reach in order to pull aggro."], + }, + AggroBarColor = { + type = "color", + order = 18, + name = L["Pull Aggro Bar Color"], + desc = L["The background color for your Pull Aggro bar"], + hasAlpha = true, + get = function(info) + local t = db.Bar.AggroBarColor + return t.r, t.g, t.b, t.a + end, + set = function(info, r, g, b, a) + local t = db.Bar.AggroBarColor + t.r, t.g, t.b, t.a = r, g, b, a + Omen:UpdateBars() + end, + disabled = function() return not db.Bar.ShowAggroBar end, + }, + UseClassColors = { + type = "toggle", + order = 20, name = L["Use Class Colors"], desc = L["Use standard class colors for the background color of threat bars"], }, BarColor = { type = "color", - order = 18, + order = 21, name = L["Bar BG Color"], desc = L["The background color for all threat bars"], hasAlpha = true, @@ -2199,7 +2255,7 @@ local options = { }, AlwaysShowSelf = { type = "toggle", - order = 19, + order = 24, name = L["Always Show Self"], desc = L["Always show your threat bar on Omen (ignores class filter settings), showing your bar on the last row if necessary"], },