Skip to content

Commit c4d4e52

Browse files
Preparation for first release.
* Bug fixes, * Script fixes * Hackishly fixed Folder Browser not locating when opening.
1 parent ed3e961 commit c4d4e52

11 files changed

+215
-371
lines changed

TConvert/CommandLine.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ public string OptionsToString() {
7171

7272
/**<summary>The collection of command line options.</summary>*/
7373
private static readonly Dictionary<ArgTypes, OptionInfo> Options = new Dictionary<ArgTypes, OptionInfo>() {
74-
{ ArgTypes.Input, new OptionInfo(ProcessInput, "Input", "Specify input files & folders.", "[filepaths]", "-i", "--input") },
75-
{ ArgTypes.Output, new OptionInfo(ProcessOutput, "Output", "Specify output files & folders.", "[filepaths]", "-o", "--output") },
74+
{ ArgTypes.Input, new OptionInfo(ProcessInput, "Input", "Specify input files & folders.", "filepaths", "-i", "--input") },
75+
{ ArgTypes.Output, new OptionInfo(ProcessOutput, "Output", "Specify output files & folders.", "filepaths", "-o", "--output") },
7676
#if !(CONSOLE)
7777
{ ArgTypes.Console, new OptionInfo(ProcessConsole, "Console", "Don't display a progress window.", null, "-C", "--Console") },
7878
#endif
@@ -469,8 +469,8 @@ private static void ProcessHelp() {
469469
line += " " + argInfo.Value.PostOptions;
470470
if (line.Length < 22)
471471
line += new string(' ', 22 - line.Length);
472-
else if (line.Length < 30)
473-
line += new string(' ', 30 - line.Length);
472+
else if (line.Length < 27)
473+
line += new string(' ', 27 - line.Length);
474474
line += argInfo.Value.Description;
475475
Log(line);
476476
}

TConvert/Convert/PngConverter.cs

+6
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,15 @@ public static bool Convert(string inputFile, string outputFile, bool changeExten
9999
if (changeExtension) {
100100
outputFile = Path.ChangeExtension(outputFile, ".xnb");
101101
}
102+
103+
// Throw more helpful exceptions than what Bitmap.ctor() throws.
102104
if (!Directory.Exists(Path.GetDirectoryName(inputFile))) {
103105
throw new DirectoryNotFoundException("Could not find a part of the path '" + inputFile + "'.");
104106
}
107+
else if (!File.Exists(inputFile)) {
108+
throw new FileNotFoundException("Could not find file '" + inputFile + "'.");
109+
}
110+
105111
using (Bitmap bmp = new Bitmap(inputFile)) {
106112
using (FileStream stream = new FileStream(outputFile, FileMode.OpenOrCreate, FileAccess.Write)) {
107113
using (BinaryWriter writer = new BinaryWriter(stream)) {

TConvert/Convert/WavConverter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static bool Convert(string inputFile, string outputFile, bool changeExten
2222

2323
int dataChunkSize;
2424
byte[] waveData;
25-
25+
2626
using (FileStream stream = new FileStream(inputFile, FileMode.Open)) {
2727
using (BinaryReader reader = new BinaryReader(stream)) {
2828
string format = new string(reader.ReadChars(4));

TConvert/MainWindow.xaml

+23-24
Original file line numberDiff line numberDiff line change
@@ -112,27 +112,27 @@
112112
<System:String>Folder</System:String>
113113
<System:String>File</System:String>
114114
</ComboBox>
115-
115+
<Button x:Name="buttonExtract" Content="Extract" HorizontalAlignment="Right" Margin="0,12,10,0" VerticalAlignment="Top" Width="75" Click="OnExtract" IsDefault="True"/>
116+
<Button x:Name="buttonExtractUseTerraria" Content="Use Terraria" HorizontalAlignment="Right" Margin="0,12,90,0" VerticalAlignment="Top" Width="100" Click="OnExtractUseTerraria" IsTabStop="False" Focusable="False"/>
117+
116118
<Label x:Name="labelExtractInput" Content="Input Folder" HorizontalAlignment="Left" Margin="10,45,0,0" VerticalAlignment="Top" Padding="0,5,5,5"/>
117-
<TextBox x:Name="textBoxExtractInput" Height="23" Margin="100,47,41,0" VerticalAlignment="Top" IsHitTestVisible="True" IsTabStop="False" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnExtractInputChanged"/>
119+
<TextBox x:Name="textBoxExtractInput" Height="23" Margin="100,47,41,0" VerticalAlignment="Top" IsHitTestVisible="True" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnExtractInputChanged"/>
118120
<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">
119121
<Image Height="16" Width="16" Source="Resources/Icons/Browse.png" IsHitTestVisible="False" Style="{StaticResource ButtonImageDisablable}"/>
120122
</Button>
121123
<Label x:Name="labelExtractOutput" Content="Output Folder" HorizontalAlignment="Left" Margin="10,78,0,0" VerticalAlignment="Top" Padding="0,5,5,5"/>
122-
<TextBox x:Name="textBoxExtractOutput" Height="23" Margin="100,80,41,0" VerticalAlignment="Top" IsHitTestVisible="True" IsTabStop="False" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnExtractOutputChanged"/>
124+
<TextBox x:Name="textBoxExtractOutput" Height="23" Margin="100,80,41,0" VerticalAlignment="Top" IsHitTestVisible="True" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnExtractOutputChanged"/>
123125
<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">
124126
<Image Height="16" Width="16" Source="Resources/Icons/Browse.png" IsHitTestVisible="False" Style="{StaticResource ButtonImageDisablable}"/>
125127
</Button>
126128

127129
<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"/>
128130
<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"/>
129131
<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"/>
130-
<Button x:Name="buttonExtract" Content="Extract" HorizontalAlignment="Right" Margin="0,12,10,0" VerticalAlignment="Top" Width="75" Click="OnExtract" IsDefault="True"/>
131-
<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"/>
132-
<Button x:Name="buttonExtractUseTerraria" Content="Use Terraria" HorizontalAlignment="Right" Margin="0,12,90,0" VerticalAlignment="Top" Width="100" Click="OnExtractUseTerraria" IsTabStop="False" Focusable="False"/>
133-
<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"/>
132+
<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"/>
134133

135-
</Grid>
134+
<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"/>
135+
</Grid>
136136
</TabItem>
137137
<TabItem Header="Convert" IsTabStop="False">
138138
<Grid Background="#FFF9F9F9">
@@ -141,56 +141,55 @@
141141
<System:String>Folder</System:String>
142142
<System:String>File</System:String>
143143
</ComboBox>
144+
<Button x:Name="buttonConvert" Content="Convert" HorizontalAlignment="Right" Margin="0,12,10,0" VerticalAlignment="Top" Width="75" Click="OnConvert" IsDefault="True"/>
145+
<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"/>
144146

145147
<Label x:Name="labelConvertInput" Content="Input Folder" HorizontalAlignment="Left" Margin="10,45,0,0" VerticalAlignment="Top" Padding="0,5,5,5"/>
146-
<TextBox x:Name="textBoxConvertInput" Height="23" Margin="100,47,41,0" VerticalAlignment="Top" IsHitTestVisible="True" IsTabStop="False" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnConvertInputChanged"/>
148+
<TextBox x:Name="textBoxConvertInput" Height="23" Margin="100,47,41,0" VerticalAlignment="Top" IsHitTestVisible="True" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnConvertInputChanged"/>
147149
<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">
148150
<Image Height="16" Width="16" Source="Resources/Icons/Browse.png" IsHitTestVisible="False" Style="{StaticResource ButtonImageDisablable}"/>
149151
</Button>
150152
<Label x:Name="labelConvertOutput" Content="Output Folder" HorizontalAlignment="Left" Margin="10,78,0,0" VerticalAlignment="Top" Padding="0,5,5,5"/>
151-
<TextBox x:Name="textBoxConvertOutput" Height="23" Margin="100,80,41,0" VerticalAlignment="Top" IsHitTestVisible="True" IsTabStop="False" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnConvertOutputChanged"/>
153+
<TextBox x:Name="textBoxConvertOutput" Height="23" Margin="100,80,41,0" VerticalAlignment="Top" IsHitTestVisible="True" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnConvertOutputChanged"/>
152154
<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">
153155
<Image Height="16" Width="16" Source="Resources/Icons/Browse.png" IsHitTestVisible="False" Style="{StaticResource ButtonImageDisablable}"/>
154156
</Button>
155157

156-
<Button x:Name="buttonConvert" Content="Convert" HorizontalAlignment="Right" Margin="0,12,10,0" VerticalAlignment="Top" Width="75" Click="OnConvert" IsDefault="True"/>
157-
<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"/>
158-
<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"/>
159158
<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"/>
160159
<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"/>
160+
161+
<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"/>
161162
</Grid>
162163
</TabItem>
163164
<TabItem Header="Backup" IsTabStop="False">
164165
<Grid Background="#FFF9F9F9">
166+
<Label Content="Backup or Restore" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Padding="0,5,5,5"/>
167+
<Button Content="Restore" HorizontalAlignment="Right" Margin="0,12,90,0" VerticalAlignment="Top" Width="75" Click="OnRestore" IsDefault="True"/>
168+
<Button Content="Backup" HorizontalAlignment="Right" Margin="0,12,10,0" VerticalAlignment="Top" Width="75" Click="OnBackup"/>
169+
<Button Content="Use Terraria" HorizontalAlignment="Right" Margin="0,12,170,0" VerticalAlignment="Top" Width="100" Click="OnBackupUseTerraria" Focusable="False" IsTabStop="False"/>
165170

166171
<Label Content="Content Folder" HorizontalAlignment="Left" Margin="10,45,0,0" VerticalAlignment="Top" Padding="0,5,5,5"/>
167-
<TextBox x:Name="textBoxContent" Height="23" Margin="100,47,41,0" VerticalAlignment="Top" IsHitTestVisible="True" IsTabStop="False" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnContentChanged"/>
172+
<TextBox x:Name="textBoxContent" Height="23" Margin="100,47,41,0" VerticalAlignment="Top" IsHitTestVisible="True" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnContentChanged"/>
168173
<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">
169174
<Image Height="16" Width="16" Source="Resources/Icons/Browse.png" IsHitTestVisible="False" Style="{StaticResource ButtonImageDisablable}"/>
170175
</Button>
171176
<Label Content="Backup Folder" HorizontalAlignment="Left" Margin="10,78,0,0" VerticalAlignment="Top" Padding="0,5,5,5"/>
172-
<TextBox x:Name="textBoxBackup" Height="23" Margin="100,80,41,0" VerticalAlignment="Top" IsHitTestVisible="True" IsTabStop="False" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnBackupChanged"/>
177+
<TextBox x:Name="textBoxBackup" Height="23" Margin="100,80,41,0" VerticalAlignment="Top" IsHitTestVisible="True" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnBackupChanged"/>
173178
<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">
174179
<Image Height="16" Width="16" Source="Resources/Icons/Browse.png" IsHitTestVisible="False" Style="{StaticResource ButtonImageDisablable}"/>
175180
</Button>
176-
177-
<Button Content="Backup" HorizontalAlignment="Right" Margin="0,12,10,0" VerticalAlignment="Top" Width="75" Click="OnBackup"/>
178-
<Button Content="Restore" HorizontalAlignment="Right" Margin="0,12,90,0" VerticalAlignment="Top" Width="75" Click="OnRestore" IsDefault="True"/>
179-
<Button Content="Use Terraria" HorizontalAlignment="Right" Margin="0,12,170,0" VerticalAlignment="Top" Width="100" Click="OnBackupUseTerraria" Focusable="False" IsTabStop="False"/>
180-
<Label Content="Backup or Restore" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Padding="0,5,5,5"/>
181181
</Grid>
182182
</TabItem>
183183
<TabItem Header="Script" IsTabStop="False">
184184
<Grid Background="#FFF9F9F9">
185185
<Label Content="Run an Extract, Convert, or Restore Script" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Padding="0,5,5,5"/>
186-
186+
<Button x:Name="buttonScript" Content="Run Script" HorizontalAlignment="Right" Margin="0,12,10,0" VerticalAlignment="Top" Width="75" Click="OnRunScript" IsDefault="True"/>
187+
187188
<Label Content="Script File" HorizontalAlignment="Left" Margin="10,45,0,0" VerticalAlignment="Top" Padding="0,5,5,5"/>
188-
<TextBox x:Name="textBoxScript" Height="23" Margin="100,47,41,0" VerticalAlignment="Top" IsHitTestVisible="True" IsTabStop="False" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnScriptChanged"/>
189+
<TextBox x:Name="textBoxScript" Height="23" Margin="100,47,41,0" VerticalAlignment="Top" IsHitTestVisible="True" AllowDrop="True" ScrollViewer.CanContentScroll="True" TextChanged="OnScriptChanged"/>
189190
<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">
190191
<Image Height="16" Width="16" Source="Resources/Icons/Browse.png" IsHitTestVisible="False" Style="{StaticResource ButtonImageDisablable}"/>
191192
</Button>
192-
193-
<Button x:Name="buttonScript" Content="Run Script" HorizontalAlignment="Right" Margin="0,12,10,0" VerticalAlignment="Top" Width="75" Click="OnRunScript" IsDefault="True"/>
194193
</Grid>
195194
</TabItem>
196195
</TabControl>

TConvert/MainWindow.xaml.cs

+13
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ private void OnExtract(object sender, RoutedEventArgs e) {
201201
TriggerMessageBox.Show(this, MessageIcon.Warning, "Output folder path is invalid.", "Invalid Path");
202202
return;
203203
}
204+
input = Helpers.FixPathSafe(input);
205+
output = Helpers.FixPathSafe(output);
204206
thread = new Thread(() => {
205207
Processing.ExtractAll(input, output, allowImages, allowSounds, allowFonts, allowWaveBank);
206208
});
@@ -214,6 +216,8 @@ private void OnExtract(object sender, RoutedEventArgs e) {
214216
TriggerMessageBox.Show(this, MessageIcon.Warning, "Output file path is invalid.", "Invalid Path");
215217
return;
216218
}
219+
input = Helpers.FixPathSafe(input);
220+
output = Helpers.FixPathSafe(output);
217221
thread = new Thread(() => {
218222
Processing.ExtractSingleFile(input, output);
219223
});
@@ -319,6 +323,8 @@ private void OnConvert(object sender, RoutedEventArgs e) {
319323
TriggerMessageBox.Show(this, MessageIcon.Warning, "Output folder path is invalid.", "Invalid Path");
320324
return;
321325
}
326+
input = Helpers.FixPathSafe(input);
327+
output = Helpers.FixPathSafe(output);
322328
thread = new Thread(() => {
323329
Processing.ConvertAll(input, output, allowImages, allowSounds);
324330
});
@@ -332,6 +338,8 @@ private void OnConvert(object sender, RoutedEventArgs e) {
332338
TriggerMessageBox.Show(this, MessageIcon.Warning, "Output file path is invalid.", "Invalid Path");
333339
return;
334340
}
341+
input = Helpers.FixPathSafe(input);
342+
output = Helpers.FixPathSafe(output);
335343
thread = new Thread(() => {
336344
Processing.ConvertSingleFile(input, output);
337345
});
@@ -428,6 +436,8 @@ private void OnBackup(object sender, RoutedEventArgs e) {
428436
return;
429437
}
430438

439+
input = Helpers.FixPathSafe(input);
440+
output = Helpers.FixPathSafe(output);
431441
Thread thread = new Thread(() => {
432442
Processing.BackupFiles(input, output);
433443
});
@@ -450,6 +460,8 @@ private void OnRestore(object sender, RoutedEventArgs e) {
450460
return;
451461
}
452462

463+
input = Helpers.FixPathSafe(input);
464+
output = Helpers.FixPathSafe(output);
453465
Thread thread = new Thread(() => {
454466
Processing.RestoreFiles(input, output);
455467
});
@@ -510,6 +522,7 @@ private void OnRunScript(object sender, RoutedEventArgs e) {
510522
TriggerMessageBox.Show(this, MessageIcon.Warning, "Could not find the script file.", "Invalid Path");
511523
return;
512524
}
525+
input = Helpers.FixPathSafe(input);
513526
thread = new Thread(() => {
514527
Processing.RunScript(input);
515528
});

0 commit comments

Comments
 (0)