- fixed a bug causing the mirror bar to not obey "offset" setting

- made the mirror bar's text stop bouncing up and down based on its offset setting. now will always remain in the same place (since there are vertical/horizontal adjustment sliders for this text already)
This commit is contained in:
Parnic
2008-10-14 01:46:29 +00:00
parent b85b9a48ad
commit 3671b0da91

View File

@ -27,6 +27,10 @@ function MirrorBar.prototype:init(side, offset, name, db)
self.moduleSettings.offset = offset self.moduleSettings.offset = offset
self.moduleSettings.barVisible = {bar = true, bg = true} self.moduleSettings.barVisible = {bar = true, bg = true}
self.moduleSettings.shouldAnimate = false self.moduleSettings.shouldAnimate = false
-- this has to be set to 0 or else it will error out when trying to use it for SetPoint later
self.moduleSettings.barVerticalOffset = 0
-- avoid nil warnings here
self.moduleSettings.myTagVersion = IceHUD.CurrTagVersion
-- unregister the event superclass registered, we don't want to register -- unregister the event superclass registered, we don't want to register
-- this to the core -- this to the core
@ -42,7 +46,7 @@ end
function MirrorBar.prototype:Enable(core) function MirrorBar.prototype:Enable(core)
MirrorBar.super.prototype.Enable(self, core) MirrorBar.super.prototype.Enable(self, core)
self.frame.bottomUpperText:SetWidth(200) self.frame.bottomUpperText:SetWidth(200)
self.frame.bottomLowerText:SetWidth(200) self.frame.bottomLowerText:SetWidth(200)
@ -53,7 +57,7 @@ end
-- OVERRIDE -- OVERRIDE
function MirrorBar.prototype:Create(parent) function MirrorBar.prototype:Create(parent)
MirrorBar.super.prototype.Create(self, parent) MirrorBar.super.prototype.Create(self, parent)
if (self.timer) then if (self.timer) then
self:Show(true) self:Show(true)
end end
@ -68,9 +72,9 @@ function MirrorBar.prototype:OnUpdate(elapsed)
self:Update() self:Update()
self.value = self.value + (self.timerScale * elapsed * 1000) self.value = self.value + (self.timerScale * elapsed * 1000)
scale = self.value / self.maxValue scale = self.value / self.maxValue
if (scale < 0) then -- lag compensation if (scale < 0) then -- lag compensation
scale = 0 scale = 0
end end
@ -78,10 +82,10 @@ function MirrorBar.prototype:OnUpdate(elapsed)
scale = 1 scale = 1
end end
local timeRemaining = (self.value) / 1000 local timeRemaining = (self.value) / 1000
local remaining = string.format("%.1f", timeRemaining) local remaining = string.format("%.1f", timeRemaining)
if (timeRemaining < 0) then -- lag compensation if (timeRemaining < 0) then -- lag compensation
remaining = 0 remaining = 0
end end
@ -90,16 +94,11 @@ function MirrorBar.prototype:OnUpdate(elapsed)
end end
self:UpdateBar(scale, self.timer) self:UpdateBar(scale, self.timer)
local text = self.label .. " " .. remaining .. "s" local text = self.label .. " " .. remaining .. "s"
if (math.fmod(self.moduleSettings.offset, 2) == 1) then self:SetBottomText1(text)
self:SetBottomText1(text) self:SetBottomText2()
self:SetBottomText2()
else
self:SetBottomText1()
self:SetBottomText2(text, "Text", 1)
end
end end
@ -110,7 +109,7 @@ function MirrorBar.prototype:MirrorStart(timer, value, maxValue, scale, paused,
self.timerScale = scale self.timerScale = scale
self.paused = (paused > 0) self.paused = (paused > 0)
self.label = label self.label = label
self.startTime = GetTime() self.startTime = GetTime()
self:Update() self:Update()
@ -195,7 +194,7 @@ end
-- OVERRIDE -- OVERRIDE
function MirrorBarHandler.prototype:GetOptions() function MirrorBarHandler.prototype:GetOptions()
local opts = MirrorBarHandler.super.prototype.GetOptions(self) local opts = MirrorBarHandler.super.prototype.GetOptions(self)
opts["side"] = opts["side"] =
{ {
type = 'text', type = 'text',
@ -219,7 +218,7 @@ function MirrorBarHandler.prototype:GetOptions()
validate = { "Left", "Right" }, validate = { "Left", "Right" },
order = 30 order = 30
} }
opts["offset"] = opts["offset"] =
{ {
type = 'range', type = 'range',
@ -254,7 +253,7 @@ function MirrorBarHandler.prototype:GetOptions()
end, end,
order = 28 order = 28
} }
opts["bgVisible"] = { opts["bgVisible"] = {
type = 'toggle', type = 'toggle',
name = 'Bar background visible', name = 'Bar background visible',
@ -271,7 +270,7 @@ function MirrorBarHandler.prototype:GetOptions()
end, end,
order = 29 order = 29
} }
opts["textSettings"] = opts["textSettings"] =
{ {
type = 'group', type = 'group',
@ -295,7 +294,7 @@ function MirrorBarHandler.prototype:GetOptions()
step = 1, step = 1,
order = 11 order = 11
}, },
fontBold = { fontBold = {
type = 'toggle', type = 'toggle',
name = 'Bar Font Bold', name = 'Bar Font Bold',
@ -309,7 +308,7 @@ function MirrorBarHandler.prototype:GetOptions()
end, end,
order = 12 order = 12
}, },
lockFontAlpha = { lockFontAlpha = {
type = "toggle", type = "toggle",
name = "Lock Bar Text Alpha", name = "Lock Bar Text Alpha",
@ -323,7 +322,7 @@ function MirrorBarHandler.prototype:GetOptions()
end, end,
order = 13 order = 13
}, },
upperTextVisible = { upperTextVisible = {
type = 'toggle', type = 'toggle',
name = 'Upper text visible', name = 'Upper text visible',
@ -337,7 +336,7 @@ function MirrorBarHandler.prototype:GetOptions()
end, end,
order = 14 order = 14
}, },
lowerTextVisible = { lowerTextVisible = {
type = 'toggle', type = 'toggle',
name = 'Lower text visible', name = 'Lower text visible',
@ -391,7 +390,7 @@ function MirrorBarHandler.prototype:GetOptions()
} }
} }
} }
return opts return opts
end end
@ -401,7 +400,7 @@ function MirrorBarHandler.prototype:Enable(core)
self:RegisterEvent("MIRROR_TIMER_START", "MirrorStart") self:RegisterEvent("MIRROR_TIMER_START", "MirrorStart")
self:RegisterEvent("MIRROR_TIMER_STOP", "MirrorStop") self:RegisterEvent("MIRROR_TIMER_STOP", "MirrorStop")
self:RegisterEvent("MIRROR_TIMER_PAUSE", "MirrorPause") self:RegisterEvent("MIRROR_TIMER_PAUSE", "MirrorPause")
-- hide blizz mirror bar -- hide blizz mirror bar
UIParent:UnregisterEvent("MIRROR_TIMER_START"); UIParent:UnregisterEvent("MIRROR_TIMER_START");
end end
@ -409,14 +408,14 @@ end
function MirrorBarHandler.prototype:Disable(core) function MirrorBarHandler.prototype:Disable(core)
MirrorBarHandler.super.prototype.Disable(self, core) MirrorBarHandler.super.prototype.Disable(self, core)
UIParent:RegisterEvent("MIRROR_TIMER_START"); UIParent:RegisterEvent("MIRROR_TIMER_START");
end end
function MirrorBarHandler.prototype:Redraw() function MirrorBarHandler.prototype:Redraw()
MirrorBarHandler.super.prototype.Redraw(self) MirrorBarHandler.super.prototype.Redraw(self)
if (not self.moduleSettings.enabled) then if (not self.moduleSettings.enabled) then
return return
end end
@ -431,7 +430,7 @@ end
function MirrorBarHandler.prototype:MirrorStart(timer, value, maxValue, scale, paused, label) function MirrorBarHandler.prototype:MirrorStart(timer, value, maxValue, scale, paused, label)
local done = nil local done = nil
-- check if we can find an already running timer to reverse it -- check if we can find an already running timer to reverse it
for i = 1, table.getn(self.bars) do for i = 1, table.getn(self.bars) do
if (self.bars[i].timer == timer) then if (self.bars[i].timer == timer) then
@ -439,7 +438,7 @@ function MirrorBarHandler.prototype:MirrorStart(timer, value, maxValue, scale, p
self.bars[i]:MirrorStart(timer, value, maxValue, scale, paused, label) self.bars[i]:MirrorStart(timer, value, maxValue, scale, paused, label)
end end
end end
-- check if there's a free instance in case we didn't find an already running bar -- check if there's a free instance in case we didn't find an already running bar
if not (done) then if not (done) then
for i = 1, table.getn(self.bars) do for i = 1, table.getn(self.bars) do
@ -449,7 +448,7 @@ function MirrorBarHandler.prototype:MirrorStart(timer, value, maxValue, scale, p
end end
end end
end end
-- finally create a new instance if no available ones were found -- finally create a new instance if no available ones were found
if not (done) then if not (done) then
local count = table.getn(self.bars) local count = table.getn(self.bars)
@ -490,7 +489,6 @@ function MirrorBarHandler.prototype:SetSettings(bar)
bar.moduleSettings.textVerticalOffset = self.moduleSettings.textVerticalOffset bar.moduleSettings.textVerticalOffset = self.moduleSettings.textVerticalOffset
bar.moduleSettings.textHorizontalOffset = self.moduleSettings.textHorizontalOffset bar.moduleSettings.textHorizontalOffset = self.moduleSettings.textHorizontalOffset
bar.moduleSettings.barVisible = self.moduleSettings.barVisible bar.moduleSettings.barVisible = self.moduleSettings.barVisible
bar.moduleSettings.myTagVersion = self.moduleSettings.myTagVersion
end end