added default clientinfo generation

This commit is contained in:
Bitl 2021-09-27 12:48:22 -07:00
parent 476c8c456a
commit 84af43ea4a
3 changed files with 396 additions and 235 deletions

View File

@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.Globalization;
using System.IO;
using System.Net;
using System.Reflection;
@ -562,11 +563,33 @@ public class GlobalFuncs
if (!File.Exists(clientpath))
{
try
{
#if LAUNCHER
ConsolePrint("ERROR - No clientinfo.nov detected with the client you chose. The client either cannot be loaded, or it is not available.", 2, box);
ConsolePrint("ERROR - No clientinfo.nov detected with the client you chose. The client either cannot be loaded, or it is not available. Novetus will attempt to generate one.", 2, box);
#elif CMD
GlobalFuncs.ConsolePrint("ERROR - No clientinfo.nov detected with the client you chose. The client either cannot be loaded, or it is not available.", 2);
#elif URI
ConsolePrint("ERROR - No clientinfo.nov detected with the client you chose. The client either cannot be loaded, or it is not available. Novetus will attempt to generate one.", 2);
#endif
GenerateDefaultClientInfo(Path.GetDirectoryName(clientpath));
#if LAUNCHER
ReadClientValues(name, box, initial);
#else
ReadClientValues(name, initial);
#endif
}
catch (Exception ex)
{
#if LAUNCHER || CMD || URI
LogExceptions(ex);
#endif
#if LAUNCHER
ConsolePrint("ERROR - Failed to generate default clientinfo.nov. Info: " + ex.Message, 2, box);
ConsolePrint("Loading default client '" + GlobalVars.ProgramInformation.DefaultClient + "'", 4, box);
#elif CMD
ConsolePrint("ERROR - Failed to generate default clientinfo.nov. Info: " + ex.Message, 2);
ConsolePrint("Loading default client '" + GlobalVars.ProgramInformation.DefaultClient + "'", 4);
#endif
name = GlobalVars.ProgramInformation.DefaultClient;
#if LAUNCHER
@ -575,6 +598,7 @@ public class GlobalFuncs
ReadClientValues(name, initial);
#endif
}
}
else
{
LoadClientValues(clientpath);
@ -584,8 +608,7 @@ public class GlobalFuncs
#if LAUNCHER
ConsolePrint("Client '" + name + "' successfully loaded.", 3, box);
#elif CMD
GlobalFuncs.ConsolePrint("Client '" + name + "' successfully loaded.", 3);
#elif URI
ConsolePrint("Client '" + name + "' successfully loaded.", 3);
#endif
}
}
@ -609,6 +632,75 @@ public class GlobalFuncs
ChangeGameSettings(ClientName);
}
public static void GenerateDefaultClientInfo(string path)
{
FileFormat.ClientInfo DefaultClientInfo = new FileFormat.ClientInfo();
bool placeholder = false;
string ClientName = "";
if (File.Exists(path + "\\RobloxApp_client.exe"))
{
ClientName = "\\RobloxApp_client.exe";
}
else if (File.Exists(path + "\\RobloxApp.exe"))
{
ClientName = "\\RobloxApp.exe";
DefaultClientInfo.LegacyMode = true;
}
else
{
IOException clientNotFoundEX = new IOException("Could not find client exe for MD5 generation.");
throw clientNotFoundEX;
}
string ClientMD5 = File.Exists(path + ClientName) ? SecurityFuncs.GenerateMD5(path + ClientName) : "";
if (!string.IsNullOrWhiteSpace(ClientMD5))
{
DefaultClientInfo.ClientMD5 = ClientMD5.ToUpper(CultureInfo.InvariantCulture);
}
else
{
IOException clientNotFoundEX = new IOException("Could not find client exe for MD5 generation.");
throw clientNotFoundEX;
}
string ClientScriptMD5 = File.Exists(path + "\\content\\scripts\\" + GlobalPaths.ScriptName + ".lua") ? SecurityFuncs.GenerateMD5(path + "\\content\\scripts\\" + GlobalPaths.ScriptName + ".lua") : "";
if (!string.IsNullOrWhiteSpace(ClientScriptMD5))
{
DefaultClientInfo.ScriptMD5 = ClientScriptMD5.ToUpper(CultureInfo.InvariantCulture);
}
else
{
IOException clientNotFoundEX = new IOException("Could not find script file for MD5 generation.");
throw clientNotFoundEX;
}
string desc = "This client information file for '" + GlobalVars.UserConfiguration.SelectedClient +
"' was pre-generated by Novetus for your convienence.\nIf you experience any issues with the default settings, load this clientinfo.nov file into the Client SDK.";
DefaultClientInfo.Description = desc;
string[] lines = {
SecurityFuncs.Base64Encode(DefaultClientInfo.UsesPlayerName.ToString()),
SecurityFuncs.Base64Encode(DefaultClientInfo.UsesID.ToString()),
SecurityFuncs.Base64Encode(DefaultClientInfo.Warning.ToString()),
SecurityFuncs.Base64Encode(DefaultClientInfo.LegacyMode.ToString()),
SecurityFuncs.Base64Encode(DefaultClientInfo.ClientMD5.ToString()),
SecurityFuncs.Base64Encode(DefaultClientInfo.ScriptMD5.ToString()),
SecurityFuncs.Base64Encode(DefaultClientInfo.Description.ToString()),
SecurityFuncs.Base64Encode(placeholder.ToString()),
SecurityFuncs.Base64Encode(DefaultClientInfo.Fix2007.ToString()),
SecurityFuncs.Base64Encode(DefaultClientInfo.AlreadyHasSecurity.ToString()),
SecurityFuncs.Base64Encode(((int)DefaultClientInfo.ClientLoadOptions).ToString()),
SecurityFuncs.Base64Encode(DefaultClientInfo.CommandLineArgs.ToString())
};
File.WriteAllText(path + "\\clientinfo.nov", SecurityFuncs.Base64Encode(string.Join("|", lines)));
}
public static void FixedFileCopy(string src, string dest, bool overwrite, bool overwritewarning = false)
{
if (File.Exists(dest))
@ -727,11 +819,22 @@ public class GlobalFuncs
public static FileFormat.ClientInfo GetClientInfoValues(string ClientName)
{
string name = ClientName;
try
{
FileFormat.ClientInfo info = new FileFormat.ClientInfo();
string clientpath = GlobalPaths.ClientDir + @"\\" + name + @"\\clientinfo.nov";
LoadClientValues(info, clientpath);
return info;
}
catch (Exception ex)
{
#if LAUNCHER || CMD || URI
LogExceptions(ex);
#endif
return null;
}
}
//https://social.msdn.microsoft.com/Forums/vstudio/en-US/b0c31115-f6f0-4de5-a62d-d766a855d4d1/directorygetfiles-with-searchpattern-to-get-all-dll-and-exe-files-in-one-call?forum=netfxbcl
public static string[] GetFiles(string path, string searchPattern, SearchOption searchOption)
@ -1030,6 +1133,8 @@ public class GlobalFuncs
}
public static void ChangeGameSettings(string ClientName)
{
try
{
FileFormat.ClientInfo info = GetClientInfoValues(ClientName);
@ -1219,8 +1324,6 @@ public class GlobalFuncs
string terms = "_" + ClientName;
string[] dirs = Directory.GetFiles(GlobalPaths.ConfigDirClients);
try
{
foreach (string dir in dirs)
{
if (dir.Contains(terms) && !dir.Contains("_default"))
@ -1231,21 +1334,23 @@ public class GlobalFuncs
}
}
}
}
catch (Exception ex)
{
#if URI || LAUNCHER || CMD
#if LAUNCHER || CMD || URI
LogExceptions(ex);
#endif
return;
}
}
}
//oh god....
//we're using this one for custom graphics quality. Better than the latter.
public static void ApplyClientSettings_custom(FileFormat.ClientInfo info, string ClientName, int MeshDetail, int ShadingQuality, int MaterialQuality,
int AA, int AASamples, int Bevels, int Shadows_2008, bool Shadows_2007, string Style_2007, int GFXQualityLevel, string WindowResolution, string FullscreenResolution,
int ModernResolution)
{
try
{
int GraphicsMode = 0;
@ -1293,6 +1398,14 @@ public class GlobalFuncs
ApplyClientSettings(info, ClientName, GraphicsMode, MeshDetail, ShadingQuality, MaterialQuality,
AA, AASamples, Bevels, Shadows_2008, Shadows_2007, Style_2007, GFXQualityLevel, WindowResolution, FullscreenResolution, ModernResolution);
}
catch (Exception ex)
{
#if LAUNCHER || CMD || URI
LogExceptions(ex);
#endif
return;
}
}
//it's worse.
public static void ApplyClientSettings(FileFormat.ClientInfo info, string ClientName, int GraphicsMode, int MeshDetail, int ShadingQuality, int MaterialQuality,

View File

@ -819,8 +819,40 @@ namespace NovetusLauncher
}
}
public bool GenerateIfInvalid()
{
string clientpath = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\clientinfo.nov";
if (!File.Exists(clientpath))
{
try
{
MessageBox.Show("No clientinfo.nov detected with the client you chose. The client either cannot be loaded, or it is not available.\n\nNovetus will attempt to generate one.", "Novetus - Client Load Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
GlobalFuncs.GenerateDefaultClientInfo(Path.GetDirectoryName(clientpath));
}
catch (Exception ex)
{
GlobalFuncs.LogExceptions(ex);
MessageBox.Show("Failed to generate default clientinfo.nov. Info: " + ex.Message + "\n\nLoading default client '" + GlobalVars.ProgramInformation.DefaultClient + "'", "Novetus - Client Info Generation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
GlobalVars.UserConfiguration.SelectedClient = GlobalVars.ProgramInformation.DefaultClient;
return false;
}
}
return true;
}
public void ReadClientValues(bool initial = false)
{
//reset clients
if (!GenerateIfInvalid())
{
if (Tabs.SelectedTab == Tabs.TabPages[TabPageClients])
{
ClientBox.SelectedItem = GlobalVars.UserConfiguration.SelectedClient;
}
}
GlobalFuncs.ReadClientValues(ConsoleBox, initial);
PlayerNameTextBox.Enabled = GlobalVars.SelectedClientInfo.UsesPlayerName;

View File

@ -197,6 +197,22 @@ namespace NovetusLauncher
public void ReadClientValues(bool initial = false)
{
//reset clients
if (!launcherFormStylishInterface1.launcherForm.GenerateIfInvalid())
{
if (launcherFormStylishInterface1.clientTab != null && launcherFormStylishInterface1.clientTab.IsSelected)
{
foreach (object o in launcherFormStylishInterface1.clientListBox.Items)
{
if ((o is ClientListItem) && (o as ClientListItem).ClientName.Contains(GlobalVars.UserConfiguration.SelectedClient))
{
launcherFormStylishInterface1.clientListBox.SelectedItem = o;
break;
}
}
}
}
GlobalFuncs.ReadClientValues(null, initial);
launcherFormStylishInterface1.userNameBox.IsEnabled = GlobalVars.SelectedClientInfo.UsesPlayerName;