diff --git a/.pkgmeta b/.pkgmeta index 0f42c61..f6ebe59 100644 --- a/.pkgmeta +++ b/.pkgmeta @@ -20,4 +20,5 @@ externals: optional-dependencies: - libdogtag-3-0 - libdogtag-unit-3-0 - - librangecheck-2-0 \ No newline at end of file + - librangecheck-2-0 + - libhealcomm-3-0 \ No newline at end of file diff --git a/IceHUD.lua b/IceHUD.lua index 760e4ec..397ef8e 100644 --- a/IceHUD.lua +++ b/IceHUD.lua @@ -613,6 +613,8 @@ function IceHUD:OnInitialize() self:RegisterChatCommand({ "/icehud" }, IceHUD.slashMenu) self:SyncSettingsVersions() + + self:InitLDB() end @@ -650,6 +652,26 @@ function IceHUD:SyncSettingsVersions() end end + +function IceHUD:InitLDB() + local LDB = LibStub and LibStub("LibDataBroker-1.1", true) + + if (LDB) then + local ldbButton = LDB:NewDataObject("IceHUD", { + type = "launcher", + text = "IceHUD", + icon = "Interface\\Icons\\Spell_Frost_Frost", + OnClick = function(_, msg) + if not (UnitAffectingCombat("player")) then + waterfall:Open("IceHUD") + else + DEFAULT_CHAT_FRAME:AddMessage("|cff8888ffIceHUD|r: Combat lockdown restriction. Leave combat and try again.") + end + end, + }) + end +end + -- fubar stuff IceHUD.OnMenuRequest = IceHUD.options IceHUD.hasIcon = "Interface\\Icons\\Spell_Frost_Frost" diff --git a/IceHUD.toc b/IceHUD.toc index 49eed9a..6915204 100644 --- a/IceHUD.toc +++ b/IceHUD.toc @@ -5,7 +5,7 @@ ## Notes: Another HUD addon ## Version: @project-version@ (Revision: @project-revision@) ## SavedVariables: IceCoreDB -## OptionalDeps: Ace2, LibSharedMedia-3.0, Waterfall-1.0, Deformat, DewdropLib, LibDogTag-3.0, LibDogTag-Unit-3.0, FuBarPlugin-2.0, LibDruidMana-1.0, LibRangeCheck-2.0 +## OptionalDeps: Ace2, LibSharedMedia-3.0, Waterfall-1.0, Deformat, DewdropLib, LibDogTag-3.0, LibDogTag-Unit-3.0, FuBarPlugin-2.0, LibDruidMana-1.0, LibRangeCheck-2.0, LibHealComm-3.0 ## X-Category: HUDs ## X-Website: http://www.wowace.com/projects/ice-hud/ diff --git a/modules/PlayerHealth.lua b/modules/PlayerHealth.lua index 7683110..26b629c 100644 --- a/modules/PlayerHealth.lua +++ b/modules/PlayerHealth.lua @@ -5,12 +5,15 @@ local PlayerHealth = AceOO.Class(IceUnitBar) PlayerHealth.prototype.resting = nil local configMode = false +local HealComm +local incomingHealAmt = 0 -- Constructor -- function PlayerHealth.prototype:init() PlayerHealth.super.prototype.init(self, "PlayerHealth", "player") self:SetDefaultColor("PlayerHealth", 37, 164, 30) + self:SetDefaultColor("PlayerHealthHealAmount", 37, 164, 30) end @@ -24,6 +27,7 @@ function PlayerHealth.prototype:GetDefaultSettings() settings["lowerText"] = "[FractionalHP:HPColor:Bracket]" settings["allowMouseInteraction"] = false settings["allowMouseInteractionCombat"] = false + settings["healAlpha"] = 0.6 settings["lockIconAlpha"] = false settings["showStatusIcon"] = true @@ -70,6 +74,13 @@ function PlayerHealth.prototype:Enable(core) self:RegisterEvent("PLAYER_FLAGS_CHANGED", "CheckPvP") self:RegisterEvent("UNIT_FACTION", "CheckPvP") + if AceLibrary:HasInstance("LibHealComm-3.0") then + HealComm = AceLibrary("LibHealComm-3.0") + HealComm.RegisterCallback(self, "HealComm_DirectHealStart", function(event, healerName, healSize, endTime, ...) self:HealComm_DirectHealStart(event, healerName, healSize, endTime, ...) end) + HealComm.RegisterCallback(self, "HealComm_DirectHealStop", function(event, healerName, healSize, succeeded, ...) self:HealComm_DirectHealStop(event, healerName, healSize, succeeded, ...) end) + HealComm.RegisterCallback(self, "HealComm_HealModifierUpdate", function(event, unit, targetName, healModifier) self:HealComm_HealModifierUpdate(event, unit, targetName, healModifier) end) + end + if (self.moduleSettings.hideBlizz) then self:HideBlizz() end @@ -78,6 +89,21 @@ function PlayerHealth.prototype:Enable(core) --self:Update(self.unit) end +function PlayerHealth.prototype:HealComm_DirectHealStart(event, healerName, healSize, endTime, ...) + incomingHealAmt = healSize + self:Update() +end + +function PlayerHealth.prototype:HealComm_DirectHealStop(event, healerName, healSize, succeeded, ...) + incomingHealAmt = 0 + self:Update() +end + +function PlayerHealth.prototype:HealComm_HealModifierUpdate(event, unit, targetName, healModifier) + incomingHealAmt = incomingHealAmt * healModifier + self:Update() +end + -- OVERRIDE function PlayerHealth.prototype:GetOptions() @@ -174,6 +200,26 @@ function PlayerHealth.prototype:GetOptions() order = 43.5 } + opts["healAlpha"] = + { + type = "range", + name = "Incoming heal bar alpha", + desc = "What alpha value to use for the bar that displays how much health you'll have after an incoming heal (This gets multiplied by the bar's current alpha to stay in line with the bar on top of it)", + min = 0, + max = 100, + step = 5, + get = function() + return self.moduleSettings.healAlpha * 100 + end, + set = function(v) + self.moduleSettings.healAlpha = v / 100.0 + self:Redraw() + end, + disabled = function() + return not self.moduleSettings.enabled + end + } + opts["iconSettings"] = { type = 'group', @@ -568,6 +614,13 @@ function PlayerHealth.prototype:GetOptions() end +function PlayerHealth.prototype:CreateFrame() + PlayerHealth.super.prototype.CreateFrame(self) + + self:CreateHealBar() +end + + function PlayerHealth.prototype:CreateBackground(redraw) PlayerHealth.super.prototype.CreateBackground(self) @@ -598,6 +651,32 @@ function PlayerHealth.prototype:CreateBackground(redraw) self:EnableClickTargeting(self.moduleSettings.allowMouseInteraction) end +function PlayerHealth.prototype:CreateHealBar() + if not self.healFrame then + self.healFrame = CreateFrame("Statusbar", nil, self.frame) + self.CurrScale = 0 + end + + self.healFrame:SetFrameStrata("LOW") + self.healFrame:SetWidth(self.settings.barWidth + (self.moduleSettings.widthModifier or 0)) + self.healFrame:SetHeight(self.settings.barHeight) + + if not self.healFrame.bar then + self.healFrame.bar = self.frame:CreateTexture(nil, "BACKGROUND") + end + + self.healFrame.bar:SetTexture(IceElement.TexturePath .. self.settings.barTexture) + self.healFrame.bar:SetAllPoints(self.frame) + + self.healFrame:SetStatusBarTexture(self.healFrame.bar) + self.healFrame:SetStatusBarColor(self:GetColor("PlayerHealthIncomingHeal", self.alpha * self.moduleSettings.healAlpha)) + + self:UpdateBar(1, "undef") + + self.healFrame:ClearAllPoints() + self.healFrame:SetPoint("BOTTOM", self.frame, "BOTTOM", 0, 0) +end + function PlayerHealth.prototype:EnableClickTargeting(bEnable) if bEnable then @@ -782,6 +861,15 @@ function PlayerHealth.prototype:Update(unit) self:UpdateBar(self.health/self.maxHealth, color) + -- sadly, animation uses bar-local variables so we can't use the animation for 2 bar textures on the same bar element + if self.healFrame and self.healFrame.bar and incomingHealAmt then + if (self.moduleSettings.side == IceCore.Side.Left) then + self.healFrame.bar:SetTexCoord(1, 0, 1-((self.health + incomingHealAmt) / self.maxHealth), 1) + else + self.healFrame.bar:SetTexCoord(0, 1, 1-((self.health + incomingHealAmt) / self.maxHealth), 1) + end + end + if not IceHUD.IceCore:ShouldUseDogTags() then self:SetBottomText1(math.floor(self.healthPercentage * 100)) self:SetBottomText2(self:GetFormattedText(self.health, self.maxHealth), textColor)