-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpsk.lua
More file actions
90 lines (68 loc) · 2.68 KB
/
psk.lua
File metadata and controls
90 lines (68 loc) · 2.68 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
--[[ The database is defined in psk.toc for all characters on an account (instead of just one),
so alts can access it also. Without the DB being defined, all data will be lost on
reload/relog. ]]
if not PSKDB then
PSKDB = {
}
end
--[[ Create the main frame. Everything in the WoW UI requires a frame to attach to.
"BasicFrameTemplateWithInset provides the title bar, close button, background,
and border for the frame.]]
local pskFrame = CreateFrame("Frame", "PSKMainFrame", UIParent, "BasicFrameTemplateWithInset")
pskFrame:SetSize(800, 600)
pskFrame:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
pskFrame:SetFrameStrata("HIGH")
pskFrame.TitleBg:SetHeight(30)
pskFrame.title = pskFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
pskFrame.title:SetPoint("TOPLEFT", pskFrame.TitleBg, "TOPLEFT", 5, -3)
pskFrame.title:SetText("Perchance PSK")
pskFrame:Hide()
pskFrame:EnableMouse(true)
pskFrame:SetMovable(true)
pskFrame:RegisterForDrag("LeftButton")
--[[ Mouse functions for the frame ]]
pskFrame:SetScript("OnDragStart", function(self)
self:StartMoving()
end)
pskFrame:SetScript("OnDragStop", function(self)
self:StopMovingOrSizing()
end)
pskFrame:SetScript("OnShow", function()
PlaySound(808)
end)
pskFrame:SetScript("OnHide", function()
PlaySound(808)
end)
--[[ This is the slash command to open the addon via the console. We'll also add a minimap button later. ]]
SLASH_PSK1 = "/psk"
SlashCmdList["PSK"] = function()
pskFrame:Show()
end
--[[ Adds "PSKMainFrame" to the "special" frames so that it has access to key controls (ESC to close, etc).
Other special frames are things like the character frame, social frame, etc. ]]
table.insert(UISpecialFrames, "PSKMainFrame")
--[[ Creates another frame for an event listener, and sets its parent to the UI parent frame ]]
local pskListenerFrame = CreateFrame("Frame", "PSKEventListenerFrame", UIParent)
--[[ Handle the events that are registered below ]]
local function eventHandler(self, event, ...)
if event == "CHAT_MSG_GUILD"
or event == "CHAT_MSG_RAID"
or event == "CHAT_MSG_WHISPER_INFORM" then
print(sender .. " said: " .. message)
end
end
pskListenerFrame:SetScript("OnEvent", function(self, event, message, sender, ...)
if event == "CHAT_MSG_GUILD"
or event == "CHAT_MSG_RAID"
or event == "CHAT_MSG_WHISPER_INFORM"
or event == "CHAT_MSG_WHISPER" then
print(sender .. " said: " .. message)
end
if pskFrame:IsShown() then
print("PSK is showing")
end
end)
pskListenerFrame:RegisterEvent("CHAT_MSG_GUILD")
pskListenerFrame:RegisterEvent("CHAT_MSG_RAID")
pskListenerFrame:RegisterEvent("CHAT_MSG_WHISPER")
pskListenerFrame:RegisterEvent("CHAT_MSG_WHISPER_INFORM")