diff --git a/Novetus/NovetusCore/Classes/Settings.cs b/Novetus/NovetusCore/Classes/Settings.cs index 9c8e504..ab22401 100644 --- a/Novetus/NovetusCore/Classes/Settings.cs +++ b/Novetus/NovetusCore/Classes/Settings.cs @@ -30,7 +30,8 @@ public class Settings { None = 0, Extended = 1, - Compact = 2 + Compact = 2, + Stylish = 3 } public enum ClientLoadOptions diff --git a/Novetus/NovetusCore/NovetusCore.projitems b/Novetus/NovetusCore/NovetusCore.projitems index 8b94f33..1aa561b 100644 --- a/Novetus/NovetusCore/NovetusCore.projitems +++ b/Novetus/NovetusCore/NovetusCore.projitems @@ -32,6 +32,5 @@ Component - \ No newline at end of file diff --git a/Novetus/NovetusCore/WinForms/TreeNodeHelper.cs b/Novetus/NovetusLauncher/Classes/Launcher/TreeNodeHelper.cs similarity index 51% rename from Novetus/NovetusCore/WinForms/TreeNodeHelper.cs rename to Novetus/NovetusLauncher/Classes/Launcher/TreeNodeHelper.cs index 998b7e4..fc2445f 100644 --- a/Novetus/NovetusCore/WinForms/TreeNodeHelper.cs +++ b/Novetus/NovetusLauncher/Classes/Launcher/TreeNodeHelper.cs @@ -3,7 +3,10 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Reflection; +using System.Windows; using System.Windows.Forms; +using System.Windows.Media; #endregion #region Tree Node Helper @@ -47,30 +50,6 @@ public static class TreeNodeHelper return null; } - public static string GetFolderNameFromPrefix(string source, string seperator = " -") - { - try - { - string result = source.Substring(0, source.IndexOf(seperator)); - - if (Directory.Exists(GlobalPaths.MapsDir + @"\\" + result)) - { - return result + @"\\"; - } - else - { - return ""; - } - } - catch (Exception ex) - { -#if URI || LAUNCHER || CMD - GlobalFuncs.LogExceptions(ex); -#endif - return ""; - } - } - public static void CopyNodes(TreeNodeCollection oldcollection, TreeNodeCollection newcollection) { foreach (TreeNode node in oldcollection) @@ -78,45 +57,5 @@ public static class TreeNodeHelper newcollection.Add((TreeNode)node.Clone()); } } - - public static List GetAllNodes(this TreeView _self) - { - List result = new List(); - foreach (TreeNode child in _self.Nodes) - { - result.AddRange(child.GetAllNodes()); - } - return result; - } - - public static List GetAllNodes(this TreeNode _self) - { - List result = new List(); - result.Add(_self); - foreach (TreeNode child in _self.Nodes) - { - result.AddRange(child.GetAllNodes()); - } - return result; - } - - public static List Ancestors(this TreeNode node) - { - return AncestorsInternal(node).Reverse().ToList(); - } - public static List AncestorsAndSelf(this TreeNode node) - { - return AncestorsInternal(node, true).Reverse().ToList(); - } - private static IEnumerable AncestorsInternal(TreeNode node, bool self = false) - { - if (self) - yield return node; - while (node.Parent != null) - { - node = node.Parent; - yield return node; - } - } } #endregion diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs index 29fac8b..db7867b 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs @@ -67,7 +67,7 @@ namespace NovetusLauncher try { NetFuncs.StartUPnP(device, protocol, port); - string IP = (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : device.GetExternalIP().ToString()); + 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) @@ -85,7 +85,7 @@ namespace NovetusLauncher try { NetFuncs.StopUPnP(device, protocol, port); - string IP = (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : device.GetExternalIP().ToString()); + 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) @@ -101,7 +101,7 @@ namespace NovetusLauncher try { INatDevice device = args.Device; - string IP = (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : device.GetExternalIP().ToString()); + 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); @@ -118,7 +118,7 @@ namespace NovetusLauncher try { INatDevice device = args.Device; - string IP = (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : device.GetExternalIP().ToString()); + 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); @@ -184,22 +184,25 @@ namespace NovetusLauncher GlobalFuncs.ConsolePrint("Novetus version " + GlobalVars.ProgramInformation.Version + " loaded. Initializing config.", 4, ConsoleBox); GlobalFuncs.ConsolePrint("Novetus path: " + GlobalPaths.BasePath, 4, ConsoleBox); - if (File.Exists(GlobalPaths.RootPath + "\\changelog.txt")) + if (FormStyle != Settings.Style.Stylish) { - ChangelogBox.Text = File.ReadAllText(GlobalPaths.RootPath + "\\changelog.txt"); - } - else - { - GlobalFuncs.ConsolePrint("ERROR - " + GlobalPaths.RootPath + "\\changelog.txt not found.", 2, ConsoleBox); - } + if (File.Exists(GlobalPaths.RootPath + "\\changelog.txt")) + { + ChangelogBox.Text = File.ReadAllText(GlobalPaths.RootPath + "\\changelog.txt"); + } + else + { + GlobalFuncs.ConsolePrint("ERROR - " + GlobalPaths.RootPath + "\\changelog.txt not found.", 2, ConsoleBox); + } - if (File.Exists(GlobalPaths.RootPath + "\\README-AND-CREDITS.TXT")) - { - ReadmeBox.Text = File.ReadAllText(GlobalPaths.RootPath + "\\README-AND-CREDITS.TXT"); - } - else - { - GlobalFuncs.ConsolePrint("ERROR - " + GlobalPaths.RootPath + "\\README-AND-CREDITS.TXT not found.", 2, ConsoleBox); + if (File.Exists(GlobalPaths.RootPath + "\\README-AND-CREDITS.TXT")) + { + ReadmeBox.Text = File.ReadAllText(GlobalPaths.RootPath + "\\README-AND-CREDITS.TXT"); + } + else + { + GlobalFuncs.ConsolePrint("ERROR - " + GlobalPaths.RootPath + "\\README-AND-CREDITS.TXT not found.", 2, ConsoleBox); + } } if (!File.Exists(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName)) @@ -225,17 +228,26 @@ namespace NovetusLauncher GlobalFuncs.CreateAssetCacheDirectories(); - ProductVersionLabel.Text = Application.ProductVersion; SetupImportantData(); - NovetusVersionLabel.Text = GlobalVars.ProgramInformation.Version; SplashLabel.Text = SplashReader.GetSplash(); LocalVars.prevsplash = SplashLabel.Text; - ReadConfigValues(true); + if (FormStyle != Settings.Style.Stylish) + { + ProductVersionLabel.Text = Application.ProductVersion; + NovetusVersionLabel.Text = GlobalVars.ProgramInformation.Version; + + ReadConfigValues(true); + } + InitUPnP(); StartDiscord(); - LocalVars.launcherInitState = false; + + if (FormStyle != Settings.Style.Stylish) + { + LocalVars.launcherInitState = false; + } } public void CloseEvent() @@ -742,29 +754,20 @@ namespace NovetusLauncher { GlobalFuncs.ReadClientValues(ConsoleBox, initial); - switch (GlobalVars.SelectedClientInfo.UsesPlayerName) - { - case true: - PlayerNameTextBox.Enabled = true; - break; - case false: - PlayerNameTextBox.Enabled = false; - break; - } + PlayerNameTextBox.Enabled = GlobalVars.SelectedClientInfo.UsesPlayerName; + + PlayerIDTextBox.Enabled = GlobalVars.SelectedClientInfo.UsesID; + RegeneratePlayerIDButton.Enabled = GlobalVars.SelectedClientInfo.UsesID; switch (GlobalVars.SelectedClientInfo.UsesID) { case true: - PlayerIDTextBox.Enabled = true; - RegeneratePlayerIDButton.Enabled = true; if (GlobalVars.IP.Equals("localhost")) { LocalPlayCheckBox.Enabled = true; } break; case false: - PlayerIDTextBox.Enabled = false; - RegeneratePlayerIDButton.Enabled = false; LocalPlayCheckBox.Enabled = false; GlobalVars.LocalPlayMode = false; break; @@ -860,13 +863,10 @@ namespace NovetusLauncher TreeNodeHelper.CopyNodes(Tree.Nodes, _TreeCache.Nodes); Tree.SelectedNode = TreeNodeHelper.SearchTreeView(GlobalVars.UserConfiguration.Map, Tree.Nodes); Tree.Focus(); - if (File.Exists(GlobalPaths.RootPath + @"\\" + Tree.SelectedNode.FullPath.ToString().Replace(".rbxl", "").Replace(".rbxlx", "") + "_desc.txt")) + + if (FormStyle != Settings.Style.Stylish) { - MapDescBox.Text = File.ReadAllText(GlobalPaths.RootPath + @"\\" + Tree.SelectedNode.FullPath.ToString().Replace(".rbxl", "").Replace(".rbxlx", "") + "_desc.txt"); - } - else - { - MapDescBox.Text = Tree.SelectedNode.Text.ToString(); + LoadMapDesc(); } } @@ -893,19 +893,27 @@ namespace NovetusLauncher GlobalVars.UserConfiguration.Map = Tree.SelectedNode.Text.ToString(); GlobalVars.UserConfiguration.MapPathSnip = Tree.SelectedNode.FullPath.ToString().Replace(@"\", @"\\"); GlobalVars.UserConfiguration.MapPath = GlobalPaths.BasePath + @"\\" + GlobalVars.UserConfiguration.MapPathSnip; - SelectedMapLabel.Text = GlobalVars.UserConfiguration.Map; - if (File.Exists(GlobalPaths.RootPath + @"\\" + Tree.SelectedNode.FullPath.ToString().Replace(".rbxl", "").Replace(".rbxlx", "") + "_desc.txt")) + if (FormStyle != Settings.Style.Stylish) { - MapDescBox.Text = File.ReadAllText(GlobalPaths.RootPath + @"\\" + Tree.SelectedNode.FullPath.ToString().Replace(".rbxl", "").Replace(".rbxlx", "") + "_desc.txt"); - } - else - { - MapDescBox.Text = Tree.SelectedNode.Text.ToString(); + SelectedMapLabel.Text = GlobalVars.UserConfiguration.Map; + LoadMapDesc(); } } } + private void LoadMapDesc() + { + if (File.Exists(GlobalPaths.RootPath + @"\\" + Tree.SelectedNode.FullPath.ToString().Replace(".rbxl", "").Replace(".rbxlx", "") + "_desc.txt")) + { + MapDescBox.Text = File.ReadAllText(GlobalPaths.RootPath + @"\\" + Tree.SelectedNode.FullPath.ToString().Replace(".rbxl", "").Replace(".rbxlx", "") + "_desc.txt"); + } + else + { + MapDescBox.Text = Tree.SelectedNode.Text.ToString(); + } + } + public void AddIPPortListing(ListBox box, string file, object val) { File.AppendAllText(file, val + Environment.NewLine); @@ -983,16 +991,43 @@ namespace NovetusLauncher public void ChangeClient() { + if (ClientBox.Items.Count == 0) + return; + + string clientdir = GlobalPaths.ClientDir; + DirectoryInfo dinfo = new DirectoryInfo(clientdir); + DirectoryInfo[] Dirs = dinfo.GetDirectories(); + List clientNameList = new List(); + foreach (DirectoryInfo dir in Dirs) + { + clientNameList.Add(dir.Name); + } + + if (ClientBox.Items.Count == (clientNameList.Count - 1)) + return; + + if (ClientBox.SelectedItem == null) + return; + string ourselectedclient = GlobalVars.UserConfiguration.SelectedClient; GlobalVars.UserConfiguration.SelectedClient = ClientBox.SelectedItem.ToString(); - if (!ourselectedclient.Equals(GlobalVars.UserConfiguration.SelectedClient)) + + if (!string.IsNullOrWhiteSpace(ourselectedclient)) { - ReadClientValues(true); + if (!ourselectedclient.Equals(GlobalVars.UserConfiguration.SelectedClient)) + { + ReadClientValues(true); + } + else + { + ReadClientValues(); + } } else { - ReadClientValues(); + return; } + GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InLauncher, ""); FormCollection fc = Application.OpenForms; diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylish.Designer.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylish.Designer.cs index 624902e..ed9c214 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylish.Designer.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylish.Designer.cs @@ -32,7 +32,7 @@ namespace NovetusLauncher System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LauncherFormStylish)); this.splashLabel = new System.Windows.Forms.Label(); this.elementHost1 = new System.Windows.Forms.Integration.ElementHost(); - this.launcherFormStylishInterface1 = new LauncherFormStylishInterface(); + this.launcherFormStylishInterface1 = new LauncherFormStylishInterface(this); this.logoImageBox = new System.Windows.Forms.PictureBox(); ((System.ComponentModel.ISupportInitialize)(this.logoImageBox)).BeginInit(); this.SuspendLayout(); @@ -94,9 +94,9 @@ namespace NovetusLauncher this.Name = "LauncherFormStylish"; this.Text = "Novetus"; this.Load += new System.EventHandler(this.LauncherFormStylish_Load); + this.Closing += new System.ComponentModel.CancelEventHandler(this.LauncherFormStylish_Close); ((System.ComponentModel.ISupportInitialize)(this.logoImageBox)).EndInit(); this.ResumeLayout(false); - } #endregion diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylish.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylish.cs index cec8e83..c884395 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylish.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylish.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; +using System.IO; using System.Linq; using System.Text; using System.Windows.Forms; @@ -19,22 +20,72 @@ namespace NovetusLauncher private void LauncherFormStylish_Load(object sender, EventArgs e) { - CryptoRandom rand = new CryptoRandom(); - int randColor = rand.Next(0, 2); - - switch (randColor) + try { - case 0: - //orange message + //splash loader + CryptoRandom rand = new CryptoRandom(); + int randColor = rand.Next(0, 3); + + if (randColor == 0) + { splashLabel.BackColor = Color.FromArgb(245, 135, 13); - break; - case 1: - //red message + } + else if (randColor == 1) + { splashLabel.BackColor = Color.FromArgb(255, 3, 2); - break; - default: - break; + } + else if (randColor == 2) + { + splashLabel.BackColor = Color.FromArgb(238, 154, 181); + } + + launcherFormStylishInterface1.mapsBox.BackColor = Color.FromArgb(237, 237, 237); + + launcherFormStylishInterface1.launcherForm.SplashLabel = splashLabel; + launcherFormStylishInterface1.launcherForm.InitForm(); + + if (File.Exists(GlobalPaths.RootPath + "\\changelog.txt")) + { + launcherFormStylishInterface1.changelogBox.Text = File.ReadAllText(GlobalPaths.RootPath + "\\changelog.txt"); + } + + if (File.Exists(GlobalPaths.RootPath + "\\README-AND-CREDITS.TXT")) + { + launcherFormStylishInterface1.readmeBox.Text = File.ReadAllText(GlobalPaths.RootPath + "\\README-AND-CREDITS.TXT"); + } + + launcherFormStylishInterface1.versionLabel.Content = Application.ProductVersion; + launcherFormStylishInterface1.versionNovetusLabel.Content = GlobalVars.ProgramInformation.Version; + + if (launcherFormStylishInterface1.playTab != null && launcherFormStylishInterface1.playTab.IsSelected) + { + if (launcherFormStylishInterface1.mapsBox.Nodes.Count == 0) + { + launcherFormStylishInterface1.launcherForm.RefreshMaps(); + launcherFormStylishInterface1.LoadMapDesc(); + } + } + + ReadConfigValues(true); + + LocalVars.launcherInitState = false; + CenterToScreen(); } + catch (Exception ex) + { + GlobalFuncs.LogExceptions(ex); + } + } + + void LauncherFormStylish_Close(object sender, CancelEventArgs e) + { + WriteConfigValues(); + + if (GlobalVars.UserConfiguration.DiscordPresence) + { + DiscordRPC.Shutdown(); + } + Application.Exit(); } void splashLabel_Paint(object sender, PaintEventArgs e) @@ -51,5 +102,60 @@ namespace NovetusLauncher color, width, style, color, width, style); } + + public void ReadConfigValues(bool initial = false) + { + GlobalFuncs.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, false); + + //CloseOnLaunchCheckbox.Checked = GlobalVars.UserConfiguration.CloseOnLaunch; + launcherFormStylishInterface1.userIDBox.Text = GlobalVars.UserConfiguration.UserID.ToString(); + launcherFormStylishInterface1.tripcodeLabel.Content = GlobalVars.UserConfiguration.PlayerTripcode.ToString(); + launcherFormStylishInterface1.maxPlayersBox.Text = GlobalVars.UserConfiguration.PlayerLimit.ToString(); + launcherFormStylishInterface1.userNameBox.Text = GlobalVars.UserConfiguration.PlayerName; + //SelectedClientLabel.Text = GlobalVars.UserConfiguration.SelectedClient; + //SelectedMapLabel.Text = GlobalVars.UserConfiguration.Map; + //Tree.SelectedNode = TreeNodeHelper.SearchTreeView(GlobalVars.UserConfiguration.Map, Tree.Nodes); + //Tree.Focus(); + launcherFormStylishInterface1.joinPortBox.Text = GlobalVars.JoinPort.ToString(); + launcherFormStylishInterface1.serverPortBox.Text = GlobalVars.UserConfiguration.RobloxPort.ToString(); + //DiscordPresenceCheckbox.Checked = GlobalVars.UserConfiguration.DiscordPresence; + launcherFormStylishInterface1.uPnPBox.IsChecked = GlobalVars.UserConfiguration.UPnP; + launcherFormStylishInterface1.NotifBox.IsChecked = GlobalVars.UserConfiguration.ShowServerNotifications; + launcherFormStylishInterface1.browserNameBox.Text = GlobalVars.UserConfiguration.ServerBrowserServerName; + launcherFormStylishInterface1.browserAddressBox.Text = GlobalVars.UserConfiguration.ServerBrowserServerAddress; + + ReadClientValues(initial); + } + + public void WriteConfigValues(bool ShowBox = false) + { + GlobalFuncs.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, true); + ReadClientValues(); + if (ShowBox) + { + MessageBox.Show("Config Saved!", "Novetus - Config Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + public void ReadClientValues(bool initial = false) + { + GlobalFuncs.ReadClientValues(null, initial); + + launcherFormStylishInterface1.userNameBox.IsEnabled = GlobalVars.SelectedClientInfo.UsesPlayerName; + + launcherFormStylishInterface1.userIDBox.IsEnabled = GlobalVars.SelectedClientInfo.UsesID; + launcherFormStylishInterface1.regenerateIDButton.IsEnabled = GlobalVars.SelectedClientInfo.UsesID; + + if (!string.IsNullOrWhiteSpace(GlobalVars.SelectedClientInfo.Warning)) + { + launcherFormStylishInterface1.clientWarningBox.Text = GlobalVars.SelectedClientInfo.Warning; + } + else + { + launcherFormStylishInterface1.clientWarningBox.Text = ""; + } + + launcherFormStylishInterface1.clientDescBox.Text = GlobalVars.SelectedClientInfo.Description; + //SelectedClientLabel.Text = GlobalVars.UserConfiguration.SelectedClient; + } } } diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishInterface.xaml b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishInterface.xaml index a38a252..b686ff9 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishInterface.xaml +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishInterface.xaml @@ -4,10 +4,14 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:properties="clr-namespace:NovetusLauncher.Properties" + xmlns:local="clr-namespace:NovetusLauncher" + xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" mc:Ignorable="d" Height="299.569" Width="695.158"> - - + + @@ -518,51 +529,66 @@ - - + + - + + -