IP and port are now part of 1 class. ToString() returns a Minecraft styled server address.

This commit is contained in:
Bitl 2022-09-19 11:02:55 -07:00
parent b3b2dc7fb9
commit 5bf54df1e0
13 changed files with 122 additions and 93 deletions

View File

@ -1410,8 +1410,8 @@ public class ScriptFuncs
case ScriptType.Client: case ScriptType.Client:
return "_G.CSConnect(" return "_G.CSConnect("
+ (info.UsesID ? GlobalVars.UserConfiguration.UserID : 0) + ",'" + (info.UsesID ? GlobalVars.UserConfiguration.UserID : 0) + ",'"
+ GlobalVars.IP + "'," + GlobalVars.CurrentServer.ServerIP + "',"
+ GlobalVars.JoinPort + ",'" + GlobalVars.CurrentServer.ServerPort + ",'"
+ (info.UsesPlayerName ? GlobalVars.UserConfiguration.PlayerName : "Player") + "'," + (info.UsesPlayerName ? GlobalVars.UserConfiguration.PlayerName : "Player") + "',"
+ GlobalVars.Loadout + "," + GlobalVars.Loadout + ","
+ md5s + ",'" + md5s + ",'"
@ -1689,9 +1689,10 @@ public class ScriptFuncs
.Replace("%mapfile%", mapfile) .Replace("%mapfile%", mapfile)
.Replace("%luafile%", luafile) .Replace("%luafile%", luafile)
.Replace("%charapp%", GlobalVars.UserCustomization.CharacterID) .Replace("%charapp%", GlobalVars.UserCustomization.CharacterID)
.Replace("%ip%", GlobalVars.IP) .Replace("%server%", GlobalVars.CurrentServer.ToString())
.Replace("%ip%", GlobalVars.CurrentServer.ServerIP)
.Replace("%port%", GlobalVars.UserConfiguration.RobloxPort.ToString()) .Replace("%port%", GlobalVars.UserConfiguration.RobloxPort.ToString())
.Replace("%joinport%", GlobalVars.JoinPort.ToString()) .Replace("%joinport%", GlobalVars.CurrentServer.ServerPort.ToString())
.Replace("%name%", GlobalVars.UserConfiguration.PlayerName) .Replace("%name%", GlobalVars.UserConfiguration.PlayerName)
.Replace("%icone%", ConvertIconStringToInt().ToString()) .Replace("%icone%", ConvertIconStringToInt().ToString())
.Replace("%icon%", GlobalVars.UserCustomization.Icon) .Replace("%icon%", GlobalVars.UserCustomization.Icon)

View File

@ -8,6 +8,7 @@
*/ */
#region Usings #region Usings
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
#endregion #endregion
@ -24,6 +25,25 @@ public enum ScriptType
} }
#endregion #endregion
#region Game Server Definition
public class GameServer
{
public GameServer(string ip, int port)
{
ServerIP = ip;
ServerPort = port;
}
public override string ToString()
{
return ServerIP + ":" + ServerPort.ToString();
}
public string ServerIP { get; set; }
public int ServerPort { get; set; }
}
#endregion
#region Global Variables #region Global Variables
public static class GlobalVars public static class GlobalVars
{ {
@ -52,10 +72,10 @@ public static class GlobalVars
#endregion #endregion
#region Joining/Hosting #region Joining/Hosting
public static string IP = "localhost"; public static string DefaultIP = "localhost";
public static string ExternalIP = SecurityFuncs.GetExternalIPAddress();
public static int DefaultRobloxPort = 53640; public static int DefaultRobloxPort = 53640;
public static int JoinPort = DefaultRobloxPort; public static GameServer CurrentServer = new GameServer(DefaultIP, DefaultRobloxPort);
public static string ExternalIP = SecurityFuncs.GetExternalIPAddress();
public static ScriptType GameOpened = ScriptType.None; public static ScriptType GameOpened = ScriptType.None;
public static string PlayerTripcode = ""; public static string PlayerTripcode = "";
#endregion #endregion

View File

@ -273,7 +273,7 @@ public class SecurityFuncs
+ GlobalVars.ProgramInformation.Version + " - " + GlobalVars.ProgramInformation.Version + " - "
+ clientname + " " + clientname + " "
+ ScriptFuncs.Generator.GetNameForType(type) + ScriptFuncs.Generator.GetNameForType(type)
+ " [" + GlobalVars.IP + ":" + GlobalVars.JoinPort + "]" + " [" + GlobalVars.CurrentServer.ToString() + "]"
+ RandomStringTitle()); + RandomStringTitle());
break; break;
case ScriptType.Server: case ScriptType.Server:

View File

@ -79,10 +79,10 @@ namespace NovetusLauncher
return; return;
} }
GlobalVars.IP = textBox1.Text; GlobalVars.CurrentServer.ServerIP = textBox1.Text;
checkBox3.Enabled = false; checkBox3.Enabled = false;
GlobalVars.LocalPlayMode = false; GlobalVars.LocalPlayMode = false;
label37.Text = GlobalVars.IP; label37.Text = GlobalVars.CurrentServer.ServerIP;
} }
void CheckBox1CheckedChanged(object sender, EventArgs e) void CheckBox1CheckedChanged(object sender, EventArgs e)
@ -142,12 +142,12 @@ namespace NovetusLauncher
void Button10Click(object sender, EventArgs e) void Button10Click(object sender, EventArgs e)
{ {
launcherForm.AddIPPortListing(null, GlobalPaths.ConfigDir + "\\servers.txt", GlobalVars.IP); launcherForm.AddIPPortListing(null, GlobalPaths.ConfigDir + "\\servers.txt", GlobalVars.CurrentServer.ServerIP);
} }
void Button11Click(object sender, EventArgs e) void Button11Click(object sender, EventArgs e)
{ {
launcherForm.AddIPPortListing(null, GlobalPaths.ConfigDir + "\\ports.txt", GlobalVars.JoinPort); launcherForm.AddIPPortListing(null, GlobalPaths.ConfigDir + "\\ports.txt", GlobalVars.CurrentServer.ServerPort);
} }
void Button12Click(object sender, EventArgs e) void Button12Click(object sender, EventArgs e)
@ -172,12 +172,12 @@ namespace NovetusLauncher
void Button16Click(object sender, EventArgs e) void Button16Click(object sender, EventArgs e)
{ {
launcherForm.AddIPPortListing(listBox3, GlobalPaths.ConfigDir + "\\servers.txt", GlobalVars.IP); launcherForm.AddIPPortListing(listBox3, GlobalPaths.ConfigDir + "\\servers.txt", GlobalVars.CurrentServer.ServerIP);
} }
void Button17Click(object sender, EventArgs e) void Button17Click(object sender, EventArgs e)
{ {
launcherForm.AddIPPortListing(listBox4, GlobalPaths.ConfigDir + "\\ports.txt", GlobalVars.JoinPort); launcherForm.AddIPPortListing(listBox4, GlobalPaths.ConfigDir + "\\ports.txt", GlobalVars.CurrentServer.ServerPort);
} }
void NumericUpDown1ValueChanged(object sender, EventArgs e) void NumericUpDown1ValueChanged(object sender, EventArgs e)
@ -197,7 +197,7 @@ namespace NovetusLauncher
void Button7Click(object sender, EventArgs e) void Button7Click(object sender, EventArgs e)
{ {
launcherForm.ResetCurPort(numericUpDown1, GlobalVars.JoinPort); launcherForm.ResetCurPort(numericUpDown1, GlobalVars.CurrentServer.ServerPort);
} }
void Button22Click(object sender, EventArgs e) void Button22Click(object sender, EventArgs e)

View File

