-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.lua
More file actions
executable file
·85 lines (76 loc) · 2.92 KB
/
core.lua
File metadata and controls
executable file
·85 lines (76 loc) · 2.92 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
local ADDON_NAME, ns = ...
local L = ns.L
-- Load the Addon
function PrincessHasArrived_OnLoad(self)
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("CHAT_MSG_ADDON")
end
-- Event Triggers
function PrincessHasArrived_OnEvent(self, event, ...)
if event == "PLAYER_ENTERING_WORLD" then
local isInitialLogin, isReloadingUi = ...
ns.registered = C_ChatInfo.RegisterAddonMessagePrefix(ns.name)
ns.characterName = UnitName("player") .. "-" .. GetNormalizedRealmName("player")
ns.race = ns:GetRace()
ns.gender = ns:GetGender()
ns:SetOptionDefaults()
ns:CreateSettingsPanel(PHA_options, ns.data.defaults, L.Settings, ns.title, ns.prefix, ns.version)
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
elseif event == "CHAT_MSG_ADDON" then
local addonName, soundType, channel, sender, _ = ...
if addonName ~= ns.name then
return
end
ns:ReceivedSound(soundType, sender, channel)
end
end
-- Addon Compartment Handling
AddonCompartmentFrame:RegisterAddon({
text = ns.title,
icon = ns.icon,
registerForAnyClick = true,
notCheckable = true,
func = function(button, menuInputData, menu)
local mouseButton = menuInputData.buttonName
if mouseButton == "RightButton" then
ns:OpenSettings()
else
ns:ProcessSound()
end
end,
funcOnEnter = function(menuItem)
GameTooltip:SetOwner(menuItem)
GameTooltip:SetText(ns.title .. " v" .. ns.version)
GameTooltip:AddLine(" ", 1, 1, 1, true)
GameTooltip:AddLine(L.AddonCompartmentTooltip1, 1, 1, 1, true)
GameTooltip:AddLine(L.AddonCompartmentTooltip2, 1, 1, 1, true)
GameTooltip:Show()
end,
funcOnLeave = function()
GameTooltip:Hide()
end,
})
-- Slash Command Handling
local sounds = ns.data.sounds
local soundTypesList = {}
for index = 1, #sounds do
local sound = sounds[index]
soundTypesList[index] = ns:Capitalize(sound.type)
end
SlashCmdList["PRINCESSHASARRIVED"] = function(message)
message = message and ns:Trim(message) or nil
if message == "c" or message:match("con") or message == "o" or message:match("opt") or message:match("sett") or message:match("togg") then
-- Open settings window
ns:OpenSettings()
elseif message == "h" or message:match("help") then
-- Print ways to interact with addon
ns:PrettyPrint(L.Help .. "|n" .. table.concat(soundTypesList, ", "))
elseif message == "m" or message:match("mute") or message == "s" or message:match("sound") then
PHA_options.PHA_sound = PHA_options.PHA_sound ~= true and true or false
ns:PrettyPrint(L.SoundsToggled:format((PHA_options.PHA_sound and _G.VIDEO_OPTIONS_ENABLED or _G.MUTED):lower()))
else
-- Process the message for sound types
ns:ProcessSound(message)
end
end
SLASH_PRINCESSHASARRIVED1 = "/" .. ns.command