consolidate launcher code into single class part 1
This commit is contained in:
parent
6ffbf1c26c
commit
6a30217641
|
|
@ -33,6 +33,7 @@ public static class GlobalVars
|
||||||
|
|
||||||
#region Joining
|
#region Joining
|
||||||
public static string IP = "localhost";
|
public static string IP = "localhost";
|
||||||
|
public static int JoinPort = 53640;
|
||||||
public static int DefaultRobloxPort = 53640;
|
public static int DefaultRobloxPort = 53640;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,6 @@ namespace NovetusLauncher
|
||||||
#region LauncherForm - Compact
|
#region LauncherForm - Compact
|
||||||
public partial class LauncherFormCompact : Form
|
public partial class LauncherFormCompact : Form
|
||||||
{
|
{
|
||||||
#region Private Variables
|
|
||||||
private DiscordRPC.EventHandlers handlers;
|
|
||||||
private List<TreeNode> CurrentNodeMatches = new List<TreeNode>();
|
|
||||||
private int LastNodeIndex = 0;
|
|
||||||
private string LastSearchText;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructor
|
#region Constructor
|
||||||
public LauncherFormCompact()
|
public LauncherFormCompact()
|
||||||
{
|
{
|
||||||
|
|
@ -30,183 +23,6 @@ namespace NovetusLauncher
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region UPnP
|
|
||||||
public void InitUPnP()
|
|
||||||
{
|
|
||||||
if (GlobalVars.UserConfiguration.UPnP)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
NetFuncs.InitUPnP(DeviceFound, DeviceLost);
|
|
||||||
GlobalFuncs.ConsolePrint("UPnP: Service initialized", 3, richTextBox1);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("UPnP: Unable to initialize UPnP. Reason - " + ex.Message, 2, richTextBox1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void StartUPnP(INatDevice device, Protocol protocol, int port)
|
|
||||||
{
|
|
||||||
if (GlobalVars.UserConfiguration.UPnP)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
NetFuncs.StartUPnP(device, protocol, port);
|
|
||||||
string IP = (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : device.GetExternalIP().ToString());
|
|
||||||
GlobalFuncs.ConsolePrint("UPnP: Port " + port + " opened on '" + IP + "' (" + protocol.ToString() + ")", 3, richTextBox1);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("UPnP: Unable to open port mapping. Reason - " + ex.Message, 2, richTextBox1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void StopUPnP(INatDevice device, Protocol protocol, int port)
|
|
||||||
{
|
|
||||||
if (GlobalVars.UserConfiguration.UPnP)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
NetFuncs.StopUPnP(device, protocol, port);
|
|
||||||
string IP = (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : device.GetExternalIP().ToString());
|
|
||||||
GlobalFuncs.ConsolePrint("UPnP: Port " + port + " closed on '" + IP + "' (" + protocol.ToString() + ")", 3, richTextBox1);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("UPnP: Unable to close port mapping. Reason - " + ex.Message, 2, richTextBox1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DeviceFound(object sender, DeviceEventArgs args)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
INatDevice device = args.Device;
|
|
||||||
string IP = (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : device.GetExternalIP().ToString());
|
|
||||||
GlobalFuncs.ConsolePrint("UPnP: Device '" + IP + "' registered.", 3, richTextBox1);
|
|
||||||
StartUPnP(device, Protocol.Udp, GlobalVars.UserConfiguration.RobloxPort);
|
|
||||||
StartUPnP(device, Protocol.Tcp, GlobalVars.UserConfiguration.RobloxPort);
|
|
||||||
StartUPnP(device, Protocol.Udp, GlobalVars.UserConfiguration.WebServerPort);
|
|
||||||
StartUPnP(device, Protocol.Tcp, GlobalVars.UserConfiguration.WebServerPort);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("UPnP: Unable to register device. Reason - " + ex.Message, 2, richTextBox1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DeviceLost(object sender, DeviceEventArgs args)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
INatDevice device = args.Device;
|
|
||||||
string IP = (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : device.GetExternalIP().ToString());
|
|
||||||
GlobalFuncs.ConsolePrint("UPnP: Device '" + IP + "' disconnected.", 3, richTextBox1);
|
|
||||||
StopUPnP(device, Protocol.Udp, GlobalVars.UserConfiguration.RobloxPort);
|
|
||||||
StopUPnP(device, Protocol.Tcp, GlobalVars.UserConfiguration.RobloxPort);
|
|
||||||
StopUPnP(device, Protocol.Udp, GlobalVars.UserConfiguration.WebServerPort);
|
|
||||||
StopUPnP(device, Protocol.Tcp, GlobalVars.UserConfiguration.WebServerPort);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("UPnP: Unable to disconnect device. Reason - " + ex.Message, 2, richTextBox1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Discord
|
|
||||||
public void ReadyCallback()
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("Discord RPC: Ready", 3, richTextBox1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DisconnectedCallback(int errorCode, string message)
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("Discord RPC: Disconnected. Reason - " + errorCode + ": " + message, 2, richTextBox1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ErrorCallback(int errorCode, string message)
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("Discord RPC: Error. Reason - " + errorCode + ": " + message, 2, richTextBox1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void JoinCallback(string secret)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SpectateCallback(string secret)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RequestCallback(DiscordRPC.JoinRequest request)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void StartDiscord()
|
|
||||||
{
|
|
||||||
if (GlobalVars.UserConfiguration.DiscordPresence)
|
|
||||||
{
|
|
||||||
handlers = new DiscordRPC.EventHandlers();
|
|
||||||
handlers.readyCallback = ReadyCallback;
|
|
||||||
handlers.disconnectedCallback += DisconnectedCallback;
|
|
||||||
handlers.errorCallback += ErrorCallback;
|
|
||||||
handlers.joinCallback += JoinCallback;
|
|
||||||
handlers.spectateCallback += SpectateCallback;
|
|
||||||
handlers.requestCallback += RequestCallback;
|
|
||||||
DiscordRPC.Initialize(GlobalVars.appid, ref handlers, true, "");
|
|
||||||
|
|
||||||
GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InLauncher, "", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Web Server
|
|
||||||
//udp clients will connect to the web server alongside the game.
|
|
||||||
void StartWebServer()
|
|
||||||
{
|
|
||||||
if (SecurityFuncs.IsElevated)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
GlobalVars.WebServer = new SimpleHTTPServer(GlobalPaths.DataPath, GlobalVars.UserConfiguration.WebServerPort);
|
|
||||||
GlobalFuncs.ConsolePrint("WebServer: Server is running on port: " + GlobalVars.WebServer.Port.ToString(), 3, richTextBox1);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("WebServer: Failed to launch WebServer. Some features may not function. (" + ex.Message + ")", 2, richTextBox1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("WebServer: Failed to launch WebServer. Some features may not function. (Did not run as Administrator)", 2, richTextBox1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StopWebServer()
|
|
||||||
{
|
|
||||||
if (SecurityFuncs.IsElevated)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("WebServer: Server has stopped on port: " + GlobalVars.WebServer.Port.ToString(), 2, richTextBox1);
|
|
||||||
GlobalVars.WebServer.Stop();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("WebServer: Failed to stop WebServer. Some features may not function. (" + ex.Message + ")", 2, richTextBox1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("WebServer: Failed to stop WebServer. Some features may not function. (Did not run as Administrator)", 2, richTextBox1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Form Events
|
#region Form Events
|
||||||
async void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
|
async void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
@ -1340,25 +1156,6 @@ namespace NovetusLauncher
|
||||||
GlobalVars.UserConfiguration.ShowServerNotifications = checkBox9.Checked;
|
GlobalVars.UserConfiguration.ShowServerNotifications = checkBox9.Checked;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Functions
|
|
||||||
private void SearchNodes(string SearchText, TreeNode StartNode)
|
|
||||||
{
|
|
||||||
while (StartNode != null)
|
|
||||||
{
|
|
||||||
if (StartNode.Text.ToLower().Contains(SearchText.ToLower()))
|
|
||||||
{
|
|
||||||
CurrentNodeMatches.Add(StartNode);
|
|
||||||
};
|
|
||||||
if (StartNode.Nodes.Count != 0)
|
|
||||||
{
|
|
||||||
SearchNodes(SearchText, StartNode.Nodes[0]);//Recursive Search
|
|
||||||
};
|
|
||||||
StartNode = StartNode.NextNode;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,7 @@ namespace NovetusLauncher
|
||||||
#region LauncherForm - Extended
|
#region LauncherForm - Extended
|
||||||
public partial class LauncherFormExtended : Form
|
public partial class LauncherFormExtended : Form
|
||||||
{
|
{
|
||||||
#region Private Variables
|
LauncherFormShared launcherForm = null;
|
||||||
private DiscordRPC.EventHandlers handlers;
|
|
||||||
private List<TreeNode> CurrentNodeMatches = new List<TreeNode>();
|
|
||||||
private int LastNodeIndex = 0;
|
|
||||||
private string LastSearchText;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructor
|
#region Constructor
|
||||||
public LauncherFormExtended()
|
public LauncherFormExtended()
|
||||||
|
|
@ -30,374 +25,66 @@ namespace NovetusLauncher
|
||||||
_fieldsTreeCache = new TreeView();
|
_fieldsTreeCache = new TreeView();
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
//*vomits*
|
||||||
|
launcherForm = new LauncherFormShared();
|
||||||
|
launcherForm.Parent = this;
|
||||||
|
launcherForm.ConsoleBox = richTextBox1;
|
||||||
|
launcherForm.Tabs = tabControl1;
|
||||||
|
launcherForm.MapDescBox = textBox4;
|
||||||
|
launcherForm.ServerInfo = textBox3;
|
||||||
|
launcherForm.Tree = treeView1;
|
||||||
|
launcherForm._TreeCache = _fieldsTreeCache;
|
||||||
|
launcherForm.TabPageHost = "tabPage2";
|
||||||
|
launcherForm.TabPageMaps = "tabPage4";
|
||||||
|
launcherForm.TabPageClients = "tabPage3";
|
||||||
|
launcherForm.TabPageSaved = "tabPage6";
|
||||||
|
launcherForm.ServerBox = listBox3;
|
||||||
|
launcherForm.PortBox = listBox4;
|
||||||
|
launcherForm.ClientBox = listBox2;
|
||||||
|
launcherForm.SplashLabel = label12;
|
||||||
|
launcherForm.SearchBar = SearchBar;
|
||||||
|
|
||||||
|
|
||||||
Size = new Size(745, 377);
|
Size = new Size(745, 377);
|
||||||
panel2.Size = new Size(646, 272);
|
panel2.Size = new Size(646, 272);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region UPnP
|
|
||||||
public void InitUPnP()
|
|
||||||
{
|
|
||||||
if (GlobalVars.UserConfiguration.UPnP)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
NetFuncs.InitUPnP(DeviceFound, DeviceLost);
|
|
||||||
GlobalFuncs.ConsolePrint("UPnP: Service initialized", 3, richTextBox1);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("UPnP: Unable to initialize UPnP. Reason - " + ex.Message, 2, richTextBox1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void StartUPnP(INatDevice device, Protocol protocol, int port)
|
|
||||||
{
|
|
||||||
if (GlobalVars.UserConfiguration.UPnP)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
NetFuncs.StartUPnP(device, protocol, port);
|
|
||||||
string IP = (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : device.GetExternalIP().ToString());
|
|
||||||
GlobalFuncs.ConsolePrint("UPnP: Port " + port + " opened on '" + IP + "' (" + protocol.ToString() + ")", 3, richTextBox1);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("UPnP: Unable to open port mapping. Reason - " + ex.Message, 2, richTextBox1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void StopUPnP(INatDevice device, Protocol protocol, int port)
|
|
||||||
{
|
|
||||||
if (GlobalVars.UserConfiguration.UPnP)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
NetFuncs.StopUPnP(device, protocol, port);
|
|
||||||
string IP = (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : device.GetExternalIP().ToString());
|
|
||||||
GlobalFuncs.ConsolePrint("UPnP: Port " + port + " closed on '" + IP + "' (" + protocol.ToString() + ")", 3, richTextBox1);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("UPnP: Unable to close port mapping. Reason - " + ex.Message, 2, richTextBox1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DeviceFound(object sender, DeviceEventArgs args)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
INatDevice device = args.Device;
|
|
||||||
string IP = (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : device.GetExternalIP().ToString());
|
|
||||||
GlobalFuncs.ConsolePrint("UPnP: Device '" + IP + "' registered.", 3, richTextBox1);
|
|
||||||
StartUPnP(device, Protocol.Udp, GlobalVars.UserConfiguration.RobloxPort);
|
|
||||||
StartUPnP(device, Protocol.Tcp, GlobalVars.UserConfiguration.RobloxPort);
|
|
||||||
StartUPnP(device, Protocol.Udp, GlobalVars.UserConfiguration.WebServerPort);
|
|
||||||
StartUPnP(device, Protocol.Tcp, GlobalVars.UserConfiguration.WebServerPort);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("UPnP: Unable to register device. Reason - " + ex.Message, 2, richTextBox1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DeviceLost(object sender, DeviceEventArgs args)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
INatDevice device = args.Device;
|
|
||||||
string IP = (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : device.GetExternalIP().ToString());
|
|
||||||
GlobalFuncs.ConsolePrint("UPnP: Device '" + IP + "' disconnected.", 3, richTextBox1);
|
|
||||||
StopUPnP(device, Protocol.Udp, GlobalVars.UserConfiguration.RobloxPort);
|
|
||||||
StopUPnP(device, Protocol.Tcp, GlobalVars.UserConfiguration.RobloxPort);
|
|
||||||
StopUPnP(device, Protocol.Udp, GlobalVars.UserConfiguration.WebServerPort);
|
|
||||||
StopUPnP(device, Protocol.Tcp, GlobalVars.UserConfiguration.WebServerPort);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("UPnP: Unable to disconnect device. Reason - " + ex.Message, 2, richTextBox1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Discord
|
|
||||||
public void ReadyCallback()
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("Discord RPC: Ready", 3, richTextBox1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DisconnectedCallback(int errorCode, string message)
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("Discord RPC: Disconnected. Reason - " + errorCode + ": " + message, 2, richTextBox1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ErrorCallback(int errorCode, string message)
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("Discord RPC: Error. Reason - " + errorCode + ": " + message, 2, richTextBox1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void JoinCallback(string secret)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SpectateCallback(string secret)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RequestCallback(DiscordRPC.JoinRequest request)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void StartDiscord()
|
|
||||||
{
|
|
||||||
if (GlobalVars.UserConfiguration.DiscordPresence)
|
|
||||||
{
|
|
||||||
handlers = new DiscordRPC.EventHandlers();
|
|
||||||
handlers.readyCallback = ReadyCallback;
|
|
||||||
handlers.disconnectedCallback += DisconnectedCallback;
|
|
||||||
handlers.errorCallback += ErrorCallback;
|
|
||||||
handlers.joinCallback += JoinCallback;
|
|
||||||
handlers.spectateCallback += SpectateCallback;
|
|
||||||
handlers.requestCallback += RequestCallback;
|
|
||||||
DiscordRPC.Initialize(GlobalVars.appid, ref handlers, true, "");
|
|
||||||
|
|
||||||
GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InLauncher, "", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Web Server
|
|
||||||
//udp clients will connect to the web server alongside the game.
|
|
||||||
void StartWebServer()
|
|
||||||
{
|
|
||||||
if (SecurityFuncs.IsElevated)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
GlobalVars.WebServer = new SimpleHTTPServer(GlobalPaths.DataPath, GlobalVars.UserConfiguration.WebServerPort);
|
|
||||||
GlobalFuncs.ConsolePrint("WebServer: Server is running on port: " + GlobalVars.WebServer.Port.ToString(), 3, richTextBox1);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("WebServer: Failed to launch WebServer. Some features may not function. (" + ex.Message + ")", 2, richTextBox1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("WebServer: Failed to launch WebServer. Some features may not function. (Did not run as Administrator)", 2, richTextBox1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StopWebServer()
|
|
||||||
{
|
|
||||||
if (SecurityFuncs.IsElevated)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("WebServer: Server has stopped on port: " + GlobalVars.WebServer.Port.ToString(), 2, richTextBox1);
|
|
||||||
GlobalVars.WebServer.Stop();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("WebServer: Failed to stop WebServer. Some features may not function. (" + ex.Message + ")", 2, richTextBox1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("WebServer: Failed to stop WebServer. Some features may not function. (Did not run as Administrator)", 2, richTextBox1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Form Events
|
#region Form Events
|
||||||
async void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
|
async void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
switch (tabControl1.SelectedTab)
|
launcherForm.ChangeTabs();
|
||||||
{
|
|
||||||
case TabPage pg2 when pg2 == tabControl1.TabPages["tabPage2"]:
|
|
||||||
treeView1.Nodes.Clear();
|
|
||||||
_fieldsTreeCache.Nodes.Clear();
|
|
||||||
textBox4.Text = "";
|
|
||||||
listBox2.Items.Clear();
|
|
||||||
listBox3.Items.Clear();
|
|
||||||
listBox4.Items.Clear();
|
|
||||||
//since we are async, DO THESE first or we'll clear out random stuff.
|
|
||||||
textBox3.Text = "Loading...";
|
|
||||||
string IP = await SecurityFuncs.GetExternalIPAddressAsync();
|
|
||||||
textBox3.Text = "";
|
|
||||||
string[] lines1 = {
|
|
||||||
SecurityFuncs.Base64Encode((!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : IP)),
|
|
||||||
SecurityFuncs.Base64Encode(GlobalVars.UserConfiguration.RobloxPort.ToString()),
|
|
||||||
SecurityFuncs.Base64Encode(GlobalVars.UserConfiguration.SelectedClient)
|
|
||||||
};
|
|
||||||
string URI = "novetus://" + SecurityFuncs.Base64Encode(string.Join("|", lines1), true);
|
|
||||||
string[] lines2 = {
|
|
||||||
SecurityFuncs.Base64Encode("localhost"),
|
|
||||||
SecurityFuncs.Base64Encode(GlobalVars.UserConfiguration.RobloxPort.ToString()),
|
|
||||||
SecurityFuncs.Base64Encode(GlobalVars.UserConfiguration.SelectedClient)
|
|
||||||
};
|
|
||||||
string URI2 = "novetus://" + SecurityFuncs.Base64Encode(string.Join("|", lines2), true);
|
|
||||||
string[] text = {
|
|
||||||
"Client: " + GlobalVars.UserConfiguration.SelectedClient,
|
|
||||||
"IP: " + (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : IP),
|
|
||||||
"Port: " + GlobalVars.UserConfiguration.RobloxPort.ToString(),
|
|
||||||
"Map: " + GlobalVars.UserConfiguration.Map,
|
|
||||||
"Players: " + GlobalVars.UserConfiguration.PlayerLimit,
|
|
||||||
"Version: Novetus " + GlobalVars.ProgramInformation.Version,
|
|
||||||
"Online URI Link:",
|
|
||||||
URI,
|
|
||||||
"Local URI Link:",
|
|
||||||
URI2,
|
|
||||||
GlobalVars.IsWebServerOn ? "Web Server URL:" : "",
|
|
||||||
GlobalVars.IsWebServerOn ? "http://" + (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : IP) + ":" + GlobalVars.WebServer.Port.ToString() : "",
|
|
||||||
GlobalVars.IsWebServerOn ? "Local Web Server URL:" : "",
|
|
||||||
GlobalVars.IsWebServerOn ? "http://localhost:" + (GlobalVars.WebServer.Port.ToString()).ToString() : ""
|
|
||||||
};
|
|
||||||
|
|
||||||
foreach (string str in text)
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrWhiteSpace(str))
|
|
||||||
{
|
|
||||||
textBox3.AppendText(str + Environment.NewLine);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
textBox3.SelectionStart = 0;
|
|
||||||
textBox3.ScrollToCaret();
|
|
||||||
break;
|
|
||||||
case TabPage pg4 when pg4 == tabControl1.TabPages["tabPage4"]:
|
|
||||||
string mapdir = GlobalPaths.MapsDir;
|
|
||||||
string[] fileexts = new string[] { ".rbxl", ".rbxlx" };
|
|
||||||
TreeNodeHelper.ListDirectory(treeView1, mapdir, fileexts);
|
|
||||||
TreeNodeHelper.CopyNodes(treeView1.Nodes, _fieldsTreeCache.Nodes);
|
|
||||||
treeView1.SelectedNode = TreeNodeHelper.SearchTreeView(GlobalVars.UserConfiguration.Map, treeView1.Nodes);
|
|
||||||
treeView1.Focus();
|
|
||||||
textBox3.Text = "";
|
|
||||||
listBox2.Items.Clear();
|
|
||||||
listBox3.Items.Clear();
|
|
||||||
listBox4.Items.Clear();
|
|
||||||
break;
|
|
||||||
case TabPage pg3 when pg3 == tabControl1.TabPages["tabPage3"]:
|
|
||||||
string clientdir = GlobalPaths.ClientDir;
|
|
||||||
DirectoryInfo dinfo = new DirectoryInfo(clientdir);
|
|
||||||
DirectoryInfo[] Dirs = dinfo.GetDirectories();
|
|
||||||
foreach (DirectoryInfo dir in Dirs)
|
|
||||||
{
|
|
||||||
listBox2.Items.Add(dir.Name);
|
|
||||||
}
|
|
||||||
listBox2.SelectedItem = GlobalVars.UserConfiguration.SelectedClient;
|
|
||||||
treeView1.Nodes.Clear();
|
|
||||||
_fieldsTreeCache.Nodes.Clear();
|
|
||||||
textBox4.Text = "";
|
|
||||||
textBox3.Text = "";
|
|
||||||
listBox3.Items.Clear();
|
|
||||||
listBox4.Items.Clear();
|
|
||||||
break;
|
|
||||||
case TabPage pg6 when pg6 == tabControl1.TabPages["tabPage6"]:
|
|
||||||
string[] lines_server = File.ReadAllLines(GlobalPaths.ConfigDir + "\\servers.txt");
|
|
||||||
string[] lines_ports = File.ReadAllLines(GlobalPaths.ConfigDir + "\\ports.txt");
|
|
||||||
listBox3.Items.AddRange(lines_server);
|
|
||||||
listBox4.Items.AddRange(lines_ports);
|
|
||||||
treeView1.Nodes.Clear();
|
|
||||||
_fieldsTreeCache.Nodes.Clear();
|
|
||||||
textBox4.Text = "";
|
|
||||||
textBox3.Text = "";
|
|
||||||
listBox2.Items.Clear();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
treeView1.Nodes.Clear();
|
|
||||||
_fieldsTreeCache.Nodes.Clear();
|
|
||||||
textBox4.Text = "";
|
|
||||||
textBox3.Text = "";
|
|
||||||
listBox2.Items.Clear();
|
|
||||||
listBox3.Items.Clear();
|
|
||||||
listBox4.Items.Clear();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button1Click(object sender, EventArgs e)
|
void Button1Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (GlobalVars.LocalPlayMode)
|
launcherForm.StartGame(ScriptType.Client);
|
||||||
{
|
}
|
||||||
GeneratePlayerID();
|
|
||||||
GenerateTripcode();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WriteConfigValues();
|
|
||||||
}
|
|
||||||
|
|
||||||
StartClient();
|
|
||||||
|
|
||||||
if (GlobalVars.UserConfiguration.CloseOnLaunch)
|
|
||||||
{
|
|
||||||
Visible = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Button2Click(object sender, EventArgs e)
|
void Button2Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
WriteConfigValues();
|
launcherForm.StartGame(ScriptType.Server);
|
||||||
StartServer(false);
|
}
|
||||||
|
|
||||||
if (GlobalVars.UserConfiguration.CloseOnLaunch)
|
|
||||||
{
|
|
||||||
Visible = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Button3Click(object sender, EventArgs e)
|
void Button3Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
DialogResult result = MessageBox.Show("If you want to test out your place, you will have to save your place in Novetus's map folder, then launch your place in Play Solo.", "Novetus - Launch ROBLOX Studio", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
|
launcherForm.StartGame(ScriptType.Studio);
|
||||||
if (result == DialogResult.Cancel)
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
WriteConfigValues();
|
|
||||||
StartStudio(false);
|
|
||||||
if (GlobalVars.UserConfiguration.CloseOnLaunch)
|
|
||||||
{
|
|
||||||
Visible = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Button18Click(object sender, EventArgs e)
|
void Button18Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
WriteConfigValues();
|
launcherForm.StartGame(ScriptType.Server, true);
|
||||||
StartServer(true);
|
|
||||||
|
|
||||||
if (GlobalVars.UserConfiguration.CloseOnLaunch)
|
|
||||||
{
|
|
||||||
Visible = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button19Click(object sender, EventArgs e)
|
void Button19Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
WriteConfigValues();
|
launcherForm.StartGame(ScriptType.Solo);
|
||||||
StartSolo();
|
|
||||||
|
|
||||||
if (GlobalVars.UserConfiguration.CloseOnLaunch)
|
|
||||||
{
|
|
||||||
Visible = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void button35_Click(object sender, EventArgs e)
|
private void button35_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
DialogResult result = MessageBox.Show("If you want to test out your place, you will have to save your place in Novetus's map folder, then launch your place in Play Solo.", "Novetus - Launch ROBLOX Studio", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
|
launcherForm.StartGame(ScriptType.Studio, false, true);
|
||||||
if (result == DialogResult.Cancel)
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
WriteConfigValues();
|
|
||||||
StartStudio(true);
|
|
||||||
if (GlobalVars.UserConfiguration.CloseOnLaunch)
|
|
||||||
{
|
|
||||||
Visible = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainFormLoad(object sender, EventArgs e)
|
void MainFormLoad(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
@ -814,37 +501,9 @@ namespace NovetusLauncher
|
||||||
listBox4.Items.AddRange(lines_ports);
|
listBox4.Items.AddRange(lines_ports);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void richTextBox1_KeyDown(object sender, KeyEventArgs e)
|
void richTextBox1_KeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
//Command proxy
|
launcherForm.ProcessConsole(e);
|
||||||
|
|
||||||
int totalLines = richTextBox1.Lines.Length;
|
|
||||||
if (totalLines > 0)
|
|
||||||
{
|
|
||||||
string lastLine = richTextBox1.Lines[totalLines - 1];
|
|
||||||
|
|
||||||
if (e.KeyCode == Keys.Enter)
|
|
||||||
{
|
|
||||||
richTextBox1.AppendText(Environment.NewLine);
|
|
||||||
ConsoleProcessCommands(lastLine);
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( e.Modifiers == Keys.Control )
|
|
||||||
{
|
|
||||||
switch(e.KeyCode)
|
|
||||||
{
|
|
||||||
case Keys.X:
|
|
||||||
case Keys.Z:
|
|
||||||
e.Handled = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResetConfigValues()
|
void ResetConfigValues()
|
||||||
|
|
@ -865,178 +524,6 @@ namespace NovetusLauncher
|
||||||
WriteConfigValues();
|
WriteConfigValues();
|
||||||
ReadConfigValues();
|
ReadConfigValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartClient()
|
|
||||||
{
|
|
||||||
GlobalFuncs.LaunchRBXClient(ScriptType.Client, false, true, new EventHandler(ClientExited), richTextBox1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StartSolo()
|
|
||||||
{
|
|
||||||
GlobalFuncs.LaunchRBXClient(ScriptType.Solo, false, false, new EventHandler(ClientExited), richTextBox1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StartServer(bool no3d)
|
|
||||||
{
|
|
||||||
GlobalFuncs.LaunchRBXClient(ScriptType.Server, no3d, false, new EventHandler(ServerExited), richTextBox1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StartStudio(bool nomap)
|
|
||||||
{
|
|
||||||
GlobalFuncs.LaunchRBXClient(ScriptType.Studio, false, nomap, new EventHandler(ClientExited), richTextBox1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StartEasterEgg()
|
|
||||||
{
|
|
||||||
GlobalFuncs.LaunchRBXClient(ScriptType.EasterEgg, false, false, new EventHandler(EasterEggExited), richTextBox1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClientExited(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InLauncher, "");
|
|
||||||
if (GlobalVars.UserConfiguration.CloseOnLaunch)
|
|
||||||
{
|
|
||||||
Visible = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServerExited(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (GlobalVars.UserConfiguration.CloseOnLaunch)
|
|
||||||
{
|
|
||||||
Visible = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void EasterEggExited(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InLauncher, "");
|
|
||||||
label12.Text = LocalVars.prevsplash;
|
|
||||||
if (GlobalVars.UserConfiguration.CloseOnLaunch)
|
|
||||||
{
|
|
||||||
Visible = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConsoleProcessCommands(string cmd)
|
|
||||||
{
|
|
||||||
switch(cmd)
|
|
||||||
{
|
|
||||||
case string server3d when string.Compare(server3d, "server 3d", true, CultureInfo.InvariantCulture) == 0:
|
|
||||||
StartServer(false);
|
|
||||||
break;
|
|
||||||
case string serverno3d when string.Compare(serverno3d, "server no3d", true, CultureInfo.InvariantCulture) == 0:
|
|
||||||
StartServer(false);
|
|
||||||
break;
|
|
||||||
case string client when string.Compare(client, "client", true, CultureInfo.InvariantCulture) == 0:
|
|
||||||
StartClient();
|
|
||||||
break;
|
|
||||||
case string solo when string.Compare(solo, "solo", true, CultureInfo.InvariantCulture) == 0:
|
|
||||||
StartSolo();
|
|
||||||
break;
|
|
||||||
case string studiomap when string.Compare(studiomap, "studio map", true, CultureInfo.InvariantCulture) == 0:
|
|
||||||
StartStudio(false);
|
|
||||||
break;
|
|
||||||
case string studionomap when string.Compare(studionomap, "studio nomap", true, CultureInfo.InvariantCulture) == 0:
|
|
||||||
StartStudio(true);
|
|
||||||
break;
|
|
||||||
case string configsave when string.Compare(configsave, "config save", true, CultureInfo.InvariantCulture) == 0:
|
|
||||||
WriteConfigValues();
|
|
||||||
break;
|
|
||||||
case string configload when string.Compare(configload, "config load", true, CultureInfo.InvariantCulture) == 0:
|
|
||||||
ReadConfigValues();
|
|
||||||
break;
|
|
||||||
case string configreset when string.Compare(configreset, "config reset", true, CultureInfo.InvariantCulture) == 0:
|
|
||||||
ResetConfigValues();
|
|
||||||
break;
|
|
||||||
case string help when string.Compare(help, "help", true, CultureInfo.InvariantCulture) == 0:
|
|
||||||
ConsoleHelp();
|
|
||||||
break;
|
|
||||||
case string sdk when string.Compare(sdk, "sdk", true, CultureInfo.InvariantCulture) == 0:
|
|
||||||
LoadLauncher();
|
|
||||||
break;
|
|
||||||
case string webserverstart when string.Compare(webserverstart, "webserver start", true, CultureInfo.InvariantCulture) == 0:
|
|
||||||
if (!GlobalVars.IsWebServerOn)
|
|
||||||
{
|
|
||||||
StartWebServer();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("WebServer: There is already a web server on.", 2, richTextBox1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case string webserverstop when string.Compare(webserverstop, "webserver stop", true, CultureInfo.InvariantCulture) == 0:
|
|
||||||
if (GlobalVars.IsWebServerOn)
|
|
||||||
{
|
|
||||||
StopWebServer();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("WebServer: There is no web server on.", 2, richTextBox1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case string webserverrestart when string.Compare(webserverrestart, "webserver restart", true, CultureInfo.InvariantCulture) == 0:
|
|
||||||
try
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("WebServer: Restarting...", 4, richTextBox1);
|
|
||||||
StopWebServer();
|
|
||||||
StartWebServer();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("WebServer: Cannot restart web server. (" + ex.Message + ")", 2, richTextBox1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case string dlldeleteon when string.Compare(dlldeleteon, "dlldelete on", true, CultureInfo.InvariantCulture) == 0:
|
|
||||||
GlobalVars.UserConfiguration.DisableReshadeDelete = false;
|
|
||||||
GlobalFuncs.ConsolePrint("ReShade DLL deletion enabled.", 4, richTextBox1);
|
|
||||||
break;
|
|
||||||
case string dlldeleteoff when string.Compare(dlldeleteoff, "dlldelete off", true, CultureInfo.InvariantCulture) == 0:
|
|
||||||
GlobalVars.UserConfiguration.DisableReshadeDelete = true;
|
|
||||||
GlobalFuncs.ConsolePrint("ReShade DLL deletion disabled.", 4, richTextBox1);
|
|
||||||
break;
|
|
||||||
case string important when string.Compare(important, LocalVars.important, true, CultureInfo.InvariantCulture) == 0:
|
|
||||||
GlobalVars.AdminMode = true;
|
|
||||||
GlobalFuncs.ConsolePrint("ADMIN MODE ENABLED.", 4, richTextBox1);
|
|
||||||
GlobalFuncs.ConsolePrint("YOU ARE GOD.", 2, richTextBox1);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
GlobalFuncs.ConsolePrint("ERROR 3 - Command is either not registered or valid", 2, richTextBox1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoadLauncher()
|
|
||||||
{
|
|
||||||
NovetusSDK im = new NovetusSDK();
|
|
||||||
im.Show();
|
|
||||||
GlobalFuncs.ConsolePrint("Novetus SDK Launcher Loaded.", 4, richTextBox1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConsoleHelp()
|
|
||||||
{
|
|
||||||
GlobalFuncs.ConsolePrint("Help:", 3, richTextBox1);
|
|
||||||
GlobalFuncs.ConsolePrint("---------", 1, richTextBox1);
|
|
||||||
GlobalFuncs.ConsolePrint("= client | Launches client with launcher settings", 4, richTextBox1);
|
|
||||||
GlobalFuncs.ConsolePrint("= solo | Launches client in Play Solo mode with launcher settings", 4, richTextBox1);
|
|
||||||
GlobalFuncs.ConsolePrint("= server 3d | Launches server with launcher settings", 4, richTextBox1);
|
|
||||||
GlobalFuncs.ConsolePrint("= server no3d | Launches server in NoGraphics mode with launcher settings", 4, richTextBox1);
|
|
||||||
GlobalFuncs.ConsolePrint("= studio map | Launches Roblox Studio with the selected map", 4, richTextBox1);
|
|
||||||
GlobalFuncs.ConsolePrint("= studio nomap | Launches Roblox Studio without the selected map", 4, richTextBox1);
|
|
||||||
GlobalFuncs.ConsolePrint("= sdk | Launches the Novetus SDK Launcher", 4, richTextBox1);
|
|
||||||
GlobalFuncs.ConsolePrint("---------", 1, richTextBox1);
|
|
||||||
GlobalFuncs.ConsolePrint("= config save | Saves the config file", 4, richTextBox1);
|
|
||||||
GlobalFuncs.ConsolePrint("= config load | Reloads the config file", 4, richTextBox1);
|
|
||||||
GlobalFuncs.ConsolePrint("= config reset | Resets the config file", 4, richTextBox1);
|
|
||||||
GlobalFuncs.ConsolePrint("---------", 1, richTextBox1);
|
|
||||||
GlobalFuncs.ConsolePrint("= webserver restart | Restarts the web server", 4, richTextBox1);
|
|
||||||
GlobalFuncs.ConsolePrint("= webserver stop | Stops a web server if there is one on.", 4, richTextBox1);
|
|
||||||
GlobalFuncs.ConsolePrint("= webserver start | Starts a web server if there isn't one on yet.", 4, richTextBox1);
|
|
||||||
GlobalFuncs.ConsolePrint("---------", 1, richTextBox1);
|
|
||||||
GlobalFuncs.ConsolePrint("= dlldelete off | Turn off the deletion of opengl32.dll when ReShade is off.", 4, richTextBox1);
|
|
||||||
GlobalFuncs.ConsolePrint("= dlldelete on | Turn on the deletion of opengl32.dll when ReShade is off.", 4, richTextBox1);
|
|
||||||
GlobalFuncs.ConsolePrint("---------", 1, richTextBox1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Button21Click(object sender, EventArgs e)
|
void Button21Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
@ -1288,39 +775,8 @@ namespace NovetusLauncher
|
||||||
|
|
||||||
private void label8_Click(object sender, EventArgs e)
|
private void label8_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (LocalVars.Clicks < 10)
|
launcherForm.EasterEggLogic();
|
||||||
{
|
}
|
||||||
LocalVars.Clicks += 1;
|
|
||||||
|
|
||||||
switch(LocalVars.Clicks)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
label12.Text = "Hi " + GlobalVars.UserConfiguration.PlayerName + "!";
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
label12.Text = "How are you doing today?";
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
label12.Text = "I just wanted to say something.";
|
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
label12.Text = "Just wait a little on the last click, OK?";
|
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
label12.Text = "Thank you. <3";
|
|
||||||
WriteConfigValues();
|
|
||||||
StartEasterEgg();
|
|
||||||
|
|
||||||
if (GlobalVars.UserConfiguration.CloseOnLaunch)
|
|
||||||
{
|
|
||||||
Visible = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkBox5_CheckedChanged(object sender, EventArgs e)
|
private void checkBox5_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
@ -1416,54 +872,9 @@ namespace NovetusLauncher
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FINALLY. https://stackoverflow.com/questions/11530643/treeview-search
|
|
||||||
|
|
||||||
private void SearchButton_Click(object sender, EventArgs e)
|
private void SearchButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
string searchText = SearchBar.Text;
|
launcherForm.SearchMaps();
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(searchText))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (LastSearchText != searchText)
|
|
||||||
{
|
|
||||||
//It's a new Search
|
|
||||||
CurrentNodeMatches.Clear();
|
|
||||||
LastSearchText = searchText;
|
|
||||||
LastNodeIndex = 0;
|
|
||||||
SearchNodes(searchText, treeView1.Nodes[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LastNodeIndex >= 0 && CurrentNodeMatches.Count > 0 && LastNodeIndex < CurrentNodeMatches.Count)
|
|
||||||
{
|
|
||||||
TreeNode selectedNode = CurrentNodeMatches[LastNodeIndex];
|
|
||||||
LastNodeIndex++;
|
|
||||||
treeView1.SelectedNode = selectedNode;
|
|
||||||
treeView1.SelectedNode.Expand();
|
|
||||||
treeView1.Select();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//It's a new Search
|
|
||||||
CurrentNodeMatches.Clear();
|
|
||||||
LastSearchText = searchText;
|
|
||||||
LastNodeIndex = 0;
|
|
||||||
SearchNodes(searchText, treeView1.Nodes[0]);
|
|
||||||
TreeNode selectedNode = CurrentNodeMatches[LastNodeIndex];
|
|
||||||
LastNodeIndex++;
|
|
||||||
treeView1.SelectedNode = selectedNode;
|
|
||||||
treeView1.SelectedNode.Expand();
|
|
||||||
treeView1.Select();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
MessageBox.Show("The map '" + searchText + "' cannot be found. Please try another term.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void button36_Click(object sender, EventArgs e)
|
private void button36_Click(object sender, EventArgs e)
|
||||||
|
|
@ -1511,25 +922,6 @@ namespace NovetusLauncher
|
||||||
GlobalVars.UserConfiguration.ShowServerNotifications = checkBox9.Checked;
|
GlobalVars.UserConfiguration.ShowServerNotifications = checkBox9.Checked;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Functions
|
|
||||||
private void SearchNodes(string SearchText, TreeNode StartNode)
|
|
||||||
{
|
|
||||||
while (StartNode != null)
|
|
||||||
{
|
|
||||||
if (StartNode.Text.ToLower().Contains(SearchText.ToLower()))
|
|
||||||
{
|
|
||||||
CurrentNodeMatches.Add(StartNode);
|
|
||||||
};
|
|
||||||
if (StartNode.Nodes.Count != 0)
|
|
||||||
{
|
|
||||||
SearchNodes(SearchText, StartNode.Nodes[0]);//Recursive Search
|
|
||||||
};
|
|
||||||
StartNode = StartNode.NextNode;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,641 @@
|
||||||
|
#region Usings
|
||||||
|
using Mono.Nat;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace NovetusLauncher
|
||||||
|
{
|
||||||
|
public class LauncherFormShared
|
||||||
|
{
|
||||||
|
#region Variables
|
||||||
|
public DiscordRPC.EventHandlers handlers;
|
||||||
|
public List<TreeNode> CurrentNodeMatches = new List<TreeNode>();
|
||||||
|
public int LastNodeIndex = 0;
|
||||||
|
public string LastSearchText;
|
||||||
|
bool isWPF = false;
|
||||||
|
|
||||||
|
//CONTROLS
|
||||||
|
public Form Parent = null;
|
||||||
|
public RichTextBox ConsoleBox = null;
|
||||||
|
public TabControl Tabs = null;
|
||||||
|
public TextBox MapDescBox, ServerInfo, SearchBar = null;
|
||||||
|
public TreeView Tree, _TreeCache = null;
|
||||||
|
public ListBox ServerBox, PortBox, ClientBox = null;
|
||||||
|
public Label SplashLabel = null;
|
||||||
|
public string TabPageHost, TabPageMaps, TabPageClients, TabPageSaved = "";
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public LauncherFormShared(bool WPF = false)
|
||||||
|
{
|
||||||
|
//TODO: add WPF support...
|
||||||
|
isWPF = WPF;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region UPnP
|
||||||
|
public void InitUPnP()
|
||||||
|
{
|
||||||
|
if (GlobalVars.UserConfiguration.UPnP)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
NetFuncs.InitUPnP(DeviceFound, DeviceLost);
|
||||||
|
GlobalFuncs.ConsolePrint("UPnP: Service initialized", 3, ConsoleBox);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalFuncs.ConsolePrint("UPnP: Unable to initialize UPnP. Reason - " + ex.Message, 2, ConsoleBox);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StartUPnP(INatDevice device, Protocol protocol, int port)
|
||||||
|
{
|
||||||
|
if (GlobalVars.UserConfiguration.UPnP)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
NetFuncs.StartUPnP(device, protocol, port);
|
||||||
|
string IP = (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : device.GetExternalIP().ToString());
|
||||||
|
GlobalFuncs.ConsolePrint("UPnP: Port " + port + " opened on '" + IP + "' (" + protocol.ToString() + ")", 3, ConsoleBox);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalFuncs.ConsolePrint("UPnP: Unable to open port mapping. Reason - " + ex.Message, 2, ConsoleBox);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StopUPnP(INatDevice device, Protocol protocol, int port)
|
||||||
|
{
|
||||||
|
if (GlobalVars.UserConfiguration.UPnP)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
NetFuncs.StopUPnP(device, protocol, port);
|
||||||
|
string IP = (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : device.GetExternalIP().ToString());
|
||||||
|
GlobalFuncs.ConsolePrint("UPnP: Port " + port + " closed on '" + IP + "' (" + protocol.ToString() + ")", 3, ConsoleBox);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalFuncs.ConsolePrint("UPnP: Unable to close port mapping. Reason - " + ex.Message, 2, ConsoleBox);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeviceFound(object sender, DeviceEventArgs args)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
INatDevice device = args.Device;
|
||||||
|
string IP = (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : device.GetExternalIP().ToString());
|
||||||
|
GlobalFuncs.ConsolePrint("UPnP: Device '" + IP + "' registered.", 3, ConsoleBox);
|
||||||
|
StartUPnP(device, Protocol.Udp, GlobalVars.UserConfiguration.RobloxPort);
|
||||||
|
StartUPnP(device, Protocol.Tcp, GlobalVars.UserConfiguration.RobloxPort);
|
||||||
|
StartUPnP(device, Protocol.Udp, GlobalVars.UserConfiguration.WebServerPort);
|
||||||
|
StartUPnP(device, Protocol.Tcp, GlobalVars.UserConfiguration.WebServerPort);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalFuncs.ConsolePrint("UPnP: Unable to register device. Reason - " + ex.Message, 2, ConsoleBox);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeviceLost(object sender, DeviceEventArgs args)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
INatDevice device = args.Device;
|
||||||
|
string IP = (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : device.GetExternalIP().ToString());
|
||||||
|
GlobalFuncs.ConsolePrint("UPnP: Device '" + IP + "' disconnected.", 3, ConsoleBox);
|
||||||
|
StopUPnP(device, Protocol.Udp, GlobalVars.UserConfiguration.RobloxPort);
|
||||||
|
StopUPnP(device, Protocol.Tcp, GlobalVars.UserConfiguration.RobloxPort);
|
||||||
|
StopUPnP(device, Protocol.Udp, GlobalVars.UserConfiguration.WebServerPort);
|
||||||
|
StopUPnP(device, Protocol.Tcp, GlobalVars.UserConfiguration.WebServerPort);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalFuncs.ConsolePrint("UPnP: Unable to disconnect device. Reason - " + ex.Message, 2, ConsoleBox);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Discord
|
||||||
|
public void ReadyCallback()
|
||||||
|
{
|
||||||
|
GlobalFuncs.ConsolePrint("Discord RPC: Ready", 3, ConsoleBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DisconnectedCallback(int errorCode, string message)
|
||||||
|
{
|
||||||
|
GlobalFuncs.ConsolePrint("Discord RPC: Disconnected. Reason - " + errorCode + ": " + message, 2, ConsoleBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ErrorCallback(int errorCode, string message)
|
||||||
|
{
|
||||||
|
GlobalFuncs.ConsolePrint("Discord RPC: Error. Reason - " + errorCode + ": " + message, 2, ConsoleBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void JoinCallback(string secret)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SpectateCallback(string secret)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RequestCallback(DiscordRPC.JoinRequest request)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StartDiscord()
|
||||||
|
{
|
||||||
|
if (GlobalVars.UserConfiguration.DiscordPresence)
|
||||||
|
{
|
||||||
|
handlers = new DiscordRPC.EventHandlers();
|
||||||
|
handlers.readyCallback = ReadyCallback;
|
||||||
|
handlers.disconnectedCallback += DisconnectedCallback;
|
||||||
|
handlers.errorCallback += ErrorCallback;
|
||||||
|
handlers.joinCallback += JoinCallback;
|
||||||
|
handlers.spectateCallback += SpectateCallback;
|
||||||
|
handlers.requestCallback += RequestCallback;
|
||||||
|
DiscordRPC.Initialize(GlobalVars.appid, ref handlers, true, "");
|
||||||
|
|
||||||
|
GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InLauncher, "", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Web Server
|
||||||
|
//udp clients will connect to the web server alongside the game.
|
||||||
|
public void StartWebServer()
|
||||||
|
{
|
||||||
|
if (SecurityFuncs.IsElevated)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
GlobalVars.WebServer = new SimpleHTTPServer(GlobalPaths.DataPath, GlobalVars.UserConfiguration.WebServerPort);
|
||||||
|
GlobalFuncs.ConsolePrint("WebServer: Server is running on port: " + GlobalVars.WebServer.Port.ToString(), 3, ConsoleBox);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalFuncs.ConsolePrint("WebServer: Failed to launch WebServer. Some features may not function. (" + ex.Message + ")", 2, ConsoleBox);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GlobalFuncs.ConsolePrint("WebServer: Failed to launch WebServer. Some features may not function. (Did not run as Administrator)", 2, ConsoleBox);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StopWebServer()
|
||||||
|
{
|
||||||
|
if (SecurityFuncs.IsElevated)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
GlobalFuncs.ConsolePrint("WebServer: Server has stopped on port: " + GlobalVars.WebServer.Port.ToString(), 2, ConsoleBox);
|
||||||
|
GlobalVars.WebServer.Stop();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalFuncs.ConsolePrint("WebServer: Failed to stop WebServer. Some features may not function. (" + ex.Message + ")", 2, ConsoleBox);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GlobalFuncs.ConsolePrint("WebServer: Failed to stop WebServer. Some features may not function. (Did not run as Administrator)", 2, ConsoleBox);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Form Event Functions
|
||||||
|
public async void ChangeTabs()
|
||||||
|
{
|
||||||
|
switch (Tabs.SelectedTab)
|
||||||
|
{
|
||||||
|
case TabPage pg2 when pg2 == Tabs.TabPages[TabPageHost]:
|
||||||
|
Tree.Nodes.Clear();
|
||||||
|
_TreeCache.Nodes.Clear();
|
||||||
|
MapDescBox.Text = "";
|
||||||
|
ClientBox.Items.Clear();
|
||||||
|
ServerBox.Items.Clear();
|
||||||
|
PortBox.Items.Clear();
|
||||||
|
//since we are async, DO THESE first or we'll clear out random stuff.
|
||||||
|
ServerInfo.Text = "Loading...";
|
||||||
|
string IP = await SecurityFuncs.GetExternalIPAddressAsync();
|
||||||
|
ServerInfo.Text = "";
|
||||||
|
string[] lines1 = {
|
||||||
|
SecurityFuncs.Base64Encode((!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : IP)),
|
||||||
|
SecurityFuncs.Base64Encode(GlobalVars.UserConfiguration.RobloxPort.ToString()),
|
||||||
|
SecurityFuncs.Base64Encode(GlobalVars.UserConfiguration.SelectedClient)
|
||||||
|
};
|
||||||
|
string URI = "novetus://" + SecurityFuncs.Base64Encode(string.Join("|", lines1), true);
|
||||||
|
string[] lines2 = {
|
||||||
|
SecurityFuncs.Base64Encode("localhost"),
|
||||||
|
SecurityFuncs.Base64Encode(GlobalVars.UserConfiguration.RobloxPort.ToString()),
|
||||||
|
SecurityFuncs.Base64Encode(GlobalVars.UserConfiguration.SelectedClient)
|
||||||
|
};
|
||||||
|
string URI2 = "novetus://" + SecurityFuncs.Base64Encode(string.Join("|", lines2), true);
|
||||||
|
string[] text = {
|
||||||
|
"Client: " + GlobalVars.UserConfiguration.SelectedClient,
|
||||||
|
"IP: " + (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : IP),
|
||||||
|
"Port: " + GlobalVars.UserConfiguration.RobloxPort.ToString(),
|
||||||
|
"Map: " + GlobalVars.UserConfiguration.Map,
|
||||||
|
"Players: " + GlobalVars.UserConfiguration.PlayerLimit,
|
||||||
|
"Version: Novetus " + GlobalVars.ProgramInformation.Version,
|
||||||
|
"Online URI Link:",
|
||||||
|
URI,
|
||||||
|
"Local URI Link:",
|
||||||
|
URI2,
|
||||||
|
GlobalVars.IsWebServerOn ? "Web Server URL:" : "",
|
||||||
|
GlobalVars.IsWebServerOn ? "http://" + (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : IP) + ":" + GlobalVars.WebServer.Port.ToString() : "",
|
||||||
|
GlobalVars.IsWebServerOn ? "Local Web Server URL:" : "",
|
||||||
|
GlobalVars.IsWebServerOn ? "http://localhost:" + (GlobalVars.WebServer.Port.ToString()).ToString() : ""
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (string str in text)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(str))
|
||||||
|
{
|
||||||
|
ServerInfo.AppendText(str + Environment.NewLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ServerInfo.SelectionStart = 0;
|
||||||
|
ServerInfo.ScrollToCaret();
|
||||||
|
break;
|
||||||
|
case TabPage pg3 when pg3 == Tabs.TabPages[TabPageClients]:
|
||||||
|
string clientdir = GlobalPaths.ClientDir;
|
||||||
|
DirectoryInfo dinfo = new DirectoryInfo(clientdir);
|
||||||
|
DirectoryInfo[] Dirs = dinfo.GetDirectories();
|
||||||
|
foreach (DirectoryInfo dir in Dirs)
|
||||||
|
{
|
||||||
|
ClientBox.Items.Add(dir.Name);
|
||||||
|
}
|
||||||
|
ClientBox.SelectedItem = GlobalVars.UserConfiguration.SelectedClient;
|
||||||
|
Tree.Nodes.Clear();
|
||||||
|
_TreeCache.Nodes.Clear();
|
||||||
|
MapDescBox.Text = "";
|
||||||
|
ServerInfo.Text = "";
|
||||||
|
ServerBox.Items.Clear();
|
||||||
|
PortBox.Items.Clear();
|
||||||
|
break;
|
||||||
|
case TabPage pg4 when pg4 == Tabs.TabPages[TabPageMaps]:
|
||||||
|
string mapdir = GlobalPaths.MapsDir;
|
||||||
|
string[] fileexts = new string[] { ".rbxl", ".rbxlx" };
|
||||||
|
TreeNodeHelper.ListDirectory(Tree, mapdir, fileexts);
|
||||||
|
TreeNodeHelper.CopyNodes(Tree.Nodes, _TreeCache.Nodes);
|
||||||
|
Tree.SelectedNode = TreeNodeHelper.SearchTreeView(GlobalVars.UserConfiguration.Map, Tree.Nodes);
|
||||||
|
Tree.Focus();
|
||||||
|
ServerInfo.Text = "";
|
||||||
|
ClientBox.Items.Clear();
|
||||||
|
ServerBox.Items.Clear();
|
||||||
|
PortBox.Items.Clear();
|
||||||
|
break;
|
||||||
|
case TabPage pg6 when pg6 == Tabs.TabPages[TabPageSaved]:
|
||||||
|
string[] lines_server = File.ReadAllLines(GlobalPaths.ConfigDir + "\\servers.txt");
|
||||||
|
string[] lines_ports = File.ReadAllLines(GlobalPaths.ConfigDir + "\\ports.txt");
|
||||||
|
ServerBox.Items.AddRange(lines_server);
|
||||||
|
PortBox.Items.AddRange(lines_ports);
|
||||||
|
Tree.Nodes.Clear();
|
||||||
|
_TreeCache.Nodes.Clear();
|
||||||
|
MapDescBox.Text = "";
|
||||||
|
ServerInfo.Text = "";
|
||||||
|
ClientBox.Items.Clear();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Tree.Nodes.Clear();
|
||||||
|
_TreeCache.Nodes.Clear();
|
||||||
|
MapDescBox.Text = "";
|
||||||
|
ServerInfo.Text = "";
|
||||||
|
ClientBox.Items.Clear();
|
||||||
|
ServerBox.Items.Clear();
|
||||||
|
PortBox.Items.Clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StartGame(ScriptType gameType, bool no3d = false, bool nomap = false)
|
||||||
|
{
|
||||||
|
if (gameType == ScriptType.Studio)
|
||||||
|
{
|
||||||
|
DialogResult result = MessageBox.Show("If you want to test out your place, you will have to save your place in Novetus's map folder, then launch your place in Play Solo.", "Novetus - Launch ROBLOX Studio", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
|
||||||
|
if (result == DialogResult.Cancel)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gameType == ScriptType.Client && GlobalVars.LocalPlayMode)
|
||||||
|
{
|
||||||
|
GeneratePlayerID();
|
||||||
|
GenerateTripcode();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteConfigValues();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (gameType)
|
||||||
|
{
|
||||||
|
case ScriptType.Client:
|
||||||
|
GlobalFuncs.LaunchRBXClient(ScriptType.Client, false, true, new EventHandler(ClientExited), ConsoleBox);
|
||||||
|
break;
|
||||||
|
case ScriptType.Server:
|
||||||
|
GlobalFuncs.LaunchRBXClient(ScriptType.Server, no3d, false, new EventHandler(ClientExitedBase), ConsoleBox);
|
||||||
|
break;
|
||||||
|
case ScriptType.Solo:
|
||||||
|
GlobalFuncs.LaunchRBXClient(ScriptType.Solo, false, false, new EventHandler(ClientExited), ConsoleBox);
|
||||||
|
break;
|
||||||
|
case ScriptType.Studio:
|
||||||
|
GlobalFuncs.LaunchRBXClient(ScriptType.Studio, false, nomap, new EventHandler(ClientExited), ConsoleBox);
|
||||||
|
break;
|
||||||
|
case ScriptType.EasterEgg:
|
||||||
|
GlobalFuncs.LaunchRBXClient(ScriptType.EasterEgg, false, false, new EventHandler(EasterEggExited), ConsoleBox);
|
||||||
|
break;
|
||||||
|
case ScriptType.None:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GlobalVars.UserConfiguration.CloseOnLaunch)
|
||||||
|
{
|
||||||
|
Parent.Visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EasterEggLogic()
|
||||||
|
{
|
||||||
|
if (LocalVars.Clicks < 10)
|
||||||
|
{
|
||||||
|
LocalVars.Clicks += 1;
|
||||||
|
|
||||||
|
switch (LocalVars.Clicks)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
SplashLabel.Text = "Hi " + GlobalVars.UserConfiguration.PlayerName + "!";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
SplashLabel.Text = "How are you doing today?";
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
SplashLabel.Text = "I just wanted to say something.";
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
SplashLabel.Text = "Just wait a little on the last click, OK?";
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
SplashLabel.Text = "Thank you. <3";
|
||||||
|
StartGame(ScriptType.EasterEgg);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClientExited(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InLauncher, "");
|
||||||
|
ClientExitedBase(sender, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EasterEggExited(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InLauncher, "");
|
||||||
|
SplashLabel.Text = LocalVars.prevsplash;
|
||||||
|
ClientExitedBase(sender, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClientExitedBase(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (GlobalVars.UserConfiguration.CloseOnLaunch)
|
||||||
|
{
|
||||||
|
Parent.Visible = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FINALLY. https://stackoverflow.com/questions/11530643/treeview-search
|
||||||
|
public void SearchMaps()
|
||||||
|
{
|
||||||
|
string searchText = SearchBar.Text;
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(searchText))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (LastSearchText != searchText)
|
||||||
|
{
|
||||||
|
//It's a new Search
|
||||||
|
CurrentNodeMatches.Clear();
|
||||||
|
LastSearchText = searchText;
|
||||||
|
LastNodeIndex = 0;
|
||||||
|
SearchNodes(searchText, Tree.Nodes[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LastNodeIndex >= 0 && CurrentNodeMatches.Count > 0 && LastNodeIndex < CurrentNodeMatches.Count)
|
||||||
|
{
|
||||||
|
TreeNode selectedNode = CurrentNodeMatches[LastNodeIndex];
|
||||||
|
LastNodeIndex++;
|
||||||
|
Tree.SelectedNode = selectedNode;
|
||||||
|
Tree.SelectedNode.Expand();
|
||||||
|
Tree.Select();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//It's a new Search
|
||||||
|
CurrentNodeMatches.Clear();
|
||||||
|
LastSearchText = searchText;
|
||||||
|
LastNodeIndex = 0;
|
||||||
|
SearchNodes(searchText, Tree.Nodes[0]);
|
||||||
|
TreeNode selectedNode = CurrentNodeMatches[LastNodeIndex];
|
||||||
|
LastNodeIndex++;
|
||||||
|
Tree.SelectedNode = selectedNode;
|
||||||
|
Tree.SelectedNode.Expand();
|
||||||
|
Tree.Select();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
MessageBox.Show("The map '" + searchText + "' cannot be found. Please try another term.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ProcessConsole(KeyEventArgs e)
|
||||||
|
{
|
||||||
|
//Command proxy
|
||||||
|
|
||||||
|
int totalLines = ConsoleBox.Lines.Length;
|
||||||
|
if (totalLines > 0)
|
||||||
|
{
|
||||||
|
string lastLine = ConsoleBox.Lines[totalLines - 1];
|
||||||
|
|
||||||
|
if (e.KeyCode == Keys.Enter)
|
||||||
|
{
|
||||||
|
ConsoleBox.AppendText(Environment.NewLine);
|
||||||
|
ConsoleProcessCommands(lastLine);
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.Modifiers == Keys.Control)
|
||||||
|
{
|
||||||
|
switch (e.KeyCode)
|
||||||
|
{
|
||||||
|
case Keys.X:
|
||||||
|
case Keys.Z:
|
||||||
|
e.Handled = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ConsoleProcessCommands(string cmd)
|
||||||
|
{
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case string server3d when string.Compare(server3d, "server 3d", true, CultureInfo.InvariantCulture) == 0:
|
||||||
|
StartGame(ScriptType.Server);
|
||||||
|
break;
|
||||||
|
case string serverno3d when string.Compare(serverno3d, "server no3d", true, CultureInfo.InvariantCulture) == 0:
|
||||||
|
StartGame(ScriptType.Server, true);
|
||||||
|
break;
|
||||||
|
case string client when string.Compare(client, "client", true, CultureInfo.InvariantCulture) == 0:
|
||||||
|
StartGame(ScriptType.Client);
|
||||||
|
break;
|
||||||
|
case string solo when string.Compare(solo, "solo", true, CultureInfo.InvariantCulture) == 0:
|
||||||
|
StartGame(ScriptType.Solo);
|
||||||
|
break;
|
||||||
|
case string studiomap when string.Compare(studiomap, "studio map", true, CultureInfo.InvariantCulture) == 0:
|
||||||
|
StartGame(ScriptType.Studio);
|
||||||
|
break;
|
||||||
|
case string studionomap when string.Compare(studionomap, "studio nomap", true, CultureInfo.InvariantCulture) == 0:
|
||||||
|
StartGame(ScriptType.Studio, false, true);
|
||||||
|
break;
|
||||||
|
case string configsave when string.Compare(configsave, "config save", true, CultureInfo.InvariantCulture) == 0:
|
||||||
|
WriteConfigValues();
|
||||||
|
break;
|
||||||
|
case string configload when string.Compare(configload, "config load", true, CultureInfo.InvariantCulture) == 0:
|
||||||
|
ReadConfigValues();
|
||||||
|
break;
|
||||||
|
case string configreset when string.Compare(configreset, "config reset", true, CultureInfo.InvariantCulture) == 0:
|
||||||
|
ResetConfigValues();
|
||||||
|
break;
|
||||||
|
case string help when string.Compare(help, "help", true, CultureInfo.InvariantCulture) == 0:
|
||||||
|
ConsoleHelp();
|
||||||
|
break;
|
||||||
|
case string sdk when string.Compare(sdk, "sdk", true, CultureInfo.InvariantCulture) == 0:
|
||||||
|
LoadLauncher();
|
||||||
|
break;
|
||||||
|
case string webserverstart when string.Compare(webserverstart, "webserver start", true, CultureInfo.InvariantCulture) == 0:
|
||||||
|
if (!GlobalVars.IsWebServerOn)
|
||||||
|
{
|
||||||
|
StartWebServer();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GlobalFuncs.ConsolePrint("WebServer: There is already a web server on.", 2, ConsoleBox);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case string webserverstop when string.Compare(webserverstop, "webserver stop", true, CultureInfo.InvariantCulture) == 0:
|
||||||
|
if (GlobalVars.IsWebServerOn)
|
||||||
|
{
|
||||||
|
StopWebServer();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GlobalFuncs.ConsolePrint("WebServer: There is no web server on.", 2, ConsoleBox);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case string webserverrestart when string.Compare(webserverrestart, "webserver restart", true, CultureInfo.InvariantCulture) == 0:
|
||||||
|
try
|
||||||
|
{
|
||||||
|
GlobalFuncs.ConsolePrint("WebServer: Restarting...", 4, ConsoleBox);
|
||||||
|
StopWebServer();
|
||||||
|
StartWebServer();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalFuncs.ConsolePrint("WebServer: Cannot restart web server. (" + ex.Message + ")", 2, ConsoleBox);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case string dlldeleteon when string.Compare(dlldeleteon, "dlldelete on", true, CultureInfo.InvariantCulture) == 0:
|
||||||
|
GlobalVars.UserConfiguration.DisableReshadeDelete = false;
|
||||||
|
GlobalFuncs.ConsolePrint("ReShade DLL deletion enabled.", 4, ConsoleBox);
|
||||||
|
break;
|
||||||
|
case string dlldeleteoff when string.Compare(dlldeleteoff, "dlldelete off", true, CultureInfo.InvariantCulture) == 0:
|
||||||
|
GlobalVars.UserConfiguration.DisableReshadeDelete = true;
|
||||||
|
GlobalFuncs.ConsolePrint("ReShade DLL deletion disabled.", 4, ConsoleBox);
|
||||||
|
break;
|
||||||
|
case string important when string.Compare(important, LocalVars.important, true, CultureInfo.InvariantCulture) == 0:
|
||||||
|
GlobalVars.AdminMode = true;
|
||||||
|
GlobalFuncs.ConsolePrint("ADMIN MODE ENABLED.", 4, ConsoleBox);
|
||||||
|
GlobalFuncs.ConsolePrint("YOU ARE GOD.", 2, ConsoleBox);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
GlobalFuncs.ConsolePrint("ERROR 3 - Command is either not registered or valid", 2, ConsoleBox);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadLauncher()
|
||||||
|
{
|
||||||
|
NovetusSDK im = new NovetusSDK();
|
||||||
|
im.Show();
|
||||||
|
GlobalFuncs.ConsolePrint("Novetus SDK Launcher Loaded.", 4, ConsoleBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ConsoleHelp()
|
||||||
|
{
|
||||||
|
GlobalFuncs.ConsolePrint("Help:", 3, ConsoleBox);
|
||||||
|
GlobalFuncs.ConsolePrint("---------", 1, ConsoleBox);
|
||||||
|
GlobalFuncs.ConsolePrint("= client | Launches client with launcher settings", 4, ConsoleBox);
|
||||||
|
GlobalFuncs.ConsolePrint("= solo | Launches client in Play Solo mode with launcher settings", 4, ConsoleBox);
|
||||||
|
GlobalFuncs.ConsolePrint("= server 3d | Launches server with launcher settings", 4, ConsoleBox);
|
||||||
|
GlobalFuncs.ConsolePrint("= server no3d | Launches server in NoGraphics mode with launcher settings", 4, ConsoleBox);
|
||||||
|
GlobalFuncs.ConsolePrint("= studio map | Launches Roblox Studio with the selected map", 4, ConsoleBox);
|
||||||
|
GlobalFuncs.ConsolePrint("= studio nomap | Launches Roblox Studio without the selected map", 4, ConsoleBox);
|
||||||
|
GlobalFuncs.ConsolePrint("= sdk | Launches the Novetus SDK Launcher", 4, ConsoleBox);
|
||||||
|
GlobalFuncs.ConsolePrint("---------", 1, ConsoleBox);
|
||||||
|
GlobalFuncs.ConsolePrint("= config save | Saves the config file", 4, ConsoleBox);
|
||||||
|
GlobalFuncs.ConsolePrint("= config load | Reloads the config file", 4, ConsoleBox);
|
||||||
|
GlobalFuncs.ConsolePrint("= config reset | Resets the config file", 4, ConsoleBox);
|
||||||
|
GlobalFuncs.ConsolePrint("---------", 1, ConsoleBox);
|
||||||
|
GlobalFuncs.ConsolePrint("= webserver restart | Restarts the web server", 4, ConsoleBox);
|
||||||
|
GlobalFuncs.ConsolePrint("= webserver stop | Stops a web server if there is one on.", 4, ConsoleBox);
|
||||||
|
GlobalFuncs.ConsolePrint("= webserver start | Starts a web server if there isn't one on yet.", 4, ConsoleBox);
|
||||||
|
GlobalFuncs.ConsolePrint("---------", 1, ConsoleBox);
|
||||||
|
GlobalFuncs.ConsolePrint("= dlldelete off | Turn off the deletion of opengl32.dll when ReShade is off.", 4, ConsoleBox);
|
||||||
|
GlobalFuncs.ConsolePrint("= dlldelete on | Turn on the deletion of opengl32.dll when ReShade is off.", 4, ConsoleBox);
|
||||||
|
GlobalFuncs.ConsolePrint("---------", 1, ConsoleBox);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Functions
|
||||||
|
public void SearchNodes(string SearchText, TreeNode StartNode)
|
||||||
|
{
|
||||||
|
while (StartNode != null)
|
||||||
|
{
|
||||||
|
if (StartNode.Text.ToLower().Contains(SearchText.ToLower()))
|
||||||
|
{
|
||||||
|
CurrentNodeMatches.Add(StartNode);
|
||||||
|
};
|
||||||
|
if (StartNode.Nodes.Count != 0)
|
||||||
|
{
|
||||||
|
SearchNodes(SearchText, StartNode.Nodes[0]);//Recursive Search
|
||||||
|
};
|
||||||
|
StartNode = StartNode.NextNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -92,18 +92,24 @@ namespace NovetusLauncher
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (serverList[selectedServer] != null)
|
if (ServerListView.Items.Count > 0 && ServerListView.Items[selectedServer] != null && serverList[selectedServer] != null)
|
||||||
{
|
{
|
||||||
MessageBox.Show(ServerListView.Items[selectedServer].Text + " = " + serverList[selectedServer].ServerName);
|
VarStorage.GameServer curServer = serverList[selectedServer];
|
||||||
}
|
if (ServerListView.Items[selectedServer].Text == curServer.ServerName)
|
||||||
else
|
{
|
||||||
{
|
GlobalVars.IP = curServer.ServerIP;
|
||||||
MessageBox.Show("broke");
|
GlobalVars.JoinPort = curServer.ServerPort;
|
||||||
|
#if LAUNCHER
|
||||||
|
GlobalFuncs.LaunchRBXClient(curServer.ServerClient, ScriptType.Client, false, false, null, null);
|
||||||
|
#else
|
||||||
|
GlobalFuncs.LaunchRBXClient(curServer.ServerClient, ScriptType.Client, false, false, null);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
MessageBox.Show("broke (TEMP)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,7 @@
|
||||||
<Compile Include="Forms\CustomGraphicsOptions.Designer.cs">
|
<Compile Include="Forms\CustomGraphicsOptions.Designer.cs">
|
||||||
<DependentUpon>CustomGraphicsOptions.cs</DependentUpon>
|
<DependentUpon>CustomGraphicsOptions.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Forms\LauncherFormShared.cs" />
|
||||||
<Compile Include="Forms\LauncherForm\Compact\LauncherFormCompact.cs">
|
<Compile Include="Forms\LauncherForm\Compact\LauncherFormCompact.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue