-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCore.lua
More file actions
97 lines (83 loc) · 3.27 KB
/
Copy pathCore.lua
File metadata and controls
97 lines (83 loc) · 3.27 KB
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
local ADDON_NAME, ns = ...
local Scry = LibStub("AceAddon-3.0"):NewAddon(ADDON_NAME, "AceConsole-3.0", "AceEvent-3.0")
ns.Addon = Scry
local deDE = GetLocale() == "deDE"
------------------------------------------------------------
-- Saved variables
------------------------------------------------------------
local defaults = {
profile = {
minimap = { hide = false }, -- LibDBIcon state
cacheTTL = 3600, -- seconds a capture stays "fresh" before a re-check is suggested (0 = never expire)
checkSockets = true, -- flag empty gem sockets
checkTalents = true, -- capture talent spread; flag players with 0 points spent
checkRingEnchants = false, -- ring enchants are enchanter-only; off by default
whisperOnFlag = true, -- allow the "whisper flagged" button
window = { point = nil }, -- { point, relPoint, x, y }
},
global = {
-- Persistent per-GUID capture cache, survives reloads. Keyed by player GUID.
-- [guid] = { name, class, realm, time, slots = {...}, problems = {...} }
cache = {},
whispered = {}, -- [guid] = true; players already notified, so we never double-whisper
},
}
------------------------------------------------------------
-- Lifecycle
------------------------------------------------------------
function Scry:OnInitialize()
self.db = LibStub("AceDB-3.0"):New("ScryDB", defaults, true)
ns.db = self.db
-- Minimap / broker icon (spyglass fits "Scry").
local LDB = LibStub("LibDataBroker-1.1", true)
local LDBIcon = LibStub("LibDBIcon-1.0", true)
if LDB and LDBIcon then
local broker = LDB:NewDataObject(ADDON_NAME, {
type = "launcher",
icon = "Interface\\AddOns\\Scry\\Media\\icon.tga",
label = ADDON_NAME,
OnClick = function()
ns.UI:Toggle()
end,
OnTooltipShow = function(tt)
tt:AddLine(ADDON_NAME)
tt:AddLine(deDE and "Klick: Fenster öffnen/schließen" or "Click: open/close window", 0.8, 0.8, 0.8)
end,
})
self.db.profile.minimap.hide = false -- icon is always shown
LDBIcon:Register(ADDON_NAME, broker, self.db.profile.minimap)
end
self:RegisterChatCommand("scry", "SlashHandler")
end
function Scry:OnEnable()
-- IMPORTANT: We ONLY listen. We never call NotifyInspect/CanInspect/CheckInteractDistance
-- from addon code, because on Classic Anniversary that taints and breaks the manual
-- inspect. INSPECT_READY fires whenever the *user* manually inspects someone (the secure
-- FrameXML path), and reading the data afterwards is always taint-free.
self:RegisterEvent("INSPECT_READY", "OnInspectReady")
self:RegisterEvent("GROUP_ROSTER_UPDATE", "OnRosterUpdate")
end
function Scry:OnInspectReady(_, guid)
ns.Capture:OnInspectReady(guid)
ns.UI:Refresh()
end
function Scry:OnRosterUpdate()
ns.UI:Refresh()
end
------------------------------------------------------------
-- Slash command
------------------------------------------------------------
function Scry:SlashHandler(input)
input = (input or ""):lower():gsub("^%s+", ""):gsub("%s+$", "")
if input == "reset" then
wipe(self.db.global.cache)
wipe(self.db.global.whispered)
self:Print(deDE and "Cache geleert." or "Cache cleared.")
ns.UI:Refresh()
elseif input == "whisper" then
ns.Roster:WhisperFlagged()
else
ns.UI:Toggle()
end
end
ns.deDE = deDE