|
|
@@ -1,6 +1,7 @@
|
|
|
|
LevelUpAnnouncer = LibStub("AceAddon-3.0"):NewAddon("LevelUpAnnouncer", "AceConsole-3.0", "AceEvent-3.0")
|
|
|
|
LevelUpAnnouncer = LibStub("AceAddon-3.0"):NewAddon("LevelUpAnnouncer", "AceConsole-3.0", "AceEvent-3.0")
|
|
|
|
|
|
|
|
|
|
|
|
local version = "2.0.2"
|
|
|
|
local version = GetAddOnMetadata("LevelUpAnnouncer", "Version")
|
|
|
|
|
|
|
|
local author = GetAddOnMetadata("LevelUpAnnouncer", "Author")
|
|
|
|
|
|
|
|
|
|
|
|
local defaults = {
|
|
|
|
local defaults = {
|
|
|
|
profile = {
|
|
|
|
profile = {
|
|
|
@@ -8,6 +9,7 @@ local defaults = {
|
|
|
|
chatAnnounce = true,
|
|
|
|
chatAnnounce = true,
|
|
|
|
chatPercAnnounce = false,
|
|
|
|
chatPercAnnounce = false,
|
|
|
|
reversePerc = false,
|
|
|
|
reversePerc = false,
|
|
|
|
|
|
|
|
replaceWithEmote = true,
|
|
|
|
dingFormat = "DING! LEVEL {LEVEL}!",
|
|
|
|
dingFormat = "DING! LEVEL {LEVEL}!",
|
|
|
|
percFormat = "{PERCENTAGE}% INTO LEVEL {LEVEL}!",
|
|
|
|
percFormat = "{PERCENTAGE}% INTO LEVEL {LEVEL}!",
|
|
|
|
reversePercFormat = "{PERCENTAGE}% UNTIL LEVEL {NEXTLEVEL}!",
|
|
|
|
reversePercFormat = "{PERCENTAGE}% UNTIL LEVEL {NEXTLEVEL}!",
|
|
|
@@ -20,7 +22,7 @@ local options = {
|
|
|
|
type = "group",
|
|
|
|
type = "group",
|
|
|
|
args = {
|
|
|
|
args = {
|
|
|
|
LUPHeader = {
|
|
|
|
LUPHeader = {
|
|
|
|
name = "Level Up Announcer - by oskar3123 - version " .. version,
|
|
|
|
name = "Level Up Announcer - by " .. author .. " - version " .. version,
|
|
|
|
type = "header"
|
|
|
|
type = "header"
|
|
|
|
},
|
|
|
|
},
|
|
|
|
LUPToggles = {
|
|
|
|
LUPToggles = {
|
|
|
@@ -33,32 +35,40 @@ local options = {
|
|
|
|
name = "Enable Sound",
|
|
|
|
name = "Enable Sound",
|
|
|
|
desc = "Play a sound each time you level up",
|
|
|
|
desc = "Play a sound each time you level up",
|
|
|
|
type = "toggle",
|
|
|
|
type = "toggle",
|
|
|
|
set = function(info, value) LevelUpAnnouncer.db.profile.playSound = value end,
|
|
|
|
set = function(_, value) LevelUpAnnouncer.db.profile.playSound = value end,
|
|
|
|
get = function(info) return LevelUpAnnouncer.db.profile.playSound end
|
|
|
|
get = function() return LevelUpAnnouncer.db.profile.playSound end
|
|
|
|
},
|
|
|
|
},
|
|
|
|
chatAnnounce = {
|
|
|
|
chatAnnounce = {
|
|
|
|
order = 2,
|
|
|
|
order = 2,
|
|
|
|
name = "Chat Announce",
|
|
|
|
name = "Chat Announce",
|
|
|
|
desc = "Announces in chat when you level up",
|
|
|
|
desc = "Announces in chat when you level up",
|
|
|
|
type = "toggle",
|
|
|
|
type = "toggle",
|
|
|
|
set = function(info, value) LevelUpAnnouncer.db.profile.chatAnnounce = value end,
|
|
|
|
set = function(_, value) LevelUpAnnouncer.db.profile.chatAnnounce = value end,
|
|
|
|
get = function(info) return LevelUpAnnouncer.db.profile.chatAnnounce end
|
|
|
|
get = function() return LevelUpAnnouncer.db.profile.chatAnnounce end
|
|
|
|
},
|
|
|
|
},
|
|
|
|
chatPercAnnounce = {
|
|
|
|
chatPercAnnounce = {
|
|
|
|
order = 3,
|
|
|
|
order = 3,
|
|
|
|
name = "Percentage Announce",
|
|
|
|
name = "Percentage Announce",
|
|
|
|
desc = "Announces in chat when you pass a percentage barrier (25%, 50% and 75%)",
|
|
|
|
desc = "Announces in chat when you pass a percentage barrier (25%, 50% and 75%)",
|
|
|
|
type = "toggle",
|
|
|
|
type = "toggle",
|
|
|
|
set = function(info, value) LevelUpAnnouncer.db.profile.chatPercAnnounce = value end,
|
|
|
|
set = function(_, value) LevelUpAnnouncer.db.profile.chatPercAnnounce = value end,
|
|
|
|
get = function(info) return LevelUpAnnouncer.db.profile.chatPercAnnounce end
|
|
|
|
get = function() return LevelUpAnnouncer.db.profile.chatPercAnnounce end
|
|
|
|
},
|
|
|
|
},
|
|
|
|
reversePerc = {
|
|
|
|
reversePerc = {
|
|
|
|
order = 4,
|
|
|
|
order = 4,
|
|
|
|
name = "Reverse Percentages",
|
|
|
|
name = "Reverse Percentages",
|
|
|
|
desc = "Reverses the percentages in percentage announce mode (announces 75% when at 25%, 50% at 50% and 25% at 75%)",
|
|
|
|
desc = "Reverses the percentages in percentage announce mode (announces 75% when at 25%, 50% at 50% and 25% at 75%)",
|
|
|
|
type = "toggle",
|
|
|
|
type = "toggle",
|
|
|
|
set = function(info, value) LevelUpAnnouncer.db.profile.reversePerc = value end,
|
|
|
|
set = function(_, value) LevelUpAnnouncer.db.profile.reversePerc = value end,
|
|
|
|
get = function(info) return LevelUpAnnouncer.db.profile.reversePerc end
|
|
|
|
get = function() return LevelUpAnnouncer.db.profile.reversePerc end
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
replaceWithEmote = {
|
|
|
|
|
|
|
|
order = 5,
|
|
|
|
|
|
|
|
name = "Smart Message Mode",
|
|
|
|
|
|
|
|
desc = "Replace \"Message Mode\" with EMOTE if using SAY or YELL when not in an instance",
|
|
|
|
|
|
|
|
type = "toggle",
|
|
|
|
|
|
|
|
set = function(_, value) LevelUpAnnouncer.db.profile.replaceWithEmote = value end,
|
|
|
|
|
|
|
|
get = function() return LevelUpAnnouncer.db.profile.replaceWithEmote end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
@@ -73,24 +83,24 @@ local options = {
|
|
|
|
name = "Level Up Announce Format",
|
|
|
|
name = "Level Up Announce Format",
|
|
|
|
desc = "The format used when you level up",
|
|
|
|
desc = "The format used when you level up",
|
|
|
|
type = "input",
|
|
|
|
type = "input",
|
|
|
|
set = function(info, value) LevelUpAnnouncer.db.profile.dingFormat = value end,
|
|
|
|
set = function(_, value) LevelUpAnnouncer.db.profile.dingFormat = value end,
|
|
|
|
get = function(info) return LevelUpAnnouncer.db.profile.dingFormat end
|
|
|
|
get = function() return LevelUpAnnouncer.db.profile.dingFormat end
|
|
|
|
},
|
|
|
|
},
|
|
|
|
percFormat = {
|
|
|
|
percFormat = {
|
|
|
|
order = 2,
|
|
|
|
order = 2,
|
|
|
|
name = "Percentage Announce Format",
|
|
|
|
name = "Percentage Announce Format",
|
|
|
|
desc = "The format used when you pass a percentage barrier (25%, 50% and 75%)",
|
|
|
|
desc = "The format used when you pass a percentage barrier (25%, 50% and 75%)",
|
|
|
|
type = "input",
|
|
|
|
type = "input",
|
|
|
|
set = function(info, value) LevelUpAnnouncer.db.profile.percFormat = value end,
|
|
|
|
set = function(_, value) LevelUpAnnouncer.db.profile.percFormat = value end,
|
|
|
|
get = function(info) return LevelUpAnnouncer.db.profile.percFormat end
|
|
|
|
get = function() return LevelUpAnnouncer.db.profile.percFormat end
|
|
|
|
},
|
|
|
|
},
|
|
|
|
reversePercFormat = {
|
|
|
|
reversePercFormat = {
|
|
|
|
order = 3,
|
|
|
|
order = 3,
|
|
|
|
name = "Reversed Percentage Announce Format",
|
|
|
|
name = "Reversed Percentage Announce Format",
|
|
|
|
desc = "The format used when you pass a percentage barrier in reverse mode (75%, 50% and 25%)",
|
|
|
|
desc = "The format used when you pass a percentage barrier in reverse mode (75%, 50% and 25%)",
|
|
|
|
type = "input",
|
|
|
|
type = "input",
|
|
|
|
set = function(info, value) LevelUpAnnouncer.db.profile.reversePercFormat = value end,
|
|
|
|
set = function(_, value) LevelUpAnnouncer.db.profile.reversePercFormat = value end,
|
|
|
|
get = function(info) return LevelUpAnnouncer.db.profile.reversePercFormat end
|
|
|
|
get = function() return LevelUpAnnouncer.db.profile.reversePercFormat end
|
|
|
|
},
|
|
|
|
},
|
|
|
|
placeholderHelp = {
|
|
|
|
placeholderHelp = {
|
|
|
|
order = 4,
|
|
|
|
order = 4,
|
|
|
@@ -111,23 +121,23 @@ local options = {
|
|
|
|
type = "input",
|
|
|
|
type = "input",
|
|
|
|
pattern = "(%d)",
|
|
|
|
pattern = "(%d)",
|
|
|
|
usage = "Only numbers are allowed",
|
|
|
|
usage = "Only numbers are allowed",
|
|
|
|
set = function(info, value) LevelUpAnnouncer.db.profile.soundID = tonumber(value) end,
|
|
|
|
set = function(_, value) LevelUpAnnouncer.db.profile.soundID = tonumber(value) end,
|
|
|
|
get = function(info) return tostring(LevelUpAnnouncer.db.profile.soundID) end
|
|
|
|
get = function() return tostring(LevelUpAnnouncer.db.profile.soundID) end
|
|
|
|
},
|
|
|
|
},
|
|
|
|
messageMode = {
|
|
|
|
messageMode = {
|
|
|
|
order = 2,
|
|
|
|
order = 2,
|
|
|
|
name = "Message Mode",
|
|
|
|
name = "Message Mode",
|
|
|
|
desc = "Modes:\nSAY\nYELL\nPARTY\nINSTANCE_CHAT\nRAID\nRAID_WARNING\nGUILD\nOFFICER\nEMOTE\nCHANNEL.X (So for channel 1 type: \"CHANNEL.1\")",
|
|
|
|
desc = "Modes:\nSAY (Only works in instances)\nYELL(Only works in instances)\nPARTY\nINSTANCE_CHAT\nRAID\nRAID_WARNING\nGUILD\nOFFICER\nEMOTE\nCHANNEL.X (So for channel 1 type: \"CHANNEL.1\", only works in instances)",
|
|
|
|
type = "input",
|
|
|
|
type = "input",
|
|
|
|
set = function(info, value) LevelUpAnnouncer.db.profile.messageModeString = value end,
|
|
|
|
set = function(_, value) LevelUpAnnouncer.db.profile.messageModeString = value end,
|
|
|
|
get = function(info) return LevelUpAnnouncer.db.profile.messageModeString end
|
|
|
|
get = function() return LevelUpAnnouncer.db.profile.messageModeString end
|
|
|
|
},
|
|
|
|
},
|
|
|
|
testSound = {
|
|
|
|
testSound = {
|
|
|
|
order = 3,
|
|
|
|
order = 3,
|
|
|
|
name = "Test Sound",
|
|
|
|
name = "Test Sound",
|
|
|
|
desc = "Click this to test the selected sound",
|
|
|
|
desc = "Click this to test the selected sound",
|
|
|
|
type = "execute",
|
|
|
|
type = "execute",
|
|
|
|
func = function() PlaySoundKitID(LevelUpAnnouncer.db.profile.soundID) end
|
|
|
|
func = function() PlaySound(LevelUpAnnouncer.db.profile.soundID) end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -152,7 +162,16 @@ local sendToChat = function(message)
|
|
|
|
local t = split(str, ".")
|
|
|
|
local t = split(str, ".")
|
|
|
|
local channel
|
|
|
|
local channel
|
|
|
|
if #t > 1 then channel = t[2] end
|
|
|
|
if #t > 1 then channel = t[2] end
|
|
|
|
local mode = t[1]
|
|
|
|
local mode = string.upper(t[1])
|
|
|
|
|
|
|
|
local replaceWithEmote = LevelUpAnnouncer.db.profile.replaceWithEmote
|
|
|
|
|
|
|
|
-- SendChatMessage is hardware event protected for modes "SAY", "YELL" and "CHANNEL" when player is "outdoors"
|
|
|
|
|
|
|
|
if not IsInInstance() and (mode == "SAY" or mode == "YELL" or mode == "CHANNEL") then
|
|
|
|
|
|
|
|
if replaceWithEmote and mode ~= "CHANNEL" then
|
|
|
|
|
|
|
|
mode = "EMOTE"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
SendChatMessage(message, mode, nil, channel)
|
|
|
|
SendChatMessage(message, mode, nil, channel)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@@ -176,7 +195,7 @@ function LevelUpAnnouncer:OnInitialize()
|
|
|
|
LevelUpAnnouncer:RegisterEvent("PLAYER_LEVEL_UP")
|
|
|
|
LevelUpAnnouncer:RegisterEvent("PLAYER_LEVEL_UP")
|
|
|
|
LevelUpAnnouncer:RegisterEvent("PLAYER_XP_UPDATE")
|
|
|
|
LevelUpAnnouncer:RegisterEvent("PLAYER_XP_UPDATE")
|
|
|
|
|
|
|
|
|
|
|
|
local command = function(msg) LibStub("AceConfigDialog-3.0"):Open("LevelUpAnnouncer") end
|
|
|
|
local command = function() LibStub("AceConfigDialog-3.0"):Open("LevelUpAnnouncer") end
|
|
|
|
LevelUpAnnouncer:RegisterChatCommand("levelup", command)
|
|
|
|
LevelUpAnnouncer:RegisterChatCommand("levelup", command)
|
|
|
|
LevelUpAnnouncer:RegisterChatCommand("lvlup", command)
|
|
|
|
LevelUpAnnouncer:RegisterChatCommand("lvlup", command)
|
|
|
|
end
|
|
|
|
end
|
|
|
@@ -186,14 +205,14 @@ function LevelUpAnnouncer:PLAYER_LOGIN()
|
|
|
|
self.tmpPercIndex = math.floor(self.xpPct * 4)
|
|
|
|
self.tmpPercIndex = math.floor(self.xpPct * 4)
|
|
|
|
self.curLevel = UnitLevel("player")
|
|
|
|
self.curLevel = UnitLevel("player")
|
|
|
|
|
|
|
|
|
|
|
|
print("|cff0066FFLevel Up Announcer|r, by |cff0066FFoskar3123|r, version |cff0066FF" ..version .. "|r loaded, /" .. "|cff0066FFlevelup|r for settings.")
|
|
|
|
print("|cff0066FFLevel Up Announcer|r, by |cff0066FF" .. author .. "|r, version |cff0066FF" ..version .. "|r loaded, /" .. "|cff0066FFlevelup|r for settings.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function LevelUpAnnouncer:PLAYER_LEVEL_UP()
|
|
|
|
function LevelUpAnnouncer:PLAYER_LEVEL_UP()
|
|
|
|
self.tmpPercIndex = 0
|
|
|
|
self.tmpPercIndex = 0
|
|
|
|
self.curLevel = self.curLevel + 1
|
|
|
|
self.curLevel = self.curLevel + 1
|
|
|
|
if self.db.profile.playSound then
|
|
|
|
if self.db.profile.playSound then
|
|
|
|
PlaySoundKitID(self.db.profile.soundID)
|
|
|
|
PlaySound(self.db.profile.soundID)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if self.db.profile.chatAnnounce then
|
|
|
|
if self.db.profile.chatAnnounce then
|
|
|
|
sendToChat(replaceFormats(self.db.profile.dingFormat, 0, self.curLevel))
|
|
|
|
sendToChat(replaceFormats(self.db.profile.dingFormat, 0, self.curLevel))
|
|
|
@@ -207,9 +226,11 @@ function LevelUpAnnouncer:PLAYER_XP_UPDATE()
|
|
|
|
if self.db.profile.reversePerc then stc = function(p) return sendToChat(replaceFormats(self.db.profile.reversePercFormat, 100 - p, self.curLevel)) end end
|
|
|
|
if self.db.profile.reversePerc then stc = function(p) return sendToChat(replaceFormats(self.db.profile.reversePercFormat, 100 - p, self.curLevel)) end end
|
|
|
|
if self.xpPct>=0.25 and self.tmpPercIndex<1 then
|
|
|
|
if self.xpPct>=0.25 and self.tmpPercIndex<1 then
|
|
|
|
stc(25)
|
|
|
|
stc(25)
|
|
|
|
elseif self.xpPct>=0.5 and self.tmpPercIndex<2 then
|
|
|
|
end
|
|
|
|
|
|
|
|
if self.xpPct>=0.5 and self.tmpPercIndex<2 then
|
|
|
|
stc(50)
|
|
|
|
stc(50)
|
|
|
|
elseif self.xpPct>=0.75 and self.tmpPercIndex<3 then
|
|
|
|
end
|
|
|
|
|
|
|
|
if self.xpPct>=0.75 and self.tmpPercIndex<3 then
|
|
|
|
stc(75)
|
|
|
|
stc(75)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
self.tmpPercIndex = math.floor(self.xpPct * 4)
|
|
|
|
self.tmpPercIndex = math.floor(self.xpPct * 4)
|
|
|
|