diff --git a/src/Syroot.Worms.OnlineWorms.Launcher/AssemblyInfo.cs b/src/Syroot.Worms.OnlineWorms.Launcher/AssemblyInfo.cs
new file mode 100644
index 0000000..309d94a
--- /dev/null
+++ b/src/Syroot.Worms.OnlineWorms.Launcher/AssemblyInfo.cs
@@ -0,0 +1,28 @@
+using System.Reflection;
+
+namespace Syroot.Worms.OnlineWorms.Launcher
+{
+ ///
+ /// Represents entry assembly information.
+ ///
+ internal static class AssemblyInfo
+ {
+ // ---- FIELDS -------------------------------------------------------------------------------------------------
+
+ private static readonly Assembly _entryAssembly;
+
+ // ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
+
+ static AssemblyInfo()
+ {
+ _entryAssembly = Assembly.GetEntryAssembly();
+ }
+
+ // ---- PROPERTIES ---------------------------------------------------------------------------------------------
+
+ ///
+ /// Gets the value of the .
+ ///
+ internal static string Title => _entryAssembly.GetCustomAttribute().Title;
+ }
+}
diff --git a/src/Syroot.Worms.OnlineWorms.Launcher/Config.cs b/src/Syroot.Worms.OnlineWorms.Launcher/Config.cs
index 96abd0e..b740c91 100644
--- a/src/Syroot.Worms.OnlineWorms.Launcher/Config.cs
+++ b/src/Syroot.Worms.OnlineWorms.Launcher/Config.cs
@@ -1,4 +1,5 @@
-using System.Net;
+using System.Collections.Generic;
+using System.Net;
namespace Syroot.Worms.OnlineWorms.Launcher
{
@@ -13,11 +14,12 @@ namespace Syroot.Worms.OnlineWorms.Launcher
public string Password { get; set; }
public uint PasswordKey { get; set; }
- public string ExecutablePath { get; set; } = "DWait.exe";
+ public string ExecutablePaths { get; set; } = "DWait.exe;Main.exe";
public string ExecutableArgs { get; set; }
public string MappingName { get; set; } = "KG1234567890";
public bool StartSuspended { get; set; }
+ internal IList ExecutePathList => ExecutablePaths.Split(';');
internal IPEndPoint ServerEndPoint => new IPEndPoint(IPAddress.Parse(ServerIP), ServerPort);
}
}
diff --git a/src/Syroot.Worms.OnlineWorms.Launcher/OWLauncherConfig.json b/src/Syroot.Worms.OnlineWorms.Launcher/LauncherConfig.json
similarity index 85%
rename from src/Syroot.Worms.OnlineWorms.Launcher/OWLauncherConfig.json
rename to src/Syroot.Worms.OnlineWorms.Launcher/LauncherConfig.json
index e14fe58..e5f0978 100644
--- a/src/Syroot.Worms.OnlineWorms.Launcher/OWLauncherConfig.json
+++ b/src/Syroot.Worms.OnlineWorms.Launcher/LauncherConfig.json
@@ -9,7 +9,7 @@
// Debugging settings (optional)
"PasswordKey": 1000, // base value to encrypt and decrypt password in launch file mapping
- "ExecutablePath": "DWait.exe", // relative or absolute path to game executable
+ "ExecutablePaths": "DWait.exe;Main.exe", // relative or absolute paths to game executables to consider
"ExecutableArgs": "", // additional arguments appended to command line
"MappingName": "KG1234567890", // launch file mapping identifier used and passed as first argument to game
"StartSuspended": false // true to create, but wait for confirmation to run the game process (to attach debuggers)
diff --git a/src/Syroot.Worms.OnlineWorms.Launcher/Program.cs b/src/Syroot.Worms.OnlineWorms.Launcher/Program.cs
index 0049f14..db0709b 100644
--- a/src/Syroot.Worms.OnlineWorms.Launcher/Program.cs
+++ b/src/Syroot.Worms.OnlineWorms.Launcher/Program.cs
@@ -1,5 +1,7 @@
using System;
+using System.Diagnostics;
using System.IO;
+using System.Linq;
using System.Windows.Forms;
using Microsoft.Extensions.Configuration;
@@ -15,35 +17,30 @@ namespace Syroot.Worms.OnlineWorms.Launcher
{
// Create and read the configuration.
Config config = new ConfigurationBuilder()
- .AddJsonFile("OWLauncherConfig.json", true)
+ .AddJsonFile("LauncherConfig.json", true)
.Build()
.Get();
- // Create the launch configuration.
- LaunchConfig launchConfig = new LaunchConfig
- {
- ServerEndPoint = config.ServerEndPoint,
- UserName = config.UserName
- };
- launchConfig.SetPassword(config.Password, config.PasswordKey);
+ // Check which of the game executables is available.
+ string executablePath = config.ExecutePathList.FirstOrDefault(x => File.Exists(x));
+ if (executablePath == null)
+ throw new InvalidOperationException("Game executable was not found.");
+ // Kill any possibly existing process.
+ KillProcesses(Path.GetFileNameWithoutExtension(executablePath));
- // Map the launch configuration to pass it to the process.
+ // Create the launch configuration and map it.
+ LaunchConfig launchConfig = CreateLaunchConfig(config);
using (launchConfig.CreateMappedFile(config.MappingName))
{
- // Create the process.
- string commandLine = String.Join(" ", config.MappingName, config.ExecutableArgs).TrimEnd();
- string directory = Path.GetDirectoryName(config.ExecutablePath);
- if (String.IsNullOrEmpty(directory))
- directory = null;
- NativeProcessFlags flags = NativeProcessFlags.InheritHandles;
- if (config.StartSuspended)
- flags |= NativeProcessFlags.StartSuspended;
- NativeProcess process = new NativeProcess(config.ExecutablePath, commandLine, directory, flags);
+ // Create and run the process.
+ NativeProcess process = CreateProcess(executablePath,
+ String.Join(" ", config.MappingName, config.ExecutableArgs).TrimEnd(),
+ config.StartSuspended);
if (config.StartSuspended)
{
- if (MessageBox.Show("Game process is paused. Click OK to resume or Cancel to kill it.",
- Application.ProductName, MessageBoxButtons.OKCancel, MessageBoxIcon.Information)
- == DialogResult.OK)
+ if (ShowMessage(MessageBoxIcon.Information,
+ "Game process has been created and is paused. Click OK to resume or Cancel to kill it.",
+ MessageBoxButtons.OKCancel) == DialogResult.OK)
{
process.Resume();
}
@@ -52,14 +49,49 @@ namespace Syroot.Worms.OnlineWorms.Launcher
process.Terminate();
}
}
-
process.WaitForExit();
}
}
catch (Exception ex)
{
+ ShowMessage(MessageBoxIcon.Error, ex.Message, MessageBoxButtons.OK);
Console.WriteLine(ex);
}
}
+
+ private static void KillProcesses(string processName)
+ {
+ foreach (Process process in Process.GetProcessesByName(processName))
+ process.Kill();
+ }
+
+ private static LaunchConfig CreateLaunchConfig(Config config)
+ {
+ LaunchConfig launchConfig = new LaunchConfig
+ {
+ ServerEndPoint = config.ServerEndPoint,
+ UserName = config.UserName
+ };
+ launchConfig.SetPassword(config.Password, config.PasswordKey);
+ return launchConfig;
+ }
+
+ private static NativeProcess CreateProcess(string executablePath, string commandLine, bool startSuspended)
+ {
+ string directory = Path.GetDirectoryName(executablePath);
+ if (String.IsNullOrEmpty(directory))
+ directory = null;
+
+ NativeProcessFlags flags = NativeProcessFlags.InheritHandles;
+ if (startSuspended)
+ flags |= NativeProcessFlags.StartSuspended;
+
+ return new NativeProcess(executablePath, commandLine, directory, flags);
+ }
+
+ private static DialogResult ShowMessage(MessageBoxIcon icon, string text, MessageBoxButtons buttons)
+ {
+ return MessageBox.Show(text, AssemblyInfo.Title, buttons, icon);
+ }
}
}
diff --git a/src/Syroot.Worms.OnlineWorms.Launcher/Properties/launchSettings.json b/src/Syroot.Worms.OnlineWorms.Launcher/Properties/launchSettings.json
index 681c7d3..c3f017a 100644
--- a/src/Syroot.Worms.OnlineWorms.Launcher/Properties/launchSettings.json
+++ b/src/Syroot.Worms.OnlineWorms.Launcher/Properties/launchSettings.json
@@ -2,7 +2,7 @@
"profiles": {
"Syroot.OnlineWorms.Launcher": {
"commandName": "Project",
- "workingDirectory": "C:\\Games\\Online Worms"
+ "workingDirectory": "C:\\Games\\WWP Aqua"
}
}
}
\ No newline at end of file
diff --git a/src/Syroot.Worms.OnlineWorms.Launcher/Resources/Icon.ico b/src/Syroot.Worms.OnlineWorms.Launcher/Resources/Icon.ico
index 3d9d7c0..67e55e9 100644
Binary files a/src/Syroot.Worms.OnlineWorms.Launcher/Resources/Icon.ico and b/src/Syroot.Worms.OnlineWorms.Launcher/Resources/Icon.ico differ
diff --git a/src/Syroot.Worms.OnlineWorms.Launcher/Syroot.Worms.OnlineWorms.Launcher.csproj b/src/Syroot.Worms.OnlineWorms.Launcher/Syroot.Worms.OnlineWorms.Launcher.csproj
index a2c8642..2075c66 100644
--- a/src/Syroot.Worms.OnlineWorms.Launcher/Syroot.Worms.OnlineWorms.Launcher.csproj
+++ b/src/Syroot.Worms.OnlineWorms.Launcher/Syroot.Worms.OnlineWorms.Launcher.csproj
@@ -2,16 +2,16 @@
false
Resources\Icon.ico
- OWLauncher
- Online Worms Launcher
+ Launcher
+ Mgame Worms Launcher
Syroot
(c) Syroot, licensed under MIT
None
- Game launcher for Online Worms
+ Game launcher for Mgame Worms games
WinExe
Online Worms Launcher
net461
- 0.1.0-alpha1
+ 0.5.0
app.manifest
@@ -20,13 +20,9 @@
-
-
-
-
-
-
- PreserveNewest
-
+
+
+ PreserveNewest
+