WoWInterface SVN TipTop

Compare Revisions

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

Rev 51 → Rev 52

TipTopOptions.lua
1,6 → 1,638
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",
sbarcolor = {r=0, g=1, b=0, a=1},
sbarbg = "TipTop Default",
sbarbgcolor = {r=0, g=0, b=0, a=.4},
topBar = false,
insideBar = 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 = {
general = {
name = "Tip Top",
type = "group",
args = {
header1 = {
name = "General",
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:SetFonts()
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:SetBackgrounds()
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:SetBackgrounds()
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:SetBackgrounds()
end,
order = 5,
},
empty1 = {
name = " ",
type = "description",
order = 6,
},
empty5 = {
name = " ",
type = "description",
order = 30,
},
header5 = {
name = "Tooltip Position",
type = "header",
order = 31,
},
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 = 32,
},
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 = 33,
},
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 = 34,
},
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 = 35,
},
},
},
baropts = {
name = "Health Bar",
type = "group",
args = {
header2 = {
name = "",
type = "group",
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:SBarCustom()
end,
order = 8,
},
sbarcolor = {
name = "Health bar color",
desc = "The color of the health bar.",
type = "color",
hasAlpha = true,
get = function() return db.sbarcolor.r, db.sbarcolor.g, db.sbarcolor.b, db.sbarcolor.a end,
set = function(_,r,g,b,a)
db.sbarcolor.r = r
db.sbarcolor.g = g
db.sbarcolor.b = b
db.sbarcolor.a = a
TipTop:SBarCustom()
end,
order = 9,
},
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:SBarPosition()
end,
order = 10,
},
insideBar = {
name = "Health bar inside",
desc = "If checked, the health bar will be displayed within the tooltip frame.",
type = "toggle",
get = function() return db.insideBar end,
set = function()
db.insideBar = not db.insideBar
TipTop:SBarPosition()
end,
order = 11,
},
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:SBarCustom()
end,
order = 12,
},
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:SBarCustom()
end,
order = 13,
},
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 = 14,
},
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]
end,
order = 15,
},
},
},
-- empty2 = {
-- name = " ",
-- type = "description",
-- order = 16,
-- },
borderopts = {
name = "Borders",
type = "group",
args = {
header3 = {
name = "",
type = "header",
order = 17,
},
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:SetBackgrounds()
end,
order = 18,
},
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:SetBackgrounds()
end,
order = 19,
},
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:SetBackgrounds()
end,
order = 20,
},
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:SetBackgrounds()
end,
order = 21,
},
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 = 22,
},
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 = 23,
},
},
},
-- empty3 = {
-- name = " ",
-- type = "description",
-- order = 24,
-- },
riconopts = {
name = "Raid Icon",
type = "group",
args = {
header4 = {
name = "",
type = "header",
order = 25,
},
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:RaidIcon()
end,
order = 26,
},
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:RaidIcon()
end,
order = 27,
},
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:RaidIcon()
end,
order = 28,
},
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:RaidIcon()
end,
order = 29,
},
},
},
-- empty4 = {
-- name = " ",
-- type = "description",
-- order = 30,
-- },
extraopts = {
name = "Extra Lines",
type = "group",
args = {
header6 = {
name = "",
type = "header",
order = 37,
},
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 = 38,
},
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 = 39,
},
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 = 40,
},
},
},
-- empty6 = {
-- name = " ",
-- type = "description",
-- order = 41,
-- },
profile = {
name = "Profile",
type = "group",
args = {
header7 = {
name = "",
type = "header",
order = 42,
},
charSpec = {
name = "Character specific settings",
desc = "Change to character specific settings.",
type = "toggle",
width = "full",
get = function() return TipTopPCDB.charSpec end,
set = function()
TipTopPCDB.charSpec = not TipTopPCDB.charSpec
ConfirmProfilePopup()
end,
order = 43,
},
warning = {
name = "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 = "description",
order = 44,
},
},
},
},
}
 
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", nil, "general")
TipTop.optionsFrame.baropts = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("TipTop", "Health Bar", "TipTop", "baropts")
TipTop.optionsFrame.borderopts = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("TipTop", "Borders", "TipTop", "borderopts")
TipTop.optionsFrame.riconopts = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("TipTop", "Raid Icon", "TipTop", "riconopts")
TipTop.optionsFrame.extraopts = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("TipTop", "Extra Lines", "TipTop", "extraopts")
TipTop.optionsFrame.profile = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("TipTop", "Profile", "TipTop", "profile")
 
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")
\ No newline at end of file + LSM:Register("background", "brushed", "Interface\\AddOns\\TipTop\\brushed.tga") +--end + + +f:SetScript("OnEvent", OnInitialize) +f:RegisterEvent("PLAYER_LOGIN") \ No newline at end of file
tiptop.lua
1,50 → 1,18
--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",
sbarcolor = {r=0, g=1, b=0, a=1},
sbarbg = "TipTop Default",
sbarbgcolor = {r=0, g=0, b=0, a=.4},
topBar = false,
insideBar = 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%",
}
 
