WoWInterface SVN TipTop

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /branches/2.0
    from Rev 44 to Rev 45
    Reverse comparison

Rev 44 → Rev 45

TipTopOptions.lua
1,564 → 1,6
local f = CreateFrame("FRAME")
local LSM = LibStub("LibSharedMedia-3.0")
local widgetLists = AceGUIWidgetLSMlists
local db
 
local positions = {"TOP", "TOPRIGHT", "TOPLEFT",
"BOTTOM", "BOTTOMRIGHT", "BOTTOMLEFT",
"RIGHT", "LEFT", "CENTER"}
local formats = {"100/100", "100%", "100/100 (100%)"}
 
local defaults = {
alpha = 1,
scale = 1,
font = "Friz Quadrata TT",
bg = "brushed",
bgColor = {r=.09, g=.09, b=.19}, --TOOLTIP_DEFAULT_BACKGROUND_COLOR
border = "Seerah Solid",
borderWidth = 2.5,
inset = 0,
classColor = true,
itemColor = true,
borderColor = {r=.6, g=.6, b=.6, a=1},
healthBar = "TipTop Default",
sbarbg = "TipTop Default",
sbarbgcolor = {r=0, g=0, b=0, a=.4},
topBar = false,
raidIconSize = 16,
raidIconPosition = "TOP",
raidIconX = "0",
raidIconY = "0",
onCursor = false,
anchor = "BOTTOMRIGHT",
offsetX = "-2",
offsetY = "109",
showTargetText = true,
you = true,
showTalentText = true,
healthText = true,
textformat = "100%",
}
 
 
local function SetUpDB()
if TipTopPCDB.charSpec then
--set defaults if new charSpec DB
for k,v in pairs(defaults) do
if type(TipTopPCDB[k]) == "nil" then
TipTopPCDB[k] = v
end
end
db = TipTopPCDB
else
db = TipTopDB
end
end
 
