diff --git a/IceBarElement.lua b/IceBarElement.lua index 1b2b44b..4ebca46 100644 --- a/IceBarElement.lua +++ b/IceBarElement.lua @@ -7,8 +7,10 @@ IceBarElement.TexturePath = IceHUD.Location .. "\\textures\\" IceBarElement.BarTextureWidth = 128 IceBarElement.prototype.barFrame = nil +IceBarElement.prototype.backroundAlpha = nil IceBarElement.prototype.combat = nil +IceBarElement.prototype.target = nil @@ -30,6 +32,22 @@ function IceBarElement.prototype:Enable() self:RegisterEvent("PLAYER_REGEN_DISABLED", "InCombat") self:RegisterEvent("PLAYER_REGEN_ENABLED", "OutCombat") self:RegisterEvent("PLAYER_ENTERING_WORLD", "CheckCombat") + self:RegisterEvent("PLAYER_TARGET_CHANGED", "TargetChanged") +end + + +-- OVERRIDE +function IceBarElement.prototype:GetDefaultSettings() + local settings = IceBarElement.super.prototype.GetDefaultSettings(self) + + settings["side"] = IceCore.Side.Left + settings["offset"] = 1 + settings["barFontSize"] = 13 + settings["barFontBold"] = true + settings["lockTextAlpha"] = true + settings["textVisible"] = {upper = true, lower = true} + + return settings end @@ -40,7 +58,7 @@ function IceBarElement.prototype:GetOptions() opts["side"] = { type = 'text', - name = 'Side', + name = '|c' .. self.configColor .. 'Side|r', desc = 'Side of the HUD where the bar appears', get = function() if (self.moduleSettings.side == IceCore.Side.Right) then @@ -64,7 +82,7 @@ function IceBarElement.prototype:GetOptions() opts["offset"] = { type = 'range', - name = 'Offset', + name = '|c' .. self.configColor .. 'Offset|r', desc = 'Offset of the bar', min = -1, max = 10, @@ -79,6 +97,88 @@ function IceBarElement.prototype:GetOptions() order = 31 } + opts["textSettings"] = + { + type = 'group', + name = '|c' .. self.configColor .. 'Text Settings|r', + desc = 'Settings related to texts', + order = 32, + args = { + fontsize = { + type = 'range', + name = 'Bar Font Size', + desc = 'Bar Font Size', + get = function() + return self.moduleSettings.barFontSize + end, + set = function(v) + self.moduleSettings.barFontSize = v + self:Redraw() + end, + min = 8, + max = 20, + step = 1, + order = 11 + }, + + fontBold = { + type = 'toggle', + name = 'Bar Font Bold', + desc = 'If you have game default font selected, this option has no effect', + get = function() + return self.moduleSettings.barFontBold + end, + set = function(v) + self.moduleSettings.barFontBold = v + self:Redraw() + end, + order = 12 + }, + + lockFontAlpha = { + type = "toggle", + name = "Lock Bar Text Alpha", + desc = "Locks upper text alpha to 100%", + get = function() + return self.moduleSettings.lockTextAlpha + end, + set = function(v) + self.moduleSettings.lockTextAlpha = v + self:Redraw() + end, + order = 13 + }, + + upperTextVisible = { + type = 'toggle', + name = 'Upper text visible', + desc = 'Toggle upper text visibility', + get = function() + return self.moduleSettings.textVisible['upper'] + end, + set = function(v) + self.moduleSettings.textVisible['upper'] = v + self:Redraw() + end, + order = 14 + }, + + lowerTextVisible = { + type = 'toggle', + name = 'Lower text visible', + desc = 'Toggle lower text visibility', + get = function() + return self.moduleSettings.textVisible['lower'] + end, + set = function(v) + self.moduleSettings.textVisible['lower'] = v + self:Redraw() + end, + order = 15 + }, + } + } + return opts end @@ -193,8 +293,8 @@ end function IceBarElement.prototype:CreateTexts() - self.frame.bottomUpperText = self:FontFactory(self.settings.barFontBold, self.settings.barFontSize, nil, self.frame.bottomUpperText) - self.frame.bottomLowerText = self:FontFactory(self.settings.barFontBold, self.settings.barFontSize, nil, self.frame.bottomLowerText) + self.frame.bottomUpperText = self:FontFactory(self.moduleSettings.barFontBold, self.moduleSettings.barFontSize, nil, self.frame.bottomUpperText) + self.frame.bottomLowerText = self:FontFactory(self.moduleSettings.barFontBold, self.moduleSettings.barFontSize, nil, self.frame.bottomLowerText) self.frame.bottomUpperText:SetWidth(80) self.frame.bottomLowerText:SetWidth(120) @@ -239,13 +339,13 @@ function IceBarElement.prototype:CreateTexts() self.frame.bottomUpperText:SetPoint("TOP"..ownPoint , self.frame, "BOTTOM"..parentPoint, offx, -1) self.frame.bottomLowerText:SetPoint("TOP"..ownPoint , self.frame, "BOTTOM"..parentPoint, offx, -15) - if (self.settings.textVisible["upper"]) then + if (self.moduleSettings.textVisible["upper"]) then self.frame.bottomUpperText:Show() else self.frame.bottomUpperText:Hide() end - if (self.settings.textVisible["lower"]) then + if (self.moduleSettings.textVisible["lower"]) then self.frame.bottomLowerText:Show() else self.frame.bottomLowerText:Hide() @@ -275,8 +375,12 @@ function IceBarElement.prototype:UpdateBar(scale, color, alpha) alpha = alpha or 1 self.frame:SetAlpha(alpha) - local c = self.settings.backgroundColor - self.frame:SetStatusBarColor(c.r, c.g, c.b, self.settings.alphabg) + local r, g, b = self.settings.backgroundColor.r, self.settings.backgroundColor.g, self.settings.backgroundColor.b + if (self.settings.backgroundToggle) then + r, g, b = self:GetColor(color) + end + + self.frame:SetStatusBarColor(r, g, b, self.backgroundAlpha) self.barFrame:SetStatusBarColor(self:GetColor(color)) @@ -287,7 +391,7 @@ end -- Bottom line 1 function IceBarElement.prototype:SetBottomText1(text, color) - if not (self.settings.textVisible["upper"]) and not (self.moduleSettings.alwaysShowText) then + if not (self.moduleSettings.textVisible["upper"]) then return end @@ -296,7 +400,7 @@ function IceBarElement.prototype:SetBottomText1(text, color) end local alpha = 1 - if not (self.settings.lockTextAlpha) then + if not (self.moduleSettings.lockTextAlpha) then -- boost text alpha a bit to make it easier to see if (self.alpha > 0) then alpha = self.alpha + 0.1 @@ -316,7 +420,7 @@ end -- Bottom line 2 function IceBarElement.prototype:SetBottomText2(text, color, alpha) - if not (self.settings.textVisible["lower"]) and not (self.moduleSettings.alwaysShowText) then + if not (self.moduleSettings.textVisible["lower"]) then return end @@ -352,8 +456,13 @@ end function IceBarElement.prototype:Update() if (self.combat) then self.alpha = self.settings.alphaic + self.backgroundAlpha = self.settings.alphaicbg + elseif (self.target) then + self.alpha = self.settings.alphaTarget + self.backgroundAlpha = self.settings.alphaTargetbg else self.alpha = self.settings.alphaooc + self.backgroundAlpha = self.settings.alphaoocbg end end @@ -376,5 +485,12 @@ end function IceBarElement.prototype:CheckCombat() self.combat = UnitAffectingCombat("player") + self.target = UnitExists("target") + self:Update(self.unit) +end + + +function IceBarElement.prototype:TargetChanged() + self.target = UnitExists("target") self:Update(self.unit) end diff --git a/IceCore.lua b/IceCore.lua index 309456e..c0bebd6 100644 --- a/IceCore.lua +++ b/IceCore.lua @@ -37,15 +37,20 @@ function IceCore.prototype:init() gap = 150, verticalPos = -150, scale = 1, + alphaooc = 0.3, alphaic = 0.6, - alphabg = 0.2, + alphaTarget = 0.3, + + alphaoocbg = 0.2, + alphaicbg = 0.2, + alphaTargetbg = 0.2, + + backgroundToggle = false, backgroundColor = {r = 0.2, g = 0.2, b = 0.2}, - lockTextAlpha = true, barTexture = "Bar", - barFontSize = 13, - textVisible = {upper = true, lower = true}, barPreset = defaultPreset, + fontFamily = "IceHUD", debug = false } @@ -183,29 +188,53 @@ function IceCore.prototype:SetScale(value) end -function IceCore.prototype:GetAlphaOOC() - return self.settings.alphaooc +function IceCore.prototype:GetAlpha(mode) + if (mode == "IC") then + return self.settings.alphaic + elseif (mode == "Target") then + return self.settings.alphaTarget + else + return self.settings.alphaooc + end end -function IceCore.prototype:SetAlphaOOC(value) - self.settings.alphaooc = value +function IceCore.prototype:SetAlpha(mode, value) + if (mode == "IC") then + self.settings.alphaic = value + elseif (mode == "Target") then + self.settings.alphaTarget = value + else + self.settings.alphaooc = value + end self:Redraw() end -function IceCore.prototype:GetAlphaIC() - return self.settings.alphaic +function IceCore.prototype:GetAlphaBG(mode) + if (mode == "IC") then + return self.settings.alphaicbg + elseif (mode == "Target") then + return self.settings.alphaTargetbg + else + return self.settings.alphaoocbg + end end -function IceCore.prototype:SetAlphaIC(value) - self.settings.alphaic = value +function IceCore.prototype:SetAlphaBG(mode, value) + if (mode == "IC") then + self.settings.alphaicbg = value + elseif (mode == "Target") then + self.settings.alphaTargetbg = value + else + self.settings.alphaoocbg = value + end self:Redraw() end -function IceCore.prototype:GetAlphaBG() - return self.settings.alphabg +function IceCore.prototype:GetBackgroundToggle() + return self.settings.backgroundToggle end -function IceCore.prototype:SetAlphaBG(value) - self.settings.alphabg = value +function IceCore.prototype:SetBackgroundToggle(value) + self.settings.backgroundToggle = value self:Redraw() end @@ -222,42 +251,6 @@ function IceCore.prototype:SetBackgroundColor(r, g, b) end -function IceCore.prototype:GetLockTextAlpha() - return self.settings.lockTextAlpha -end -function IceCore.prototype:SetLockTextAlpha(value) - self.settings.lockTextAlpha = value - self:Redraw() -end - - -function IceCore.prototype:GetBarFontSize() - return self.settings.barFontSize -end -function IceCore.prototype:SetBarFontSize(value) - self.settings.barFontSize = value - self:Redraw() -end - - -function IceCore.prototype:GetBarFontBold() - return self.settings.barFontBold -end -function IceCore.prototype:SetBarFontBold(value) - self.settings.barFontBold = value - self:Redraw() -end - - -function IceCore.prototype:GetTextVisibility(text) - return self.settings.textVisible[text] -end -function IceCore.prototype:SetTextVisibility(text, value) - self.settings.textVisible[text] = value - self:Redraw() -end - - function IceCore.prototype:GetBarTexture() return self.settings.barTexture end @@ -320,6 +313,15 @@ function IceCore.prototype:ChangePreset(value) end +function IceCore.prototype:GetFontFamily() + return self.settings.fontFamily +end +function IceCore.prototype:SetFontFamily(value) + self.settings.fontFamily = value + self:Redraw() +end + + function IceCore.prototype:GetDebug() return self.settings.debug end diff --git a/IceElement.lua b/IceElement.lua index 9052609..52a0c0e 100644 --- a/IceElement.lua +++ b/IceElement.lua @@ -14,6 +14,7 @@ IceElement.prototype.alpha = nil IceElement.settings = nil IceElement.moduleSettings = nil +IceElement.prototype.configColor = "ff8888ff" -- Constructor -- -- IceElements are to be instantiated before IceCore is loaded. @@ -90,7 +91,7 @@ function IceElement.prototype:GetOptions() local opts = {} opts["enabled"] = { type = "toggle", - name = "|cff8888ffEnabled|r", + name = "|c" .. self.configColor .. "Enabled|r", desc = "Enable/disable module", get = function() return self.moduleSettings.enabled @@ -178,7 +179,11 @@ function IceElement.prototype:FontFactory(weight, size, frame, font) if (weight) then weightString = "Bold" end + local fontFile = IceHUD.Location .. "\\fonts\\Calibri" .. weightString ..".ttf" + if (self.settings.fontFamily == "Default") then + fontFile = STANDARD_TEXT_FONT + end if not (frame) then frame = self.frame diff --git a/IceHUD.lua b/IceHUD.lua index 97777e9..125bdb7 100644 --- a/IceHUD.lua +++ b/IceHUD.lua @@ -78,55 +78,142 @@ IceHUD.options = desc = 'Settings for bar transparencies', order = 12, args = { + headerAlpha = { + type = 'header', + name = "Bar Alpha", + order = 10 + }, + alphaic = { type = 'range', name = 'Alpha IC', desc = 'Bar alpha In Combat', get = function() - return IceHUD.IceCore:GetAlphaIC() + return IceHUD.IceCore:GetAlpha("IC") end, set = function(v) - IceHUD.IceCore:SetAlphaIC(v) + IceHUD.IceCore:SetAlpha("IC", v) end, min = 0, max = 1, step = 0.05, isPercent = true, - order = 14, + order = 11, }, alphaooc = { type = 'range', name = 'Alpha OOC', - desc = 'Bar alpha Out Of Combat', + desc = 'Bar alpha Out Of Combat without target', get = function() - return IceHUD.IceCore:GetAlphaOOC() + return IceHUD.IceCore:GetAlpha("OOC") end, set = function(v) - IceHUD.IceCore:SetAlphaOOC(v) + IceHUD.IceCore:SetAlpha("OOC", v) end, min = 0, max = 1, step = 0.05, isPercent = true, - order = 15, + order = 12, }, - alphabg = { + alphaTarget = { type = 'range', - name = 'Background Alpha', - desc = 'Background alpha for bars', + name = 'Alpha OOC and Target', + desc = 'Bar alpha Out Of Combat with target accuired', get = function() - return IceHUD.IceCore:GetAlphaBG() + return IceHUD.IceCore:GetAlpha("Target") end, set = function(v) - IceHUD.IceCore:SetAlphaBG(v) + IceHUD.IceCore:SetAlpha("Target", v) end, min = 0, max = 1, step = 0.05, isPercent = true, - order = 16, + order = 13, + }, + + + + headerAlphaBackgroundBlank = { type = 'header', name = " ", order = 20 }, + headerAlphaBackground = { + type = 'header', + name = "Background Alpha", + order = 20 + }, + + alphaicbg = { + type = 'range', + name = 'BG Alpha IC', + desc = 'Background alpha for bars IC', + get = function() + return IceHUD.IceCore:GetAlphaBG("IC") + end, + set = function(v) + IceHUD.IceCore:SetAlphaBG("IC", v) + end, + min = 0, + max = 1, + step = 0.05, + isPercent = true, + order = 21, + }, + + alphaoocbg = { + type = 'range', + name = 'BG Alpha OOC', + desc = 'Background alpha for bars OOC without target', + get = function() + return IceHUD.IceCore:GetAlphaBG("OOC") + end, + set = function(v) + IceHUD.IceCore:SetAlphaBG("OOC", v) + end, + min = 0, + max = 1, + step = 0.05, + isPercent = true, + order = 22, + }, + + alphaTargetbg = { + type = 'range', + name = 'BG Alpha OOC and Target', + desc = 'Background alpha for bars OOC and target accuired', + get = function() + return IceHUD.IceCore:GetAlphaBG("Target") + end, + set = function(v) + IceHUD.IceCore:SetAlphaBG("Target", v) + end, + min = 0, + max = 1, + step = 0.05, + isPercent = true, + order = 23, + }, + + + headerBarAdvancedBlank = { type = 'header', name = " ", order = 30 }, + headerBarAdvanced = { + type = 'header', + name = "Other", + order = 30 + }, + + backgroundToggle = { + type = "toggle", + name = "Contextual Background", + desc = "Toggles contextual background coloring", + get = function() + return IceHUD.IceCore:GetBackgroundToggle() + end, + set = function(value) + IceHUD.IceCore:SetBackgroundToggle(value) + end, + order = 31 }, backgroundColor = { @@ -139,85 +226,25 @@ IceHUD.options = set = function(r, g, b) IceHUD.IceCore:SetBackgroundColor(r, g, b) end, + order = 32, }, } }, textSettings = { - type = 'group', - name = 'Text Settings', - desc = 'Settings related to texts', - order = 15, - args = { - fontsize = { - type = 'range', - name = 'Bar Font Size', - desc = 'Bar Font Size', - get = function() - return IceHUD.IceCore:GetBarFontSize() - end, - set = function(v) - IceHUD.IceCore:SetBarFontSize(v) - end, - min = 8, - max = 20, - step = 1, - order = 11 - }, - - fontBold = { - type = 'toggle', - name = 'Bar Font Bold', - desc = 'Bar Font Bold', - get = function() - return IceHUD.IceCore:GetBarFontBold() - end, - set = function(v) - IceHUD.IceCore:SetBarFontBold(v) - end, - order = 12 - }, - - lockFontAlpha = { - type = "toggle", - name = "Lock Bar Text Alpha", - desc = "Lock Bar Text Alpha", - get = function() - return IceHUD.IceCore:GetLockTextAlpha() - end, - set = function(value) - IceHUD.IceCore:SetLockTextAlpha(value) - end, - order = 13 - }, - - upperTextVisible = { - type = 'toggle', - name = 'Upper text visible', - desc = 'Toggle upper text visibility', - get = function() - return IceHUD.IceCore:GetTextVisibility("upper") - end, - set = function(v) - IceHUD.IceCore:SetTextVisibility("upper", v) - end, - order = 14 - }, - - lowerTextVisible = { - type = 'toggle', - name = 'Lower text visible', - desc = 'Toggle lower text visibility', - get = function() - return IceHUD.IceCore:GetTextVisibility("lower") - end, - set = function(v) - IceHUD.IceCore:SetTextVisibility("lower", v) - end, - order = 15 - }, - } + type = 'text', + name = 'Font', + desc = 'IceHUD Font', + order = 19, + get = function() + return IceHUD.IceCore:GetFontFamily() + end, + set = function(value) + IceHUD.IceCore:SetFontFamily(value) + IceHUD.IceCore:Redraw() + end, + validate = { "IceHUD", "Default" }, }, barSettings = { @@ -356,7 +383,7 @@ IceHUD.options = enabled = { type = "toggle", - name = "|cff8888ffEnabled|r", + name = "|cff11aa11Enabled|r", desc = "Enable/disable IceHUD", get = function() return IceHUD.IceCore:IsEnabled() diff --git a/IceHUD.toc b/IceHUD.toc index a20ac8d..6762cf3 100644 --- a/IceHUD.toc +++ b/IceHUD.toc @@ -3,7 +3,7 @@ ## Name: IceHUD ## Title: IceHUD |cff7fff7f -Ace2-|r ## Notes: Another HUD mod -## Version: 0.4.1 ($Revision$) +## Version: 0.4.2 ($Revision$) ## SavedVariables: IceCoreDB ## OptionalDeps: FuBar_ToFu, DruidBar, SoleManax, MobHealth ## X-Category: UnitFrame @@ -21,8 +21,14 @@ libs\AceDebug-2.0\AceDebug-2.0.lua libs\AceLocale-2.0\AceLocale-2.0.lua libs\AceConsole-2.0\AceConsole-2.0.lua libs\AceAddon-2.0\AceAddon-2.0.lua +libs\Compost-2.0\Compost-2.0.lua libs\Metrognome-2.0\Metrognome-2.0.lua libs\Dewdrop-2.0\Dewdrop-2.0.lua +libs\Deformat-2.0\Deformat-2.0.lua +libs\Gratuity-2.0\Gratuity-2.0.lua +libs\SpellCache-1.0\SpellCache-1.0.lua +libs\SpellStatus-1.0\SpellStatus-1.0.lua + # IceHUD core functionality IceCore.lua diff --git a/modules/CastBar.lua b/modules/CastBar.lua index 1f677df..c18e49f 100644 --- a/modules/CastBar.lua +++ b/modules/CastBar.lua @@ -1,4 +1,5 @@ local AceOO = AceLibrary("AceOO-2.0") +local SpellCache = AceLibrary("SpellCache-1.0") local CastBar = AceOO.Class(IceBarElement) @@ -6,8 +7,10 @@ CastBar.prototype.casting = nil CastBar.prototype.channeling = nil CastBar.prototype.failing = nil CastBar.prototype.succeeding = nil +CastBar.prototype.instanting = nil CastBar.prototype.spellName = nil +CastBar.prototype.spellRank = nil CastBar.prototype.startTime = nil CastBar.prototype.castTime = nil @@ -35,7 +38,7 @@ function CastBar.prototype:GetDefaultSettings() local settings = CastBar.super.prototype.GetDefaultSettings(self) settings["side"] = IceCore.Side.Left settings["offset"] = 0 - settings["alwaysShowText"] = true + settings["showInstants"] = true return settings end @@ -43,20 +46,21 @@ end -- OVERRIDE function CastBar.prototype:GetOptions() local opts = CastBar.super.prototype.GetOptions(self) - opts["alwaysShowText"] = + + opts["showInstants"] = { type = 'toggle', - name = 'Always Show Text', - desc = 'Overrides possible text hiding option', + name = 'Show Instant Casts', + desc = 'Toggles showing instant spell names', get = function() - return self.moduleSettings.alwaysShowText + return self.moduleSettings.showInstants end, set = function(value) - self.moduleSettings.alwaysShowText = value - self:Redraw() + self.moduleSettings.showInstants = value end, order = 50 } + return opts end @@ -64,17 +68,17 @@ end function CastBar.prototype:Enable() CastBar.super.prototype.Enable(self) - self:RegisterEvent("SPELLCAST_START", "CastStart") - self:RegisterEvent("SPELLCAST_STOP", "CastStop") - self:RegisterEvent("SPELLCAST_FAILED", "CastFailed") - self:RegisterEvent("SPELLCAST_INTERRUPTED", "CastInterrupted") - - self:RegisterEvent("SPELLCAST_DELAYED", "CastDelayed") - - self:RegisterEvent("SPELLCAST_CHANNEL_START", "ChannelingStart") - self:RegisterEvent("SPELLCAST_CHANNEL_STOP", "ChannelingStop") - self:RegisterEvent("SPELLCAST_CHANNEL_UPDATE", "ChannelingUpdate") + self:RegisterEvent("SpellStatus_SpellCastInstant") + self:RegisterEvent("SpellStatus_SpellCastCastingStart") + self:RegisterEvent("SpellStatus_SpellCastCastingChange") + self:RegisterEvent("SpellStatus_SpellCastCastingFinish") + self:RegisterEvent("SpellStatus_SpellCastFailure") + self:RegisterEvent("SpellStatus_SpellCastChannelingStart") + self:RegisterEvent("SpellStatus_SpellCastChannelingChange") + self:RegisterEvent("SpellStatus_SpellCastChannelingFinish") + + self.frame:Hide() -- remove blizz cast bar @@ -99,17 +103,13 @@ end -- OVERRIDE function CastBar.prototype:Redraw() CastBar.super.prototype.Redraw(self) - - if (self.moduleSettings.alwaysShowText) then - self.frame.bottomUpperText:Show() - end - - end + -- 'Protected' methods -------------------------------------------------------- + -- OVERRIDE function CastBar.prototype:CreateFrame() CastBar.super.prototype.CreateFrame(self) @@ -140,7 +140,9 @@ function CastBar.prototype:OnUpdate() end self:UpdateBar(scale, "castCasting") - self:SetBottomText1(remaining .. "s " .. self.spellName) + + self.spellName = self.spellName or '' + self:SetBottomText1(remaining .. "s " .. self.spellName .. self:FormatRank(self.spellRank)) elseif (self.failing) then self.alpha = 0.7 @@ -165,6 +167,22 @@ function CastBar.prototype:OnUpdate() self.frame:Hide() self.frame:SetScript("OnUpdate", nil) end + + elseif (self.instanting) then + self:UpdateBar(1, "castSuccess", 1-scale) + self.frame.bg:Hide() + self.barFrame:Hide() + + self.spellName = self.spellName or '' + self:SetBottomText1(self.spellName .. self:FormatRank(self.spellRank)) + + if (scale >= 1) then + self.frame.bg:Show() + self.barFrame:Show() + + self:CleanUp() + self.frame:SetScript("OnUpdate", nil) + end else -- shouldn't be needed self:CleanUp() @@ -175,26 +193,83 @@ end -function CastBar.prototype:CastStart(name, castTime) - self.spellName = name - self.castTime = castTime / 1000 - self.startTime = GetTime() +function CastBar.prototype:CleanUp() + self.spellName = nil + self.spellRank = nil + self.castTime = nil + self.startTime = nil self.delay = 0 - self.casting = true + self.casting = false + self.channeling = false + self.failing = false + self.succeeding = false + self.instanting = false + self:SetBottomText1() + self.alpha = self.settings.alphaooc +end + + +function CastBar.prototype:FormatRank(rank) + if (rank) then + return " (" .. rank .. ")" + else + return "" + end +end + + + +------------------------------------------------------------------------------- +-- INSTANT SPELLS -- +------------------------------------------------------------------------------- + +function CastBar.prototype:SpellStatus_SpellCastInstant(sId, sName, sRank, sFullName, sCastTime) + IceHUD:Debug("SpellStatus_SpellCastInstant", sId, sName, sRank, sFullName, sCastTime) + + if not (self.moduleSettings.showInstants) then + return + end + + self:CleanUp() + + self.spellName = sName + self.spellRank = SpellCache:GetRankNumber(sRank or '') + self.castTime = 1 + self.startTime = GetTime() + self.instanting = true self.frame:Show() - self.frame:SetScript("OnUpdate", function() self:OnUpdate() end) end -function CastBar.prototype:CastStop() - if not (self.casting) then - return - end + + +------------------------------------------------------------------------------- +-- NORMAL SPELLS -- +------------------------------------------------------------------------------- + +function CastBar.prototype:SpellStatus_SpellCastCastingStart(sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration) + IceHUD:Debug("SpellStatus_SpellCastCastingStart", sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration) + + self.spellName = sName + self.spellRank = SpellCache:GetRankNumber(sRank or '') + + self.castTime = sCastDuration / 1000 + self.startTime = sCastStartTime + self.delay = 0 + self.casting = true + + self.frame:Show() + self.frame:SetScript("OnUpdate", function() self:OnUpdate() end) +end + + +function CastBar.prototype:SpellStatus_SpellCastCastingFinish (sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration, sCastDelayTotal) + IceHUD:Debug("SpellStatus_SpellCastCastingFinish ", sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration, sCastDelayTotal) + self:CleanUp() - self.spellName = nil self.castTime = 1 self.startTime = GetTime() self.succeeding = true @@ -203,23 +278,22 @@ function CastBar.prototype:CastStop() end -function CastBar.prototype:CastFailed() - self:CastTerminated("Failed") +function CastBar.prototype:SpellStatus_SpellCastCastingChange(sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration, sCastDelay, sCastDelayTotal) + IceHUD:Debug("SpellStatus_SpellCastCastingChange", sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration, sCastDelay, sCastDelayTotal) + self.delay = sCastDelayTotal end -function CastBar.prototype:CastInterrupted() - self:CastTerminated("Interrupted") -end - - -function CastBar.prototype:CastTerminated(reason) - if not (self.casting or self.channeling or self.succeeding) then +function CastBar.prototype:SpellStatus_SpellCastFailure(sId, sName, sRank, sFullName, isActiveSpell, UIEM_Message, CMSFLP_SpellName, CMSFLP_Message) + IceHUD:Debug("SpellStatus_SpellCastFailure", sId, sName, sRank, sFullName, isActiveSpell, UIEM_Message, CMSFLP_SpellName, CMSFLP_Message) + + if (not (isActiveSpell) or not (self.casting or self.channeling)) then return end + self:CleanUp() - self.spellName = reason + self.spellName = UIEM_Message self.castTime = 1 self.startTime = GetTime() self.failing = true @@ -228,17 +302,22 @@ function CastBar.prototype:CastTerminated(reason) end -function CastBar.prototype:CastDelayed(delay) - self.delay = self.delay + (delay / 1000) -end -function CastBar.prototype:ChannelingStart(duration, spell) - self.spellName = spell - self.castTime = duration / 1000 - self.startTime = GetTime() + +------------------------------------------------------------------------------- +-- CHANNELING SPELLS -- +------------------------------------------------------------------------------- + +function CastBar.prototype:SpellStatus_SpellCastChannelingStart(sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration, sAction) + IceHUD:Debug("SpellStatus_SpellCastChannelingStart", sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration, sAction) + + self.spellName = sName + self.spellRank = SpellCache:GetRankNumber(sRank or '') + self.castTime = sCastDuration + self.startTime = sCastStartTime self.delay = 0 self.channeling = true @@ -248,30 +327,27 @@ function CastBar.prototype:ChannelingStart(duration, spell) end -function CastBar.prototype:ChannelingStop() +function CastBar.prototype:SpellStatus_SpellCastChannelingFinish(sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration, sAction, sCastDisruptionTotal) + IceHUD:Debug("SpellStatus_SpellCastChannelingFinish", sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration, sAction, sCastDisruptionTotal) + self:CleanUp() self.frame:Hide() end -function CastBar.prototype:ChannelingUpdate(duration) - self.castTime = duration / 1000 +function CastBar.prototype:SpellStatus_SpellCastChannelingChange(sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration, sAction, sCastDisruption, sCastDisruptionTotal) + IceHUD:Debug("SpellStatus_SpellCastChannelingChange", sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration, sAction, sCastDisruption, sCastDisruptionTotal) + self.castTime = sCastDuration / 1000 end -function CastBar.prototype:CleanUp() - self.spellName = nil - self.castTime = nil - self.startTime = nil - self.delay = 0 - self.casting = false - self.channeling = false - self.failing = false - self.succeeding = false - self:SetBottomText1() - self.alpha = self.settings.alphaooc -end + + + + + + -- Load us up diff --git a/modules/DruidMana.lua b/modules/DruidMana.lua index 4f9b23b..fa20386 100644 --- a/modules/DruidMana.lua +++ b/modules/DruidMana.lua @@ -5,8 +5,8 @@ local DruidMana = AceOO.Class(IceUnitBar) DruidMana.prototype.inForms = nil DruidMana.prototype.mode = nil -DruidMana.prototype.mana = nil -DruidMana.prototype.maxMana = nil +DruidMana.prototype.druidMana = nil +DruidMana.prototype.druidMaxMana = nil -- Constructor -- @@ -71,20 +71,21 @@ end function DruidMana.prototype:UpdateSoleManax(mana, maxMana) - self.mana = mana - self.maxMana = maxMana self:Update() + self.druidMana = mana + self.druidMaxMana = maxMana end function DruidMana.prototype:UpdateDruidBarMana() - self.mana = DruidBarKey.keepthemana - self.maxMana = DruidBarKey.maxmana self:Update() + self.druidMana = DruidBarKey.keepthemana + self.druidMaxMana = DruidBarKey.maxmana end function DruidMana.prototype:Update() + DruidMana.super.prototype.Update(self) if ((not self.alive) or (not self.inForms)) then self.frame:Hide() return @@ -94,9 +95,9 @@ function DruidMana.prototype:Update() local color = "druidMana" - self:UpdateBar(self.mana / self.maxMana, color) + self:UpdateBar(self.druidMana / self.druidMaxMana, color) - local percentage = (self.mana / self.maxMana) * 100 + local percentage = (self.druidMana / self.druidMaxMana) * 100 self:SetBottomText1(math.floor(percentage)) end diff --git a/modules/MirrorBar.lua b/modules/MirrorBar.lua index 8a2ab42..33aef7a 100644 --- a/modules/MirrorBar.lua +++ b/modules/MirrorBar.lua @@ -48,6 +48,16 @@ function MirrorBar.prototype:Enable() end +-- OVERRIDE +function MirrorBar.prototype:Create(parent) + MirrorBar.super.prototype.Create(self, parent) + + if (self.timer) then + self.frame:Show() + end +end + + function MirrorBar.prototype:OnUpdate(elapsed) if (self.paused) then return @@ -96,6 +106,7 @@ function MirrorBar.prototype:MirrorStart(timer, value, maxValue, scale, paused, self.startTime = GetTime() + self:Update() self.frame:Show() self.frame:SetScript("OnUpdate", function() self:OnUpdate(arg1) end) end @@ -160,6 +171,10 @@ function MirrorBarHandler.prototype:GetDefaultSettings() local settings = MirrorBarHandler.super.prototype.GetDefaultSettings(self) settings["side"] = IceCore.Side.Left settings["offset"] = 3 + settings["barFontSize"] = 13 + settings["barFontBold"] = true + settings["lockTextAlpha"] = true + settings["textVisible"] = {upper = true, lower = true} return settings end @@ -171,7 +186,7 @@ function MirrorBarHandler.prototype:GetOptions() opts["side"] = { type = 'text', - name = 'Side', + name = '|c' .. self.configColor .. 'Side|r', desc = 'Side of the HUD where the bar appears', get = function() if (self.moduleSettings.side == IceCore.Side.Right) then @@ -195,7 +210,7 @@ function MirrorBarHandler.prototype:GetOptions() opts["offset"] = { type = 'range', - name = 'Offset', + name = '|c' .. self.configColor .. 'Offset|r', desc = 'Offset of the bar', min = -1, max = 10, @@ -209,7 +224,89 @@ function MirrorBarHandler.prototype:GetOptions() end, order = 31 } - + + opts["textSettings"] = + { + type = 'group', + name = '|c' .. self.configColor .. 'Text Settings|r', + desc = 'Settings related to texts', + order = 32, + args = { + fontsize = { + type = 'range', + name = 'Bar Font Size', + desc = 'Bar Font Size', + get = function() + return self.moduleSettings.barFontSize + end, + set = function(v) + self.moduleSettings.barFontSize = v + self:Redraw() + end, + min = 8, + max = 20, + step = 1, + order = 11 + }, + + fontBold = { + type = 'toggle', + name = 'Bar Font Bold', + desc = 'If you have game default font selected, this option has no effect', + get = function() + return self.moduleSettings.barFontBold + end, + set = function(v) + self.moduleSettings.barFontBold = v + self:Redraw() + end, + order = 12 + }, + + lockFontAlpha = { + type = "toggle", + name = "Lock Bar Text Alpha", + desc = "Locks upper text alpha to 100%", + get = function() + return self.moduleSettings.lockTextAlpha + end, + set = function(v) + self.moduleSettings.lockTextAlpha = v + self:Redraw() + end, + order = 13 + }, + + upperTextVisible = { + type = 'toggle', + name = 'Upper text visible', + desc = 'Toggle upper text visibility', + get = function() + return self.moduleSettings.textVisible['upper'] + end, + set = function(v) + self.moduleSettings.textVisible['upper'] = v + self:Redraw() + end, + order = 14 + }, + + lowerTextVisible = { + type = 'toggle', + name = 'Lower text visible', + desc = 'Toggle lower text visibility', + get = function() + return self.moduleSettings.textVisible['lower'] + end, + set = function(v) + self.moduleSettings.textVisible['lower'] = v + self:Redraw() + end, + order = 15 + }, + } + } + return opts end @@ -236,6 +333,7 @@ function MirrorBarHandler.prototype:Redraw() MirrorBarHandler.super.prototype.Redraw(self) for i = 1, table.getn(self.bars) do + self:SetSettings(self.bars[i]) self.bars[i]:UpdatePosition(self.moduleSettings.side, self.moduleSettings.offset + (i-1)) self.bars[i]:Create(self.parent) end @@ -267,6 +365,7 @@ function MirrorBarHandler.prototype:MirrorStart(timer, value, maxValue, scale, p if not (done) then local count = table.getn(self.bars) self.bars[count + 1] = MirrorBar:new(self.moduleSettings.side, self.moduleSettings.offset + count, "MirrorBar" .. tostring(count+1), self.settings) + self:SetSettings(self.bars[count+1]) self.bars[count + 1]:Create(self.parent) self.bars[count + 1]:Enable() self.bars[count + 1]:MirrorStart(timer, value, maxValue, scale, paused, label) @@ -293,6 +392,16 @@ end +function MirrorBarHandler.prototype:SetSettings(bar) + bar.moduleSettings.barFontSize = self.moduleSettings.barFontSize + bar.moduleSettings.barFontBold = self.moduleSettings.barFontBold + bar.moduleSettings.lockTextAlpha = self.moduleSettings.lockTextAlpha + bar.moduleSettings.textVisible = self.moduleSettings.textVisible +end + + + + -- Load us up MirrorBarHandler:new() diff --git a/modules/PetHealth.lua b/modules/PetHealth.lua index 0b44638..ee21071 100644 --- a/modules/PetHealth.lua +++ b/modules/PetHealth.lua @@ -38,7 +38,7 @@ function PetHealth.prototype:GetOptions() self.moduleSettings.scale = value self:Redraw() end, - order = 31 + order = 51 } return opts end diff --git a/modules/PetMana.lua b/modules/PetMana.lua index a5b86aa..ffde534 100644 --- a/modules/PetMana.lua +++ b/modules/PetMana.lua @@ -32,7 +32,7 @@ function PetMana.prototype:GetOptions() self.moduleSettings.scale = value self:Redraw() end, - order = 31 + order = 51 } return opts end diff --git a/modules/PlayerMana.lua b/modules/PlayerMana.lua index ac34c3a..9e7a5f7 100644 --- a/modules/PlayerMana.lua +++ b/modules/PlayerMana.lua @@ -22,7 +22,7 @@ function PlayerMana.prototype:GetDefaultSettings() settings["side"] = IceCore.Side.Right settings["offset"] = 1 settings["tickerEnabled"] = true - settings["tickerAlpha"] = 0.8 + settings["tickerAlpha"] = 0.5 return settings end @@ -42,7 +42,7 @@ function PlayerMana.prototype:GetOptions() self.moduleSettings.tickerEnabled = value self:ManaType(self.unit) end, - order = 31 + order = 51 } opts["tickerAlpha"] = @@ -60,7 +60,7 @@ function PlayerMana.prototype:GetOptions() self.moduleSettings.tickerAlpha = value self.tickerFrame:SetStatusBarColor(self:GetColor("playerEnergy", self.moduleSettings.tickerAlpha)) end, - order = 32 + order = 52 } return opts diff --git a/modules/TargetHealth.lua b/modules/TargetHealth.lua index efac013..d311811 100644 --- a/modules/TargetHealth.lua +++ b/modules/TargetHealth.lua @@ -54,8 +54,7 @@ function TargetHealth.prototype:Enable() self:RegisterEvent("UNIT_HEALTH", "Update") self:RegisterEvent("UNIT_MAXHEALTH", "Update") - self:RegisterEvent("PLAYER_TARGET_CHANGED", "TargetChanged") - + self:Update(self.unit) end @@ -65,10 +64,6 @@ function TargetHealth.prototype:Disable() end -function TargetHealth.prototype:TargetChanged() - self:Update(self.unit) -end - function TargetHealth.prototype:Update(unit) TargetHealth.super.prototype.Update(self) diff --git a/modules/TargetMana.lua b/modules/TargetMana.lua index f3044f3..263ebda 100644 --- a/modules/TargetMana.lua +++ b/modules/TargetMana.lua @@ -33,16 +33,10 @@ function TargetMana.prototype:Enable() self:RegisterEvent("UNIT_MAXENERGY", "Update") self:RegisterEvent("UNIT_AURA", "Update") - self:RegisterEvent("PLAYER_TARGET_CHANGED", "TargetChanged") - self:Update("target") end -function TargetMana.prototype:TargetChanged() - self:Update("target") -end - function TargetMana.prototype:Update(unit) TargetMana.super.prototype.Update(self) diff --git a/modules/TimerBar.lua b/modules/TimerBar.lua index f421948..55bb99f 100644 --- a/modules/TimerBar.lua +++ b/modules/TimerBar.lua @@ -15,8 +15,8 @@ end function TimerBar.prototype:GetDefaultSettings() local settings = TimerBar.super.prototype.GetDefaultSettings(self) - settings["side"] = IceCore.Side.Left - settings["offset"] = 0 + settings["side"] = IceCore.Side.Right + settings["offset"] = 3 return settings end