From e2bce8cdaefe53265770068c6830a638e87f64b9 Mon Sep 17 00:00:00 2001 From: Parnic Date: Mon, 25 Oct 2010 06:09:48 +0000 Subject: [PATCH] - attempt at auto-removing sunder/lacerate/maelstrom modules on load if the player has them enabled. this will automatically create a custom counter behind the scenes since those are much more fully-featured --- IceCore.lua | 116 +++++++++++++ IceHUD.toc | 3 - modules/LacerateCount.lua | 333 ------------------------------------- modules/MaelstromCount.lua | 308 ---------------------------------- modules/SunderCount.lua | 312 ---------------------------------- 5 files changed, 116 insertions(+), 956 deletions(-) delete mode 100644 modules/LacerateCount.lua delete mode 100644 modules/MaelstromCount.lua delete mode 100644 modules/SunderCount.lua diff --git a/IceCore.lua b/IceCore.lua index 57a951f..c94f11f 100644 --- a/IceCore.lua +++ b/IceCore.lua @@ -34,6 +34,10 @@ IceCore.prototype.enabled = nil IceCore.prototype.presets = {} IceCore.prototype.bConfigMode = false +local SUNDER_SPELL_ID = 7386 +local LACERATE_SPELL_ID = 33745 +local MAELSTROM_SPELL_ID = 53817 + -- Constructor -- function IceCore.prototype:init() IceHUD:Debug("IceCore.prototype:init()") @@ -207,12 +211,124 @@ function IceCore.prototype:Enable(userToggle) self.settings.updatePeriod = 0.033 end + self:RedirectRemovedModules() + -- make sure the module options are re-generated. if we switched profiles, we don't want the old elements hanging around IceHUD:GenerateModuleOptions() self.enabled = true end +function IceCore.prototype:RedirectRemovedModules() + local _, class = UnitClass("player") + if class == "WARRIOR" and self.settings.modules["SunderCount"] then + if self.settings.modules["SunderCount"].enabled or self.settings.modules["SunderCount"].enabled == nil then + local bFound = false + + for k,v in pairs(self.elements) do + if v.moduleSettings.customBarType == "Counter" + and string.upper(v.moduleSettings.auraName) == string.upper(GetSpellInfo(SUNDER_SPELL_ID)) then + bFound = true + break + end + end + + if not bFound then + local newCounter + newCounter = IceCustomCount:new() + newCounter.elementName = "Sunders" + self.settings.modules[newCounter.elementName] = newCounter:GetDefaultSettings() + self:AddNewDynamicModule(newCounter, true) + + newCounter.moduleSettings.alwaysFullAlpha = self.settings.modules["SunderCount"].alwaysFullAlpha or newCounter.moduleSettings.alwaysFullAlpha + newCounter.moduleSettings.scale = self.settings.modules["SunderCount"].scale or newCounter.moduleSettings.scale + newCounter.moduleSettings.vpos = self.settings.modules["SunderCount"].vpos or newCounter.moduleSettings.vpos + newCounter.moduleSettings.countFontSize = self.settings.modules["SunderCount"].sunderFontSize or newCounter.moduleSettings.countFontSize + newCounter.moduleSettings.countMode = self.settings.modules["SunderCount"].sunderMode or newCounter.moduleSettings.countMode + newCounter.moduleSettings.countGap = self.settings.modules["SunderCount"].sunderGap or newCounter.moduleSettings.countGap + newCounter.moduleSettings.gradient = self.settings.modules["SunderCount"].gradient or newCounter.moduleSettings.gradient + newCounter.moduleSettings.maxCount = 3 + newCounter.moduleSettings.auraTarget = "target" + newCounter.moduleSettings.auraType = "debuff" + newCounter.moduleSettings.auraName = GetSpellInfo(SUNDER_SPELL_ID) + newCounter:Enable() + end + end + + self.settings.modules["SunderCount"] = nil + end + + if class == "DRUID" and self.settings.modules["LacerateCount"] then + if self.settings.modules["LacerateCount"].enabled or self.settings.modules["LacerateCount"].enabled == nil then + local bFound = false + for k,v in pairs(self.elements) do + if v.moduleSettings.customBarType == "Counter" + and string.upper(v.moduleSettings.auraName) == string.upper(GetSpellInfo(LACERATE_SPELL_ID)) then + bFound = true + break + end + end + + if not bFound then + local newCounter + newCounter = IceCustomCount:new() + newCounter.elementName = "Lacerates" + self.settings.modules[newCounter.elementName] = newCounter:GetDefaultSettings() + self:AddNewDynamicModule(newCounter, true) + + newCounter.moduleSettings.alwaysFullAlpha = self.settings.modules["LacerateCount"].alwaysFullAlpha or newCounter.moduleSettings.alwaysFullAlpha + newCounter.moduleSettings.scale = self.settings.modules["LacerateCount"].scale or newCounter.moduleSettings.scale + newCounter.moduleSettings.vpos = self.settings.modules["LacerateCount"].vpos or newCounter.moduleSettings.vpos + newCounter.moduleSettings.hpos = self.settings.modules["LacerateCount"].hpos or newCounter.moduleSettings.hpos + newCounter.moduleSettings.countFontSize = self.settings.modules["LacerateCount"].lacerateFontSize or newCounter.moduleSettings.countFontSize + newCounter.moduleSettings.countMode = self.settings.modules["LacerateCount"].lacerateMode or newCounter.moduleSettings.countMode + newCounter.moduleSettings.countGap = self.settings.modules["LacerateCount"].lacerateGap or newCounter.moduleSettings.countGap + newCounter.moduleSettings.gradient = self.settings.modules["LacerateCount"].gradient or newCounter.moduleSettings.gradient + newCounter.moduleSettings.maxCount = 3 + newCounter.moduleSettings.auraTarget = "target" + newCounter.moduleSettings.auraType = "debuff" + newCounter.moduleSettings.auraName = GetSpellInfo(LACERATE_SPELL_ID) + newCounter:Enable() + end + end + + self.settings.modules["LacerateCount"] = nil + end + + if class == "SHAMAN" and self.settings.modules["MaelstromCount"] then + if self.settings.modules["MaelstromCount"].enabled or self.settings.modules["MaelstromCount"].enabled == nil then + local bFound = false + for k,v in pairs(self.elements) do + if v.moduleSettings.customBarType == "Counter" + and string.upper(v.moduleSettings.auraName) == string.upper(GetSpellInfo(MAELSTROM_SPELL_ID)) then + bFound = true + break + end + end + + if not bFound then + local newCounter + newCounter = IceCustomCount:new() + newCounter.elementName = "Maelstroms" + self.settings.modules[newCounter.elementName] = newCounter:GetDefaultSettings() + self:AddNewDynamicModule(newCounter, true) + + newCounter.moduleSettings.alwaysFullAlpha = self.settings.modules["MaelstromCount"].alwaysFullAlpha or newCounter.moduleSettings.alwaysFullAlpha + newCounter.moduleSettings.scale = self.settings.modules["MaelstromCount"].scale or newCounter.moduleSettings.scale + newCounter.moduleSettings.vpos = self.settings.modules["MaelstromCount"].vpos or newCounter.moduleSettings.vpos + newCounter.moduleSettings.countFontSize = self.settings.modules["MaelstromCount"].maelstromFontSize or newCounter.moduleSettings.countFontSize + newCounter.moduleSettings.countMode = self.settings.modules["MaelstromCount"].maelstromMode or newCounter.moduleSettings.countMode + newCounter.moduleSettings.countGap = self.settings.modules["MaelstromCount"].maelstromGap or newCounter.moduleSettings.countGap + newCounter.moduleSettings.gradient = self.settings.modules["MaelstromCount"].gradient or newCounter.moduleSettings.gradient + newCounter.moduleSettings.auraName = GetSpellInfo(MAELSTROM_SPELL_ID) + newCounter:Enable() + end + end + + self.settings.modules["MaelstromCount"] = nil + end +end + function IceCore.prototype:AddNewDynamicModule(module, hasSettings) if not hasSettings then diff --git a/IceHUD.toc b/IceHUD.toc index e3b4711..614f274 100644 --- a/IceHUD.toc +++ b/IceHUD.toc @@ -42,7 +42,6 @@ modules\ComboPoints.lua modules\CastBar.lua modules\TargetCast.lua modules\MirrorBar.lua -modules\SunderCount.lua modules\GlobalCoolDown.lua modules\SliceAndDice.lua modules\TargetCC.lua @@ -51,7 +50,6 @@ modules\FocusCC.lua modules\FocusHealth.lua modules\FocusMana.lua modules\FocusCast.lua -modules\LacerateCount.lua modules\Runes.lua # - make sure TargetOfTarget health/mana load after TargetHealth/TargetMana since they inherit modules\TargetOfTargetHealth.lua @@ -59,7 +57,6 @@ modules\TargetOfTargetMana.lua modules\Threat.lua modules\FocusThreat.lua modules\RangeCheck.lua -modules\MaelstromCount.lua modules\CustomBar.lua modules\CustomCount.lua # - make sure PlayerInfo loads after TargetInfo since it inherits diff --git a/modules/LacerateCount.lua b/modules/LacerateCount.lua deleted file mode 100644 index 21c56bd..0000000 --- a/modules/LacerateCount.lua +++ /dev/null @@ -1,333 +0,0 @@ -local L = LibStub("AceLocale-3.0"):GetLocale("IceHUD", false) -local LacerateCount = IceCore_CreateClass(IceElement) - -local IceHUD = _G.IceHUD - -LacerateCount.prototype.lacerateSize = 20 -LacerateCount.prototype.numLacerates = 3 - --- Constructor -- -function LacerateCount.prototype:init() - LacerateCount.super.prototype.init(self, "LacerateCount") - - self:SetDefaultColor("LacerateCount", 1, 1, 0) - self.scalingEnabled = true -end - - - --- 'Public' methods ----------------------------------------------------------- - - --- OVERRIDE -function LacerateCount.prototype:GetOptions() - local opts = LacerateCount.super.prototype.GetOptions(self) - - opts["vpos"] = { - type = "range", - name = L["Vertical Position"], - desc = L["Vertical Position"], - get = function() - return self.moduleSettings.vpos - end, - set = function(info, v) - self.moduleSettings.vpos = v - self:Redraw() - end, - min = -300, - max = 200, - step = 1, - disabled = function() - return not self.moduleSettings.enabled - end, - order = 31 - } - - opts["hpos"] = { - type = "range", - name = L["Horizontal Position"], - desc = L["Horizontal Position"], - get = function() - return self.moduleSettings.hpos - end, - set = function(info, v) - self.moduleSettings.hpos = v - self:Redraw() - end, - min = -700, - max = 700, - step = 1, - disabled = function() - return not self.moduleSettings.enabled - end, - order = 31 - } - - opts["lacerateFontSize"] = { - type = "range", - name = L["Lacerate Count Font Size"], - desc = L["Lacerate Count Font Size"], - get = function() - return self.moduleSettings.lacerateFontSize - end, - set = function(info, v) - self.moduleSettings.lacerateFontSize = v - self:Redraw() - end, - min = 10, - max = 40, - step = 1, - disabled = function() - return not self.moduleSettings.enabled - end, - order = 32 - } - - opts["lacerateMode"] = { - type = 'select', - name = L["Display Mode"], - desc = L["Show graphical or numeric lacerates"], - get = function(info) - return IceHUD:GetSelectValue(info, self.moduleSettings.lacerateMode) - end, - set = function(info, v) - self.moduleSettings.lacerateMode = info.option.values[v] - self:CreateLacerateFrame(true) - self:Redraw() - IceHUD:NotifyOptionsChange() - end, - values = { "Numeric", "Graphical Bar", "Graphical Circle", "Graphical Glow", "Graphical Clean Circle" }, - disabled = function() - return not self.moduleSettings.enabled - end, - order = 33 - } - - opts["lacerateGap"] = { - type = 'range', - name = L["Lacerate gap"], - desc = L["Spacing between each lacerate count (only works for graphical mode)"], - min = 0, - max = 100, - step = 1, - get = function() - return self.moduleSettings.lacerateGap - end, - set = function(info, v) - self.moduleSettings.lacerateGap = v - self:Redraw() - end, - disabled = function() - return not self.moduleSettings.enabled or self.moduleSettings.lacerateMode == "Numeric" - end, - order = 33.2 - } - - opts["gradient"] = { - type = "toggle", - name = L["Change color"], - desc = L["1 lacerate: yellow, 5 lacerates: red"], - get = function() - return self.moduleSettings.gradient - end, - set = function(info, v) - self.moduleSettings.gradient = v - self:Redraw() - end, - disabled = function() - return not self.moduleSettings.enabled - end, - order = 34 - } - - opts.gradient.desc = string.gsub(opts.gradient.desc, "5", tostring(self.numLacerates)) - - return opts -end - - --- OVERRIDE -function LacerateCount.prototype:GetDefaultSettings() - local defaults = LacerateCount.super.prototype.GetDefaultSettings(self) - defaults["vpos"] = -20 - defaults["hpos"] = 0 - defaults["lacerateFontSize"] = 20 - defaults["lacerateMode"] = "Numeric" - defaults["gradient"] = false - defaults["usesDogTagStrings"] = false - defaults["alwaysFullAlpha"] = true - defaults["lacerateGap"] = 0 - return defaults -end - - --- OVERRIDE -function LacerateCount.prototype:Redraw() - LacerateCount.super.prototype.Redraw(self) - - self:CreateFrame() - self:UpdateLacerateCount() -end - - --- OVERRIDE -function LacerateCount.prototype:Enable(core) - LacerateCount.super.prototype.Enable(self, core) - - self:RegisterEvent("PLAYER_TARGET_CHANGED", "UpdateLacerateCount") - self:RegisterEvent("UNIT_AURA", "UpdateLacerateCount") - - if self.moduleSettings.lacerateMode == "Graphical" then - self.moduleSettings.lacerateMode = "Graphical Bar" - end - - self:CreateLacerateFrame(true) -end - - - --- 'Protected' methods -------------------------------------------------------- - --- OVERRIDE -function LacerateCount.prototype:CreateFrame() - LacerateCount.super.prototype.CreateFrame(self) - - self.frame:SetFrameStrata("BACKGROUND") - self.frame:SetWidth(self.lacerateSize*self.numLacerates) - self.frame:SetHeight(1) - self.frame:ClearAllPoints() - self.frame:SetPoint("TOP", self.parent, "BOTTOM", self.moduleSettings.hpos, self.moduleSettings.vpos) - - self:Show(true) - - self:CreateLacerateFrame() -end - - - -function LacerateCount.prototype:CreateLacerateFrame(doTextureUpdate) - -- create numeric lacerates - self.frame.numeric = self:FontFactory(self.moduleSettings.lacerateFontSize, nil, self.frame.numeric) - - self.frame.numeric:SetWidth(50) - self.frame.numeric:SetJustifyH("CENTER") - - self.frame.numeric:SetPoint("TOP", self.frame, "TOP", 0, 0) - self.frame.numeric:Show() - - if (not self.frame.graphicalBG) then - self.frame.graphicalBG = {} - self.frame.graphical = {} - end - - -- create backgrounds - for i = 1, self.numLacerates do - if (not self.frame.graphicalBG[i]) then - local frame = CreateFrame("Frame", nil, self.frame) - self.frame.graphicalBG[i] = frame - frame.texture = frame:CreateTexture() - frame.texture:SetAllPoints(frame) - end - - if doTextureUpdate then - if self.moduleSettings.lacerateMode == "Graphical Bar" then - self.frame.graphicalBG[i].texture:SetTexture(IceElement.TexturePath .. "ComboBG") - elseif self.moduleSettings.lacerateMode == "Graphical Circle" then - self.frame.graphicalBG[i].texture:SetTexture(IceElement.TexturePath .. "ComboRoundBG") - elseif self.moduleSettings.lacerateMode == "Graphical Glow" then - self.frame.graphicalBG[i].texture:SetTexture(IceElement.TexturePath .. "ComboGlowBG") - elseif self.moduleSettings.lacerateMode == "Graphical Clean Circle" then - self.frame.graphicalBG[i].texture:SetTexture(IceElement.TexturePath .. "ComboCleanCurvesBG") - end - end - - self.frame.graphicalBG[i]:SetFrameStrata("BACKGROUND") - self.frame.graphicalBG[i]:SetWidth(self.lacerateSize) - self.frame.graphicalBG[i]:SetHeight(self.lacerateSize) - self.frame.graphicalBG[i]:SetPoint("TOPLEFT", (i-1) * (self.lacerateSize-5) + (i-1) + ((i-1) * self.moduleSettings.lacerateGap), 0) - self.frame.graphicalBG[i]:SetAlpha(0.15) - self.frame.graphicalBG[i].texture:SetVertexColor(self:GetColor("LacerateCount")) - - self.frame.graphicalBG[i]:Hide() - end - - -- create lacerates - for i = 1, self.numLacerates do - if (not self.frame.graphical[i]) then - local frame = CreateFrame("Frame", nil, self.frame) - self.frame.graphical[i] = frame - frame.texture = frame:CreateTexture() - frame.texture:SetAllPoints(frame) - end - - if doTextureUpdate then - if self.moduleSettings.lacerateMode == "Graphical Bar" then - self.frame.graphical[i].texture:SetTexture(IceElement.TexturePath .. "Combo") - elseif self.moduleSettings.lacerateMode == "Graphical Circle" then - self.frame.graphical[i].texture:SetTexture(IceElement.TexturePath .. "ComboRound") - elseif self.moduleSettings.lacerateMode == "Graphical Glow" then - self.frame.graphical[i].texture:SetTexture(IceElement.TexturePath .. "ComboGlow") - elseif self.moduleSettings.lacerateMode == "Graphical Clean Circle" then - self.frame.graphical[i].texture:SetTexture(IceElement.TexturePath .. "ComboCleanCurves") - end - end - - self.frame.graphical[i]:SetFrameStrata("BACKGROUND") - self.frame.graphical[i]:SetAllPoints(self.frame.graphicalBG[i]) - - local r, g, b = self:GetColor("LacerateCount") - if (self.moduleSettings.gradient) then - g = g - ((0.75 / self.numLacerates) * i) - end - self.frame.graphical[i].texture:SetVertexColor(r, g, b) - - self.frame.graphical[i]:Hide() - end -end - - -function LacerateCount.prototype:UpdateLacerateCount() - local points - if IceHUD.IceCore:IsInConfigMode() then - points = self.numLacerates - else - points = IceHUD:GetDebuffCount("target", "Ability_Druid_Lacerate", true) - end - - if (points == 0) then - points = nil - end - - if (self.moduleSettings.lacerateMode == "Numeric") then - local r, g, b = self:GetColor("LacerateCount") - if (self.moduleSettings.gradient and points) then - g = g - ((0.75 / self.numLacerates) * points) - end - self.frame.numeric:SetTextColor(r, g, b, 0.7) - - self.frame.numeric:SetText(points) - else - self.frame.numeric:SetText() - - for i = 1, table.getn(self.frame.graphical) do - if (points ~= nil) then - self.frame.graphicalBG[i]:Show() - else - self.frame.graphicalBG[i]:Hide() - end - - if (points ~= nil and i <= points) then - self.frame.graphical[i]:Show() - else - self.frame.graphical[i]:Hide() - end - end - end -end - - --- Load us up -local _, unitClass = UnitClass("player") -if (unitClass == "DRUID") then - IceHUD.LacerateCount = LacerateCount:new() -end diff --git a/modules/MaelstromCount.lua b/modules/MaelstromCount.lua deleted file mode 100644 index 0f51904..0000000 --- a/modules/MaelstromCount.lua +++ /dev/null @@ -1,308 +0,0 @@ -local L = LibStub("AceLocale-3.0"):GetLocale("IceHUD", false) -local MaelstromCount = IceCore_CreateClass(IceElement) - -local IceHUD = _G.IceHUD - -MaelstromCount.prototype.maelstromSize = 20 - --- Constructor -- -function MaelstromCount.prototype:init() - MaelstromCount.super.prototype.init(self, "MaelstromCount") - - self:SetDefaultColor("MaelstromCount", 1, 1, 0) - self.scalingEnabled = true -end - - - --- 'Public' methods ----------------------------------------------------------- - - --- OVERRIDE -function MaelstromCount.prototype:GetOptions() - local opts = MaelstromCount.super.prototype.GetOptions(self) - - opts["vpos"] = { - type = "range", - name = L["Vertical Position"], - desc = L["Vertical Position"], - get = function() - return self.moduleSettings.vpos - end, - set = function(info, v) - self.moduleSettings.vpos = v - self:Redraw() - end, - min = -300, - max = 200, - step = 1, - disabled = function() - return not self.moduleSettings.enabled - end, - order = 31 - } - - opts["maelstromFontSize"] = { - type = "range", - name = L["Maelstrom Count Font Size"], - desc = L["Maelstrom Count Font Size"], - get = function() - return self.moduleSettings.maelstromFontSize - end, - set = function(info, v) - self.moduleSettings.maelstromFontSize = v - self:Redraw() - end, - min = 10, - max = 40, - step = 1, - disabled = function() - return not self.moduleSettings.enabled - end, - order = 32 - } - - opts["maelstromMode"] = { - type = 'select', - name = L["Display Mode"], - desc = L["Show graphical or numeric maelstroms"], - get = function(info) - return IceHUD:GetSelectValue(info, self.moduleSettings.maelstromMode) - end, - set = function(info, v) - self.moduleSettings.maelstromMode = info.option.values[v] - self:CreateMaelstromFrame(true) - self:Redraw() - IceHUD:NotifyOptionsChange() - end, - values = { "Numeric", "Graphical Bar", "Graphical Circle", "Graphical Glow", "Graphical Clean Circle" }, - disabled = function() - return not self.moduleSettings.enabled - end, - order = 33 - } - - opts["maelstromGap"] = { - type = 'range', - name = L["Maelstrom gap"], - desc = L["Spacing between each maelstrom point (only works for graphical mode)"], - min = 0, - max = 100, - step = 1, - get = function() - return self.moduleSettings.maelstromGap - end, - set = function(info, v) - self.moduleSettings.maelstromGap = v - self:Redraw() - end, - disabled = function() - return not self.moduleSettings.enabled or self.moduleSettings.maelstromMode == "Numeric" - end, - order = 33.2 - } - - opts["gradient"] = { - type = "toggle", - name = L["Change color"], - desc = L["1 maelstrom: yellow, 5 maelstroms: red"], - get = function() - return self.moduleSettings.gradient - end, - set = function(info, v) - self.moduleSettings.gradient = v - self:Redraw() - end, - disabled = function() - return not self.moduleSettings.enabled - end, - order = 34 - } - - return opts -end - - --- OVERRIDE -function MaelstromCount.prototype:GetDefaultSettings() - local defaults = MaelstromCount.super.prototype.GetDefaultSettings(self) - defaults["vpos"] = 0 - defaults["maelstromFontSize"] = 20 - defaults["maelstromMode"] = "Numeric" - defaults["gradient"] = false - defaults["usesDogTagStrings"] = false - defaults["alwaysFullAlpha"] = true - defaults["maelstromGap"] = 0 - return defaults -end - - --- OVERRIDE -function MaelstromCount.prototype:Redraw() - MaelstromCount.super.prototype.Redraw(self) - - self:CreateFrame() - self:UpdateMaelstromCount() -end - - --- OVERRIDE -function MaelstromCount.prototype:Enable(core) - MaelstromCount.super.prototype.Enable(self, core) - - self:RegisterEvent("UNIT_AURA", "UpdateMaelstromCount") - - self:CreateMaelstromFrame(true) -end - - - --- 'Protected' methods -------------------------------------------------------- - --- OVERRIDE -function MaelstromCount.prototype:CreateFrame() - MaelstromCount.super.prototype.CreateFrame(self) - - self.frame:SetFrameStrata("BACKGROUND") - self.frame:SetWidth(self.maelstromSize*5) - self.frame:SetHeight(1) - self.frame:ClearAllPoints() - self.frame:SetPoint("TOP", self.parent, "BOTTOM", 0, self.moduleSettings.vpos) - - self:Show(true) - - self:CreateMaelstromFrame() -end - - - -function MaelstromCount.prototype:CreateMaelstromFrame(doTextureUpdate) - -- create numeric maelstroms - self.frame.numeric = self:FontFactory(self.moduleSettings.maelstromFontSize, nil, self.frame.numeric) - - self.frame.numeric:SetWidth(50) - self.frame.numeric:SetJustifyH("CENTER") - - self.frame.numeric:SetPoint("TOP", self.frame, "TOP", 0, 0) - self.frame.numeric:Show() - - if (not self.frame.graphicalBG) then - self.frame.graphicalBG = {} - self.frame.graphical = {} - end - - -- create backgrounds - for i = 1, 5 do - if (not self.frame.graphicalBG[i]) then - local frame = CreateFrame("Frame", nil, self.frame) - self.frame.graphicalBG[i] = frame - frame.texture = frame:CreateTexture() - frame.texture:SetAllPoints(frame) - end - - if doTextureUpdate then - if self.moduleSettings.maelstromMode == "Graphical Bar" then - self.frame.graphicalBG[i].texture:SetTexture(IceElement.TexturePath .. "ComboBG") - elseif self.moduleSettings.maelstromMode == "Graphical Circle" then - self.frame.graphicalBG[i].texture:SetTexture(IceElement.TexturePath .. "ComboRoundBG") - elseif self.moduleSettings.maelstromMode == "Graphical Glow" then - self.frame.graphicalBG[i].texture:SetTexture(IceElement.TexturePath .. "ComboGlowBG") - elseif self.moduleSettings.maelstromMode == "Graphical Clean Circle" then - self.frame.graphicalBG[i].texture:SetTexture(IceElement.TexturePath .. "ComboCleanCurvesBG") - end - end - - self.frame.graphicalBG[i]:SetFrameStrata("BACKGROUND") - self.frame.graphicalBG[i]:SetWidth(self.maelstromSize) - self.frame.graphicalBG[i]:SetHeight(self.maelstromSize) - self.frame.graphicalBG[i]:SetPoint("TOPLEFT", (i-1) * (self.maelstromSize-5) + (i-1) + ((i-1) * self.moduleSettings.maelstromGap), 0) - self.frame.graphicalBG[i]:SetAlpha(0.15) - self.frame.graphicalBG[i].texture:SetVertexColor(self:GetColor("MaelstromCount")) - - self.frame.graphicalBG[i]:Hide() - end - - -- create maelstroms - for i = 1, 5 do - if (not self.frame.graphical[i]) then - local frame = CreateFrame("Frame", nil, self.frame) - self.frame.graphical[i] = frame - frame.texture = frame:CreateTexture() - frame.texture:SetAllPoints(frame) - end - - if doTextureUpdate then - if self.moduleSettings.maelstromMode == "Graphical Bar" then - self.frame.graphical[i].texture:SetTexture(IceElement.TexturePath .. "Combo") - elseif self.moduleSettings.maelstromMode == "Graphical Circle" then - self.frame.graphical[i].texture:SetTexture(IceElement.TexturePath .. "ComboRound") - elseif self.moduleSettings.maelstromMode == "Graphical Glow" then - self.frame.graphical[i].texture:SetTexture(IceElement.TexturePath .. "ComboGlow") - elseif self.moduleSettings.maelstromMode == "Graphical Clean Circle" then - self.frame.graphical[i].texture:SetTexture(IceElement.TexturePath .. "ComboCleanCurves") - end - end - - self.frame.graphical[i]:SetFrameStrata("BACKGROUND") - self.frame.graphical[i]:SetAllPoints(self.frame.graphicalBG[i]) - - local r, g, b = self:GetColor("MaelstromCount") - if (self.moduleSettings.gradient) then - g = g - (0.15*i) - end - self.frame.graphical[i].texture:SetVertexColor(r, g, b) - - self.frame.graphical[i]:Hide() - end -end - - -function MaelstromCount.prototype:UpdateMaelstromCount(event, unit) - if unit and unit ~= "player" then - return - end - - local points - if IceHUD.IceCore:IsInConfigMode() then - points = 5 - else - points = IceHUD:GetBuffCount("player", "Spell_Shaman_MaelstromWeapon") - end - - if (points == 0) then - points = nil - end - - if (self.moduleSettings.maelstromMode == "Numeric") then - local r, g, b = self:GetColor("MaelstromCount") - if (self.moduleSettings.gradient and points) then - g = g - (0.15*points) - end - self.frame.numeric:SetTextColor(r, g, b, 0.7) - - self.frame.numeric:SetText(points) - else - self.frame.numeric:SetText() - - for i = 1, table.getn(self.frame.graphical) do - if (points ~= nil) then - self.frame.graphicalBG[i]:Show() - else - self.frame.graphicalBG[i]:Hide() - end - - if (points ~= nil and i <= points) then - self.frame.graphical[i]:Show() - else - self.frame.graphical[i]:Hide() - end - end - end -end - - --- Load us up -local _, unitClass = UnitClass("player") -if (unitClass == "SHAMAN") then - IceHUD.MaelstromCount = MaelstromCount:new() -end diff --git a/modules/SunderCount.lua b/modules/SunderCount.lua deleted file mode 100644 index 964ee06..0000000 --- a/modules/SunderCount.lua +++ /dev/null @@ -1,312 +0,0 @@ -local L = LibStub("AceLocale-3.0"):GetLocale("IceHUD", false) -local SunderCount = IceCore_CreateClass(IceElement) - -local IceHUD = _G.IceHUD - -SunderCount.prototype.sunderSize = 20 -SunderCount.prototype.numSunders = 3 - --- Constructor -- -function SunderCount.prototype:init() - SunderCount.super.prototype.init(self, "SunderCount") - - self:SetDefaultColor("SunderCount", 1, 1, 0) - self.scalingEnabled = true -end - - - --- 'Public' methods ----------------------------------------------------------- - - --- OVERRIDE -function SunderCount.prototype:GetOptions() - local opts = SunderCount.super.prototype.GetOptions(self) - - opts["vpos"] = { - type = "range", - name = L["Vertical Position"], - desc = L["Vertical Position"], - get = function() - return self.moduleSettings.vpos - end, - set = function(info, v) - self.moduleSettings.vpos = v - self:Redraw() - end, - min = -300, - max = 200, - step = 1, - disabled = function() - return not self.moduleSettings.enabled - end, - order = 31 - } - - opts["sunderFontSize"] = { - type = "range", - name = L["Sunder Count Font Size"], - desc = L["Sunder Count Font Size"], - get = function() - return self.moduleSettings.sunderFontSize - end, - set = function(info, v) - self.moduleSettings.sunderFontSize = v - self:Redraw() - end, - min = 10, - max = 40, - step = 1, - disabled = function() - return not self.moduleSettings.enabled - end, - order = 32 - } - - opts["sunderMode"] = { - type = 'select', - name = L["Display Mode"], - desc = L["Show graphical or numeric sunders"], - get = function(info) - return IceHUD:GetSelectValue(info, self.moduleSettings.sunderMode) - end, - set = function(info, v) - self.moduleSettings.sunderMode = info.option.values[v] - self:CreateSunderFrame(true) - self:Redraw() - IceHUD:NotifyOptionsChange() - end, - values = { "Numeric", "Graphical Bar", "Graphical Circle", "Graphical Glow", "Graphical Clean Circle" }, - disabled = function() - return not self.moduleSettings.enabled - end, - order = 33 - } - - opts["sunderGap"] = { - type = 'range', - name = L["Sunder gap"], - desc = L["Spacing between each sunder count (only works for graphical mode)"], - min = 0, - max = 100, - step = 1, - get = function() - return self.moduleSettings.sunderGap - end, - set = function(info, v) - self.moduleSettings.sunderGap = v - self:Redraw() - end, - disabled = function() - return not self.moduleSettings.enabled or self.moduleSettings.sunderMode == "Numeric" - end, - order = 33.2 - } - - opts["gradient"] = { - type = "toggle", - name = L["Change color"], - desc = L["1 sunder: yellow, 5 sunders: red"], - get = function() - return self.moduleSettings.gradient - end, - set = function(info, v) - self.moduleSettings.gradient = v - self:Redraw() - end, - disabled = function() - return not self.moduleSettings.enabled - end, - order = 34 - } - - opts.gradient.desc = string.gsub(opts.gradient.desc, "5", tostring(self.numSunders)) - - return opts -end - - --- OVERRIDE -function SunderCount.prototype:GetDefaultSettings() - local defaults = SunderCount.super.prototype.GetDefaultSettings(self) - defaults["vpos"] = 0 - defaults["sunderFontSize"] = 20 - defaults["sunderMode"] = "Numeric" - defaults["gradient"] = false - defaults["usesDogTagStrings"] = false - defaults["alwaysFullAlpha"] = true - defaults["sunderGap"] = 0 - return defaults -end - - --- OVERRIDE -function SunderCount.prototype:Redraw() - SunderCount.super.prototype.Redraw(self) - - self:CreateFrame() - self:UpdateSunderCount() -end - - --- OVERRIDE -function SunderCount.prototype:Enable(core) - SunderCount.super.prototype.Enable(self, core) - - self:RegisterEvent("PLAYER_TARGET_CHANGED", "UpdateSunderCount") - self:RegisterEvent("UNIT_AURA", "UpdateSunderCount") - - if self.moduleSettings.sunderMode == "Graphical" then - self.moduleSettings.sunderMode = "Graphical Bar" - end - - self:CreateSunderFrame(true) -end - - - --- 'Protected' methods -------------------------------------------------------- - --- OVERRIDE -function SunderCount.prototype:CreateFrame() - SunderCount.super.prototype.CreateFrame(self) - - self.frame:SetFrameStrata("BACKGROUND") - self.frame:SetWidth(self.sunderSize*self.numSunders) - self.frame:SetHeight(1) - self.frame:ClearAllPoints() - self.frame:SetPoint("TOP", self.parent, "BOTTOM", 0, self.moduleSettings.vpos) - - self:Show(true) - - self:CreateSunderFrame() -end - - - -function SunderCount.prototype:CreateSunderFrame(doTextureUpdate) - -- create numeric sunders - self.frame.numeric = self:FontFactory(self.moduleSettings.sunderFontSize, nil, self.frame.numeric) - - self.frame.numeric:SetWidth(50) - self.frame.numeric:SetJustifyH("CENTER") - - self.frame.numeric:SetPoint("TOP", self.frame, "TOP", 0, 0) - self.frame.numeric:Show() - - if (not self.frame.graphicalBG) then - self.frame.graphicalBG = {} - self.frame.graphical = {} - end - - -- create backgrounds - for i = 1, self.numSunders do - if (not self.frame.graphicalBG[i]) then - local frame = CreateFrame("Frame", nil, self.frame) - self.frame.graphicalBG[i] = frame - frame.texture = frame:CreateTexture() - frame.texture:SetAllPoints(frame) - end - - if doTextureUpdate then - if self.moduleSettings.sunderMode == "Graphical Bar" then - self.frame.graphicalBG[i].texture:SetTexture(IceElement.TexturePath .. "ComboBG") - elseif self.moduleSettings.sunderMode == "Graphical Circle" then - self.frame.graphicalBG[i].texture:SetTexture(IceElement.TexturePath .. "ComboRoundBG") - elseif self.moduleSettings.sunderMode == "Graphical Glow" then - self.frame.graphicalBG[i].texture:SetTexture(IceElement.TexturePath .. "ComboGlowBG") - elseif self.moduleSettings.sunderMode == "Graphical Clean Circle" then - self.frame.graphicalBG[i].texture:SetTexture(IceElement.TexturePath .. "ComboCleanCurvesBG") - end - end - - self.frame.graphicalBG[i]:SetFrameStrata("BACKGROUND") - self.frame.graphicalBG[i]:SetWidth(self.sunderSize) - self.frame.graphicalBG[i]:SetHeight(self.sunderSize) - self.frame.graphicalBG[i]:SetPoint("TOPLEFT", (i-1) * (self.sunderSize-5) + (i-1) + ((i-1) * self.moduleSettings.sunderGap), 0) - self.frame.graphicalBG[i]:SetAlpha(0.15) - self.frame.graphicalBG[i].texture:SetVertexColor(self:GetColor("SunderCount")) - - self.frame.graphicalBG[i]:Hide() - end - - -- create sunders - for i = 1, self.numSunders do - if (not self.frame.graphical[i]) then - local frame = CreateFrame("Frame", nil, self.frame) - self.frame.graphical[i] = frame - frame.texture = frame:CreateTexture() - frame.texture:SetAllPoints(frame) - end - - if doTextureUpdate then - if self.moduleSettings.sunderMode == "Graphical Bar" then - self.frame.graphical[i].texture:SetTexture(IceElement.TexturePath .. "Combo") - elseif self.moduleSettings.sunderMode == "Graphical Circle" then - self.frame.graphical[i].texture:SetTexture(IceElement.TexturePath .. "ComboRound") - elseif self.moduleSettings.sunderMode == "Graphical Glow" then - self.frame.graphical[i].texture:SetTexture(IceElement.TexturePath .. "ComboGlow") - elseif self.moduleSettings.sunderMode == "Graphical Clean Circle" then - self.frame.graphical[i].texture:SetTexture(IceElement.TexturePath .. "ComboCleanCurves") - end - end - - self.frame.graphical[i]:SetFrameStrata("BACKGROUND") - self.frame.graphical[i]:SetAllPoints(self.frame.graphicalBG[i]) - - local r, g, b = self:GetColor("SunderCount") - if (self.moduleSettings.gradient) then - g = g - ((0.75 / self.numSunders) * i) - end - self.frame.graphical[i].texture:SetVertexColor(r, g, b) - - self.frame.graphical[i]:Hide() - end -end - - -function SunderCount.prototype:UpdateSunderCount() - local points - if IceHUD.IceCore:IsInConfigMode() then - points = self.numSunders - else - points = IceHUD:GetDebuffCount("target", "Ability_Warrior_Sunder") - end - - if (points == 0) then - points = nil - end - - if (self.moduleSettings.sunderMode == "Numeric") then - local r, g, b = self:GetColor("SunderCount") - if (self.moduleSettings.gradient and points) then - g = g - ((0.75 / self.numSunders) * points) - end - self.frame.numeric:SetTextColor(r, g, b, 0.7) - - self.frame.numeric:SetText(points) - else - self.frame.numeric:SetText() - - for i = 1, table.getn(self.frame.graphical) do - if (points ~= nil) then - self.frame.graphicalBG[i]:Show() - else - self.frame.graphicalBG[i]:Hide() - end - - if (points ~= nil and i <= points) then - self.frame.graphical[i]:Show() - else - self.frame.graphical[i]:Hide() - end - end - end -end - - --- Load us up -local _, unitClass = UnitClass("player") -if (unitClass == "WARRIOR") then - IceHUD.SunderCount = SunderCount:new() -end