local function ConfirmProfilePopup()
if not StaticPopupDialogs["TIPTOP_PROFILE"] then
StaticPopupDialogs["TIPTOP_PROFILE"] = {
text = "Are you sure you want to change your profile and reload your UI?",
button1 = "Yes",
button2 = "No",
OnAccept = function() ReloadUI() end,
OnCancel = function()
TipTopPCDB.charSpec = not TipTopPCDB.charSpec
LibStub("AceConfigRegistry-3.0"):NotifyChange("TipTop")
print("Your profile switch has been cancelled.")
end,
timeout = 0,
whileDead = 1,
hideOnEscape = 1
}
end
StaticPopup_Show("TIPTOP_PROFILE")
end
 
 
local options = {
name = "TipTop Options",
type = "group",
args = {
header1 = {
name = "Appearance",
type = "header",
order = 1,
},
font = {
name = "Font",
desc = "Select the font for the tooltip and health text.",
type = "select",
dialogControl = "LSM30_Font",
values = widgetLists.font,
get = function()
return db.font
end,
set = function(self, font)
db.font = font
TipTop:SetUpTips()
end,
order = 2,
},
scale = {
name = "Tooltip scale",
desc = "The scale of the entire tooltip.",
type = "range",
min = .5,
max = 2,
step = .05,
get = function() return db.scale end,
set = function(_, scale)
db.scale = scale
TipTop:SetUpTips()
end,
order = 3,
},
bgColor = {
name = "Background Color/Alpha",
desc = "The background color and transparency.\n\nIf you wish to use a custom background texture and do not want it colored, set this to white.",
type = "color",
hasAlpha = true,
get = function() return db.bgColor.r, db.bgColor.g, db.bgColor.b, db.alpha end,
set = function(_,r,g,b,a)
db.bgColor.r = r
db.bgColor.g = g
db.bgColor.b = b
db.alpha = a
TipTop:SetUpTips()
end,
order = 4,
},
bg = {
name = "Background",
desc = "Texture to use as the tip's background.",
type = "select",
dialogControl = "LSM30_Background",
values = widgetLists.background,
get = function()
return db.bg
end,
set = function(self, bg)
db.bg = bg
TipTop:SetUpTips()
end,
order = 5,
},
empty1 = {
name = " ",
type = "description",
order = 6,
},
header2 = {
name = "Health Bar",
type = "header",
order = 7,
},
healthBar = {
name = "Health bar texture",
desc = "Texture to use for the status bar below the tooltip.",
type = "select",
dialogControl = "LSM30_Statusbar",
values = widgetLists.statusbar,
get = function()
return db.healthBar
end,
set = function(self, healthBar)
db.healthBar = healthBar
TipTop:SetUpTips()
end,
order = 8,
},
topBar = {
name = "Health bar on top",
desc = "If checked, the health bar will be displayed above the tooltip instead of below.",
type = "toggle",
get = function() return db.topBar end,
set = function()
db.topBar = not db.topBar
TipTop:SetUpTips()
end,
order = 8.5,
},
sbarbg = {
name = "Background texture",
desc = "Texture to use for the status bar's background.",
type = "select",
dialogControl = "LSM30_Statusbar",
values = widgetLists.statusbar,
get = function()
return db.sbarbg
end,
set = function(self, sbarbg)
db.sbarbg = sbarbg
TipTop:SetUpTips()
end,
order = 9,
},
sbarbgcolor = {
name = "Background Color",
desc = "The color of the health bar's background.",
type = "color",
hasAlpha = true,
get = function() return db.sbarbgcolor.r, db.sbarbgcolor.g, db.sbarbgcolor.b, db.sbarbgcolor.a end,
set = function(_,r,g,b,a)
db.sbarbgcolor.r = r
db.sbarbgcolor.g = g
db.sbarbgcolor.b = b
db.sbarbgcolor.a = a
TipTop:SetUpTips()
end,
order = 9.5,
},
healthText = {
name = "Health text",
desc = "If checked, health percentage will be displayed on the tooltip's status bar.",
type = "toggle",
get = function() return db.healthText end,
set = function()
db.healthText = not db.healthText
if db.healthText == true then
ttHealth:Show()
else
ttHealth:Hide()
end
end,
order = 10,
},
textformat = {
name = "Text format",
desc = "Select how you would like health text displayed.",
type = "select",
disabled = function() return not db.healthText end,
values = formats,
get = function()
for k, v in pairs(formats) do
if db.textformat == v then
return k
end
end
end,
set = function(_, textformat)
db.textformat = formats[textformat]
TipTop:HealthFormat(db.textformat)
end,
order = 10.5,
},
empty2 = {
name = " ",
type = "description",
order = 10.75,
},
header3 = {
name = "Borders",
type = "header",
order = 11,
},
border = {
name = "Border",
desc = "Texture for the tooltip borders.",
type = "select",
dialogControl = "LSM30_Border",
values = widgetLists.border,
get = function()
return db.border
end,
set = function(self, border)
db.border = border
TipTop:SetUpTips()
end,
order = 12,
},
borderColor = {
name = "Border color",
desc = "Color of the border when not class or item quality colored.",
type = "color",
hasAlpha = true,
get = function() return db.borderColor.r, db.borderColor.g, db.borderColor.b, db.borderColor.a end,
set = function(_,r,g,b,a)
db.borderColor.r = r
db.borderColor.g = g
db.borderColor.b = b
db.borderColor.a = a
TipTop:SetUpTips()
end,
order = 13,
},
borderWidth = {
name = "Border Width",
desc = "Width of the border.",
type = "range",
min = 1,
max = 24,
step = .5,
get = function() return db.borderWidth end,
set = function(_, borderWidth)
db.borderWidth = borderWidth
TipTop:SetUpTips()
end,
order = 14,
},
inset = {
name = "Inset",
desc = "The inset of the background from the border texture.",
type = "range",
min = 0,
max = 10,
step = .5,
get = function() return db.inset end,
set = function(_, inset)
db.inset = inset
TipTop:SetUpTips()
end,
order = 14.5,
},
classColor = {
name = "Class-colored borders",
desc = "If checked, the border is colored by class when mousing over a unit",
type = "toggle",
get = function() return db.classColor end,
set = function()
db.classColor = not db.classColor
end,
order = 15,
},
itemColor = {
name = "Item quality borders",
desc = "If checked, the border is colored by item quality when mousing over an item",
type = "toggle",
get = function() return db.itemColor end,
set = function()
db.itemColor = not db.itemColor
end,
order = 16,
},
empty3 = {
name = " ",
type = "description",
order = 17,
},
header4 = {
name = "Raid Icon",
type = "header",
order = 18,
},
raidIconSize = {
name = "Raid icon size",
desc = "Width and height of the raid icon on the tooltip",
type = "range",
min = 8,
max = 32,
step = 1,
get = function() return db.raidIconSize end,
set = function(_, raidIconSize)
db.raidIconSize = raidIconSize
TipTop:SetUpTips()
end,
order = 19,
},
raidIconPosition = {
name = "Raid icon position",
desc = "What side of the tip you would like the icon located at.",
type = "select",
values = positions,
get = function()
for k, v in pairs(positions) do
if db.raidIconPosition == v then
return k
end
end
end,
set = function(_, raidIconPosition)
db.raidIconPosition = positions[raidIconPosition]
TipTop:SetUpTips()
end,
order = 20,
},
raidIconX = {
name = "X Offset",
desc = "Offsets from the icon's position left/right",
type = "input",
get = function() return db.raidIconX end,
set = function(_,raidIconX)
if raidIconX == nil or raidIconX == "" then
raidIconX = "0"
end
db.raidIconX = raidIconX
TipTop:SetUpTips()
end,
order = 21,
},
raidIconY = {
name = "Y Offset",
desc = "Offsets from the icon's position up/down",
type = "input",
get = function() return db.raidIconY end,
set = function(_,raidIconY)
if raidIconY == nil or raidIconY == "" then
raidIconY = "0"
end
db.raidIconY = raidIconY
TipTop:SetUpTips()
end,
order = 22,
},
empty4 = {
name = " ",
type = "description",
order = 23,
},
header5 = {
name = "Position",
type = "header",
order = 24,
},
onCursor = {
name = "On Cursor",
desc = "Whether you want the tooltip attached to the cursor or not.\n\nNote: If checked, anchor and offsets below do not apply.",
type = "toggle",
get = function() return db.onCursor end,
set = function()
db.onCursor = not db.onCursor
end,
order = 25,
},
anchor = {
name = "Tip Anchor",
desc = "What side of the screen you would like the tooltip located at.",
type = "select",
disabled = function() return db.onCursor end,
values = positions,
get = function()
for k, v in pairs(positions) do
if db.anchor == v then
return k
end
end
end,
set = function(_, anchor)
db.anchor = positions[anchor]
end,
order = 26,
},
offsetX = {
name = "X Offset",
desc = "Offsets from the tooltip's anchor left/right",
type = "input",
disabled = function() return db.onCursor end,
get = function() return db.offsetX end,
set = function(_,offsetX)
if offsetX == nil or offsetX == "" then
offsetX = "0"
end
db.offsetX = offsetX
end,
order = 27,
},
offsetY = {
name = "Y Offset",
desc = "Offsets from the tooltip's anchor up/down",
type = "input",
disabled = function() return db.onCursor end,
get = function() return db.offsetY end,
set = function(_,offsetY)
if offsetY == nil or offsetY == "" then
offsetY = "0"
end
db.offsetY = offsetY
end,
order = 28,
},
empty5 = {
name = " ",
type = "description",
order = 29,
},
header6 = {
name = "Extra Lines",
type = "header",
order = 30,
},
showTargetText = {
name = "Target text",
desc = "Whether you wish to view the mouseover unit's target in the tooltip",
type = "toggle",
get = function() return db.showTargetText end,
set = function()
db.showTargetText = not db.showTargetText
end,
order = 31,
},
you = {
name = "Target emphasis",
desc = "When checked, if the mouseover unit's target is you, it will be displayed as |c00E30016<<YOU>>|r.",
type = "toggle",
disabled = function() return not db.showTargetText end,
get = function() return db.you end,
set = function()
db.you = not db.you
end,
order = 32,
},
showTalentText = {
name = "Talent text",
desc = "Whether you wish to view the mouseover unit's talent info in the tooltip",
type = "toggle",
get = function() return db.showTalentText end,
set = function()
db.showTalentText = not db.showTalentText
end,
order = 33,
},
empty6 = {
name = " ",
type = "description",
order = 34,
},
header7 = {
name = "Profile",
type = "header",
order = 35,
},
charSpec = {
name = "Character specific settings",
desc = "Have this character use their own profile. If checked, any changes made will not affect other characters.\n\n|c00E30016WARNING:|r Your UI will be reloaded in the process!",
type = "toggle",
width = "full",
get = function() return TipTopPCDB.charSpec end,
set = function()
TipTopPCDB.charSpec = not TipTopPCDB.charSpec
ConfirmProfilePopup()
end,
order = 36,
},
},
}
 
