Quantcast

Add LibQTip and make anchor info global.

Scott Sibley [08-07-10 - 22:36]
Add LibQTip and make anchor info global.
Filename
.pkgmeta
Modules/DeadlyAnnounce.lua
Modules/Position.lua
StarTip.lua
embeds.xml
diff --git a/.pkgmeta b/.pkgmeta
index 2870aca..dbc433e 100644
--- a/.pkgmeta
+++ b/.pkgmeta
@@ -44,4 +44,7 @@ externals:
         tag: latest
     Libs/LibDataBroker-1.1:
         url: git://github.com/tekkub/libdatabroker-1-1.git
-        tag: v1.1.4
+        tag: v1.1.4
+    Libs/LibQtip-1.0:
+        url: svn://svn.wowace.com/wow/libqtip-1-0/mainline/trunk
+		tag: latest
diff --git a/Modules/DeadlyAnnounce.lua b/Modules/DeadlyAnnounce.lua
index 3687c76..789d08e 100644
--- a/Modules/DeadlyAnnounce.lua
+++ b/Modules/DeadlyAnnounce.lua
@@ -4,21 +4,35 @@ mod.name = "DeadlyAnnounce"
 mod.toggled = true
 mod.desc = "Show the last DBM announcements."
 mod.defaultOff = true
+local LibQTip = LibStub('LibQTip-1.0')
 local _G = _G
 local StarTip = _G.StarTip
 local GameTooltip = _G.GameTooltip
 local ShoppingTooltip1 = _G.ShoppingTooltip1
 local ShoppingTooltip2 = _G.ShoppingTooltip2
 local self = mod
+local begin = GetTime()
+
+local anchorText = {
+	"Top",
+	"Top-right",
+	"Top-left",
+	"Bottom",
+	"Bottom-right",
+	"Bottom-left",
+	"Left",
+	"Right",
+	"Single Tooltip"
+}

 local defaults = {
 	profile = {
 		delay = 3,
-		hide = true
+		hide = true,
+		position = #anchorText
 	},
 }

-
 local options = {
 	hide = {
 		name = "Hide DeadlyAnnounce",
@@ -45,6 +59,15 @@ local options = {
 		pattern = "%d",
 		order = 6
 	},
+	position = {
+		name = "Position",
+		desc = "Select where to place tooltip.",
+		type = "select",
+		values = anchorText,
+		get = function() return mod.db.profile.position end,
+		set = function(info, v) mod.db.profile.position = v end,
+		order = 7
+	}
 }

 local history = {}
@@ -128,11 +151,13 @@ function mod:OnEnable()

 		local function NewBoss(module, ...)
 			local mod = BigWigs:GetBossModule(module)
-			-StarTip:SecureHook(mod, "DelayedMessage", function(key, delay, text, ...) tinsert(history, text) end)
+			StarTip:SecureHook(mod, "DelayedMessage", function(key, delay, text, ...) tinsert(history, {text = text, time = GetTime()}) end)
 		end

 		StarTip:SecureHook(BigWigs, "NewBoss", NewBoss)
 	end
+
+	tinsert(history, {text = "Test", time = GetTime()})
 end

 function mod:OnDisable()
@@ -164,8 +189,18 @@ function mod:SetUnit()
 	end
 	GameTooltip:ClearLines()
 	GameTooltip:AddLine("--- DeadlyAnnounce ---")
-	for i = #history, 1, -1 do
-		GameTooltip:AddLine(history[i], 1, 1, 1)
+
+	local length = 0
+
+	for i = #history + 1, 1, -1 do
+		local time = history[i].time - history[i + 1].time
+		length = length + time
+	end
+
+	for i = #history + 1, 1, -1 do
+		local time = GetTime()
+		time = time - history[i].time
+		GameTooltip:AddLine(time .. ": " .. history[i].text, 1, 1, 1)
 	end

 	StarTip:ScheduleTimer(hideDW, self.db.profile.delay)
diff --git a/Modules/Position.lua b/Modules/Position.lua
index 157c0bd..a91b699 100644
--- a/Modules/Position.lua
+++ b/Modules/Position.lua
@@ -23,59 +23,8 @@ local defaults = {
 	}
 }

