- fixed a few taint issues in the ToTHealth and CustomHealth modules

- removed some duplicated code in CustomHealth for click-targeting
This commit is contained in:
Parnic
2010-07-27 00:30:55 +00:00
parent 374ff3d324
commit 915e36af68
3 changed files with 61 additions and 114 deletions

View File

@ -21,7 +21,6 @@ function IceCustomHealth.prototype:GetDefaultSettings()
settings["classColor"] = false
settings["barVerticalOffset"] = 0
settings["scale"] = 1
settings["allowMouseInteraction"] = false
settings["customBarType"] = "Health"
settings["unitToTrack"] = "focustarget"
@ -93,24 +92,6 @@ function IceCustomHealth.prototype:GetOptions()
order = 20.4,
}
opts["allowClickTarget"] = {
type = 'toggle',
name = 'Allow click-targeting',
desc = 'Whether or not to allow click targeting/casting for this bar (Note: does not work properly with HiBar, have to click near the base of the bar)',
get = function()
return self.moduleSettings.allowMouseInteraction
end,
set = function(v)
self.moduleSettings.allowMouseInteraction = v
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
usage = '',
order = 41,
}
return opts
end
@ -158,60 +139,10 @@ function IceCustomHealth.prototype:Update(unit)
RegisterUnitWatch(self.frame)
end
self:Show(true)
--self.determineColor = false
IceCustomHealth.super.prototype.Update(self, unit)
end
function IceCustomHealth.prototype:CreateBackground()
IceCustomHealth.super.prototype.CreateBackground(self)
if not self.frame.button then
self.frame.button = CreateFrame("Button", nil, self.frame, "SecureUnitButtonTemplate")
end
self.frame.button:ClearAllPoints()
-- Parnic - kinda hacky, but in order to fit this region to multiple types of bars, we need to do this...
-- would be nice to define this somewhere in data, but for now...here we are
if self:GetMyBarTexture() == "HiBar" then
self.frame.button:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", 0, 0)
self.frame.button:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMRIGHT", -1 * self.frame:GetWidth(), 0)
else
if self.moduleSettings.side == IceCore.Side.Left then
self.frame.button:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", -6, 0)
self.frame.button:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMRIGHT", -1 * self.frame:GetWidth() / 3, 0)
else
self.frame.button:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 6, 0)
self.frame.button:SetPoint("BOTTOMRIGHT", self.frame, "BOTTOMRIGHT", -1 * self.frame:GetWidth() / 1.5, 0)
end
end
self:EnableClickTargeting(self.moduleSettings.allowMouseInteraction)
end
function IceCustomHealth.prototype:EnableClickTargeting(bEnable)
if bEnable then
self.frame.button:EnableMouse(true)
self.frame.button:RegisterForClicks("LeftButtonUp")
self.frame.button:SetAttribute("type1", "target")
-- set up click casting
ClickCastFrames = ClickCastFrames or {}
ClickCastFrames[self.frame.button] = true
-- Parnic - debug code for showing the clickable region on this bar
-- self.frame.button:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background",
-- edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
-- tile = false,
-- insets = { left = 0, right = 0, top = 0, bottom = 0 }});
-- self.frame.button:SetBackdropColor(0,0,0,1);
else
self.frame.button:EnableMouse(false)
self.frame.button:RegisterForClicks()
end
end
function IceCustomHealth.prototype:SetUnit(unit)
IceCustomHealth.super.prototype.SetUnit(self, unit)
if self.frame ~= nil and self.frame.button ~= nil then

View File

