TBMM/GCMM/Program.cs
2021-01-20 00:49:11 +01:00

51 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GCMM
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (args.Length > 0)
{
DealWithCommandLineAsync(args);
Application.Run();
return;
}
Application.Run(new MainForm());
}
private static async void DealWithCommandLineAsync(string[] args)
{
var form = new MainForm();
await form.LoadEverything();
bool? shouldStay = null;
if (args[0] == "-start" && args.Length > 1)
shouldStay = await form.PatchStartGame(args[1]);
else
MessageBox.Show("Supported options:\n-start <command> - Starts the game using the given command");
if (shouldStay.HasValue)
{
form.FormClosed += (sender, e) => Application.Exit();
if (!shouldStay.Value)
{
await Task.Delay(2000);
form.Close();
}
}
else
Application.Exit();
}
}
}