mirror of
https://github.com/jie65535/GrasscutterCommandGenerator.git
synced 2025-12-11 09:01:35 +08:00
Framework changed to WPF
Only the basic window frame is implemented. Adjusted the structure of resource files.
This commit is contained in:
16
Source/GrasscutterTools/Models/GameItem.cs
Normal file
16
Source/GrasscutterTools/Models/GameItem.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace GrasscutterTools.Models
|
||||
{
|
||||
public class GameItem
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Category { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Id} : {Name}";
|
||||
}
|
||||
}
|
||||
}
|
||||
35
Source/GrasscutterTools/Models/GameItems.cs
Normal file
35
Source/GrasscutterTools/Models/GameItems.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user