@ -16,6 +16,7 @@ IceTargetHealth.prototype.raidIconHeight = 16
IceTargetHealth.prototype.EliteTexture = IceElement.TexturePath .. "Elite"
IceTargetHealth.prototype.RareEliteTexture = IceElement.TexturePath .. "RareElite"
IceTargetHealth.prototype.RareTexture = IceElement.TexturePath .. "Rare"
IceTargetHealth.prototype.DisplayClickTargetOption = true
local configMode = false
@ -135,7 +136,7 @@ function IceTargetHealth.prototype:GetOptions()
self:CreateBackground(true)
end,
disabled = function()
return not self.moduleSettings.enabled
return not self.moduleSettings.enabled or not self.DisplayClickTargetOption
end,
usage = '',
order = 43
@ -555,44 +556,45 @@ end
function IceTargetHealth.prototype:CreateBackground(redraw)
IceTargetHealth.super.prototype.CreateBackground(self)
if not self.frame.button then
self.frame.button = CreateFrame("Button", "IceHUD_TargetClickFrame", self.frame, "SecureUnitButtonTemplate")
end
self.frame.button:ClearAllPoints()
-- Parnic - kinda hacky, but in order to fit this region to multiple types of bars, we need to do this...
-- would be nice to define this somewhere in data, but for now...here we are
if self:GetMyBarTexture() == "HiBar" then
self.frame.button:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", 0, 0)
self.frame.button:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMRIGHT", -1 * self.frame:GetWidth(), 0)
elseif self:GetMyBarTexture() == "ArcHUD" then
if self.moduleSettings.side == IceCore.Side.Left then
self.frame.button:SetPoint("TOPLEFT", self.frame, "TOPLEFT")
self.frame.button:SetPoint("BOTTOMRIGHT", self.frame, "BOTTOMLEFT", self.frame:GetWidth() / 3, 0)
else
self.frame.button:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT")
self.frame.button:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMRIGHT", -1 * self.frame:GetWidth() / 3, 0)
end
else
if self.moduleSettings.side == IceCore.Side.Left then
self.frame.button:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", -6, 0)
self.frame.button:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMRIGHT", -1 * self.frame:GetWidth() / 3, 0)
else
self.frame.button:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 6, 0)
self.frame.button:SetPoint("BOTTOMRIGHT", self.frame, "BOTTOMRIGHT", -1 * self.frame:GetWidth() / 1.5, 0)
end
end
self.frame.button.menu = function()
ToggleDropDownMenu(1, nil, TargetFrameDropDown, "cursor");
end
self:EnableClickTargeting(self.moduleSettings.allowMouseInteraction)
if self.frame.button then
self.frame.button:ClearAllPoints()
-- Parnic - kinda hacky, but in order to fit this region to multiple types of bars, we need to do this...
-- would be nice to define this somewhere in data, but for now...here we are
if self:GetMyBarTexture() == "HiBar" then
self.frame.button:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", 0, 0)
self.frame.button:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMRIGHT", -1 * self.frame:GetWidth(), 0)
elseif self:GetMyBarTexture() == "ArcHUD" then
if self.moduleSettings.side == IceCore.Side.Left then
self.frame.button:SetPoint("TOPLEFT", self.frame, "TOPLEFT")
self.frame.button:SetPoint("BOTTOMRIGHT", self.frame, "BOTTOMLEFT", self.frame:GetWidth() / 3, 0)
else
self.frame.button:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT")
self.frame.button:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMRIGHT", -1 * self.frame:GetWidth() / 3, 0)
end
else
if self.moduleSettings.side == IceCore.Side.Left then
self.frame.button:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", -6, 0)
self.frame.button:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMRIGHT", -1 * self.frame:GetWidth() / 3, 0)
else
self.frame.button:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 6, 0)
self.frame.button:SetPoint("BOTTOMRIGHT", self.frame, "BOTTOMRIGHT", -1 * self.frame:GetWidth() / 1.5, 0)
end
end
self.frame.button.menu = function()
ToggleDropDownMenu(1, nil, TargetFrameDropDown, "cursor");
end
end
end
function IceTargetHealth.prototype:EnableClickTargeting(bEnable)
if bEnable then
if not self.frame.button then
self.frame.button = CreateFrame("Button", "IceHUD_TargetClickFrame", self.frame, "SecureUnitButtonTemplate")
end
self.frame.button:EnableMouse(true)
self.frame.button:RegisterForClicks("AnyUp")
self.frame.button:SetAttribute("type1", "target")
@ -610,8 +612,12 @@ function IceTargetHealth.prototype:EnableClickTargeting(bEnable)
-- insets = { left = 0, right = 0, top = 0, bottom = 0 }});
-- self.frame.button:SetBackdropColor(0,0,0,1);
else
self.frame.button:EnableMouse(false)
self.frame.button:RegisterForClicks()
if self.frame.button then
self.frame.button:EnableMouse(false)
self.frame.button:RegisterForClicks()
self.frame.button = nil
end
end
end

View File

@ -43,12 +43,21 @@ function TargetTargetHealth.prototype:GetOptions()
opts["selfDisplayMode"] = {
type = "text",
name = "Self Display Mode",
desc = "What this bar should do whenever the player is the TargetOfTarget",
desc = "What this bar should do whenever the player is the TargetOfTarget\n\nNOTE: When this is set to 'hide', then click-targeting is not available due to Blizzard's restrictions",
get = function()
return self.moduleSettings.selfDisplayMode
end,
set = function(value)
self.moduleSettings.selfDisplayMode = value
if value == "Hide" then
self.moduleSettings.allowMouseInteraction = false
self.DisplayClickTargetOption = false
UnregisterUnitWatch(self.frame)
else
RegisterUnitWatch(self.frame)
self.DisplayClickTargetOption = true
end
AceLibrary("Waterfall-1.0"):Refresh("IceHUD")
self:Redraw()
end,
disabled = function()
@ -84,6 +93,13 @@ function TargetTargetHealth.prototype:Enable(core)
self.registerEvents = false
TargetTargetHealth.super.prototype.Enable(self, core)
if self.moduleSettings.selfDisplayMode == "Hide" then
UnregisterUnitWatch(self.frame)
self.DisplayClickTargetOption = false
self.moduleSettings.allowMouseInteraction = false
self:EnableClickTargeting(false)
end
if self.moduleSettings.useSelfColor ~= nil then
if self.moduleSettings.useSelfColor == true then
self.moduleSettings.selfDisplayMode = "Color as SelfColor"
@ -130,21 +146,15 @@ function TargetTargetHealth.prototype:Update(unit)
if self.moduleSettings.selfDisplayMode == "Color as SelfColor" then
self.color = "SelfColor"
elseif self.moduleSettings.selfDisplayMode == "Hide" then
if self:IsVisible() then
UnregisterUnitWatch(self.frame)
end
self:Show(false)
return
end
end
if not self:IsVisible() then
RegisterUnitWatch(self.frame)
if self.moduleSettings.selfDisplayMode == "Hide" then
self:Show(UnitExists(self.unit))
end
self:Show(true)
self.determineColor = false
TargetTargetHealth.super.prototype.Update(self, unit)
end