Files
YarikStudio/AssetStudio/AssetMap.cs
Razmoth 3d1799b9df - AssetBrowser Optimizations.
- Filter options added to `AssetBrowser`.
- New game entry.
- Togglable Model Preview.
- bug fixes.
2023-05-18 20:45:30 +04:00

50 lines
1.8 KiB
C#

using MessagePack;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace AssetStudio
{
[MessagePackObject]
public record AssetMap
{
[Key(0)]
public GameType GameType { get; set; }
[Key(1)]
public AssetEntry[] AssetEntries { get; set; }
}
[MessagePackObject]
public record AssetEntry
{
[Key(0)]
public string Name { get; set; }
[Key(1)]
public string Container { get; set; }
[Key(2)]
public string Source { get; set; }
[Key(3)]
public long PathID { get; set; }
[Key(4)]
public ClassIDType Type { get; set; }
public bool Matches(Dictionary<string, Regex> filters)
{
var matches = new List<bool>();
foreach(var filter in filters)
{
matches.Add(filter.Key switch
{
string value when value.Equals(nameof(Name), StringComparison.OrdinalIgnoreCase) => filter.Value.IsMatch(Name),
string value when value.Equals(nameof(Container), StringComparison.OrdinalIgnoreCase) => filter.Value.IsMatch(Container),
string value when value.Equals(nameof(Source), StringComparison.OrdinalIgnoreCase) => filter.Value.IsMatch(Source),
string value when value.Equals(nameof(PathID), StringComparison.OrdinalIgnoreCase) => filter.Value.IsMatch(PathID.ToString()),
string value when value.Equals(nameof (Type), StringComparison.OrdinalIgnoreCase) => filter.Value.IsMatch(Type.ToString()),
_ => throw new NotImplementedException()
});
}
return matches.Count(x => x == true) == filters.Count;
}
}
}