Quantcast

Hide nameplates when mousing over them

Scott Sibley [10-14-10 - 09:38]
Hide nameplates when mousing over them
Filename
.pkgmeta
Modules/Nameplates/Nameplates.lua
Modules/Nameplates/StarTip_Nameplates.toc
StarTip.lua
modules.xml
diff --git a/.pkgmeta b/.pkgmeta
index fc74409..2251229 100644
--- a/.pkgmeta
+++ b/.pkgmeta
@@ -65,4 +65,5 @@ move-folders:
     StarTip/Modules/UnitTooltip: StarTip_UnitTooltip
     StarTip/Modules/Portrait: StarTip_Portrait
     StarTip/Modules/Icons: StarTip_Icons
-    StarTip/Modules/Gestures: StarTip_Gestures
\ No newline at end of file
+    StarTip/Modules/Gestures: StarTip_Gestures
+    StarTip/Modules/Nameplate: StarTip_Nameplate
\ No newline at end of file
diff --git a/Modules/Nameplates/Nameplates.lua b/Modules/Nameplates/Nameplates.lua
new file mode 100644
index 0000000..6f0e416
--- /dev/null
+++ b/Modules/Nameplates/Nameplates.lua
@@ -0,0 +1,122 @@
+local mod = StarTip:NewModule("Nameplates", "AceTimer-3.0")
+mod.name = "Hide Nameplates"
+mod.toggled = true
+mod.desc = "Toggle this module on to cause the mouse cursor to hide nameplates when mousing over them."
+--mod.childGroup = true
+--mod.defaultOff = true
+local _G = _G
+local StarTip = _G.StarTip
+local GameTooltip = _G.GameTooltip
+local GameTooltipStatusBar = _G.GameTooltipStatusBar
+local UnitIsPlayer = _G.UnitIsPlayer
+local RAID_CLASS_COLORS = _G.RAID_CLASS_COLORS
+local UnitSelectionColor = _G.UnitSelectionColor
+local UnitClass = _G.UnitClass
+local self = mod
+local LSM = LibStub("LibSharedMedia-3.0")
+local WidgetHistogram = LibStub("LibScriptableDisplayWidgetHistogram-1.0")
+local LibCore = LibStub("LibScriptableDisplayCore-1.0")
+local LibTimer = LibStub("LibScriptableDisplayTimer-1.0")
+local PluginUtils = LibStub("LibScriptableDisplayPluginUtils-1.0")
+
+local unit
+local environment = {}
+
+local createNameplates
+local widgets = {}
+
+local anchors = {
+	"TOP",
+	"TOPRIGHT",
+	"TOPLEFT",
+	"BOTTOM",
+	"BOTTOMRIGHT",
+	"BOTTOMLEFT",
+	"RIGHT",
+	"LEFT",
+	"CENTER"
+}
+
+local anchorsDict = {}
+
+for i, v in ipairs(anchors) do
+	anchorsDict[v] = i
+end
+
+local function copy(tbl)
+	if type(tbl) ~= "table" then return tbl end
+	local newTbl = {}
+	for k, v in pairs(tbl) do
+		newTbl[k] = copy(v)
+	end
+	return newTbl
+end
+
+
+local defaults = {
+	profile = {
+	}
+}
+
+local options = {}
+local optionsDefaults = {
+}
+
+local update
+function mod:OnInitialize()
+	self.db = StarTip.db:RegisterNamespace(self:GetName(), defaults)
+
+	self.timer = LibTimer:New("Nameplates", 300, true, update)
+end
+
+function mod:OnEnable()
+	StarTip:SetOptionsDisabled(options, false)
+
+	self.timer:Start()
+end
+
+function mod:OnDisable()
+	StarTip:SetOptionsDisabled(options, true)
+
+	self.timer:Stop()
+end
+
+function mod:GetOptions()
+	return options
+end
+
+local function isNameplate(frame)
+	local region = frame:GetRegions()
+	return region and region:GetObjectType() == "Texture" and region:GetTexture() == "Interface\\TargetingFrame\\UI-TargetingFrame-Flash"
+end
+
+local function showframe(frame)
+	frame:Show()
+end
+
+local function stoptimer(frame)
+	frame.startiptimer:Stop()
+end
+
+local anchor = CreateFrame("Frame")
+anchor:SetWidth(200)
+anchor:SetHeight(200)
+anchor:Show()
+local frames = {}
+function update()
+	for i = 1, select("#", WorldFrame:GetChildren()) do
+		frame = select(i, WorldFrame:GetChildren())
+		if isNameplate(frame) then
+			if UnitExists("mouseover") then
+				local x, y = GetCursorPosition()
+				anchor:ClearAllPoints()
+				anchor:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", x - 100, y - 100)
+				if PluginUtils.Intersect(anchor, frame) then
+					frame:Hide()
+					frame.startiptimer = frame.startiptimer or LibTimer:New("timer", 3000, false, showframe, frame)
+					frame.startiptimer:Start()
+				end
+			end
+		end
+	end
+end
diff --git a/Modules/Nameplates/StarTip_Nameplates.toc b/Modules/Nameplates/StarTip_Nameplates.toc
new file mode 100644
index 0000000..8f6b893
--- /dev/null
+++ b/Modules/Nameplates/StarTip_Nameplates.toc
@@ -0,0 +1,8 @@
+## Interface: 40000
+## Title: StarTip [Nameplates]
+## Notes: Tooltips from outerspace
+## Author: Starlon
+## Version: 1.0
+## OptionalDeps: StarTip
+
+Nameplates.lua
\ No newline at end of file
diff --git a/StarTip.lua b/StarTip.lua
index 8d4d573..99037ea 100644
--- a/StarTip.lua
+++ b/StarTip.lua
@@ -578,6 +578,15 @@ function StarTip:RebuildOpts()
 				get = function() return (self.db.profile.modules[k]  == nil and not v.defaultOff) or self.db.profile.modules[k] end,
 				order = 2
 			}
+			if v.desc then
+				t.desc = {
+					name = "Description",
+					type = "input",
+					multiline = true,
+					get = function() return v.desc end,
+					order = 3
+				}
+			end
 		end
 		options.args.modules.args[v:GetName()].args = t
 	end
diff --git a/modules.xml b/modules.xml
index 4ca2afa..66ff3b0 100644
--- a/modules.xml
+++ b/modules.xml
@@ -15,6 +15,7 @@
 <Script file = "Modules\Portrait\Portrait.lua"/>
 <Script file = "Modules\Icons\Icons.lua"/>
 <Script file = "Modules\Gestures\Gestures.lua"/>
+<Script file = "Modules\Nameplates\Nameplates.lua"/>
 <Script file = "Modules\Debug\Debug.lua"/>
 <!--@end-debug@-->