fixes for launching studio with no map

This commit is contained in:
Bitl 2020-03-26 08:32:16 -07:00
parent 9a37c2daaf
commit 68a4402896
7 changed files with 39 additions and 36 deletions

View File

@ -404,7 +404,7 @@ namespace NovetusCMD
} }
} }
try try
{ {
ConsolePrint("Server Loaded.", 4); ConsolePrint("Server Loaded.", 4);
Process client = new Process(); Process client = new Process();
client.StartInfo.FileName = rbxexe; client.StartInfo.FileName = rbxexe;
@ -414,7 +414,7 @@ namespace NovetusCMD
client.Exited += new EventHandler(ServerExited); client.Exited += new EventHandler(ServerExited);
client.Start(); client.Start();
client.PriorityClass = ProcessPriorityClass.RealTime; client.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.Server); SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.Server, GlobalVars.Map);
LocalVars.ProcessID = client.Id; LocalVars.ProcessID = client.Id;
CreateTXT(); CreateTXT();
} }

View File

@ -795,7 +795,7 @@ public class LauncherFuncs
return image; return image;
} }
public static void UpdateRichPresence(LauncherState state, bool initial = false) public static void UpdateRichPresence(LauncherState state, string mapname, bool initial = false)
{ {
if (GlobalVars.DiscordPresence) if (GlobalVars.DiscordPresence)
{ {
@ -805,6 +805,8 @@ public class LauncherFuncs
GlobalVars.presence.startTimestamp = SecurityFuncs.UnixTimeNow(); GlobalVars.presence.startTimestamp = SecurityFuncs.UnixTimeNow();
} }
string ValidMapname = (string.IsNullOrWhiteSpace(mapname) ? "Place1.rbxl" : mapname);
switch (state) switch (state)
{ {
case LauncherState.InLauncher: case LauncherState.InLauncher:
@ -816,21 +818,21 @@ public class LauncherFuncs
break; break;
case LauncherState.InMPGame: case LauncherState.InMPGame:
GlobalVars.presence.smallImageKey = GlobalVars.image_ingame; GlobalVars.presence.smallImageKey = GlobalVars.image_ingame;
GlobalVars.presence.details = ""; GlobalVars.presence.details = ValidMapname;
GlobalVars.presence.state = "In " + GlobalVars.SelectedClient + " Multiplayer Game"; GlobalVars.presence.state = "In " + GlobalVars.SelectedClient + " Multiplayer Game";
GlobalVars.presence.largeImageText = GlobalVars.PlayerName + " | Novetus " + GlobalVars.Version; GlobalVars.presence.largeImageText = GlobalVars.PlayerName + " | Novetus " + GlobalVars.Version;
GlobalVars.presence.smallImageText = "In " + GlobalVars.SelectedClient + " Multiplayer Game"; GlobalVars.presence.smallImageText = "In " + GlobalVars.SelectedClient + " Multiplayer Game";
break; break;
case LauncherState.InSoloGame: case LauncherState.InSoloGame:
GlobalVars.presence.smallImageKey = GlobalVars.image_ingame; GlobalVars.presence.smallImageKey = GlobalVars.image_ingame;
GlobalVars.presence.details = GlobalVars.Map; GlobalVars.presence.details = ValidMapname;
GlobalVars.presence.state = "In " + GlobalVars.SelectedClient + " Solo Game"; GlobalVars.presence.state = "In " + GlobalVars.SelectedClient + " Solo Game";
GlobalVars.presence.largeImageText = GlobalVars.PlayerName + " | Novetus " + GlobalVars.Version; GlobalVars.presence.largeImageText = GlobalVars.PlayerName + " | Novetus " + GlobalVars.Version;
GlobalVars.presence.smallImageText = "In " + GlobalVars.SelectedClient + " Solo Game"; GlobalVars.presence.smallImageText = "In " + GlobalVars.SelectedClient + " Solo Game";
break; break;
case LauncherState.InStudio: case LauncherState.InStudio:
GlobalVars.presence.smallImageKey = GlobalVars.image_instudio; GlobalVars.presence.smallImageKey = GlobalVars.image_instudio;
GlobalVars.presence.details = GlobalVars.Map; GlobalVars.presence.details = ValidMapname;
GlobalVars.presence.state = "In " + GlobalVars.SelectedClient + " Studio"; GlobalVars.presence.state = "In " + GlobalVars.SelectedClient + " Studio";
GlobalVars.presence.largeImageText = GlobalVars.PlayerName + " | Novetus " + GlobalVars.Version; GlobalVars.presence.largeImageText = GlobalVars.PlayerName + " | Novetus " + GlobalVars.Version;
GlobalVars.presence.smallImageText = "In " + GlobalVars.SelectedClient + " Studio"; GlobalVars.presence.smallImageText = "In " + GlobalVars.SelectedClient + " Studio";
@ -844,14 +846,14 @@ public class LauncherFuncs
break; break;
case LauncherState.InEasterEggGame: case LauncherState.InEasterEggGame:
GlobalVars.presence.smallImageKey = GlobalVars.image_ingame; GlobalVars.presence.smallImageKey = GlobalVars.image_ingame;
GlobalVars.presence.details = GlobalVars.Map; GlobalVars.presence.details = ValidMapname;
GlobalVars.presence.state = "Reading a message."; GlobalVars.presence.state = "Reading a message.";
GlobalVars.presence.largeImageText = GlobalVars.PlayerName + " | Novetus " + GlobalVars.Version; GlobalVars.presence.largeImageText = GlobalVars.PlayerName + " | Novetus " + GlobalVars.Version;
GlobalVars.presence.smallImageText = "Reading a message."; GlobalVars.presence.smallImageText = "Reading a message.";
break; break;
case LauncherState.LoadingURI: case LauncherState.LoadingURI:
GlobalVars.presence.smallImageKey = GlobalVars.image_ingame; GlobalVars.presence.smallImageKey = GlobalVars.image_ingame;
GlobalVars.presence.details = ""; GlobalVars.presence.details = ValidMapname;
GlobalVars.presence.state = "Joining a " + GlobalVars.SelectedClient + " Multiplayer Game"; GlobalVars.presence.state = "Joining a " + GlobalVars.SelectedClient + " Multiplayer Game";
GlobalVars.presence.largeImageText = GlobalVars.PlayerName + " | Novetus " + GlobalVars.Version; GlobalVars.presence.largeImageText = GlobalVars.PlayerName + " | Novetus " + GlobalVars.Version;
GlobalVars.presence.smallImageText = "Joining a " + GlobalVars.SelectedClient + " Multiplayer Game"; GlobalVars.presence.smallImageText = "Joining a " + GlobalVars.SelectedClient + " Multiplayer Game";

View File

@ -150,22 +150,22 @@ public class SecurityFuncs
return new String(' ', random.Next(20)); return new String(' ', random.Next(20));
} }
public static void RenameWindow(Process exe, ScriptGenerator.ScriptType type) public static void RenameWindow(Process exe, ScriptGenerator.ScriptType type, string mapname)
{ {
if (GlobalVars.AlreadyHasSecurity != true) { if (GlobalVars.AlreadyHasSecurity != true) {
int time = 500; int time = 500;
BackgroundWorker worker = new BackgroundWorker(); BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += (obj, e) => WorkerDoWork(exe, type, time, worker, GlobalVars.SelectedClient); worker.DoWork += (obj, e) => WorkerDoWork(exe, type, time, worker, GlobalVars.SelectedClient, mapname);
worker.RunWorkerAsync(); worker.RunWorkerAsync();
} }
} }
private static void WorkerDoWork(Process exe, ScriptGenerator.ScriptType type, int time, BackgroundWorker worker, string clientname) private static void WorkerDoWork(Process exe, ScriptGenerator.ScriptType type, int time, BackgroundWorker worker, string clientname, string mapname)
{ {
if (exe.IsRunning() == true) { if (exe.IsRunning() == true) {
while (exe.IsRunning() == true) { while (exe.IsRunning() == true) {
if (exe.IsRunning() != true) { if (exe.IsRunning() != true) {
worker.DoWork -= (obj, e) => WorkerDoWork(exe, type, time, worker, clientname); worker.DoWork -= (obj, e) => WorkerDoWork(exe, type, time, worker, clientname, mapname);
worker.CancelAsync(); worker.CancelAsync();
worker.Dispose(); worker.Dispose();
break; break;
@ -174,7 +174,7 @@ public class SecurityFuncs
if (type == ScriptGenerator.ScriptType.Client) { if (type == ScriptGenerator.ScriptType.Client) {
SetWindowText(exe.MainWindowHandle, "Novetus " + GlobalVars.Version + " - " + clientname + " " + ScriptGenerator.GetNameForType(type) + " [" + GlobalVars.IP + ":" + GlobalVars.RobloxPort + "]" + RandomStringTitle()); SetWindowText(exe.MainWindowHandle, "Novetus " + GlobalVars.Version + " - " + clientname + " " + ScriptGenerator.GetNameForType(type) + " [" + GlobalVars.IP + ":" + GlobalVars.RobloxPort + "]" + RandomStringTitle());
} else if (type == ScriptGenerator.ScriptType.Server || type == ScriptGenerator.ScriptType.Solo || type == ScriptGenerator.ScriptType.Studio) { } else if (type == ScriptGenerator.ScriptType.Server || type == ScriptGenerator.ScriptType.Solo || type == ScriptGenerator.ScriptType.Studio) {
SetWindowText(exe.MainWindowHandle, "Novetus " + GlobalVars.Version + " - " + clientname + " " + ScriptGenerator.GetNameForType(type) + " [" + GlobalVars.Map + "]" + RandomStringTitle()); SetWindowText(exe.MainWindowHandle, "Novetus " + GlobalVars.Version + " - " + clientname + " " + ScriptGenerator.GetNameForType(type) + (string.IsNullOrWhiteSpace(mapname) ? " [Place1.rbxl]" : " [" + mapname + "]") + RandomStringTitle());
}else if (type == ScriptGenerator.ScriptType.EasterEgg) { }else if (type == ScriptGenerator.ScriptType.EasterEgg) {
SetWindowText(exe.MainWindowHandle, ScriptGenerator.GetNameForType(type) + RandomStringTitle()); SetWindowText(exe.MainWindowHandle, ScriptGenerator.GetNameForType(type) + RandomStringTitle());
} }
@ -182,7 +182,7 @@ public class SecurityFuncs
} }
} else { } else {
Thread.Sleep(time); Thread.Sleep(time);
RenameWindow(exe, type); RenameWindow(exe, type, mapname);
} }
} }

View File

@ -138,7 +138,7 @@ namespace NovetusLauncher
checkBox1.Checked = GlobalVars.Custom_Extra_ShowHats; checkBox1.Checked = GlobalVars.Custom_Extra_ShowHats;
//discord //discord
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InCustomization); LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InCustomization, GlobalVars.Map);
LauncherFuncs.ReloadLoadtextValue(); LauncherFuncs.ReloadLoadtextValue();
} }
@ -540,7 +540,7 @@ namespace NovetusLauncher
void CharacterCustomizationClose(object sender, CancelEventArgs e) void CharacterCustomizationClose(object sender, CancelEventArgs e)
{ {
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher); LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher, "");
LauncherFuncs.ReloadLoadtextValue(); LauncherFuncs.ReloadLoadtextValue();
} }

