Quantcast

Merge branch 'master' into mop

F16Gaming [08-29-12 - 17:37]
Merge branch 'master' into mop
Filename
CommandManager.lua
DuelManager.lua
PlayerManager.lua
RoleManager.lua
SummonManager.lua
locales/enUS.lua
locales/svSE.lua
diff --git a/CommandManager.lua b/CommandManager.lua
index 7d6f747..b187cd2 100644
--- a/CommandManager.lua
+++ b/CommandManager.lua
@@ -28,6 +28,7 @@ local tonumber = tonumber
 -- API Upvalues
 local SetCVar = SetCVar
 local UnitName = UnitName
+local FollowUnit = FollowUnit
 local ShowUIPanel = ShowUIPanel
 local HideUIPanel = HideUIPanel
 local AcceptGroup = AcceptGroup
@@ -58,9 +59,9 @@ C.CommandManager = {
 	Commands = {}
 }

+local L = C.LocaleManager
 local CM = C.CommandManager
 local PM = C.PlayerManager
-local L = C.LocaleManager
 local QM = C.QueueManager
 local RM = C.RollManager
 local LM = C.LootManager
@@ -295,7 +296,13 @@ CM:Register({"set", "s"}, PM.Access.Groups.Admin.Level, function(args, sender, i
 			return false, "CM_ERR_NOCHAT"
 		end
 		local setting = args[2]:lower()
-		if setting:match("^[eay]") then -- Enable
+		if setting:match("^[eay].*a") then -- Enable Announce
+			return SM:EnableAnnounce()
+		elseif setting:match("^[dn].*a") then -- Disable Announce
+			return SM:DisableAnnounce()
+		elseif setting:match("^a.*t") or setting:match("^t.*a") then -- Toggle Announce
+			return SM:ToggleAnnounce()
+		elseif setting:match("^[eay]") then -- Enable
 			return SM:Enable()
 		elseif setting:match("^di") or setting:match("^n") then -- Disable
 			return SM:Disable()
@@ -407,6 +414,38 @@ CM:Register({"set", "s"}, PM.Access.Groups.Admin.Level, function(args, sender, i
 			return CDM:Disable()
 		end
 		return false, "CM_SET_CDM_USAGE"
+	elseif mod:match("^r") then -- RoleManager
+		if #args < 2 then
+			if CRM:IsEnabled() then
+				return "CM_SET_CRM_ISENABLED"
+			end
+			return "CM_SET_CRM_ISDISABLED"
+		end
+		if isChat then -- Players are only allowed to check the status of RoleManager
+			return false, "CM_ERR_NOCHAT"
+		end
+		local setting = args[2]:lower()
+		if setting:match("^[eay].*a") then -- Enable Announce
+			return CRM:EnableAnnounce()
+		elseif setting:match("^[dn].*a") then -- Disable Announce
+			return CRM:DisableAnnounce()
+		elseif setting:match("^a.*t") or setting:match("^t.*a") then -- Toggle Announce
+			return CRM:ToggleAnnounce()
+		elseif setting:match("^s.*d") or setting:match("^de") then -- (Set) Delay
+			if #args < 3 then
+				return "CM_SET_CRM_DELAY_CURRENT", {CRM:GetDelay()}
+			end
+			local newDelay = tonumber(args[3])
+			if not newDelay then return false, "CM_SET_CRM_DELAY_USAGE" end
+			return CRM:SetDelay(newDelay)
+		elseif setting:match("^[eay]") then -- Enable
+			return CRM:Enable()
+		elseif setting:match("^[dn]") then -- Disable
+			return CRM:Disable()
+		elseif setting:match("^t") then -- Toggle
+			return CRM:Toggle()
+		end
+		return false, "CM_SET_CDM_USAGE"
 	end
 	return false, "CM_SET_USAGE"
 end, "CM_SET_HELP")
@@ -1133,6 +1172,20 @@ CM:Register({"role", "rm"}, PM.Access.Groups.User.Level, function(args, sender,
 	return false, "CM_ROLE_USAGE"
 end, "CM_ROLE_HELP")

+CM:Register({"follow", "f"}, PM.Access.Groups.User.Level, function(args, sender, isChat, bnetInfo)
+	local name = args[1]
+	if name then
+		name = PM:GetOrCreatePlayer(name).Info.Name
+	else
+		name = sender.Info.Name
+	end
+	if name == UnitName("player") then
+		return false, "CM_FOLLOW_SELF"
+	end
+	FollowUnit(name)
+	return "CM_FOLLOW_STARTED", {name}
+end, "CM_FOLLOW_HELP")
+
 for i,v in ipairs(CM.Slash) do
 	_G["SLASH_" .. C.Name:upper() .. i] = "/" .. v
 end
diff --git a/DuelManager.lua b/DuelManager.lua
index 374c531..96a0384 100644
--- a/DuelManager.lua
+++ b/DuelManager.lua
@@ -85,7 +85,7 @@ function DM:OnDuel(sender)
 end

 function DM:Announce(sender)
-	if not self:HasDuel() then return end
+	if not self:HasDuel() or not self.Settings.ANNOUNCE then return end
 	local locale = PM:GetOrCreatePlayer(sender).Settings.locale
 	local msg = L(locale, "CDM_ANNOUNCE", true)
 	CM:SendMessage(msg, "WHISPER", sender)
diff --git a/PlayerManager.lua b/PlayerManager.lua
index bfcede0..a5db8ee 100644
--- a/PlayerManager.lua
+++ b/PlayerManager.lua
@@ -629,6 +629,8 @@ function PM:Invite(player, sender, pID)
 		return false, "PM_INVITE_INGROUP", {player.Info.Name}
 	elseif GT:IsGroupFull() then
 		return false, "PM_INVITE_FULL"
+	elseif GT:IsLFGGroup() then
+		return false, "PM_INVITE_LFG"
 	end
 	if GT:IsGroupLeader() or GT:IsRaidLeaderOrAssistant() or not GT:IsGroup() then
 		if self.Invites[player.Info.Name] then
diff --git a/RoleManager.lua b/RoleManager.lua
index 7405ebf..55c8976 100644
--- a/RoleManager.lua
+++ b/RoleManager.lua
@@ -67,6 +67,10 @@ function RM:LoadSavedVars()
 		self.Settings.ENABLED = true
 	end

+	if type(self.Settings.ANNOUNCE) ~= "boolean" then
+		self.Settings.ANNOUNCE = true
+	end
+
 	if type(self.Settings.DELAY) ~= "number" then
 		self.Settings.DELAY = DEFAULT_DELAY
 	end
@@ -90,7 +94,7 @@ function RM:OnRoleCheck()
 end

 function RM:Announce()
-	if not self:RolePollActive() then return end
+	if not self:RolePollActive() or not self.Settings.ANNOUNCE then return end
 	local current = self:GetRole()
 	local msg
 	if current ~= self.Roles.Undefined then
@@ -166,10 +170,12 @@ function RM:Start()
 	if self:RolePollActive() then
 		return false, "CRM_START_ACTIVE"
 	elseif (GT:IsParty() and GT:IsGroupLeader()) or (GT:IsRaid() and GT:IsRaidLeaderOrAssistant()) then
-
-	else
-		return false, "CRM_START_NOPRIV"
+		InitiateRolePoll()
+		return "CRM_START_SUCCESS"
+	elseif not GT:IsGroup() then
+		return false, "CRM_START_NOGROUP"
 	end
+	return false, "CRM_START_NOPRIV"
 end

 function RM:Enable()
@@ -193,6 +199,22 @@ function RM:IsEnabled()
 	return self.Settings.ENABLED
 end

+function RM:EnableAnnounce()
+
+end
+
+function RM:DisableAnnounce()
+
+end
+
+function RM:ToggleAnnounce()
+
+end
+
+function RM:IsAnnounceEnabled()
+
+end
+
 function RM:GetDelay()
 	return CEN:FormatSeconds(self:GetRawDelay())
 end
diff --git a/SummonManager.lua b/SummonManager.lua
index 3a8c54a..221556d 100644
--- a/SummonManager.lua
+++ b/SummonManager.lua
@@ -71,6 +71,10 @@ function SM:LoadSavedVars()
 		self.Settings.ENABLED = true
 	end

+	if type(self.Settings.ANNOUNCE) ~= "boolean" then
+		self.Settings.ANNOUNCE = true
+	end
+
 	if type(self.Settings.DELAY) ~= "number" then
 		self.Settings.DELAY = DEFAULT_DELAY
 	end
@@ -99,7 +103,7 @@ function SM:OnSummon()
 end

 function SM:Announce()
-	if not self:HasSummon() then return end
+	if not self:HasSummon() or not self.Settings.ANNOUNCE then return end

 	local name = GetSummonConfirmSummoner()
 	local area = GetSummonConfirmAreaName()
@@ -107,7 +111,7 @@ function SM:Announce()

 	if not name or not area or not left or left <= 0 then return end

-	left = FormatSeconds(left)
+	left = CEN:FormatSeconds(left)

 	LastSummoner = name

@@ -169,6 +173,27 @@ function SM:Toggle()
 	return self:Enable()
 end

+function SM:EnableAnnounce()
+	self.Settings.ANNOUNCE = true
+	return "SM_ANNOUNCE_ENABLED"
+end
+
+function SM:DisableAnnounce()
+	self.Settings.ANNOUNCE = false
+	return "SM_ANNOUNCE_DISABLED"
+end
+
+function SM:ToggleAnnounce()
+	if self:IsAnnounceEnabled() then
+		return self:DisableAnnounce()
+	end
+	return self:EnableAnnounce()
+end
+
+function SM:IsAnnounceEnabled()
+	return self.Settings.ANNOUNCE
+end
+
 function SM:GetDelay()
 	return FormatSeconds(self:GetRawDelay())
 end
diff --git a/locales/enUS.lua b/locales/enUS.lua
index b536361..e2d27e6 100644
--- a/locales/enUS.lua
+++ b/locales/enUS.lua
@@ -138,6 +138,11 @@ local L = {
 	CM_SET_CDM_DELAY_CURRENT = "Announce delay is set to %d second(s).",
 	CM_SET_CDM_DELAY_USAGE = "Usage: set duelmanager delay [delay]",
 	CM_SET_CDM_USAGE = "Usage: set duelmanager [enable|disable|toggle|enableannounce|disableannounce|toggleannounce|delay]",
+	CM_SET_CRM_ISENABLED = "RoleManager is enabled.",
+	CM_SET_CRM_ISDISABLED = "RoleManager is disabled.",
+	CM_SET_CRM_DELAY_CURRENT = "Announce delay is set to %s.",
+	CM_SET_CRM_DELAY_USAGE = "Usage: set rm delay [delay]",
+	CM_SET_CRM_USAGE = "Usage: set rm [enable|disable|toggle|enableannounce|disableannounce|toggleannounce|setdelay]",

 	CM_LOCALE_HELP = "Change locale settings.",
 	CM_LOCALE_USAGE ="Usage: locale [set|reset|usemaster|playerindependent]",
@@ -310,6 +315,10 @@ local L = {
 	CM_ROLE_SET_USAGE = "Usage: role set tank|healer|dps",
 	CM_ROLE_CONFIRM_USAGE = "Usage: role confirm [tank|healer|dps]",

+	CM_FOLLOW_HELP = "Starts following the specified player (or sender if no player specified).",
+	CM_FOLLOW_STARTED = "Started following %s!",
+	CM_FOLLOW_SELF = "I cannot follow myself.",
+
 	------------
 	-- Events --
 	------------
@@ -422,6 +431,7 @@ local L = {
 	PM_INVITE_SELF = "Cannot invite myself to group.",
 	PM_INVITE_INGROUP = "%s is already in the group.",
 	PM_INVITE_FULL = "The group is already full.",
+	PM_INVITE_LFG = "Cannot invite players to an LFG group.",
 	PM_INVITE_ACTIVE = "%s already has an active invite.",
 	PM_INVITE_DECLINED = "%s has declined the group invite.",
 	PM_INVITE_INOTHERGROUP = "%s is already in a group.",
@@ -612,6 +622,7 @@ local L = {

 	CRM_START_ACTIVE = "A role check is already pending, please wait until it has ended.",
 	CRM_START_NOPRIV = "Unable to start role check, not leader or assistant.",
+	CRM_START_NOGROUP = "Role checks can only be started when in a group.",

 	CRM_STARTDELAY_SUCCESS = "RoleManager announce delay set to %s!",
 	CRM_STARTDELAY_INSTANT = "RoleManager now announces instantly.",
diff --git a/locales/svSE.lua b/locales/svSE.lua
index 8854ca0..ad663be 100644
--- a/locales/svSE.lua
+++ b/locales/svSE.lua
@@ -138,6 +138,11 @@ local L = {
 	CM_SET_CDM_DELAY_CURRENT = "Announce delay is set to %d second(s).",
 	CM_SET_CDM_DELAY_USAGE = "Usage: set duelmanager delay [delay]",
 	CM_SET_CDM_USAGE = "Usage: set duelmanager [enable|disable|toggle|enableannounce|disableannounce|toggleannounce|delay]",
+	CM_SET_CRM_ISENABLED = "RoleManager is enabled.",
+	CM_SET_CRM_ISDISABLED = "RoleManager is disabled.",
+	CM_SET_CRM_DELAY_CURRENT = "Announce delay is set to %s.",
+	CM_SET_CRM_DELAY_USAGE = "Usage: set rm delay [delay]",
+	CM_SET_CRM_USAGE = "Usage: set rm [enable|disable|toggle|enableannounce|disableannounce|toggleannounce|setdelay]",

 	CM_LOCALE_HELP = "Change locale settings.",
 	CM_LOCALE_USAGE ="Användning: locale [set|reset|usemaster|playerindependent]",
@@ -310,6 +315,10 @@ local L = {
 	CM_ROLE_SET_USAGE = "Användning: role set tank|healer|dps",
 	CM_ROLE_CONFIRM_USAGE = "Usage: role confirm [tank|healer|dps]",

+	CM_FOLLOW_HELP = "Starts following the specified player (or sender if no player specified).",
+	CM_FOLLOW_STARTED = "Started following %s!",
+	CM_FOLLOW_SELF = "I cannot follow myself.",
+
 	------------
 	-- Events --
 	------------
@@ -422,6 +431,7 @@ local L = {
 	PM_INVITE_SELF = "Cannot invite myself to group.",
 	PM_INVITE_INGROUP = "%s is already in the group.",
 	PM_INVITE_FULL = "The group is already full.",
+	PM_INVITE_LFG = "Cannot invite players to an LFG group.",
 	PM_INVITE_ACTIVE = "%s already has an active invite.",
 	PM_INVITE_DECLINED = "%s has declined the group invite.",
 	PM_INVITE_INOTHERGROUP = "%s is already in a group.",
@@ -612,6 +622,7 @@ local L = {

 	CRM_START_ACTIVE = "A role check is already pending, please wait until it has ended.",
 	CRM_START_NOPRIV = "Unable to start role check, not leader or assistant.",
+	CRM_START_NOGROUP = "Role checks can only be started when in a group.",

 	CRM_STARTDELAY_SUCCESS = "RoleManager announce delay set to %s!",
 	CRM_STARTDELAY_INSTANT = "RoleManager now announces instantly.",