From e8332067d19485de7df4785434aa5ff6ac15be02 Mon Sep 17 00:00:00 2001 From: Chev <11602755+chev2@users.noreply.github.com> Date: Sun, 10 Jan 2021 20:06:26 -0800 Subject: [PATCH] UI new tabs Updated TSCB to have a pixel view. Added SARC, Yaz0 & RSTB tabs. --- botw-toolset/Control/TSCBAreaExpander.xaml | 14 + botw-toolset/Control/TSCBAreaExpander.xaml.cs | 15 + botw-toolset/Control/TabRSTB.xaml | 12 + botw-toolset/Control/TabRSTB.xaml.cs | 15 + botw-toolset/Control/TabSARC.xaml | 67 +++ botw-toolset/Control/TabSARC.xaml.cs | 168 +++++++ botw-toolset/Control/TabTSCB.xaml | 40 +- botw-toolset/Control/TabTSCB.xaml.cs | 411 +++++++++++++++++- botw-toolset/Control/TabYaz0.xaml | 27 ++ botw-toolset/Control/TabYaz0.xaml.cs | 167 +++++++ botw-toolset/Dashboard.xaml | 30 +- botw-toolset/Dashboard.xaml.cs | 10 + 12 files changed, 942 insertions(+), 34 deletions(-) create mode 100644 botw-toolset/Control/TSCBAreaExpander.xaml create mode 100644 botw-toolset/Control/TSCBAreaExpander.xaml.cs create mode 100644 botw-toolset/Control/TabRSTB.xaml create mode 100644 botw-toolset/Control/TabRSTB.xaml.cs create mode 100644 botw-toolset/Control/TabSARC.xaml create mode 100644 botw-toolset/Control/TabSARC.xaml.cs create mode 100644 botw-toolset/Control/TabYaz0.xaml create mode 100644 botw-toolset/Control/TabYaz0.xaml.cs diff --git a/botw-toolset/Control/TSCBAreaExpander.xaml b/botw-toolset/Control/TSCBAreaExpander.xaml new file mode 100644 index 0000000..8fa3fd2 --- /dev/null +++ b/botw-toolset/Control/TSCBAreaExpander.xaml @@ -0,0 +1,14 @@ + + + + + + + diff --git a/botw-toolset/Control/TSCBAreaExpander.xaml.cs b/botw-toolset/Control/TSCBAreaExpander.xaml.cs new file mode 100644 index 0000000..52ff792 --- /dev/null +++ b/botw-toolset/Control/TSCBAreaExpander.xaml.cs @@ -0,0 +1,15 @@ +using System.Windows.Controls; + +namespace BOTWToolset.Control +{ + /// + /// Interaction logic for TSCBAreaExpander.xaml + /// + public partial class TSCBAreaExpander : UserControl + { + public TSCBAreaExpander() + { + InitializeComponent(); + } + } +} diff --git a/botw-toolset/Control/TabRSTB.xaml b/botw-toolset/Control/TabRSTB.xaml new file mode 100644 index 0000000..42c3dd3 --- /dev/null +++ b/botw-toolset/Control/TabRSTB.xaml @@ -0,0 +1,12 @@ + + + + diff --git a/botw-toolset/Control/TabRSTB.xaml.cs b/botw-toolset/Control/TabRSTB.xaml.cs new file mode 100644 index 0000000..093fdec --- /dev/null +++ b/botw-toolset/Control/TabRSTB.xaml.cs @@ -0,0 +1,15 @@ +using System.Windows.Controls; + +namespace BOTWToolset.Control +{ + /// + /// Interaction logic for TabRSTB.xaml + /// + public partial class TabRSTB : UserControl + { + public TabRSTB() + { + InitializeComponent(); + } + } +} diff --git a/botw-toolset/Control/TabSARC.xaml b/botw-toolset/Control/TabSARC.xaml new file mode 100644 index 0000000..f77c4f4 --- /dev/null +++ b/botw-toolset/Control/TabSARC.xaml @@ -0,0 +1,67 @@ + + + + diff --git a/botw-toolset/Control/TabSARC.xaml.cs b/botw-toolset/Control/TabSARC.xaml.cs new file mode 100644 index 0000000..203b756 --- /dev/null +++ b/botw-toolset/Control/TabSARC.xaml.cs @@ -0,0 +1,168 @@ +using BOTWToolset.Debugging; +using BOTWToolset.IO.SARC; +using Microsoft.Win32; +using System.Windows; +using System.Windows.Controls; + +namespace BOTWToolset.Control +{ + /// + /// Interaction logic for TabSARC.xaml + /// + public partial class TabSARC : UserControl + { + public static string fileLocation; + public static SARC currentSARC; + + public TabSARC() + { + InitializeComponent(); + } + + public void SetEnabled(SARC s) + { + // SARC header + SARCMagic.Text = s.Magic; + SARCHeaderLength.Text = s.HeaderLength.ToString(); + SARCIsBigEndian.Text = s.IsBigEndian ? "Yes" : "No"; + SARCFileSize.Text = s.FileSize.ToString(); + SARCDataOffset.Text = s.DataOffset.ToString(); + SARCVersion.Text = s.Version.ToString(); + + // SFAT header + SFATMagic.Text = s.SFAT.Magic; + SFATHeaderLength.Text = s.SFAT.HeaderLength.ToString(); + SFATNodeCount.Text = s.SFAT.NodeCount.ToString(); + SFATHashKey.Text = s.SFAT.HashKey.ToString(); + + // SFNT header + SFNTMagic.Text = s.SFNT.Magic; + SFNTHeaderLength.Text = s.SFNT.HeaderLength.ToString(); + + // Show file count + FileCount.Content = $"SARC file count: {s.SFAT.NodeCount}"; + + for (int i = 0; i < s.SFNT.FileNames.Length; i++) + { + string file_name = s.SFNT.FileNames[i]; + int file_size = s.Files[i].Length; + + Grid grid = new Grid + { + Height = 112 + }; + + Label title = new Label + { + Height = 44, + Content = file_name, + FontSize = 20, + Margin = new Thickness(10, 10, 10, 0), + VerticalAlignment = VerticalAlignment.Top, + VerticalContentAlignment = VerticalAlignment.Center + }; + + Label desc = new Label + { + Content = $"{file_size:n0} bytes", + Margin = new Thickness(10, 59, 10, 10), + FontSize = 16, + VerticalContentAlignment = VerticalAlignment.Center + }; + + grid.Children.Add(title); + grid.Children.Add(desc); + + FileDisplay.Children.Add(grid); + } + } + + public void SetDisabled() + { + // SARC header + SARCMagic.Clear(); + SARCHeaderLength.Clear(); + SARCIsBigEndian.Clear(); + SARCFileSize.Clear(); + SARCDataOffset.Clear(); + SARCVersion.Clear(); + + // SFAT header + SFATMagic.Clear(); + SFATHeaderLength.Clear(); + SFATNodeCount.Clear(); + SFATHashKey.Clear(); + + // SFNT header + SFNTMagic.Clear(); + SFNTHeaderLength.Clear(); + + // SARC Files + FileCount.Content = ""; + FileDisplay.Children.Clear(); + } + + private void Menu_FileOpen(object sender, RoutedEventArgs e) + { + BOTWConsole.Log("Clicked File -> Open button"); + + var openFileDialog = new OpenFileDialog + { + InitialDirectory = @"C:\", + RestoreDirectory = true, + Title = "Select SARC file", + DefaultExt = "sarc", + Filter = "SARC files (*.arc;*.sarc;*.blarc;*.bgenv;*.genvb;*.pack;*.bars;*.stera)|*.arc;*.sarc;*.blarc;*.bgenv;*.genvb;*.pack;*.bars;*.stera|All files (*.*)|*.*", + CheckFileExists = true + }; + + if ((bool)openFileDialog.ShowDialog()) + { + BOTWConsole.Log("Opening file"); + + SARC s = SARC.ReadFile(openFileDialog.FileName); + + // Set the current file location to the chosen file's location + fileLocation = openFileDialog.FileName; + + currentSARC = s; + + // Display info in the tab + SetEnabled(s); + + // Enable file edits + MenuFileClose.IsEnabled = true; + MenuFileSave.IsEnabled = true; + MenuFileSaveAs.IsEnabled = true; + } + } + + private void Menu_FileClose(object sender, RoutedEventArgs e) + { + BOTWConsole.Log("Clicked File -> Close button"); + + fileLocation = null; + + // Set the current TSCB info to nothing + currentSARC = null; + + // Set the tab as disabled + SetDisabled(); + + // Disable file edits + MenuFileClose.IsEnabled = false; + MenuFileSave.IsEnabled = false; + MenuFileSaveAs.IsEnabled = false; + } + + private void Menu_FileSave(object sender, RoutedEventArgs e) + { + + } + + private void Menu_FileSaveAs(object sender, RoutedEventArgs e) + { + + } + } +} diff --git a/botw-toolset/Control/TabTSCB.xaml b/botw-toolset/Control/TabTSCB.xaml index e19b97a..8f84b81 100644 --- a/botw-toolset/Control/TabTSCB.xaml +++ b/botw-toolset/Control/TabTSCB.xaml @@ -1,9 +1,9 @@ - @@ -11,12 +11,16 @@ - - - + + + - + + + + + + + +