View File

@ -257,7 +257,7 @@ namespace NovetusLauncher
// button3 // button3
// //
this.button3.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.button3.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button3.Location = new System.Drawing.Point(113, 3); this.button3.Location = new System.Drawing.Point(157, 3);
this.button3.Name = "button3"; this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(81, 20); this.button3.Size = new System.Drawing.Size(81, 20);
this.button3.TabIndex = 6; this.button3.TabIndex = 6;
@ -484,7 +484,7 @@ namespace NovetusLauncher
// button35 // button35
// //
this.button35.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.button35.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button35.Location = new System.Drawing.Point(197, 3); this.button35.Location = new System.Drawing.Point(113, 3);
this.button35.Name = "button35"; this.button35.Name = "button35";
this.button35.Size = new System.Drawing.Size(41, 20); this.button35.Size = new System.Drawing.Size(41, 20);
this.button35.TabIndex = 61; this.button35.TabIndex = 61;

View File

@ -164,7 +164,7 @@ namespace NovetusLauncher
handlers.requestCallback += RequestCallback; handlers.requestCallback += RequestCallback;
DiscordRpc.Initialize(GlobalVars.appid, ref handlers, true, ""); DiscordRpc.Initialize(GlobalVars.appid, ref handlers, true, "");
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher, true); LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher, "", true);
} }
} }
@ -627,7 +627,7 @@ namespace NovetusLauncher
{ {
GlobalVars.SelectedClient = listBox2.SelectedItem.ToString(); GlobalVars.SelectedClient = listBox2.SelectedItem.ToString();
ReadClientValues(GlobalVars.SelectedClient); ReadClientValues(GlobalVars.SelectedClient);
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher); LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher, "");
} }
void CheckBox3CheckedChanged(object sender, EventArgs e) void CheckBox3CheckedChanged(object sender, EventArgs e)
@ -970,13 +970,13 @@ namespace NovetusLauncher
client.Exited += new EventHandler(ClientExited); client.Exited += new EventHandler(ClientExited);
client.Start(); client.Start();
client.PriorityClass = ProcessPriorityClass.RealTime; client.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.Client); SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.Client, GlobalVars.Map);
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InMPGame); LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InMPGame, GlobalVars.Map);
} }
void ClientExited(object sender, EventArgs e) void ClientExited(object sender, EventArgs e)
{ {
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher); LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher, "");
if (GlobalVars.CloseOnLaunch == true) if (GlobalVars.CloseOnLaunch == true)
{ {
this.Visible = true; this.Visible = true;
@ -1017,8 +1017,8 @@ namespace NovetusLauncher
client.Exited += new EventHandler(StudioExited); client.Exited += new EventHandler(StudioExited);
client.Start(); client.Start();
client.PriorityClass = ProcessPriorityClass.RealTime; client.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.Solo); SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.Solo, GlobalVars.Map);
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InSoloGame); LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InSoloGame, GlobalVars.Map);
} }
catch (Exception ex) when (!Env.Debugging) catch (Exception ex) when (!Env.Debugging)
{ {
@ -1069,7 +1069,7 @@ namespace NovetusLauncher
client.Exited += new EventHandler(ServerExited); client.Exited += new EventHandler(ServerExited);
client.Start(); client.Start();
client.PriorityClass = ProcessPriorityClass.RealTime; client.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.Server); SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.Server, GlobalVars.Map);
} }
catch (Exception ex) when (!Env.Debugging) catch (Exception ex) when (!Env.Debugging)
{ {
@ -1091,6 +1091,7 @@ namespace NovetusLauncher
string luafile = GetLuaFileName(); string luafile = GetLuaFileName();
string rbxexe = GetClientEXEDir(ScriptGenerator.ScriptType.Studio); string rbxexe = GetClientEXEDir(ScriptGenerator.ScriptType.Studio);
string mapfile = (nomap ? "" : GlobalVars.MapPath); string mapfile = (nomap ? "" : GlobalVars.MapPath);
string mapname = (nomap ? "" : GlobalVars.Map);
string quote = "\""; string quote = "\"";
string args = ""; string args = "";
if (GlobalVars.CustomArgs.Equals("%args%")) if (GlobalVars.CustomArgs.Equals("%args%"))
@ -1120,8 +1121,8 @@ namespace NovetusLauncher
client.Exited += new EventHandler(StudioExited); client.Exited += new EventHandler(StudioExited);
client.Start(); client.Start();
client.PriorityClass = ProcessPriorityClass.RealTime; client.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.Studio); SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.Studio, mapname);
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InStudio); LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InStudio, mapname);
} }
catch (Exception ex) when (!Env.Debugging) catch (Exception ex) when (!Env.Debugging)
{ {
@ -1132,7 +1133,7 @@ namespace NovetusLauncher
void StudioExited(object sender, EventArgs e) void StudioExited(object sender, EventArgs e)
{ {
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher); LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher, "");
if (GlobalVars.CloseOnLaunch == true) if (GlobalVars.CloseOnLaunch == true)
{ {
this.Visible = true; this.Visible = true;
@ -1761,8 +1762,8 @@ namespace NovetusLauncher
client.Exited += new EventHandler(EasterEggExited); client.Exited += new EventHandler(EasterEggExited);
client.Start(); client.Start();
client.PriorityClass = ProcessPriorityClass.RealTime; client.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.EasterEgg); SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.EasterEgg, "");
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InEasterEggGame); LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InEasterEggGame, "");
} }
catch (Exception ex) when (!Env.Debugging) catch (Exception ex) when (!Env.Debugging)
{ {
@ -1773,7 +1774,7 @@ namespace NovetusLauncher
void EasterEggExited(object sender, EventArgs e) void EasterEggExited(object sender, EventArgs e)
{ {
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher); LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher, "");
label3.Text = ""; label3.Text = "";
if (GlobalVars.CloseOnLaunch == true) if (GlobalVars.CloseOnLaunch == true)
{ {

View File

@ -98,7 +98,7 @@ namespace NovetusLauncher
handlers.requestCallback += RequestCallback; handlers.requestCallback += RequestCallback;
DiscordRpc.Initialize(GlobalVars.appid, ref handlers, true, ""); DiscordRpc.Initialize(GlobalVars.appid, ref handlers, true, "");
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.LoadingURI, true); LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.LoadingURI, "", true);
} }
void StartGame() void StartGame()
@ -196,14 +196,14 @@ namespace NovetusLauncher
clientproc.Exited += new EventHandler(ClientExited); clientproc.Exited += new EventHandler(ClientExited);
clientproc.Start(); clientproc.Start();
clientproc.PriorityClass = ProcessPriorityClass.RealTime; clientproc.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(clientproc, ScriptGenerator.ScriptType.Client); SecurityFuncs.RenameWindow(clientproc, ScriptGenerator.ScriptType.Client, "");
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InMPGame); LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InMPGame, "");
this.Visible = false; this.Visible = false;
} }
void ClientExited(object sender, EventArgs e) void ClientExited(object sender, EventArgs e)
{ {
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher); LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher, "");
this.Close(); this.Close();
} }