diff --git a/Control/TabTSCB.xaml b/Control/TabTSCB.xaml
index 5a89cff..46dafdd 100644
--- a/Control/TabTSCB.xaml
+++ b/Control/TabTSCB.xaml
@@ -5,14 +5,25 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BOTWToolset.Control"
mc:Ignorable="d"
- d:DesignHeight="597" d:DesignWidth="1246 " Width="Auto" Height="Auto">
+ d:DesignHeight="597" d:DesignWidth="1246 " Width="Auto" Height="Auto" Loaded="UserControlLoaded">
+
+
+
+
+
+
+
+
+
+
diff --git a/Control/TabTSCB.xaml.cs b/Control/TabTSCB.xaml.cs
index 18b9450..877929e 100644
--- a/Control/TabTSCB.xaml.cs
+++ b/Control/TabTSCB.xaml.cs
@@ -20,11 +20,27 @@ namespace BOTWToolset.Control
///
public partial class TabTSCB : UserControl
{
+ ///
+ /// The file location for the currently loaded TSCB file.
+ ///
public static string fileLocation;
+
+ ///
+ /// The currently loaded TSCB, if any.
+ ///
public static TSCB currentTSCB;
- public static WriteableBitmap writeableBitmap; //used for pixel-like display
+ ///
+ /// WriteableBitmap that is used for the map display.
+ ///
+ public static WriteableBitmap writeableBitmap;
+ ///
+ /// Used to modify the map display with new info.
+ ///
+ /// The SARC archive to read for data.
+ /// X and Y integer offsets.
+ ///
private delegate void IteratePixels(SARC sarc, int[] xyoffs, int i);
public TabTSCB()
@@ -37,6 +53,12 @@ namespace BOTWToolset.Control
PixelView.Stretch = Stretch.Uniform;
}
+ private void UserControlLoaded(object sender, RoutedEventArgs e)
+ {
+ this.Focusable = true;
+ this.Focus(); // Update IsEnabled on MenuItem buttons
+ }
+
private void ClearBitmap()
{
PixelView.Source = null;
@@ -285,7 +307,7 @@ namespace BOTWToolset.Control
}
}
- private void Menu_FileOpen(object sender, RoutedEventArgs e)
+ private void Menu_FileOpen(object sender, ExecutedRoutedEventArgs e)
{
BOTWConsole.Log("Clicked File -> Open button");
@@ -320,6 +342,7 @@ namespace BOTWToolset.Control
// Allow the file to be saved
MenuFileClose.IsEnabled = true;
MenuFileSave.IsEnabled = true;
+ MenuFileSaveAs.IsEnabled = true;
// Really laggy, creating 9,000+ controls isn't necessarily a fantastic idea
// Maybe having a filter would help?
@@ -334,6 +357,36 @@ namespace BOTWToolset.Control
}
}
+ private void Menu_FileSave(object sender, ExecutedRoutedEventArgs e)
+ {
+ BOTWConsole.Log("Clicked File -> Save button");
+
+ File.WriteAllBytes(fileLocation, TSCB.ToBytes(currentTSCB));
+
+ BOTWConsole.LogStatus($"Saved file to {fileLocation}.");
+ }
+
+ private void Menu_FileSaveAs(object sender, ExecutedRoutedEventArgs e)
+ {
+ BOTWConsole.Log("Clicked File -> Save As button");
+
+ SaveFileDialog saveFileDialog = new SaveFileDialog
+ {
+ InitialDirectory = @"C;\",
+ RestoreDirectory = true,
+ Title = "Save TSCB file",
+ DefaultExt = "tscb",
+ Filter = "TSCB files (*.tscb)|*.tscb"
+ };
+
+ if ((bool)saveFileDialog.ShowDialog())
+ {
+ File.WriteAllBytes(saveFileDialog.FileName, TSCB.ToBytes(currentTSCB));
+
+ BOTWConsole.LogStatus($"Saved file to {saveFileDialog.FileName}.");
+ }
+ }
+
private void Menu_FileClose(object sender, RoutedEventArgs e)
{
BOTWConsole.Log("Clicked File -> Close button");
@@ -347,26 +400,7 @@ namespace BOTWToolset.Control
// Since there's no file open, don't allow saving
MenuFileClose.IsEnabled = false;
MenuFileSave.IsEnabled = false;
- }
-
- // TODO: split this into "save" and "save as"
- private void Menu_FileSave(object sender, RoutedEventArgs e)
- {
- BOTWConsole.Log("Clicked File -> Save button");
-
- SaveFileDialog saveFileDialog = new SaveFileDialog
- {
- InitialDirectory = @"C;\",
- RestoreDirectory = true,
- Title = "Save TSCB file",
- DefaultExt = "tscb",
- Filter = "TSCB files (*.tscb)|*.tscb"
- };
-
- if ((bool)saveFileDialog.ShowDialog())
- {
- File.WriteAllBytes(saveFileDialog.FileName, TSCB.ToBytes(currentTSCB));
- }
+ MenuFileSaveAs.IsEnabled = false;
}
private void OverrideKeyDown(object sender, KeyEventArgs e)