Skip to content

Commit

Permalink
Added -nolauncher launch option
Browse files Browse the repository at this point in the history
  • Loading branch information
DraakjeYoblama committed Nov 29, 2023
1 parent c58b9e4 commit 9bd78bf
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using NLog.Targets;
using System.Diagnostics;
using System.Globalization;
using System.Media;
using System.Runtime.InteropServices;

namespace CityLauncher
Expand Down Expand Up @@ -34,12 +35,18 @@ internal static class Program
/// @author Neato (https://steamcommunity.com/id/frofoo)
/// </summary>
[STAThread]
static void Main()
static void Main(string[] args)
{
bool IsNewWindow = true;
using (Mutex mtx = new(true, "{BD4C408D-EF15-4C98-B792-C30D089E19D1}", out IsNewWindow))
{
if (IsNewWindow)
if (args.Contains("-nolauncher"))
{
SetupCulture();
SetupLogger();
LauncherBypass();
}
else if (IsNewWindow)
{
SetupCulture();
SetupLogger();
Expand Down Expand Up @@ -108,5 +115,25 @@ private static void SetupLogger()
config.AddRule(LogLevel.Debug, LogLevel.Warn, logfile);
LogManager.Configuration = config;
}
}

private static void LauncherBypass()
{
Nlog.Info("LauncherBypass - Starting logs at {0} on {1}.", DateTime.Now.ToString("HH:mm:ss"), DateTime.Now.ToString("D", new CultureInfo("en-GB")));
using (Process LaunchGame = new())
{
if (FileHandler.DetectGameExe())
{
LaunchGame.StartInfo.FileName = "BatmanAC.exe";
LaunchGame.StartInfo.CreateNoWindow = true;
LaunchGame.Start();
Nlog.Info("LauncherBypass - Launching the game. Concluding logs at {0} on {1}.", DateTime.Now.ToString("HH:mm:ss"), DateTime.Now.ToString("D", new CultureInfo("en-GB")));
Application.Exit();
}
else
{
MessageBox.Show("Could not find 'BatmanAC.exe'.\nIs the Launcher in the correct folder?", "Error!", MessageBoxButtons.OK);
}
}
}
}
}

0 comments on commit 9bd78bf

Please sign in to comment.