local function OnInitialize()
TipTopDB = TipTopDB or {}
TipTopPCDB = TipTopPCDB or {}
if TipTopPCDB.charSpec == nil then
TipTopPCDB.charSpec = false
end
for k,v in pairs(defaults) do
if type(TipTopDB[k]) == "nil" then
TipTopDB[k] = v
end
end
SetUpDB()
 
LibStub("AceConfig-3.0"):RegisterOptionsTable("TipTop", options)
TipTop.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("TipTop", "TipTop")
 
SlashCmdList["TIPTOP"] = function() InterfaceOptionsFrame_OpenToCategory("TipTop") end
SLASH_TIPTOP1 = "/tiptop"
SLASH_TIPTOP2 = "/tip"
end
LSM:Register("statusbar", "TipTop Default", "Interface\\AddOns\\TipTop\\bar2.blp")
LSM:Register("statusbar", "TipTop Alt", "Interface\\AddOns\\TipTop\\bar1.blp")
LSM:Register("border", "Seerah Solid", "Interface\\AddOns\\TipTop\\SeerahSolidBorder.blp")
LSM:Register("background", "brushed", "Interface\\AddOns\\TipTop\\brushed.tga")
--end
 
 
f:SetScript("OnEvent", OnInitialize)
f:RegisterEvent("PLAYER_LOGIN")
\ No newline at end of file + LSM:Register("background", "brushed", "Interface\\AddOns\\TipTop\\brushed.tga") \ No newline at end of file
tiptop.lua
1,65 → 1,49
TipTop = CreateFrame("FRAME", nil, GameTooltip)
--this is the defaults table from TipTopOptions.lua
--just placed here as the db table for now
local db = {
alpha = 1,
scale = 1,
font = "Friz Quadrata TT",
bg = "brushed",
bgColor = {r=.09, g=.09, b=.19}, --TOOLTIP_DEFAULT_BACKGROUND_COLOR
border = "Seerah Solid",
borderWidth = 2.5,
inset = 0,
classColor = true,
itemColor = true,
borderColor = {r=.6, g=.6, b=.6, a=1},
healthBar = "TipTop Default",
sbarbg = "TipTop Default",
sbarbgcolor = {r=0, g=0, b=0, a=.4},
topBar = false,
raidIconSize = 16,
raidIconPosition = "TOP",
raidIconX = "0",
raidIconY = "0",
onCursor = false,
anchor = "BOTTOMRIGHT",
offsetX = "-2",
offsetY = "109",
showTargetText = true,
you = true,
showTalentText = true,
healthText = true,
textformat = "100%",
}
 
