From ced858b06a9c8067272d8dcb96857944194c8456 Mon Sep 17 00:00:00 2001 From: Parnic Date: Sat, 19 Jan 2008 01:26:18 +0000 Subject: [PATCH] - bump toc - added the ability to scale most health/power bars by the amount they're filled up with a customizable max/min color (health can go green to red, for example) - updated from SharedMedia-1.0 to LibSharedMedia-2.0 --- IceHUD.toc | 7 +++---- IceUnitBar.lua | 44 ++++++++++++++++++++++++++++++++++++++-- embeds.xml | 2 +- modules/PetHealth.lua | 29 ++++++++++++++++++++++++++ modules/PetMana.lua | 28 +++++++++++++++++++++++++ modules/PlayerHealth.lua | 21 +++++++++++++++++++ modules/PlayerMana.lua | 22 +++++++++++++++++++- modules/TargetHealth.lua | 21 +++++++++++++++++++ modules/TargetMana.lua | 27 ++++++++++++++++++++++++ 9 files changed, 193 insertions(+), 8 deletions(-) diff --git a/IceHUD.toc b/IceHUD.toc index 380bde1..5ef33a6 100644 --- a/IceHUD.toc +++ b/IceHUD.toc @@ -1,12 +1,12 @@ -## Interface: 20200 +## Interface: 20300 ## Author: Iceroth ## Name: IceHUD ## Title: IceHUD |cff7fff7f -Ace2-|r ## Notes: Another HUD addon ## Version: 1.0 ($Revision$) ## SavedVariables: IceCoreDB -## OptionalDeps: Ace2, GratuityLib, SharedMediaLib, WaterfallLib, MobHealth -## X-Embeds: Ace2, GratuityLib, SharedMediaLib, WaterfallLib +## OptionalDeps: Ace2, GratuityLib, LibSharedMedia, WaterfallLib, MobHealth +## X-Embeds: Ace2, GratuityLib, LibSharedMedia, WaterfallLib ## X-Category: UnitFrame ## X-Date: $Date$ ## X-Website: http://www.wowace.com/forums/index.php/topic,1705.0.html @@ -38,4 +38,3 @@ modules\ComboPoints.lua modules\CastBar.lua modules\TargetCast.lua modules\MirrorBar.lua - diff --git a/IceUnitBar.lua b/IceUnitBar.lua index 4db109f..ae80284 100644 --- a/IceUnitBar.lua +++ b/IceUnitBar.lua @@ -13,6 +13,7 @@ IceUnitBar.prototype.healthPercentage = nil IceUnitBar.prototype.mana = nil IceUnitBar.prototype.maxMana = nil IceUnitBar.prototype.manaPercentage = nil +IceUnitBar.prototype.scaleColorInst = nil IceUnitBar.prototype.unitClass = nil IceUnitBar.prototype.hasPet = nil @@ -30,15 +31,23 @@ function IceUnitBar.prototype:init(name, unit) self:SetDefaultColor("Dead", 0.5, 0.5, 0.5) self:SetDefaultColor("Tapped", 0.8, 0.8, 0.8) + self:SetDefaultColor("ScaledHealthColor", 0, 1, 0) + self:SetDefaultColor("ScaledManaColor", 0, 0, 1) + self:SetDefaultColor("MaxHealthColor", 37, 200, 30) + self:SetDefaultColor("MinHealthColor", 200, 37, 30) + self:SetDefaultColor("MaxManaColor", 0, 0, 255) + self:SetDefaultColor("MinManaColor", 255, 0, 255) end -- OVERRIDE function IceUnitBar.prototype:GetDefaultSettings() local settings = IceUnitBar.super.prototype.GetDefaultSettings(self) - + settings["lowThreshold"] = 0 - + settings["scaleHealthColor"] = true + settings["scaleManaColor"] = true + return settings end @@ -141,6 +150,9 @@ end -- OVERRIDE function IceUnitBar.prototype:Update() + local maxColor = {r = 0, g = 0, b = 0} + local minColor = {r = 0, g = 0, b = 0} + IceUnitBar.super.prototype.Update(self) self.tapped = UnitIsTapped(self.unit) and (not UnitIsTappedByPlayer(self.unit)) @@ -153,6 +165,30 @@ function IceUnitBar.prototype:Update() self.manaPercentage = math.floor( (self.mana/self.maxMana)*100 ) _, self.unitClass = UnitClass(self.unit) + + if( self.moduleSettings.scaleHealthColor ) then + minColor.r,minColor.g,minColor.b = self:GetColor("MinHealthColor") + maxColor.r,maxColor.g,maxColor.b = self:GetColor("MaxHealthColor") + self:SetScaledColor(self.healthPercentage/100, maxColor, minColor) + self:SetColor("ScaledHealthColor", self.scaleColorInst.r, self.scaleColorInst.g, self.scaleColorInst.b) + end + if( self.moduleSettings.scaleManaColor ) then + minColor.r,minColor.g,minColor.b = self:GetColor("MinManaColor") + maxColor.r,maxColor.g,maxColor.b = self:GetColor("MaxManaColor") + self:SetScaledColor(self.manaPercentage/100, maxColor, minColor) + self:SetColor("ScaledManaColor", self.scaleColorInst.r, self.scaleColorInst.g, self.scaleColorInst.b) + end +end + + +function IceUnitBar.prototype:SetScaledColor(percent, maxColor, minColor) + if( not self.scaleColorInst ) then + self.scaleColorInst = { r = 0, g = 0, b = 0 } + end + + self.scaleColorInst.r = ((maxColor.r - minColor.r) * percent) + minColor.r + self.scaleColorInst.g = ((maxColor.g - minColor.g) * percent) + minColor.g + self.scaleColorInst.b = ((maxColor.b - minColor.b) * percent) + minColor.b end @@ -206,3 +242,7 @@ function IceUnitBar.prototype:OnFlashUpdate() end +function IceUnitBar.prototype:SetScaleColorEnabled(enabled) + self.moduleSettings.scaleColor = enabled +end + diff --git a/embeds.xml b/embeds.xml index 19ae5a2..42d9af9 100644 --- a/embeds.xml +++ b/embeds.xml @@ -9,7 +9,7 @@