Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 3 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
Showing with 101 additions and 92 deletions.
  1. +73 −67 Icetip.lua
  2. +11 −13 modules/appstyle.lua
  3. +1 −1 modules/healthbar.lua
  4. +14 −9 modules/itemref.lua
  5. +1 −1 modules/mousetarget.lua
  6. +1 −1 modules/powerbar.lua
View
140 Icetip.lua
@@ -6,11 +6,8 @@
local addonName, Icetip = ...
Icetip = LibStub("AceAddon-3.0"):NewAddon(Icetip, addonName, "AceEvent-3.0", "AceHook-3.0", "AceTimer-3.0");
Icetip.vesion = GetAddOnMetadata(addonName, "Version")
-Icetip.revision = tonumber(("$Revision$"):match("%d+"));
-
local modules = {};
Icetip.modules = modules;
-
local SM = LibStub("LibSharedMedia-3.0");
local LDB = LibStub("LibDataBroker-1.1", true);
local icon = LibStub("LibDBIcon-1.0", true);
@@ -48,7 +45,6 @@ local default = {
b = 0,
a = 0,
},
- --style
tooltipStyle = {
bgTexture = "Blizzard Tooltip",
borderTexture = "Blank",
@@ -183,7 +179,6 @@ function Icetip:NewModule(name, embedHook)
end
modules[name] = mod;
- --need hooked lib?
if embedHook then
LibStub("AceHook-3.0"):Embed(mod);
end
@@ -211,7 +206,7 @@ function Icetip:HasModule(name)
return false
end
-function Icetip:OnTooltipMethod(name)
+function Icetip:OnTooltipMethod(name, ...)
for i = 1, 3 do
local methodName;
if i == 1 then
@@ -221,7 +216,7 @@ function Icetip:OnTooltipMethod(name)
else
methodName = "PostTooltip"..name
end
- self:CallMethodAllModules(methodName);
+ self:CallMethodAllModules(methodName, ...);
end
end
@@ -237,9 +232,8 @@ function Icetip:CallMethodAllModules(methodName, ...)
end
----------------------------------------------------------------
---- init addon --------------------------------------------------------
+----------------------- init addon ----------------------------
----------------------------------------------------------------
-
function Icetip:OnInitialize()
--register sharedmedia
SM:Register("border", "Blank", [[Interface\AddOns\Icetip\media\blank.tga]]);
@@ -247,9 +241,9 @@ function Icetip:OnInitialize()
SM:Register("statusbar", "Smooth", [[Interface\AddOns\Icetip\media\Smooth.tga]]);
local db = LibStub("AceDB-3.0"):New("IcetipDB", default, "Default");
- db.RegisterCallback(self, "OnProfileChanged", "ProfileChanged");
- db.RegisterCallback(self, "OnProfileCopied", "ProfileChanged");
- db.RegisterCallback(self, "OnProfileReset", "ProfileChanged");
+ --db.RegisterCallback(self, "OnProfileChanged", "ProfileChanged");
+ --db.RegisterCallback(self, "OnProfileCopied", "ProfileChanged");
+ --db.RegisterCallback(self, "OnProfileReset", "ProfileChanged");
self.acedb = db;
self.db = db.profile;
@@ -278,19 +272,22 @@ function Icetip:OnEnable()
mod["OnEnable"](mod);
end
end
- --hook
+
for _, tooltip in pairs(tooltips) do
self:HookScript(tooltip, "OnShow", "GameTooltip_OnShow");
self:HookScript(tooltip, "OnHide", "GameTooltip_OnHide");
+
+ self:HookScript(tooltip, "OnUpdate", "GameTooltip_OnUpdate");
+
+ --self:HookScript(GameTooltip, "OnTooltipCleared", "")
+ self:HookScript(tooltip, "OnTooltipSetUnit", "GameTooltip_SetUnit");
+ self:HookScript(tooltip, "OnTooltipSetItem", "GameTooltip_SetItem");
+ self:HookScript(tooltip, "OnTooltipSetSpell", "GameTooltip_SetSpell")
+ --self:HookScript(GameTooltip, "OnTooltipSetQuest", "GameTooltip_SetQuest")
+ --self:HookScript(GameTooltip, "OnTooltipSetAchievement", "GameTooltip_SetAchievement")
end
- --self:HookScript(GameTooltip, "OnUpdate", "GameTooltip_OnUpdate");
- self:HookScript(GameTooltip, "OnTooltipSetUnit", "GameTooltip_SetUnit");
- self:HookScript(GameTooltip, "OnTooltipSetItem", "GameTooltip_SetItem");
- self:HookScript(GameTooltip, "OnTooltipSetSpell", "GameTooltip_SetSpell")
- --self:RawHook(GameTooltip, "FadeOut", "GameTooltip_FadeOut", true);
- --hack gametooltip
local tt = GameTooltip;
tt.GetBackdropColor = function()
return unpack(self.db.bgColor["other"])
@@ -318,6 +315,7 @@ function Icetip:OnEnable()
previousDead = nil
end
end, 0.05)
+
self:RegisterEvent("MODIFIER_STATE_CHANGED");
end
@@ -329,26 +327,53 @@ function Icetip:ShortValue(value)
end
end
-local forgetNextOnTooltipMethod = false
-
---update db
-function Icetip:ProfileChanged(db)
-
+function Icetip:GetMouseoverUnit()
+ local _, tooltipUnit = GameTooltip:GetUnit()
+ if not tooltipUnit or not UnitExists(tooltipUnit) or UnitIsUnit(tooltipUnit, "mouseover") then
+ return "mouseover"
+ else
+ return tooltipUnit
+ end
end
-function Icetip:GameTooltip_FadeOut(tooltip, ...)
- self.hooks[tooltip].FadeOut(tooltip, ...)
+function Icetip:MODIFIER_STATE_CHANGED(event, modifier, down)
+ local m = self.db.tipmodifier.modifier;
+ if modifier:match(m) == nil then
+ return
+ end
+ local frame = GetMouseFocus();
+ if frame == WorldFrame or frame == UIParent then
+ local mouseover_unit = self:GetMouseoverUnit();
+ if not UnitExists(mouseover_unit) then
+ GameTooltip:Hide()
+ end
+ GameTooltip:Hide();
+ GameTooltip_SetDefaultAnchor(GameTooltip, UIParent);
+ GameTooltip:SetUnit(mouseover_unit);
+ GameTooltip:Show();
+ else
+ local onLeave, onEnter = frame:GetScript("OnLeave"), frame:GetScript("OnEnter");
+ if onLeave then
+ self.modifierFrame = frame;
+ onLeave(frame);
+ self.modifierFrame = nil;
+ end
+ if onEnter then
+ self.modifierFrame = frame;
+ onEnter(frame);
+ self.modifierFrame = nil;
+ end
+ end
end
+local forgetNextOnTooltipMethod = false
function Icetip:GameTooltip_OnShow(tooltip, ...)
- modules["Appstyle"]:Tooltip_OnShow(tooltip, ...);
- tooltip:SetBackdropBorderColor(self.db["border_color"].r, self.db["border_color"].g, self.db["border_color"].b, self.db["border_color"].a);
+ self:CallMethodAllModules("PreOnTooltipShow", tooltip, ...);
- --only GameTooltip need fix
if tooltip == GameTooltip then
if not doneOnTooltipMethod then
if tooltip:GetUnit() then
- self:OnTooltipMethod("SetUnit");
+ self:OnTooltipMethod("SetUnit", tooltip, ...);
forgetNextOnTooltipMethod = true
elseif tooltip:GetItem() then
forgetNextOnTooltipMethod = true
@@ -404,6 +429,7 @@ function Icetip:GameTooltip_OnShow(tooltip, ...)
tooltip.justHide = nil
end
end
+
self.hooks[tooltip].OnShow(tooltip, ...)
self:CallMethodAllModules("OnTooltipShow", tooltip);
end
@@ -413,7 +439,6 @@ function Icetip:GameTooltip_OnHide(tooltip, ...)
forgetNextOnTooltipMethod = false
self:CallMethodAllModules("OnTooltipHide");
-
if self.hooks[tooltip] and self.hooks[tooltip].OnHide then
--reset gametooltip style
local ct = self.db.bgColor["other"];
@@ -429,63 +454,44 @@ function Icetip:GameTooltip_SetUnit(tooltip, ...)
if forgetNextOnTooltipMethod then
forgetNextOnTooltipMethod = false
else
- self:OnTooltipMethod("SetUnit");
+ self:OnTooltipMethod("SetUnit", tooltip, ...);
end
end
function Icetip:GameTooltip_SetItem(tooltip, ...)
- --forgetNextOnTooltipMethod = true
+ --local doneOnTooltipMethod = true
if forgetNextOnTooltipMethod then
forgetNextOnTooltipMethod = false
else
- self:OnTooltipMethod("SetItem");
+ self:OnTooltipMethod("SetItem", tooltip, ...);
end
end
function Icetip:GameTooltip_SetSpell(tooltip, ...)
-
+ --local doneOnTooltipMethod = true
+ if forgetNextOnTooltipMethod then
+ forgetNextOnTooltipMethod = false
+ else
+ self:OnTooltipMethod("SetSpell", tooltip, ...);
+ end
end
-function Icetip:GetMouseoverUnit()
- local _, tooltipUnit = GameTooltip:GetUnit()
- if not tooltipUnit or not UnitExists(tooltipUnit) or UnitIsUnit(tooltipUnit, "mouseover") then
- return "mouseover"
+function Icetip:GameTooltip_SetQuest(tooltip, ...)
+ if forgetNextOnTooltipMethod then
+ forgetNextOnTooltipMethod = false
else
- return tooltipUnit
+ self:OnTooltipMethod("SetQuest", tooltip, ...);
end
end
-function Icetip:MODIFIER_STATE_CHANGED(event, modifier, down)
- local m = self.db.tipmodifier.modifier;
- if modifier:match(m) == nil then
- return
- end
- local frame = GetMouseFocus();
- if frame == WorldFrame or frame == UIParent then
- local mouseover_unit = self:GetMouseoverUnit();
- if not UnitExists(mouseover_unit) then
- GameTooltip:Hide()
- end
- GameTooltip:Hide();
- GameTooltip_SetDefaultAnchor(GameTooltip, UIParent);
- GameTooltip:SetUnit(mouseover_unit);
- GameTooltip:Show();
+function Icetip:GameTooltip_SetAchievement(tooltip, ...)
+ if forgetNextOnTooltipMethod then
+ forgetNextOnTooltipMethod = false
else
- local onLeave, onEnter = frame:GetScript("OnLeave"), frame:GetScript("OnEnter");
- if onLeave then
- self.modifierFrame = frame;
- onLeave(frame);
- self.modifierFrame = nil;
- end
- if onEnter then
- self.modifierFrame = frame;
- onEnter(frame);
- self.modifierFrame = nil;
- end
+ self:OnTooltipMethod("SetAchievement", tooltip, ...);
end
end
function Icetip:GameTooltip_OnUpdate(tip, elapsed)
-
end
View
24 modules/appstyle.lua
@@ -1,16 +1,22 @@
local _, Icetip = ...
local SM = LibStub("LibSharedMedia-3.0");
local mod = Icetip:NewModule("Appstyle");
-
---local Icetip_Appstyle = {};
---Icetip.Appstyle = Icetip_Appstyle;
+local backdrop = {insets = {}};
+local hooked = {}
function mod:OnEnable()
end
-local backdrop = {insets = {}};
-local hooked = {}
+function mod:PreOnTooltipShow(tooltip, ...)
+ if hooked[tooltip] then
+ else
+ hooked[tooltip] = true
+ self:UpdateBackdrop(tooltip, ...)
+ end
+ tooltip:SetBackdropBorderColor(self.db["border_color"].r, self.db["border_color"].g, self.db["border_color"].b, self.db["border_color"].a);
+end
+
function mod:UpdateBackdrop(tooltip, ...)
if not tooltip then tooltip = GameTooltip end
@@ -28,14 +34,6 @@ function mod:UpdateBackdrop(tooltip, ...)
tooltip:SetBackdrop(backdrop);
end
---Onshow
-function mod:Tooltip_OnShow(tooltip, ...)
- if hooked[tooltip] then
- return
- end
- hooked[tooltip] = true
- self:UpdateBackdrop(tooltip, ...)
-end
function mod:OnTooltipShow(tooltip)
if self.db["tooltipStyle"].customColor then
View
2 modules/healthbar.lua
@@ -81,7 +81,7 @@ function mod:SetBarPoint()
end
end
-function mod:OnTooltipShow()
+function mod:OnTooltipSetUnit()
if not healthbar then
healthbar = CreateFrame("StatusBar", "Icetip_Health_Bar", GameTooltip);
healthbar:SetStatusBarTexture(SM:Fetch("statusbar", self.db.texture));
View
23 modules/itemref.lua
@@ -2,27 +2,32 @@ local _, Icetip = ...;
local mod = Icetip:NewModule("ItemRef");
local db;
+local colors = {}
+
function mod:OnEnable()
local db = self.db
end
-local function ItemQualityBorder()
- local tooltips = Icetip.tooltips
- for i=1, #tooltips do
- if not tooltips[i]["GetItem"] then return end
- local item = select(2, tooltips[i]:GetItem());
+function mod:PreTooltipSetItem(tooltip, ...)
+ if (tooltip["GetItem"]) then
+ local item = select(2, tooltip:GetItem());
if item then
local quality = select(3, GetItemInfo(item));
if quality then
local r, g, b = GetItemQualityColor(quality);
- tooltips[i]:SetBackdropBorderColor(r, g, b);
+ colors[tooltip] = {r, g, b}
end
end
end
end
-function mod:OnTooltipShow()
- if self.db.itemQBorder then
- ItemQualityBorder();
+function mod:OnTooltipShow(tooltip)
+ if self.db.itemQBorder and colors[tooltip] then
+ local r, g, b = unpack(colors[tooltip])
+ tooltip:SetBackdropBorderColor(r, g, b);
end
end
+
+function mod:OnTooltipHide()
+ wipe(colors)
+end
View
2 modules/mousetarget.lua
@@ -22,7 +22,7 @@ function mod:OnEnable()
self.db = db
end
-function mod:OnTooltipShow()
+function mod:PreTooltipSetUnit()
if GameTooltip:GetUnit() then
self:SetTooltipInfo(select(2, GameTooltip:GetUnit()));
end
View
2 modules/powerbar.lua
@@ -81,7 +81,7 @@ function mod:SetBarPoint()
end
end
-function mod:OnTooltipShow()
+function mod:OnTooltipSetUnit()
if not powerbar then
powerbar = CreateFrame("StatusBar", "Icetip_Power_Bar", GameTooltip);
powerbar:SetStatusBarTexture(SM:Fetch("statusbar", self.db.texture));

No commit comments for this range

Something went wrong with that request. Please try again.