Quantcast

- Bold setting for lines

Scott Sibley [08-06-10 - 09:15]
- Bold setting for lines
Filename
.pkgmeta
Modules/Text.lua
StarTip.lua
embeds.xml
diff --git a/.pkgmeta b/.pkgmeta
index d50972b..c263fd8 100644
--- a/.pkgmeta
+++ b/.pkgmeta
@@ -39,9 +39,6 @@ externals:
     Libs/LibTalentQuery-1.0:
         url: svn://svn.wowace.com/wow/libtalentquery-1-0/mainline/trunk
         tag: latest
-    Libs/LibQTip-1.0:
-        url: svn://svn.wowace.com/wow/libqtip-1-0/mainline/trunk
-        tag: latest
 	Libs/LibDBIcon-1.0:
 	    url: svn://svn.wowace.com/wow/libdbicon-1-0/mainline/trunk/LibDBIcon-1.0
 		tag: latest
diff --git a/Modules/Text.lua b/Modules/Text.lua
index 56d1cb1..be7af5d 100644
--- a/Modules/Text.lua
+++ b/Modules/Text.lua
@@ -119,6 +119,25 @@ local function updateLines()
     end
 end

+--[[
+local newFont, delFont
+do
+	local pool = setmetatable({},{__mode='k'})
+	newFont = function(key)
+		local t = next(pool)
+		if not t then
+			t = CreateFont(key)
+			t:CopyFontObject(GameTooltipText)
+		end
+		pool[t] = nil
+		return t
+	end
+	delFont = function(tbl)
+		pool[tbl] = true
+	end
+end
+]]
+
 local defaults = {profile={titles=true, empty = true, lines = {}}}

 local defaultLines={
@@ -136,7 +155,8 @@ end
 return text.unitName, c
 ]],
         right = nil,
-        updating = false
+        updating = false,
+		bold = true
     },
     [2] = {
         name = "Target",
@@ -358,9 +378,10 @@ function mod:CreateLines()
     for i, v in ipairs(self.db.profile.lines) do
         llines[i] = v
     end
-    lines = setmetatable(llines, {__call=function(this)
+    lines = setmetatable(llines, {__call=function(self)
         local lineNum = 0
-        for i, v in ipairs(this) do
+		GameTooltip:ClearLines()
+        for i, v in ipairs(self) do
             --if self.db.profile[v.db] then
                 local left, right, c
                 if v.right then
@@ -373,25 +394,41 @@ function mod:CreateLines()
                 if left and right then
                     lineNum = lineNum + 1
                     if v.right then
-                        GameTooltip:AddDoubleLine(' ', ' ', 1, 1, 1, 1, 1, 1)
+						GameTooltip:AddDoubleLine(' ', ' ', 1, 1, 1, 1, 1, 1)
                         mod.leftLines[lineNum]:SetText(left)
                         mod.rightLines[lineNum]:SetText(right)
                         if type(c) == "table" and c.r then
                             mod.rightLines[lineNum]:SetVertexColor(c.r, c.g, c.b)
                         end
+						--[[if v.bold then
+							mod.leftLines[lineNum]:SetFont("Fonts\\FRIZQT__.TTF", 14, "OUTLINE, MONOCHROME")
+							mod.rightLines[lineNum]:SetFont("Fonts\\FRIZQT__.TTF", 14, "OUTLINE, MONOCHROME")
+						end]]
                     else
-                        GameTooltip:AddLine(' ', 1, 1, 1)
+						GameTooltip:AddLine(' ', 1, 1, 1)
                         mod.leftLines[lineNum]:SetText(left)
                         if type(c) == "table" and c.r then
                             mod.leftLines[lineNum]:SetVertexColor(c.r, c.g, c.b)
                         end
+						--[[if v.bold then
+							mod.leftLines[lineNum]:SetFont("Fonts\\FRIZQT__.TTF", 14, "OUTLINE, MONOCHROME")
+						end]]
                     end
                 end
 				StarTip:del(c)
             --end
         end
         self.NUM_LINES = lineNum
-    end})
+    end})
+	for i, v in ipairs(self.db.profile.lines) do
+		if v.bold then
+			mod.leftLines[i]:SetFont("Fonts\\FRIZQT__.TTF", 14, "OUTLINE, MONOCHROME")
+			mod.rightLines[i]:SetFont("Fonts\\FRIZQT__.TTF", 14, "OUTLINE, MONOCHROME")
+		else
+			mod.leftLines[i]:SetFont("Fonts\\FRIZQT__.TTF", 12, "MONOCHROME")
+			mod.rightLines[i]:SetFont("Fonts\\FRIZQT__.TTF", 12, "MONOCHROME")
+		end
+	end
 end

 function mod:RebuildOpts()
@@ -423,9 +460,10 @@ function mod:RebuildOpts()
 				self:CreateLines()
 			end,
 			order = 6
-		}
+		},
 	}
     for i, v in ipairs(self.db.profile.lines) do
+		if type(v) ~= "table" then break end
         options["line" .. i] = {
             name = v.name,
             type = "group",
@@ -512,6 +550,17 @@ function mod:RebuildOpts()
                     end,
                     order = 5
                 },
