add console detection

This commit is contained in:
Bitl 2022-09-15 11:10:29 -07:00
parent b3eef48006
commit e6d2858ccf
4 changed files with 33 additions and 10 deletions

View File

@ -1015,7 +1015,10 @@ public class ClientManagement
Util.ConsolePrint("ERROR - Failed to launch Novetus. (A server is already running.)", 2); Util.ConsolePrint("ERROR - Failed to launch Novetus. (A server is already running.)", 2);
#if LAUNCHER #if LAUNCHER
if (!GlobalVars.isConsoleOnly)
{
MessageBox.Show("Failed to launch Novetus. (Error: A server is already running.)", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Failed to launch Novetus. (Error: A server is already running.)", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
#endif #endif
return; return;
} }
@ -1027,7 +1030,10 @@ public class ClientManagement
"Roblox does NOT use TCP, only UDP. However, if your server doesn't work with just UDP, feel free to set up TCP too as that might help the issue in some cases."; "Roblox does NOT use TCP, only UDP. However, if your server doesn't work with just UDP, feel free to set up TCP too as that might help the issue in some cases.";
#pragma warning restore CS0219 // Variable is assigned but its value is never used #pragma warning restore CS0219 // Variable is assigned but its value is never used
#if LAUNCHER #if LAUNCHER
if (!GlobalVars.isConsoleOnly)
{
MessageBox.Show(hostingTips, "Novetus - Hosting Tips", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show(hostingTips, "Novetus - Hosting Tips", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
#elif CMD #elif CMD
Util.ConsolePrint(hostingTips + "\nPress any key to continue...", 4); Util.ConsolePrint(hostingTips + "\nPress any key to continue...", 4);
Console.ReadKey(); Console.ReadKey();
@ -1048,7 +1054,10 @@ public class ClientManagement
Util.ConsolePrint("ERROR - Failed to launch Novetus. (A game is already running.)", 2); Util.ConsolePrint("ERROR - Failed to launch Novetus. (A game is already running.)", 2);
#if LAUNCHER #if LAUNCHER
if (!GlobalVars.isConsoleOnly)
{
MessageBox.Show("Failed to launch Novetus. (Error: A game is already running.)", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Failed to launch Novetus. (Error: A game is already running.)", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
#endif #endif
return; return;
} }
@ -1095,7 +1104,10 @@ public class ClientManagement
#endif #endif
#if LAUNCHER #if LAUNCHER
if (!GlobalVars.isConsoleOnly)
{
MessageBox.Show("Failed to launch Novetus. (Error: The client has been detected as modified.)", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Failed to launch Novetus. (Error: The client has been detected as modified.)", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
#endif #endif
#if URI #if URI
@ -1185,7 +1197,10 @@ public class ClientManagement
#endif #endif
#if LAUNCHER #if LAUNCHER
if (!GlobalVars.isConsoleOnly)
{
MessageBox.Show("Failed to launch Novetus. (Error: The client has been detected as modified.)", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Failed to launch Novetus. (Error: The client has been detected as modified.)", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
#endif #endif
#if URI #if URI
@ -1243,7 +1258,10 @@ public class ClientManagement
#endif #endif
#if URI || LAUNCHER #if URI || LAUNCHER
if (!GlobalVars.isConsoleOnly)
{
MessageBox.Show("Failed to launch Novetus. (Error: " + ex.Message + ")", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Failed to launch Novetus. (Error: " + ex.Message + ")", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
#endif #endif
#if URI || LAUNCHER || CMD || BASICLAUNCHER #if URI || LAUNCHER || CMD || BASICLAUNCHER
Util.LogExceptions(ex); Util.LogExceptions(ex);

View File

@ -109,6 +109,7 @@ public static class GlobalVars
public static string Important2 = ""; public static string Important2 = "";
public static string NextCommand = ""; public static string NextCommand = "";
public static bool AppClosed = false; public static bool AppClosed = false;
public static bool isConsoleOnly = false;
#endregion #endregion
} }
#endregion #endregion

View File

@ -351,7 +351,7 @@ namespace NovetusLauncher
break; break;
} }
if (GlobalVars.UserConfiguration.CloseOnLaunch) if (GlobalVars.UserConfiguration.CloseOnLaunch && !GlobalVars.isConsoleOnly)
{ {
Parent.Visible = false; Parent.Visible = false;
} }
@ -431,6 +431,11 @@ namespace NovetusLauncher
{ {
Parent.Visible = true; Parent.Visible = true;
} }
if (GlobalVars.isConsoleOnly && !GlobalVars.isConsoleOnly)
{
CloseEventInternal();
}
} }
// FINALLY. https://stackoverflow.com/questions/11530643/treeview-search // FINALLY. https://stackoverflow.com/questions/11530643/treeview-search

View File

@ -41,7 +41,6 @@ namespace NovetusLauncher
GlobalVars.ColorsLoaded = FileManagement.InitColors(); GlobalVars.ColorsLoaded = FileManagement.InitColors();
bool isSDK = false; bool isSDK = false;
bool isCMD = false;
if (args.Length > 0) if (args.Length > 0)
{ {
@ -54,7 +53,7 @@ namespace NovetusLauncher
if (CommandLine["cmd"] != null) if (CommandLine["cmd"] != null)
{ {
isCMD = true; GlobalVars.isConsoleOnly = true;
} }
if (CommandLine["nofilelist"] != null) if (CommandLine["nofilelist"] != null)
@ -63,7 +62,7 @@ namespace NovetusLauncher
} }
} }
Run(args, isSDK, isCMD); Run(args, isSDK, GlobalVars.isConsoleOnly);
} }
static void Run(string[] args, bool sdk = false, bool cmdonly = false) static void Run(string[] args, bool sdk = false, bool cmdonly = false)