From d23e5eeb76750ac50ff7c4d33c72d1ba16cfbd88 Mon Sep 17 00:00:00 2001 From: David_JonesDVN Date: Wed, 2 Feb 2022 14:39:10 +0330 Subject: [PATCH] Fixed: The launcher creating another directory for thcrap sometimes. --- Touhou Launcher/MainForm.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Touhou Launcher/MainForm.cs b/Touhou Launcher/MainForm.cs index 3a2c385..8aba9bb 100644 --- a/Touhou Launcher/MainForm.cs +++ b/Touhou Launcher/MainForm.cs @@ -1003,7 +1003,8 @@ private void browse_Click(object sender, EventArgs e) txtbox.BackColor = SystemColors.Window; txtbox.Text = file; curCfg.np2Dir = np2Dir.Text; - curCfg.crapDir = Path.GetDirectoryName(crapDir.Text).TrimEnd("\\bin".ToCharArray()); + string crapPath = Path.GetDirectoryName(crapDir.Text); + curCfg.crapDir = (Directory.Exists(crapPath + "\\bin") || !crapPath.EndsWith("\\bin")) ? crapPath : crapPath.Substring(0, crapPath.LastIndexOf("\\bin")); } } @@ -1013,8 +1014,8 @@ private void Dir_LostFocus(object sender, EventArgs e) { ((TextBox)sender).BackColor = SystemColors.Window; curCfg.np2Dir = np2Dir.Text; - string crapPath = crapDir.Text == "" ? "" : Path.GetDirectoryName(crapDir.Text); - curCfg.crapDir = Directory.Exists(crapPath + "\\bin") ? crapPath : crapPath.TrimEnd("\\bin".ToCharArray()); + string crapPath = Path.GetDirectoryName(crapDir.Text); + curCfg.crapDir = (Directory.Exists(crapPath + "\\bin") || !crapPath.EndsWith("\\bin")) ? crapPath : crapPath.Substring(0, crapPath.LastIndexOf("\\bin")); curCfg.StartingRepo = crapStartingRepo.Text; } else @@ -1032,7 +1033,9 @@ private void crapConfigure_Click(object sender, EventArgs e) if (curCfg.crapDir != "") { string procDir = curCfg.crapDir + "\\bin\\thcrap_configure.exe"; - if (File.Exists(procDir)) + if (!File.Exists(procDir)) + MessageBox.Show(rm.GetString("errorcrapNotFound")); + else startProcess(procDir); } }