+				bold = {
+					name = "Bold",
+					desc = "Whether to bold this line or not",
+					type = "toggle",
+					get = function() return self.db.profile.lines[i].bold end,
+					set = function(info, v)
+						self.db.profile.lines[i].bold = v
+						self:CreateLines()
+					end,
+					order = 6
+				},
 				delete = {
 					name = "Delete",
 					desc = "Delete this line",
@@ -522,7 +571,7 @@ function mod:RebuildOpts()
 						StarTip:RebuildOpts()
 						self:CreateLines()
 					end,
-					order = 6
+					order = 7
 				},
             },
             order = i + 5
diff --git a/StarTip.lua b/StarTip.lua
index 2e4b72c..db52f0f 100644
--- a/StarTip.lua
+++ b/StarTip.lua
@@ -1,5 +1,5 @@
 StarTip = LibStub("AceAddon-3.0"):NewAddon("StarTip", "AceConsole-3.0", "AceHook-3.0", "AceEvent-3.0")
-local LibQTip = LibStub('LibQTip-1.0')
+--local LibQTip = LibStub('LibQTip-1.0')
 local LibDBIcon = LibStub("LibDBIcon-1.0")
 local LSM = _G.LibStub("LibSharedMedia-3.0")
 local LDB = LibStub:GetLibrary("LibDataBroker-1.1")
@@ -18,10 +18,14 @@ local LDB = LibStub("LibDataBroker-1.1"):NewDataObject("StarTip", {
 local defaults = {
 	profile = {
 		modules = {},
-		minimap = {hide=true}
+		minimap = {hide=true},
+		modifier = 1
 	}
 }

+local modNames = {"None", "Ctrl", "Alt", "Shift"}
+local modFuncs = {function() return true end, IsControlKeyDown, IsAltKeyDown, IsShiftKeyDown}
+
 local options = {
 	type = "group",
 	args = {
@@ -52,7 +56,17 @@ local options = {
 						end
 					end,
 					order = 1
-				}
+				},
+				modifier = {
+					name = "Modifier",
+					desc = "Whether to use a modifier key or not",
+					type = "select",
+					values = {"None", "Ctrl", "Alt", "Shift"},
+					get = function() return StarTip.db.profile.modifier end,
+					set = function() StarTip.db.profile.modifier = v end,
+					order = 6
+				},
+
 			}
 		}
 	}
@@ -207,7 +221,7 @@ function StarTip:OpenConfig()
 end

 local ff = CreateFrame("Frame")
-function StarTip.OnTooltipSetUnit()
+function StarTip.OnTooltipSetUnit()
 	if not StarTip.justSetUnit then
 		if not UnitExists("mouseover") then
 			if ff:GetScript("OnUpdate") then
@@ -225,7 +239,7 @@ function StarTip.OnTooltipSetUnit()
 	end
 end

-function StarTip.OnTooltipSetItem(self, ...)
+function StarTip.OnTooltipSetItem(self, ...)
 	if not StarTip.justSetItem then
 		for k, v in StarTip:IterateModules() do
 			if v.SetItem and v:IsEnabled() then v:SetItem(...) end
@@ -233,7 +247,7 @@ function StarTip.OnTooltipSetItem(self, ...)
 	end
 end

-function StarTip.OnTooltipSetSpell(...)
+function StarTip.OnTooltipSetSpell(...)
 	if not StarTip.justSetSpell then
 		for k, v in StarTip:IterateModules() do
 			if v.SetSpell and v:IsEnabled() then v:SetSpell(...) end
@@ -249,20 +263,22 @@ function StarTip:OnTooltipHide(...)
 	end
 	self.hooks[GameTooltip].OnHide(...)

-	LibQTip:Release(self.tooltip)
+	--LibQTip:Release(self.tooltip)
 	self.tooltip = nil

 end

 function StarTip:OnTooltipShow(...)
+	if self.db.profile.modifier > 1 and modFuncs[self.db.profile.modifier or 1] then
+		if modFuncs[self.db.profile.modifier]() then
+			return
+		end
+	end
 	if not self.justShow then
 		for k, v in self:IterateModules() do
 			if v.OnShow and v:IsEnabled() then v:OnShow(...) end
 		end
 	end
-   -- Acquire a tooltip with 3 columns, respectively aligned to left, center and right
-	local tooltip = LibQTip:Acquire("GameTooltip", 2, "LEFT", "CENTER", "RIGHT")
-	StarTip.tooltip = tooltip

     self.hooks[GameTooltip].OnShow(...)
 end
diff --git a/embeds.xml b/embeds.xml
index 31fc8d0..f12401f 100644
--- a/embeds.xml
+++ b/embeds.xml
@@ -16,7 +16,6 @@
 <Include file="Libs\LibSharedMedia-3.0\lib.xml"/>
 <Include file="Libs\LibMobHealth-4.0\lib.xml"/>
 <Script file="Libs\LibTalentQuery-1.0\LibTalentQuery-1.0.lua"/>
-<Script file="libs\LibQTip-1.0\LibQTip-1.0.lua"/>
 <Script file="Libs\LibDatabroker-1.1\LibDatabroker-1.1.lua"/>
 <Script file="Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua"/>