Commit 12e83d4e authored by Ivaria's avatar Ivaria
Browse files

Only register LibHealComm callbacks when the option is actually enabled - this...

Only register LibHealComm callbacks when the option is actually enabled - this will require a reload when the option is toggled
parent ca618c3e
......@@ -16,7 +16,7 @@ VUHDO_LibBase64 = LibStub:GetLibrary("LibBase64-1.0");
VUHDO_LibCustomGlow = LibStub("LibCustomGlow-1.0");
VUHDO_LibNickTag = LibStub("NickTag-1.0");
VUHDO_LibHealComm = LibStub("LibHealComm-4.0");
VUHDO_LibHealComm = nil;
VUHDO_LibSharedMedia:Register("font", "Arial Black", "Interface\\AddOns\\VuhDo\\Fonts\\ariblk.ttf");
VUHDO_LibSharedMedia:Register("font", "Emblem", "Interface\\AddOns\\VuhDo\\Fonts\\Emblem.ttf");
......@@ -246,3 +246,50 @@ function VUHDO_initShowMinimap()
end
end
--
function VUHDO_initLibHealComm()
VUHDO_LibHealComm = VUHDO_CONFIG["SHOW_LIBHEALCOMM_INCOMING"] and LibStub("LibHealComm-4.0", true) or nil;
if VUHDO_LibHealComm then
local tInstance = _G["VuhDo"];
local function HealComm_HealUpdated(aEvent, aCasterGUID, aSpellID, aHealType, aEndTime, ...)
local tTargets = { n = select("#", ...), ... };
for i = 1, tTargets.n do
local tTarget = VUHDO_RAID_GUIDS[tTargets[i]];
if (VUHDO_RAID or tEmptyRaid)[tTarget] then -- auch target, focus
VUHDO_updateHealth(tTarget, 9); -- VUHDO_UPDATE_INC
VUHDO_updateBouquetsForEvent(tTarget, 9); -- VUHDO_UPDATE_ALT_POWER
end
end
end
tInstance.HealComm_HealUpdated = HealComm_HealUpdated;
VUHDO_LibHealComm.RegisterCallback(tInstance, "HealComm_HealStarted", HealComm_HealUpdated);
VUHDO_LibHealComm.RegisterCallback(tInstance, "HealComm_HealStopped", HealComm_HealUpdated);
VUHDO_LibHealComm.RegisterCallback(tInstance, "HealComm_HealDelayed", HealComm_HealUpdated);
VUHDO_LibHealComm.RegisterCallback(tInstance, "HealComm_HealUpdated", HealComm_HealUpdated);
local function HealComm_HealModified(aEvent, aTargetGUID)
local tTarget = VUHDO_RAID_GUIDS[aTargetGUID];
if (VUHDO_RAID or tEmptyRaid)[tTarget] then -- auch target, focus
VUHDO_updateHealth(tTarget, 9); -- VUHDO_UPDATE_INC
VUHDO_updateBouquetsForEvent(tTarget, 9); -- VUHDO_UPDATE_ALT_POWER
end
end
tInstance.HealComm_HealModified = HealComm_HealModified;
VUHDO_LibHealComm.RegisterCallback(tInstance, "HealComm_ModifierChanged", HealComm_HealModified);
VUHDO_LibHealComm.RegisterCallback(tInstance, "HealComm_GUIDDisappeared", HealComm_HealModified);
elseif VUHDO_CONFIG["SHOW_LIBHEALCOMM_INCOMING"] then
VUHDO_Msg("WARNING: Use LibHealComm is enabled but LibHealComm-4.0 doesn't seem to be loaded!", 1, 0.4, 0.4);
end
end
......@@ -376,6 +376,8 @@ local function VUHDO_init()
VUHDO_getAutoProfile();
VUHDO_initCliqueSupport();
VUHDO_initLibHealComm();
if VuhDoNewOptionsTabbedFrame then
VuhDoNewOptionsTabbedFrame:ClearAllPoints();
VuhDoNewOptionsTabbedFrame:SetPoint("CENTER", "UIParent", "CENTER", 0, 0);
......@@ -1627,41 +1629,6 @@ function VUHDO_OnLoad(anInstance)
VUHDO_ALL_EVENTS = nil;
if VUHDO_LibHealComm then
local function HealComm_HealUpdated(aEvent, aCasterGUID, aSpellID, aHealType, aEndTime, ...)
local tTargets = { n = select("#", ...), ... };
for i = 1, tTargets.n do
local tTarget = VUHDO_RAID_GUIDS[tTargets[i]];
if (VUHDO_RAID or tEmptyRaid)[tTarget] then -- auch target, focus
VUHDO_updateHealth(tTarget, 9); -- VUHDO_UPDATE_INC
VUHDO_updateBouquetsForEvent(tTarget, 9); -- VUHDO_UPDATE_ALT_POWER
end
end
end
anInstance.HealComm_HealUpdated = HealComm_HealUpdated;
VUHDO_LibHealComm.RegisterCallback(anInstance, "HealComm_HealStarted", HealComm_HealUpdated);
VUHDO_LibHealComm.RegisterCallback(anInstance, "HealComm_HealStopped", HealComm_HealUpdated);
VUHDO_LibHealComm.RegisterCallback(anInstance, "HealComm_HealDelayed", HealComm_HealUpdated);
VUHDO_LibHealComm.RegisterCallback(anInstance, "HealComm_HealUpdated", HealComm_HealUpdated);
local function HealComm_HealModified(aEvent, aTargetGUID)
local tTarget = VUHDO_RAID_GUIDS[aTargetGUID];
if (VUHDO_RAID or tEmptyRaid)[tTarget] then -- auch target, focus
VUHDO_updateHealth(tTarget, 9); -- VUHDO_UPDATE_INC
VUHDO_updateBouquetsForEvent(tTarget, 9); -- VUHDO_UPDATE_ALT_POWER
end
end
anInstance.HealComm_HealModified = HealComm_HealModified;
VUHDO_LibHealComm.RegisterCallback(anInstance, "HealComm_ModifierChanged", HealComm_HealModified);
VUHDO_LibHealComm.RegisterCallback(anInstance, "HealComm_GUIDDisappeared", HealComm_HealModified);
end
SLASH_VUHDO1 = "/vuhdo";
SLASH_VUHDO2 = "/vd";
SlashCmdList["VUHDO"] = function(aMessage)
......
......@@ -320,6 +320,18 @@
VUHDO_lnfSetModel(self, "VUHDO_CONFIG.SHOW_LIBHEALCOMM_INCOMING");
VUHDO_lnfSetTooltip(self, VUHDO_I18N_TT.K900);
</OnLoad>
<OnClick>
VUHDO_lnfCheckButtonUpdateModel(self);
VUHDO_lnfCheckButtonClicked(self);
local _, tProfile = VUHDO_getProfileNamedCompressed(VUHDO_CONFIG["CURRENT_PROFILE"]);
if (tProfile ~= nil and not tProfile["LOCKED"]) then
VUHDO_saveCurrentProfile();
end
ReloadUI();
</OnClick>
</Scripts>
</CheckButton>
......
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