Skip to content

Commit dc6e935

Browse files
committed
Change shortcuts based on which launcher is downloaded
1 parent 02ec47f commit dc6e935

4 files changed

Lines changed: 48 additions & 7 deletions

File tree

src/Common.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ public static string SourcePath2
168168
set { Main.SourcePath2.Text = value; }
169169
}
170170

171+
// Path to launcher executable based on selection
172+
public static string LauncherPath { get; set; } = "";
173+
171174
// Flag to control how operation window will function
172175
// 0 is for downloading Flashpoint
173176
// 1 is for adding/removing components
@@ -246,6 +249,7 @@ public static TreeNode AddNodeToList(XmlNode child, TreeNodeCollection parent, b
246249
Component component = new Component(child);
247250

248251
listNode.Text = component.Title;
252+
listNode.Name = component.ID;
249253

250254
if (component.ID.StartsWith("required"))
251255
{
@@ -259,6 +263,7 @@ public static TreeNode AddNodeToList(XmlNode child, TreeNodeCollection parent, b
259263
Category category = new Category(child);
260264

261265
listNode.Text = category.Title;
266+
listNode.Name = category.ID;
262267

263268
if (category.ID.StartsWith("required"))
264269
{

src/Forms/FinishOperation.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,20 @@ private void FinishDownload_Exit(object sender, EventArgs e)
2727
{
2828
if (RunOnClose.Checked)
2929
{
30-
var flashpointProcess = new Process();
31-
flashpointProcess.StartInfo.UseShellExecute = true;
32-
flashpointProcess.StartInfo.FileName = "Flashpoint.exe";
33-
flashpointProcess.StartInfo.WorkingDirectory = Path.Combine(FPM.DestinationPath, @"Launcher");
34-
flashpointProcess.Start();
30+
if (FPM.LauncherPath != "")
31+
{
32+
string[] path = FPM.LauncherPath.Split('\\');
33+
34+
var flashpointProcess = new Process();
35+
flashpointProcess.StartInfo.UseShellExecute = true;
36+
flashpointProcess.StartInfo.FileName = path[1];
37+
flashpointProcess.StartInfo.WorkingDirectory = Path.Combine(FPM.DestinationPath, path[0]);
38+
flashpointProcess.Start();
39+
}
40+
else
41+
{
42+
Process.Start("explorer.exe", FPM.DestinationPath);
43+
}
3544
}
3645
}
3746

src/Forms/MainDownload.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,24 @@ private void DownloadButton_Click(object sender, EventArgs e)
100100

101101
FPM.CheckDependencies(ComponentList);
102102

103+
FPM.LauncherPath = "";
104+
foreach (TreeNode launcher in ComponentList.Nodes["launcher"].Nodes)
105+
{
106+
if (launcher.Checked)
107+
{
108+
if (launcher.Name == "launcher-electron")
109+
{
110+
FPM.LauncherPath = @"Launcher\Flashpoint.exe";
111+
break;
112+
}
113+
else if (launcher.Name == "launcher-winforms")
114+
{
115+
FPM.LauncherPath = @"SharpLauncher\SharpLauncher.exe";
116+
break;
117+
}
118+
}
119+
}
120+
103121
FPM.OperateMode = 0;
104122

105123
var operationWindow = new Operation();

src/Forms/Operation.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,17 @@ await Task.Run(() =>
301301
foreach (string path in shortcutPaths)
302302
{
303303
var shortcut = new IWshRuntimeLibrary.WshShell().CreateShortcut(Path.Combine(path, "Flashpoint.lnk"));
304-
shortcut.TargetPath = Path.Combine(FPM.DestinationPath, @"Launcher\Flashpoint.exe");
305-
shortcut.WorkingDirectory = Path.Combine(FPM.DestinationPath, @"Launcher");
304+
305+
if (FPM.LauncherPath != "")
306+
{
307+
shortcut.TargetPath = Path.Combine(FPM.DestinationPath, FPM.LauncherPath);
308+
shortcut.WorkingDirectory = Path.Combine(FPM.DestinationPath, FPM.LauncherPath.Split('\\')[0]);
309+
}
310+
else
311+
{
312+
shortcut.TargetPath = FPM.DestinationPath;
313+
}
314+
306315
shortcut.Description = "Shortcut to Flashpoint";
307316
shortcut.Save();
308317
}

0 commit comments

Comments
 (0)