deleted obsolete exit methods. while loops ftw

This commit is contained in:
Bitl 2020-06-29 13:27:08 -07:00
parent 7b23076c85
commit 8a3cf6e689
3 changed files with 102 additions and 73 deletions

View File

@ -13,6 +13,7 @@ using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
public static class Env
{
@ -258,4 +259,10 @@ public static class GlobalVars
{
return Process.GetProcesses().Any(x => x.Id == id);
}
//task.delay is only available on net 4.5.......
public static async void Delay(int miliseconds)
{
await TaskEx.Delay(miliseconds);
}
}

View File

@ -981,14 +981,21 @@ namespace NovetusLauncher
client.StartInfo.Arguments = args;
client.EnableRaisingEvents = true;
ReadClientValues(GlobalVars.SelectedClient);
client.Exited += new EventHandler(ClientExited);
client.Start();
client.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.Client, GlobalVars.Map);
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InMPGame, GlobalVars.Map);
}
//while (!client.HasExited && client.Responding)
//{
//insert events
//GlobalVars.Delay(15);
//}
client.WaitForExit();
ClientExited();
}
void ClientExited(object sender, EventArgs e)
//again, we don't need this.
void ClientExited()
{
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher, "");
if (GlobalVars.CloseOnLaunch == true)
@ -1028,12 +1035,18 @@ namespace NovetusLauncher
client.StartInfo.Arguments = args;
client.EnableRaisingEvents = true;
ReadClientValues(GlobalVars.SelectedClient);
client.Exited += new EventHandler(StudioExited);
client.Start();
client.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.Solo, GlobalVars.Map);
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InSoloGame, GlobalVars.Map);
}
//while (!client.HasExited && client.Responding)
//{
//insert events
//GlobalVars.Delay(15);
//}
client.WaitForExit();
ClientExited();
}
catch (Exception ex) when (!Env.Debugging)
{
ConsolePrint("ERROR - Failed to launch Novetus. (" + ex.Message + ")", 2);
@ -1080,10 +1093,19 @@ namespace NovetusLauncher
client.StartInfo.Arguments = args;
client.EnableRaisingEvents = true;
ReadClientValues(GlobalVars.SelectedClient);
client.Exited += new EventHandler(ServerExited);
client.Start();
client.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.Server, GlobalVars.Map);
//while (!client.HasExited && client.Responding)
//{
//insert events
//GlobalVars.Delay(15);
//}
client.WaitForExit();
if (GlobalVars.CloseOnLaunch == true)
{
Visible = true;
}
}
catch (Exception ex) when (!Env.Debugging)
{
@ -1092,14 +1114,6 @@ namespace NovetusLauncher
}
}
void ServerExited(object sender, EventArgs e)
{
if (GlobalVars.CloseOnLaunch == true)
{
Visible = true;
}
}
void StartStudio(bool nomap)
{
string luafile = LauncherFuncs.GetLuaFileName();
@ -1132,12 +1146,18 @@ namespace NovetusLauncher
client.StartInfo.Arguments = args;
client.EnableRaisingEvents = true;
ReadClientValues(GlobalVars.SelectedClient);
client.Exited += new EventHandler(StudioExited);
client.Start();
client.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.Studio, mapname);
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InStudio, mapname);
}
//while (!client.HasExited && client.Responding)
//{
//insert events
//GlobalVars.Delay(15);
//}
client.WaitForExit();
ClientExited();
}
catch (Exception ex) when (!Env.Debugging)
{
ConsolePrint("ERROR - Failed to launch Novetus. (" + ex.Message + ")", 2);
@ -1145,15 +1165,6 @@ namespace NovetusLauncher
}
}
void StudioExited(object sender, EventArgs e)
{
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher, "");
if (GlobalVars.CloseOnLaunch == true)
{
Visible = true;
}
}
void ConsoleProcessCommands(string command)
{
if (string.Compare(command,"server",true, CultureInfo.InvariantCulture) == 0)
@ -1777,12 +1788,18 @@ namespace NovetusLauncher
client.StartInfo.Arguments = args;
client.EnableRaisingEvents = true;
ReadClientValues(GlobalVars.SelectedClient);
client.Exited += new EventHandler(EasterEggExited);
client.Start();
client.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.EasterEgg, "");
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InEasterEggGame, "");
}
//while (!client.HasExited && client.Responding)
//{
//insert events
//GlobalVars.Delay(15);
//}
client.WaitForExit();
ClientExited();
}
catch (Exception ex) when (!Env.Debugging)
{
ConsolePrint("ERROR - Failed to launch Easter Egg. (" + ex.Message + ")", 2);
@ -1790,16 +1807,6 @@ namespace NovetusLauncher
}
}
void EasterEggExited(object sender, EventArgs e)
{
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher, "");
label12.Text = LocalVars.prevsplash;
if (GlobalVars.CloseOnLaunch == true)
{
Visible = true;
}
}
private void checkBox5_CheckedChanged(object sender, EventArgs e)
{
if (checkBox5.Checked == true)

View File

@ -16,6 +16,7 @@ using System.ComponentModel;
using System.Reflection;
using Mono.Nat;
using System.Globalization;
using LiteNetLib;
namespace NovetusLauncher
{
@ -947,14 +948,21 @@ namespace NovetusLauncher
client.StartInfo.Arguments = args;
client.EnableRaisingEvents = true;
ReadClientValues(GlobalVars.SelectedClient);
client.Exited += new EventHandler(ClientExited);
client.Start();
client.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.Client, GlobalVars.Map);
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InMPGame, GlobalVars.Map);
}
//while (!client.HasExited && client.Responding)
//{
//insert events
//GlobalVars.Delay(15);
//}
client.WaitForExit();
ClientExited();
}
void ClientExited(object sender, EventArgs e)
//TODO: make it so we don't need this.
void ClientExited(/*NetManager mgr*/)
{
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher, "");
if (GlobalVars.CloseOnLaunch == true)
@ -994,12 +1002,18 @@ namespace NovetusLauncher
client.StartInfo.Arguments = args;
client.EnableRaisingEvents = true;
ReadClientValues(GlobalVars.SelectedClient);
client.Exited += new EventHandler(StudioExited);
client.Start();
client.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.Solo, GlobalVars.Map);
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InSoloGame, GlobalVars.Map);
}
//while (!client.HasExited && client.Responding)
//{
//insert events
//GlobalVars.Delay(15);
//}
client.WaitForExit();
ClientExited();
}
catch (Exception ex) when (!Env.Debugging)
{
ConsolePrint("ERROR - Failed to launch Novetus. (" + ex.Message + ")", 2);
@ -1046,10 +1060,20 @@ namespace NovetusLauncher
client.StartInfo.Arguments = args;
client.EnableRaisingEvents = true;
ReadClientValues(GlobalVars.SelectedClient);
client.Exited += new EventHandler(ServerExited);
client.Start();
client.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.Server, GlobalVars.Map);
//we need to consider this implementation for ALL process code.
//while (!client.HasExited && client.Responding)
//{
//insert events
//GlobalVars.Delay(15);
//}
client.WaitForExit();
if (GlobalVars.CloseOnLaunch == true)
{
Visible = true;
}
}
catch (Exception ex) when (!Env.Debugging)
{
@ -1058,13 +1082,6 @@ namespace NovetusLauncher
}
}
void ServerExited(object sender, EventArgs e)
{
if (GlobalVars.CloseOnLaunch == true)
{
Visible = true;
}
}
void StartStudio(bool nomap)
{
@ -1098,12 +1115,18 @@ namespace NovetusLauncher
client.StartInfo.Arguments = args;
client.EnableRaisingEvents = true;
ReadClientValues(GlobalVars.SelectedClient);
client.Exited += new EventHandler(StudioExited);
client.Start();
client.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.Studio, mapname);
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InStudio, mapname);
}
//while (!client.HasExited && client.Responding)
//{
//insert events
//GlobalVars.Delay(15);
//}
client.WaitForExit();
ClientExited();
}
catch (Exception ex) when (!Env.Debugging)
{
ConsolePrint("ERROR - Failed to launch Novetus. (" + ex.Message + ")", 2);
@ -1111,15 +1134,6 @@ namespace NovetusLauncher
}
}
void StudioExited(object sender, EventArgs e)
{
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher, "");
if (GlobalVars.CloseOnLaunch == true)
{
Visible = true;
}
}
void ConsoleProcessCommands(string command)
{
if (string.Compare(command,"server",true, CultureInfo.InvariantCulture) == 0)
@ -1743,12 +1757,23 @@ namespace NovetusLauncher
client.StartInfo.Arguments = args;
client.EnableRaisingEvents = true;
ReadClientValues(GlobalVars.SelectedClient);
client.Exited += new EventHandler(EasterEggExited);
client.Start();
client.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.EasterEgg, "");
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InEasterEggGame, "");
}
//while (!client.HasExited && client.Responding)
//{
//insert events
//GlobalVars.Delay(15);
//}
client.WaitForExit();
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher, "");
label12.Text = LocalVars.prevsplash;
if (GlobalVars.CloseOnLaunch == true)
{
Visible = true;
}
}
catch (Exception ex) when (!Env.Debugging)
{
ConsolePrint("ERROR - Failed to launch Easter Egg. (" + ex.Message + ")", 2);
@ -1756,16 +1781,6 @@ namespace NovetusLauncher
}
}
void EasterEggExited(object sender, EventArgs e)
{
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher, "");
label12.Text = LocalVars.prevsplash;
if (GlobalVars.CloseOnLaunch == true)
{
Visible = true;
}
}
void SettingsButtonClick(object sender, EventArgs e)
{
NovetusSettings im = new NovetusSettings();