Separate pages

This commit is contained in:
2022-11-26 23:47:46 +08:00
parent 6ab7bac20b
commit 436c4d809c
48 changed files with 12655 additions and 8659 deletions

View File

@@ -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();
}
}
}