Skip to content

Commit

Permalink
Visibility defaults changes
Browse files Browse the repository at this point in the history
  • Loading branch information
greven committed Oct 19, 2020
1 parent 3714176 commit 983fd6a
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 93 deletions.
43 changes: 38 additions & 5 deletions config/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ cfg.units = {
frequentUpdates = true,
smooth = true
},
-- visibility = "[combat][mod][@target,exists][vehicleui][group] show; hide",
name = {
show = true
},
Expand All @@ -121,9 +120,12 @@ cfg.units = {
show = true
}
},
-- visibility = "[combat][mod][@target,exists][@mouseover,harm][vehicleui][group][channeling] show; hide",
fader = {
enable = false,
alpha = 0.3
fadeInAlpha = 1,
fadeInDuration = 0.3,
fadeOutAlpha = 0,
fadeOutDuration = 0.3
}
},
target = {
Expand Down Expand Up @@ -160,6 +162,12 @@ cfg.units = {
barTimers = {
show = true
}
},
fader = {
fadeInAlpha = 1,
fadeInDuration = 0.3,
fadeOutAlpha = 0,
fadeOutDuration = 0.3
}
},
targettarget = {
Expand All @@ -179,6 +187,12 @@ cfg.units = {
classColored = false,
frequentUpdates = false,
smooth = true
},
fader = {
fadeInAlpha = 1,
fadeInDuration = 0.3,
fadeOutAlpha = 0,
fadeOutDuration = 0.3
}
},
focus = {
Expand All @@ -204,6 +218,12 @@ cfg.units = {
color = {123 / 255, 66 / 255, 200 / 255},
width = 282,
height = cfg.frames.main.height
},
fader = {
fadeInAlpha = 1,
fadeInDuration = 0.3,
fadeOutAlpha = 0,
fadeOutDuration = 0.3
}
},
pet = {
Expand Down Expand Up @@ -233,7 +253,13 @@ cfg.units = {
buffs = {
filter = true
},
visibility = "[petbattle][overridebar][vehicleui][possessbar][shapeshift][channeling] hide; [pet,mod][harm][combat] show; hide"
visibility = "[petbattle][overridebar][vehicleui][possessbar][shapeshift][channeling] hide; [pet,mod][pet,harm][pet,combat] show; hide",
fader = {
fadeInAlpha = 1,
fadeInDuration = 0.3,
fadeOutAlpha = 0,
fadeOutDuration = 0.3
}
},
boss = {
show = true,
Expand Down Expand Up @@ -330,7 +356,14 @@ cfg.elements = {
backdrop = {
color = {r = 0, g = 0, b = 0, a = 0.85}
},
timeToHold = 2
timeToHold = 1.5,
fader = {
fadeInAlpha = 1,
fadeInDuration = 0.1,
fadeOutAlpha = 0,
fadeOutDuration = 0.3,
fadeOutDelay = 0.5
}
},
experiencebar = {
show = true,
Expand Down
82 changes: 82 additions & 0 deletions core/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,85 @@ function core:createDropShadow(frame, point, edge, color)
shadow:SetBackdropColor(0, 0, 0, 0)
shadow:SetBackdropBorderColor(unpack(color))
end

-- Frame Fader
local function FaderOnFinished(self)
self.__owner:SetAlpha(self.finAlpha)
end

local function FaderOnUpdate(self)
self.__owner:SetAlpha(self.__animFrame:GetAlpha())
end

function core:IsMouseOverFrame(frame)
if MouseIsOver(frame) then
return true
end
return false
end

function core:StartFadeIn(frame)
if frame.fader.direction == "in" then
return
end
frame.fader:Pause()
frame.fader.anim:SetFromAlpha(frame.faderConfig.fadeOutAlpha or 0)
frame.fader.anim:SetToAlpha(frame.faderConfig.fadeInAlpha or 1)
frame.fader.anim:SetDuration(frame.faderConfig.fadeInDuration or 0.3)
frame.fader.anim:SetSmoothing(frame.faderConfig.fadeInSmooth or "OUT")
--start right away
frame.fader.anim:SetStartDelay(frame.faderConfig.fadeInDelay or 0)
frame.fader.finAlpha = frame.faderConfig.fadeInAlpha
frame.fader.direction = "in"
frame.fader:Play()
end

function core:StartFadeOut(frame)
if frame.fader.direction == "out" then
return
end
frame.fader:Pause()
frame.fader.anim:SetFromAlpha(frame.faderConfig.fadeInAlpha or 1)
frame.fader.anim:SetToAlpha(frame.faderConfig.fadeOutAlpha or 0)
frame.fader.anim:SetDuration(frame.faderConfig.fadeOutDuration or 0.3)
frame.fader.anim:SetSmoothing(frame.faderConfig.fadeOutSmooth or "OUT")
-- wait for some time before starting the fadeout
frame.fader.anim:SetStartDelay(frame.faderConfig.fadeOutDelay or 0)
frame.fader.finAlpha = frame.faderConfig.fadeOutAlpha
frame.fader.direction = "out"
frame.fader:Play()
end

function core:CreateFaderAnimation(frame)
if frame.fader then
return
end
local animFrame = CreateFrame("Frame", nil, frame)
animFrame.__owner = frame
frame.fader = animFrame:CreateAnimationGroup()
frame.fader.__owner = frame
frame.fader.__animFrame = animFrame
frame.fader.direction = nil
frame.fader.setToFinalAlpha = false
frame.fader.anim = frame.fader:CreateAnimation("Alpha")
frame.fader:HookScript("OnFinished", FaderOnFinished)
frame.fader:HookScript("OnUpdate", FaderOnUpdate)
end

local function fadeIn(frame)
core:StartFadeIn(frame)
end

local function fadeOut(frame)
core:StartFadeOut(frame)
end

function core:CreateFrameFader(frame, faderConfig)
if frame.faderConfig then
return
end
frame.faderConfig = faderConfig
core:CreateFaderAnimation(frame)
frame:HookScript("OnShow", fadeIn)
frame:HookScript("OnHide", fadeOut)
end
77 changes: 7 additions & 70 deletions elements/castbar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,74 +18,6 @@ local function resetAttributes(self)
self.spellID = nil
end

local OnUpdate = function(self, elapsed)
if (self.casting or self.channeling) then
local isCasting = self.casting
self:SetAlpha(1)

if (isCasting) then
self.duration = self.duration + elapsed
if (self.duration >= self.max) then
local spellID = self.spellID

resetAttributes(self)
self:Hide()

if (self.PostCastStop) then
self:PostCastStop(self.__owner.unit, spellID)
end

return
end
else
self.duration = self.duration - elapsed
if (self.duration <= 0) then
local spellID = self.spellID

resetAttributes(self)
self:Hide()

if (self.PostCastStop) then
self:PostCastStop(self.__owner.unit, spellID)
end

return
end
end

if (self.Time) then
if (self.delay ~= 0) then
if (self.CustomDelayText) then
self:CustomDelayText(self.duration)
else
self.Time:SetFormattedText("%.1f|cffff0000%s%.2f|r", self.duration, isCasting and "+" or "-", self.delay)
end
else
if (self.CustomTimeText) then
self:CustomTimeText(self.duration)
else
self.Time:SetFormattedText("%.1f", self.duration)
end
end
end

self:SetValue(self.duration)
elseif (self.holdTime > 0) then
self.holdTime = self.holdTime - elapsed

-- Fade castbar
local alpha = self:GetAlpha() - 0.025
if alpha > 0 then
self:SetAlpha(alpha)
else
self:SetAlpha(0)
end
else
resetAttributes(self)
self:Hide()
end
end

local CheckForSpellInterrupt = function(self, unit)
local initialColor = cfg.units[unit].castbar.color

Expand Down Expand Up @@ -116,11 +48,13 @@ local onPostCastStart = function(self, unit)
-- Set the castbar unit's initial color
self:SetStatusBarColor(unpack(cfg.units[unit].castbar.color))
CheckForSpellInterrupt(self, unit)
core:StartFadeIn(self)
end

local OnPostCastFail = function(self, unit)
-- Color castbar red when cast fails
self:SetStatusBarColor(235 / 255, 25 / 255, 25 / 255)
core:StartFadeOut(self)

if self.Max then
self.Max:Hide()
Expand Down Expand Up @@ -260,10 +194,13 @@ function core:CreateCastbar(self)
Castbar.PostCastStart = onPostCastStart
Castbar.PostCastFail = OnPostCastFail
Castbar.PostCastInterruptible = OnPostCastInterruptible
Castbar.OnUpdate = OnUpdate

Castbar.timeToHold = cfg.elements.castbar.timeToHold
Castbar.CustomTimeText = CustomCastTimeText
Castbar.timeToHold = cfg.elements.castbar.timeToHold

-- FadeIn / FadeOut animation
core:CreateFaderAnimation(Castbar)
Castbar.faderConfig = cfg.elements.castbar.fader

Castbar.bg = Background
Castbar.Text = Text
Expand Down
4 changes: 4 additions & 0 deletions tasks.todo
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
general:
☐ Add scale back to frames (player, party, target, etc)

party:
☐ Health is showing as depleted when 100% @bug
☐ Finish the party frames
☐ Add debuffs
☐ Add buffs?
☐ Add seperate layouts for healing specs and rest (even to detect spec on joining party)
☐ Add PhaseIndicator

raid:
☐ Create the raid frames?
☐ Add corner indicators (example healers: DoTs, etc, debuffs, etc, make it configurable)
☐ Add PhaseIndicator

personal resource display:
☐ skin the element
11 changes: 10 additions & 1 deletion units/focus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,14 @@ end
if cfg.units[frame].show then
oUF:RegisterStyle(A .. frame:gsub("^%l", string.upper), createStyle)
oUF:SetActiveStyle(A .. frame:gsub("^%l", string.upper))
oUF:Spawn(frame, A .. frame:gsub("^%l", string.upper))
local f = oUF:Spawn(frame, A .. frame:gsub("^%l", string.upper))
-- Frame Visibility
if cfg.units[frame].visibility then
f:Disable()
RegisterStateDriver(f, "visibility", cfg.units[frame].visibility)
end
-- Fader
if cfg.units[frame].fader then
core:CreateFrameFader(f, cfg.units[frame].fader)
end
end
4 changes: 4 additions & 0 deletions units/pet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,8 @@ if cfg.units[frame].show then
f:Disable()
RegisterStateDriver(f, "visibility", cfg.units[frame].visibility)
end
-- Fader
if cfg.units[frame].fader then
core:CreateFrameFader(f, cfg.units[frame].fader)
end
end
21 changes: 4 additions & 17 deletions units/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -508,23 +508,6 @@ local createStyle = function(self)
-- Power
self.Power.frequentUpdates = self.cfg.power.frequentUpdates

-- Out of Combat Frame Fading
if self.cfg.fader.enable then
self:SetAlpha(self.cfg.fader.alpha)
self:RegisterEvent(
"PLAYER_REGEN_DISABLED",
function(self)
self:SetAlpha(1)
end
)
self:RegisterEvent(
"PLAYER_REGEN_ENABLED",
function(self)
self:SetAlpha(self.cfg.fader.alpha)
end
)
end

-- Castbar
if self.cfg.castbar.enable then
core:CreateCastbar(self)
Expand Down Expand Up @@ -698,4 +681,8 @@ if cfg.units[frame].show then
f:Disable()
RegisterStateDriver(f, "visibility", cfg.units[frame].visibility)
end
-- Fader
if cfg.units[frame].fader then
core:CreateFrameFader(f, cfg.units[frame].fader)
end
end
4 changes: 4 additions & 0 deletions units/target.lua
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,8 @@ if cfg.units[frame].show then
f:Disable()
RegisterStateDriver(f, "visibility", cfg.units[frame].visibility)
end
-- Fader
if cfg.units[frame].fader then
core:CreateFrameFader(f, cfg.units[frame].fader)
end
end
4 changes: 4 additions & 0 deletions units/targettarget.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@ if cfg.units[frame].show then
f:Disable()
RegisterStateDriver(f, "visibility", cfg.units[frame].visibility)
end
-- Fader
if cfg.units[frame].fader then
core:CreateFrameFader(f, cfg.units[frame].fader)
end
end

0 comments on commit 983fd6a

Please sign in to comment.