From d79b05e85e14b1bd6fcce9f9b360b9e1656fdd60 Mon Sep 17 00:00:00 2001 From: shagu Date: Mon, 15 Jun 2020 17:14:43 +0200 Subject: [PATCH] infight: modernize and add instant updates --- modules/gui.lua | 2 +- modules/infight.lua | 70 ++++++++++++++++++++++----------------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/modules/gui.lua b/modules/gui.lua index be60c017..feee4bfe 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -1451,7 +1451,7 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function () CreateConfig(nil, T["Bags Border Size"], C.appearance.border, "bags", "dropdown", pfUI.gui.dropdowns.border) CreateConfig(U["nameplates"], T["Nameplate Border Size"], C.appearance.border, "nameplates", "dropdown", pfUI.gui.dropdowns.border) CreateConfig(nil) -- spacer - CreateConfig(nil, T["Enable Combat Glow Effects On Screen Edges"], C.appearance.infight, "screen", "checkbox") + CreateConfig(U["infight"], T["Enable Combat Glow Effects On Screen Edges"], C.appearance.infight, "screen", "checkbox") end) CreateGUIEntry(T["Settings"], T["Cooldown"], function() diff --git a/modules/infight.lua b/modules/infight.lua index 87372432..993cad7e 100644 --- a/modules/infight.lua +++ b/modules/infight.lua @@ -1,42 +1,42 @@ pfUI:RegisterModule("infight", "vanilla:tbc", function () - -- build the frame - pfUI.infight = CreateFrame("Frame", "pfUICombat", UIParent) + local function OnUpdate() + if this.mode == 0 then return end + if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .1 end - pfUI.infight.backdrop = { - edgeFile = pfUI.media["img:glow"], edgeSize = 8, - insets = {left = 0, right = 0, top = 0, bottom = 0}, - } + if not this.fadeValue then this.fadeValue = 1 end + if this.fadeValue >= 0.3 then + this.fadeModifier = -0.1 + end + if this.fadeValue <= 0 then + this.fadeModifier = 0.1 + end + this.fadeValue = this.fadeValue + this.fadeModifier - pfUI.infight:SetScript("OnUpdate",function(s,e) - if not pfUI.infight.clock then pfUI.infight.clock = GetTime() -0.1 end - if GetTime() >= pfUI.infight.clock + 0.1 then - pfUI.infight.clock = GetTime() - - if not pfUI.infight.fadeValue then pfUI.infight.fadeValue = 1 end - if pfUI.infight.fadeValue >= 0.3 then - pfUI.infight.fadeModifier = -0.1 - end - if pfUI.infight.fadeValue <= 0 then - pfUI.infight.fadeModifier = 0.1 - end - pfUI.infight.fadeValue = pfUI.infight.fadeValue + pfUI.infight.fadeModifier - - if C.appearance.infight.screen == "1" and pfUI.infight.screen then - if UnitAffectingCombat("player") then - pfUI.infight.screen:Show() - pfUI.infight.screen:SetBackdropBorderColor(1,0.2+pfUI.infight.fadeValue, pfUI.infight.fadeValue, 1-pfUI.infight.fadeValue); - else - pfUI.infight.screen:Hide() - end + if C.appearance.infight.screen == "1" and this.screen then + if UnitAffectingCombat("player") then + this.screen:Show() + this.screen:SetBackdropBorderColor(1,0.2+this.fadeValue, this.fadeValue, 1-this.fadeValue); + else + this.screen:Hide() end end - end) - - if C.appearance.infight.screen == "1" then - pfUI.infight.screen = CreateFrame("Frame", "pfUICombatScreen", UIParent) - pfUI.infight.screen:SetFrameStrata("BACKGROUND") - pfUI.infight.screen:SetBackdrop(pfUI.infight.backdrop) - pfUI.infight.screen:SetAllPoints(WorldFrame) - pfUI.infight.screen:Hide() end + + pfUI.infight = CreateFrame("Frame", "pfUICombat", UIParent) + pfUI.infight:SetScript("OnUpdate", OnUpdate) + + pfUI.infight.screen = CreateFrame("Frame", "pfUICombatScreen", UIParent) + pfUI.infight.screen:SetFrameStrata("BACKGROUND") + pfUI.infight.screen:SetAllPoints(WorldFrame) + pfUI.infight.screen:SetBackdrop({ + edgeFile = pfUI.media["img:glow"], edgeSize = 8, + insets = {left = 0, right = 0, top = 0, bottom = 0}, + }) + pfUI.infight.screen:Hide() + + pfUI.infight.UpdateConfig = function(self) + pfUI.infight.mode = tonumber(C.appearance.infight.screen) + end + + pfUI.infight.UpdateConfig() end)