Improvements and bug fixes.
This commit is contained in:
@@ -43,7 +43,6 @@ namespace AssetStudio
|
||||
public static Game[] GetGames() => Games.Values.ToArray();
|
||||
public static string[] GetGameNames() => Games.Values.Select(x => x.Name).ToArray();
|
||||
public static string SupportedGames() => $"Supported Games:\n{string.Join("\n", Games.Values.Select(x => $"{x.Name} ({x.DisplayName})"))}";
|
||||
public static string ToString() => string.Join("\n", Games.Values);
|
||||
}
|
||||
|
||||
public abstract class Game
|
||||
|
||||
@@ -31,35 +31,38 @@ namespace AssetStudio
|
||||
}
|
||||
public static void FromFile(string path)
|
||||
{
|
||||
Logger.Info(string.Format("Parsing...."));
|
||||
try
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
Clear();
|
||||
|
||||
using (var stream = File.OpenRead(path))
|
||||
Logger.Info(string.Format("Parsing...."));
|
||||
try
|
||||
{
|
||||
var bytes = new byte[stream.Length];
|
||||
var count = stream.Read(bytes, 0, bytes.Length);
|
||||
Clear();
|
||||
|
||||
if (count != bytes.Length)
|
||||
throw new Exception("Error While Reading AssetIndex");
|
||||
|
||||
var json = Encoding.UTF8.GetString(bytes);
|
||||
|
||||
var obj = JsonConvert.DeserializeObject<AssetIndex>(json);
|
||||
if (obj != null)
|
||||
using (var stream = File.OpenRead(path))
|
||||
{
|
||||
MapToResourceIndex(obj);
|
||||
var bytes = new byte[stream.Length];
|
||||
var count = stream.Read(bytes, 0, bytes.Length);
|
||||
|
||||
if (count != bytes.Length)
|
||||
throw new Exception("Error While Reading AssetIndex");
|
||||
|
||||
var json = Encoding.UTF8.GetString(bytes);
|
||||
|
||||
var obj = JsonConvert.DeserializeObject<AssetIndex>(json);
|
||||
if (obj != null)
|
||||
{
|
||||
MapToResourceIndex(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error("AssetIndex was not loaded");
|
||||
Console.WriteLine(e.ToString());
|
||||
return;
|
||||
}
|
||||
Logger.Info("Loaded !!");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error("AssetIndex was not loaded");
|
||||
Console.WriteLine(e.ToString());
|
||||
return;
|
||||
}
|
||||
Logger.Info("Loaded !!");
|
||||
}
|
||||
public static void Clear()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Buffers.Binary;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -31,8 +32,6 @@ namespace AssetStudio
|
||||
public List<SerializedType> m_RefTypes;
|
||||
public string userInformation;
|
||||
|
||||
private static int DecryptClassId(int id) => (id ^ 0x23746FBE) - 3;
|
||||
|
||||
public SerializedFile(FileReader reader, AssetsManager assetsManager, string path = null)
|
||||
{
|
||||
this.assetsManager = assetsManager;
|
||||
@@ -238,12 +237,9 @@ namespace AssetStudio
|
||||
var type = new SerializedType();
|
||||
|
||||
type.classID = reader.ReadInt32();
|
||||
|
||||
if ((type.classID > 0xFFFF || type.classID <= 0x0) && !Enum.IsDefined(typeof(ClassIDType), type.classID))
|
||||
if (BitConverter.ToBoolean(header.m_Reserved, 0))
|
||||
{
|
||||
byte[] classIdBytes = BitConverter.GetBytes(type.classID);
|
||||
Array.Reverse(classIdBytes);
|
||||
type.classID = DecryptClassId(BitConverter.ToInt32(classIdBytes, 0));
|
||||
type.classID = DecodeClassID(type.classID);
|
||||
}
|
||||
|
||||
if (header.m_Version >= SerializedFileFormatVersion.RefactoredClassId)
|
||||
@@ -385,6 +381,12 @@ namespace AssetStudio
|
||||
ObjectsDic.Add(obj.m_PathID, obj);
|
||||
}
|
||||
|
||||
private int DecodeClassID(int value)
|
||||
{
|
||||
var bytes = BitConverter.GetBytes(value);
|
||||
value = BinaryPrimitives.ReadInt32BigEndian(bytes);
|
||||
return (value ^ 0x23746FBE) - 3;
|
||||
}
|
||||
public bool IsVersionStripped => unityVersion == strippedVersion;
|
||||
|
||||
private const string strippedVersion = "0.0.0";
|
||||
|
||||
@@ -194,9 +194,11 @@ namespace AssetStudio
|
||||
value = reader.ReadSByte();
|
||||
break;
|
||||
case "UInt8":
|
||||
case "char":
|
||||
value = reader.ReadByte();
|
||||
break;
|
||||
case "char":
|
||||
value = BitConverter.ToChar(reader.ReadBytes(2), 0);
|
||||
break;
|
||||
case "short":
|
||||
case "SInt16":
|
||||
value = reader.ReadInt16();
|
||||
|
||||
@@ -15,10 +15,10 @@ namespace AssetStudio
|
||||
animationClip.m_ScaleCurves = converter.Scales.Union(animationClip.m_ScaleCurves).ToArray();
|
||||
animationClip.m_FloatCurves = converter.Floats.Union(animationClip.m_FloatCurves).ToArray();
|
||||
animationClip.m_PPtrCurves = converter.PPtrs.Union(animationClip.m_PPtrCurves).ToArray();
|
||||
return ConvertSerializedAnimationClip(animationClip, game);
|
||||
return ConvertSerializedAnimationClip(animationClip);
|
||||
}
|
||||
|
||||
public static string ConvertSerializedAnimationClip(AnimationClip animationClip, Game game)
|
||||
public static string ConvertSerializedAnimationClip(AnimationClip animationClip)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
using (var stringWriter = new StringWriter(sb))
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace AssetStudio
|
||||
var polygons = triangles.Select(x => new Polygon(new LinearLineSegment(x.Select(y => new PointF(y.X, y.Y)).ToArray()))).ToArray();
|
||||
IPathCollection path = new PathCollection(polygons);
|
||||
var matrix = Matrix3x2.CreateScale(m_Sprite.m_PixelsToUnits);
|
||||
matrix *= Matrix3x2.CreateTranslation(textureRect.width * m_Sprite.m_Pivot.X - textureRectOffset.X, textureRect.height * m_Sprite.m_Pivot.Y - textureRectOffset.Y);
|
||||
matrix *= Matrix3x2.CreateTranslation(m_Sprite.m_Rect.width * m_Sprite.m_Pivot.X - textureRectOffset.X, m_Sprite.m_Rect.height * m_Sprite.m_Pivot.Y - textureRectOffset.Y);
|
||||
path = path.Transform(matrix);
|
||||
var graphicsOptions = new GraphicsOptions
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user