private static void Main(string[] args) { LogFile.Initialize(false); LogFile.AddMessage($"Starting {ProgramName} (v{VersionString})..."); #if DEBUG Steam.Init(); var games = InstallForm.FindGames(); if (games.Any(t => t.GameName == Games.SonicForces.GameName)) { StartDirectory = Path.GetDirectoryName(games.Find(t => t.GameName == Games.SonicForces.GameName).Path); } #endif ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; LogFile.AddMessage($"Running {ProgramName} in {StartDirectory}"); // Writes "cpkredir.ini" if it doesn't exists as HedgeModManager uses it to store its config if (!File.Exists(Path.Combine(StartDirectory, "cpkredir.ini"))) { LogFile.AddMessage("Writing cpkredir.ini"); File.WriteAllText(Path.Combine(StartDirectory, "cpkredir.ini"), Resources.cpkredirINI); } if (File.Exists(Path.Combine(StartDirectory, "cpkredir.ini"))) { MainForm.CPKREDIRIni = new IniFile(Path.Combine(StartDirectory, "cpkredir.ini")); } if (args.Length > 0) { if (args[0] == "-dev") { LogFile.AddMessage("Starting Dev Tools"); DevTools.Init(); return; } if (args[0] == "-gb") { LogFile.AddMessage("Running GB Installer"); DownloadGameBananaItem(args[1]); LogFile.Close(); return; } } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); while (Restart) { LogFile.Initialize(!Restart); Restart = false; LogFile.AddMessage($"Starting {ProgramName} (v{VersionString})..."); Application.Run(new MainForm()); } }
private static void Main(string[] args) { Args = args; // Language CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US"); CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("en-US"); // Makes sure HMM uses TLSv1.2 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; // Check if HMM is running bool running = Process.GetProcessesByName(ProgramNameShort).Length > 1; // Start Pipe Server if (!running) { HMMCommand.Start(); } LogFile.Initialize(true); LogFile.AddMessage($"Starting {ProgramName} (v{VersionString})..."); #if !DEBUG // Enable our Crash Window if Compiled in Release if (!Debugger.IsAttached) { // Redirects all Unhandle Exceptions to Application.ThreadException Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); // Adds our EVent into the Application.ThreadException handler Application.ThreadException += new ThreadExceptionEventHandler(ExceptionWindow.UnhandledExceptionEventHandler); // Incase anything else throws an exception it will go to our handler AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionWindow.UnhandledExceptionEventHandler); } #endif #if DEBUG Steam.Init(); var games = InstallForm.FindGames(); if (games.Any(t => t.GameName == Games.SonicForces.GameName)) { StartDirectory = Path.GetDirectoryName(games.Find(t => t.GameName == Games.SonicForces.GameName).Path); } #endif LogFile.AddMessage($"Running {ProgramName} in {StartDirectory}"); // Writes "cpkredir.ini" if it doesn't exists as HedgeModManager and cpkredir uses it to store its config if (!File.Exists(Path.Combine(StartDirectory, "cpkredir.ini"))) { LogFile.AddMessage("Writing cpkredir.ini"); File.WriteAllText(Path.Combine(StartDirectory, "cpkredir.ini"), Resources.cpkredirINI); } if (File.Exists(Path.Combine(StartDirectory, "cpkredir.ini"))) { MainForm.CPKREDIRIni = new IniFile(Path.Combine(StartDirectory, "cpkredir.ini")); } if (args.Length > 0) { if (args[0] == "-dev") { LogFile.AddMessage("Starting Dev Tools"); DevTools.Init(); HMMCommand.Close(); return; } if (args[0] == "-gb") { if (running) { HMMCommand.SendMessage("GB " + args[1]); LogFile.Close(); return; } LogFile.AddMessage("Running GB Installer"); DownloadGameBananaItem(args[1]); } } if (!running) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); while (Restart) { LogFile.Initialize(!Restart); Restart = false; LogFile.AddMessage($"Re-Starting {ProgramName} (v{VersionString})..."); Application.Run(new MainForm()); } HMMCommand.Close(); } }