------------------------------------
--------OTHER LOCALS-------
------------------------------------
TipTop = CreateFrame("FRAME", nil, GameTooltip)
local TipTop = TipTop
local LSM = LibStub("LibSharedMedia-3.0")
local db
local font
local tt = GameTooltip
local irt = ItemRefTooltip
local ttSBar = GameTooltipStatusBar
local ttSBarBG = CreateFrame("Frame", nil, ttSBar)
local ttHealth = ttSBar:CreateFontString("ttHealth", "OVERLAY")
local height = GameTooltipStatusBar:GetHeight()
local color
local player = UnitName("player")
local server = GetRealmName()
local target, tclass, tserver, targetLine, _, active, tree, pnts, spec, points, lasthp, lastmax, textformat
local talents = {}
local raidIcon = ttSBar:CreateTexture(nil, "OVERLAY")
local tooltips = { GameTooltip,
local tooltips = { --GameTooltip,
ItemRefTooltip,
ShoppingTooltip1,
ShoppingTooltip2,
ShoppingTooltip3}
ShoppingTooltip3,
TipTop}
 
-------------------------
-----UPVALUES-----
-------------------------
--local _G = getfenv(0)
local _G = _G
local table_sort = _G.table.sort
--local CanInspect = _G.CanInspect
local GetItemInfo = _G.GetItemInfo
local GetItemQualityColor = _G.GetItemQualityColor
local GetRaidTargetIndex = _G.GetRaidTargetIndex
local GetTalentTabInfo = _G.GetTalentTabInfo
--local NotifyInspect = _G.NotifyInspect
local SetRaidTargetIconTexture = _G.SetRaidTargetIconTexture
local UnitClass = _G.UnitClass
local UnitClassification = _G.UnitClassification
local UnitExists = _G.UnitExists
local UnitHealth = _G.UnitHealth
local UnitIsAFK = _G.UnitIsAFK
local UnitIsConnected = _G.UnitIsConnected
local UnitIsDead = _G.UnitIsDead
local UnitIsDND = _G.UnitIsDND
local UnitIsTapped = _G.UnitIsTapped
local UnitIsTappedByPlayer = _G.UnitIsTappedByPlayer
local UnitLevel = _G.UnitLevel
local UnitHealthMax = _G.UnitHealthMax
local UnitName = _G.UnitName
local UnitPlayerControlled = _G.UnitPlayerControlled
 
