|
|
@ -31,6 +31,9 @@ var private AssociativeArray registeredCommands; |
|
|
|
// Setting this to `true` enables players to input commands right in the chat |
|
|
|
// Setting this to `true` enables players to input commands right in the chat |
|
|
|
// by prepending them with "!" character. |
|
|
|
// by prepending them with "!" character. |
|
|
|
var private /*config*/ bool useChatInput; |
|
|
|
var private /*config*/ bool useChatInput; |
|
|
|
|
|
|
|
// Setting this to `true` enables players to input commands with "mutate" |
|
|
|
|
|
|
|
// console command. |
|
|
|
|
|
|
|
var private /*config*/ bool useMutateInput; |
|
|
|
|
|
|
|
|
|
|
|
var LoggerAPI.Definition errCommandDuplicate; |
|
|
|
var LoggerAPI.Definition errCommandDuplicate; |
|
|
|
|
|
|
|
|
|
|
@ -38,7 +41,6 @@ protected function OnEnabled() |
|
|
|
{ |
|
|
|
{ |
|
|
|
registeredCommands = _.collections.EmptyAssociativeArray(); |
|
|
|
registeredCommands = _.collections.EmptyAssociativeArray(); |
|
|
|
RegisterCommand(class'ACommandHelp'); |
|
|
|
RegisterCommand(class'ACommandHelp'); |
|
|
|
_.chat.OnMessage(self).connect = HandleCommands; |
|
|
|
|
|
|
|
// Macro selector |
|
|
|
// Macro selector |
|
|
|
commandDelimiters[0] = P("@"); |
|
|
|
commandDelimiters[0] = P("@"); |
|
|
|
// Key selector |
|
|
|
// Key selector |
|
|
@ -51,7 +53,14 @@ protected function OnEnabled() |
|
|
|
|
|
|
|
|
|
|
|
protected function OnDisabled() |
|
|
|
protected function OnDisabled() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (useChatInput) { |
|
|
|
_.chat.OnMessage(self).Disconnect(); |
|
|
|
_.chat.OnMessage(self).Disconnect(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (useMutateInput) { |
|
|
|
|
|
|
|
_.unreal.mutator.OnMutate(self).Disconnect(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
useChatInput = false; |
|
|
|
|
|
|
|
useMutateInput = false; |
|
|
|
if (registeredCommands != none) |
|
|
|
if (registeredCommands != none) |
|
|
|
{ |
|
|
|
{ |
|
|
|
registeredCommands.Empty(true); |
|
|
|
registeredCommands.Empty(true); |
|
|
@ -68,17 +77,26 @@ protected function SwapConfig(FeatureConfig config) |
|
|
|
if (newConfig == none) { |
|
|
|
if (newConfig == none) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (useChatInput != newConfig.useChatInput) |
|
|
|
|
|
|
|
{ |
|
|
|
useChatInput = newConfig.useChatInput; |
|
|
|
useChatInput = newConfig.useChatInput; |
|
|
|
} |
|
|
|
if (newConfig.useChatInput) { |
|
|
|
|
|
|
|
_.chat.OnMessage(self).connect = HandleCommands; |
|
|
|
/** |
|
|
|
} |
|
|
|
* Checks whether this feature uses in-game chat input for commands. |
|
|
|
else { |
|
|
|
* |
|
|
|
_.chat.OnMessage(self).Disconnect(); |
|
|
|
* @return `true` iff this feature uses in-game chat input for commands. |
|
|
|
} |
|
|
|
*/ |
|
|
|
} |
|
|
|
public final function bool UsingChatInput() |
|
|
|
if (useMutateInput != newConfig.useMutateInput) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return useChatInput; |
|
|
|
useMutateInput = newConfig.useMutateInput; |
|
|
|
|
|
|
|
if (newConfig.useMutateInput) { |
|
|
|
|
|
|
|
_.unreal.mutator.OnMutate(self).connect = HandleMutate; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
_.unreal.mutator.OnMutate(self).Disconnect(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -227,9 +245,6 @@ private function bool HandleCommands( |
|
|
|
bool teamMessage) |
|
|
|
bool teamMessage) |
|
|
|
{ |
|
|
|
{ |
|
|
|
local Parser parser; |
|
|
|
local Parser parser; |
|
|
|
if (!UsingChatInput()) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// We are only interested in messages that start with "!" |
|
|
|
// We are only interested in messages that start with "!" |
|
|
|
parser = _.text.Parse(message); |
|
|
|
parser = _.text.Parse(message); |
|
|
|
if (!parser.Match(P("!")).Ok()) |
|
|
|
if (!parser.Match(P("!")).Ok()) |
|
|
@ -243,6 +258,17 @@ private function bool HandleCommands( |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function HandleMutate(string command, PlayerController sendingPlayer) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local Parser parser; |
|
|
|
|
|
|
|
local EPlayer sender; |
|
|
|
|
|
|
|
parser = _.text.ParseString(command); |
|
|
|
|
|
|
|
sender = _.players.FromController(sendingPlayer); |
|
|
|
|
|
|
|
HandleInput(parser, sender); |
|
|
|
|
|
|
|
sender.FreeSelf(); |
|
|
|
|
|
|
|
parser.FreeSelf(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
defaultproperties |
|
|
|
defaultproperties |
|
|
|
{ |
|
|
|
{ |
|
|
|
configClass = class'Commands' |
|
|
|
configClass = class'Commands' |
|
|
|