diff --git a/ElvUI_SLE/libs/oUF_Vengeance/oUF_Vengeance.lua b/ElvUI_SLE/libs/oUF_Vengeance/oUF_Vengeance.lua index 306f4a0..098e865 100644 --- a/ElvUI_SLE/libs/oUF_Vengeance/oUF_Vengeance.lua +++ b/ElvUI_SLE/libs/oUF_Vengeance/oUF_Vengeance.lua @@ -30,18 +30,19 @@ text:SetText(value) end ... - self.Vengeance.OverrideText = VengOverrideText + ElvUF_Player.Vengeance.OverrideText = VengOverrideText others: - self.Vengeance.showInfight [boolean] + ElvUF_Player.Vengeance.showInfight [boolean] if true, the Vengeance bar will be shown infight, even if you haven't got stacks of Vengeance --]] +local E, L, V, P, G = unpack(ElvUI); --Engine +local VG = E:NewModule('Vengeance', 'AceHook-3.0', 'AceEvent-3.0'); local _, ns = ... ---local oUF = oUF or ns.oUF local oUF = ElvUF or oUF local _, class = UnitClass("player") -local vengeance = GetSpellInfo(93098) +local vengeance = GetSpellInfo(93098) or GetSpellInfo(76691) local UnitAura = UnitAura local InCombatLockdown = InCombatLockdown @@ -52,9 +53,25 @@ local tooltiptext = _G[tooltip:GetName().."TextLeft2"] tooltip:SetOwner(UIParent, "ANCHOR_NONE") tooltiptext:SetText("") +function VG:CreateBar() +ElvUF_Player.Vengeance = CreateFrame("StatusBar", nil, RightChatTab) +local Vbar = ElvUF_Player.Vengeance +Vbar:CreateBackdrop("Default") +Vbar:SetFrameLevel(5) +Vbar:Point("TOPLEFT", RightChatTab, "TOPLEFT", 0, 0) --2 lines for determining positioning and size +Vbar:Point("BOTTOMRIGHT", RightChatTab, "BOTTOMRIGHT", 0, 0) +Vbar:SetStatusBarTexture(E["media"].normTex) + +Vbar.Text = Vbar:CreateFontString(nil, 'OVERLAY') +Vbar.Text:FontTemplate(nil, 10) --Font temeplate. will need to change that maybe +Vbar.Text:SetParent(Vbar) + +Vbar.Text:Point("CENTER", Vbar, "CENTER", 0, 0) --May need to change that to be at the left side instead of center +end + local function valueChanged(self, event, unit) if unit ~= "player" then return end - local bar = self.Vengeance + local bar = ElvUF_Player.Vengeance if not bar.isTank then bar:Hide() @@ -67,7 +84,7 @@ local function valueChanged(self, event, unit) tooltip:ClearLines() tooltip:SetUnitBuff("player", name) local value = (tooltiptext:GetText() and tonumber(string.match(tostring(tooltiptext:GetText()), "%d+"))) or -1 - + if value > 0 then if value > bar.max then value = bar.max end if value == bar.value then return end @@ -76,14 +93,22 @@ local function valueChanged(self, event, unit) bar:SetValue(value) bar.value = value bar:Show() + local percent = (value/bar.max)*100 if bar.Text then if bar.OverrideText then - bar:OverrideText(value) + bar:OverrideText(self, value) else - bar.Text:SetText(value) + bar.Text:SetText(string.format(vengeance..": %s/%s (%.2f%%)",value,bar.max,percent)) end end + if (percent <= 25) then + bar:SetStatusBarColor(1, 75 / 255, 75 / 255, 0.5, .8) + elseif (percent > 25 and percent < 60) then + bar:SetStatusBarColor(1, 180 / 255, 0, .8) + else + bar:SetStatusBarColor(30 / 255, 1, 30 / 255, .8) + end end elseif bar.showInfight and InCombatLockdown() then bar:Show() @@ -98,7 +123,7 @@ end local function maxChanged(self, event, unit) if unit ~= "player" then return end - local bar = self.Vengeance + local bar = ElvUF_Player.Vengeance if not bar.isTank then bar:Hide() @@ -107,10 +132,14 @@ local function maxChanged(self, event, unit) local health = UnitHealthMax("player") local _, stamina = UnitStat("player", 3) + local baseStam = min(20, stamina) + local moreStam = stamina - baseStam + local hpFromStam = (baseStam + (moreStam*UnitHPPerStamina("player")))*GetUnitMaxHealthModifier("player") + local baseHP = health - hpFromStam if not health or not stamina then return end - bar.max = 0.1 * (health - 15 * stamina) + stamina + bar.max = stamina + floor(baseHP/10) bar:SetMinMaxValues(0, bar.max) valueChanged(self, event, unit) @@ -118,7 +147,7 @@ end local function isTank(self, event) local masteryIndex = GetPrimaryTalentTree() - local bar = self.Vengeance + local bar = ElvUF_Player.Vengeance if masteryIndex then if class == "DRUID" and masteryIndex == 2 then @@ -126,7 +155,6 @@ local function isTank(self, event) elseif (class == "DEATH KNIGHT" or class == "DEATHKNIGHT") and masteryIndex == 1 then bar.isTank = true elseif class == "PALADIN" and masteryIndex == 2 then - print("Checked") bar.isTank = true elseif class == "WARRIOR" and masteryIndex == 3 then bar.isTank = true @@ -138,25 +166,22 @@ local function isTank(self, event) bar.isTank = false bar:Hide() end - print("IsTank") maxChanged(self, event, "player") end local function Enable(self, unit) - local bar = self.Vengeance + local bar = ElvUF_Player.Vengeance if bar and unit == "player" then bar.max = 0 bar.value = 0 - - self:RegisterEvent("UNIT_AURA", valueChanged) + self:RegisterEvent("UNIT_AURA", maxChanged) self:RegisterEvent("UNIT_MAXHEALTH", maxChanged) self:RegisterEvent("UNIT_LEVEL", maxChanged) self:RegisterEvent("PLAYER_REGEN_DISABLED", isTank) - bar:Hide() return true @@ -164,7 +189,7 @@ local function Enable(self, unit) end local function Disable(self) - local bar = self.Vengeance + local bar = ElvUF_Player.Vengeance if bar then self:UnregisterEvent("UNIT_AURA", valueChanged) @@ -176,6 +201,13 @@ local function Disable(self) end end +Enable(ElvUF_Player, "player") + oUF:AddElement("Vengeance", nil, Enable, Disable) -for i, frame in ipairs(oUF.objects) do Enable(frame) end \ No newline at end of file +function VG:Initialize() + VG:CreateBar() + Enable(ElvUF_Player, "player") +end + +E:RegisterModule(VG:GetName()) \ No newline at end of file diff --git a/ElvUI_SLE/libs/oUF_Vengeance/oUF_Vengeance.toc b/ElvUI_SLE/libs/oUF_Vengeance/oUF_Vengeance.toc index 24e0937..7a04cec 100644 --- a/ElvUI_SLE/libs/oUF_Vengeance/oUF_Vengeance.toc +++ b/ElvUI_SLE/libs/oUF_Vengeance/oUF_Vengeance.toc @@ -3,6 +3,6 @@ ## Version: 40200.5 ## Title: oUF Vengeance ## Notes: Vengeance plug-in for oUF -## RequiredDeps: oUF +## RequiredDeps: ElvUI_SLE oUF_Vengeance.lua \ No newline at end of file diff --git a/ElvUI_SLE/modules/load_modules.xml b/ElvUI_SLE/modules/load_modules.xml index d74f08d..8afe6be 100644 --- a/ElvUI_SLE/modules/load_modules.xml +++ b/ElvUI_SLE/modules/load_modules.xml @@ -12,5 +12,4 @@ <Include file='skins\load_skins.xml'/> <Include file='uibuttons\load_uibuttons.xml'/> <Include file='unitframes\load_unitframes.xml'/> - <Include file='vengeance\load_vengeance.xml'/> </Ui> \ No newline at end of file diff --git a/ElvUI_SLE/modules/vengeance/load_vengeance.xml b/ElvUI_SLE/modules/vengeance/load_vengeance.xml deleted file mode 100644 index e10f79c..0000000 --- a/ElvUI_SLE/modules/vengeance/load_vengeance.xml +++ /dev/null @@ -1,4 +0,0 @@ -<Ui xmlns="http://www.blizzard.com/wow/ui/"> - <Script file='vengeance.lua'/> - <Script file='options.lua'/> -</Ui> \ No newline at end of file diff --git a/ElvUI_SLE/modules/vengeance/options.lua b/ElvUI_SLE/modules/vengeance/options.lua deleted file mode 100644 index 884b9c1..0000000 --- a/ElvUI_SLE/modules/vengeance/options.lua +++ /dev/null @@ -1 +0,0 @@ -local E, L, V, P, G = unpack(ElvUI); --Inport: Engine, Locales, ProfileDB, GlobalDB diff --git a/ElvUI_SLE/modules/vengeance/vengeance.lua b/ElvUI_SLE/modules/vengeance/vengeance.lua deleted file mode 100644 index 56f5290..0000000 --- a/ElvUI_SLE/modules/vengeance/vengeance.lua +++ /dev/null @@ -1,139 +0,0 @@ -local E, L, V, P, G = unpack(ElvUI); --Engine -local VG = E:NewModule('Vengeance', 'AceHook-3.0', 'AceEvent-3.0'); -local UF = E:GetModule('UnitFrames'); -print("Vengeance loaded") - -local Vbar -local Vstam -local VaddHP -local Vmax -local V_ScanTip = CreateFrame("GameTooltip","VengeanceModuleScanTip",nil,"GameTooltipTemplate") -V_ScanTip:SetOwner(UIParent, "ANCHOR_NONE") - -local function getTooltipText(...) --This stuff is for knowing how much bonus AP we actually have. It's called from aura event function - local text = "" - for i=1,select("#",...) do - local rgn = select(i,...) - if rgn and rgn:GetObjectType() == "FontString" then - text = text .. (rgn:GetText() or "") - end - end - return text == "" and "0" or text -end - -function VG:CreateBar() - Vbar = ElvUF_Player.Vengeance --This is actually from the plugin. idk how to put other functionings from there to the code O_o - Vbar = CreateFrame("StatusBar", nil, ElvUF_Player) - Vbar:CreateBackdrop("Default") - Vbar:Point("TOPLEFT", ElvUF_Player.Power, "BOTTOMLEFT", 0, -4) --2 lines for determining positioning and size - Vbar:Point("BOTTOMRIGHT", ElvUF_Player.Power, "BOTTOMRIGHT", 0, -12) --The bar is docked under power bar for now - Vbar:SetStatusBarTexture(E["media"].normTex) - --Vbar:SetStatusBarColor(1,0,0) --No need atm - - Vbar.value = Vbar:CreateFontString(nil, 'OVERLAY') - Vbar.value:FontTemplate(nil, 10) --Font temeplate. will need to change that to use UF font and size - Vbar.value:SetParent(Vbar) - - Vbar.value:Point("CENTER", Vbar, "CENTER", 0, 0) --May need to change that to be at the keft side instead of center - - --Setting text on initial load as i didn't add a function for player_entering_world event - V_ScanTip:ClearLines() - V_ScanTip:SetUnitBuff("player", GetSpellInfo(93098) or GetSpellInfo(76691)) - local tipText = getTooltipText(V_ScanTip:GetRegions()) - local vengval,percentmax,downtime - vengval = tonumber(string.match(tipText,"%d+")) - percentmax = (vengval/Vmax)*100 - Vbar:SetMinMaxValues(0,Vmax) - Vbar:SetValue(vengval) - Vbar.value:SetText(string.format("%s/%s (%.2f%%)",vengval,Vmax,percentmax)) -end - -function VG:setBaseHPadd() --For knowing base HP bonus to AP - local baseHP - local level = UnitLevel("player"); - - local stat, effectiveStat, posBuff, negBuff = UnitStat("player", 3); - local baseStam = min(20, effectiveStat); - local moreStam = effectiveStat - baseStam; - local healthPerStam = UnitHPPerStamina("player") - local hpFromStam = (baseStam + (moreStam*healthPerStam))*GetUnitMaxHealthModifier("player") - baseHP = UnitHealthMax("player") - hpFromStam - - if baseHP then - VaddHP = floor(baseHP/10) - else - DEFAULT_CHAT_FRAME:AddMessage("ERROR - Unable to calculate baseHP") - end -end - -function VG:SetMax() --For knowing our current maximum AP bonus - Vstam = UnitStat("player", 3); - print("Stamina: "..Vstam) - Vmax = VaddHP + Vstam - print("Maximun Vengeance: "..Vmax) -end - -function VG:UNIT_AURA(...) --Updating on aura event. Setting the values and colors when we gain or loose vengeance bonuses. - local event, unit = ...; - if unit == "player" then - local n,_,_,_,_,_,_,_,_,_,id = UnitAura("player", (GetSpellInfo(93098) or GetSpellInfo(76691))); - if n then - V_ScanTip:ClearLines() - V_ScanTip:SetUnitBuff("player",n) - local tipText = getTooltipText(V_ScanTip:GetRegions()) - local vengval,percentmax,downtime - vengval = tonumber(string.match(tipText,"%d+")) - percentmax = (vengval/Vmax)*100 - print("Percent of vengeance:"..percentmax) - Vbar:SetMinMaxValues(0,Vmax) - Vbar:SetValue(vengval) - Vbar.value:SetText(string.format("%s/%s (%.2f%%)",vengval,Vmax,percentmax)) - if (percentmax <= 25) then - Vbar:SetStatusBarColor(1, 75 / 255, 75 / 255, 0.5, .8) - elseif (percentmax > 25 and percentmax < 60) then - Vbar:SetStatusBarColor(1, 180 / 255, 0, .8) - else - Vbar:SetStatusBarColor(30 / 255, 1, 30 / 255, .8) - end - else - VG:SetMax() - Vbar:SetMinMaxValues(0,Vmax) - Vbar:SetValue(0) - Vbar.value:SetText("0/"..Vmax.." (0.00%)") - end - end -end - -function VG:UNIT_STATS(...) --Updating when our stats are changed - local event, unit = ...; - if unit == "player" then - VG:SetMax() - Vbar:SetMinMaxValues(0,Vmax) - local vengval = Vbar:GetValue() - if vengval and (vengval > 0) then - local percentmax = min(((vengval/Vmax)*100),100) - Vbar.value:SetText(string.format("%s/%s (%.2f%%)",vengval,Vgmax,percentmax)) - else - Vbar.value:SetText("0/"..Vmax.." (0.00%)") - end - end -end - -function VG:Initialize() - VG:setBaseHPadd() - VG:SetMax() - VG:CreateBar() - - --Commented lines are for more events that can influence the bonus - --self:RegisterEvent("ADDON_LOADED") - --self:RegisterEvent("PLAYER_LOGIN") - --self:RegisterEvent("PLAYER_DEAD") - --self:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED") - self:RegisterEvent("UNIT_AURA") - self:RegisterEvent("UNIT_STATS") - --self:RegisterEvent("UNIT_LEVEL") - --self:RegisterEvent("PLAYER_REGEN_ENABLED") - --self:RegisterEvent("PLAYER_REGEN_DISABLED") -end - -E:RegisterModule(VG:GetName()) \ No newline at end of file