diff --git a/Yura/Archive/DefianceArchive.cs b/Yura/Archive/DefianceArchive.cs index 3a0006c..ebfcd8d 100644 --- a/Yura/Archive/DefianceArchive.cs +++ b/Yura/Archive/DefianceArchive.cs @@ -6,15 +6,19 @@ namespace Yura.Archive { class DefianceArchive : ArchiveFile { + private const int XboxAlignment = 0xFA00000; + private string _file; + private TextureFormat _platform; private bool _littleEndian; private List _files; - public DefianceArchive(string path, bool littleEndian = true) + public DefianceArchive(string path, TextureFormat platform, bool littleEndian = true) : base(path) { _file = path; + _platform = platform; _littleEndian = littleEndian; _files = new List(); @@ -74,10 +78,24 @@ public override byte[] Read(ArchiveRecord record) { var file = record as DefianceRecord; - var stream = File.OpenRead(_file); + var filename = _file; + var offset = file.Offset; + + if (_platform == TextureFormat.Xbox) + { + // xbox bigfiles in this game are spread over multiple physical files + // calculate the bigfile this file is in + var bigfile = offset / XboxAlignment; + offset = offset % XboxAlignment; + + var name = Path.GetFileNameWithoutExtension(_file); + filename = Path.GetDirectoryName(_file) + Path.DirectorySeparatorChar + name + "." + bigfile.ToString("000"); + } + + var stream = File.OpenRead(filename); var bytes = new byte[file.Size]; - stream.Position = file.Offset; + stream.Position = offset; stream.Read(bytes, 0, (int)file.Size); stream.Close(); diff --git a/Yura/MainWindow.xaml.cs b/Yura/MainWindow.xaml.cs index 33dd1bd..5a63d30 100644 --- a/Yura/MainWindow.xaml.cs +++ b/Yura/MainWindow.xaml.cs @@ -145,7 +145,7 @@ public void OpenBigfile(string bigfile, IFileSettings settings) _bigfile = new DeusExArchive(bigfile, _littleEndian); break; case Game.Defiance: - _bigfile = new DefianceArchive(bigfile, _littleEndian); + _bigfile = new DefianceArchive(bigfile, settings.TextureFormat, _littleEndian); break; case Game.Tiger: _bigfile = new TigerArchive(bigfile, _littleEndian); diff --git a/Yura/OpenDialog.xaml b/Yura/OpenDialog.xaml index 841597d..fdf8f48 100644 --- a/Yura/OpenDialog.xaml +++ b/Yura/OpenDialog.xaml @@ -53,8 +53,10 @@ PC - Wii + PS2 PS3 + Xbox + Wii diff --git a/Yura/OpenDialog.xaml.cs b/Yura/OpenDialog.xaml.cs index cd5ec3d..95c4ca5 100644 --- a/Yura/OpenDialog.xaml.cs +++ b/Yura/OpenDialog.xaml.cs @@ -97,15 +97,17 @@ public class FileListItem private void GameSelect_SelectionChanged(object sender, SelectionChangedEventArgs e) { - AlignmentField.IsEnabled = GameSelect.SelectedIndex < (int)Game.DeusEx; + AlignmentField.IsEnabled = GameSelect.SelectedIndex == (int)Game.Legend; } } public enum TextureFormat { Pc, - Wii, - Ps3 + Ps2, + Ps3, + Xbox, + Wii } public enum Game diff --git a/Yura/TextureViewer.xaml.cs b/Yura/TextureViewer.xaml.cs index 9a4632e..db4011e 100644 --- a/Yura/TextureViewer.xaml.cs +++ b/Yura/TextureViewer.xaml.cs @@ -23,19 +23,21 @@ private void CreateImage(int width, int height, StreamReader reader) var textureData = new byte[width + height * stride]; reader.BaseStream.Read(textureData); - BitmapSource image = null; + BitmapSource image; - if (TextureFormat == TextureFormat.Pc) + switch (TextureFormat) { - image = BitmapSource.Create(width, height, 96, 96, PixelFormats.Bgra32, null, textureData, stride); - } - else if (TextureFormat == TextureFormat.Wii) - { - image = new CMPRTexture(width, height, textureData); - } - else if (TextureFormat == TextureFormat.Ps3) - { - image = new PS3Texture(width, height, textureData); + case TextureFormat.Wii: + image = new CMPRTexture(width, height, textureData); + break; + + case TextureFormat.Ps3: + image = new CMPRTexture(width, height, textureData); + break; + + default: + image = BitmapSource.Create(width, height, 96, 96, PixelFormats.Bgra32, null, textureData, stride); + break; } TextureImage.Source = image; diff --git a/Yura/Yura.csproj b/Yura/Yura.csproj index 80384b6..f1f0e93 100644 --- a/Yura/Yura.csproj +++ b/Yura/Yura.csproj @@ -6,7 +6,7 @@ true true Yura.ico - 1.4 + 1.5