GrasscutterCommandGenerator/Source/GrasscutterTools/Models/GameItems.cs
筱傑 a055dc5299 Framework changed to WPF
Only the basic window frame is implemented.
Adjusted the structure of resource files.
2022-09-29 21:56:43 +08:00

36 lines
1.1 KiB
C#

using System;
using System.Collections.ObjectModel;
namespace GrasscutterTools.Models
{
public class GameItems : Collection<GameItem>
{
public GameItems(string sources)
{
var lines = sources.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
var category = string.Empty;
foreach (var line in lines)
{
if (line.StartsWith("//"))
{
category = line.Substring(2).Trim().Replace('_', ' ').ToLowerInvariant();
category = char.ToUpperInvariant(category[0]) + category.Substring(1);
}
else
{
var sp = line.IndexOf(':');
if (sp >= 0)
{
Items.Add(new GameItem
{
Id = int.Parse(line.Substring(0, sp).Trim()),
Name = line.Substring(sp + 1).Trim(),
Category = category
});
}
}
}
}
}
}