mirror of
https://github.com/jie65535/GrasscutterCommandGenerator.git
synced 2025-10-21 19:59:48 +08:00
Separate pages
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
/**
|
||||
* Grasscutter Tools
|
||||
* Copyright (C) 2022 jie65535
|
||||
*
|
||||
@@ -29,5 +32,37 @@ namespace GrasscutterTools.Game
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Command { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取命令记录
|
||||
/// (反序列化)
|
||||
/// </summary>
|
||||
/// <param name="commandsText">命令记录文本(示例:"标签1\n命令1\n标签2\n命令2...")</param>
|
||||
/// <returns>命令列表</returns>
|
||||
public static List<GameCommand> Parse(string commandsText)
|
||||
{
|
||||
var lines = commandsText.Split('\n');
|
||||
List<GameCommand> commands = new List<GameCommand>(lines.Length / 2);
|
||||
for (int i = 0; i < lines.Length - 1; i += 2)
|
||||
commands.Add(new GameCommand(lines[i].Trim(), lines[i + 1].Trim()));
|
||||
return commands;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取命令记录文本
|
||||
/// (序列化)
|
||||
/// </summary>
|
||||
/// <param name="commands">命令列表</param>
|
||||
/// <returns>命令记录文本(示例:"标签1\n命令1\n标签2\n命令2...")</returns>
|
||||
public static string ToString(List<GameCommand> commands)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
foreach (var cmd in commands)
|
||||
{
|
||||
builder.AppendLine(cmd.Name);
|
||||
builder.AppendLine(cmd.Command);
|
||||
}
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user