add arg support to console

This commit is contained in:
Bitl 2022-09-15 09:24:45 -07:00
parent 1f0b6d0770
commit 0cbadf7859
2 changed files with 71 additions and 47 deletions

View File

@ -17,10 +17,16 @@ namespace NovetusLauncher
{
static LauncherFormShared ConsoleForm;
public NovetusConsole()
public NovetusConsole(string[] args)
{
ConsoleForm = new LauncherFormShared();
InitializeComponent();
if (args.Length > 0)
{
//DO ARGS HERE
ConsoleProcessArguments(args);
}
}
private void NovetusConsole_Load(object sender, EventArgs e)
@ -56,6 +62,16 @@ namespace NovetusLauncher
Util.StartDiscord();
}
private void ConsoleProcessArguments(string[] args)
{
CommandLineArguments.Arguments ConsoleArgs = new CommandLineArguments.Arguments(args);
if (ConsoleArgs["cmd"] != null)
{
//cmd mode
}
}
public void ConsoleProcessCommands(string cmd)
{
if (string.IsNullOrWhiteSpace(cmd))
@ -181,10 +197,6 @@ namespace NovetusLauncher
Util.ConsolePrint("Please specify the IP address you would like to set Novetus to.", 2);
}
break;
case string nofilelist when (string.Compare(nofilelist, "nofilelist", true, CultureInfo.InvariantCulture) == 0):
GlobalVars.NoFileList = true;
Util.ConsolePrint("File List Generation is now disabled for this sesion.", 4);
break;
case string important when string.Compare(important, GlobalVars.Important, true, CultureInfo.InvariantCulture) == 0:
GlobalVars.AdminMode = true;
Util.ConsolePrint("ADMIN MODE ENABLED.", 4);
@ -195,9 +207,6 @@ namespace NovetusLauncher
de.Show();
Util.ConsolePrint("???", 2);
break;
case string quit when (string.Compare(quit, "exit", true, CultureInfo.InvariantCulture) == 0 || string.Compare(quit, "quit", true, CultureInfo.InvariantCulture) == 0):
ConsoleForm.CloseEventInternal();
break;
default:
Util.ConsolePrint("Command is either not registered or valid", 2);
break;
@ -208,17 +217,23 @@ namespace NovetusLauncher
{
Util.ConsolePrint("Help:", 3, true);
Util.ConsolePrint("---------", 1, true);
Util.ConsolePrint("= client | Launches client with launcher settings", 4, true);
Util.ConsolePrint("= solo | Launches client in Play Solo mode with launcher settings", 4, true);
Util.ConsolePrint("= server 3d | Launches server with launcher settings", 4, true);
Util.ConsolePrint("= server no3d | Launches server in NoGraphics mode with launcher settings", 4, true);
Util.ConsolePrint("= studio map | Launches Roblox Studio with the selected map", 4, true);
Util.ConsolePrint("= studio nomap | Launches Roblox Studio without the selected map", 4, true);
Util.ConsolePrint("= sdk | Launches the Novetus SDK Launcher", 4, true);
Util.ConsolePrint("= dlldelete | Toggle the deletion of opengl32.dll when ReShade is off.", 4, true);
Util.ConsolePrint("= altserverip <IP> | Sets the alternate server IP for server info. Replace <IP> with your specified IP or specify 'none' to remove the current alternate server IP", 4, true);
Util.ConsolePrint("= nofilelist | Disables initial file list generation. Meant for the command line.", 4, true);
Util.ConsolePrint("= exit/quit | Closes Novetus.", 4, true);
Util.ConsolePrint("Commands:", 3, true);
Util.ConsolePrint("---------", 1, true);
Util.ConsolePrint("+ client | Launches client with launcher settings", 4, true);
Util.ConsolePrint("+ solo | Launches client in Play Solo mode with launcher settings", 4, true);
Util.ConsolePrint("+ server 3d | Launches server with launcher settings", 4, true);
Util.ConsolePrint("+ server no3d | Launches server in NoGraphics mode with launcher settings", 4, true);
Util.ConsolePrint("+ studio map | Launches Roblox Studio with the selected map", 4, true);
Util.ConsolePrint("+ studio nomap | Launches Roblox Studio without the selected map", 4, true);
Util.ConsolePrint("+ sdk | Launches the Novetus SDK Launcher", 4, true);
Util.ConsolePrint("+ dlldelete | Toggle the deletion of opengl32.dll when ReShade is off.", 4, true);
Util.ConsolePrint("+ altserverip <IP> | Sets the alternate server IP for server info. Replace <IP> with your specified IP or specify 'none' to remove the current alternate server IP", 4, true);
Util.ConsolePrint("---------", 1, true);
Util.ConsolePrint("Command-Line Parameters:", 3, true);
Util.ConsolePrint("---------", 1, true);
Util.ConsolePrint("- sdk | Launches the Novetus SDK Launcher", 4, true);
Util.ConsolePrint("- client | Launches client with launcher settings", 4, true);
Util.ConsolePrint("- nofilelist | Disables file list generation", 4, true);
Util.ConsolePrint("---------", 1, true);
Util.ConsolePrint("= config save | Saves the config file", 4, true);
Util.ConsolePrint("= config load | Reloads the config file", 4, true);

View File

@ -40,17 +40,21 @@ namespace NovetusLauncher
FileManagement.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, false);
GlobalVars.ColorsLoaded = FileManagement.InitColors();
if (args.Length == 0)
{
Run();
}
else
bool isSDK = false;
bool isCMD = false;
if (args.Length > 0)
{
CommandLineArguments.Arguments CommandLine = new CommandLineArguments.Arguments(args);
if (CommandLine["sdk"] != null)
{
Run(true);
isSDK = true;
}
if (CommandLine["cmd"] != null)
{
isCMD = true;
}
if (CommandLine["nofilelist"] != null)
@ -58,9 +62,11 @@ namespace NovetusLauncher
GlobalVars.NoFileList = true;
}
}
Run(args, isSDK, isCMD);
}
static void Run(bool sdk = false)
static void Run(string[] args, bool sdk = false, bool cmdonly = false)
{
try
{
@ -70,33 +76,36 @@ namespace NovetusLauncher
if (!formsOpen)
{
NovetusConsole console = new NovetusConsole();
NovetusConsole console = new NovetusConsole(args);
GlobalVars.consoleForm = console;
console.Show();
if (!sdk)
if (!cmdonly)
{
switch (GlobalVars.UserConfiguration.LauncherStyle)
if (!sdk)
{
case Settings.Style.Compact:
LauncherFormCompact compact = new LauncherFormCompact();
compact.Show();
break;
case Settings.Style.Extended:
LauncherFormExtended extended = new LauncherFormExtended();
extended.Show();
break;
case Settings.Style.Stylish:
default:
LauncherFormStylish stylish = new LauncherFormStylish();
stylish.Show();
break;
switch (GlobalVars.UserConfiguration.LauncherStyle)
{
case Settings.Style.Compact:
LauncherFormCompact compact = new LauncherFormCompact();
compact.Show();
break;
case Settings.Style.Extended:
LauncherFormExtended extended = new LauncherFormExtended();
extended.Show();
break;
case Settings.Style.Stylish:
default:
LauncherFormStylish stylish = new LauncherFormStylish();
stylish.Show();
break;
}
}
else
{
NovetusSDK sdkApp = new NovetusSDK(false);
sdkApp.Show();
}
}
else
{
NovetusSDK sdkApp = new NovetusSDK(false);
sdkApp.Show();
}
formsOpen = true;