Skip to content

Commit 85cf1e9

Browse files
committed
[FlashpointInstaller] Improve destination path handling
1 parent 2d11b63 commit 85cf1e9

4 files changed

Lines changed: 18 additions & 27 deletions

File tree

FlashpointInstaller/src/Common.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,6 @@ public static bool RedistInstalled
160160
get => Registry.LocalMachine.OpenSubKey("SOFTWARE\\WOW6432Node\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\X86") != null;
161161
}
162162

163-
// Pointer to destination path textbox
164-
private static string destinationPath = Path.Combine(Path.GetPathRoot(AppDomain.CurrentDomain.BaseDirectory), "Flashpoint");
165-
public static string DestinationPath
166-
{
167-
get { return destinationPath; }
168-
set
169-
{
170-
if (VerifyDestinationPath(value))
171-
{
172-
destinationPath = value;
173-
Main.DestinationPath.Text = destinationPath;
174-
}
175-
}
176-
}
177-
178163
// Object for tracking numerous file size sums
179164
public static class SizeTracker
180165
{

FlashpointInstaller/src/Forms/Finish.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ private void FinishDownload_Exit(object sender, EventArgs e)
1818
var flashpointProcess = new Process();
1919
flashpointProcess.StartInfo.UseShellExecute = true;
2020
flashpointProcess.StartInfo.FileName = "Flashpoint.exe";
21-
flashpointProcess.StartInfo.WorkingDirectory = Path.Combine(FPM.DestinationPath, "Launcher");
21+
flashpointProcess.StartInfo.WorkingDirectory = Path.Combine(FPM.Main.DestinationPath.Text, "Launcher");
2222
flashpointProcess.Start();
2323
}
2424

FlashpointInstaller/src/Forms/Main.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private void Main_Load(object sender, EventArgs e)
3434
Environment.Exit(1);
3535
}
3636

37-
DestinationPath.Text = FPM.DestinationPath;
37+
DestinationPath.Text = Path.Combine(Path.GetPathRoot(AppDomain.CurrentDomain.BaseDirectory), "Flashpoint");
3838
}
3939

4040
private void Link_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
@@ -89,18 +89,24 @@ private void DestinationPathBrowse_Click(object _, EventArgs e)
8989

9090
if (pathDialog.ShowDialog() == CommonFileDialogResult.Ok)
9191
{
92-
FPM.DestinationPath = Path.Combine(pathDialog.FileName, "Flashpoint");
92+
string path = Path.Combine(pathDialog.FileName, "Flashpoint");
93+
94+
if (FPM.VerifyDestinationPath(path)) DestinationPath.Text = path;
9395
}
9496
}
9597

9698
private void DestinationPath_KeyPress(object sender, KeyPressEventArgs e)
9799
{
98-
if (e.KeyChar == (char)Keys.Return) DownloadButton_Click(this, e);
100+
if (e.KeyChar == (char)Keys.Return)
101+
{
102+
DownloadButton_Click(this, e);
103+
e.Handled = true;
104+
}
99105
}
100106

101107
private void DownloadButton_Click(object sender, EventArgs e)
102108
{
103-
if (!FPM.VerifyDestinationPath(FPM.DestinationPath)) return;
109+
if (!FPM.VerifyDestinationPath(DestinationPath.Text)) return;
104110

105111
FPM.CheckDependencies();
106112

FlashpointInstaller/src/Forms/Operate.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ private void OnDownloadFileCompleted(object sender, System.ComponentModel.AsyncC
136136

137137
private void ExtractComponents()
138138
{
139-
string rootPath = FPM.DestinationPath;
140-
string infoPath = Path.Combine(rootPath, "Components");
139+
string rootPath = FPM.Main.DestinationPath.Text;
140+
string infoPath = Path.Combine(FPM.Main.DestinationPath.Text, "Components");
141141
string infoFile = Path.Combine(infoPath, $"{workingComponent.ID}.txt");
142142

143143
Directory.CreateDirectory(infoPath);
@@ -231,8 +231,8 @@ await Task.Run(() =>
231231
foreach (string path in shortcutPaths)
232232
{
233233
var shortcut = new IWshRuntimeLibrary.WshShell().CreateShortcut(Path.Combine(path, "Flashpoint.lnk"));
234-
shortcut.TargetPath = Path.Combine(FPM.DestinationPath, "Launcher", "Flashpoint.exe");
235-
shortcut.WorkingDirectory = Path.Combine(FPM.DestinationPath, "Launcher");
234+
shortcut.TargetPath = Path.Combine(FPM.Main.DestinationPath.Text, "Launcher", "Flashpoint.exe");
235+
shortcut.WorkingDirectory = Path.Combine(FPM.Main.DestinationPath.Text, "Launcher");
236236
shortcut.Description = "Shortcut to Flashpoint";
237237
shortcut.Save();
238238
}
@@ -259,14 +259,14 @@ await Task.Run(() =>
259259
{
260260
while (cancelStatus != 2) { }
261261

262-
if (Directory.Exists(FPM.DestinationPath))
262+
if (Directory.Exists(FPM.Main.DestinationPath.Text))
263263
{
264-
foreach (string file in Directory.EnumerateFiles(FPM.DestinationPath))
264+
foreach (string file in Directory.EnumerateFiles(FPM.Main.DestinationPath.Text))
265265
{
266266
try { File.Delete(file); } catch { }
267267
}
268268

269-
try { Directory.Delete(FPM.DestinationPath, true); } catch { }
269+
try { Directory.Delete(FPM.Main.DestinationPath.Text, true); } catch { }
270270
}
271271
});
272272

0 commit comments

Comments
 (0)