diff --git a/SVUI_!Core/system/mail.lua b/SVUI_!Core/system/mail.lua index c816521..4665d78 100644 --- a/SVUI_!Core/system/mail.lua +++ b/SVUI_!Core/system/mail.lua @@ -55,232 +55,263 @@ local GetCVarBool = _G.GetCVarBool; local GameTooltip = _G.GameTooltip; local StaticPopup_Hide = _G.StaticPopup_Hide; local ERR_NOT_IN_COMBAT = _G.ERR_NOT_IN_COMBAT; -local InboxFrame_OnClick = _G.InboxFrame_OnClick; +local InboxFrame_OnClick = _G.InboxFrame_OnClick; local SV = select(2, ...); local L = SV.L; -local MailMinion = _G["SVUI_MailMinion"]; ---[[ -########################################################## +local MailMinion = _G["SVUI_MailMinion"]; +local MailMinionGetMail = _G["SVUI_MailMinionGetMail"]; +local MailMinionGetGold = _G["SVUI_MailMinionGetGold"]; +local MailMinionDelete = _G["SVUI_MailMinionDelete"]; +--[[ +########################################################## LOCAL VARS ########################################################## ]]-- -local takingOnlyCash = false; -local deletedelay = 0.5; -local mailElapsed = 0; -local GetAllMail, GetAllMailCash, OpenMailItem, WaitForMail, DeleteAllMail, DeleteMailItem, WaitForDelete, StopOpeningMail; -local lastopened, lastdeleted, needsToWait, waitToDelete, total_cash, baseInboxFrame_OnClick; ---[[ -########################################################## +local mailElapsed, deleteElapsed, deletedelay = 0, 0, 0.5; +local GetAllMail, GetAllMailCash, WaitForMail, DeleteAllMail, DeleteMailItem, WaitForDelete; +local takingOnlyCash, lastopened, lastdeleted, needsToWait, waitToDelete, total_cash, baseInboxFrame_OnClick; +local dummy = function() return end; +--[[ +########################################################## LOCAL FUNCTIONS ########################################################## ]]-- -function GetAllMail() - if(GetInboxNumItems() == 0) then return end - MailMinion.GetMail:SetScript("OnClick", nil) - MailMinion.GetGold:SetScript("OnClick", nil) - MailMinion.Delete:SetScript("OnClick", nil) - baseInboxFrame_OnClick = InboxFrame_OnClick; - InboxFrame_OnClick = SV.fubar - MailMinion.GetMail:RegisterEvent("UI_ERROR_MESSAGE") - OpenMailItem(GetInboxNumItems()) -end - -function GetAllMailCash() - takingOnlyCash = true; - GetAllMail() -end - -function OpenMailItem(mail) - if not InboxFrame:IsVisible()then return StopOpeningMail("Mailbox Minion Needs a Mailbox!")end - if mail==0 then - MiniMapMailFrame:Hide() - return StopOpeningMail("Finished getting your mail!") - end - local _, _, _, _, money, CODAmount, _, itemCount = GetInboxHeaderInfo(mail) - if not takingOnlyCash then - if money > 0 or itemCount and itemCount > 0 and CODAmount <= 0 then - AutoLootMailItem(mail) - needsToWait=true - end - elseif money > 0 then - TakeInboxMoney(mail) - needsToWait=true; - if total_cash then total_cash = total_cash - money end - end - local numMail = GetInboxNumItems() - if itemCount and itemCount > 0 or numMail > 1 and mail <= numMail then - lastopened = mail; - MailMinion.GetMail:SetScript("OnUpdate",WaitForMail) - else - MiniMapMailFrame:Hide() - StopOpeningMail() - end +local function FancifyMoneys(cash) + if cash > 10000 then + return("%d|cffffd700g|r%d|cffc7c7cfs|r%d|cffeda55fc|r"):format((cash / 10000), ((cash / 100) % 100), (cash % 100)) + elseif cash > 100 then + return("%d|cffc7c7cfs|r%d|cffeda55fc|r"):format(((cash / 100) % 100), (cash % 100)) + else + return("%d|cffeda55fc|r"):format(cash%100) + end end -function WaitForMail(_, elapsed) +local MailMinionOpening_OnUpdate = function(self, elapsed) mailElapsed = mailElapsed + elapsed; if not needsToWait or mailElapsed > deletedelay then - if not InboxFrame:IsVisible() then return StopOpeningMail("The Mailbox Minion Needs a Mailbox!") end + if not InboxFrame:IsVisible() then return StopMailMinion("The Mailbox Minion Needs a Mailbox!") end mailElapsed = 0; - needsToWait = false; - MailMinion.GetMail:SetScript("OnUpdate", nil) + needsToWait = nil; + + MailMinionGetMail:SetScript("OnUpdate", nil) + local _, _, _, _, money, CODAmount, _, itemCount = GetInboxHeaderInfo(lastopened) - if money > 0 or not takingOnlyCash and CODAmount <= 0 and itemCount and itemCount > 0 then - OpenMailItem(lastopened) + local return_index; + if((money and money > 0) or ((not takingOnlyCash) and (not (CODAmount > 0)) and (itemCount and itemCount > 0))) then + return_index = lastopened else - OpenMailItem(lastopened - 1) - end - end -end - -function DeleteAllMail() - if(GetInboxNumItems() == 0) then return end - MailMinion.GetMail:SetScript("OnClick", nil) - MailMinion.GetGold:SetScript("OnClick", nil) - MailMinion.Delete:SetScript("OnClick", nil) - baseInboxFrame_OnClick = InboxFrame_OnClick; - InboxFrame_OnClick = SV.fubar - DeleteMailItem(GetInboxNumItems()) -end + return_index = lastopened - 1 + end -function DeleteMailItem(mail) - if not InboxFrame:IsVisible()then return StopOpeningMail("Mailbox Minion Needs a Mailbox!")end - if mail==0 then - MiniMapMailFrame:Hide() - return StopOpeningMail("Finished deleting your mail!") - end - local _, _, _, _, money, CODAmount, _, itemCount = GetInboxHeaderInfo(mail) - if(((not money) or (money and money == 0)) or ((not itemCount) or (itemCount and itemCount > 0))) then - DeleteInboxItem(mail) - waitToDelete = true + StartMailMinion(return_index) end - local numMail = GetInboxNumItems() - if(numMail > 1 and waitToDelete) then - lastdeleted = mail; - MailMinion.Delete:SetScript("OnUpdate", WaitForDelete) - else - MiniMapMailFrame:Hide() - StopOpeningMail() - end -end +end + +local MailMinionDeleting_OnUpdate = function(self, elapsed) + deleteElapsed = deleteElapsed + elapsed; + if not waitToDelete or deleteElapsed > deletedelay then + if not InboxFrame:IsVisible() then return StopMailMinion("The Mailbox Minion Needs a Mailbox!") end + deleteElapsed = 0; + waitToDelete = nil; + + MailMinionDelete:SetScript("OnUpdate", nil) -function WaitForDelete(_, elapsed) - mailElapsed = mailElapsed + elapsed; - if not waitToDelete or mailElapsed > deletedelay then - if not InboxFrame:IsVisible() then return StopOpeningMail("The Mailbox Minion Needs a Mailbox!") end - mailElapsed = 0; - waitToDelete = false; - MailMinion.Delete:SetScript("OnUpdate", nil) local _, _, _, _, money, CODAmount, _, itemCount = GetInboxHeaderInfo(lastdeleted) - if(((not money) or (money and money == 0)) or ((not itemCount) or (itemCount and itemCount > 0))) then - DeleteMailItem(lastdeleted) + local return_index; + if(((not money) or (money and money == 0)) or ((not itemCount) or (itemCount and itemCount == 0))) then + return_index = lastopened else - DeleteMailItem(lastdeleted - 1) + return_index = lastopened - 1 end - end + + StartMailMinion(return_index, true) + end end -function StopOpeningMail(msg, ...) - MailMinion.GetMail:SetScript("OnUpdate", nil) - MailMinion.Delete:SetScript("OnUpdate", nil) - MailMinion.GetMail:SetScript("OnClick", GetAllMail) - MailMinion.Delete:SetScript("OnClick", DeleteAllMail) - MailMinion.GetGold:SetScript("OnClick", GetAllMailCash) - if baseInboxFrame_OnClick then - InboxFrame_OnClick = baseInboxFrame_OnClick - end - MailMinion.GetMail:UnregisterEvent("UI_ERROR_MESSAGE") - takingOnlyCash = false; +local function StopMailMinion(mail_message) + MailMinionGetMail:SetScript("OnUpdate", nil) + MailMinionDelete:SetScript("OnUpdate", nil) + + MailMinionGetMail:Enable() + MailMinionDelete:Enable() + MailMinionGetGold:Enable() + + if(baseInboxFrame_OnClick) then + InboxFrame_OnClick = baseInboxFrame_OnClick; + end + + MailMinionGetMail:UnregisterEvent("UI_ERROR_MESSAGE"); + + takingOnlyCash = nil; total_cash = nil; - needsToWait = false; - waitToDelete = false; - if msg then - SV:AddonMessage(msg) - end + needsToWait = nil; + waitToDelete = nil; + lastopened = nil; + lastdeleted = nil; + + mailElapsed = 0; + deleteElapsed = 0; + + if(mail_message) then + SV:AddonMessage(mail_message) + end end -local function FancifyMoneys(cash) - if cash > 10000 then - return("%d|cffffd700g|r%d|cffc7c7cfs|r%d|cffeda55fc|r"):format((cash / 10000), ((cash / 100) % 100), (cash % 100)) - elseif cash > 100 then - return("%d|cffc7c7cfs|r%d|cffeda55fc|r"):format(((cash / 100) % 100), (cash % 100)) +local function StartMailMinion(mail_index, is_deleting) + if(not InboxFrame:IsVisible()) then + return StopMailMinion("Mailbox Minion Needs a Mailbox!") + elseif(mail_index == 0) then + MiniMapMailFrame:Hide() + local mail_message = is_deleting and "Finished deleting your mail!" or "Finished getting your mail!" + return StopMailMinion(mail_message) + end + + local _, _, _, _, money, CODAmount, _, itemCount = GetInboxHeaderInfo(mail_index) + + if(not is_deleting) then + if((not takingOnlyCash) and ((money and money > 0) or (itemCount and itemCount > 0)) and (not (CODAmount > 0))) then + AutoLootMailItem(mail_index) + needsToWait = true; + elseif(money and money > 0) then + TakeInboxMoney(mail_index) + needsToWait = true; + if(total_cash) then + total_cash = total_cash - money + end + end + + local numMail = GetInboxNumItems() + if((itemCount and itemCount > 0) or ((numMail > 1) and (not (mail_index > numMail)))) then + lastopened = mail_index; + MailMinionGetMail:SetScript("OnUpdate", MailMinionOpening_OnUpdate) + else + MiniMapMailFrame:Hide() + StopMailMinion() + end else - return("%d|cffeda55fc|r"):format(cash%100) - end + if(((not money) or (money and money == 0)) and ((not itemCount) or (itemCount and itemCount == 0))) then + DeleteInboxItem(mail_index) + waitToDelete = true; + end + + local numMail = GetInboxNumItems() + if((numMail > 1) and (not (mail_index > numMail))) then + lastdeleted = mail_index; + MailMinionDelete:SetScript("OnUpdate", MailMinionDeleting_OnUpdate) + else + MiniMapMailFrame:Hide() + StopMailMinion() + end + end +end +--[[ +########################################################## +BUTTON SPECIFIC HANDLERS +########################################################## +]]-- +function MailMinionGetMail:ClickHandler() + MailMinionGetMail:RegisterEvent("UI_ERROR_MESSAGE") + StartMailMinion(GetInboxNumItems()) end -local MailButton_OnEnter = function(self) +function MailMinionGetGold:ClickHandler() + takingOnlyCash = true; + StartMailMinion(GetInboxNumItems()) +end + +function MailMinionDelete:ClickHandler() + StartMailMinion(GetInboxNumItems(), true) +end +--[[ +########################################################## +SCRIPT HANDLERS +########################################################## +]]-- +local GoldMinionButton_OnEnter = function(self) + if(not total_cash) then + total_cash = 0; + for i = 0, GetInboxNumItems() do + total_cash = total_cash + select(5, GetInboxHeaderInfo(i)) + end + end + GameTooltip:SetOwner(self, "ANCHOR_RIGHT") + GameTooltip:AddLine(FancifyMoneys(total_cash), 1, 1, 1) + GameTooltip:Show() +end + +local MailMinionButton_OnEnter = function(self) GameTooltip:SetOwner(self, "ANCHOR_RIGHT") GameTooltip:AddLine(("%d messages"):format(GetInboxNumItems()), 1, 1, 1) GameTooltip:Show() end -local MailButton_OnLeave = function(self) +local MailMinionButton_OnLeave = function(self) GameTooltip:Hide() end -local MailButton_OnEvent = function(self, event, subEvent) - if(event == "UI_ERROR_MESSAGE") then - if((subEvent == ERR_INV_FULL) or (subEvent == ERR_ITEM_MAX_COUNT)) then - StopOpeningMail("Your bags are too full!") - end - end +local MailMinionButton_OnClick = function(self, button) + if(GetInboxNumItems() == 0) then return end + + MailMinionGetMail:Disable() + MailMinionGetGold:Disable() + MailMinionDelete:Disable() + + baseInboxFrame_OnClick = InboxFrame_OnClick; + InboxFrame_OnClick = dummy; + + self:ClickHandler(button); end -local GoldButton_OnEnter = function(self) - if(not total_cash) then - total_cash = 0; - for i = 0, GetInboxNumItems() do - total_cash = total_cash + select(5, GetInboxHeaderInfo(i)) - end - end - GameTooltip:SetOwner(self, "ANCHOR_RIGHT") - GameTooltip:AddLine(FancifyMoneys(total_cash), 1, 1, 1) - GameTooltip:Show() +local MailMinionButton_OnEvent = function(self, event, subEvent) + if(event == "UI_ERROR_MESSAGE") then + if((subEvent == ERR_INV_FULL) or (subEvent == ERR_ITEM_MAX_COUNT)) then + StopMailMinion("Your bags are too full!") + end + end end ---[[ -########################################################## +--[[ +########################################################## MAIL HELPER ########################################################## ]]-- function SV:ToggleMailMinions() - if not SV.db.Extras.mailOpener then + if not SV.db.Extras.mailOpener then MailMinion:Hide() else MailMinion:Show() - end -end ---[[ -########################################################## + end +end +--[[ +########################################################## LOAD BY TRIGGER ########################################################## ]]-- local function LoadMailMinions() - if IsAddOnLoaded("Postal") then + if IsAddOnLoaded("Postal") then SV.db.Extras.mailOpener = false else MailMinion:Show() - MailMinion.GetMail:SetStyle("Button") - MailMinion.GetMail:SetScript("OnClick",GetAllMail) - MailMinion.GetMail:SetScript("OnEnter", MailButton_OnEnter) - MailMinion.GetMail:SetScript("OnLeave", MailButton_OnLeave) - MailMinion.GetMail:SetScript("OnEvent", MailButton_OnEvent) - - MailMinion.GetGold:SetStyle("Button") - MailMinion.GetGold:SetScript("OnClick", GetAllMailCash) - MailMinion.GetGold:SetScript("OnEnter", GoldButton_OnEnter) - MailMinion.GetGold:SetScript("OnLeave", MailButton_OnLeave) - - MailMinion.Delete:SetStyle("Button", 1, 1, "red") - MailMinion.Delete:SetScript("OnClick", DeleteAllMail) - MailMinion.Delete:SetScript("OnEnter", MailButton_OnEnter) - MailMinion.Delete:SetScript("OnLeave", MailButton_OnLeave) + MailMinionGetMail:SetStyle("Button") + MailMinionGetMail:SetScript("OnClick", MailMinionButton_OnClick) + MailMinionGetMail:SetScript("OnEnter", MailMinionButton_OnEnter) + MailMinionGetMail:SetScript("OnLeave", MailMinionButton_OnLeave) + MailMinionGetMail:SetScript("OnEvent", MailMinionButton_OnEvent) + + MailMinionGetGold:SetStyle("Button") + MailMinionGetGold:SetScript("OnClick", MailMinionButton_OnClick) + MailMinionGetGold:SetScript("OnEnter", GoldMinionButton_OnEnter) + MailMinionGetGold:SetScript("OnLeave", MailMinionButton_OnLeave) + + MailMinionDelete:SetStyle("Button", 1, 1, "red") + MailMinionDelete:SetScript("OnClick", MailMinionButton_OnClick) + MailMinionDelete:SetScript("OnEnter", MailMinionButton_OnEnter) + MailMinionDelete:SetScript("OnLeave", MailMinionButton_OnLeave) SV:ToggleMailMinions() end end -SV.Events:On("CORE_INITIALIZED", LoadMailMinions); \ No newline at end of file +SV.Events:On("CORE_INITIALIZED", LoadMailMinions); diff --git a/SVUI_UnitFrames/elements/essentials.lua b/SVUI_UnitFrames/elements/essentials.lua index 26e3641..5d8baa9 100644 --- a/SVUI_UnitFrames/elements/essentials.lua +++ b/SVUI_UnitFrames/elements/essentials.lua @@ -1,7 +1,7 @@ --[[ ########################################################## S V U I By: Munglunch -########################################################## +########################################################## LOCALIZED LUA FUNCTIONS ########################################################## ]]-- @@ -53,8 +53,8 @@ local UnitThreatSituation = _G.UnitThreatSituation; local UnitAffectingCombat = _G.UnitAffectingCombat; local GetThreatStatusColor = _G.GetThreatStatusColor; local UnitAlternatePowerInfo = _G.UnitAlternatePowerInfo; ---[[ -########################################################## +--[[ +########################################################## GET ADDON DATA ########################################################## ]]-- @@ -63,24 +63,24 @@ local L = SV.L; local LSM = _G.LibStub("LibSharedMedia-3.0") local MOD = SV.UnitFrames -if(not MOD) then return end +if(not MOD) then return end local oUF_SVUI = MOD.oUF assert(oUF_SVUI, "SVUI UnitFrames: unable to locate oUF.") ---[[ -########################################################## +--[[ +########################################################## LOCALS ########################################################## ]]-- local FontMapping = { - ["player"] = "SVUI_Font_Unit", - ["target"] = "SVUI_Font_Unit", + ["player"] = "SVUI_Font_Unit", + ["target"] = "SVUI_Font_Unit", ["targettarget"] = "SVUI_Font_Unit_Small", - ["pet"] = "SVUI_Font_Unit", + ["pet"] = "SVUI_Font_Unit", ["pettarget"] = "SVUI_Font_Unit_Small", - ["focus"] = "SVUI_Font_Unit", + ["focus"] = "SVUI_Font_Unit", ["focustarget"] = "SVUI_Font_Unit_Small", - ["boss"] = "SVUI_Font_Unit", + ["boss"] = "SVUI_Font_Unit", ["arena"] = "SVUI_Font_Unit", ["party"] = "SVUI_Font_Unit_Small", ["raid"] = "SVUI_Font_Unit_Small", @@ -89,9 +89,9 @@ local FontMapping = { ["assist"] = "SVUI_Font_Unit_Small", }; local ThreatMapping = { - ["player"] = true, - ["pet"] = true, - ["focus"] = true, + ["player"] = true, + ["pet"] = true, + ["focus"] = true, ["party"] = true, ["raid"] = true, ["raidpet"] = true, @@ -121,8 +121,8 @@ local ELITE_RIGHT = [[Interface\Addons\SVUI_UnitFrames\assets\Border\ELITE-RIGHT local STUNNED_ANIM = [[Interface\Addons\SVUI_UnitFrames\assets\UNIT-STUNNED]]; local AGGRO_TEXTURE = [[Interface\AddOns\SVUI_UnitFrames\assets\UNIT-AGGRO]]; local token = {[0] = "MANA", [1] = "RAGE", [2] = "FOCUS", [3] = "ENERGY", [6] = "RUNIC_POWER"} ---[[ -########################################################## +--[[ +########################################################## ACTIONPANEL ########################################################## ]]-- @@ -164,7 +164,7 @@ local UpdatePlayerThreat = function(self, event, unit) end end threat:Hide() - end + end end local function CreateThreat(frame, unit) @@ -175,12 +175,12 @@ local function CreateThreat(frame, unit) threat:SetBackdrop({ edgeFile = SV.media.border.shadow, edgeSize = 3, - insets = + insets = { - left = 2, - right = 2, - top = 2, - bottom = 2, + left = 2, + right = 2, + top = 2, + bottom = 2, }, }); threat:SetBackdropBorderColor(0,0,0,0.5) @@ -196,7 +196,7 @@ local function CreateThreat(frame, unit) aggro.texture:SetTexture(AGGRO_TEXTURE) SV.Animate:Pulse(aggro) aggro:SetScript("OnShow", function(this) - this.anim:Play() + this.anim:Play() end); aggro:Hide(); frame.Aggro = aggro @@ -206,7 +206,7 @@ local function CreateThreat(frame, unit) threat.Override = UpdateThreat end - return threat + return threat end local function CreateNameText(frame, unitName) @@ -353,19 +353,21 @@ function MOD:SetActionPanel(frame, unit, noHealthText, noPowerText, noMiscText) stunned:SetTexture(STUNNED_ANIM) stunned:SetBlendMode("ADD") SV.Animate:Sprite4(stunned, 0.12, false, true) - stunned:Hide() frame.LossOfControl.stunned = stunned - LossOfControlFrame:HookScript("OnShow", function() - if(_G["SVUI_Player"] and _G["SVUI_Player"].LossOfControl) then - _G["SVUI_Player"].LossOfControl:Show() - end - end) - LossOfControlFrame:HookScript("OnHide", function() - if(_G["SVUI_Player"] and _G["SVUI_Player"].LossOfControl) then - _G["SVUI_Player"].LossOfControl:Hide() - end - end) + --stunned:Hide() + -- LossOfControlFrame:HookScript("OnShow", function() + -- if(_G["SVUI_Player"] and _G["SVUI_Player"].LossOfControl) then + -- _G["SVUI_Player"].LossOfControl:Show() + -- end + -- end) + -- LossOfControlFrame:HookScript("OnHide", function() + -- if(_G["SVUI_Player"] and _G["SVUI_Player"].LossOfControl) then + -- _G["SVUI_Player"].LossOfControl:Hide() + -- end + -- end) + + frame.LossOfControl:SetParent(LossOfControlFrame) end elseif(unit and (unit == 'pet' or unit == 'targettarget')) then local info = CreateFrame("Frame", nil, frame) @@ -385,7 +387,7 @@ function MOD:SetActionPanel(frame, unit, noHealthText, noPowerText, noMiscText) else frame.TextGrip = CreateFrame("Frame", nil, frame) frame.TextGrip:SetFrameStrata("LOW") - frame.TextGrip:SetFrameLevel(frame:GetFrameLevel() + 1) + frame.TextGrip:SetFrameLevel(20) frame.TextGrip:ModPoint("TOPLEFT", frame.ActionPanel, "TOPLEFT", 2, -2) frame.TextGrip:ModPoint("BOTTOMRIGHT", frame.ActionPanel, "BOTTOMRIGHT", -2, 2) end @@ -448,8 +450,8 @@ function MOD:SetActionPanel(frame, unit, noHealthText, noPowerText, noMiscText) frame.Threat = CreateThreat(frame, unit) end end ---[[ -########################################################## +--[[ +########################################################## HEALTH ANIMATIONS ########################################################## ]]-- @@ -457,7 +459,7 @@ local Anim_OnUpdate = function(self) local parent = self.parent local coord = self._coords; parent:SetTexCoord(coord[1],coord[2],coord[3],coord[4]) -end +end local Anim_OnPlay = function(self) local parent = self.parent @@ -465,7 +467,7 @@ local Anim_OnPlay = function(self) if not parent:IsShown() then parent:Show() end -end +end local Anim_OnStop = function(self) local parent = self.parent @@ -473,7 +475,7 @@ local Anim_OnStop = function(self) if parent:IsShown() then parent:Hide() end -end +end local function SetNewAnimation(frame, animType, parent) local anim = frame:CreateAnimation(animType) @@ -506,31 +508,31 @@ local function SetAnim(frame, parent) frame.anim[3]:SetDuration(speed) frame.anim[3]._coords = {0,0.5,0.25,0.5} frame.anim[3]:SetScript("OnUpdate", Anim_OnUpdate) - + frame.anim[4] = SetNewAnimation(frame.anim, "Translation", frame) frame.anim[4]:SetOrder(4) frame.anim[4]:SetDuration(speed) frame.anim[4]._coords = {0.5,1,0.25,0.5} frame.anim[4]:SetScript("OnUpdate", Anim_OnUpdate) - + frame.anim[5] = SetNewAnimation(frame.anim, "Translation", frame) frame.anim[5]:SetOrder(5) frame.anim[5]:SetDuration(speed) frame.anim[5]._coords = {0,0.5,0.5,0.75} frame.anim[5]:SetScript("OnUpdate", Anim_OnUpdate) - + frame.anim[6] = SetNewAnimation(frame.anim, "Translation", frame) frame.anim[6]:SetOrder(6) frame.anim[6]:SetDuration(speed) frame.anim[6]._coords = {0.5,1,0.5,0.75} frame.anim[6]:SetScript("OnUpdate", Anim_OnUpdate) - + frame.anim[7] = SetNewAnimation(frame.anim, "Translation", frame) frame.anim[7]:SetOrder(7) frame.anim[7]:SetDuration(speed) frame.anim[7]._coords = {0,0.5,0.75,1} frame.anim[7]:SetScript("OnUpdate", Anim_OnUpdate) - + frame.anim[8] = SetNewAnimation(frame.anim, "Translation", frame) frame.anim[8]:SetOrder(8) frame.anim[8]:SetDuration(speed) @@ -539,8 +541,8 @@ local function SetAnim(frame, parent) frame.anim:SetLooping("REPEAT") end ---[[ -########################################################## +--[[ +########################################################## HEALTH ########################################################## ]]-- @@ -550,7 +552,7 @@ local OverlayHealthUpdate = function(health, unit, min, max) health:SetValue(disconnected and 0 or -min) local invisible = ((min == max) or UnitIsDeadOrGhost(unit) or disconnected); if invisible then health.lowAlerted = false end - + if health.fillInverted then health:SetReverseFill(true) end @@ -576,10 +578,10 @@ local OverlayHealthUpdate = function(health, unit, min, max) health:SetStatusBarColor(t[1], t[2], t[3], 0.9) else health:SetStatusBarColor(1, 0.25 * mu, 0, 0.85) - health.animation[1]:SetVertexColor(1, 0.1 * mu, 0, 0.5) + health.animation[1]:SetVertexColor(1, 0.1 * mu, 0, 0.5) end - if(health.overlayAnimation and not invisible) then + if(health.overlayAnimation and not invisible) then if(mu <= 0.25) then health.animation[1]:SetAlpha(1) health.animation[1].anim:Play() @@ -588,7 +590,7 @@ local OverlayHealthUpdate = function(health, unit, min, max) health.animation[1]:SetAlpha(0) end end -end +end local RefreshHealthBar = function(self, overlay) if(overlay) then @@ -597,7 +599,7 @@ local RefreshHealthBar = function(self, overlay) else self.Health.bg:SetVertexColor(0.4, 0.1, 0.1, 0.8) self.Health.PreUpdate = nil; - end + end end function MOD:CreateHealthBar(frame, hasbg) @@ -605,14 +607,14 @@ function MOD:CreateHealthBar(frame, hasbg) healthBar:SetFrameStrata("LOW") healthBar:SetFrameLevel(4) healthBar:SetStatusBarTexture(SV.media.statusbar.default); - - if hasbg then + + if hasbg then healthBar.bg = healthBar:CreateTexture(nil, "BORDER") healthBar.bg:SetAllPoints() healthBar.bg:SetTexture(SV.media.statusbar.gradient) healthBar.bg:SetVertexColor(0.4, 0.1, 0.1) healthBar.bg.multiplier = 0.25 - end + end local flasher = CreateFrame("Frame", nil, frame) flasher:SetFrameLevel(3) @@ -625,7 +627,7 @@ function MOD:CreateHealthBar(frame, hasbg) flasher[1]:SetBlendMode("ADD") flasher[1]:SetAllPoints(flasher) SetAnim(flasher[1], flasher) - flasher:Hide() + flasher:Hide() healthBar.animation = flasher healthBar.noupdate = false; @@ -635,45 +637,45 @@ function MOD:CreateHealthBar(frame, hasbg) healthBar.colorDisconnected = true; frame.RefreshHealthBar = RefreshHealthBar - + return healthBar end ---[[ -########################################################## +--[[ +########################################################## POWER ########################################################## ]]-- local PostUpdateAltPower = function(self, min, current, max) local remaining = floor(current / max * 100) local parent = self:GetParent() - if remaining < 35 then + if remaining < 35 then self:SetStatusBarColor(0, 1, 0) - elseif remaining < 70 then + elseif remaining < 70 then self:SetStatusBarColor(1, 1, 0) - else + else self:SetStatusBarColor(1, 0, 0) - end + end local unit = parent.unit; - if(unit == "player" and self.text) then + if(unit == "player" and self.text) then local apInfo = select(10, UnitAlternatePowerInfo(unit)) - if remaining > 0 then + if remaining > 0 then self.text:SetText(apInfo..": "..format("%d%%", remaining)) - else + else self.text:SetText(apInfo..": 0%") - end - elseif(unit and unit:find("boss%d") and self.text) then + end + elseif(unit and unit:find("boss%d") and self.text) then self.text:SetTextColor(self:GetStatusBarColor()) - if not parent.TextGrip.Power:GetText() or parent.TextGrip.Power:GetText() == "" then + if not parent.TextGrip.Power:GetText() or parent.TextGrip.Power:GetText() == "" then self.text:ModPoint("BOTTOMRIGHT", parent.Health, "BOTTOMRIGHT") - else + else self.text:ModPoint("RIGHT", parent.TextGrip.Power, "LEFT", 2, 0) - end - if remaining > 0 then + end + if remaining > 0 then self.text:SetText("|cffD7BEA5[|r"..format("%d%%", remaining).."|cffD7BEA5]|r") - else + else self.text:SetText(nil) - end - end + end + end end function MOD:CreatePowerBar(frame) @@ -683,12 +685,12 @@ function MOD:CreatePowerBar(frame) power:SetFrameStrata("LOW") power:SetFrameLevel(6) power.bg = power.Panel.Skin - power.bg.multiplier = 0.2 + power.bg.multiplier = 0.2 power.colorDisconnected = false; power.colorTapping = false; power.PostUpdate = MOD.PostUpdatePower; - return power -end + return power +end function MOD:CreateAltPowerBar(frame) local altPower = CreateFrame("StatusBar", nil, frame) @@ -702,7 +704,7 @@ function MOD:CreateAltPowerBar(frame) altPower.text:SetJustifyH("CENTER") altPower.text:SetFontObject(SVUI_Font_Unit) altPower.PostUpdate = PostUpdateAltPower; - return altPower + return altPower end function MOD:PostUpdatePower(unit, value, max) @@ -713,16 +715,16 @@ function MOD:PostUpdatePower(unit, value, max) value = random(1, max) powerType = random(0, 4) self:SetValue(value) - end + end local colors = oUF_SVUI.colors.power[token[powerType]] local mult = self.bg.multiplier or 1; local isPlayer = UnitPlayerControlled(unit) - if isPlayer and self.colorClass then + if isPlayer and self.colorClass then local _, class = UnitClassBase(unit); colors = oUF_SVUI["colors"].class[class] elseif(not isPlayer and (powerType and powerType == 1 and value == 0)) then colors = nil - end + end if(not colors) then self:Hide() else @@ -731,8 +733,8 @@ function MOD:PostUpdatePower(unit, value, max) self.bg:SetVertexColor(colors[1] * mult, colors[2] * mult, colors[3] * mult) end end ---[[ -########################################################## +--[[ +########################################################## PORTRAIT ########################################################## ]]-- @@ -742,9 +744,9 @@ function MOD:CreatePortrait(frame,smallUnit,isPlayer) portrait3D:SetFrameStrata("LOW") portrait3D:SetFrameLevel(2) - if smallUnit then + if smallUnit then portrait3D:SetStyle("Frame", "UnitSmall") - else + else portrait3D:SetStyle("Frame", "UnitLarge") end @@ -756,9 +758,9 @@ function MOD:CreatePortrait(frame,smallUnit,isPlayer) portrait2Danchor:SetFrameStrata("LOW") portrait2Danchor:SetFrameLevel(2) - if smallUnit then + if smallUnit then portrait2Danchor:SetStyle("Frame", "UnitSmall") - else + else portrait2Danchor:SetStyle("Frame", "UnitLarge") end @@ -770,4 +772,4 @@ function MOD:CreatePortrait(frame,smallUnit,isPlayer) -- Assign To Frame frame.PortraitModel = portrait3D; frame.PortraitTexture = portrait2D; -end \ No newline at end of file +end