added default clientinfo generation
This commit is contained in:
parent
476c8c456a
commit
84af43ea4a
|
|
@ -7,6 +7,7 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
@ -562,11 +563,33 @@ public class GlobalFuncs
|
||||||
|
|
||||||
if (!File.Exists(clientpath))
|
if (!File.Exists(clientpath))
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
#if LAUNCHER
|
#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
|
#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);
|
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);
|
||||||
#elif URI
|
#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
|
#endif
|
||||||
name = GlobalVars.ProgramInformation.DefaultClient;
|
name = GlobalVars.ProgramInformation.DefaultClient;
|
||||||
#if LAUNCHER
|
#if LAUNCHER
|
||||||
|
|
@ -575,6 +598,7 @@ public class GlobalFuncs
|
||||||
ReadClientValues(name, initial);
|
ReadClientValues(name, initial);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LoadClientValues(clientpath);
|
LoadClientValues(clientpath);
|
||||||
|
|
@ -584,8 +608,7 @@ public class GlobalFuncs
|
||||||
#if LAUNCHER
|
#if LAUNCHER
|
||||||
ConsolePrint("Client '" + name + "' successfully loaded.", 3, box);
|
ConsolePrint("Client '" + name + "' successfully loaded.", 3, box);
|
||||||
#elif CMD
|
#elif CMD
|
||||||
GlobalFuncs.ConsolePrint("Client '" + name + "' successfully loaded.", 3);
|
ConsolePrint("Client '" + name + "' successfully loaded.", 3);
|
||||||
#elif URI
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -609,6 +632,75 @@ public class GlobalFuncs
|
||||||
ChangeGameSettings(ClientName);
|
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)
|
public static void FixedFileCopy(string src, string dest, bool overwrite, bool overwritewarning = false)
|
||||||
{
|
{
|
||||||
if (File.Exists(dest))
|
if (File.Exists(dest))
|
||||||
|
|
@ -727,11 +819,22 @@ public class GlobalFuncs
|
||||||
public static FileFormat.ClientInfo GetClientInfoValues(string ClientName)
|
public static FileFormat.ClientInfo GetClientInfoValues(string ClientName)
|
||||||
{
|
{
|
||||||
string name = ClientName;
|
string name = ClientName;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
FileFormat.ClientInfo info = new FileFormat.ClientInfo();
|
FileFormat.ClientInfo info = new FileFormat.ClientInfo();
|
||||||
string clientpath = GlobalPaths.ClientDir + @"\\" + name + @"\\clientinfo.nov";
|
string clientpath = GlobalPaths.ClientDir + @"\\" + name + @"\\clientinfo.nov";
|
||||||
LoadClientValues(info, clientpath);
|
LoadClientValues(info, clientpath);
|
||||||
return info;
|
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
|
//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)
|
public static string[] GetFiles(string path, string searchPattern, SearchOption searchOption)
|
||||||
|
|
@ -1030,6 +1133,8 @@ public class GlobalFuncs
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ChangeGameSettings(string ClientName)
|
public static void ChangeGameSettings(string ClientName)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
FileFormat.ClientInfo info = GetClientInfoValues(ClientName);
|
FileFormat.ClientInfo info = GetClientInfoValues(ClientName);
|
||||||
|
|
||||||
|
|
@ -1219,8 +1324,6 @@ public class GlobalFuncs
|
||||||
string terms = "_" + ClientName;
|
string terms = "_" + ClientName;
|
||||||
string[] dirs = Directory.GetFiles(GlobalPaths.ConfigDirClients);
|
string[] dirs = Directory.GetFiles(GlobalPaths.ConfigDirClients);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
foreach (string dir in dirs)
|
foreach (string dir in dirs)
|
||||||
{
|
{
|
||||||
if (dir.Contains(terms) && !dir.Contains("_default"))
|
if (dir.Contains(terms) && !dir.Contains("_default"))
|
||||||
|
|
@ -1231,21 +1334,23 @@ public class GlobalFuncs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
#if URI || LAUNCHER || CMD
|
#if LAUNCHER || CMD || URI
|
||||||
LogExceptions(ex);
|
LogExceptions(ex);
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//oh god....
|
//oh god....
|
||||||
//we're using this one for custom graphics quality. Better than the latter.
|
//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,
|
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 AA, int AASamples, int Bevels, int Shadows_2008, bool Shadows_2007, string Style_2007, int GFXQualityLevel, string WindowResolution, string FullscreenResolution,
|
||||||
int ModernResolution)
|
int ModernResolution)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
int GraphicsMode = 0;
|
int GraphicsMode = 0;
|
||||||
|
|
||||||
|
|
@ -1293,6 +1398,14 @@ public class GlobalFuncs
|
||||||
ApplyClientSettings(info, ClientName, GraphicsMode, MeshDetail, ShadingQuality, MaterialQuality,
|
ApplyClientSettings(info, ClientName, GraphicsMode, MeshDetail, ShadingQuality, MaterialQuality,
|
||||||
AA, AASamples, Bevels, Shadows_2008, Shadows_2007, Style_2007, GFXQualityLevel, WindowResolution, FullscreenResolution, ModernResolution);
|
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.
|
//it's worse.
|
||||||
public static void ApplyClientSettings(FileFormat.ClientInfo info, string ClientName, int GraphicsMode, int MeshDetail, int ShadingQuality, int MaterialQuality,
|
public static void ApplyClientSettings(FileFormat.ClientInfo info, string ClientName, int GraphicsMode, int MeshDetail, int ShadingQuality, int MaterialQuality,
|
||||||
|
|
|
||||||
|
|
@ -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)
|
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);
|
GlobalFuncs.ReadClientValues(ConsoleBox, initial);
|
||||||
|
|
||||||
PlayerNameTextBox.Enabled = GlobalVars.SelectedClientInfo.UsesPlayerName;
|
PlayerNameTextBox.Enabled = GlobalVars.SelectedClientInfo.UsesPlayerName;
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,22 @@ namespace NovetusLauncher
|
||||||
|
|
||||||
public void ReadClientValues(bool initial = false)
|
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);
|
GlobalFuncs.ReadClientValues(null, initial);
|
||||||
|
|
||||||
launcherFormStylishInterface1.userNameBox.IsEnabled = GlobalVars.SelectedClientInfo.UsesPlayerName;
|
launcherFormStylishInterface1.userNameBox.IsEnabled = GlobalVars.SelectedClientInfo.UsesPlayerName;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue