fix ricxh presence. change OpenedGame to a ScriptType

This commit is contained in:
Bitl 2021-11-05 08:50:40 -07:00
parent 5c18a023d6
commit 06d4d6771d
10 changed files with 84 additions and 57 deletions

View File

@ -317,7 +317,7 @@ namespace NovetusCMD
static void ServerExited(object sender, EventArgs e) 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."); GlobalFuncs.PingMasterServer(0, "The server has removed itself from the master server list.");
Environment.Exit(0); Environment.Exit(0);
} }

View File

@ -155,14 +155,14 @@ class CharacterCustomizationShared
} }
//discord //discord
GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InCustomization, GlobalVars.UserConfiguration.Map); GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InCustomization);
GlobalFuncs.ReloadLoadoutValue(); GlobalFuncs.ReloadLoadoutValue();
} }
public void CloseEvent() public void CloseEvent()
{ {
GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InLauncher, ""); GlobalFuncs.UpdateRichPresence(GlobalFuncs.GetStateForType(GlobalVars.GameOpened));
GlobalFuncs.ReloadLoadoutValue(); GlobalFuncs.ReloadLoadoutValue();
SaveOutfit(false); SaveOutfit(false);
} }

View File

@ -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) public static void UpdateRichPresence(GlobalVars.LauncherState state, string mapname, bool initial = false)
{ {
UpdateRichPresence(state, GlobalVars.UserConfiguration.SelectedClient, mapname, initial); UpdateRichPresence(state, GlobalVars.UserConfiguration.SelectedClient, mapname, initial);
@ -1812,13 +1823,13 @@ public class GlobalFuncs
switch (type) switch (type)
{ {
case ScriptType.Client: case ScriptType.Client:
if (!GlobalVars.LocalPlayMode && GlobalVars.GameOpened != GlobalVars.OpenedGame.Server) if (!GlobalVars.LocalPlayMode && GlobalVars.GameOpened != ScriptType.Server)
{ {
goto default; goto default;
} }
break; break;
case ScriptType.Server: case ScriptType.Server:
if (GlobalVars.GameOpened == GlobalVars.OpenedGame.Server) if (GlobalVars.GameOpened == ScriptType.Server)
{ {
#if LAUNCHER #if LAUNCHER
if (box != null) if (box != null)
@ -1844,9 +1855,19 @@ public class GlobalFuncs
#endif #endif
GlobalVars.UserConfiguration.FirstServerLaunch = false; GlobalVars.UserConfiguration.FirstServerLaunch = false;
} }
else
{
goto default;
}
break;
case ScriptType.Solo:
if (GlobalVars.GameOpened != ScriptType.Studio)
{
goto default;
}
break; break;
default: default:
if (GlobalVars.GameOpened == GlobalVars.OpenedGame.Client) if (GlobalVars.GameOpened != ScriptType.None)
{ {
#if LAUNCHER #if LAUNCHER
if (box != null) if (box != null)
@ -2038,13 +2059,18 @@ public class GlobalFuncs
switch (type) switch (type)
{ {
case ScriptType.Client: 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; goto default;
} }
break; break;
case ScriptType.Server: case ScriptType.Server:
GlobalVars.GameOpened = GlobalVars.OpenedGame.Server;
#if LAUNCHER #if LAUNCHER
if (box != null) if (box != null)
{ {
@ -2053,9 +2079,9 @@ public class GlobalFuncs
#elif CMD #elif CMD
PingMasterServer(1, "Server will now display on the defined master server."); PingMasterServer(1, "Server will now display on the defined master server.");
#endif #endif
break; goto default;
default: default:
GlobalVars.GameOpened = GlobalVars.OpenedGame.Client; GlobalVars.GameOpened = type;
break; break;
} }

View File

@ -12,6 +12,18 @@ using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
#endregion #endregion
#region Script Type
public enum ScriptType
{
Client = 0,
Server = 1,
Solo = 2,
Studio = 3,
EasterEgg = 4,
None = 5
}
#endregion
#region Global Variables #region Global Variables
public static class GlobalVars public static class GlobalVars
{ {
@ -28,15 +40,6 @@ public static class GlobalVars
} }
#endregion #endregion
#region
public enum OpenedGame
{
None = 0,
Client = 1,
Server = 2
}
#endregion
#region Class definitions #region Class definitions
public static FileFormat.ProgramInfo ProgramInformation = new FileFormat.ProgramInfo(); public static FileFormat.ProgramInfo ProgramInformation = new FileFormat.ProgramInfo();
public static FileFormat.Config UserConfiguration = new FileFormat.Config(); public static FileFormat.Config UserConfiguration = new FileFormat.Config();
@ -51,7 +54,7 @@ public static class GlobalVars
public static string ExternalIP = SecurityFuncs.GetExternalIPAddress(); public static string ExternalIP = SecurityFuncs.GetExternalIPAddress();
public static int DefaultRobloxPort = 53640; public static int DefaultRobloxPort = 53640;
public static int JoinPort = DefaultRobloxPort; public static int JoinPort = DefaultRobloxPort;
public static OpenedGame GameOpened = OpenedGame.None; public static ScriptType GameOpened = ScriptType.None;
#endregion #endregion
#region NovetusCMD #region NovetusCMD

View File

@ -7,18 +7,6 @@ using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
#endregion #endregion
#region Script Type
public enum ScriptType
{
Client = 0,
Server = 1,
Solo = 2,
Studio = 3,
EasterEgg = 4,
None = 5
}
#endregion
#region Script Functions #region Script Functions
public class ScriptFuncs public class ScriptFuncs
{ {

View File

@ -192,7 +192,7 @@ namespace NovetusLauncher
handlers.requestCallback += RequestCallback; handlers.requestCallback += RequestCallback;
DiscordRPC.Initialize(GlobalVars.appid, ref handlers, true, ""); DiscordRPC.Initialize(GlobalVars.appid, ref handlers, true, "");
GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InLauncher, "", true); GlobalFuncs.UpdateRichPresence(GlobalFuncs.GetStateForType(GlobalVars.GameOpened), true);
} }
} }
#endregion #endregion
@ -291,14 +291,14 @@ namespace NovetusLauncher
public void CloseEvent(CancelEventArgs e) public void CloseEvent(CancelEventArgs e)
{ {
if (GlobalVars.GameOpened != GlobalVars.OpenedGame.None) if (GlobalVars.GameOpened != ScriptType.None)
{ {
switch (GlobalVars.GameOpened) switch (GlobalVars.GameOpened)
{ {
case GlobalVars.OpenedGame.Client: case ScriptType.Client:
ShowCloseError("A game is open.", "Game", e); ShowCloseError("A game is open.", "Game", e);
break; break;
case GlobalVars.OpenedGame.Server: case ScriptType.Server:
ShowCloseError("A server is open.", "Server", e); ShowCloseError("A server is open.", "Server", e);
break; break;
default: default:
@ -503,7 +503,7 @@ namespace NovetusLauncher
GlobalFuncs.LaunchRBXClient(ScriptType.Server, no3d, false, new EventHandler(ServerExited), ConsoleBox); GlobalFuncs.LaunchRBXClient(ScriptType.Server, no3d, false, new EventHandler(ServerExited), ConsoleBox);
break; break;
case ScriptType.Solo: case ScriptType.Solo:
GlobalFuncs.LaunchRBXClient(ScriptType.Solo, false, false, new EventHandler(ClientExited), ConsoleBox); GlobalFuncs.LaunchRBXClient(ScriptType.Solo, false, false, new EventHandler(SoloExited), ConsoleBox);
break; break;
case ScriptType.Studio: case ScriptType.Studio:
GlobalFuncs.LaunchRBXClient(ScriptType.Studio, false, nomap, new EventHandler(ClientExited), ConsoleBox); GlobalFuncs.LaunchRBXClient(ScriptType.Studio, false, nomap, new EventHandler(ClientExited), ConsoleBox);
@ -554,25 +554,35 @@ namespace NovetusLauncher
void ClientExited(object sender, EventArgs e) 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); ClientExitedBase(sender, e);
} }
void ServerExited(object sender, EventArgs 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); GlobalFuncs.PingMasterServer(0, "The server has removed itself from the master server list.", ConsoleBox);
ClientExitedBase(sender, e); ClientExitedBase(sender, e);
} }
void EasterEggExited(object sender, EventArgs e) void EasterEggExited(object sender, EventArgs e)
{ {
GlobalVars.GameOpened = GlobalVars.OpenedGame.None; GlobalVars.GameOpened = ScriptType.None;
GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InLauncher, ""); GlobalFuncs.UpdateRichPresence(GlobalFuncs.GetStateForType(GlobalVars.GameOpened));
SplashLabel.Text = LocalVars.prevsplash; SplashLabel.Text = LocalVars.prevsplash;
if (GlobalVars.AdminMode) if (GlobalVars.AdminMode)
{ {
@ -1062,7 +1072,7 @@ namespace NovetusLauncher
public void RestartLauncherAfterSetting(bool check, string title, string subText) 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); 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; return;
@ -1190,7 +1200,7 @@ namespace NovetusLauncher
public void ChangeClient() 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); MessageBox.Show("You must close the currently open client before changing clients.", "Novetus - Client is Open Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
@ -1233,7 +1243,7 @@ namespace NovetusLauncher
return; return;
} }
GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InLauncher, ""); GlobalFuncs.UpdateRichPresence(GlobalFuncs.GetStateForType(GlobalVars.GameOpened));
FormCollection fc = Application.OpenForms; FormCollection fc = Application.OpenForms;

View File

@ -129,7 +129,7 @@ namespace NovetusLauncher
if (!IsLoaded) if (!IsLoaded)
return; 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); 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; return;
@ -178,7 +178,7 @@ namespace NovetusLauncher
GlobalVars.UserConfiguration.SelectedClient + " | MAP: " + GlobalVars.UserConfiguration.SelectedClient + " | MAP: " +
GlobalVars.UserConfiguration.Map + "]"; GlobalVars.UserConfiguration.Map + "]";
GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.InLauncher, ""); GlobalFuncs.UpdateRichPresence(GlobalFuncs.GetStateForType(GlobalVars.GameOpened));
FormCollection fc = System.Windows.Forms.Application.OpenForms; FormCollection fc = System.Windows.Forms.Application.OpenForms;
@ -455,7 +455,7 @@ namespace NovetusLauncher
if (LocalVars.launcherInitState) if (LocalVars.launcherInitState)
return; 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); 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; return;

View File

@ -111,7 +111,7 @@ public partial class NovetusSDK : Form
#else #else
GlobalFuncs.LaunchRBXClient("ClientScriptTester", ScriptType.Client, false, false, null); GlobalFuncs.LaunchRBXClient("ClientScriptTester", ScriptType.Client, false, false, null);
#endif #endif
GlobalVars.GameOpened = GlobalVars.OpenedGame.None; GlobalVars.GameOpened = ScriptType.None;
break; break;
case SDKApps.XMLContentEditor: case SDKApps.XMLContentEditor:
XMLContentEditor xml = new XMLContentEditor(); XMLContentEditor xml = new XMLContentEditor();

View File

@ -65,11 +65,11 @@ namespace NovetusLauncher
void ClientExited(object sender, EventArgs e) 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.IP = oldIP;
GlobalVars.JoinPort = oldPort; GlobalVars.JoinPort = oldPort;
} }

View File

@ -53,7 +53,7 @@ namespace NovetusURI
handlers.requestCallback += RequestCallback; handlers.requestCallback += RequestCallback;
DiscordRPC.Initialize(GlobalVars.appid, ref handlers, true, ""); DiscordRPC.Initialize(GlobalVars.appid, ref handlers, true, "");
GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.LoadingURI, "", true); GlobalFuncs.UpdateRichPresence(GlobalVars.LauncherState.LoadingURI, true);
} }
} }
#endregion #endregion
@ -81,11 +81,11 @@ namespace NovetusURI
void ClientExited(object sender, EventArgs e) 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(); Close();
} }