diff --git a/Novetus/NovetusCMD/NovetusCMD.cs b/Novetus/NovetusCMD/NovetusCMD.cs index 38346cd..3edf786 100644 --- a/Novetus/NovetusCMD/NovetusCMD.cs +++ b/Novetus/NovetusCMD/NovetusCMD.cs @@ -317,7 +317,7 @@ namespace NovetusCMD static void ServerExited(object sender, EventArgs e) { - GlobalVars.GameOpened = GlobalVars.OpenedGame.None; + GlobalVars.GameOpened = ScriptType.None; GlobalFuncs.PingMasterServer(0, "The server has removed itself from the master server list."); Environment.Exit(0); } diff --git a/Novetus/NovetusCore/CharCustom/CharacterCustomizationShared.cs b/Novetus/NovetusCore/CharCustom/CharacterCustomizationShared.cs index 9a7e5dc..304ea9a 100644 --- a/Novetus/NovetusCore/CharCustom/CharacterCustomizationShared.cs +++ b/Novetus/NovetusCore/CharCustom/CharacterCustomizationShared.cs @@ -155,14 +155,14 @@ class CharacterCustomizationShared } //discord - GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InCustomization, GlobalVars.UserConfiguration.Map); + GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InCustomization); GlobalFuncs.ReloadLoadoutValue(); } public void CloseEvent() { - GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InLauncher, ""); + GlobalFuncs.UpdateRichPresence(GlobalFuncs.GetStateForType(GlobalVars.GameOpened)); GlobalFuncs.ReloadLoadoutValue(); SaveOutfit(false); } diff --git a/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs b/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs index f22e0bd..6048641 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs @@ -1205,6 +1205,17 @@ public class GlobalFuncs } } + public static void UpdateRichPresence(GlobalVars.LauncherState state, bool initial = false) + { + string mapname = ""; + if (GlobalVars.GameOpened != ScriptType.Client) + { + mapname = GlobalVars.UserConfiguration.Map; + } + + UpdateRichPresence(state, GlobalVars.UserConfiguration.SelectedClient, mapname, initial); + } + public static void UpdateRichPresence(GlobalVars.LauncherState state, string mapname, bool initial = false) { UpdateRichPresence(state, GlobalVars.UserConfiguration.SelectedClient, mapname, initial); @@ -1812,13 +1823,13 @@ public class GlobalFuncs switch (type) { case ScriptType.Client: - if (!GlobalVars.LocalPlayMode && GlobalVars.GameOpened != GlobalVars.OpenedGame.Server) + if (!GlobalVars.LocalPlayMode && GlobalVars.GameOpened != ScriptType.Server) { goto default; } break; case ScriptType.Server: - if (GlobalVars.GameOpened == GlobalVars.OpenedGame.Server) + if (GlobalVars.GameOpened == ScriptType.Server) { #if LAUNCHER if (box != null) @@ -1844,9 +1855,19 @@ public class GlobalFuncs #endif GlobalVars.UserConfiguration.FirstServerLaunch = false; } + else + { + goto default; + } + break; + case ScriptType.Solo: + if (GlobalVars.GameOpened != ScriptType.Studio) + { + goto default; + } break; default: - if (GlobalVars.GameOpened == GlobalVars.OpenedGame.Client) + if (GlobalVars.GameOpened != ScriptType.None) { #if LAUNCHER if (box != null) @@ -2038,13 +2059,18 @@ public class GlobalFuncs switch (type) { case ScriptType.Client: - if (!GlobalVars.LocalPlayMode && GlobalVars.GameOpened != GlobalVars.OpenedGame.Server) + if (!GlobalVars.LocalPlayMode && GlobalVars.GameOpened != ScriptType.Server) + { + goto default; + } + break; + case ScriptType.Solo: + if (GlobalVars.GameOpened != ScriptType.Studio) { goto default; } break; case ScriptType.Server: - GlobalVars.GameOpened = GlobalVars.OpenedGame.Server; #if LAUNCHER if (box != null) { @@ -2053,9 +2079,9 @@ public class GlobalFuncs #elif CMD PingMasterServer(1, "Server will now display on the defined master server."); #endif - break; + goto default; default: - GlobalVars.GameOpened = GlobalVars.OpenedGame.Client; + GlobalVars.GameOpened = type; break; } diff --git a/Novetus/NovetusCore/StorageAndFunctions/GlobalVars.cs b/Novetus/NovetusCore/StorageAndFunctions/GlobalVars.cs index 3f30cd8..feb27c9 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/GlobalVars.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/GlobalVars.cs @@ -12,6 +12,18 @@ using System.Collections.Generic; using System.Windows.Forms; #endregion +#region Script Type +public enum ScriptType +{ + Client = 0, + Server = 1, + Solo = 2, + Studio = 3, + EasterEgg = 4, + None = 5 +} +#endregion + #region Global Variables public static class GlobalVars { @@ -28,15 +40,6 @@ public static class GlobalVars } #endregion - #region - public enum OpenedGame - { - None = 0, - Client = 1, - Server = 2 - } - #endregion - #region Class definitions public static FileFormat.ProgramInfo ProgramInformation = new FileFormat.ProgramInfo(); public static FileFormat.Config UserConfiguration = new FileFormat.Config(); @@ -51,7 +54,7 @@ public static class GlobalVars public static string ExternalIP = SecurityFuncs.GetExternalIPAddress(); public static int DefaultRobloxPort = 53640; public static int JoinPort = DefaultRobloxPort; - public static OpenedGame GameOpened = OpenedGame.None; + public static ScriptType GameOpened = ScriptType.None; #endregion #region NovetusCMD diff --git a/Novetus/NovetusCore/StorageAndFunctions/ScriptFuncs.cs b/Novetus/NovetusCore/StorageAndFunctions/ScriptFuncs.cs index 7afa05e..5bd6e3e 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/ScriptFuncs.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/ScriptFuncs.cs @@ -7,18 +7,6 @@ using System.Text.RegularExpressions; using System.Windows.Forms; #endregion -#region Script Type -public enum ScriptType -{ - Client = 0, - Server = 1, - Solo = 2, - Studio = 3, - EasterEgg = 4, - None = 5 -} -#endregion - #region Script Functions public class ScriptFuncs { diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs index ef100bb..ab4fa55 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs @@ -192,7 +192,7 @@ namespace NovetusLauncher handlers.requestCallback += RequestCallback; DiscordRPC.Initialize(GlobalVars.appid, ref handlers, true, ""); - GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InLauncher, "", true); + GlobalFuncs.UpdateRichPresence(GlobalFuncs.GetStateForType(GlobalVars.GameOpened), true); } } #endregion @@ -291,14 +291,14 @@ namespace NovetusLauncher public void CloseEvent(CancelEventArgs e) { - if (GlobalVars.GameOpened != GlobalVars.OpenedGame.None) + if (GlobalVars.GameOpened != ScriptType.None) { switch (GlobalVars.GameOpened) { - case GlobalVars.OpenedGame.Client: + case ScriptType.Client: ShowCloseError("A game is open.", "Game", e); break; - case GlobalVars.OpenedGame.Server: + case ScriptType.Server: ShowCloseError("A server is open.", "Server", e); break; default: @@ -503,7 +503,7 @@ namespace NovetusLauncher GlobalFuncs.LaunchRBXClient(ScriptType.Server, no3d, false, new EventHandler(ServerExited), ConsoleBox); break; case ScriptType.Solo: - GlobalFuncs.LaunchRBXClient(ScriptType.Solo, false, false, new EventHandler(ClientExited), ConsoleBox); + GlobalFuncs.LaunchRBXClient(ScriptType.Solo, false, false, new EventHandler(SoloExited), ConsoleBox); break; case ScriptType.Studio: GlobalFuncs.LaunchRBXClient(ScriptType.Studio, false, nomap, new EventHandler(ClientExited), ConsoleBox); @@ -554,25 +554,35 @@ namespace NovetusLauncher void ClientExited(object sender, EventArgs e) { - if (!GlobalVars.LocalPlayMode && GlobalVars.GameOpened != GlobalVars.OpenedGame.Server) + if (!GlobalVars.LocalPlayMode && GlobalVars.GameOpened != ScriptType.Server) { - GlobalVars.GameOpened = GlobalVars.OpenedGame.None; + GlobalVars.GameOpened = ScriptType.None; } - GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InLauncher, ""); + GlobalFuncs.UpdateRichPresence(GlobalFuncs.GetStateForType(GlobalVars.GameOpened)); + ClientExitedBase(sender, e); + } + + void SoloExited(object sender, EventArgs e) + { + if (GlobalVars.GameOpened != ScriptType.Studio) + { + GlobalVars.GameOpened = ScriptType.None; + } + GlobalFuncs.UpdateRichPresence(GlobalFuncs.GetStateForType(GlobalVars.GameOpened)); ClientExitedBase(sender, e); } void ServerExited(object sender, EventArgs e) { - GlobalVars.GameOpened = GlobalVars.OpenedGame.None; + GlobalVars.GameOpened = ScriptType.None; GlobalFuncs.PingMasterServer(0, "The server has removed itself from the master server list.", ConsoleBox); ClientExitedBase(sender, e); } void EasterEggExited(object sender, EventArgs e) { - GlobalVars.GameOpened = GlobalVars.OpenedGame.None; - GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InLauncher, ""); + GlobalVars.GameOpened = ScriptType.None; + GlobalFuncs.UpdateRichPresence(GlobalFuncs.GetStateForType(GlobalVars.GameOpened)); SplashLabel.Text = LocalVars.prevsplash; if (GlobalVars.AdminMode) { @@ -1062,7 +1072,7 @@ namespace NovetusLauncher public void RestartLauncherAfterSetting(bool check, string title, string subText) { - if (GlobalVars.GameOpened != GlobalVars.OpenedGame.None) + if (GlobalVars.GameOpened != ScriptType.None) { MessageBox.Show("You must close the currently open client before this setting can be applied.", "Novetus - Client is Open Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -1190,7 +1200,7 @@ namespace NovetusLauncher public void ChangeClient() { - if (GlobalVars.GameOpened != GlobalVars.OpenedGame.None) + if (GlobalVars.GameOpened != ScriptType.None) { MessageBox.Show("You must close the currently open client before changing clients.", "Novetus - Client is Open Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -1233,7 +1243,7 @@ namespace NovetusLauncher return; } - GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InLauncher, ""); + GlobalFuncs.UpdateRichPresence(GlobalFuncs.GetStateForType(GlobalVars.GameOpened)); FormCollection fc = Application.OpenForms; diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishInterface.xaml.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishInterface.xaml.cs index 6988265..96d51eb 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishInterface.xaml.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/Stylish/LauncherFormStylishInterface.xaml.cs @@ -129,7 +129,7 @@ namespace NovetusLauncher if (!IsLoaded) return; - if (GlobalVars.GameOpened != GlobalVars.OpenedGame.None) + if (GlobalVars.GameOpened != ScriptType.None) { System.Windows.Forms.MessageBox.Show("You must close the currently open client before changing clients.", "Novetus - Client is Open Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -178,7 +178,7 @@ namespace NovetusLauncher GlobalVars.UserConfiguration.SelectedClient + " | MAP: " + GlobalVars.UserConfiguration.Map + "]"; - GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InLauncher, ""); + GlobalFuncs.UpdateRichPresence(GlobalFuncs.GetStateForType(GlobalVars.GameOpened)); FormCollection fc = System.Windows.Forms.Application.OpenForms; @@ -455,7 +455,7 @@ namespace NovetusLauncher if (LocalVars.launcherInitState) return; - if (GlobalVars.GameOpened != GlobalVars.OpenedGame.None) + if (GlobalVars.GameOpened != ScriptType.None) { System.Windows.Forms.MessageBox.Show("You must close the currently open client before changing styles.", "Novetus - Client is Open Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; diff --git a/Novetus/NovetusLauncher/Forms/SDK/NovetusSDK.cs b/Novetus/NovetusLauncher/Forms/SDK/NovetusSDK.cs index efd7855..523073e 100644 --- a/Novetus/NovetusLauncher/Forms/SDK/NovetusSDK.cs +++ b/Novetus/NovetusLauncher/Forms/SDK/NovetusSDK.cs @@ -111,7 +111,7 @@ public partial class NovetusSDK : Form #else GlobalFuncs.LaunchRBXClient("ClientScriptTester", ScriptType.Client, false, false, null); #endif - GlobalVars.GameOpened = GlobalVars.OpenedGame.None; + GlobalVars.GameOpened = ScriptType.None; break; case SDKApps.XMLContentEditor: XMLContentEditor xml = new XMLContentEditor(); diff --git a/Novetus/NovetusLauncher/Forms/ServerBrowser.cs b/Novetus/NovetusLauncher/Forms/ServerBrowser.cs index 25077e2..35ea795 100644 --- a/Novetus/NovetusLauncher/Forms/ServerBrowser.cs +++ b/Novetus/NovetusLauncher/Forms/ServerBrowser.cs @@ -65,11 +65,11 @@ namespace NovetusLauncher void ClientExited(object sender, EventArgs e) { - if (!GlobalVars.LocalPlayMode && GlobalVars.GameOpened != GlobalVars.OpenedGame.Server) + if (!GlobalVars.LocalPlayMode && GlobalVars.GameOpened != ScriptType.Server) { - GlobalVars.GameOpened = GlobalVars.OpenedGame.None; + GlobalVars.GameOpened = ScriptType.None; } - GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InLauncher, ""); + GlobalFuncs.UpdateRichPresence(GlobalFuncs.GetStateForType(GlobalVars.GameOpened)); GlobalVars.IP = oldIP; GlobalVars.JoinPort = oldPort; } diff --git a/Novetus/NovetusURI/Forms/LoaderForm.cs b/Novetus/NovetusURI/Forms/LoaderForm.cs index 607390c..d5b041d 100644 --- a/Novetus/NovetusURI/Forms/LoaderForm.cs +++ b/Novetus/NovetusURI/Forms/LoaderForm.cs @@ -53,7 +53,7 @@ namespace NovetusURI handlers.requestCallback += RequestCallback; DiscordRPC.Initialize(GlobalVars.appid, ref handlers, true, ""); - GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.LoadingURI, "", true); + GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.LoadingURI, true); } } #endregion @@ -81,11 +81,11 @@ namespace NovetusURI void ClientExited(object sender, EventArgs e) { - if (!GlobalVars.LocalPlayMode && GlobalVars.GameOpened != GlobalVars.OpenedGame.Server) + if (!GlobalVars.LocalPlayMode && GlobalVars.GameOpened != ScriptType.Server) { - GlobalVars.GameOpened = GlobalVars.OpenedGame.None; + GlobalVars.GameOpened = ScriptType.None; } - GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InLauncher, ""); + GlobalFuncs.UpdateRichPresence(GlobalFuncs.GetStateForType(GlobalVars.GameOpened)); Close(); }