Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
* Fonts checkbox disables correctly.
* No more path errors.
  • Loading branch information
trigger-segfault committed Sep 3, 2017
1 parent 6fa8f87 commit baca621
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 14 deletions.
2 changes: 1 addition & 1 deletion TConvert/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public static class Script {
/**<summary>Loads the settings.</summary>*/
public static void Load() {
TerrariaContentDirectory = Settings.Default.TerrariaContentDirectory;
if (TerrariaContentDirectory == "") {
if (TerrariaContentDirectory == "" && (TerrariaLocator.TerrariaContentDirectory != null && TerrariaLocator.TerrariaContentDirectory != "")) {
TerrariaContentDirectory = TerrariaLocator.TerrariaContentDirectory;
}
Tabs tab;
Expand Down
41 changes: 32 additions & 9 deletions TConvert/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private void LoadConfig() {
buttonExtractUseTerraria.IsEnabled = !Config.Extract.UseInput && Config.Extract.Mode == InputModes.Folder;
checkBoxExtractImages.IsEnabled = Config.Extract.Mode == InputModes.Folder;
checkBoxExtractSounds.IsEnabled = Config.Extract.Mode == InputModes.Folder;
checkBoxExtractFonts.IsEnabled = Config.Extract.Mode == InputModes.Folder;
checkBoxExtractWaveBank.IsEnabled = Config.Extract.Mode == InputModes.Folder;
switch (Config.Extract.Mode) {
case InputModes.Folder:
Expand Down Expand Up @@ -163,7 +164,7 @@ private void OnBrowseTerraria(object sender, RoutedEventArgs e) {
System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
dialog.ShowNewFolderButton = false;
dialog.Description = "Choose Terraria Content folder";
dialog.SelectedPath = Path.GetFullPath(Config.TerrariaContentDirectory);
dialog.SelectedPath = Helpers.FixPathSafe(Config.TerrariaContentDirectory);
if (dialog.SelectedPath == string.Empty)
dialog.SelectedPath = lastFolderPath;
var result = FolderBrowserLauncher.ShowFolderBrowser(dialog);
Expand Down Expand Up @@ -244,6 +245,7 @@ private void OnExtractModeChanged(object sender, SelectionChangedEventArgs e) {
buttonExtractUseTerraria.IsEnabled = !Config.Extract.UseInput && Config.Extract.Mode == InputModes.Folder;
checkBoxExtractImages.IsEnabled = Config.Extract.Mode == InputModes.Folder;
checkBoxExtractSounds.IsEnabled = Config.Extract.Mode == InputModes.Folder;
checkBoxExtractFonts.IsEnabled = Config.Extract.Mode == InputModes.Folder;
checkBoxExtractWaveBank.IsEnabled = Config.Extract.Mode == InputModes.Folder;
}
private void OnExtractChangeInput(object sender, RoutedEventArgs e) {
Expand Down Expand Up @@ -535,8 +537,13 @@ private void OnChangeScript(object sender, RoutedEventArgs e) {
dialog.Title = "Choose script file";
dialog.CheckFileExists = true;
if (Config.Script.File != string.Empty) {
dialog.FileName = Path.GetFileName(Config.Script.File);
dialog.InitialDirectory = Path.GetDirectoryName(Config.Script.File);
try {
dialog.FileName = Path.GetFileName(Config.Script.File);
dialog.InitialDirectory = Path.GetDirectoryName(Config.Script.File);
}
catch {
dialog.InitialDirectory = lastFilePath;
}
}
else {
dialog.InitialDirectory = lastFilePath;
Expand All @@ -546,7 +553,10 @@ private void OnChangeScript(object sender, RoutedEventArgs e) {
textBoxScript.Text = dialog.FileName;
Config.Script.File = dialog.FileName;
}
lastFilePath = Path.GetDirectoryName(dialog.FileName);
try {
lastFilePath = Path.GetDirectoryName(dialog.FileName);
}
catch { }
}
private void OnScriptChanged(object sender, TextChangedEventArgs e) {
if (!loaded)
Expand Down Expand Up @@ -670,9 +680,11 @@ private void OnOpenTerrariaFolder(object sender, RoutedEventArgs e) {
string dir = Config.TerrariaContentDirectory;
try {
dir = Path.GetDirectoryName(Config.TerrariaContentDirectory);
Process.Start(dir);
}
catch {
TriggerMessageBox.Show(this, MessageIcon.Warning, "Failed to locate Terraria folder.", "Missing Folder");
}
catch { }
Process.Start(dir);
}
}
private void OnExit(object sender, RoutedEventArgs e) {
Expand Down Expand Up @@ -758,14 +770,25 @@ private string GetPath(string currentPath, bool input, bool extract) {
dialog.Title = "Choose " + (input ? "input" : "output") + " file";
dialog.CheckFileExists = input;
if (currentPath != string.Empty) {
dialog.FileName = Path.GetFileName(currentPath);
dialog.InitialDirectory = Path.GetDirectoryName(currentPath);
try {
dialog.FileName = Path.GetFileName(currentPath);
}
catch { }
try {
dialog.InitialDirectory = Path.GetDirectoryName(currentPath);
}
catch {
dialog.InitialDirectory = lastFilePath;
}
}
else {
dialog.InitialDirectory = lastFilePath;
}
var result = dialog.ShowDialog(this);
lastFilePath = Path.GetDirectoryName(dialog.FileName);
try {
lastFilePath = Path.GetDirectoryName(dialog.FileName);
}
catch { }
if (result.HasValue && result.Value) {
return dialog.FileName;
}
Expand Down
4 changes: 2 additions & 2 deletions TConvert/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")]
[assembly: AssemblyVersion("1.0.0.2")]
[assembly: AssemblyFileVersion("1.0.0.2")]
[assembly: Guid("81FD8C9E-23D9-4CE3-95F7-21B735444371")]
[assembly: NeutralResourcesLanguage("en-US")]

2 changes: 1 addition & 1 deletion TConvert/TerrariaLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static class TerrariaLocator {

/**<summary>Start looking for the Terraria Content folder.</summary>*/
static TerrariaLocator() {
TerrariaContentDirectory = FindTerrariaContentDirectory();
TerrariaContentDirectory = null;// FindTerrariaContentDirectory();
}

#endregion
Expand Down
6 changes: 5 additions & 1 deletion TConvert/Windows/FolderBrowserLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ public static class FolderBrowserLauncher {
public static DialogResult ShowFolderBrowser(FolderBrowserDialog dlg, IWin32Window parent = null) {
DialogResult result = DialogResult.Cancel;
int retries = 40;
dlg.SelectedPath = System.IO.Path.GetFullPath(dlg.SelectedPath);
try {
if (dlg.SelectedPath != "")
dlg.SelectedPath = System.IO.Path.GetFullPath(dlg.SelectedPath);
}
catch { }

using (Timer t = new Timer()) {
t.Tick += (s, a) => {
Expand Down

0 comments on commit baca621

Please sign in to comment.