forked from parzivail/RainbowForge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
flip textures horizontally in viewport, improve navigation performanc…
…e on large, non-previewable assets
- Loading branch information
Showing
8 changed files
with
105 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
using System.IO; | ||
using System; | ||
using System.IO; | ||
|
||
namespace Prism | ||
{ | ||
internal record AssetStream(ulong Uid, ulong Magic, string Filename, BinaryReader Stream); | ||
internal record AssetStream(ulong Uid, ulong Magic, string Filename, Func<BinaryReader> StreamProvider); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using System; | ||
using System.IO; | ||
|
||
namespace RainbowForge | ||
{ | ||
public class SubStream : Stream, IDisposable | ||
{ | ||
private readonly Stream _source; | ||
private readonly int _length; | ||
private readonly long _minPos; | ||
private readonly long _maxPos; | ||
|
||
public SubStream(Stream source, long offset, int length) | ||
{ | ||
_source = source; | ||
_minPos = offset; | ||
_length = length; | ||
_maxPos = offset + length; | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void Dispose(bool disposing) | ||
{ | ||
if (disposing) | ||
{ | ||
_source?.Dispose(); | ||
} | ||
|
||
base.Dispose(disposing); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override void Flush() | ||
{ | ||
_source.Flush(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override int Read(byte[] buffer, int offset, int count) | ||
{ | ||
return _source.Read(buffer, offset, Math.Min((int)(_maxPos - _source.Position), count)); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override long Seek(long offset, SeekOrigin origin) | ||
{ | ||
return _source.Seek(offset + _minPos, origin); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override void SetLength(long value) => throw new NotSupportedException(); | ||
|
||
/// <inheritdoc /> | ||
public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException(); | ||
|
||
/// <inheritdoc /> | ||
public override bool CanRead => _source.CanRead; | ||
|
||
/// <inheritdoc /> | ||
public override bool CanSeek => _source.CanSeek; | ||
|
||
/// <inheritdoc /> | ||
public override bool CanWrite => false; | ||
|
||
/// <inheritdoc /> | ||
public override long Length => _length; | ||
|
||
/// <inheritdoc /> | ||
public override long Position | ||
{ | ||
get => _source.Position - _minPos; | ||
set => _source.Position = _minPos + value; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using RainbowForge; | ||
using RainbowForge.Archive; | ||
using RainbowForge.Core; | ||
using RainbowForge.Core.Container; | ||
|
||
namespace Sandbox | ||
{ | ||
internal class Program | ||
{ | ||
private static void Main(string[] args) | ||
{ | ||
using var sw = new StreamWriter("out.txt"); | ||
foreach (var forgeFilename in Directory.GetFiles("R:\\Siege Dumps\\Y6S1 v15500403", "*.forge")) | ||
{ | ||
Console.WriteLine(forgeFilename); | ||
|
||
var newForge = Forge.GetForge(forgeFilename); | ||
|
||
foreach (var entry in newForge.Entries) | ||
{ | ||
TestMagic(entry.MetaData.FileType); | ||
|
||
if (MagicHelper.GetFiletype(entry.MetaData.FileType) != AssetType.FlatArchive) | ||
continue; | ||
|
||
var container = newForge.GetContainer(entry.Uid); | ||
if (container is not ForgeAsset fa) | ||
continue; | ||
|
||
var arc = FlatArchive.Read(fa.GetDataStream(newForge)); | ||
|
||
foreach (var arcEntry in arc.Entries) TestMagic(arcEntry.MetaData.FileType); | ||
} | ||
} | ||
|
||
foreach (var (magic, count) in MagicTable.OrderByDescending(pair => pair.Value)) | ||
if (Enum.IsDefined(typeof(Magic), (ulong)magic)) | ||
sw.WriteLine($"0x{magic:X8} ({(Magic)magic}) - {count}"); | ||
else | ||
sw.WriteLine($"0x{magic:X8} - {count}"); | ||
|
||
Console.WriteLine("Done."); | ||
} | ||
|
||
private static readonly Dictionary<uint, int> MagicTable = new(); | ||
|
||
private static void TestMagic(uint fileType) | ||
{ | ||
if (!MagicTable.ContainsKey(fileType)) | ||
MagicTable[fileType] = 0; | ||
|
||
MagicTable[fileType]++; | ||
} | ||
} | ||
} |