Files
YarikStudio/AssetStudio/ResourceMap.cs
Razmoth 6b060f734c AssetBrowser redesigned
- Load multiple entries (while selected).
- fix resize issue.
2023-05-08 21:29:19 +04:00

38 lines
1.2 KiB
C#

using MessagePack;
using System;
using System.IO;
namespace AssetStudio
{
public static class ResourceMap
{
private static AssetMap Instance = new() { GameType = GameType.Normal, AssetEntries = Array.Empty<AssetEntry>() };
public static AssetEntry[] GetEntries() => Instance.AssetEntries;
public static void FromFile(string path)
{
if (!string.IsNullOrEmpty(path))
{
Logger.Info(string.Format("Parsing...."));
try
{
using var stream = File.OpenRead(path);
Instance = MessagePackSerializer.Deserialize<AssetMap>(stream, MessagePackSerializerOptions.Standard.WithCompression(MessagePackCompression.Lz4BlockArray));
}
catch (Exception e)
{
Logger.Error("AssetMap was not loaded");
Console.WriteLine(e.ToString());
return;
}
Logger.Info("Loaded !!");
}
}
public static void Clear()
{
Instance.GameType = GameType.Normal;
Instance.AssetEntries = Array.Empty<AssetEntry>();
}
}
}