@ -84,10 +84,10 @@ namespace NovetusLauncher
return; return;
} }
GlobalVars.IP = textBox1.Text; GlobalVars.CurrentServer.ServerIP = textBox1.Text;
checkBox3.Enabled = false; checkBox3.Enabled = false;
GlobalVars.LocalPlayMode = false; GlobalVars.LocalPlayMode = false;
label37.Text = GlobalVars.IP; label37.Text = GlobalVars.CurrentServer.ServerIP;
} }
void CheckBox1CheckedChanged(object sender, EventArgs e) void CheckBox1CheckedChanged(object sender, EventArgs e)
@ -147,12 +147,12 @@ namespace NovetusLauncher
void Button10Click(object sender, EventArgs e) void Button10Click(object sender, EventArgs e)
{ {
launcherForm.AddIPPortListing(null, GlobalPaths.ConfigDir + "\\servers.txt", GlobalVars.IP); launcherForm.AddIPPortListing(null, GlobalPaths.ConfigDir + "\\servers.txt", GlobalVars.CurrentServer.ServerIP);
} }
void Button11Click(object sender, EventArgs e) void Button11Click(object sender, EventArgs e)
{ {
launcherForm.AddIPPortListing(null, GlobalPaths.ConfigDir + "\\ports.txt", GlobalVars.JoinPort); launcherForm.AddIPPortListing(null, GlobalPaths.ConfigDir + "\\ports.txt", GlobalVars.CurrentServer.ServerPort);
} }
void Button12Click(object sender, EventArgs e) void Button12Click(object sender, EventArgs e)
@ -177,12 +177,12 @@ namespace NovetusLauncher
void Button16Click(object sender, EventArgs e) void Button16Click(object sender, EventArgs e)
{ {
launcherForm.AddIPPortListing(listBox3, GlobalPaths.ConfigDir + "\\servers.txt", GlobalVars.IP); launcherForm.AddIPPortListing(listBox3, GlobalPaths.ConfigDir + "\\servers.txt", GlobalVars.CurrentServer.ServerIP);
} }
void Button17Click(object sender, EventArgs e) void Button17Click(object sender, EventArgs e)
{ {
launcherForm.AddIPPortListing(listBox4, GlobalPaths.ConfigDir + "\\ports.txt", GlobalVars.JoinPort); launcherForm.AddIPPortListing(listBox4, GlobalPaths.ConfigDir + "\\ports.txt", GlobalVars.CurrentServer.ServerPort);
} }
void NumericUpDown1ValueChanged(object sender, EventArgs e) void NumericUpDown1ValueChanged(object sender, EventArgs e)
@ -202,7 +202,7 @@ namespace NovetusLauncher
void Button7Click(object sender, EventArgs e) void Button7Click(object sender, EventArgs e)
{ {
launcherForm.ResetCurPort(numericUpDown1, GlobalVars.JoinPort); launcherForm.ResetCurPort(numericUpDown1, GlobalVars.CurrentServer.ServerPort);
} }
void Button22Click(object sender, EventArgs e) void Button22Click(object sender, EventArgs e)

View File

