Skip to content

Commit

Permalink
Preparation for first release.
Browse files Browse the repository at this point in the history
* Bug fixes,
* Script fixes
* Hackishly fixed Folder Browser not locating when opening.
  • Loading branch information
trigger-segfault committed Sep 2, 2017
1 parent ed3e961 commit c4d4e52
Show file tree
Hide file tree
Showing 11 changed files with 215 additions and 371 deletions.
8 changes: 4 additions & 4 deletions TConvert/CommandLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public string OptionsToString() {

/**<summary>The collection of command line options.</summary>*/
private static readonly Dictionary<ArgTypes, OptionInfo> Options = new Dictionary<ArgTypes, OptionInfo>() {
{ ArgTypes.Input, new OptionInfo(ProcessInput, "Input", "Specify input files & folders.", "[filepaths]", "-i", "--input") },
{ ArgTypes.Output, new OptionInfo(ProcessOutput, "Output", "Specify output files & folders.", "[filepaths]", "-o", "--output") },
{ ArgTypes.Input, new OptionInfo(ProcessInput, "Input", "Specify input files & folders.", "filepaths", "-i", "--input") },
{ ArgTypes.Output, new OptionInfo(ProcessOutput, "Output", "Specify output files & folders.", "filepaths", "-o", "--output") },
#if !(CONSOLE)
{ ArgTypes.Console, new OptionInfo(ProcessConsole, "Console", "Don't display a progress window.", null, "-C", "--Console") },
#endif
Expand Down Expand Up @@ -469,8 +469,8 @@ private static void ProcessHelp() {
line += " " + argInfo.Value.PostOptions;
if (line.Length < 22)
line += new string(' ', 22 - line.Length);
else if (line.Length < 30)
line += new string(' ', 30 - line.Length);
else if (line.Length < 27)
line += new string(' ', 27 - line.Length);
line += argInfo.Value.Description;
Log(line);
}
Expand Down
6 changes: 6 additions & 0 deletions TConvert/Convert/PngConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,15 @@ public static bool Convert(string inputFile, string outputFile, bool changeExten
if (changeExtension) {
outputFile = Path.ChangeExtension(outputFile, ".xnb");
}

// Throw more helpful exceptions than what Bitmap.ctor() throws.
if (!Directory.Exists(Path.GetDirectoryName(inputFile))) {
throw new DirectoryNotFoundException("Could not find a part of the path '" + inputFile + "'.");
}
else if (!File.Exists(inputFile)) {
throw new FileNotFoundException("Could not find file '" + inputFile + "'.");
}

using (Bitmap bmp = new Bitmap(inputFile)) {
using (FileStream stream = new FileStream(outputFile, FileMode.OpenOrCreate, FileAccess.Write)) {
using (BinaryWriter writer = new BinaryWriter(stream)) {
Expand Down
2 changes: 1 addition & 1 deletion TConvert/Convert/WavConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static bool Convert(string inputFile, string outputFile, bool changeExten

int dataChunkSize;
byte[] waveData;

using (FileStream stream = new FileStream(inputFile, FileMode.Open)) {
using (BinaryReader reader = new BinaryReader(stream)) {
string format = new string(reader.ReadChars(4));
Expand Down
47 changes: 23 additions & 24 deletions TConvert/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,27 +112,27 @@
<System:String>Folder</System:String>
<System:String>File</System:String>
</ComboBox>

<Button x:Name="buttonExtract" Content="Extract" HorizontalAlignment="Right" Margin="0,12,10,0" VerticalAlignment="Top" Width="75" Click="OnExtract" IsDefault="True"/>
<Button x:Name="buttonExtractUseTerraria" Content="Use Terraria" HorizontalAlignment="Right" Margin="0,12,90,0" VerticalAlignment="Top" Width="100" Click="OnExtractUseTerraria" IsTabStop="False" Focusable="False"/>

<Label x:Name="labelExtractInput" Content="Input Folder" HorizontalAlignment="Left" Margin="10,45,0,0" VerticalAlignment="Top" Padding="0,5,5,5"/>
<TextBox x:Name="textBoxExtractInput" Height="23" Margin="100,47,41,0" VerticalAlignment="Top" IsHitTestVisible="True" IsTabStop="False" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnExtractInputChanged"/>
<TextBox x:Name="textBoxExtractInput" Height="23" Margin="100,47,41,0" VerticalAlignment="Top" IsHitTestVisible="True" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnExtractInputChanged"/>
<Button HorizontalAlignment="Right" Margin="0,47,10,0" VerticalAlignment="Top" Width="22" Height="22" Padding="0" Grid.IsSharedSizeScope="True" ToolTip="Browse" Focusable="False" IsTabStop="False" Click="OnExtractChangeInput">
<Image Height="16" Width="16" Source="Resources/Icons/Browse.png" IsHitTestVisible="False" Style="{StaticResource ButtonImageDisablable}"/>
</Button>
<Label x:Name="labelExtractOutput" Content="Output Folder" HorizontalAlignment="Left" Margin="10,78,0,0" VerticalAlignment="Top" Padding="0,5,5,5"/>
<TextBox x:Name="textBoxExtractOutput" Height="23" Margin="100,80,41,0" VerticalAlignment="Top" IsHitTestVisible="True" IsTabStop="False" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnExtractOutputChanged"/>
<TextBox x:Name="textBoxExtractOutput" Height="23" Margin="100,80,41,0" VerticalAlignment="Top" IsHitTestVisible="True" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnExtractOutputChanged"/>
<Button x:Name="buttonExtractOutput" HorizontalAlignment="Right" Margin="0,80,10,0" VerticalAlignment="Top" Width="22" Height="22" Padding="0" Grid.IsSharedSizeScope="True" ToolTip="Browse" Focusable="False" IsTabStop="False" Click="OnExtractChangeOutput">
<Image Height="16" Width="16" Source="Resources/Icons/Browse.png" IsHitTestVisible="False" Style="{StaticResource ButtonImageDisablable}"/>
</Button>

<CheckBox x:Name="checkBoxExtractImages" Content="Images" HorizontalAlignment="Left" Margin="10,0,0,10" VerticalAlignment="Bottom" Padding="4,-1,0,0" IsChecked="True" Click="OnExtractImagesChecked" IsTabStop="False"/>
<CheckBox x:Name="checkBoxExtractSounds" Content="Sounds" HorizontalAlignment="Left" Margin="75,0,0,10" VerticalAlignment="Bottom" Padding="4,-1,0,0" IsChecked="True" Click="OnExtractSoundsChecked" IsTabStop="False"/>
<CheckBox x:Name="checkBoxExtractFonts" Content="Fonts" HorizontalAlignment="Left" Margin="141,0,0,10" VerticalAlignment="Bottom" Padding="4,-1,0,0" IsChecked="True" Click="OnExtractFontsChecked" IsTabStop="False"/>
<Button x:Name="buttonExtract" Content="Extract" HorizontalAlignment="Right" Margin="0,12,10,0" VerticalAlignment="Top" Width="75" Click="OnExtract" IsDefault="True"/>
<CheckBox x:Name="checkBoxExtractUseInput" Content="Use Input as Output" HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom" Padding="4,-1,0,0" Click="OnExtractUseInputChecked" IsTabStop="False"/>
<Button x:Name="buttonExtractUseTerraria" Content="Use Terraria" HorizontalAlignment="Right" Margin="0,12,90,0" VerticalAlignment="Top" Width="100" Click="OnExtractUseTerraria" IsTabStop="False" Focusable="False"/>
<CheckBox x:Name="checkBoxExtractWaveBank" Content="Wave Bank" HorizontalAlignment="Left" Margin="197,0,0,10" VerticalAlignment="Bottom" Padding="4,-1,0,0" IsChecked="True" Click="OnExtractWaveBankChecked" IsTabStop="False"/>
<CheckBox x:Name="checkBoxExtractWaveBank" Content="Wave Bank" HorizontalAlignment="Left" Margin="197,0,0,10" VerticalAlignment="Bottom" Padding="4,-1,0,0" IsChecked="True" Click="OnExtractWaveBankChecked" IsTabStop="False"/>

</Grid>
<CheckBox x:Name="checkBoxExtractUseInput" Content="Use Input as Output" HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom" Padding="4,-1,0,0" Click="OnExtractUseInputChecked" IsTabStop="False"/>
</Grid>
</TabItem>
<TabItem Header="Convert" IsTabStop="False">
<Grid Background="#FFF9F9F9">
Expand All @@ -141,56 +141,55 @@
<System:String>Folder</System:String>
<System:String>File</System:String>
</ComboBox>
<Button x:Name="buttonConvert" Content="Convert" HorizontalAlignment="Right" Margin="0,12,10,0" VerticalAlignment="Top" Width="75" Click="OnConvert" IsDefault="True"/>
<Button x:Name="buttonConvertUseTerraria" Content="Use Terraria" HorizontalAlignment="Right" Margin="0,12,90,0" VerticalAlignment="Top" Width="100" Click="OnConvertUseTerraria" AllowDrop="True" IsHitTestVisible="True" IsTabStop="False" Focusable="False"/>

<Label x:Name="labelConvertInput" Content="Input Folder" HorizontalAlignment="Left" Margin="10,45,0,0" VerticalAlignment="Top" Padding="0,5,5,5"/>
<TextBox x:Name="textBoxConvertInput" Height="23" Margin="100,47,41,0" VerticalAlignment="Top" IsHitTestVisible="True" IsTabStop="False" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnConvertInputChanged"/>
<TextBox x:Name="textBoxConvertInput" Height="23" Margin="100,47,41,0" VerticalAlignment="Top" IsHitTestVisible="True" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnConvertInputChanged"/>
<Button HorizontalAlignment="Right" Margin="0,47,10,0" VerticalAlignment="Top" Width="22" Height="22" Padding="0" Grid.IsSharedSizeScope="True" ToolTip="Browse" Focusable="False" IsTabStop="False" Click="OnConvertChangeInput">
<Image Height="16" Width="16" Source="Resources/Icons/Browse.png" IsHitTestVisible="False" Style="{StaticResource ButtonImageDisablable}"/>
</Button>
<Label x:Name="labelConvertOutput" Content="Output Folder" HorizontalAlignment="Left" Margin="10,78,0,0" VerticalAlignment="Top" Padding="0,5,5,5"/>
<TextBox x:Name="textBoxConvertOutput" Height="23" Margin="100,80,41,0" VerticalAlignment="Top" IsHitTestVisible="True" IsTabStop="False" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnConvertOutputChanged"/>
<TextBox x:Name="textBoxConvertOutput" Height="23" Margin="100,80,41,0" VerticalAlignment="Top" IsHitTestVisible="True" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnConvertOutputChanged"/>
<Button x:Name="buttonConvertOutput" HorizontalAlignment="Right" Margin="0,80,10,0" VerticalAlignment="Top" Width="22" Height="22" Padding="0" Grid.IsSharedSizeScope="True" ToolTip="Browse" Focusable="False" IsTabStop="False" Click="OnConvertChangeOutput">
<Image Height="16" Width="16" Source="Resources/Icons/Browse.png" IsHitTestVisible="False" Style="{StaticResource ButtonImageDisablable}"/>
</Button>

<Button x:Name="buttonConvert" Content="Convert" HorizontalAlignment="Right" Margin="0,12,10,0" VerticalAlignment="Top" Width="75" Click="OnConvert" IsDefault="True"/>
<CheckBox x:Name="checkBoxConvertUseInput" Content="Use Input as Output" HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom" Padding="4,-1,0,0" Click="OnConvertUseInputChecked" IsTabStop="False" Focusable="False"/>
<Button x:Name="buttonConvertUseTerraria" Content="Use Terraria" HorizontalAlignment="Right" Margin="0,12,90,0" VerticalAlignment="Top" Width="100" Click="OnConvertUseTerraria" AllowDrop="True" IsHitTestVisible="True" IsTabStop="False" Focusable="False"/>
<CheckBox x:Name="checkBoxConvertImages" Content="Images" HorizontalAlignment="Left" Margin="10,0,0,10" VerticalAlignment="Bottom" Padding="4,-1,0,0" IsChecked="True" Click="OnConvertImagesChecked" IsTabStop="False" Focusable="False"/>
<CheckBox x:Name="checkBoxConvertSounds" Content="Sounds" HorizontalAlignment="Left" Margin="75,0,0,10" VerticalAlignment="Bottom" Padding="4,-1,0,0" IsChecked="True" Click="OnConvertSoundsChecked" Focusable="False" IsTabStop="False"/>

<CheckBox x:Name="checkBoxConvertUseInput" Content="Use Input as Output" HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom" Padding="4,-1,0,0" Click="OnConvertUseInputChecked" IsTabStop="False" Focusable="False"/>
</Grid>
</TabItem>
<TabItem Header="Backup" IsTabStop="False">
<Grid Background="#FFF9F9F9">
<Label Content="Backup or Restore" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Padding="0,5,5,5"/>
<Button Content="Restore" HorizontalAlignment="Right" Margin="0,12,90,0" VerticalAlignment="Top" Width="75" Click="OnRestore" IsDefault="True"/>
<Button Content="Backup" HorizontalAlignment="Right" Margin="0,12,10,0" VerticalAlignment="Top" Width="75" Click="OnBackup"/>
<Button Content="Use Terraria" HorizontalAlignment="Right" Margin="0,12,170,0" VerticalAlignment="Top" Width="100" Click="OnBackupUseTerraria" Focusable="False" IsTabStop="False"/>

<Label Content="Content Folder" HorizontalAlignment="Left" Margin="10,45,0,0" VerticalAlignment="Top" Padding="0,5,5,5"/>
<TextBox x:Name="textBoxContent" Height="23" Margin="100,47,41,0" VerticalAlignment="Top" IsHitTestVisible="True" IsTabStop="False" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnContentChanged"/>
<TextBox x:Name="textBoxContent" Height="23" Margin="100,47,41,0" VerticalAlignment="Top" IsHitTestVisible="True" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnContentChanged"/>
<Button HorizontalAlignment="Right" Margin="0,47,10,0" VerticalAlignment="Top" Width="22" Height="22" Padding="0" Grid.IsSharedSizeScope="True" ToolTip="Browse" Focusable="False" IsTabStop="False" Click="OnBackupChangeContent">
<Image Height="16" Width="16" Source="Resources/Icons/Browse.png" IsHitTestVisible="False" Style="{StaticResource ButtonImageDisablable}"/>
</Button>
<Label Content="Backup Folder" HorizontalAlignment="Left" Margin="10,78,0,0" VerticalAlignment="Top" Padding="0,5,5,5"/>
<TextBox x:Name="textBoxBackup" Height="23" Margin="100,80,41,0" VerticalAlignment="Top" IsHitTestVisible="True" IsTabStop="False" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnBackupChanged"/>
<TextBox x:Name="textBoxBackup" Height="23" Margin="100,80,41,0" VerticalAlignment="Top" IsHitTestVisible="True" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnBackupChanged"/>
<Button HorizontalAlignment="Right" Margin="0,80,10,0" VerticalAlignment="Top" Width="22" Height="22" Padding="0" Grid.IsSharedSizeScope="True" ToolTip="Browse" Focusable="False" IsTabStop="False" Click="OnBackupChangeBackup">
<Image Height="16" Width="16" Source="Resources/Icons/Browse.png" IsHitTestVisible="False" Style="{StaticResource ButtonImageDisablable}"/>
</Button>

<Button Content="Backup" HorizontalAlignment="Right" Margin="0,12,10,0" VerticalAlignment="Top" Width="75" Click="OnBackup"/>
<Button Content="Restore" HorizontalAlignment="Right" Margin="0,12,90,0" VerticalAlignment="Top" Width="75" Click="OnRestore" IsDefault="True"/>
<Button Content="Use Terraria" HorizontalAlignment="Right" Margin="0,12,170,0" VerticalAlignment="Top" Width="100" Click="OnBackupUseTerraria" Focusable="False" IsTabStop="False"/>
<Label Content="Backup or Restore" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Padding="0,5,5,5"/>
</Grid>
</TabItem>
<TabItem Header="Script" IsTabStop="False">
<Grid Background="#FFF9F9F9">
<Label Content="Run an Extract, Convert, or Restore Script" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Padding="0,5,5,5"/>

<Button x:Name="buttonScript" Content="Run Script" HorizontalAlignment="Right" Margin="0,12,10,0" VerticalAlignment="Top" Width="75" Click="OnRunScript" IsDefault="True"/>

<Label Content="Script File" HorizontalAlignment="Left" Margin="10,45,0,0" VerticalAlignment="Top" Padding="0,5,5,5"/>
<TextBox x:Name="textBoxScript" Height="23" Margin="100,47,41,0" VerticalAlignment="Top" IsHitTestVisible="True" IsTabStop="False" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnScriptChanged"/>
<TextBox x:Name="textBoxScript" Height="23" Margin="100,47,41,0" VerticalAlignment="Top" IsHitTestVisible="True" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnScriptChanged"/>
<Button HorizontalAlignment="Right" Margin="0,47,10,0" VerticalAlignment="Top" Width="22" Height="22" Padding="0" Grid.IsSharedSizeScope="True" ToolTip="Browse" Focusable="False" IsTabStop="False" Click="OnChangeScript">
<Image Height="16" Width="16" Source="Resources/Icons/Browse.png" IsHitTestVisible="False" Style="{StaticResource ButtonImageDisablable}"/>
</Button>

<Button x:Name="buttonScript" Content="Run Script" HorizontalAlignment="Right" Margin="0,12,10,0" VerticalAlignment="Top" Width="75" Click="OnRunScript" IsDefault="True"/>
</Grid>
</TabItem>
</TabControl>
Expand Down
13 changes: 13 additions & 0 deletions TConvert/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ private void OnExtract(object sender, RoutedEventArgs e) {
TriggerMessageBox.Show(this, MessageIcon.Warning, "Output folder path is invalid.", "Invalid Path");
return;
}
input = Helpers.FixPathSafe(input);
output = Helpers.FixPathSafe(output);
thread = new Thread(() => {
Processing.ExtractAll(input, output, allowImages, allowSounds, allowFonts, allowWaveBank);
});
Expand All @@ -214,6 +216,8 @@ private void OnExtract(object sender, RoutedEventArgs e) {
TriggerMessageBox.Show(this, MessageIcon.Warning, "Output file path is invalid.", "Invalid Path");
return;
}
input = Helpers.FixPathSafe(input);
output = Helpers.FixPathSafe(output);
thread = new Thread(() => {
Processing.ExtractSingleFile(input, output);
});
Expand Down Expand Up @@ -319,6 +323,8 @@ private void OnConvert(object sender, RoutedEventArgs e) {
TriggerMessageBox.Show(this, MessageIcon.Warning, "Output folder path is invalid.", "Invalid Path");
return;
}
input = Helpers.FixPathSafe(input);
output = Helpers.FixPathSafe(output);
thread = new Thread(() => {
Processing.ConvertAll(input, output, allowImages, allowSounds);
});
Expand All @@ -332,6 +338,8 @@ private void OnConvert(object sender, RoutedEventArgs e) {
TriggerMessageBox.Show(this, MessageIcon.Warning, "Output file path is invalid.", "Invalid Path");
return;
}
input = Helpers.FixPathSafe(input);
output = Helpers.FixPathSafe(output);
thread = new Thread(() => {
Processing.ConvertSingleFile(input, output);
});
Expand Down Expand Up @@ -428,6 +436,8 @@ private void OnBackup(object sender, RoutedEventArgs e) {
return;
}

input = Helpers.FixPathSafe(input);
output = Helpers.FixPathSafe(output);
Thread thread = new Thread(() => {
Processing.BackupFiles(input, output);
});
Expand All @@ -450,6 +460,8 @@ private void OnRestore(object sender, RoutedEventArgs e) {
return;
}

input = Helpers.FixPathSafe(input);
output = Helpers.FixPathSafe(output);
Thread thread = new Thread(() => {
Processing.RestoreFiles(input, output);
});
Expand Down Expand Up @@ -510,6 +522,7 @@ private void OnRunScript(object sender, RoutedEventArgs e) {
TriggerMessageBox.Show(this, MessageIcon.Warning, "Could not find the script file.", "Invalid Path");
return;
}
input = Helpers.FixPathSafe(input);
thread = new Thread(() => {
Processing.RunScript(input);
});
Expand Down
Loading

0 comments on commit c4d4e52

Please sign in to comment.