-
Notifications
You must be signed in to change notification settings - Fork 1
/
GatherNotifications.lua
101 lines (84 loc) · 3.08 KB
/
GatherNotifications.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
--[[
Gatherer Addon for World of Warcraft(tm).
Version: 3.1.2 (<%codename%>)
Revision: $Id: GatherNotifications.lua 697 2008-02-27 18:45:53Z Esamynn $
License:
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program(see GPL.txt); if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Note:
This AddOn's source code is specifically designed to work with
World of Warcraft's interpreted AddOn system.
You have an implicit licence to use this AddOn with these facilities
since that is it's designated purpose as per:
http://www.fsf.org/licensing/licenses/gpl-faq.html#InterpreterIncompat
User Notification System
This is a system for delivering information to the user in a non-threatening manner
such as warnings about Gatherer not recognizing all of the client's maps
]]
Gatherer_RegisterRevision("$URL: http://svn.norganna.org/gatherer/trunk/Gatherer/GatherNotifications.lua $", "$Rev: 697 $")
local _tr = Gatherer.Locale.Tr
local _trC = Gatherer.Locale.TrClient
local _trL = Gatherer.Locale.TrLocale
local metatable = { __index = getfenv(0) }
setmetatable( Gatherer.Notifications, metatable )
setfenv(1, Gatherer.Notifications)
Tooltip = nil -- will be set by the OnLoad function
Messages = {}
local function DisplayNotification()
if ( IsLoggedIn() and Messages[1] ) then
Tooltip:ClearLines()
if not ( Tooltip:IsShown() ) then
Tooltip:SetOwner(UIParent, "ANCHOR_PRESERVE")
end
local C = HIGHLIGHT_FONT_COLOR
Tooltip:SetText(_trL("Gatherer: Warnings"), C.r, C.g, C.b)
for _, text in ipairs(Messages) do
Tooltip:AddLine("———————————————————————————————————————————————————") -- I'd perfer if this produced a solid line :/
Tooltip:AddLine(text, nil, nil, nil, true)
end
Tooltip:Show()
end
end
function AddInfo( text )
table.insert(Messages, text)
DisplayNotification()
end
function OnLoad( tooltip )
Tooltip = tooltip
tooltip:RegisterEvent("PLAYER_LOGIN")
end
function OnShow( tooltip )
tooltip.timeVisible = 0
end
function OnHide( tooltip )
Messages = {}
end
function OnUpdate( tooltip, elapsed )
timeVisible = tooltip.timeVisible
timeVisible = timeVisible + elapsed
if ( MouseIsOver(tooltip) ) then
tooltip.timeVisible = 0
tooltip:Show()
else
if ( timeVisible > 30 ) then
tooltip:FadeOut(10)
tooltip.timeVisible = -1000
else
tooltip.timeVisible = timeVisible
end
end
end
function OnEvent(self, event, ...)
if ( event == "PLAYER_LOGIN" ) then
DisplayNotification()
end
end