From eae28b372cc8ee67c9a3a6a9ad76513f3bdb568b Mon Sep 17 00:00:00 2001 From: Scott Sibley Date: Mon, 4 Jul 2011 03:39:29 +0000 Subject: [PATCH] You can specify individual fonts and their sizes for Bold/Header face and Normal face. Outlines are back. --- Modules/Appearance/Appearance.lua | 87 +++++++++---------------------- Modules/Targeting/StarTip_Targeting.toc | 1 + Modules/Targeting/Targeting.lua | 6 ++- Modules/UnitTooltip/UnitTooltip.lua | 69 ++++++++++-------------- 4 files changed, 56 insertions(+), 107 deletions(-) diff --git a/Modules/Appearance/Appearance.lua b/Modules/Appearance/Appearance.lua index aa6d046..6020e34 100644 --- a/Modules/Appearance/Appearance.lua +++ b/Modules/Appearance/Appearance.lua @@ -13,8 +13,9 @@ local defaults = { profile = { scale = 1, font = "Friz Quadrata TT", + headerFont = "Friz Quadrata TT", fontSizeNormal = 12, - fontSizeBold = 14, + fontSizeHeader = 16, edgeFile = "Blizzard Tooltip", background = "Blizzard Tooltip", bgColor = { -- Default colors from CowTip @@ -41,7 +42,7 @@ local defaults = { } local backdropParts = {bgFile = true, edgeFile = true, edgeSize = true, background = true} -local otherParts = {scale = "SetScale", font = "SetFont"} +local otherParts = {scale = "SetScale"} local get = function(info) return self.db.profile[info[#info]] @@ -54,8 +55,6 @@ local set = function(info, v) self:SetBackdrop() elseif info[#info] == "scale" then self:SetScale() - else - self:SetFont() end end @@ -87,6 +86,20 @@ local options = { end, order = 5 }, + headerFont = { + name = L["Bold Font"], + desc = L["Set the tooltip's bold font"], + type = "select", + values = LSM:List("font"), + get = function() + return StarTip:GetLSMIndexByName("font", mod.db.profile.headerFont) + end, + set = function(info, val) + local list = LSM:List("font") + mod.db.profile.headerFont = list[val] + end, + order = 6 + }, fontSizeNormal = { name = L["Normal font size"], desc = L["Set the normal font size"], @@ -94,17 +107,17 @@ local options = { pattern = "%d", get = function() return tostring(mod.db.profile.fontSizeNormal) end, set = function(info, v) mod.db.profile.fontSizeNormal = tonumber(v) end, - order = 6 + order = 7 }, - fontSizeBold = { + fontSizeHeader = { name = L["Bold font size"], desc = L["Set the bold font size"], type = "input", pattern = "%d", - get = function() return tostring(mod.db.profile.fontSizeBold) end, - set = function(info, v) mod.db.profile.fontSizeBold = tonumber(v) end, + get = function() return tostring(mod.db.profile.fontSizeHeader) end, + set = function(info, v) mod.db.profile.fontSizeHeader = tonumber(v) end, pattern = "%d", - order = 7 + order = 8 }, edgeFile = { name = L["Tooltip Border"], @@ -118,7 +131,7 @@ local options = { local list = LSM:List("border") mod.db.profile.edgeFile = list[val] end, - order = 8 + order = 9 }, background = { name = L["Tooltip Background"], @@ -132,22 +145,8 @@ local options = { local list = LSM:List("background") mod.db.profile.background = list[val] end, - order = 9 - }, - --[[borderColor = { - name = "Tooltip Border Color", - desc = "Set the color of the tooltip's border", - type = "color", - hasAlpha = true, - get = function() return unpack(self.db.profile.borderColor) end, - set = function(info, r, g, b, a) - self.db.profile.borderColor[1] = r - self.db.profile.borderColor[2] = g - self.db.profile.borderColor[3] = b - self.db.profile.borderColor[4] = a - end, order = 10 - },]] + }, paddingTop = { name = L["Tooltip Top Padding"], desc = L["Set the tooltip's top side padding"], @@ -388,7 +387,6 @@ end function mod:OnEnable() self:SetScale() - self:SetFont() self:SetBackdrop() self:SetBackdropColor(true) StarTip:SetOptionsDisabled(options, false) @@ -401,7 +399,6 @@ end function mod:OnDisable() self:SetScale(true) - self:SetFont(true) self:SetBorderColor(true) self:SetBackdrop(true) self:SetBackdropColor(true) @@ -441,42 +438,6 @@ function mod:SetScale(reset) end end -function mod:SetFont(reset) - local font - if reset then - font = "Friz Quadrata TT" - else - font = LSM:Fetch('font', self.db.profile.font) - end - - if StarTip.leftLines[1]:GetFont() == font then - return - end - for i = 1, 50 do - local left = StarTip.leftLines[i] - local right = StarTip.rightLines[i] - local _, size, style = left:GetFont() - left:SetFont(font, size, style) - _, size, style = right:GetFont() - right:SetFont(font, size, style) - - left = self.st1left[i] - right = self.st1right[i] - _, size, style = left:GetFont() - left:SetFont(font, size, style) - _, size, style = right:GetFont() - right:SetFont(font, size, style) - - left = self.st2left[i] - right = self.st2right[i] - _, size, style = left:GetFont() - left:SetFont(font, size, style) - _, size, style = right:GetFont() - right:SetFont(font, size, style) - end -end - - local tmp, tmp2 = {}, {} function mod:SetBackdrop() if reset then diff --git a/Modules/Targeting/StarTip_Targeting.toc b/Modules/Targeting/StarTip_Targeting.toc index e526503..59cdfc6 100644 --- a/Modules/Targeting/StarTip_Targeting.toc +++ b/Modules/Targeting/StarTip_Targeting.toc @@ -3,6 +3,7 @@ ## Notes: Tooltips from Outerspace ## Author: Starlon ## Version: 1.0 +## OptionalDeps: StarTip_UnitTooltip ## Deps: StarTip ## X-Category: Tooltip ## X-Part-Of: StarTip diff --git a/Modules/Targeting/Targeting.lua b/Modules/Targeting/Targeting.lua index 406eb5f..4830cf1 100644 --- a/Modules/Targeting/Targeting.lua +++ b/Modules/Targeting/Targeting.lua @@ -2,7 +2,6 @@ local mod = StarTip:NewModule("Targeting", "AceEvent-3.0") mod.name = "Targeting" mod.toggled = true local _G = _G -local GameTooltip = _G.GameTooltip local UnitFactionGroup = _G.UnitFactionGroup local RAID_CLASS_COLORS = _G.RAID_CLASS_COLORS local StarTip = _G.StarTip @@ -48,7 +47,10 @@ function mod:SetUnit() end end if txt ~= '' then - GameTooltip:AddLine("Targeting: " .. txt, .5, .5, 1, 1) + local width = StarTip.tooltipMain:GetWidth() + local line = StarTip.tooltipMain:AddLine("") + StarTip.tooltipMain:SetCell(line, 1, "Targeting: " .. txt, nil, "LEFT", 2, nil, nil, nil, width) + StarTip.tooltipMain:SetLineColor(line, .5, .5, 1, 1) end end end diff --git a/Modules/UnitTooltip/UnitTooltip.lua b/Modules/UnitTooltip/UnitTooltip.lua index 2de1d60..8053bb5 100644 --- a/Modules/UnitTooltip/UnitTooltip.lua +++ b/Modules/UnitTooltip/UnitTooltip.lua @@ -863,7 +863,6 @@ end do local fontsList = LSM:List("font") - local widget, fontString function draw() if not UnitExists(StarTip.unit) then StarTip.tooltipMain:Hide() return end for k, v in pairs(lines) do @@ -883,49 +882,39 @@ do end for i, widget in ipairs(widgetsToDraw) do local font = LSM:Fetch("font", fontsList[appearance.db.profile.font]) + local headerFont = LSM:Fetch("font", fontsList[appearance.db.profile.headerFont]) + local justification = "LEFT" if widget.x == 2 then justification = "RIGHT" end - local fontObj = GameTooltipText - local size = 12 + + local outlined = "" + if widget.config.outlined and widget.config.outlined > 1 then + if widget.config.outlined == 2 then + outlined = "OUTLINE" + elseif widget.config.outlined == 3 then + outline = "THICKOUTLINE" + end + end + + if widget.y == 1 then - fontObj = GameTooltipHeaderText - size = 16 + widget.fontObj:SetFont(font, appearance.db.profile.fontSizeHeader, outlined) + else + widget.fontObj:SetFont(headerFont, appearance.db.profile.fontSizeNormal, outlined) end - --fontObj:SetFont(font, size) + local colSpan = 1 if not widget.config.right then colSpan = 2 end - - if widget.y and widget.buffer ~= "" then - StarTip.tooltipMain:SetCell(widget.y, widget.x, widget.buffer, fontObj, justification, colSpan) - end ---[[ - if widget.config.outlined and widget.config.outlined > 1 then - if widget.config.outlined == 2 then - fontString:SetFont(filename, fontHeight, "OUTLINED") - elseif widget.config.outlined == 3 then - fontString:SetFont(filename, fontHeight, "THICKOUTLINED") - end + if widget.y and widget.buffer ~= "" then + StarTip.tooltipMain:SetCell(widget.y, widget.x, widget.buffer, widget.fontObj, justification, colSpan) end -]] end - for cell in StarTip.tooltipMain:GetDefaultProvider():IterateCells() do - local y, x = cell:GetPosition() - if y == 1 and x == 1 then - cell.fontString.isHeader = true - else - cell.fontString.isHeader = false - end - end table.wipe(widgetsToDraw) - if UnitExists(StarTip.unit) then - --GameTooltip:Show() - --StarTip.tooltipMain:Show() - end end end @@ -958,6 +947,12 @@ function mod:CreateLines() v.outlined = v.rightOutlined llines[j].rightObj = v.right and WidgetText:New(mod.core, v.name .. " (right)", copy(v), 0, 0, v.layer or 0, StarTip.db.profile.errorLevel, updateWidget) if v.right and not v.rightUpdating then llines[j].rightObj.timer:Set(0) end + if v.left then + llines[j].leftObj.fontObj = _G[v.name .. "Left"] or CreateFont(v.name .. "Left") + end + if v.right then + llines[j].rightObj.fontObj = _G[v.name .. "Right"] or CreateFont(v.name .. "Right") + end end end self:ClearLines() @@ -1001,12 +996,7 @@ function mod:CreateLines() lineNum = lineNum + 1 if v.right then --GameTooltip:AddDoubleLine(' ', ' ', mod.db.profile.color.r, mod.db.profile.color.g, mod.db.profile.color.b, mod.db.profile.color.r, mod.db.profile.color.g, mod.db.profile.color.b) - local y, x - if lineNum == 1 then - y, x = StarTip.tooltipMain:AddHeader('', '') - else - y, x = StarTip.tooltipMain:AddLine('', '') - end + local y, x = StarTip.tooltipMain:AddLine('', '') --v.leftObj.fontString = mod.leftLines[lineNum] --v.rightObj.fontString = mod.rightLines[lineNum] --v.leftObj.fontString = StarTip.qtipLines[y][1] @@ -1016,12 +1006,7 @@ function mod:CreateLines() v.rightObj.y = y v.rightObj.x = 2 else - local y, x - if lineNum == 1 then - y, x = StarTip.tooltipMain:AddHeader('') - else - y, x = StarTip.tooltipMain:AddLine('') - end + local y, x = StarTip.tooltipMain:AddLine('') v.leftObj.y = y v.leftObj.x = 1 --GameTooltip:AddLine(' ', mod.db.profile.color.r, mod.db.profile.color.g, mod.db.profile.color.b, v.wordwrap) -- 1.7.9.5