Techblox Mod Manager / Launcher
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.5KB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using System.Windows.Forms;
  6. namespace GCMM
  7. {
  8. static class Program
  9. {
  10. /// <summary>
  11. /// The main entry point for the application.
  12. /// </summary>
  13. [STAThread]
  14. static void Main(string[] args)
  15. {
  16. //Application.SetHighDpiMode(HighDpiMode.SystemAware);
  17. Application.EnableVisualStyles();
  18. Application.SetCompatibleTextRenderingDefault(false);
  19. if (args.Length > 0)
  20. {
  21. DealWithCommandLineAsync(args);
  22. Application.Run();
  23. return;
  24. }
  25. Application.Run(new MainForm());
  26. }
  27. private static async void DealWithCommandLineAsync(string[] args)
  28. {
  29. var form = new MainForm();
  30. await form.LoadEverything(false);
  31. bool? shouldStay = null;
  32. if (args[0] == "-start" && args.Length > 1)
  33. shouldStay = await form.PatchStartGame(args[1]);
  34. else
  35. MessageBox.Show("Supported options:\n-start <command> - Starts the game using the given command");
  36. if (shouldStay.HasValue)
  37. {
  38. form.FormClosed += (sender, e) => Application.Exit();
  39. if (!shouldStay.Value)
  40. {
  41. await Task.Delay(2000);
  42. form.Close();
  43. }
  44. }
  45. else
  46. Environment.Exit(0);
  47. }
  48. }
  49. }