@ -571,10 +571,10 @@ namespace NovetusLauncher
SelectedMapLabel.Text = GlobalVars.UserConfiguration.Map; SelectedMapLabel.Text = GlobalVars.UserConfiguration.Map;
Tree.SelectedNode = TreeNodeHelper.SearchTreeView(GlobalVars.UserConfiguration.Map, Tree.Nodes); Tree.SelectedNode = TreeNodeHelper.SearchTreeView(GlobalVars.UserConfiguration.Map, Tree.Nodes);
Tree.Focus(); Tree.Focus();
JoinPortBox.Value = Convert.ToDecimal(GlobalVars.JoinPort); JoinPortBox.Value = Convert.ToDecimal(GlobalVars.CurrentServer.ServerPort);
HostPortBox.Value = Convert.ToDecimal(GlobalVars.UserConfiguration.RobloxPort); HostPortBox.Value = Convert.ToDecimal(GlobalVars.UserConfiguration.RobloxPort);
IPLabel.Text = GlobalVars.IP; IPLabel.Text = GlobalVars.CurrentServer.ServerIP;
PortLabel.Text = GlobalVars.JoinPort.ToString(); PortLabel.Text = GlobalVars.CurrentServer.ServerPort.ToString();
DiscordPresenceCheckbox.Checked = GlobalVars.UserConfiguration.DiscordPresence; DiscordPresenceCheckbox.Checked = GlobalVars.UserConfiguration.DiscordPresence;
uPnPCheckBox.Checked = GlobalVars.UserConfiguration.UPnP; uPnPCheckBox.Checked = GlobalVars.UserConfiguration.UPnP;
ShowServerNotifsCheckBox.Checked = GlobalVars.UserConfiguration.ShowServerNotifications; ShowServerNotifsCheckBox.Checked = GlobalVars.UserConfiguration.ShowServerNotifications;
@ -683,7 +683,7 @@ namespace NovetusLauncher
switch (GlobalVars.SelectedClientInfo.UsesID) switch (GlobalVars.SelectedClientInfo.UsesID)
{ {
case true: case true:
if (GlobalVars.IP.Equals("localhost")) if (GlobalVars.CurrentServer.ServerIP.Equals("localhost"))
{ {
LocalPlayCheckBox.Enabled = true; LocalPlayCheckBox.Enabled = true;
} }
@ -905,17 +905,17 @@ namespace NovetusLauncher
public void SelectIPListing() public void SelectIPListing()
{ {
GlobalVars.IP = ServerBox.SelectedItem.ToString(); GlobalVars.CurrentServer.ServerIP = ServerBox.SelectedItem.ToString();
IPBox.Text = GlobalVars.IP; IPBox.Text = GlobalVars.CurrentServer.ServerIP;
LocalPlayCheckBox.Enabled = false; LocalPlayCheckBox.Enabled = false;
GlobalVars.LocalPlayMode = false; GlobalVars.LocalPlayMode = false;
IPLabel.Text = GlobalVars.IP; IPLabel.Text = GlobalVars.CurrentServer.ServerIP;
} }
public void SelectPortListing() public void SelectPortListing()
{ {
GlobalVars.JoinPort = Convert.ToInt32(PortBox.SelectedItem.ToString()); GlobalVars.CurrentServer.ServerPort = Convert.ToInt32(PortBox.SelectedItem.ToString());
JoinPortBox.Value = Convert.ToDecimal(GlobalVars.JoinPort); JoinPortBox.Value = Convert.ToDecimal(GlobalVars.CurrentServer.ServerPort);
} }
public void ResetCurPort(NumericUpDown box, int value) public void ResetCurPort(NumericUpDown box, int value)
@ -926,8 +926,8 @@ namespace NovetusLauncher
public void ChangeJoinPort() public void ChangeJoinPort()
{ {
GlobalVars.JoinPort = Convert.ToInt32(JoinPortBox.Value); GlobalVars.CurrentServer.ServerPort = Convert.ToInt32(JoinPortBox.Value);
PortLabel.Text = GlobalVars.JoinPort.ToString(); PortLabel.Text = GlobalVars.CurrentServer.ServerPort.ToString();
} }
public void ChangeServerPort() public void ChangeServerPort()

View File

@ -115,7 +115,7 @@ namespace NovetusLauncher
launcherFormStylishInterface1.mapsBox.SelectedNode.BackColor = SystemColors.Highlight; launcherFormStylishInterface1.mapsBox.SelectedNode.BackColor = SystemColors.Highlight;
launcherFormStylishInterface1.mapsBox.SelectedNode.ForeColor = SystemColors.HighlightText; launcherFormStylishInterface1.mapsBox.SelectedNode.ForeColor = SystemColors.HighlightText;
} }
launcherFormStylishInterface1.joinPortBox.Text = GlobalVars.JoinPort.ToString(); launcherFormStylishInterface1.joinPortBox.Text = GlobalVars.CurrentServer.ServerPort.ToString();
launcherFormStylishInterface1.serverPortBox.Text = GlobalVars.UserConfiguration.RobloxPort.ToString(); launcherFormStylishInterface1.serverPortBox.Text = GlobalVars.UserConfiguration.RobloxPort.ToString();
launcherFormStylishInterface1.discordRichPresenceBox.IsChecked = GlobalVars.UserConfiguration.DiscordPresence; launcherFormStylishInterface1.discordRichPresenceBox.IsChecked = GlobalVars.UserConfiguration.DiscordPresence;
launcherFormStylishInterface1.uPnPBox.IsChecked = GlobalVars.UserConfiguration.UPnP; launcherFormStylishInterface1.uPnPBox.IsChecked = GlobalVars.UserConfiguration.UPnP;

View File

@ -325,14 +325,14 @@ namespace NovetusLauncher
{ {
if (!IsLoaded) if (!IsLoaded)
return; return;
GlobalVars.IP = ipAddressBox.Text; GlobalVars.CurrentServer.ServerIP = ipAddressBox.Text;
} }
private void joinPortBox_TextChanged(object sender, TextChangedEventArgs e) private void joinPortBox_TextChanged(object sender, TextChangedEventArgs e)
{ {
if (!IsLoaded) if (!IsLoaded)
return; return;
GlobalVars.JoinPort = Convert.ToInt32(joinPortBox.Text); GlobalVars.CurrentServer.ServerPort = Convert.ToInt32(joinPortBox.Text);
} }
private void serverPortBox_TextChanged(object sender, TextChangedEventArgs e) private void serverPortBox_TextChanged(object sender, TextChangedEventArgs e)

View File