--CREATE FRAMES--
TipTop = CreateFrame("FRAME", nil, GameTooltip)
local TipTop = TipTop
local LSM = LibStub("LibSharedMedia-3.0")
local player = UnitName("player")
local server = GetRealmName()
local TipTop = TipTop
local tt = GameTooltip
local ttSBar = GameTooltipStatusBar
local ttSBarBG = CreateFrame("Frame", nil, ttSBar)
local ttHealth = ttSBar:CreateFontString("ttHealth", "OVERLAY")
ttHealth:SetPoint("CENTER")
local raidIcon = ttSBar:CreateTexture(nil, "OVERLAY")
local _, BGPosition, color, font, target, tclass, tserver, targetLine
 
--OTHER LOCALS--
local LSM = LibStub("LibSharedMedia-3.0")
local player = UnitName("player")
local server = GetRealmName()
local _, db, BGPosition, color, font
local talents = {}
local qualColors = ITEM_QUALITY_COLORS
local tooltips = { GameTooltip,
53,7 → 21,30
ShoppingTooltip2,
ShoppingTooltip3}
 
local function SetBackgrounds()
--UPVALUES--
local table_sort = _G.table.sort
local GetItemInfo = _G.GetItemInfo
local GetItemQualityColor = _G.GetItemQualityColor
local GetRaidTargetIndex = _G.GetRaidTargetIndex
local GetTalentTabInfo = _G.GetTalentTabInfo
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
 
 
function TipTop:SetBackgrounds()
for i = 1, #tooltips do
tooltips[i]:SetScale(db.scale)
tooltips[i]:SetBackdrop({
78,7 → 69,7
TipTop:SetBackdropBorderColor(db.borderColor.r, db.borderColor.g, db.borderColor.b, db.borderColor.a)
end
 
local function SetFonts()
function TipTop:SetFonts()
font = LSM:Fetch("font", db.font) --grab font from LSM
ttHealth:SetFont(font, 12, "OUTLINE")
GameTooltipHeaderText:SetFont(font, 12 + 2)
103,9 → 94,16
for i = 1, ShoppingTooltip3:NumLines() do
_G["ShoppingTooltip3TextRight"..i]:SetFont(font, 12 -2)
end
if GameTooltipMoneyFrame1 then
GameTooltipMoneyFrame1PrefixText:SetFont(font, 12)
GameTooltipMoneyFrame1SuffixText:SetFont(font, 12)
GameTooltipMoneyFrame1CopperButtonText:SetFont(font, 12)
GameTooltipMoneyFrame1SilverButtonText:SetFont(font, 12)
GameTooltipMoneyFrame1GoldButtonText:SetFont(font, 12)
end
end
 
local function SBarCustom()
function TipTop:SBarCustom()
ttSBar:SetStatusBarTexture(LSM:Fetch("statusbar", db.healthBar))
ttSBar:SetStatusBarColor(db.sbarcolor.r, db.sbarcolor.g, db.sbarcolor.b, db.sbarcolor.a)
ttSBarBG:SetAllPoints()
114,7 → 112,7
ttSBarBG:SetBackdropColor(db.sbarbgcolor.r, db.sbarbgcolor.g, db.sbarbgcolor.b, db.sbarbgcolor.a)
end
 
local function SBarPosition()
function TipTop:SBarPosition()
ttSBar:ClearAllPoints()
if db.insideBar then
if db.topBar then
158,7 → 156,7
end
end
 
local function RaidIcon()
function TipTop:RaidIcon()
raidIcon:SetWidth(db.raidIconSize)
raidIcon:SetHeight(db.raidIconSize)
raidIcon:SetTexture("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcons")
220,67 → 218,119
if db.itemColor then
local _,item = tip:GetItem()
local _,_,quality = GetItemInfo(item)
local color = qualColors[quality]
local icolor = qualColors[quality]
if tip == tt then
TipTop:SetBackdropBorderColor(color.r - .2, color.g - .2, color.b - .2, db.borderColor.a)
TipTop:SetBackdropBorderColor(icolor.r - .2, icolor.g - .2, icolor.b - .2, db.borderColor.a)
else
tip:SetBackdropBorderColor(color.r - .2, color.g - .2, color.b - .2, db.borderColor.a)
tip:SetBackdropBorderColor(icolor.r - .2, icolor.g - .2, icolor.b - .2, db.borderColor.a)
end
end
end
 
local function CalcHealth()
local hp = UnitHealth("mouseover")
local maxhp = UnitHealthMax("mouseover")
local per = (hp/maxhp) * 100
if db.textformat == "100/100" then
ttHealth:SetFormattedText("%d / %d", hp, maxhp)
elseif db.textformat == "100%" then
if per >= 0 then --gives funny negative numbers when tooltip fades
ttHealth:SetFormattedText("%d%%", per)
if db.healthText then
local hp = UnitHealth("mouseover")
local maxhp = UnitHealthMax("mouseover")
local per = (hp/maxhp) * 100
if db.textformat == "100/100" then
ttHealth:SetFormattedText("%d / %d", hp, maxhp)
elseif db.textformat == "100%" then
if per >= 0 then --gives funny negative numbers when tooltip fades
ttHealth:SetFormattedText("%d%%", per)
end
elseif db.textformat == "100/100 (100%)" then
if per >= 0 then
ttHealth:SetFormattedText("%d / %d (%d%%)", hp, maxhp, per)
end
end
elseif db.textformat == "100/100 (100%)" then
if per >= 0 then
ttHealth:SetFormattedText("%d / %d (%d%%)", hp, maxhp, per)
end
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.showTargetText then
local target, tserver = UnitName("mouseovertarget")
local _,tclass = UnitClass("mouseovertarget")
if target and target ~= UNKNOWN then
local targetLine
for i=1, GameTooltip:NumLines() do
local left, right, leftText, rightText
left = _G[GameTooltip:GetName().."TextLeft"..i]
leftText = left:GetText()
right = _G[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()
targetLine = true
end
end
if targetLine ~= true then
if db.you and target == player and (tserver == nil or tserver == server) then
right:SetText("<<YOU>>")
right:SetTextColor(.9, 0, .1)
tt:AddDoubleLine("Target:", "<<YOU>>", nil, nil, nil, .9, 0, .1)
else
right:SetText(target)
right:SetTextColor(color[tclass].r,color[tclass].g,color[tclass].b)
local tcolor = color[tclass]
if tcolor then --sometimes get an error about tcolor being nil - maybe from tips appearing/disappearing too fast?
tt:AddDoubleLine("Target:", target, nil,nil,nil,tcolor.r,tcolor.g,tcolor.b)
end
end
tt:Show()
targetLine = true
else
targetLine = false
end
end
if targetLine ~= true then
if db.you and target == player and (tserver == nil or tserver == server) then
tt:AddDoubleLine("Target:", "<<YOU>>", nil, nil, nil, .9, 0, .1)
end
end
 
local function TalentQuery()
if CanInspect("mouseover") and db.showTalentText then
if UnitName("mouseover") ~= player and UnitLevel("mouseover") > 9 then
if InspectFrame and InspectFrame:IsShown() then
tt:AddDoubleLine("Talents:", "Inspect Frame is open", nil,nil,nil, 1,0,0)
elseif Examiner and Examiner:IsShown() then
tt:AddDoubleLine("Talents:", "Examiner frame is open", nil,nil,nil, 1,0,0)
else
local tcolor = color[tclass]
tt:AddDoubleLine("Target:", target, nil,nil,nil,tcolor.r,tcolor.g,tcolor.b)
NotifyInspect("mouseover")
TipTop:RegisterEvent("INSPECT_TALENT_READY")
tt:AddDoubleLine("Talents:", "...")
end
tt:Show()
else
targetLine = false
end
end
end
 
local function TalentsSort(a,b)
return a.pnts > b.pnts
end
 
local function TalentText()
if UnitExists("mouseover") then
local pnts, tree
local active = GetActiveTalentGroup(1)
for i=1,3 do
tree,_,pnts = GetTalentTabInfo(i, 1, nil, active)
talents[i] = {tree = tree, pnts = pnts}
end
local points = talents[1].pnts.."/"..talents[2].pnts.."/"..talents[3].pnts
local spec = talents
table_sort(spec, TalentsSort)
for i=1, GameTooltip:NumLines() do
local left = _G[GameTooltip:GetName().."TextLeft"..i]
local leftText = left:GetText()
if leftText == "Talents:" then
local right = _G[GameTooltip:GetName().."TextRight"..i]
right:SetText(spec[1].tree.." ("..points..")")
end
tt:Show()
end
end
tt:UnregisterEvent("INSPECT_TALENT_READY")
end
 
local function MouseoverTargetUpdate()
--min width for health text
if tt:GetWidth() < 125 then
291,10 → 341,9
end
end
BorderClassColor()
if db.healthText then
CalcHealth()
end
CalcHealth()
RaidIconUpdate()
TalentQuery()
Appendices()
FadedTip()
end
310,33 → 359,55
end
 
local function PlayerLogin()
SetBackgrounds()
SBarPosition()
SBarCustom()
SetFonts()
if TipTopPCDB.charSpec then
db = TipTopPCDB
else
db = TipTopDB
end
TipTop:SetBackgrounds()
TipTop:SBarCustom()
TipTop:SBarPosition()
TipTop:SetFonts()
TipTop:RaidIcon()
 
color = CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS
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")
else
tt:SetOwner(parent, "ANCHOR_NONE")
tt:SetPoint(db.anchor, UIParent, db.anchor, db.offsetX, db.offsetY)
end
end)
 
TipTop:UnregisterEvent("PLAYER_LOGIN")
TipTop:RegisterEvent("UPDATE_MOUSEOVER_UNIT")
TipTop:SetScript("OnEvent", MouseoverTargetUpdate)
TipTop:SetScript("OnEvent", function(_, event)
if event == "UPDATE_MOUSEOVER_UNIT" then
MouseoverTargetUpdate()
elseif event == "INSPECT_TALENT_READY" then
TalentText()
end
end)
local moneyfontset
for i=1,#tooltips do
tooltips[i]:HookScript("OnTooltipSetItem", function(tip)
ItemQualityBorder(tip)
--this fontstring doesn't exist until the first time it's needed
GameTooltipMoneyFrame1PrefixText:SetFont(font, 12)
GameTooltipMoneyFrame1SuffixText:SetFont(font, 12)
GameTooltipMoneyFrame1CopperButtonText:SetFont(font, 12)
GameTooltipMoneyFrame1SilverButtonText:SetFont(font, 12)
GameTooltipMoneyFrame1GoldButtonText:SetFont(font, 12)
--the vendor price strings don't exist until the first time they're needed
if GameTooltipMoneyFrame1 and not moneyfontset then
TipTop:SetFonts()
moneyfontset = true
end
end)
end
if db.healthText then
ttSBar:HookScript("OnValueChanged", CalcHealth)
end
if db.showTargetText then
ttSBar:HookScript("OnUpdate", TargetTextUpdate)
end
ttSBar:HookScript("OnValueChanged", CalcHealth)
ttSBar:HookScript("OnUpdate", TargetTextUpdate)
 
PlayerLogin = nil --let this function be garbage collected
end