--------------------------------------
--APPEARANCE/FEATURES--
--------------------------------------
 
function TipTop:SetUpTips()
font = LSM:Fetch("font", db.font)
 
--backgrounds/borders--
local function SetBackgrounds()
for i = 1, #tooltips do
tooltips[i]:SetScale(db.scale)
tooltips[i]:SetBackdrop({
70,387 → 54,56
})
tooltips[i]:SetBackdropColor(db.bgColor.r, db.bgColor.g, db.bgColor.b, db.alpha)
tooltips[i]:SetBackdropBorderColor(db.borderColor.r, db.borderColor.g, db.borderColor.b, db.borderColor.a)
tt:SetBackdrop(nil)
end
 
--healthbar--
ttSBar:SetStatusBarTexture(LSM:Fetch("statusbar", db.healthBar))
if db.topBar then
ttSBar:ClearAllPoints()
ttSBar:SetPoint("BOTTOM", tt, "TOP", 0, 2)
else
ttSBar:ClearAllPoints()
ttSBar:SetPoint("TOP", tt, "BOTTOM", 0, -2)
end
ttSBarBG:SetAllPoints()
ttSBarBG:SetFrameLevel(ttSBar:GetFrameLevel() - 1)
ttSBarBG:SetBackdrop({bgFile = LSM:Fetch("statusbar", db.sbarbg)})
ttSBarBG:SetBackdropColor(db.sbarbgcolor.r, db.sbarbgcolor.g, db.sbarbgcolor.b, db.sbarbgcolor.a)
 
--health % on status bar--
ttHealth:SetFont(font, 12, "OUTLINE")
ttHealth:SetParent(ttSBar)
ttHealth:SetPoint("CENTER", ttSBar, "CENTER")
 
--raid icon--
raidIcon:SetWidth(db.raidIconSize)
raidIcon:SetHeight(db.raidIconSize)
raidIcon:SetTexture("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcons")
raidIcon:SetPoint("CENTER", tt, db.raidIconPosition, db.raidIconX, db.raidIconY)
raidIcon:Hide()
 
--fonts--
GameTooltipHeaderText:SetFont(font, 12 + 2)
GameTooltipText:SetFont(font, 12)
GameTooltipTextSmall:SetFont(font, 12 - 2)
ShoppingTooltip1TextLeft1:SetFont(font, 12 -2)
ShoppingTooltip1TextLeft2:SetFont(font, 12)
ShoppingTooltip1TextLeft3:SetFont(font, 12 -2)
ShoppingTooltip2TextLeft1:SetFont(font, 12 -2)
ShoppingTooltip2TextLeft2:SetFont(font, 12)
ShoppingTooltip2TextLeft3:SetFont(font, 12 -2)
ShoppingTooltip3TextLeft1:SetFont(font, 12 -2)
ShoppingTooltip3TextLeft2:SetFont(font, 12)
ShoppingTooltip3TextLeft3:SetFont(font, 12 -2)
end
 