@ -31,28 +31,8 @@ namespace NovetusLauncher
private void NovetusConsole_Load(object sender, EventArgs e) private void NovetusConsole_Load(object sender, EventArgs e)
{ {
Util.ConsolePrint("Novetus version " + GlobalVars.ProgramInformation.Version + " loaded. Initializing config.", 4); Util.ConsolePrint("Novetus version " + GlobalVars.ProgramInformation.Version + " loaded.", 4);
Util.ConsolePrint("Novetus path: " + GlobalPaths.BasePath, 4); Util.ConsolePrint("Novetus path: " + GlobalPaths.BasePath, 4);
if (!File.Exists(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName))
{
Util.ConsolePrint("WARNING - " + GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName + " not found. Creating one with default values.", 5);
ConsoleForm.WriteConfigValues();
}
if (!File.Exists(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigNameCustomization))
{
Util.ConsolePrint("WARNING - " + GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigNameCustomization + " not found. Creating one with default values.", 5);
ConsoleForm.WriteCustomizationValues();
}
if (!File.Exists(GlobalPaths.ConfigDir + "\\servers.txt"))
{
Util.ConsolePrint("WARNING - " + GlobalPaths.ConfigDir + "\\servers.txt not found. Creating empty file.", 5);
File.Create(GlobalPaths.ConfigDir + "\\servers.txt").Dispose();
}
if (!File.Exists(GlobalPaths.ConfigDir + "\\ports.txt"))
{
Util.ConsolePrint("WARNING - " + GlobalPaths.ConfigDir + "\\ports.txt not found. Creating empty file.", 5);
File.Create(GlobalPaths.ConfigDir + "\\ports.txt").Dispose();
}
NovetusFuncs.SetupAdminPassword(); NovetusFuncs.SetupAdminPassword();
if (argList.Length > 0) if (argList.Length > 0)

View File

@ -83,6 +83,7 @@ partial class ClientinfoEditor
this.usenewsignformatToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.usenewsignformatToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.useloadfileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.useloadfileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.userbxassetforgenerationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.userbxassetforgenerationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.generatescriptToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.serverToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.serverToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.limitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.limitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.notificationsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.notificationsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -165,7 +166,7 @@ partial class ClientinfoEditor
this.checkBox8 = new System.Windows.Forms.CheckBox(); this.checkBox8 = new System.Windows.Forms.CheckBox();
this.textBox2 = new System.Windows.Forms.TextBox(); this.textBox2 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.generatescriptToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.serverToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -454,7 +455,8 @@ partial class ClientinfoEditor
this.usenewsignformatToolStripMenuItem, this.usenewsignformatToolStripMenuItem,
this.useloadfileToolStripMenuItem, this.useloadfileToolStripMenuItem,
this.userbxassetforgenerationToolStripMenuItem, this.userbxassetforgenerationToolStripMenuItem,
this.generatescriptToolStripMenuItem}); this.generatescriptToolStripMenuItem,
this.serverToolStripMenuItem2});
this.generalToolStripMenuItem.Name = "generalToolStripMenuItem"; this.generalToolStripMenuItem.Name = "generalToolStripMenuItem";
this.generalToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.generalToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.generalToolStripMenuItem.Text = "General"; this.generalToolStripMenuItem.Text = "General";
@ -571,6 +573,13 @@ partial class ClientinfoEditor
this.userbxassetforgenerationToolStripMenuItem.Text = "%userbxassetforgeneration%"; this.userbxassetforgenerationToolStripMenuItem.Text = "%userbxassetforgeneration%";
this.userbxassetforgenerationToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click); this.userbxassetforgenerationToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click);
// //
// generatescriptToolStripMenuItem
//
this.generatescriptToolStripMenuItem.Name = "generatescriptToolStripMenuItem";
this.generatescriptToolStripMenuItem.Size = new System.Drawing.Size(227, 22);
this.generatescriptToolStripMenuItem.Text = "%generatescript%";
this.generatescriptToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click);
//
// serverToolStripMenuItem1 // serverToolStripMenuItem1
// //
this.serverToolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.serverToolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -584,21 +593,21 @@ partial class ClientinfoEditor
// limitToolStripMenuItem // limitToolStripMenuItem
// //
this.limitToolStripMenuItem.Name = "limitToolStripMenuItem"; this.limitToolStripMenuItem.Name = "limitToolStripMenuItem";
this.limitToolStripMenuItem.Size = new System.Drawing.Size(160, 22); this.limitToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.limitToolStripMenuItem.Text = "%limit%"; this.limitToolStripMenuItem.Text = "%limit%";
this.limitToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click); this.limitToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click);
// //
// notificationsToolStripMenuItem // notificationsToolStripMenuItem
// //
this.notificationsToolStripMenuItem.Name = "notificationsToolStripMenuItem"; this.notificationsToolStripMenuItem.Name = "notificationsToolStripMenuItem";
this.notificationsToolStripMenuItem.Size = new System.Drawing.Size(160, 22); this.notificationsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.notificationsToolStripMenuItem.Text = "%notifications%"; this.notificationsToolStripMenuItem.Text = "%notifications%";
this.notificationsToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click); this.notificationsToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click);
// //
// portToolStripMenuItem // portToolStripMenuItem
// //
this.portToolStripMenuItem.Name = "portToolStripMenuItem"; this.portToolStripMenuItem.Name = "portToolStripMenuItem";
this.portToolStripMenuItem.Size = new System.Drawing.Size(160, 22); this.portToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.portToolStripMenuItem.Text = "%port%"; this.portToolStripMenuItem.Text = "%port%";
this.portToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click); this.portToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click);
// //
@ -619,49 +628,49 @@ partial class ClientinfoEditor
// md5launcherToolStripMenuItem // md5launcherToolStripMenuItem
// //
this.md5launcherToolStripMenuItem.Name = "md5launcherToolStripMenuItem"; this.md5launcherToolStripMenuItem.Name = "md5launcherToolStripMenuItem";
this.md5launcherToolStripMenuItem.Size = new System.Drawing.Size(164, 22); this.md5launcherToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.md5launcherToolStripMenuItem.Text = "%md5launcher%"; this.md5launcherToolStripMenuItem.Text = "%md5launcher%";
this.md5launcherToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click); this.md5launcherToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click);
// //
// md5scriptToolStripMenuItem // md5scriptToolStripMenuItem
// //
this.md5scriptToolStripMenuItem.Name = "md5scriptToolStripMenuItem"; this.md5scriptToolStripMenuItem.Name = "md5scriptToolStripMenuItem";
this.md5scriptToolStripMenuItem.Size = new System.Drawing.Size(164, 22); this.md5scriptToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.md5scriptToolStripMenuItem.Text = "%md5script%"; this.md5scriptToolStripMenuItem.Text = "%md5script%";
this.md5scriptToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click); this.md5scriptToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click);
// //
// md5exeToolStripMenuItem // md5exeToolStripMenuItem
// //
this.md5exeToolStripMenuItem.Name = "md5exeToolStripMenuItem"; this.md5exeToolStripMenuItem.Name = "md5exeToolStripMenuItem";
this.md5exeToolStripMenuItem.Size = new System.Drawing.Size(164, 22); this.md5exeToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.md5exeToolStripMenuItem.Text = "%md5exe%"; this.md5exeToolStripMenuItem.Text = "%md5exe%";
this.md5exeToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click); this.md5exeToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click);
// //
// md5scriptdToolStripMenuItem // md5scriptdToolStripMenuItem
// //
this.md5scriptdToolStripMenuItem.Name = "md5scriptdToolStripMenuItem"; this.md5scriptdToolStripMenuItem.Name = "md5scriptdToolStripMenuItem";
this.md5scriptdToolStripMenuItem.Size = new System.Drawing.Size(164, 22); this.md5scriptdToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.md5scriptdToolStripMenuItem.Text = "%md5scriptd%"; this.md5scriptdToolStripMenuItem.Text = "%md5scriptd%";
this.md5scriptdToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click); this.md5scriptdToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click);
// //
// md5exedToolStripMenuItem // md5exedToolStripMenuItem
// //
this.md5exedToolStripMenuItem.Name = "md5exedToolStripMenuItem"; this.md5exedToolStripMenuItem.Name = "md5exedToolStripMenuItem";
this.md5exedToolStripMenuItem.Size = new System.Drawing.Size(164, 22); this.md5exedToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.md5exedToolStripMenuItem.Text = "%md5exed%"; this.md5exedToolStripMenuItem.Text = "%md5exed%";
this.md5exedToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click); this.md5exedToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click);
// //
// md5sToolStripMenuItem // md5sToolStripMenuItem
// //
this.md5sToolStripMenuItem.Name = "md5sToolStripMenuItem"; this.md5sToolStripMenuItem.Name = "md5sToolStripMenuItem";
this.md5sToolStripMenuItem.Size = new System.Drawing.Size(164, 22); this.md5sToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.md5sToolStripMenuItem.Text = "%md5s%"; this.md5sToolStripMenuItem.Text = "%md5s%";
this.md5sToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click); this.md5sToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click);
// //
// md5sdToolStripMenuItem // md5sdToolStripMenuItem
// //
this.md5sdToolStripMenuItem.Name = "md5sdToolStripMenuItem"; this.md5sdToolStripMenuItem.Name = "md5sdToolStripMenuItem";
this.md5sdToolStripMenuItem.Size = new System.Drawing.Size(164, 22); this.md5sdToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.md5sdToolStripMenuItem.Text = "%md5sd%"; this.md5sdToolStripMenuItem.Text = "%md5sd%";
this.md5sdToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click); this.md5sdToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click);
// //
@ -1270,12 +1279,12 @@ partial class ClientinfoEditor
this.label3.TabIndex = 37; this.label3.TabIndex = 37;
this.label3.Text = "EXE Name:"; this.label3.Text = "EXE Name:";
// //
// generatescriptToolStripMenuItem // serverToolStripMenuItem2
// //
this.generatescriptToolStripMenuItem.Name = "generatescriptToolStripMenuItem"; this.serverToolStripMenuItem2.Name = "serverToolStripMenuItem2";
this.generatescriptToolStripMenuItem.Size = new System.Drawing.Size(227, 22); this.serverToolStripMenuItem2.Size = new System.Drawing.Size(227, 22);
this.generatescriptToolStripMenuItem.Text = "%generatescript%"; this.serverToolStripMenuItem2.Text = "%server%";
this.generatescriptToolStripMenuItem.Click += new System.EventHandler(this.variableToolStripMenuItem_Click); this.serverToolStripMenuItem2.Click += new System.EventHandler(this.variableToolStripMenuItem_Click);
// //
// ClientinfoEditor // ClientinfoEditor
// //
@ -1448,4 +1457,5 @@ partial class ClientinfoEditor
private System.Windows.Forms.ToolStripMenuItem useloadfileToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem useloadfileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem userbxassetforgenerationToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem userbxassetforgenerationToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem generatescriptToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem generatescriptToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem serverToolStripMenuItem2;
} }

