From 1d8fdcbd1e875d482c2e07c5f6f4aa7126160057 Mon Sep 17 00:00:00 2001 From: Chev <11602755+chev2@users.noreply.github.com> Date: Sat, 16 Jan 2021 22:39:23 -0800 Subject: [PATCH] TSCB SARC change, logging --- botw-toolset/Control/TabTSCB.xaml.cs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/botw-toolset/Control/TabTSCB.xaml.cs b/botw-toolset/Control/TabTSCB.xaml.cs index bf06382..9ce25fd 100644 --- a/botw-toolset/Control/TabTSCB.xaml.cs +++ b/botw-toolset/Control/TabTSCB.xaml.cs @@ -41,10 +41,10 @@ namespace BOTWToolset.Control { PixelView.Source = null; writeableBitmap = null; + GC.Collect(); // Garbage collect to free memory } - private void PixelView_UpdateView(object sender, RoutedEventArgs e) { byte zoom = (byte)SliderZoomLevel.Value; @@ -61,12 +61,12 @@ namespace BOTWToolset.Control { case "PixelViewMATE": { - BOTWConsole.Log("Setting view to texture..."); - string extension = ".mate.sstera"; int img_size = (int)Math.Pow(2, 8 + zoom); int grid_size = 256; + BOTWConsole.LogStatus($"Setting TSCB view to texture ({img_size / grid_size}x{img_size / grid_size})..."); + ClearBitmap(); writeableBitmap = new WriteableBitmap(img_size, img_size, 16, 16, PixelFormats.Indexed8, GridColors.MaterialPalette); PixelView.Source = writeableBitmap; @@ -90,16 +90,18 @@ namespace BOTWToolset.Control writeableBitmap.WritePixels(rect, color, writeableBitmap.BackBufferStride, 0); } }); + + BOTWConsole.LogStatus($"TSCB view set to texture ({img_size / grid_size}x{img_size / grid_size})."); } break; case "PixelViewHGHT": { - BOTWConsole.Log("Setting view to heightmap..."); - string extension = ".hght.sstera"; int img_size = (int)Math.Pow(2, 8 + zoom); int grid_size = 256; + BOTWConsole.LogStatus($"Setting TSCB view to heightmap ({img_size / grid_size}x{img_size / grid_size})..."); + ClearBitmap(); writeableBitmap = new WriteableBitmap(img_size, img_size, 16, 16, PixelFormats.Gray8, null); PixelView.Source = writeableBitmap; @@ -125,16 +127,18 @@ namespace BOTWToolset.Control writeableBitmap.WritePixels(rect, color, writeableBitmap.BackBufferStride, 0); } }); + + BOTWConsole.LogStatus($"TSCB view set to heightmap ({img_size / grid_size}x{img_size / grid_size})."); } break; case "PixelViewGrassEXTM": { - BOTWConsole.Log("Setting view to grass..."); - string extension = ".grass.extm.sstera"; int img_size = (int)Math.Pow(2, 6 + zoom); int grid_size = 64; + BOTWConsole.LogStatus($"Setting TSCB view to grass ({img_size / grid_size}x{img_size / grid_size})..."); + ClearBitmap(); writeableBitmap = new WriteableBitmap(img_size, img_size, 16, 16, PixelFormats.Rgb24, null); PixelView.Source = writeableBitmap; @@ -160,16 +164,18 @@ namespace BOTWToolset.Control writeableBitmap.WritePixels(rect, color, writeableBitmap.BackBufferStride, 0); } }); + + BOTWConsole.LogStatus($"TSCB view set to grass ({img_size / grid_size}x{img_size / grid_size})."); } break; case "PixelViewWaterEXTM": { - BOTWConsole.Log("Setting view to water..."); - string extension = ".water.extm.sstera"; int img_size = (int)Math.Pow(2, 6 + zoom); int grid_size = 64; + BOTWConsole.LogStatus($"Setting TSCB view to water ({img_size / grid_size}x{img_size / grid_size})..."); + ClearBitmap(); writeableBitmap = new WriteableBitmap(img_size, img_size, 16, 16, PixelFormats.Indexed8, GridColors.WaterPalette); PixelView.Source = writeableBitmap; @@ -193,6 +199,8 @@ namespace BOTWToolset.Control writeableBitmap.WritePixels(rect, color, writeableBitmap.BackBufferStride, 0); } }); + + BOTWConsole.LogStatus($"TSCB view set to water ({img_size / grid_size}x{img_size / grid_size})."); } break; } @@ -207,7 +215,7 @@ namespace BOTWToolset.Control { byte[] yaz0_bytes = File.ReadAllBytes(Path.Combine(folder, ext_file)); byte[] yaz0_decomp = Yaz0.Decompress(yaz0_bytes); - SARC s = SARC.FromBytes(new MemoryStream(yaz0_decomp)); + SARC s = SARC.FromBytes(yaz0_decomp); for (int i = 0; i < s.Files.Length; i++) {