local function ShoppingTipOne()
for i = 1, ShoppingTooltip1:NumLines() do
_G["ShoppingTooltip1TextRight"..i]:SetFont(font, 12 -2)
end
local function SBarContainer()
ttSBar:ClearAllPoints()
ttSBar:SetPoint("BOTTOMRIGHT", tt, "BOTTOMRIGHT", -7, -1)
ttSBar:SetPoint("BOTTOMLEFT", tt, "BOTTOMLEFT", 10, -1)
TipTop:SetPoint("TOPRIGHT", tt, "TOPRIGHT")
TipTop:SetPoint("BOTTOMLEFT", ttSBar, "BOTTOMLEFT", -5, -7)
tt:SetFrameLevel(10)
TipTop:SetFrameLevel(9)
end
 
local function ShoppingTipTwo()
for i = 1, ShoppingTooltip2:NumLines() do
_G["ShoppingTooltip2TextRight"..i]:SetFont(font, 12 -2)
end
end
 
local function ShoppingTipThree()
for i = 1, ShoppingTooltip3:NumLines() do
_G["ShoppingTooltip3TextRight"..i]:SetFont(font, 12 -2)
end
end
 
 
local function BorderClassColor()
if db.classColor then
local _,class = UnitClass("mouseover") --or UnitClass(GameTooltip:GetUnit())
if class then
tt:SetBackdropBorderColor(color[class].r - .2, color[class].g - .2, color[class].b - .2, db.borderColor.a)
end
else
local borderColor = db.borderColor
tt:SetBackdropBorderColor(borderColor.r, borderColor.g, borderColor.b, borderColor.a)
end
end
 
local function ItemQualityBorder()
if db.itemColor then
for i = 1, #tooltips do
local _,item = tooltips[i]:GetItem()
if item then
local _,_,quality = GetItemInfo(item)
if quality then
local r,g,b = GetItemQualityColor(quality)
tooltips[i]:SetBackdropBorderColor(r - .2, g - .2, b - .2, db.borderColor.a)
end
tt:HookScript("OnTooltipSetUnit", function() print("unit") end)
tt:HookScript("OnShow", function()
if ttSBar:IsShown() then
TipTop:ClearAllPoints()
TipTop:SetPoint("TOPRIGHT", tt, "TOPRIGHT")
TipTop:SetPoint("BOTTOMLEFT", ttSBar, "BOTTOMLEFT", -7, -7)
else
TipTop:ClearAllPoints()
TipTop:SetAllPoints(tt)
end
end
end
end
end)
 
local function FadeTip()
local tapped = false
if not UnitPlayerControlled("mouseover") then
if UnitIsTapped("mouseover") and not UnitIsTappedByPlayer("mouseover") then
tapped = true
end
end
if UnitIsDead("mouseover") or tapped or not UnitIsConnected("mouseover") then
local borderColor = db.borderColor
tt:SetBackdropBorderColor(borderColor.r, borderColor.g, borderColor.b, borderColor.a)
local bgColor = db.bgColor
tt:SetBackdropColor(bgColor.r + .2, bgColor.g +.2, bgColor.b + .2, db.alpha)
end
local function Initialize()
SetBackgrounds()
SBarContainer()
end
 
local function MinWidth()
if tt:GetWidth() < 125 then
tt:SetWidth(125)
end
end
 
local function SBarContainerUpdate()
tt:Show()
MinWidth()
local width = tt:GetWidth()
ttSBar:SetWidth(width)
end
 
local function RaidIconUpdate()
local icon = GetRaidTargetIndex("mouseover")
if icon then
SetRaidTargetIconTexture(raidIcon, icon)
raidIcon:Show()
else
raidIcon:Hide()
end
end
 
local function TargetTextLine()
target, tserver = UnitName("mouseovertarget")
_,tclass = UnitClass("mouseovertarget")
if tclass and target ~= UNKNOWN then
if db.you and target == player and (tserver == nil or tserver == server) then
tt:AddDoubleLine("Target:", "<<YOU>>", nil, nil, nil, .9, 0, .1)
else
local tcolor = color[tclass]
tt:AddDoubleLine("Target:", target, nil,nil,nil,tcolor.r,tcolor.g,tcolor.b)
end
SBarContainerUpdate()
end
end
 
local function TargetTextUpdate()
target, tserver = UnitName("mouseovertarget")
_,tclass = UnitClass("mouseovertarget")
if target and target ~= UNKNOWN then
for i=1, GameTooltip:NumLines() do
local left, right, leftText, rightText
left = getglobal(GameTooltip:GetName().."TextLeft"..i)
leftText = left:GetText()
right = getglobal(GameTooltip:GetName().."TextRight"..i)
if leftText == "Target:" then
if db.you and target == player and (tserver == nil or tserver == server) then
right:SetText("<<YOU>>")
right:SetTextColor(.9, 0, .1)
else
right:SetText(target)
right:SetTextColor(color[tclass].r,color[tclass].g,color[tclass].b)
end
tt:Show()
SBarContainerUpdate()
targetLine = true
end
end
if targetLine ~= true then
TargetTextLine()
else
targetLine = false
end
end
end
 
local function TalentQuery()
if CanInspect("mouseover") and db.showTalentText then
if UnitName("mouseover") ~= player and UnitLevel("mouseover") > 9 then
local talentline = nil
for i=1, GameTooltip:NumLines() do
local left, leftText
left = getglobal(GameTooltip:GetName().."TextLeft"..i)
leftText = left:GetText()
if leftText == "Talents:" then
talentline = 1
end
end
if not talentline then
if InspectFrame and InspectFrame:IsShown() then
tt:AddDoubleLine("Talents:", "Inspect Frame is open")
elseif Examiner and Examiner:IsShown() then
tt:AddDoubleLine("Talents:", "Examiner frame is open")
else
NotifyInspect("mouseover")
tt:RegisterEvent("INSPECT_TALENT_READY")
tt:AddDoubleLine("Talents:", "...")
end
SBarContainerUpdate()
end
end
end
end
 
local function TalentsSort(a,b)
return a.pnts > b.pnts
end
 
local function TalentText()
if UnitExists("mouseover") then
active = GetActiveTalentGroup(1)
for i=1,3 do
tree,_,pnts = GetTalentTabInfo(i, 1, nil, active)
talents[i] = {tree = tree, pnts = pnts}
end
points = talents[1].pnts.."/"..talents[2].pnts.."/"..talents[3].pnts
spec = talents
table_sort(spec, TalentsSort)
for i=1, GameTooltip:NumLines() do
local left, right, leftText
left = getglobal(GameTooltip:GetName().."TextLeft"..i)
leftText = left:GetText()
right = getglobal(GameTooltip:GetName().."TextRight"..i)
if leftText == "Talents:" then
right:SetText(spec[1].tree.." ("..points..")")
end
SBarContainerUpdate()
end
end
tt:UnregisterEvent("INSPECT_TALENT_READY")
end
 
local function Appendices()
local classif = UnitClassification("mouseover")
if classif == "rare" or classif == "rareelite" then
tt:AppendText(" (Rare)")
end
if UnitIsAFK("mouseover") then
tt:AppendText(" (AFK)")
end
if UnitIsDND("mouseover") then
tt:AppendText(" (DND)")
end
end
 
local function MouseoverTargetUpdate()
RaidIconUpdate()
BorderClassColor()
Appendices()
FadeTip()
TalentQuery()
SBarContainerUpdate()
end
 
local function TipShow()
if tt:GetUnit() then
BorderClassColor()
SBarContainerUpdate()
elseif tt:GetItem() then
ItemQualityBorder()
else
local borderColor = db.borderColor
tt:SetBackdropBorderColor(borderColor.r, borderColor.g, borderColor.b, borderColor.a)
end
local bgColor = db.bgColor
tt:SetBackdropColor(bgColor.r, bgColor.g, bgColor.b, db.alpha)
end
 
function TipTop:HealthFormat(textformat)
local ttSBarBG_OnUpdate
if textformat == "100/100" then
ttSBarBG_OnUpdate = function()
if db.healthText then
local hp = UnitHealth("mouseover")
local maxhp = UnitHealthMax("mouseover")
if hp ~= lasthp or maxhp ~= lastmax then
ttHealth:SetFormattedText("%d / %d", hp, maxhp)
lasthp = hp
lastmax = maxhp
end
end
if db.showTargetText and UnitExists("mouseovertarget") then
TargetTextUpdate()
end
end
elseif textformat == "100%" then
ttSBarBG_OnUpdate = function()
if db.healthText then
hp = ttSBar:GetValue()
_,maxhp = ttSBar:GetMinMaxValues()
if hp ~= lasthp or maxhp ~= lastmax then
local per = (hp/maxhp)*100
if per >= 0 then --was showing odd percent values after moving mouse, before tip faded
ttHealth:SetFormattedText("%d%%", per)
end
lasthp = hp
lastmax = maxhp
end
end
if db.showTargetText and UnitExists("mouseovertarget") then
TargetTextUpdate()
end
end
elseif textformat == "100/100 (100%)" then
ttSBarBG_OnUpdate = function()
if db.healthText then
local hp = UnitHealth("mouseover")
local maxhp = UnitHealthMax("mouseover")
if hp ~= lasthp or maxhp ~= lastmax then
local per = (hp/maxhp)*100
if per >= 0 then
ttHealth:SetFormattedText("%d / %d (%d%%)", hp, maxhp, per)
end
lasthp = hp
lastmax = maxhp
end
end
if db.showTargetText and UnitExists("mouseovertarget") then
TargetTextUpdate()
end
end
end
ttSBarBG:SetScript("OnUpdate", ttSBarBG_OnUpdate)
end
 
 
 
local function SetScriptHook(frame, script, func)
if frame:GetScript(script) then
frame:HookScript(script, func)
else
frame:SetScript(script, func)
end
end
 
local function PlayerLogin()
if TipTopPCDB.charSpec then
db = TipTopPCDB
else
db = TipTopDB
end
TipTop:SetUpTips()
 
color = CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS
 
if CUSTOM_CLASS_COLORS then
CUSTOM_CLASS_COLORS:RegisterCallback(function() color = CUSTOM_CLASS_COLORS end)
end
 
hooksecurefunc("GameTooltip_SetDefaultAnchor", function (tooltip, parent)
if db.onCursor then
tt:SetOwner(parent, "ANCHOR_CURSOR")
--[[tt:HookScript("OnTooltipSetUnit", function() print("unit: "..tt:GetUnit()) end)
tt:HookScript("OnTooltipSetItem", function() print("item: "..tt:GetItem()) end)
tt:HookScript("OnTooltipSetAchievement", function() print("achievement: ") end)
tt:HookScript("OnTooltipSetEquipmentSet", function() print("set: ") end)
tt:HookScript("OnTooltipSetQuest", function() print("quest: ") end)
tt:HookScript("OnTooltipSetSpell", function() print("spell: "..tt:GetSpell()) end)
]]--
--[[tt:HookScript("OnShow", function()
if tt:GetUnit() then
print("unit")
elseif tt:GetItem() then
print("item")
elseif tt:GetSpell() then
print("spell")
else
tt:SetOwner(parent, "ANCHOR_NONE")
tt:SetPoint(db.anchor, UIParent, db.anchor, db.offsetX, db.offsetY)
print("else")
end
end)
]]--
 
local tt_OnEvent = function(self, event)
if event == "UPDATE_MOUSEOVER_UNIT" then
MouseoverTargetUpdate()
elseif event == "INSPECT_TALENT_READY" then
TalentText()
end
end
SetScriptHook(tt, "OnEvent", tt_OnEvent)
 
local irt_OnShow = function()
ItemQualityBorder()
local bgColor = db.bgColor
irt:SetBackdropColor(bgColor.r,bgColor.g,bgColor.b,db.alpha)
end
SetScriptHook(irt, "OnShow", irt_OnShow)
 
TipTop:HealthFormat(db.textformat)
 
TipTop:SetScript("OnShow", TipShow)
ShoppingTooltip1:SetScript("OnShow", function() ShoppingTipOne() ItemQualityBorder() end)
ShoppingTooltip2:SetScript("OnShow", function() ShoppingTipTwo() ItemQualityBorder() end)
ShoppingTooltip3:SetScript("OnShow", function() ShoppingTipThree() ItemQualityBorder() end)
 
TipTop:UnregisterEvent("PLAYER_LOGIN")
PlayerLogin = nil
end
 
TipTop:SetScript("OnEvent", PlayerLogin)
 
tt:RegisterEvent("UPDATE_MOUSEOVER_UNIT")
TipTop:RegisterEvent("PLAYER_LOGIN")
\ No newline at end of file +TipTop:RegisterEvent("PLAYER_LOGIN") +TipTop:SetScript("OnEvent", Initialize) \ No newline at end of file