1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 16:52:54 +08:00

Added infoMessage class to the project, use the class for the /help command and handle command parameter better

This commit is contained in:
MrTheMake 2017-09-22 15:31:30 +02:00
parent 18c26a85ba
commit 0a27916761
2 changed files with 13 additions and 5 deletions

View File

@ -482,25 +482,25 @@ namespace osu.Game.Overlays
if (postText[0] == '/')
{
postText = postText.Substring(1);
string commandKeyword = postText.Split(' ')[0];
string unhandeledParameters = postText.Substring(1);
string commandKeyword = cutFirstParameter(ref unhandeledParameters);
switch (commandKeyword)
{
case "me":
if (!postText.StartsWith("me ") || string.IsNullOrWhiteSpace(postText.Substring(3)))
if (string.IsNullOrWhiteSpace(unhandeledParameters))
{
currentChannel.AddNewMessages(new ErrorMessage("Usage: /me [action]"));
return;
}
isAction = true;
postText = postText.Substring(3);
postText = unhandeledParameters;
break;
case "help":
currentChannel.AddNewMessages(new ErrorMessage("Supported commands: /help, /me [action]"));
currentChannel.AddNewMessages(new InfoMessage("Supported commands: /help, /me [action]"));
return;
default:
@ -528,6 +528,13 @@ namespace osu.Game.Overlays
api.Queue(req);
}
private string cutFirstParameter(ref string parameters)
{
string result = parameters.Split(' ')[0];
parameters = result.Length == parameters.Length ? "" : parameters.Substring(result.Length + 1);
return result;
}
private void transformChatHeightTo(double newChatHeight, double duration = 0, Easing easing = Easing.None)
{
this.TransformTo(this.PopulateTransform(new TransformChatHeight(), newChatHeight, duration, easing));

View File

@ -372,6 +372,7 @@
<Compile Include="Online\API\Requests\PostMessageRequest.cs" />
<Compile Include="Online\Chat\Channel.cs" />
<Compile Include="Online\Chat\ErrorMessage.cs" />
<Compile Include="Online\Chat\InfoMessage.cs" />
<Compile Include="Online\Chat\LocalEchoMessage.cs" />
<Compile Include="Online\Chat\Message.cs" />
<Compile Include="Online\Multiplayer\GameType.cs" />