Commit 1d7172c7 authored by Croc's avatar Croc
Browse files

Added smoothing of health bars through LibSmoothStatusBar

parent af1fc58a
Pipeline #555 passed with stage
in 14 seconds
package-as: LibSmoothStatusBar-1.0
enable-nolib-creation: no
externals:
LibStub: svn://svn.wowace.com/wow/libstub/mainline/trunk
--[[
Copyright (c) 2013 Bastien Clément
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
]]
-- Port of oUF Smooth Update by Xuerian
-- http://www.wowinterface.com/downloads/info11503-oUFSmoothUpdate.html
--[[
Functions:
- SmoothBar(bar)
Enables smooth animation for the bar.
The bar:SetValue() method will be overloaded to handle animation.
Parameters:
bar - StatusBar frame - The StatusBar to be animated
- ResetBar(bar)
Restores the bar to its original state. Disabling animation.
Parameters:
bar - StatusBar frame - The StatusBar to be restored
]]
local MAJOR = "LibSmoothStatusBar-1.0"
local MINOR = 1
local lib, upgrade = LibStub:NewLibrary(MAJOR, MINOR)
if not lib then return end
lib.frame = lib.frame or CreateFrame('Frame')
lib.smoothing = lib.smoothing or {}
-------------------------------------------------------------------------------
local abs = math.abs
local function AnimationTick()
for bar, value in pairs(lib.smoothing) do
local cur = bar:GetValue()
local new = cur + ((value - cur) / 3)
if new ~= new then
new = value
end
if cur == value or abs(new - value) < 2 then
bar:SetValue_(value)
lib.smoothing[bar] = nil
else
bar:SetValue_(new)
end
end
end
lib.frame:SetScript("OnUpdate", AnimationTick)
local function SmoothSetValue(self, value)
local _, max = self:GetMinMaxValues()
if value == self:GetValue() or (self._max and self._max ~= max) then
lib.smoothing[self] = nil
self:SetValue_(value)
else
lib.smoothing[self] = value
end
self._max = max
end
if upgrade then
for bar, value in pairs(lib.smoothing) do
if bar.SetValue_ then
bar.SetValue = SmoothSetValue
end
end
end
function lib:SmoothBar(bar)
if not bar.SetValue_ then
bar.SetValue_ = bar.SetValue;
bar.SetValue = SmoothSetValue;
end
end
function lib:ResetBar(bar)
if bar.SetValue_ then
bar.SetValue = bar.SetValue_;
bar.SetValue_ = nil;
end
end
## Interface: 60000
## Title: Lib: SmoothStatusBar-1.0
## Notes: Smoothly animates status bar
LibSmoothStatusBar-1.0.xml
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
<Script file="LibStub\LibStub.lua" />
<Script file="LibSmoothStatusBar-1.0.lua" />
</Ui>
......@@ -21,5 +21,6 @@
<Script file="LibBase64-1.0\LibBase64-1.0.lua" />
<Include file="LibCustomGlow-1.0\LibCustomGlow-1.0.xml" />
<Include file="NickTag-1.0\NickTag-1.0.xml" />
<Include file="LibSmoothStatusBar-1.0\LibSmoothStatusBar-1.0.xml" />
</Ui>
......@@ -15,6 +15,7 @@ VUHDO_LibCompressEncode = VUHDO_LibCompress:GetAddonEncodeTable();
VUHDO_LibBase64 = LibStub:GetLibrary("LibBase64-1.0");
VUHDO_LibCustomGlow = LibStub("LibCustomGlow-1.0");
VUHDO_LibNickTag = LibStub("NickTag-1.0");
VUHDO_LibSmoothStatusBar = LibStub("LibSmoothStatusBar-1.0");
VUHDO_LibSharedMedia:Register("font", "Arial Black", "Interface\\AddOns\\VuhDo\\Fonts\\ariblk.ttf");
VUHDO_LibSharedMedia:Register("font", "Emblem", "Interface\\AddOns\\VuhDo\\Fonts\\Emblem.ttf");
......
......@@ -252,7 +252,7 @@ function VUHDO_overhealTextCallback(aUnit, aPanelNum, aProviderName, aText, aVal
tBar = VUHDO_getHealthBar(tButton, 1);
VUHDO_getOverhealText(tBar):SetText(aText);
-- Sonderwurst Overheal wirklich ntig?
-- Overheal really necessary ? -Sonderwurst
if strfind(aProviderName, "OVERHEAL", 1, true) then
tInfo = VUHDO_RAID[aUnit];
if tInfo then
......@@ -544,7 +544,7 @@ function VUHDO_healthBarBouquetCallback(aUnit, anIsActive, anIcon, aCurrValue, a
VUHDO_getLifeText(tHealthBar):SetTextColor(VUHDO_textColor(aColor));
end
end
tHealthBar:SetValue(tQuota);
tHealthBar:SetValue(tQuota);
else
tHealthBar:SetValue(0);
end
......@@ -555,7 +555,7 @@ function VUHDO_healthBarBouquetCallback(aUnit, anIsActive, anIcon, aCurrValue, a
if not tInfo then return; end
-- Targets und targets-of-target, die im Raid sind
tAllButtons = VUHDO_IN_RAID_TARGET_BUTTONS[tInfo["name"]];
tAllButtons = VUHDO_IN_RAID_TARGET_BUTTONS[tInfo["name"]];
if not tAllButtons then return; end
VUHDO_CUSTOM_INFO["fixResolveId"] = aUnit;
......@@ -588,7 +588,7 @@ function VUHDO_healthBarBouquetCallbackCustom(aUnit, anIsActive, anIcon, aCurrVa
VUHDO_getLifeText(tHealthBar):SetTextColor(VUHDO_textColor(aColor));
end
end
tHealthBar:SetValue(tQuota);
tHealthBar:SetValue(tQuota);
else
tHealthBar:SetValue(0);
end
......@@ -727,7 +727,7 @@ function VUHDO_updateHealthBarsFor(aUnit, anUpdateMode)
elseif 5 == anUpdateMode then -- VUHDO_UPDATE_RANGE
VUHDO_determineIncHeal(aUnit);
for _, tButton in pairs(tAllButtons) do
VUHDO_customizeText(tButton, 2, false); -- fr d/c tag -- VUHDO_UPDATE_HEALTH
VUHDO_customizeText(tButton, 2, false); -- for d/c tag -- VUHDO_UPDATE_HEALTH
VUHDO_customizeDebuffIconsRange(tButton);
end
VUHDO_updateIncHeal(aUnit);
......
......@@ -181,9 +181,9 @@ local VUHDO_customizeTargetBar = VUHDO_customizeTargetBar;
-- Wir merken uns die Target-Buttons, wenn das Ziel im Raid ist,
-- um Gesundheitsupdates mit dem regulren Mechanismus durchzufhren
-- die Target-Buttons sind also durch den Target-Namen indiziert.
-- We remember the target buttons when the target is in the raid
-- to perform health updates using the regular mechanism.
-- The target buttons are indexed by target name aswell.
local tName;
local function VUHDO_rememberTargetButton(aTargetUnit, aButton)
for tUnit, tInfo in pairs(VUHDO_RAID) do
......@@ -202,9 +202,8 @@ end
-- Lsche alle Target-Buttons der Person, deren Ziel sich gendert hat
-- Wobei die Buttons mit dem Namen des TARGETS indiziert sind, welchen
-- wir uns VUHDO_IN_RAID_TARGETS aber gemerkt haben
-- Delete all target buttons for the person whose target has changed.
-- Those buttons are indexed with the name of the TARGET, which we have VUHDO_IN_RAID_TARGETS noted.
local tName;
local function VUHDO_forgetTargetButton(aTargetUnit, aButton)
tName = VUHDO_IN_RAID_TARGETS[aTargetUnit];
......
......@@ -243,6 +243,10 @@ local VUHDO_positionHealButton = VUHDO_positionHealButton;
--
local function VUHDO_initHealthBar()
if VUHDO_LibSmoothStatusBar then -- Enable smoothing of health bars if the lib is found
VUHDO_LibSmoothStatusBar:SmoothBar(sHealthBar);
end
sHealthBar:SetPoint("TOPLEFT", VUHDO_getHealthBar(sButton, 6):GetName(), "TOPLEFT", 0, 0); -- Incoming bar
sHealthBar:SetWidth(sBarWidth);
sHealthBar:SetHeight(sBarHeight);
......@@ -477,9 +481,9 @@ local function VUHDO_initBarTexts(aButton, aHealthBar, aWidth)
end
local tAnchorObject;
if strfind(sTextAnchors[1], "BOTTOM", 1, true) and strfind(sTextAnchors[2], "TOP", 1, true) -- ber Button
if strfind(sTextAnchors[1], "BOTTOM", 1, true) and strfind(sTextAnchors[2], "TOP", 1, true) -- above Button
and VUHDO_INDICATOR_CONFIG["BOUQUETS"]["THREAT_BAR"] ~= "" then
tAnchorObject = VUHDO_getHealthBar(aButton, 7) or aButton; -- Target und Tot hat keinen Threat bar
tAnchorObject = VUHDO_getHealthBar(aButton, 7) or aButton; -- Target and ToT have no Threat bar
elseif strfind(sTextAnchors[2], "BOTTOM", 1, true) and strfind(sTextAnchors[1], "TOP", 1, true) then
tAnchorObject = aButton;
else
......@@ -1100,7 +1104,7 @@ function VUHDO_reloadUI(anIsFixAllFrameLevels)
VUHDO_IS_RELOADING = true;
VUHDO_initAllBurstCaches(); -- Wichtig fr INTERNAL_TOGGLES=>Clusters
VUHDO_initAllBurstCaches(); -- Important for INTERNAL_TOGGLES=>Clusters
VUHDO_reloadRaidMembers();
VUHDO_resetNameTextCache();
VUHDO_redrawAllPanels(anIsFixAllFrameLevels);
......@@ -1111,7 +1115,7 @@ function VUHDO_reloadUI(anIsFixAllFrameLevels)
VUHDO_IS_RELOADING = false;
VUHDO_reloadBuffPanel();
VUHDO_initDebuffs(); -- Talente scheinen recht spt zur Verfgung zu stehen...
VUHDO_initDebuffs(); -- Talents seems to be available quite late...
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment