From b8aece0da3cd9133f1a6f0c3dec31c1032689bcc Mon Sep 17 00:00:00 2001 From: Parnic Date: Sun, 15 Jan 2023 12:52:22 -0600 Subject: [PATCH] Add support for a partially-ready final rune This adds support for a class power counter that has a visible recharge on the final "rune." Most power counters are either fully ready or full un-ready (where the recharge is hidden away), but Dragonriding's Vigor resource does show the recharge of the final point, which this now supports. Child classes can support this by setting self.partialReady to the index of the rune that's partially ready, and self.partialReadyPercent to the percentage that that final rune is ready (0.0-1.0). If the partially-charged point uses a different texture, the child can also implement GetPartialRuneAtlas() and it will be used only for the partially-ready rune. If we ever need to be able to show multiple partially-ready runes, this will need a small refactor. --- modules/ClassPowerCounter.lua | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/modules/ClassPowerCounter.lua b/modules/ClassPowerCounter.lua index a2586d4..32332b1 100644 --- a/modules/ClassPowerCounter.lua +++ b/modules/ClassPowerCounter.lua @@ -530,10 +530,15 @@ function IceClassPowerCounter.prototype:UpdateRunePower(event, arg1, arg2) local percentReady = self.shouldShowUnmodified and (UnitPower("player", self.unitPower, true) / self.unmodifiedMaxPerRune) or numReady if self:GetRuneMode() == "Numeric" or self.moduleSettings.alsoShowNumeric then + local displayPercent = percentReady + if self.partialReadyPercent then + displayPercent = percentReady + self.partialReadyPercent + end + if self.numericFormat then - self.frame.numeric:SetText(format(self.numericFormat, percentReady)) + self.frame.numeric:SetText(format(self.numericFormat, displayPercent)) else - self.frame.numeric:SetText(tostring(percentReady)) + self.frame.numeric:SetText(tostring(displayPercent)) end self.frame.numeric:SetTextColor(self:GetColor(self.numericColor)) end @@ -572,6 +577,17 @@ function IceClassPowerCounter.prototype:UpdateRunePower(event, arg1, arg2) end end else + if self.partialReady then + if i == self.partialReady then + self:SetRuneCoords(i, self.partialReadyPercent) + if self:GetRuneMode() == "Graphical" then + self:SetRuneGraphicalTexture(i, true) + end + else + self:SetRuneCoords(i, 0) + end + end + self:HideRune(i) end end @@ -697,6 +713,10 @@ function IceClassPowerCounter.prototype:GetShineAtlas(rune) return nil end +function IceClassPowerCounter.prototype:GetPartialRuneAtlas(rune) + return nil +end + function IceClassPowerCounter.prototype:CreateFrame() IceClassPowerCounter.super.prototype.CreateFrame(self) @@ -838,14 +858,16 @@ function IceClassPowerCounter.prototype:SetupRuneTexture(rune) end end -function IceClassPowerCounter.prototype:SetRuneGraphicalTexture(rune) +function IceClassPowerCounter.prototype:SetRuneGraphicalTexture(rune, partial) self.frame.graphical[rune].rune:SetVertexColor(1, 1, 1) local tex = self:GetRuneTexture(rune) if tex then self.frame.graphical[rune].rune:SetTexture(tex) else - self.frame.graphical[rune].rune:SetAtlas(self:GetRuneAtlas(rune), self:UseAtlasSize(rune)) + local partialAtlas = self:GetPartialRuneAtlas(rune) + local atlas = (partial and partialAtlas) and partialAtlas or self:GetRuneAtlas(rune) + self.frame.graphical[rune].rune:SetAtlas(atlas, self:UseAtlasSize(rune)) end end