View File

@ -18,8 +18,8 @@ namespace NovetusLauncher
public partial class ServerBrowser : Form public partial class ServerBrowser : Form
{ {
#region Private Variables #region Private Variables
List<GameServer> serverList = new List<GameServer>(); List<ServerBrowserDef> serverList = new List<ServerBrowserDef>();
private GameServer selectedServer; private ServerBrowserDef selectedServer;
private string oldIP; private string oldIP;
private int oldPort; private int oldPort;
#endregion #endregion
@ -45,10 +45,10 @@ namespace NovetusLauncher
{ {
if (selectedServer.IsValid()) if (selectedServer.IsValid())
{ {
oldIP = GlobalVars.IP; oldIP = GlobalVars.CurrentServer.ServerIP;
oldPort = GlobalVars.JoinPort; oldPort = GlobalVars.CurrentServer.ServerPort;
GlobalVars.IP = selectedServer.ServerIP; GlobalVars.CurrentServer.ServerIP = selectedServer.ServerIP;
GlobalVars.JoinPort = selectedServer.ServerPort; GlobalVars.CurrentServer.ServerPort = selectedServer.ServerPort;
ClientManagement.LaunchRBXClient(selectedServer.ServerClient, ScriptType.Client, false, true, new EventHandler(ClientExited)); ClientManagement.LaunchRBXClient(selectedServer.ServerClient, ScriptType.Client, false, true, new EventHandler(ClientExited));
} }
} }
@ -70,8 +70,8 @@ namespace NovetusLauncher
GlobalVars.GameOpened = ScriptType.None; GlobalVars.GameOpened = ScriptType.None;
} }
ClientManagement.UpdateRichPresence(ClientManagement.GetStateForType(GlobalVars.GameOpened)); ClientManagement.UpdateRichPresence(ClientManagement.GetStateForType(GlobalVars.GameOpened));
GlobalVars.IP = oldIP; GlobalVars.CurrentServer.ServerIP = oldIP;
GlobalVars.JoinPort = oldPort; GlobalVars.CurrentServer.ServerPort = oldPort;
} }
private void ServerListView_SelectedIndexChanged(object sender, EventArgs e) private void ServerListView_SelectedIndexChanged(object sender, EventArgs e)
@ -152,7 +152,7 @@ namespace NovetusLauncher
} }
string[] serverInfo = DecodedLine.Split('|'); string[] serverInfo = DecodedLine.Split('|');
GameServer gameServer = new GameServer(serverInfo[0], serverInfo[1], serverInfo[2], serverInfo[3], serverInfo[4]); ServerBrowserDef gameServer = new ServerBrowserDef(serverInfo[0], serverInfo[1], serverInfo[2], serverInfo[3], serverInfo[4]);
if (gameServer.IsValid()) if (gameServer.IsValid())
{ {
serverList.Add(gameServer); serverList.Add(gameServer);
@ -247,10 +247,10 @@ namespace NovetusLauncher
} }
#endregion #endregion
#region Game Server Definition #region Server browser Definition
public class GameServer public class ServerBrowserDef
{ {
public GameServer(string name, string ip, string port, string client, string version) public ServerBrowserDef(string name, string ip, string port, string client, string version)
{ {
ServerName = SecurityFuncs.Base64DecodeOld(name); ServerName = SecurityFuncs.Base64DecodeOld(name);
ServerIP = SecurityFuncs.Base64DecodeOld(ip); ServerIP = SecurityFuncs.Base64DecodeOld(ip);

View File

@ -23,6 +23,7 @@ namespace NovetusLauncher
} }
static bool formsOpen = false; static bool formsOpen = false;
static LauncherFormShared entryPointForm;
/// <summary> /// <summary>
/// Program entry point. /// Program entry point.
@ -32,6 +33,7 @@ namespace NovetusLauncher
{ {
System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.EnableVisualStyles();
System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
entryPointForm = new LauncherFormShared();
if (!Directory.Exists(GlobalPaths.LogDir)) if (!Directory.Exists(GlobalPaths.LogDir))
{ {
@ -79,15 +81,29 @@ namespace NovetusLauncher
Run(args, isSDK, state); Run(args, isSDK, state);
} }
static void CreateFiles()
{
if (!File.Exists(GlobalPaths.ConfigDir + "\\servers.txt"))
{
Util.ConsolePrint("WARNING - " + GlobalPaths.ConfigDir + "\\servers.txt not found. Creating empty file.", 5);
File.Create(GlobalPaths.ConfigDir + "\\servers.txt").Dispose();
}
if (!File.Exists(GlobalPaths.ConfigDir + "\\ports.txt"))
{
Util.ConsolePrint("WARNING - " + GlobalPaths.ConfigDir + "\\ports.txt not found. Creating empty file.", 5);
File.Create(GlobalPaths.ConfigDir + "\\ports.txt").Dispose();
}
FileManagement.CreateInitialFileListIfNeededMulti();
FileManagement.CreateAssetCacheDirectories();
Util.InitUPnP();
Util.StartDiscord();
}
static void Run(string[] args, bool sdk = false, CMDState state = CMDState.CMDOpen) static void Run(string[] args, bool sdk = false, CMDState state = CMDState.CMDOpen)
{ {
try try
{ {
FileManagement.CreateInitialFileListIfNeededMulti();
FileManagement.CreateAssetCacheDirectories();
Util.InitUPnP();
Util.StartDiscord();
while (!GlobalVars.AppClosed) while (!GlobalVars.AppClosed)
{ {
System.Windows.Forms.Application.DoEvents(); System.Windows.Forms.Application.DoEvents();
@ -101,6 +117,8 @@ namespace NovetusLauncher
console.Show(); console.Show();
} }
CreateFiles();
if (state != CMDState.CMDOnly) if (state != CMDState.CMDOnly)
{ {
if (!sdk) if (!sdk)

View File

@ -87,8 +87,8 @@ namespace NovetusURI
string port = SecurityFuncs.Base64Decode(SplitArg[1]); string port = SecurityFuncs.Base64Decode(SplitArg[1]);
string client = SecurityFuncs.Base64Decode(SplitArg[2]); string client = SecurityFuncs.Base64Decode(SplitArg[2]);
GlobalVars.UserConfiguration.SelectedClient = client; GlobalVars.UserConfiguration.SelectedClient = client;
GlobalVars.IP = ip; GlobalVars.CurrentServer.ServerIP = ip;
GlobalVars.JoinPort = Convert.ToInt32(port); GlobalVars.CurrentServer.ServerPort = Convert.ToInt32(port);
ClientManagement.ReadClientValues(); ClientManagement.ReadClientValues();
} }
catch (Exception ex) catch (Exception ex)