-local anchors = {
-	"CURSOR_TOP",
-	"CURSOR_TOPRIGHT",
-	"CURSOR_TOPLEFT",
-	"CURSOR_BOTTOM",
-	"CURSOR_BOTTOMRIGHT",
-	"CURSOR_BOTTOMLEFT",
-	"CURSOR_LEFT",
-	"CURSOR_RIGHT",
-	"TOP",
-	"TOPRIGHT",
-	"TOPLEFT",
-	"BOTTOM",
-	"BOTTOMRIGHT",
-	"BOTTOMLEFT",
-	"RIGHT",
-	"LEFT",
-	"CENTER"
-}
-
-local anchorText = {
-	"Cursor Top",
-	"Cursor Top-right",
-	"Cursor Top-left",
-	"Cursor Bottom",
-	"Cursor Bottom-right",
-	"Cursor Bottom-left",
-	"Cursor Left",
-	"Cursor Right",
-	"Screen Top",
-	"Screen Top-right",
-	"Screen Top-left",
-	"Screen Bottom",
-	"Screen Bottom-right",
-	"Screen Bottom-left",
-	"Screen Right",
-	"Screen Left",
-	"Screen Center"
-}
-
-local opposites = {
-	TOP = "BOTTOM",
-	TOPRIGHT = "BOTTOMLEFT",
-	TOPLEFT = "BOTTOMRIGHT",
-	BOTTOM = "TOP",
-	BOTTOMRIGHT = "TOPLEFT",
-	BOTTOMLEFT = "TOPRIGHT",
-	LEFT = "RIGHT",
-	RIGHT = "LEFT",
-}
-
 local selections = {}
-for i, v in ipairs(anchorText) do
+for i, v in ipairs(StarTip.anchorText) do
 	selections[i] = v
 end
 selections[#selections+1] = "Hide"
@@ -333,14 +282,14 @@ local function delayAnchor()
 	if index == #selections then
 		this:Hide()
 		return
-	elseif anchors[index]:find("^CURSOR_")  then
+	elseif StarTip.anchors[index]:find("^CURSOR_")  then
 		oldX, oldY = 0, 0
-		currentAnchor = opposites[anchors[index]:sub(8)]
+		currentAnchor = StarTip.opposites[StarTip.anchors[index]:sub(8)]
 		updateFrame:SetScript("OnUpdate", positionTooltip)
 		positionTooltip()
 	else
 		if updateFrame:GetScript("OnUpdate") then updateFrame:SetScript("OnUpdate", nil) end
-		this:SetPoint(anchors[index], UIParent, anchors[index], xoffset, yoffset)
+		this:SetPoint(StarTip.anchors[index], UIParent, StarTip.anchors[index], xoffset, yoffset)
 	end
 end

diff --git a/StarTip.lua b/StarTip.lua
index e56ca7b..211aebd 100644
--- a/StarTip.lua
+++ b/StarTip.lua
@@ -1,6 +1,5 @@
 StarTip = LibStub("AceAddon-3.0"):NewAddon("StarTip", "AceConsole-3.0", "AceHook-3.0", "AceEvent-3.0", "AceTimer-3.0")
 StarTip.__starref__ = true
---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")
@@ -16,6 +15,57 @@ local LDB = LibStub("LibDataBroker-1.1"):NewDataObject("StarTip", {
 	OnClick = function() StarTip:OpenConfig() end
 })

+StarTip.anchors = {
+	"CURSOR_TOP",
+	"CURSOR_TOPRIGHT",
+	"CURSOR_TOPLEFT",
+	"CURSOR_BOTTOM",
+	"CURSOR_BOTTOMRIGHT",
+	"CURSOR_BOTTOMLEFT",
+	"CURSOR_LEFT",
+	"CURSOR_RIGHT",
+	"TOP",
+	"TOPRIGHT",
+	"TOPLEFT",
+	"BOTTOM",
+	"BOTTOMRIGHT",
+	"BOTTOMLEFT",
+	"RIGHT",
+	"LEFT",
+	"CENTER"
+}
+
+StarTip.anchorText = {
+	"Cursor Top",
+	"Cursor Top-right",
+	"Cursor Top-left",
+	"Cursor Bottom",
+	"Cursor Bottom-right",
+	"Cursor Bottom-left",
+	"Cursor Left",
+	"Cursor Right",
+	"Screen Top",
+	"Screen Top-right",
+	"Screen Top-left",
+	"Screen Bottom",
+	"Screen Bottom-right",
+	"Screen Bottom-left",
+	"Screen Right",
+	"Screen Left",
+	"Screen Center"
+}
+
+StarTip.opposites = {
+	TOP = "BOTTOM",
+	TOPRIGHT = "BOTTOMLEFT",
+	TOPLEFT = "BOTTOMRIGHT",
+	BOTTOM = "TOP",
+	BOTTOMRIGHT = "TOPLEFT",
+	BOTTOMLEFT = "TOPRIGHT",
+	LEFT = "RIGHT",
+	RIGHT = "LEFT",
+}
+
 local defaults = {
 	profile = {
 		modules = {},
diff --git a/embeds.xml b/embeds.xml
index f12401f..62ad71b 100644
--- a/embeds.xml
+++ b/embeds.xml
@@ -18,5 +18,6 @@
 <Script file="Libs\LibTalentQuery-1.0\LibTalentQuery-1.0.lua"/>
 <Script file="Libs\LibDatabroker-1.1\LibDatabroker-1.1.lua"/>
 <Script file="Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua"/>
+<Script file="Libs\LibQtip-1.0\LibQtip-1.0"/>

 </Ui>