diff --git a/IceBarElement.lua b/IceBarElement.lua index 8c0dbdc..aa9da58 100644 --- a/IceBarElement.lua +++ b/IceBarElement.lua @@ -5,9 +5,10 @@ IceBarElement.virtual = true IceBarElement.BackgroundAlpha = 0.25 -IceBarElement.BarTexture = IceHUD.Location .. "\\textures\\HiBar" +IceBarElement.TexturePath = IceHUD.Location .. "\\textures\\" IceBarElement.BackgroundTexture = IceHUD.Location .. "\\textures\\HiBarBG" -IceBarElement.BarProportion = 0.25 -- 0.18 +IceBarElement.BarProportion = 0.35 +IceBarElement.BarTextureWidth = 128 IceBarElement.prototype.barFrame = nil IceBarElement.prototype.width = nil @@ -69,6 +70,7 @@ function IceBarElement.prototype:GetOptions() validate = { "Left", "Right" }, order = 30 } + opts["offset"] = { type = 'range', @@ -91,6 +93,13 @@ function IceBarElement.prototype:GetOptions() end +function IceBarElement.prototype:GetDefaultSettings() + local defaults = IceBarElement.super.prototype.GetDefaultSettings(self) + defaults["barFontSize"] = 13 + return defaults +end + + -- OVERRIDE function IceBarElement.prototype:Redraw() IceBarElement.super.prototype.Redraw(self) @@ -157,7 +166,7 @@ function IceBarElement.prototype:CreateBackground() -- ofxx = (bar width) + (extra space in between the bars) local offx = (IceBarElement.BarProportion * self.width * self.moduleSettings.offset) - + (self.moduleSettings.offset * 10) + + (self.moduleSettings.offset * 5) if (self.moduleSettings.side == IceCore.Side.Left) then offx = offx * -1 end @@ -182,7 +191,7 @@ function IceBarElement.prototype:CreateBar() self.barFrame.bar = self.frame:CreateTexture(nil, "BACKGROUND") end - self.barFrame.bar:SetTexture(IceBarElement.BarTexture) + self.barFrame.bar:SetTexture(IceBarElement.TexturePath .. self.settings.barTexture) self.barFrame.bar:SetAllPoints(self.frame) self.barFrame:SetStatusBarTexture(self.barFrame.bar) @@ -200,12 +209,8 @@ end function IceBarElement.prototype:CreateTexts() - if not (self.frame.bottomUpperText) then - self.frame.bottomUpperText = self:FontFactory(nil, 13) - end - if not (self.frame.bottomLowerText) then - self.frame.bottomLowerText = self:FontFactory(nil, 13) - end + self.frame.bottomUpperText = self:FontFactory(nil, self.settings.barFontSize, nil, self.frame.bottomUpperText) + self.frame.bottomLowerText = self:FontFactory(nil, self.settings.barFontSize, nil, self.frame.bottomLowerText) self.frame.bottomUpperText:SetWidth(80) self.frame.bottomLowerText:SetWidth(120) @@ -236,7 +241,7 @@ function IceBarElement.prototype:CreateTexts() local offx = 2 -- adjust offset for bars where text is aligned to the outer side if (self.moduleSettings.offset <= 1) then - offx = IceBarElement.BarProportion * self.width + 6 + offx = IceBarElement.BarProportion * self.width - offx end @@ -288,7 +293,22 @@ function IceBarElement.prototype:SetBottomText1(text, color) if not (color) then color = "text" end - self.frame.bottomUpperText:SetTextColor(self:GetColor(color, 1)) + + local alpha = 1 + if not (self.settings.lockTextAlpha) then + -- boost text alpha a bit to make it easier to see + if (self.alpha > 0) then + alpha = self.alpha + 0.1 + + if (alpha > 1) then + alpha = 1 + end + else + alpha = 0 + end + end + + self.frame.bottomUpperText:SetTextColor(self:GetColor(color, alpha)) self.frame.bottomUpperText:SetText(text) end diff --git a/IceCore.lua b/IceCore.lua index 0b66b6e..6dc1e93 100644 --- a/IceCore.lua +++ b/IceCore.lua @@ -13,6 +13,7 @@ IceCore.RegisterModule = "IceCore_RegisterModule" IceCore.prototype.settings = nil IceCore.prototype.IceHUDFrame = nil IceCore.prototype.elements = {} +IceCore.prototype.enabled = nil -- Constructor -- @@ -22,7 +23,7 @@ function IceCore.prototype:init() self:RegisterDB("IceCoreDB") - self.IceHUDFrame = CreateFrame("Frame","IceHUDFrame", WorldFrame) + self.IceHUDFrame = CreateFrame("Frame","IceHUDFrame", UIParent) -- We are ready to load modules @@ -36,10 +37,11 @@ function IceCore.prototype:init() verticalPos = -150, scale = 1, alphaooc = 0.3, - alphaic = 0.6 + alphaic = 0.6, + lockTextAlpha = true, + barTexture = "Bar", } - -- get default settings from the modules defaults.modules = {} for i = 1, table.getn(self.elements) do @@ -47,7 +49,6 @@ function IceCore.prototype:init() defaults.modules[name] = self.elements[i]:GetDefaultSettings() end - self:RegisterDefaults('account', defaults) end @@ -65,9 +66,27 @@ function IceCore.prototype:Enable() self.elements[i]:Enable() end end + + self.enabled = true end +function IceCore.prototype:Disable() + for i = 1, table.getn(self.elements) do + if (self.elements[i]:IsEnabled()) then + self.elements[i]:Disable() + end + end + + self.IceHUDFrame:Hide() + self.enabled = false +end + + +function IceCore.prototype:IsEnabled() + return self.enabled +end + function IceCore.prototype:DrawFrame() self.IceHUDFrame:SetFrameStrata("BACKGROUND") self.IceHUDFrame:SetWidth(self.settings.gap) @@ -147,8 +166,7 @@ end function IceCore.prototype:SetScale(value) self.settings.scale = value - local scale = UIParent:GetScale() * value - self.IceHUDFrame:SetScale(scale) + self.IceHUDFrame:SetScale(value) end @@ -169,3 +187,30 @@ function IceCore.prototype:SetAlphaIC(value) self:Redraw() 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:GetBarTexture() + return self.settings.barTexture +end +function IceCore.prototype:SetBarTexture(value) + self.settings.barTexture = value + self:Redraw() +end + diff --git a/IceElement.lua b/IceElement.lua index d8dceab..0afc9be 100644 --- a/IceElement.lua +++ b/IceElement.lua @@ -90,7 +90,7 @@ function IceElement.prototype:GetOptions() local opts = {} opts["enabled"] = { type = "toggle", - name = "Enabled", + name = "|cff8888ffEnabled|r", desc = "Enable/disable module", get = function() return self.moduleSettings.enabled @@ -173,7 +173,7 @@ function IceElement.prototype:GetClassColor(class) end -function IceElement.prototype:FontFactory(weight, size, frame) +function IceElement.prototype:FontFactory(weight, size, frame, font) weight = weight or "" local fontFile = IceHUD.Location .. "\\fonts\\Calibri" .. weight ..".ttf" @@ -181,12 +181,17 @@ function IceElement.prototype:FontFactory(weight, size, frame) frame = self.frame end - local font = frame:CreateFontString() - font:SetFont(fontFile, size) - font:SetShadowColor(0, 0, 0, 1) - font:SetShadowOffset(1, -1) + local fontString = nil + if not (font) then + fontString = frame:CreateFontString() + else + fontString = font + end + fontString:SetFont(fontFile, size) + fontString:SetShadowColor(0, 0, 0, 1) + fontString:SetShadowOffset(1, -1) - return font + return fontString end diff --git a/IceHUD.lua b/IceHUD.lua index baaf1f1..171c780 100644 --- a/IceHUD.lua +++ b/IceHUD.lua @@ -3,7 +3,6 @@ IceHUD = AceLibrary("AceAddon-2.0"):new("AceConsole-2.0", "AceDebug-2.0") IceHUD.dewdrop = AceLibrary("Dewdrop-2.0") IceHUD.Location = "Interface\\AddOns\\IceHUD" -IceHUD.temp = nil IceHUD.options = { type = 'group', @@ -14,6 +13,7 @@ IceHUD.options = name = "General Settings", order = 10 }, + vpos = { type = 'range', name = 'Vertical position', @@ -94,7 +94,68 @@ IceHUD.options = order = 15 }, + alphaooc = { + type = 'range', + name = 'Alpha OOC', + desc = 'Bar alpha Out Of Combat', + get = function() + return IceHUD.IceCore:GetAlphaOOC() + end, + set = function(v) + IceHUD.IceCore:SetAlphaOOC(v) + end, + min = 0, + max = 1, + step = 0.05, + order = 16, + }, + 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 = 17 + }, + + 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 = 18 + }, + + barTexture = { + type = 'text', + name = 'Bar Texture', + desc = 'IceHUD Bar Texture', + get = function() + return IceHUD.IceCore:GetBarTexture() + end, + set = function(value) + IceHUD.IceCore:SetBarTexture(value) + end, + validate = { "Bar", "HiBar" }, + order = 19 + }, + + + + headerModulesBlank = { type = 'header', name = ' ', order = 40 }, headerModules = { type = 'header', name = 'Module Settings', @@ -110,13 +171,30 @@ IceHUD.options = }, - + headerOtherBlank = { type = 'header', name = ' ', order = 90 }, headerOther = { type = 'header', - name = 'Other Settings', + name = 'Other', order = 90 }, + enabled = { + type = "toggle", + name = "|cff8888ffEnabled|r", + desc = "Enable/disable IceHUD", + get = function() + return IceHUD.IceCore:IsEnabled() + end, + set = function(value) + if (value) then + IceHUD.IceCore:Enable() + else + IceHUD.IceCore:Disable() + end + end, + order = 91 + }, + reset = { type = 'execute', name = '|cffff0000Reset|r', @@ -124,29 +202,45 @@ IceHUD.options = func = function() IceHUD.IceCore:ResetSettings() end, - order = 91 + order = 92 }, - dewdrop = { + about = { type = 'execute', - name = 'dewdrop', - desc = 'Open Dewdrop menu for commands', + name = 'About', + desc = "Prints info about IceHUD", func = function() - if not (IceHUD.dewdrop:IsRegistered(IceHUD.IceCore.IceHUDFrame)) then - IceHUD.dewdrop:Register(IceHUD.IceCore.IceHUDFrame, - 'children', IceHUD.options, - 'point', "BOTTOMLEFT", - 'relativePoint', "TOPLEFT", - 'dontHook', true - ) - end - IceHUD.dewdrop:Open(IceHUD.IceCore.IceHUDFrame) + IceHUD:PrintAddonInfo() end, - order = 92 - } + order = 93 + }, + + endSpace = { + type = 'header', + name = ' ', + order = 1000 + }, + } } +IceHUD.slashMenu = +{ + type = 'execute', + func = function() + if not (IceHUD.dewdrop:IsRegistered(IceHUD.IceCore.IceHUDFrame)) then + IceHUD.dewdrop:Register(IceHUD.IceCore.IceHUDFrame, + 'children', IceHUD.options, + 'point', "BOTTOMLEFT", + 'relativePoint', "TOPLEFT", + 'dontHook', true + ) + end + IceHUD.dewdrop:Open(IceHUD.IceCore.IceHUDFrame) + end +} + + function IceHUD:OnInitialize() self:SetDebugging(false) @@ -156,7 +250,7 @@ function IceHUD:OnInitialize() self.options.args.modules.args = self.IceCore:GetModuleOptions() - self:RegisterChatCommand({ "/icehud" }, IceHUD.options) + self:RegisterChatCommand({ "/icehud" }, IceHUD.slashMenu) end @@ -166,4 +260,3 @@ function IceHUD:OnEnable() self.IceCore:Enable() end - diff --git a/IceHUD.toc b/IceHUD.toc index bb82746..b46ecf3 100644 --- a/IceHUD.toc +++ b/IceHUD.toc @@ -3,13 +3,14 @@ ## Name: IceHUD ## Title: IceHUD |cff7fff7f -Ace2-|r ## Notes: Another HUD mod -## Version: 0.2.1 ($Revision$) +## Version: 0.3 ($Revision$) ## SavedVariables: IceCoreDB +## OptionalDeps: FuBar_ToFu, DruidBar, SoleManax ## X-Category: UnitFrame ## X-Date: $Date$ ## X-Website: http://www.wowace.com/forums/index.php/topic,1705.0.html - +# Libraries libs\AceLibrary\AceLibrary.lua libs\AceOO-2.0\AceOO-2.0.lua libs\AceDB-2.0\AceDB-2.0.lua @@ -21,13 +22,14 @@ libs\AceAddon-2.0\AceAddon-2.0.lua libs\Metrognome-2.0\Metrognome-2.0.lua libs\Dewdrop-2.0\Dewdrop-2.0.lua +# IceHUD core functionality IceCore.lua IceHUD.lua - IceElement.lua IceBarElement.lua IceUnitBar.lua +# IceHUD modules modules\PlayerHealth.lua modules\PlayerMana.lua modules\TargetHealth.lua @@ -39,3 +41,4 @@ modules\TargetInfo.lua modules\TargetOfTarget.lua modules\CastBar.lua modules\MirrorBar.lua +modules\TimerBar.lua diff --git a/modules/CastBar.lua b/modules/CastBar.lua index 299a9bb..680ef1a 100644 --- a/modules/CastBar.lua +++ b/modules/CastBar.lua @@ -57,7 +57,6 @@ function CastBar.prototype:Enable() self.frame:Hide() - -- remove blizz cast bar CastingBarFrame:UnregisterAllEvents() end @@ -76,6 +75,16 @@ function CastBar.prototype:Disable() CastingBarFrame:RegisterEvent("SPELLCAST_CHANNEL_STOP"); end + +-- OVERRIDE +function CastBar.prototype:Redraw() + CastBar.super.prototype.Redraw(self) + + self.frame.bottomUpperText:SetWidth(180) +end + + + -- 'Protected' methods -------------------------------------------------------- @@ -118,7 +127,7 @@ function CastBar.prototype:OnUpdate() if (scale < 0.1) then -- "wait" for possible fail event before showing success animation return end - self.alpha = 0.5 + self.alpha = 0.9 self:UpdateBar(1, "castSuccess", 1.1-scale) if (scale >= 1) then diff --git a/modules/DruidMana.lua b/modules/DruidMana.lua index 3a2bf91..9a821a4 100644 --- a/modules/DruidMana.lua +++ b/modules/DruidMana.lua @@ -4,6 +4,9 @@ local Metrognome = AceLibrary("Metrognome-2.0") local DruidMana = AceOO.Class(IceUnitBar) DruidMana.prototype.inForms = nil +DruidMana.prototype.mode = nil +DruidMana.prototype.mana = nil +DruidMana.prototype.maxMana = nil -- Constructor -- @@ -27,15 +30,29 @@ end function DruidMana.prototype:Enable() DruidMana.super.prototype.Enable(self) - if (DruidBar_OnLoad) then - Metrognome:Register("DruidMana", self.Update, 0.1, self) + if (IsAddOnLoaded("SoleManax")) then + self.mode = "SoleManax" + SoleManax:AddUser(self.UpdateSoleManax, TRUE, self) + self:UpdateSoleManax(SoleManax:GetPlayerMana()) + + elseif (DruidBar_OnLoad) then + self.mode = "DruidBar" + Metrognome:Register("DruidMana", self.UpdateDruidBarMana, 0.1, self) Metrognome:Start("DruidMana") end self:RegisterEvent("UNIT_DISPLAYPOWER", "FormsChanged") self:FormsChanged(self.unit) - self:Update() +end + + +function DruidMana.prototype:Disable() + DruidMana.super.prototype.Disable(self) + + if (IsAddOnLoaded("SoleManax")) then + SoleManax.DelUser(self.UpdateSoleManax) + end end @@ -45,10 +62,25 @@ function DruidMana.prototype:FormsChanged(unit) end self.inForms = (UnitPowerType(self.unit) ~= 0) + self:Update() end -function DruidMana.prototype:Update(unit) +function DruidMana.prototype:UpdateSoleManax(mana, maxMana) + self.mana = mana + self.maxMana = maxMana + self:Update() +end + + +function DruidMana.prototype:UpdateDruidBarMana() + self.mana = DruidBarKey.keepthemana + self.maxMana = DruidBarKey.maxmana + self:Update() +end + + +function DruidMana.prototype:Update() if ((not self.alive) or (not self.inForms)) then self.frame:Hide() return @@ -56,13 +88,12 @@ function DruidMana.prototype:Update(unit) self.frame:Show() end - --IceHUD:Debug(self.alive, self.inForms) - local color = "druidMana" - self:UpdateBar(DruidBarKey.keepthemana / DruidBarKey.maxmana, color) - local percentage = DruidBarKey.keepthemana / DruidBarKey.maxmana * 100 + + self:UpdateBar(self.mana / self.maxMana, color) + + local percentage = (self.mana / self.maxMana) * 100 self:SetBottomText1(math.floor(percentage)) - --self:SetBottomText2(self:GetFormattedText(DruidBarKey.keepthemana, DruidBarKey.maxmana), color) end diff --git a/modules/MirrorBar.lua b/modules/MirrorBar.lua index ab5c7e3..8a2ab42 100644 --- a/modules/MirrorBar.lua +++ b/modules/MirrorBar.lua @@ -170,34 +170,32 @@ function MirrorBarHandler.prototype:GetOptions() opts["side"] = { - type = 'group', - name = 'side', + type = 'text', + name = 'Side', desc = 'Side of the HUD where the bar appears', - args = { - left = { - type = 'execute', - name = 'left', - desc = "Left side", - func = function() - self.moduleSettings.side = IceCore.Side.Left - self:Redraw() - end - }, - right = { - type = 'execute', - name = 'right', - desc = "Right side", - func = function() - self.moduleSettings.side = IceCore.Side.Right - self:Redraw() - end - } - } + get = function() + if (self.moduleSettings.side == IceCore.Side.Right) then + return "Right" + else + return "Left" + end + end, + set = function(value) + if (value == "Right") then + self.moduleSettings.side = IceCore.Side.Right + else + self.moduleSettings.side = IceCore.Side.Left + end + self:Redraw() + end, + validate = { "Left", "Right" }, + order = 30 } + opts["offset"] = { type = 'range', - name = 'offset', + name = 'Offset', desc = 'Offset of the bar', min = -1, max = 10, @@ -208,9 +206,10 @@ function MirrorBarHandler.prototype:GetOptions() set = function(value) self.moduleSettings.offset = value self:Redraw() - end + end, + order = 31 } - + return opts end diff --git a/modules/PetHealth.lua b/modules/PetHealth.lua index 5a0d357..f7f2eab 100644 --- a/modules/PetHealth.lua +++ b/modules/PetHealth.lua @@ -25,7 +25,7 @@ function PetHealth.prototype:GetOptions() opts["scale"] = { type = 'range', - name = 'scale', + name = 'Scale', desc = 'Scale of the bar', min = 0.2, max = 1, @@ -36,7 +36,8 @@ function PetHealth.prototype:GetOptions() set = function(value) self.moduleSettings.scale = value self:Redraw() - end + end, + order = 31 } return opts end diff --git a/modules/PetMana.lua b/modules/PetMana.lua index f1a7394..27f2a76 100644 --- a/modules/PetMana.lua +++ b/modules/PetMana.lua @@ -19,7 +19,7 @@ function PetMana.prototype:GetOptions() opts["scale"] = { type = 'range', - name = 'scale', + name = 'Scale', desc = 'Scale of the bar', min = 0.2, max = 1, @@ -30,7 +30,8 @@ function PetMana.prototype:GetOptions() set = function(value) self.moduleSettings.scale = value self:Redraw() - end + end, + order = 31 } return opts end diff --git a/modules/PlayerMana.lua b/modules/PlayerMana.lua index 0e71d56..4527dbc 100644 --- a/modules/PlayerMana.lua +++ b/modules/PlayerMana.lua @@ -3,6 +3,7 @@ local AceOO = AceLibrary("AceOO-2.0") local PlayerMana = AceOO.Class(IceUnitBar) PlayerMana.prototype.manaType = nil +PlayerMana.prototype.tickStart = nil -- Constructor -- function PlayerMana.prototype:init() @@ -10,30 +11,75 @@ function PlayerMana.prototype:init() self:SetColor("playerMana", 62, 54, 152) self:SetColor("playerRage", 171, 59, 59) - self:SetColor("playerEnergy", 218, 231, 31) + self:SetColor("playerEnergy", 218, 231, 31) end + +-- OVERRIDE function PlayerMana.prototype:GetDefaultSettings() local settings = PlayerMana.super.prototype.GetDefaultSettings(self) settings["side"] = IceCore.Side.Right settings["offset"] = 1 + settings["tickerEnabled"] = true + settings["tickerAlpha"] = 0.8 return settings end +-- OVERRIDE +function PlayerMana.prototype:GetOptions() + local opts = PlayerMana.super.prototype.GetOptions(self) + + opts["tickerEnabled"] = { + type = "toggle", + name = "Show rogue/cat energy ticker", + desc = "Show rogue/cat energy ticker", + get = function() + return self.moduleSettings.tickerEnabled + end, + set = function(value) + self.moduleSettings.tickerEnabled = value + self:ManaType(self.unit) + end, + order = 31 + } + + opts["tickerAlpha"] = + { + type = 'range', + name = 'Energy Ticker Alpha', + desc = 'Energy Ticker Alpha', + min = 0.1, + max = 1, + step = 0.05, + get = function() + return self.moduleSettings.tickerAlpha + end, + set = function(value) + self.moduleSettings.tickerAlpha = value + self.tickerFrame:SetStatusBarColor(self:GetColor("playerEnergy", self.moduleSettings.tickerAlpha)) + end, + order = 32 + } + + return opts +end + function PlayerMana.prototype:Enable() PlayerMana.super.prototype.Enable(self) + self:CreateTickerFrame() + self:RegisterEvent("UNIT_MANA", "Update") self:RegisterEvent("UNIT_MAXMANA", "Update") self:RegisterEvent("UNIT_RAGE", "Update") self:RegisterEvent("UNIT_MAXRAGE", "Update") - self:RegisterEvent("UNIT_ENERGY", "Update") + self:RegisterEvent("UNIT_ENERGY", "UpdateEnergy") self:RegisterEvent("UNIT_MAXENERGY", "Update") self:RegisterEvent("UNIT_DISPLAYPOWER", "ManaType") - + self:ManaType(self.unit) end @@ -44,6 +90,16 @@ function PlayerMana.prototype:ManaType(unit) end self.manaType = UnitPowerType(self.unit) + + -- register ticker for rogue energy + if (self.moduleSettings.tickerEnabled and (self.manaType == 3) and self.alive) then + self.tickerFrame:Show() + self.tickerFrame:SetScript("OnUpdate", function() self:EnergyTick() end) + else + self.tickerFrame:Hide() + self.tickerFrame:SetScript("OnUpdate", nil) + end + self:Update(self.unit) end @@ -54,6 +110,10 @@ function PlayerMana.prototype:Update(unit) return end + if (self.manaType ~= 3) then + self.tickerFrame:Hide() + end + local color = "playerMana" if not (self.alive) then color = "dead" @@ -78,6 +138,63 @@ function PlayerMana.prototype:Update(unit) end +function PlayerMana.prototype:UpdateEnergy(unit) + if (unit and (unit ~= "player")) then + return + end + + self.tickStart = GetTime() + self.tickerFrame:Show() + self:Update(unit) +end + + +function PlayerMana.prototype:EnergyTick() + if not (self.tickStart) then + self.tickerFrame:Hide() + return + end + + local now = GetTime() + local elapsed = now - self.tickStart + + if (elapsed > 2) then + self.tickStart = now + end + + local thisTick = elapsed / 2 + local x = (thisTick * (self.width - (self.width * IceBarElement.BarProportion))) + 4 + local y = thisTick * (self.height - 5) + + self.tickerFrame:ClearAllPoints() + self.tickerFrame:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT", x, y) +end + + +function PlayerMana.prototype:CreateTickerFrame() + if not (self.tickerFrame) then + self.tickerFrame = CreateFrame("StatusBar", nil, self.barFrame) + end + + self.tickerFrame:SetFrameStrata("BACKGROUND") + self.tickerFrame:SetWidth(19) + self.tickerFrame:SetHeight(1) + + if not (self.tickerFrame.spark) then + self.tickerFrame.spark = self.tickerFrame:CreateTexture(nil, "BACKGROUND") + end + + self.tickerFrame.spark:SetTexture(self:GetColor("playerEnergy", 1)) + self.tickerFrame.spark:SetBlendMode("ADD") + self.tickerFrame.spark:ClearAllPoints() + self.tickerFrame.spark:SetAllPoints(self.tickerFrame) + + self.tickerFrame:SetStatusBarTexture(self.tickerFrame.spark) + self.tickerFrame:SetStatusBarColor(self:GetColor("playerEnergy", self.moduleSettings.tickerAlpha)) + + self.tickerFrame:Hide() +end + -- Load us up PlayerMana:new() diff --git a/modules/TargetInfo.lua b/modules/TargetInfo.lua index ee2b840..f56e77d 100644 --- a/modules/TargetInfo.lua +++ b/modules/TargetInfo.lua @@ -18,6 +18,68 @@ end -- 'Public' methods ----------------------------------------------------------- + +-- OVERRIDE +function TargetInfo.prototype:GetOptions() + local opts = TargetInfo.super.prototype.GetOptions(self) + + opts["fontSize"] = { + type = 'range', + name = 'Font Size', + desc = 'Font Size', + get = function() + return self.moduleSettings.fontSize + end, + set = function(v) + self.moduleSettings.fontSize = v + self:Redraw() + end, + min = 8, + max = 20, + step = 1, + order = 31 + } + + opts["comboFontSize"] = { + type = 'range', + name = 'Combo Points Font Size', + desc = 'Combo Points Font Size', + get = function() + return self.moduleSettings.comboFontSize + end, + set = function(v) + self.moduleSettings.comboFontSize = v + self:Redraw() + end, + min = 10, + max = 40, + step = 1, + order = 32 + } + + return opts +end + + +-- OVERRIDE +function TargetInfo.prototype:GetDefaultSettings() + local defaults = TargetInfo.super.prototype.GetDefaultSettings(self) + defaults["fontSize"] = 13 + defaults["comboFontSize"] = 20 + return defaults +end + + +-- OVERRIDE +function TargetInfo.prototype:Redraw() + TargetInfo.super.prototype.Redraw(self) + + self:CreateTextFrame() + self:CreateInfoTextFrame() + self:CreateComboFrame() +end + + function TargetInfo.prototype:Enable() TargetInfo.super.prototype.Enable(self) @@ -45,26 +107,11 @@ function TargetInfo.prototype:CreateFrame() self.frame:SetFrameStrata("BACKGROUND") self.frame:SetWidth(TargetInfo.Width) self.frame:SetHeight(42) + self.frame:ClearAllPoints() self.frame:SetPoint("TOP", self.parent, "BOTTOM", 0, -50) - --[[ - self.frame:SetBackdrop( - { - bgFile = "Interface/Tooltips/UI-Tooltip-Background", - edgeFile = "Interface/Tooltips/UI-ToolTip-Border", - tile = false, - tileSize = 32, - edgeSize = 5, - insets = { left = 1, right = 1, top = 1, bottom = 1 } - } ) - - self.frame:SetBackdropColor(0.5, 0.5, 0.5, 0.2) - self.frame:SetBackdropBorderColor(0.4, 0.4, 0.4, 0.4) - --]] - self.frame:Show() - self:CreateTextFrame() self:CreateInfoTextFrame() self:CreateBuffFrame() @@ -75,9 +122,9 @@ end function TargetInfo.prototype:CreateTextFrame() - self.frame.targetName = self:FontFactory("Bold", 15) + self.frame.targetName = self:FontFactory("Bold", self.moduleSettings.fontSize+1, nil, self.frame.targetName) - self.frame.targetName:SetWidth(TargetInfo.Width) + self.frame.targetName:SetWidth(TargetInfo.Width - 120) self.frame.targetName:SetHeight(14) self.frame.targetName:SetJustifyH("LEFT") self.frame.targetName:SetJustifyV("BOTTOM") @@ -88,7 +135,7 @@ end function TargetInfo.prototype:CreateInfoTextFrame() - self.frame.targetInfo = self:FontFactory(nil, 13) + self.frame.targetInfo = self:FontFactory(nil, self.moduleSettings.fontSize, nil, self.frame.targetInfo) self.frame.targetInfo:SetWidth(TargetInfo.Width) self.frame.targetInfo:SetHeight(14) @@ -101,7 +148,7 @@ end function TargetInfo.prototype:CreateComboFrame() - self.frame.comboPoints = self:FontFactory("Bold", 20) + self.frame.comboPoints = self:FontFactory("Bold", self.moduleSettings.comboFontSize, nil, self.frame.comboPoints) self.frame.comboPoints:SetWidth(TargetInfo.Width) self.frame.comboPoints:SetJustifyH("CENTER") diff --git a/modules/TargetOfTarget.lua b/modules/TargetOfTarget.lua index f7f87c6..4d425dd 100644 --- a/modules/TargetOfTarget.lua +++ b/modules/TargetOfTarget.lua @@ -1,7 +1,9 @@ local AceOO = AceLibrary("AceOO-2.0") -local Metrognome = AceLibrary("Metrognome-2.0") -local TargetOfTarget = AceOO.Class(IceElement) +local TargetOfTarget = AceOO.Class(IceElement, "Metrognome-2.0") + +TargetOfTarget.prototype.stackedDebuffs = nil +TargetOfTarget.prototype.buffSize = nil -- Constructor -- @@ -11,25 +13,84 @@ function TargetOfTarget.prototype:init() self:SetColor("totHostile", 0.8, 0.1, 0.1) self:SetColor("totFriendly", 0.2, 1, 0.2) self:SetColor("totNeutral", 0.9, 0.9, 0) + + self.buffSize = 15 + self.stackedDebuffs = {} end +-- OVERRIDE +function TargetOfTarget.prototype:GetOptions() + local opts = TargetOfTarget.super.prototype.GetOptions(self) + + opts["showDebuffs"] = { + type = "toggle", + name = "Show stacking debuffs", + desc = "Show stacking debuffs in ToT info", + get = function() + return self.moduleSettings.showDebuffs + end, + set = function(value) + self.moduleSettings.showDebuffs = value + self:UpdateBuffs() + end, + order = 31 + } + + opts["fontSize"] = { + type = 'range', + name = 'Font Size', + desc = 'Font Size', + get = function() + return self.moduleSettings.fontSize + end, + set = function(v) + self.moduleSettings.fontSize = v + self:Redraw() + end, + min = 8, + max = 20, + step = 1, + order = 32 + } + + return opts +end + + +-- OVERRIDE +function TargetOfTarget.prototype:GetDefaultSettings() + local defaults = TargetOfTarget.super.prototype.GetDefaultSettings(self) + defaults["showDebuffs"] = true + defaults["fontSize"] = 13 + return defaults +end + + +-- OVERRIDE +function TargetOfTarget.prototype:Redraw() + TargetOfTarget.super.prototype.Redraw(self) + + self:CreateToTFrame() + self:CreateToTHPFrame() +end + function TargetOfTarget.prototype:Enable() TargetOfTarget.super.prototype.Enable(self) - Metrognome:Register("TargetOfTarget", self.Update, 0.2, self) - Metrognome:Start("TargetOfTarget") - self:RegisterEvent("PLAYER_TARGET_CHANGED", "Update") + self:RegisterMetro(self.name, self.Update, 0.33, self) + self:StartMetro(self.name) + self:Update() end function TargetOfTarget.prototype:Disable() TargetOfTarget.super.prototype.Disable(self) - Metrognome:Unregister("TargetOfTarget") + self:UnregisterMetro(self.name) end @@ -47,36 +108,107 @@ function TargetOfTarget.prototype:CreateFrame() self:CreateToTFrame() self:CreateToTHPFrame() + self:CreateDebuffFrame() end - function TargetOfTarget.prototype:CreateToTFrame() - self.frame.totName = self:FontFactory("Bold", 14) + self.frame.totName = self:FontFactory("Bold", self.moduleSettings.fontSize+1, nil, self.frame.totName) self.frame.totName:SetWidth(120) self.frame.totName:SetHeight(14) self.frame.totName:SetJustifyH("RIGHT") self.frame.totName:SetJustifyV("BOTTOM") - self.frame.totName:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", -2, -2) + self.frame.totName:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", 0, -2) self.frame.totName:Show() end + function TargetOfTarget.prototype:CreateToTHPFrame() - self.frame.totHealth = self:FontFactory(nil, 12) + self.frame.totHealth = self:FontFactory(nil, self.moduleSettings.fontSize, nil, self.frame.totHealth) self.frame.totHealth:SetWidth(120) self.frame.totHealth:SetHeight(14) self.frame.totHealth:SetJustifyH("RIGHT") self.frame.totHealth:SetJustifyV("TOP") - self.frame.totHealth:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", -2, -16) + self.frame.totHealth:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", 0, -16) self.frame.totHealth:Show() end +function TargetOfTarget.prototype:CreateDebuffFrame() + self.frame.debuffFrame = CreateFrame("Frame", nil, self.frame) + + self.frame.debuffFrame:SetFrameStrata("BACKGROUND") + self.frame.debuffFrame:SetWidth(200) + self.frame.debuffFrame:SetHeight(20) + + self.frame.debuffFrame:SetPoint("TOPLEFT", self.frame, "TOPRIGHT", 4, 0) + self.frame.debuffFrame:Show() + + self.frame.debuffFrame.buffs = self:CreateIconFrames(self.frame.debuffFrame) +end + + +function TargetOfTarget.prototype:CreateIconFrames(parent) + local buffs = {} + + for i = 1, 16 do + buffs[i] = CreateFrame("Frame", nil, parent) + buffs[i]:SetFrameStrata("BACKGROUND") + buffs[i]:SetWidth(self.buffSize) + buffs[i]:SetHeight(self.buffSize) + buffs[i]:SetPoint("LEFT", (i-1) * self.buffSize + (i-1), 0) + buffs[i]:Show() + + buffs[i].texture = buffs[i]:CreateTexture() + buffs[i].texture:SetTexture(nil) + buffs[i].texture:SetAllPoints(buffs[i]) + + buffs[i].stack = self:FontFactory("Bold", 15, buffs[i]) + buffs[i].stack:SetPoint("BOTTOMRIGHT" , buffs[i], "BOTTOMRIGHT", 0, -1) + end + return buffs +end + + +function TargetOfTarget.prototype:UpdateBuffs() + local debuffs = 0 + + if (self.moduleSettings.showDebuffs) then + for i = 1, 16 do + local buffTexture, buffApplications = UnitDebuff("targettarget", i) + + if (buffApplications and (buffApplications > 1)) then + debuffs = debuffs + 1 + + if not (self.stackedDebuffs[debuffs]) then + self.stackedDebuffs[debuffs] = {} + end + + self.stackedDebuffs[debuffs].texture = buffTexture + self.stackedDebuffs[debuffs].count = buffApplications + end + end + end + + for i = 1, 16 do + if (self.moduleSettings.showDebuffs and (i <= debuffs)) then + self.frame.debuffFrame.buffs[i].texture:SetTexture(self.stackedDebuffs[i].texture) + self.frame.debuffFrame.buffs[i].stack:SetText(self.stackedDebuffs[i].count) + else + self.frame.debuffFrame.buffs[i].texture:SetTexture(nil) + self.frame.debuffFrame.buffs[i].stack:SetText(nil) + end + end +end + + function TargetOfTarget.prototype:Update() + self:UpdateBuffs() + if not (UnitExists("targettarget")) then self.frame.totName:SetText() self.frame.totHealth:SetText() diff --git a/modules/TimerBar.lua b/modules/TimerBar.lua new file mode 100644 index 0000000..a24851b --- /dev/null +++ b/modules/TimerBar.lua @@ -0,0 +1,70 @@ +local AceOO = AceLibrary("AceOO-2.0") + +local TimerBar = AceOO.Class(IceBarElement, "AceHook-2.0", "Metrognome-2.0") + + +-- Constructor -- +function TimerBar.prototype:init() + TimerBar.super.prototype.init(self, "TimerBar") + + self:SetColor("timerFlight", 0.2, 0.7, 0.7) +end + + +-- 'Public' methods ----------------------------------------------------------- + +function TimerBar.prototype:GetDefaultSettings() + local settings = TimerBar.super.prototype.GetDefaultSettings(self) + settings["side"] = IceCore.Side.Left + settings["offset"] = 0 + return settings +end + + +function TimerBar.prototype:Enable() + TimerBar.super.prototype.Enable(self) + + self.frame.bottomUpperText:SetWidth(180) + self.frame:Hide() + + self:Hook(ToFu, "OnUpdate") +end + + +function TimerBar.prototype:Disable() + TimerBar.super.prototype.Disable(self) + + self:Unhook(ToFu, "OnUpdate") +end + + + +-- 'Protected' methods -------------------------------------------------------- + + +function TimerBar.prototype:OnUpdate(object, timeSinceLast) + self.hooks[object].OnUpdate.orig(object, timeSinceLast) + + if (ToFu.inFlight) then + local flightTime = ToFu.fullData.paths[ace.char.faction][ToFu.start][ToFu.destination].time + + if (flightTime ~= 0) then + local timeRemaining = flightTime - ToFu.timeFlown + + self.frame:Show() + self:UpdateBar(timeRemaining / flightTime, "timerFlight") + --local text = string.format("%.1fs", timeRemaining) + local text = FuBarUtils.FormatDurationCondensed(timeRemaining) + self:SetBottomText1(text) + + return + end + end + self.frame:Hide() +end + + + + +-- Load us up +TimerBar:new() diff --git a/textures/Bar.blp b/textures/Bar.blp new file mode 100644 index 0000000..2bf24b4 Binary files /dev/null and b/textures/Bar.blp differ