diff --git a/NovetusLauncher/NovetusCMD/Program.cs b/NovetusLauncher/NovetusCMD/Program.cs index c72b6ba..fa1d301 100644 --- a/NovetusLauncher/NovetusCMD/Program.cs +++ b/NovetusLauncher/NovetusCMD/Program.cs @@ -175,7 +175,7 @@ namespace NovetusCMD if (!File.Exists(clientpath)) { ConsolePrint("ERROR - No clientinfo.nov detected with the client you chose. The client either cannot be loaded, or it is not available.", 2); - GlobalVars.UserConfiguration.SelectedClient = GlobalVars.DefaultClient; + GlobalVars.UserConfiguration.SelectedClient = GlobalVars.ProgramInformation.DefaultClient; ReadClientValues(ClientName); } else @@ -193,9 +193,9 @@ namespace NovetusCMD public static void Main(string[] args) { LauncherFuncs.ReadInfoFile(Directories.ConfigDir + "\\" + GlobalVars.InfoName, true); - Console.Title = "Novetus " + GlobalVars.Version + " CMD"; + Console.Title = "Novetus " + GlobalVars.ProgramInformation.Version + " CMD"; - ConsolePrint("NovetusCMD version " + GlobalVars.Version + " loaded.", 1); + ConsolePrint("NovetusCMD version " + GlobalVars.ProgramInformation.Version + " loaded.", 1); ConsolePrint("Novetus path: " + Directories.BasePath, 1); if (args.Length == 0) @@ -437,7 +437,7 @@ namespace NovetusCMD "Port: " + GlobalVars.UserConfiguration.RobloxPort.ToString(), "Map: " + GlobalVars.UserConfiguration.Map, "Players: " + GlobalVars.UserConfiguration.PlayerLimit, - "Version: Novetus " + GlobalVars.Version, + "Version: Novetus " + GlobalVars.ProgramInformation.Version, "Online URI Link:", URI, "Local URI Link:", diff --git a/NovetusLauncher/NovetusFuncs/NovetusFuncs.projitems b/NovetusLauncher/NovetusFuncs/NovetusFuncs.projitems index bebd590..fc79d86 100644 --- a/NovetusLauncher/NovetusFuncs/NovetusFuncs.projitems +++ b/NovetusLauncher/NovetusFuncs/NovetusFuncs.projitems @@ -9,7 +9,6 @@ NovetusFuncs - diff --git a/NovetusLauncher/NovetusFuncs/NovetusGlobalFuncs.cs b/NovetusLauncher/NovetusFuncs/NovetusGlobalFuncs.cs index 80cd13c..4cea60c 100644 --- a/NovetusLauncher/NovetusFuncs/NovetusGlobalFuncs.cs +++ b/NovetusLauncher/NovetusFuncs/NovetusGlobalFuncs.cs @@ -17,16 +17,9 @@ using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; -using System.Xml; -using System.Xml.Linq; #endregion /* - * Finish classes for: - * - * info - * reshade - * * change field names for all forms * Rewrite client launching into one function. * add regions to ALL classes. @@ -79,10 +72,9 @@ public enum RobloxFileType #region GlobalVars public static class GlobalVars { + public static ProgramInfo ProgramInformation = new ProgramInfo(); public static Config UserConfiguration = new Config(); public static string IP = "localhost"; - public static string Version = ""; - public static string Branch = ""; public static string SharedArgs = ""; public static readonly string ScriptName = "CSMPFunctions"; public static readonly string ScriptGenName = "CSMPBoot"; @@ -98,15 +90,10 @@ public static class GlobalVars //config name public static readonly string ConfigName = "config.ini"; public static string ConfigNameCustomization = "config_customization.ini"; - public static readonly string InfoName = "info.txt"; + public static readonly string InfoName = "info.ini"; //client shit public static ClientInfo SelectedClientInfo = new ClientInfo(); public static string AddonScriptPath = ""; - //info shit - public static string DefaultClient = ""; - public static string RegisterClient1 = ""; - public static string RegisterClient2 = ""; - public static string DefaultMap = ""; //charcustom public static CustomizationConfig UserCustomization = new CustomizationConfig(); public static string loadtext = ""; @@ -122,9 +109,6 @@ public static class GlobalVars public static string image_inlauncher = "inlauncher_small"; public static string image_instudio = "instudio_small"; public static string image_incustomization = "incustomization_small"; - //reshade - public static bool ReShadeFPSDisplay = false; - public static bool ReShadePerformanceMode = false; public static string MultiLine(params string[] args) { @@ -322,7 +306,9 @@ public class Config GraphicsMode = GraphicsMode.OpenGL; ReShade = false; QualityLevel = QualityLevel.Ultra; - OldLayout = false; + LauncherLayout = LauncherLayout.Extended; + ReShadeFPSDisplay = false; + ReShadePerformanceMode = false; } public string SelectedClient { get; set; } @@ -341,7 +327,9 @@ public class Config public GraphicsMode GraphicsMode { get; set; } public bool ReShade { get; set; } public QualityLevel QualityLevel { get; set; } - public bool OldLayout { get; set; } + public LauncherLayout LauncherLayout { get; set; } + public bool ReShadeFPSDisplay { get; set; } + public bool ReShadePerformanceMode { get; set; } } #endregion @@ -405,23 +393,25 @@ public class CustomizationConfig } #endregion -#region Program Information (WIP) +#region Program Information public class ProgramInfo { public ProgramInfo() { - + Version = ""; + Branch = ""; + DefaultClient = ""; + RegisterClient1 = ""; + RegisterClient2 = ""; + DefaultMap = ""; } -} -#endregion -#region ReShade Configuration (WIP) -public class ReShadeConfig -{ - public ReShadeConfig() - { - - } + public string Version { get; set; } + public string Branch { get; set; } + public string DefaultClient { get; set; } + public string RegisterClient1 { get; set; } + public string RegisterClient2 { get; set; } + public string DefaultMap { get; set; } } #endregion @@ -530,6 +520,99 @@ public class DiscordRpc #region Function Classes +#region Enum Parser +public static class EnumParser +{ + public static QualityLevel GetQualityLevelForInt(int level) + { + switch (level) + { + case 1: + return QualityLevel.VeryLow; + case 2: + return QualityLevel.Low; + case 3: + return QualityLevel.Medium; + case 4: + return QualityLevel.High; + case 5: + default: + return QualityLevel.Ultra; + } + } + + public static int GetIntForQualityLevel(QualityLevel level) + { + switch (level) + { + case QualityLevel.VeryLow: + return 1; + case QualityLevel.Low: + return 2; + case QualityLevel.Medium: + return 3; + case QualityLevel.High: + return 4; + case QualityLevel.Ultra: + default: + return 5; + } + } + + public static GraphicsMode GetGraphicsModeForInt(int level) + { + switch (level) + { + case 1: + return GraphicsMode.OpenGL; + case 2: + return GraphicsMode.DirectX; + default: + return GraphicsMode.None; + } + } + + public static int GetIntForGraphicsMode(GraphicsMode level) + { + switch (level) + { + case GraphicsMode.OpenGL: + return 1; + case GraphicsMode.DirectX: + return 2; + default: + return 0; + } + } + + public static LauncherLayout GetLauncherLayoutForInt(int level) + { + switch (level) + { + case 1: + return LauncherLayout.Extended; + case 2: + return LauncherLayout.Compact; + default: + return LauncherLayout.None; + } + } + + public static int GetIntForLauncherLayout(LauncherLayout level) + { + switch (level) + { + case LauncherLayout.Extended: + return 1; + case LauncherLayout.Compact: + return 2; + default: + return 0; + } + } +} +#endregion + #region UPNP public static class UPnP { @@ -1230,149 +1313,6 @@ public class SimpleHTTPServer } #endregion -#region Roblox XML Localizer -public static class RobloxXMLLocalizer -{ - public static void DownloadFromNodes(string filepath, AssetCacheDef assetdef, string name = "", string meshname = "") - { - DownloadFromNodes(filepath, assetdef.Class, assetdef.Id[0], assetdef.Ext[0], assetdef.Dir[0], assetdef.GameDir[0], name, meshname); - } - - public static void DownloadFromNodes(string filepath, AssetCacheDef assetdef, int idIndex, int extIndex, int outputPathIndex, int inGameDirIndex, string name = "", string meshname = "") - { - DownloadFromNodes(filepath, assetdef.Class, assetdef.Id[idIndex], assetdef.Ext[extIndex], assetdef.Dir[outputPathIndex], assetdef.GameDir[inGameDirIndex], name, meshname); - } - - public static void DownloadFromNodes(string filepath, string itemClassValue, string itemIdValue, string fileext, string outputPath, string inGameDir, string name = "", string meshname = "") - { - string oldfile = File.ReadAllText(filepath); - string fixedfile = RemoveInvalidXmlChars(ReplaceHexadecimalSymbols(oldfile)); - XDocument doc = XDocument.Parse(fixedfile); - - try - { - var v = from nodes in doc.Descendants("Item") - where nodes.Attribute("class").Value == itemClassValue - select nodes; - - foreach (var item in v) - { - var v2 = from nodes in item.Descendants("Content") - where nodes.Attribute("name").Value == itemIdValue - select nodes; - - foreach (var item2 in v2) - { - var v3 = from nodes in item2.Descendants("url") - select nodes; - - foreach (var item3 in v3) - { - if (!item3.Value.Contains("rbxassetid")) - { - if (!item3.Value.Contains("rbxasset")) - { - if (string.IsNullOrWhiteSpace(meshname)) - { - string url = item3.Value; - string urlFixed = url.Replace("&", "&").Replace("amp;", "&"); - string peram = "id="; - - if (string.IsNullOrWhiteSpace(name)) - { - if (urlFixed.Contains(peram)) - { - string IDVal = urlFixed.After(peram); - DownloadFilesFromNode(urlFixed, outputPath, fileext, IDVal); - item3.Value = inGameDir + IDVal + fileext; - } - } - else - { - DownloadFilesFromNode(urlFixed, outputPath, fileext, name); - item3.Value = inGameDir + name + fileext; - } - } - else - { - item3.Value = inGameDir + meshname; - } - } - } - else - { - if (string.IsNullOrWhiteSpace(meshname)) - { - string url = item3.Value; - string rbxassetid = "rbxassetid://"; - string urlFixed = "https://www.roblox.com/asset/?id=" + url.After(rbxassetid); - string peram = "id="; - - if (string.IsNullOrWhiteSpace(name)) - { - if (urlFixed.Contains(peram)) - { - string IDVal = urlFixed.After(peram); - DownloadFilesFromNode(urlFixed, outputPath, fileext, IDVal); - item3.Value = inGameDir + IDVal + fileext; - } - } - else - { - DownloadFilesFromNode(urlFixed, outputPath, fileext, name); - item3.Value = inGameDir + name + fileext; - } - } - else - { - item3.Value = inGameDir + meshname; - } - } - } - } - } - - } - catch (Exception ex) - { - MessageBox.Show("The download has experienced an error: " + ex.Message, "Novetus Asset Localizer", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - finally - { - doc.Save(filepath); - } - } - - private static void DownloadFilesFromNode(string url, string path, string fileext, string id) - { - if (!string.IsNullOrWhiteSpace(id)) - { - Downloader download = new Downloader(url, id); - - try - { - download.InitDownload(path, fileext); - } - catch (Exception ex) - { - MessageBox.Show("The download has experienced an error: " + ex.Message, "Novetus Asset Localizer", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - } - } - - private static string RemoveInvalidXmlChars(string content) - { - return new string(content.Where(ch => XmlConvert.IsXmlChar(ch)).ToArray()); - } - - private static string ReplaceHexadecimalSymbols(string txt) - { - string r = "[\x00-\x08\x0B\x0C\x0E-\x1F\x26]"; - return Regex.Replace(txt, r, "", RegexOptions.Compiled); - } -} -#endregion - #endregion #endregion \ No newline at end of file diff --git a/NovetusLauncher/NovetusFuncs/NovetusLauncherFuncs.cs b/NovetusLauncher/NovetusFuncs/NovetusLauncherFuncs.cs index 9a08002..014466a 100644 --- a/NovetusLauncher/NovetusFuncs/NovetusLauncherFuncs.cs +++ b/NovetusLauncher/NovetusFuncs/NovetusLauncherFuncs.cs @@ -20,6 +20,15 @@ public enum LauncherState } #endregion +#region Launcher Layout +public enum LauncherLayout +{ + None = 0, + Extended = 1, + Compact = 2 +} +#endregion + #region Launcher Functions public class LauncherFuncs { @@ -27,117 +36,76 @@ public class LauncherFuncs { } - public static void ReadInfoFile(string infopath, bool cmd = false, bool versiononly = false) + public static void ReadInfoFile(string infopath, bool cmd = false) { - string[] lines = File.ReadAllLines(infopath); //File is in System.IO - GlobalVars.IsSnapshot = Convert.ToBoolean(lines[5]); - if (GlobalVars.IsSnapshot == true) + //READ + string versionbranch, defaultclient, defaultmap, regclient1, + regclient2, issnapshot, snapshottemplate, snapshotrevision; + + IniFile ini = new IniFile(infopath); + + string section = "ProgramInfo"; + + //not using the GlobalVars definitions as those are empty until we fill them in. + versionbranch = ini.IniReadValue(section, "Branch", "0.0"); + defaultclient = ini.IniReadValue(section, "DefaultClient", "2009E"); + defaultmap = ini.IniReadValue(section, "DefaultMap", "Dev - Baseplate2048.rbxl"); + regclient1 = ini.IniReadValue(section, "UserAgentRegisterClient1", "2007M"); + regclient2 = ini.IniReadValue(section, "UserAgentRegisterClient2", "2009L"); + issnapshot = ini.IniReadValue(section, "IsSnapshot", "False"); + snapshottemplate = ini.IniReadValue(section, "SnapshotTemplate", "%version% Snapshot (%build%.%revision%.%snapshot-revision%)"); + snapshotrevision = ini.IniReadValue(section, "SnapshotRevision", "1"); + + try { - if (cmd) + GlobalVars.IsSnapshot = Convert.ToBoolean(issnapshot); + if (GlobalVars.IsSnapshot == true) { - var versionInfo = FileVersionInfo.GetVersionInfo(Directories.RootPathLauncher + "\\Novetus.exe"); - GlobalVars.Version = lines[6].Replace("%version%", lines[0]) - .Replace("%build%", versionInfo.ProductBuildPart.ToString()) - .Replace("%revision%", versionInfo.FilePrivatePart.ToString()) - .Replace("%snapshot-revision%", lines[7]); + if (cmd) + { + var versionInfo = FileVersionInfo.GetVersionInfo(Directories.RootPathLauncher + "\\Novetus.exe"); + GlobalVars.ProgramInformation.Version = snapshottemplate.Replace("%version%", versionbranch) + .Replace("%build%", versionInfo.ProductBuildPart.ToString()) + .Replace("%revision%", versionInfo.FilePrivatePart.ToString()) + .Replace("%snapshot-revision%", snapshotrevision); + } + else + { + GlobalVars.ProgramInformation.Version = snapshottemplate.Replace("%version%", versionbranch) + .Replace("%build%", Assembly.GetExecutingAssembly().GetName().Version.Build.ToString()) + .Replace("%revision%", Assembly.GetExecutingAssembly().GetName().Version.Revision.ToString()) + .Replace("%snapshot-revision%", snapshotrevision); + } + + string changelog = Directories.BasePath + "\\changelog.txt"; + if (File.Exists(changelog)) + { + string[] changelogedit = File.ReadAllLines(changelog); + if (!changelogedit[0].Equals(GlobalVars.ProgramInformation.Version)) + { + changelogedit[0] = GlobalVars.ProgramInformation.Version; + File.WriteAllLines(changelog, changelogedit); + } + } } else { - GlobalVars.Version = lines[6].Replace("%version%", lines[0]) - .Replace("%build%", Assembly.GetExecutingAssembly().GetName().Version.Build.ToString()) - .Replace("%revision%", Assembly.GetExecutingAssembly().GetName().Version.Revision.ToString()) - .Replace("%snapshot-revision%", lines[7]); + GlobalVars.ProgramInformation.Version = versionbranch; } - string changelog = Directories.BasePath + "\\changelog.txt"; - if (File.Exists(changelog)) - { - string[] changelogedit = File.ReadAllLines(changelog); - if (!changelogedit[0].Equals(GlobalVars.Version)) - { - changelogedit[0] = GlobalVars.Version; - File.WriteAllLines(changelog, changelogedit); - } - } + GlobalVars.ProgramInformation.Branch = versionbranch; + GlobalVars.ProgramInformation.DefaultClient = defaultclient; + GlobalVars.ProgramInformation.DefaultMap = defaultmap; + GlobalVars.ProgramInformation.RegisterClient1 = regclient1; + GlobalVars.ProgramInformation.RegisterClient2 = regclient2; + GlobalVars.UserConfiguration.SelectedClient = GlobalVars.ProgramInformation.DefaultClient; + GlobalVars.UserConfiguration.Map = GlobalVars.ProgramInformation.DefaultMap; + GlobalVars.UserConfiguration.MapPath = Directories.MapsDir + @"\\" + GlobalVars.ProgramInformation.DefaultMap; + GlobalVars.UserConfiguration.MapPathSnip = Directories.MapsDirBase + @"\\" + GlobalVars.ProgramInformation.DefaultMap; } - else + catch (Exception) { - GlobalVars.Version = lines[0]; - } - - GlobalVars.Branch = lines[0]; - if (!versiononly) - { - GlobalVars.DefaultClient = lines[1]; - GlobalVars.DefaultMap = lines[2]; - GlobalVars.RegisterClient1 = lines[3]; - GlobalVars.RegisterClient2 = lines[4]; - GlobalVars.UserConfiguration.SelectedClient = GlobalVars.DefaultClient; - GlobalVars.UserConfiguration.Map = GlobalVars.DefaultMap; - GlobalVars.UserConfiguration.MapPath = Directories.MapsDir + @"\\" + GlobalVars.DefaultMap; - GlobalVars.UserConfiguration.MapPathSnip = Directories.MapsDirBase + @"\\" + GlobalVars.DefaultMap; - } - } - - public static QualityLevel GetQualityLevelForInt(int level) - { - switch (level) - { - case 1: - return QualityLevel.VeryLow; - case 2: - return QualityLevel.Low; - case 3: - return QualityLevel.Medium; - case 4: - return QualityLevel.High; - case 5: - default: - return QualityLevel.Ultra; - } - } - - public static int GetIntForQualityLevel(QualityLevel level) - { - switch (level) - { - case QualityLevel.VeryLow: - return 1; - case QualityLevel.Low: - return 2; - case QualityLevel.Medium: - return 3; - case QualityLevel.High: - return 4; - case QualityLevel.Ultra: - default: - return 5; - } - } - - public static GraphicsMode GetGraphicsModeForInt(int level) - { - switch (level) - { - case 1: - return GraphicsMode.OpenGL; - case 2: - return GraphicsMode.DirectX; - default: - return GraphicsMode.None; - } - } - - public static int GetIntForGraphicsMode(GraphicsMode level) - { - switch (level) - { - case GraphicsMode.OpenGL: - return 1; - case GraphicsMode.DirectX: - return 2; - default: - return 0; + ReadInfoFile(infopath, cmd); } } @@ -163,10 +131,10 @@ public class LauncherFuncs ini.IniWriteValue(section, "DiscordRichPresence", GlobalVars.UserConfiguration.DiscordPresence.ToString()); ini.IniWriteValue(section, "MapPath", GlobalVars.UserConfiguration.MapPath.ToString()); ini.IniWriteValue(section, "MapPathSnip", GlobalVars.UserConfiguration.MapPathSnip.ToString()); - ini.IniWriteValue(section, "GraphicsMode", GetIntForGraphicsMode(GlobalVars.UserConfiguration.GraphicsMode).ToString()); + ini.IniWriteValue(section, "GraphicsMode", GlobalVars.UserConfiguration.GraphicsMode.ToString()); ini.IniWriteValue(section, "ReShade", GlobalVars.UserConfiguration.ReShade.ToString()); - ini.IniWriteValue(section, "QualityLevel", GetIntForQualityLevel(GlobalVars.UserConfiguration.QualityLevel).ToString()); - ini.IniWriteValue(section, "OldLayout", GlobalVars.UserConfiguration.OldLayout.ToString()); + ini.IniWriteValue(section, "QualityLevel", GlobalVars.UserConfiguration.QualityLevel.ToString()); + ini.IniWriteValue(section, "Layout", GlobalVars.UserConfiguration.LauncherLayout.ToString()); } else { @@ -174,7 +142,7 @@ public class LauncherFuncs string closeonlaunch, userid, name, selectedclient, map, port, limit, upnp, disablehelpmessage, tripcode, discord, mappath, mapsnip, - graphics, reshade, qualitylevel, oldlayout; + graphics, reshade, qualitylevel, layout; IniFile ini = new IniFile(cfgpath); @@ -193,15 +161,14 @@ public class LauncherFuncs discord = ini.IniReadValue(section, "DiscordRichPresence", GlobalVars.UserConfiguration.DiscordPresence.ToString()); mappath = ini.IniReadValue(section, "MapPath", GlobalVars.UserConfiguration.MapPath.ToString()); mapsnip = ini.IniReadValue(section, "MapPathSnip", GlobalVars.UserConfiguration.MapPathSnip.ToString()); - graphics = ini.IniReadValue(section, "GraphicsMode", GetIntForGraphicsMode(GlobalVars.UserConfiguration.GraphicsMode).ToString()); + graphics = ini.IniReadValue(section, "GraphicsMode", EnumParser.GetIntForGraphicsMode(GlobalVars.UserConfiguration.GraphicsMode).ToString()); reshade = ini.IniReadValue(section, "ReShade", GlobalVars.UserConfiguration.ReShade.ToString()); - qualitylevel = ini.IniReadValue(section, "QualityLevel", GetIntForQualityLevel(GlobalVars.UserConfiguration.QualityLevel).ToString()); - oldlayout = ini.IniReadValue(section, "OldLayout", GlobalVars.UserConfiguration.OldLayout.ToString()); + qualitylevel = ini.IniReadValue(section, "QualityLevel", EnumParser.GetIntForQualityLevel(GlobalVars.UserConfiguration.QualityLevel).ToString()); + layout = ini.IniReadValue(section, "Layout", EnumParser.GetIntForLauncherLayout(GlobalVars.UserConfiguration.LauncherLayout).ToString()); try { - bool bline1 = Convert.ToBoolean(closeonlaunch); - GlobalVars.UserConfiguration.CloseOnLaunch = bline1; + GlobalVars.UserConfiguration.CloseOnLaunch = Convert.ToBoolean(closeonlaunch); if (userid.Equals("0")) { @@ -210,8 +177,7 @@ public class LauncherFuncs } else { - int iline2 = Convert.ToInt32(userid); - GlobalVars.UserConfiguration.UserID = iline2; + GlobalVars.UserConfiguration.UserID = Convert.ToInt32(userid); } GlobalVars.UserConfiguration.PlayerName = name; @@ -220,17 +186,13 @@ public class LauncherFuncs GlobalVars.UserConfiguration.Map = map; - int iline6 = Convert.ToInt32(port); - GlobalVars.UserConfiguration.RobloxPort = iline6; + GlobalVars.UserConfiguration.RobloxPort = Convert.ToInt32(port); - int iline7 = Convert.ToInt32(limit); - GlobalVars.UserConfiguration.PlayerLimit = iline7; + GlobalVars.UserConfiguration.PlayerLimit = Convert.ToInt32(limit); - bool bline10 = Convert.ToBoolean(upnp); - GlobalVars.UserConfiguration.UPnP = bline10; + GlobalVars.UserConfiguration.UPnP = Convert.ToBoolean(upnp); - bool bline11 = Convert.ToBoolean(disablehelpmessage); - GlobalVars.UserConfiguration.DisabledItemMakerHelp = bline11; + GlobalVars.UserConfiguration.DisabledItemMakerHelp = Convert.ToBoolean(disablehelpmessage); if (string.IsNullOrWhiteSpace(SecurityFuncs.Base64Decode(tripcode))) { @@ -239,23 +201,18 @@ public class LauncherFuncs } else { - string sdecrypt12 = SecurityFuncs.Base64Decode(tripcode); - GlobalVars.UserConfiguration.PlayerTripcode = sdecrypt12; + GlobalVars.UserConfiguration.PlayerTripcode = SecurityFuncs.Base64Decode(tripcode); } - bool bline13 = Convert.ToBoolean(discord); - GlobalVars.UserConfiguration.DiscordPresence = bline13; + GlobalVars.UserConfiguration.DiscordPresence = Convert.ToBoolean(discord); GlobalVars.UserConfiguration.MapPath = mappath; GlobalVars.UserConfiguration.MapPathSnip = mapsnip; - int iline16 = Convert.ToInt32(graphics); - GlobalVars.UserConfiguration.GraphicsMode = GetGraphicsModeForInt(iline16); - bool bline17 = Convert.ToBoolean(reshade); - GlobalVars.UserConfiguration.ReShade = bline17; - int iline20 = Convert.ToInt32(qualitylevel); - GlobalVars.UserConfiguration.QualityLevel = GetQualityLevelForInt(iline20); - bool bline21 = Convert.ToBoolean(oldlayout); - GlobalVars.UserConfiguration.OldLayout = bline21; + + GlobalVars.UserConfiguration.GraphicsMode = EnumParser.GetGraphicsModeForInt(Convert.ToInt32(graphics)); + GlobalVars.UserConfiguration.ReShade = Convert.ToBoolean(reshade); + GlobalVars.UserConfiguration.QualityLevel = EnumParser.GetQualityLevelForInt(Convert.ToInt32(qualitylevel)); + GlobalVars.UserConfiguration.LauncherLayout = EnumParser.GetLauncherLayoutForInt(Convert.ToInt32(layout)); } catch (Exception) { @@ -368,23 +325,12 @@ public class LauncherFuncs GlobalVars.UserCustomization.Hat2 = hat2; GlobalVars.UserCustomization.Hat3 = hat3; - int iline4 = Convert.ToInt32(headcolorid); - GlobalVars.UserCustomization.HeadColorID = iline4; - - int iline5 = Convert.ToInt32(torsocolorid); - GlobalVars.UserCustomization.TorsoColorID = iline5; - - int iline6 = Convert.ToInt32(larmid); - GlobalVars.UserCustomization.LeftArmColorID = iline6; - - int iline7 = Convert.ToInt32(rarmid); - GlobalVars.UserCustomization.RightArmColorID = iline7; - - int iline8 = Convert.ToInt32(llegid); - GlobalVars.UserCustomization.LeftLegColorID = iline8; - - int iline9 = Convert.ToInt32(rlegid); - GlobalVars.UserCustomization.RightLegColorID = iline9; + GlobalVars.UserCustomization.HeadColorID = Convert.ToInt32(headcolorid); + GlobalVars.UserCustomization.TorsoColorID = Convert.ToInt32(torsocolorid); + GlobalVars.UserCustomization.LeftArmColorID = Convert.ToInt32(larmid); + GlobalVars.UserCustomization.RightArmColorID = Convert.ToInt32(rarmid); + GlobalVars.UserCustomization.LeftLegColorID = Convert.ToInt32(llegid); + GlobalVars.UserCustomization.RightLegColorID = Convert.ToInt32(rlegid); GlobalVars.UserCustomization.HeadColorString = headcolorstring; GlobalVars.UserCustomization.TorsoColorString = torsocolorstring; @@ -428,10 +374,10 @@ public class LauncherFuncs string section = "GENERAL"; - int FPS = GlobalVars.ReShadeFPSDisplay ? 1 : 0; + int FPS = GlobalVars.UserConfiguration.ReShadeFPSDisplay ? 1 : 0; ini.IniWriteValue(section, "ShowFPS", FPS.ToString()); ini.IniWriteValue(section, "ShowFrameTime", FPS.ToString()); - int PerformanceMode = GlobalVars.ReShadePerformanceMode ? 1 : 0; + int PerformanceMode = GlobalVars.UserConfiguration.ReShadePerformanceMode ? 1 : 0; ini.IniWriteValue(section, "PerformanceMode", PerformanceMode.ToString()); } else @@ -443,10 +389,10 @@ public class LauncherFuncs string section = "GENERAL"; - int FPS = GlobalVars.ReShadeFPSDisplay ? 1 : 0; + int FPS = GlobalVars.UserConfiguration.ReShadeFPSDisplay ? 1 : 0; framerate = ini.IniReadValue(section, "ShowFPS", FPS.ToString()); frametime = ini.IniReadValue(section, "ShowFrameTime", FPS.ToString()); - int PerformanceMode = GlobalVars.ReShadePerformanceMode ? 1 : 0; + int PerformanceMode = GlobalVars.UserConfiguration.ReShadePerformanceMode ? 1 : 0; performance = ini.IniReadValue(section, "PerformanceMode", PerformanceMode.ToString()); if (setglobals) @@ -456,20 +402,20 @@ public class LauncherFuncs switch(Convert.ToInt32(framerate)) { case int showFPSLine when showFPSLine == 1 && Convert.ToInt32(frametime) == 1: - GlobalVars.ReShadeFPSDisplay = true; + GlobalVars.UserConfiguration.ReShadeFPSDisplay = true; break; default: - GlobalVars.ReShadeFPSDisplay = false; + GlobalVars.UserConfiguration.ReShadeFPSDisplay = false; break; } switch (Convert.ToInt32(performance)) { case 1: - GlobalVars.ReShadePerformanceMode = true; + GlobalVars.UserConfiguration.ReShadePerformanceMode = true; break; default: - GlobalVars.ReShadePerformanceMode = false; + GlobalVars.UserConfiguration.ReShadePerformanceMode = false; break; } } @@ -595,8 +541,8 @@ public class LauncherFuncs public static void ResetConfigValues() { - GlobalVars.UserConfiguration.SelectedClient = GlobalVars.DefaultClient; - GlobalVars.UserConfiguration.Map = GlobalVars.DefaultMap; + GlobalVars.UserConfiguration.SelectedClient = GlobalVars.ProgramInformation.DefaultClient; + GlobalVars.UserConfiguration.Map = GlobalVars.ProgramInformation.DefaultMap; GlobalVars.UserConfiguration.CloseOnLaunch = false; GeneratePlayerID(); GlobalVars.UserConfiguration.PlayerName = "Player"; @@ -605,12 +551,12 @@ public class LauncherFuncs GlobalVars.UserConfiguration.UPnP = false; GlobalVars.UserConfiguration.DisabledItemMakerHelp = false; GlobalVars.UserConfiguration.DiscordPresence = true; - GlobalVars.UserConfiguration.MapPath = Directories.MapsDir + @"\\" + GlobalVars.DefaultMap; - GlobalVars.UserConfiguration.MapPathSnip = Directories.MapsDirBase + @"\\" + GlobalVars.DefaultMap; + GlobalVars.UserConfiguration.MapPath = Directories.MapsDir + @"\\" + GlobalVars.ProgramInformation.DefaultMap; + GlobalVars.UserConfiguration.MapPathSnip = Directories.MapsDirBase + @"\\" + GlobalVars.ProgramInformation.DefaultMap; GlobalVars.UserConfiguration.GraphicsMode = GraphicsMode.OpenGL; GlobalVars.UserConfiguration.ReShade = false; GlobalVars.UserConfiguration.QualityLevel = QualityLevel.Ultra; - GlobalVars.UserConfiguration.OldLayout = false; + GlobalVars.UserConfiguration.LauncherLayout = LauncherLayout.Extended; ResetCustomizationValues(); } @@ -785,49 +731,49 @@ public class LauncherFuncs GlobalVars.presence.smallImageKey = GlobalVars.image_inlauncher; GlobalVars.presence.state = "In Launcher"; GlobalVars.presence.details = "Selected " + GlobalVars.UserConfiguration.SelectedClient; - GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.Version; + GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.ProgramInformation.Version; GlobalVars.presence.smallImageText = "In Launcher"; break; case LauncherState.InMPGame: GlobalVars.presence.smallImageKey = GlobalVars.image_ingame; GlobalVars.presence.details = ValidMapname; GlobalVars.presence.state = "In " + GlobalVars.UserConfiguration.SelectedClient + " Multiplayer Game"; - GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.Version; + GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.ProgramInformation.Version; GlobalVars.presence.smallImageText = "In " + GlobalVars.UserConfiguration.SelectedClient + " Multiplayer Game"; break; case LauncherState.InSoloGame: GlobalVars.presence.smallImageKey = GlobalVars.image_ingame; GlobalVars.presence.details = ValidMapname; GlobalVars.presence.state = "In " + GlobalVars.UserConfiguration.SelectedClient + " Solo Game"; - GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.Version; + GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.ProgramInformation.Version; GlobalVars.presence.smallImageText = "In " + GlobalVars.UserConfiguration.SelectedClient + " Solo Game"; break; case LauncherState.InStudio: GlobalVars.presence.smallImageKey = GlobalVars.image_instudio; GlobalVars.presence.details = ValidMapname; GlobalVars.presence.state = "In " + GlobalVars.UserConfiguration.SelectedClient + " Studio"; - GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.Version; + GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.ProgramInformation.Version; GlobalVars.presence.smallImageText = "In " + GlobalVars.UserConfiguration.SelectedClient + " Studio"; break; case LauncherState.InCustomization: GlobalVars.presence.smallImageKey = GlobalVars.image_incustomization; GlobalVars.presence.details = "Customizing " + GlobalVars.UserConfiguration.PlayerName; GlobalVars.presence.state = "In Character Customization"; - GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.Version; + GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.ProgramInformation.Version; GlobalVars.presence.smallImageText = "In Character Customization"; break; case LauncherState.InEasterEggGame: GlobalVars.presence.smallImageKey = GlobalVars.image_ingame; GlobalVars.presence.details = ValidMapname; GlobalVars.presence.state = "Reading a message."; - GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.Version; + GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.ProgramInformation.Version; GlobalVars.presence.smallImageText = "Reading a message."; break; case LauncherState.LoadingURI: GlobalVars.presence.smallImageKey = GlobalVars.image_ingame; GlobalVars.presence.details = ValidMapname; GlobalVars.presence.state = "Joining a " + GlobalVars.UserConfiguration.SelectedClient + " Multiplayer Game"; - GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.Version; + GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.ProgramInformation.Version; GlobalVars.presence.smallImageText = "Joining a " + GlobalVars.UserConfiguration.SelectedClient + " Multiplayer Game"; break; default: @@ -984,92 +930,3 @@ public class LauncherFuncs } } #endregion - -#region Splash Reader -public static class SplashReader -{ - private static string RandomSplash() - { - string[] splashes = File.ReadAllLines(Directories.ConfigDir + "\\splashes.txt"); - string splash = ""; - - try - { - splash = splashes[new CryptoRandom().Next(0, splashes.Length - 1)]; - } - catch (Exception) - { - try - { - splash = splashes[0]; - } - catch (Exception) - { - splash = "missingno"; - return splash; - } - } - - CryptoRandom random = new CryptoRandom(); - - string formattedsplash = splash - .Replace("%name%", GlobalVars.UserConfiguration.PlayerName) - .Replace("%nextversion%", (Convert.ToDouble(GlobalVars.Branch) + 0.1).ToString()) - .Replace("%randomtext%", SecurityFuncs.RandomString(random.Next(2, 32))); - - return formattedsplash; - } - - public static string GetSplash() - { - DateTime today = DateTime.Now; - string splash = ""; - - switch (today) - { - case DateTime christmaseve when christmaseve.Month.Equals(12) && christmaseve.Day.Equals(24): - case DateTime christmasday when christmasday.Month.Equals(12) && christmasday.Day.Equals(25): - splash = "Merry Christmas!"; - break; - case DateTime newyearseve when newyearseve.Month.Equals(12) && newyearseve.Day.Equals(31): - case DateTime newyearsday when newyearsday.Month.Equals(1) && newyearsday.Day.Equals(1): - splash = "Happy New Year!"; - break; - case DateTime halloween when halloween.Month.Equals(10) && halloween.Day.Equals(31): - splash = "Happy Halloween!"; - break; - case DateTime bitlbirthday when bitlbirthday.Month.Equals(6) && bitlbirthday.Day.Equals(10): - splash = "Happy Birthday, Bitl!"; - break; - case DateTime robloxbirthday when robloxbirthday.Month.Equals(8) && robloxbirthday.Day.Equals(27): - splash = "Happy Birthday, ROBLOX!"; - break; - case DateTime novetusbirthday when novetusbirthday.Month.Equals(10) && novetusbirthday.Day.Equals(27): - splash = "Happy Birthday, Novetus!"; - break; - case DateTime leiferikson when leiferikson.Month.Equals(10) && leiferikson.Day.Equals(9): - splash = "Happy Leif Erikson Day! HINGA DINGA DURGEN!"; - break; - case DateTime smokeweedeveryday when smokeweedeveryday.Month.Equals(4) && smokeweedeveryday.Day.Equals(20): - CryptoRandom random = new CryptoRandom(); - if (random.Next(0, 1) == 1) - { - splash = "smoke weed every day"; - } - else - { - splash = "4/20 lol"; - } - break; - case DateTime erikismyhero when erikismyhero.Month.Equals(2) && erikismyhero.Day.Equals(11): - splash = "RIP Erik Cassel"; - break; - default: - splash = RandomSplash(); - break; - } - - return splash; - } -} -#endregion diff --git a/NovetusLauncher/NovetusFuncs/NovetusLoaderFuncs.cs b/NovetusLauncher/NovetusFuncs/NovetusLoaderFuncs.cs deleted file mode 100644 index 0b46376..0000000 --- a/NovetusLauncher/NovetusFuncs/NovetusLoaderFuncs.cs +++ /dev/null @@ -1,305 +0,0 @@ -#region Usings -using System; -using System.IO; -using System.Windows.Forms; -using System.Linq; -using System.Text; -using Ionic.Zip; -using System.Net; -#endregion - -#region Downloader -class Downloader -{ - private readonly string fileURL; - private readonly string fileName; - private readonly string fileFilter; - private string downloadOutcome; - private static string downloadOutcomeException; - - public Downloader(string url, string name, string filter) - { - fileName = name; - fileURL = url; - fileFilter = filter; - } - - public Downloader(string url, string name) - { - fileName = name; - fileURL = url; - fileFilter = ""; - } - - public void setDownloadOutcome(string text) - { - downloadOutcome = text; - } - - public string getDownloadOutcome() - { - return downloadOutcome; - } - - public void InitDownload(string path, string fileext, string additionalText = "") - { - string downloadOutcomeAddText = additionalText; - - string outputfilename = fileName + fileext; - string fullpath = path + "\\" + outputfilename; - - try - { - int read = DownloadFile(fileURL, fullpath); - downloadOutcome = "File " + outputfilename + " downloaded! " + read + " bytes written! " + downloadOutcomeAddText + downloadOutcomeException; - } - catch (Exception ex) - { - downloadOutcome = "Error when downloading file: " + ex.Message; - } - } - - public void InitDownload(string additionalText = "") - { - string downloadOutcomeAddText = additionalText; - - SaveFileDialog saveFileDialog1 = new SaveFileDialog - { - FileName = fileName, - //"Compressed zip files (*.zip)|*.zip|All files (*.*)|*.*" - Filter = fileFilter, - Title = "Save " + fileName - }; - - if (saveFileDialog1.ShowDialog() == DialogResult.OK) - { - try - { - int read = DownloadFile(fileURL, saveFileDialog1.FileName); - downloadOutcome = "File " + Path.GetFileName(saveFileDialog1.FileName) + " downloaded! " + read + " bytes written! " + downloadOutcomeAddText + downloadOutcomeException; - } - catch (Exception ex) - { - downloadOutcome = "Error when downloading file: " + ex.Message; - } - } - } - - private static int DownloadFile(string remoteFilename, string localFilename) - { - //credit to Tom Archer (https://www.codeguru.com/columns/dotnettips/article.php/c7005/Downloading-Files-with-the-WebRequest-and-WebResponse-Classes.htm) - //and Brokenglass (https://stackoverflow.com/questions/4567313/uncompressing-gzip-response-from-webclient/4567408#4567408) - - // Function will return the number of bytes processed - // to the caller. Initialize to 0 here. - int bytesProcessed = 0; - - // Assign values to these objects here so that they can - // be referenced in the finally block - Stream remoteStream = null; - Stream localStream = null; - WebResponse response = null; - - // Use a try/catch/finally block as both the WebRequest and Stream - // classes throw exceptions upon error - //thanks to https://stackoverflow.com/questions/33761919/tls-1-2-in-net-framework-4-0 for the net 4.0 compatible TLS 1.1/1.2 code! - try - { - ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls - | (SecurityProtocolType)3072 - | (SecurityProtocolType)768 - | SecurityProtocolType.Ssl3; - // Create a request for the specified remote file name - HttpWebRequest request = (HttpWebRequest)WebRequest.Create(remoteFilename); - request.UserAgent = "Roblox/WinINet"; - request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate"); - request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; - if (request != null) - { - // Send the request to the server and retrieve the - // WebResponse object - response = request.GetResponse(); - if (response != null) - { - // Once the WebResponse object has been retrieved, - // get the stream object associated with the response's data - remoteStream = response.GetResponseStream(); - - // Create the local file - localStream = File.Create(localFilename); - - // Allocate a 1k buffer - byte[] buffer = new byte[1024]; - int bytesRead; - - // Simple do/while loop to read from stream until - // no bytes are returned - do - { - // Read data (up to 1k) from the stream - bytesRead = remoteStream.Read(buffer, 0, buffer.Length); - - // Write the data to the local file - localStream.Write(buffer, 0, bytesRead); - - // Increment total bytes processed - bytesProcessed += bytesRead; - } while (bytesRead > 0); - } - } - } - catch (Exception e) - { - downloadOutcomeException = " Exception detected: " + e.Message; - } - finally - { - // Close the response and streams objects here - // to make sure they're closed even if an exception - // is thrown at some point - if (response != null) response.Close(); - if (remoteStream != null) remoteStream.Close(); - if (localStream != null) localStream.Close(); - } - - // Return total bytes processed to caller. - return bytesProcessed; - } -} -#endregion - -#region Addon Loader -public class AddonLoader -{ - private readonly OpenFileDialog openFileDialog1; - private string installOutcome = ""; - private int fileListDisplay = 0; - - public AddonLoader() - { - openFileDialog1 = new OpenFileDialog() - { - FileName = "Select an addon .zip file", - Filter = "Compressed zip files (*.zip)|*.zip", - Title = "Open addon .zip" - }; - } - - public void setInstallOutcome(string text) - { - installOutcome = text; - } - - public string getInstallOutcome() - { - return installOutcome; - } - - public void setFileListDisplay(int number) - { - fileListDisplay = number; - } - - public void LoadAddon() - { - if (openFileDialog1.ShowDialog() == DialogResult.OK) - { - try - { - int filecount = 0; - StringBuilder filelistbuilder = new StringBuilder(); - - using (Stream str = openFileDialog1.OpenFile()) - { - using (var zipFile = ZipFile.Read(str)) - { - ZipEntry[] entries = zipFile.Entries.ToArray(); - - foreach (ZipEntry entry in entries) - { - filelistbuilder.Append(entry.FileName + " ("+ entry.UncompressedSize +")"); - filelistbuilder.Append(Environment.NewLine); - } - - zipFile.ExtractAll(Directories.BasePath, ExtractExistingFileAction.OverwriteSilently); - } - } - - string filelist = filelistbuilder.ToString(); - - if (filecount > fileListDisplay) - { - installOutcome = "Addon " + openFileDialog1.SafeFileName + " installed! " + filecount + " files copied!" + Environment.NewLine + "Files added/modified:" + Environment.NewLine + Environment.NewLine + filelist + Environment.NewLine + "and " + (filecount - fileListDisplay) + " more files!"; - } - else - { - installOutcome = "Addon " + openFileDialog1.SafeFileName + " installed! " + filecount + " files copied!" + Environment.NewLine + "Files added/modified:" + Environment.NewLine + Environment.NewLine + filelist; - } - } - catch (Exception ex) - { - installOutcome = "Error when installing addon: " + ex.Message; - } - } - } -} -#endregion - -#region Icon Loader -public class IconLoader -{ - private OpenFileDialog openFileDialog1; - private string installOutcome = ""; - - public IconLoader() - { - openFileDialog1 = new OpenFileDialog() - { - FileName = "Select an icon .png file", - Filter = "Portable Network Graphics image (*.png)|*.png", - Title = "Open icon .png" - }; - } - - public void setInstallOutcome(string text) - { - installOutcome = text; - } - - public string getInstallOutcome() - { - return installOutcome; - } - - public void LoadImage() - { - if (openFileDialog1.ShowDialog() == DialogResult.OK) - { - try - { - using (Stream str = openFileDialog1.OpenFile()) - { - using (Stream output = new FileStream(Directories.extradir + "\\icons\\" + GlobalVars.UserConfiguration.PlayerName + ".png", FileMode.Create)) - { - byte[] buffer = new byte[32 * 1024]; - int read; - - while ((read = str.Read(buffer, 0, buffer.Length)) > 0) - { - output.Write(buffer, 0, read); - } - } - - str.Close(); - } - - installOutcome = "Icon " + openFileDialog1.SafeFileName + " installed!"; - } - catch (Exception ex) - { - installOutcome = "Error when installing icon: " + ex.Message; - } - } - } -} -#endregion \ No newline at end of file diff --git a/NovetusLauncher/NovetusFuncs/NovetusSecurityFuncs.cs b/NovetusLauncher/NovetusFuncs/NovetusSecurityFuncs.cs index 59f1e69..532b357 100644 --- a/NovetusLauncher/NovetusFuncs/NovetusSecurityFuncs.cs +++ b/NovetusLauncher/NovetusFuncs/NovetusSecurityFuncs.cs @@ -184,7 +184,7 @@ public class SecurityFuncs { case ScriptType.Client: SetWindowText(exe.MainWindowHandle, "Novetus " - + GlobalVars.Version + " - " + + GlobalVars.ProgramInformation.Version + " - " + clientname + " " + ScriptGenerator.GetNameForType(type) + " [" + GlobalVars.IP + ":" + GlobalVars.UserConfiguration.RobloxPort + "]" @@ -193,7 +193,7 @@ public class SecurityFuncs case ScriptType.Server: case ScriptType.Solo: SetWindowText(exe.MainWindowHandle, "Novetus " - + GlobalVars.Version + " - " + + GlobalVars.ProgramInformation.Version + " - " + clientname + " " + ScriptGenerator.GetNameForType(type) + (string.IsNullOrWhiteSpace(mapname) ? " [Place1]" : " [" + mapname + "]") @@ -201,7 +201,7 @@ public class SecurityFuncs break; case ScriptType.Studio: SetWindowText(exe.MainWindowHandle, "Novetus Studio " - + GlobalVars.Version + " - " + + GlobalVars.ProgramInformation.Version + " - " + clientname + (string.IsNullOrWhiteSpace(mapname) ? " [Place1]" : " [" + mapname + "]") + RandomStringTitle()); diff --git a/NovetusLauncher/NovetusLauncher/LocalVars.cs b/NovetusLauncher/NovetusLauncher/LocalVars.cs index 1242336..7b2f8e9 100644 --- a/NovetusLauncher/NovetusLauncher/LocalVars.cs +++ b/NovetusLauncher/NovetusLauncher/LocalVars.cs @@ -1,4 +1,17 @@ -namespace NovetusLauncher +#region Usings +using Ionic.Zip; +using System; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Text.RegularExpressions; +using System.Windows.Forms; +using System.Xml; +using System.Xml.Linq; +#endregion + +namespace NovetusLauncher { #region LocalVars class LocalVars @@ -10,8 +23,304 @@ } #endregion + #region Downloader + class Downloader + { + private readonly string fileURL; + private readonly string fileName; + private readonly string fileFilter; + private string downloadOutcome; + private static string downloadOutcomeException; + + public Downloader(string url, string name, string filter) + { + fileName = name; + fileURL = url; + fileFilter = filter; + } + + public Downloader(string url, string name) + { + fileName = name; + fileURL = url; + fileFilter = ""; + } + + public void setDownloadOutcome(string text) + { + downloadOutcome = text; + } + + public string getDownloadOutcome() + { + return downloadOutcome; + } + + public void InitDownload(string path, string fileext, string additionalText = "") + { + string downloadOutcomeAddText = additionalText; + + string outputfilename = fileName + fileext; + string fullpath = path + "\\" + outputfilename; + + try + { + int read = DownloadFile(fileURL, fullpath); + downloadOutcome = "File " + outputfilename + " downloaded! " + read + " bytes written! " + downloadOutcomeAddText + downloadOutcomeException; + } + catch (Exception ex) + { + downloadOutcome = "Error when downloading file: " + ex.Message; + } + } + + public void InitDownload(string additionalText = "") + { + string downloadOutcomeAddText = additionalText; + + SaveFileDialog saveFileDialog1 = new SaveFileDialog + { + FileName = fileName, + //"Compressed zip files (*.zip)|*.zip|All files (*.*)|*.*" + Filter = fileFilter, + Title = "Save " + fileName + }; + + if (saveFileDialog1.ShowDialog() == DialogResult.OK) + { + try + { + int read = DownloadFile(fileURL, saveFileDialog1.FileName); + downloadOutcome = "File " + Path.GetFileName(saveFileDialog1.FileName) + " downloaded! " + read + " bytes written! " + downloadOutcomeAddText + downloadOutcomeException; + } + catch (Exception ex) + { + downloadOutcome = "Error when downloading file: " + ex.Message; + } + } + } + + private static int DownloadFile(string remoteFilename, string localFilename) + { + //credit to Tom Archer (https://www.codeguru.com/columns/dotnettips/article.php/c7005/Downloading-Files-with-the-WebRequest-and-WebResponse-Classes.htm) + //and Brokenglass (https://stackoverflow.com/questions/4567313/uncompressing-gzip-response-from-webclient/4567408#4567408) + + // Function will return the number of bytes processed + // to the caller. Initialize to 0 here. + int bytesProcessed = 0; + + // Assign values to these objects here so that they can + // be referenced in the finally block + Stream remoteStream = null; + Stream localStream = null; + WebResponse response = null; + + // Use a try/catch/finally block as both the WebRequest and Stream + // classes throw exceptions upon error + //thanks to https://stackoverflow.com/questions/33761919/tls-1-2-in-net-framework-4-0 for the net 4.0 compatible TLS 1.1/1.2 code! + try + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls + | (SecurityProtocolType)3072 + | (SecurityProtocolType)768 + | SecurityProtocolType.Ssl3; + // Create a request for the specified remote file name + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(remoteFilename); + request.UserAgent = "Roblox/WinINet"; + request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate"); + request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; + if (request != null) + { + // Send the request to the server and retrieve the + // WebResponse object + response = request.GetResponse(); + if (response != null) + { + // Once the WebResponse object has been retrieved, + // get the stream object associated with the response's data + remoteStream = response.GetResponseStream(); + + // Create the local file + localStream = File.Create(localFilename); + + // Allocate a 1k buffer + byte[] buffer = new byte[1024]; + int bytesRead; + + // Simple do/while loop to read from stream until + // no bytes are returned + do + { + // Read data (up to 1k) from the stream + bytesRead = remoteStream.Read(buffer, 0, buffer.Length); + + // Write the data to the local file + localStream.Write(buffer, 0, bytesRead); + + // Increment total bytes processed + bytesProcessed += bytesRead; + } while (bytesRead > 0); + } + } + } + catch (Exception e) + { + downloadOutcomeException = " Exception detected: " + e.Message; + } + finally + { + // Close the response and streams objects here + // to make sure they're closed even if an exception + // is thrown at some point + if (response != null) response.Close(); + if (remoteStream != null) remoteStream.Close(); + if (localStream != null) localStream.Close(); + } + + // Return total bytes processed to caller. + return bytesProcessed; + } + } + #endregion + + #region Addon Loader + public class AddonLoader + { + private readonly OpenFileDialog openFileDialog1; + private string installOutcome = ""; + private int fileListDisplay = 0; + + public AddonLoader() + { + openFileDialog1 = new OpenFileDialog() + { + FileName = "Select an addon .zip file", + Filter = "Compressed zip files (*.zip)|*.zip", + Title = "Open addon .zip" + }; + } + + public void setInstallOutcome(string text) + { + installOutcome = text; + } + + public string getInstallOutcome() + { + return installOutcome; + } + + public void setFileListDisplay(int number) + { + fileListDisplay = number; + } + + public void LoadAddon() + { + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + try + { + int filecount = 0; + StringBuilder filelistbuilder = new StringBuilder(); + + using (Stream str = openFileDialog1.OpenFile()) + { + using (var zipFile = ZipFile.Read(str)) + { + ZipEntry[] entries = zipFile.Entries.ToArray(); + + foreach (ZipEntry entry in entries) + { + filelistbuilder.Append(entry.FileName + " (" + entry.UncompressedSize + ")"); + filelistbuilder.Append(Environment.NewLine); + } + + zipFile.ExtractAll(Directories.BasePath, ExtractExistingFileAction.OverwriteSilently); + } + } + + string filelist = filelistbuilder.ToString(); + + if (filecount > fileListDisplay) + { + installOutcome = "Addon " + openFileDialog1.SafeFileName + " installed! " + filecount + " files copied!" + Environment.NewLine + "Files added/modified:" + Environment.NewLine + Environment.NewLine + filelist + Environment.NewLine + "and " + (filecount - fileListDisplay) + " more files!"; + } + else + { + installOutcome = "Addon " + openFileDialog1.SafeFileName + " installed! " + filecount + " files copied!" + Environment.NewLine + "Files added/modified:" + Environment.NewLine + Environment.NewLine + filelist; + } + } + catch (Exception ex) + { + installOutcome = "Error when installing addon: " + ex.Message; + } + } + } + } + #endregion + + #region Icon Loader + public class IconLoader + { + private OpenFileDialog openFileDialog1; + private string installOutcome = ""; + + public IconLoader() + { + openFileDialog1 = new OpenFileDialog() + { + FileName = "Select an icon .png file", + Filter = "Portable Network Graphics image (*.png)|*.png", + Title = "Open icon .png" + }; + } + + public void setInstallOutcome(string text) + { + installOutcome = text; + } + + public string getInstallOutcome() + { + return installOutcome; + } + + public void LoadImage() + { + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + try + { + using (Stream str = openFileDialog1.OpenFile()) + { + using (Stream output = new FileStream(Directories.extradir + "\\icons\\" + GlobalVars.UserConfiguration.PlayerName + ".png", FileMode.Create)) + { + byte[] buffer = new byte[32 * 1024]; + int read; + + while ((read = str.Read(buffer, 0, buffer.Length)) > 0) + { + output.Write(buffer, 0, read); + } + } + + str.Close(); + } + + installOutcome = "Icon " + openFileDialog1.SafeFileName + " installed!"; + } + catch (Exception ex) + { + installOutcome = "Error when installing icon: " + ex.Message; + } + } + } + } + #endregion + #region Roblox Type Definitions - public class RobloxTypeDefs + public class RobloxDefs { public static AssetCacheDef Fonts { get { return new AssetCacheDef("SpecialMesh", new string[] { "MeshId", "TextureId" }, new string[] { ".mesh", ".png" }, new string[] { Directories.AssetCacheDirFonts, Directories.AssetCacheDirTextures }, new string[] { Directories.AssetCacheFontsGameDir, Directories.AssetCacheTexturesGameDir }); } } public static AssetCacheDef Sky { get { return new AssetCacheDef("Sky", new string[] { "SkyboxBk", "SkyboxDn", "SkyboxFt", "SkyboxLf", "SkyboxRt", "SkyboxUp" }, new string[] { ".png" }, new string[] { Directories.AssetCacheDirSky }, new string[] { Directories.AssetCacheSkyGameDir }); } } @@ -38,4 +347,236 @@ public static AssetCacheDef ItemPantsTexture { get { return new AssetCacheDef("Pants", new string[] { "PantsTemplate" }, new string[] { ".png" }, new string[] { Directories.pantsdirTextures }, new string[] { Directories.pantsGameDirTextures }); } } } #endregion + + #region Roblox XML Localizer + public static class RobloxXMLLocalizer + { + public static void DownloadFromNodes(string filepath, AssetCacheDef assetdef, string name = "", string meshname = "") + { + DownloadFromNodes(filepath, assetdef.Class, assetdef.Id[0], assetdef.Ext[0], assetdef.Dir[0], assetdef.GameDir[0], name, meshname); + } + + public static void DownloadFromNodes(string filepath, AssetCacheDef assetdef, int idIndex, int extIndex, int outputPathIndex, int inGameDirIndex, string name = "", string meshname = "") + { + DownloadFromNodes(filepath, assetdef.Class, assetdef.Id[idIndex], assetdef.Ext[extIndex], assetdef.Dir[outputPathIndex], assetdef.GameDir[inGameDirIndex], name, meshname); + } + + public static void DownloadFromNodes(string filepath, string itemClassValue, string itemIdValue, string fileext, string outputPath, string inGameDir, string name = "", string meshname = "") + { + string oldfile = File.ReadAllText(filepath); + string fixedfile = RemoveInvalidXmlChars(ReplaceHexadecimalSymbols(oldfile)); + XDocument doc = XDocument.Parse(fixedfile); + + try + { + var v = from nodes in doc.Descendants("Item") + where nodes.Attribute("class").Value == itemClassValue + select nodes; + + foreach (var item in v) + { + var v2 = from nodes in item.Descendants("Content") + where nodes.Attribute("name").Value == itemIdValue + select nodes; + + foreach (var item2 in v2) + { + var v3 = from nodes in item2.Descendants("url") + select nodes; + + foreach (var item3 in v3) + { + if (!item3.Value.Contains("rbxassetid")) + { + if (!item3.Value.Contains("rbxasset")) + { + if (string.IsNullOrWhiteSpace(meshname)) + { + string url = item3.Value; + string urlFixed = url.Replace("&", "&").Replace("amp;", "&"); + string peram = "id="; + + if (string.IsNullOrWhiteSpace(name)) + { + if (urlFixed.Contains(peram)) + { + string IDVal = urlFixed.After(peram); + DownloadFilesFromNode(urlFixed, outputPath, fileext, IDVal); + item3.Value = inGameDir + IDVal + fileext; + } + } + else + { + DownloadFilesFromNode(urlFixed, outputPath, fileext, name); + item3.Value = inGameDir + name + fileext; + } + } + else + { + item3.Value = inGameDir + meshname; + } + } + } + else + { + if (string.IsNullOrWhiteSpace(meshname)) + { + string url = item3.Value; + string rbxassetid = "rbxassetid://"; + string urlFixed = "https://www.roblox.com/asset/?id=" + url.After(rbxassetid); + string peram = "id="; + + if (string.IsNullOrWhiteSpace(name)) + { + if (urlFixed.Contains(peram)) + { + string IDVal = urlFixed.After(peram); + DownloadFilesFromNode(urlFixed, outputPath, fileext, IDVal); + item3.Value = inGameDir + IDVal + fileext; + } + } + else + { + DownloadFilesFromNode(urlFixed, outputPath, fileext, name); + item3.Value = inGameDir + name + fileext; + } + } + else + { + item3.Value = inGameDir + meshname; + } + } + } + } + } + + } + catch (Exception ex) + { + MessageBox.Show("The download has experienced an error: " + ex.Message, "Novetus Asset Localizer", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + finally + { + doc.Save(filepath); + } + } + + private static void DownloadFilesFromNode(string url, string path, string fileext, string id) + { + if (!string.IsNullOrWhiteSpace(id)) + { + Downloader download = new Downloader(url, id); + + try + { + download.InitDownload(path, fileext); + } + catch (Exception ex) + { + MessageBox.Show("The download has experienced an error: " + ex.Message, "Novetus Asset Localizer", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + } + + private static string RemoveInvalidXmlChars(string content) + { + return new string(content.Where(ch => XmlConvert.IsXmlChar(ch)).ToArray()); + } + + private static string ReplaceHexadecimalSymbols(string txt) + { + string r = "[\x00-\x08\x0B\x0C\x0E-\x1F\x26]"; + return Regex.Replace(txt, r, "", RegexOptions.Compiled); + } + } + #endregion + + #region Splash Reader + public static class SplashReader + { + private static string RandomSplash() + { + string[] splashes = File.ReadAllLines(Directories.ConfigDir + "\\splashes.txt"); + string splash = ""; + + try + { + splash = splashes[new CryptoRandom().Next(0, splashes.Length - 1)]; + } + catch (Exception) + { + try + { + splash = splashes[0]; + } + catch (Exception) + { + splash = "missingno"; + return splash; + } + } + + CryptoRandom random = new CryptoRandom(); + + string formattedsplash = splash + .Replace("%name%", GlobalVars.UserConfiguration.PlayerName) + .Replace("%nextversion%", (Convert.ToDouble(GlobalVars.ProgramInformation.Branch) + 0.1).ToString()) + .Replace("%randomtext%", SecurityFuncs.RandomString(random.Next(2, 32))); + + return formattedsplash; + } + + public static string GetSplash() + { + DateTime today = DateTime.Now; + string splash = ""; + + switch (today) + { + case DateTime christmaseve when christmaseve.Month.Equals(12) && christmaseve.Day.Equals(24): + case DateTime christmasday when christmasday.Month.Equals(12) && christmasday.Day.Equals(25): + splash = "Merry Christmas!"; + break; + case DateTime newyearseve when newyearseve.Month.Equals(12) && newyearseve.Day.Equals(31): + case DateTime newyearsday when newyearsday.Month.Equals(1) && newyearsday.Day.Equals(1): + splash = "Happy New Year!"; + break; + case DateTime halloween when halloween.Month.Equals(10) && halloween.Day.Equals(31): + splash = "Happy Halloween!"; + break; + case DateTime bitlbirthday when bitlbirthday.Month.Equals(6) && bitlbirthday.Day.Equals(10): + splash = "Happy Birthday, Bitl!"; + break; + case DateTime robloxbirthday when robloxbirthday.Month.Equals(8) && robloxbirthday.Day.Equals(27): + splash = "Happy Birthday, ROBLOX!"; + break; + case DateTime novetusbirthday when novetusbirthday.Month.Equals(10) && novetusbirthday.Day.Equals(27): + splash = "Happy Birthday, Novetus!"; + break; + case DateTime leiferikson when leiferikson.Month.Equals(10) && leiferikson.Day.Equals(9): + splash = "Happy Leif Erikson Day! HINGA DINGA DURGEN!"; + break; + case DateTime smokeweedeveryday when smokeweedeveryday.Month.Equals(4) && smokeweedeveryday.Day.Equals(20): + CryptoRandom random = new CryptoRandom(); + if (random.Next(0, 1) == 1) + { + splash = "smoke weed every day"; + } + else + { + splash = "4/20 lol"; + } + break; + case DateTime erikismyhero when erikismyhero.Month.Equals(2) && erikismyhero.Day.Equals(11): + splash = "RIP Erik Cassel"; + break; + default: + splash = RandomSplash(); + break; + } + + return splash; + } + } + #endregion } diff --git a/NovetusLauncher/NovetusLauncher/MainForm/MainForm.cs b/NovetusLauncher/NovetusLauncher/MainForm/MainForm.cs index 6124173..17324b0 100644 --- a/NovetusLauncher/NovetusLauncher/MainForm/MainForm.cs +++ b/NovetusLauncher/NovetusLauncher/MainForm/MainForm.cs @@ -250,7 +250,7 @@ namespace NovetusLauncher "Port: " + GlobalVars.UserConfiguration.RobloxPort.ToString(), "Map: " + GlobalVars.UserConfiguration.Map, "Players: " + GlobalVars.UserConfiguration.PlayerLimit, - "Version: Novetus " + GlobalVars.Version, + "Version: Novetus " + GlobalVars.ProgramInformation.Version, "Online URI Link:", URI, "Local URI Link:", @@ -405,8 +405,8 @@ namespace NovetusLauncher void MainFormLoad(object sender, EventArgs e) { - Text = "Novetus " + GlobalVars.Version; - ConsolePrint("Novetus version " + GlobalVars.Version + " loaded. Initializing config.", 4); + Text = "Novetus " + GlobalVars.ProgramInformation.Version; + ConsolePrint("Novetus version " + GlobalVars.ProgramInformation.Version + " loaded. Initializing config.", 4); ConsolePrint("Novetus path: " + Directories.BasePath, 4); if (File.Exists(Directories.RootPath + "\\changelog.txt")) { @@ -474,7 +474,7 @@ namespace NovetusLauncher label8.Text = Application.ProductVersion; GlobalVars.important = SecurityFuncs.CalculateMD5(Assembly.GetExecutingAssembly().Location); - label11.Text = GlobalVars.Version; + label11.Text = GlobalVars.ProgramInformation.Version; label12.Text = SplashReader.GetSplash(); LocalVars.prevsplash = label12.Text; @@ -520,8 +520,8 @@ namespace NovetusLauncher label38.Text = GlobalVars.UserConfiguration.RobloxPort.ToString(); checkBox2.Checked = GlobalVars.UserConfiguration.DiscordPresence; checkBox5.Checked = GlobalVars.UserConfiguration.ReShade; - checkBox6.Checked = GlobalVars.ReShadeFPSDisplay; - checkBox7.Checked = GlobalVars.ReShadePerformanceMode; + checkBox6.Checked = GlobalVars.UserConfiguration.ReShadeFPSDisplay; + checkBox7.Checked = GlobalVars.UserConfiguration.ReShadePerformanceMode; switch (GlobalVars.UserConfiguration.GraphicsMode) { @@ -578,7 +578,7 @@ namespace NovetusLauncher { ConsolePrint("ERROR - No clientinfo.nov detected with the client you chose. The client either cannot be loaded, or it is not available.", 2); MessageBox.Show("No clientinfo.nov detected with the client you chose. The client either cannot be loaded, or it is not available.", "Novetus - Error while loading client", MessageBoxButtons.OK, MessageBoxIcon.Error); - GlobalVars.UserConfiguration.SelectedClient = GlobalVars.DefaultClient; + GlobalVars.UserConfiguration.SelectedClient = GlobalVars.ProgramInformation.DefaultClient; ReadClientValues(ClientName); } else @@ -1273,7 +1273,7 @@ namespace NovetusLauncher { Process process = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo(); - startInfo.FileName = Directories.ClientDir + @"\\" + GlobalVars.RegisterClient1 + @"\\RobloxApp_studio.exe"; + startInfo.FileName = Directories.ClientDir + @"\\" + GlobalVars.ProgramInformation.RegisterClient1 + @"\\RobloxApp_studio.exe"; startInfo.Arguments = "/regserver"; startInfo.Verb = "runas"; process.StartInfo = startInfo; @@ -1281,7 +1281,7 @@ namespace NovetusLauncher Process process2 = new Process(); ProcessStartInfo startInfo2 = new ProcessStartInfo(); - startInfo2.FileName = Directories.ClientDir + @"\\" + GlobalVars.RegisterClient2 + @"\\RobloxApp_studio.exe"; + startInfo2.FileName = Directories.ClientDir + @"\\" + GlobalVars.ProgramInformation.RegisterClient2 + @"\\RobloxApp_studio.exe"; startInfo2.Arguments = "/regserver"; startInfo2.Verb = "runas"; process2.StartInfo = startInfo2; @@ -1528,12 +1528,12 @@ namespace NovetusLauncher private void checkBox6_CheckedChanged(object sender, EventArgs e) { - GlobalVars.ReShadeFPSDisplay = checkBox6.Checked; + GlobalVars.UserConfiguration.ReShadeFPSDisplay = checkBox6.Checked; } private void checkBox7_CheckedChanged(object sender, EventArgs e) { - GlobalVars.ReShadePerformanceMode = checkBox7.Checked; + GlobalVars.UserConfiguration.ReShadePerformanceMode = checkBox7.Checked; } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) @@ -1574,7 +1574,7 @@ namespace NovetusLauncher private void button36_Click(object sender, EventArgs e) { - GlobalVars.UserConfiguration.OldLayout = true; + GlobalVars.UserConfiguration.LauncherLayout = LauncherLayout.Compact; WriteConfigValues(); Application.Restart(); } diff --git a/NovetusLauncher/NovetusLauncher/MainForm/MainForm_legacy.cs b/NovetusLauncher/NovetusLauncher/MainForm/MainForm_legacy.cs index 2e59e2d..ebd5a5f 100644 --- a/NovetusLauncher/NovetusLauncher/MainForm/MainForm_legacy.cs +++ b/NovetusLauncher/NovetusLauncher/MainForm/MainForm_legacy.cs @@ -249,7 +249,7 @@ namespace NovetusLauncher "Port: " + GlobalVars.UserConfiguration.RobloxPort.ToString(), "Map: " + GlobalVars.UserConfiguration.Map, "Players: " + GlobalVars.UserConfiguration.PlayerLimit, - "Version: Novetus " + GlobalVars.Version, + "Version: Novetus " + GlobalVars.ProgramInformation.Version, "Online URI Link:", URI, "Local URI Link:", @@ -404,8 +404,8 @@ namespace NovetusLauncher void MainFormLoad(object sender, EventArgs e) { - Text = "Novetus " + GlobalVars.Version; - ConsolePrint("Novetus version " + GlobalVars.Version + " loaded. Initializing config.", 4); + Text = "Novetus " + GlobalVars.ProgramInformation.Version; + ConsolePrint("Novetus version " + GlobalVars.ProgramInformation.Version + " loaded. Initializing config.", 4); ConsolePrint("Novetus path: " + Directories.BasePath, 4); if (File.Exists(Directories.RootPath + "\\changelog.txt")) { @@ -473,7 +473,7 @@ namespace NovetusLauncher label8.Text = Application.ProductVersion; GlobalVars.important = SecurityFuncs.CalculateMD5(Assembly.GetExecutingAssembly().Location); - label11.Text = GlobalVars.Version; + label11.Text = GlobalVars.ProgramInformation.Version; label12.Text = SplashReader.GetSplash(); LocalVars.prevsplash = label12.Text; @@ -543,7 +543,7 @@ namespace NovetusLauncher { ConsolePrint("ERROR - No clientinfo.nov detected with the client you chose. The client either cannot be loaded, or it is not available.", 2); MessageBox.Show("No clientinfo.nov detected with the client you chose. The client either cannot be loaded, or it is not available.", "Novetus - Error while loading client", MessageBoxButtons.OK, MessageBoxIcon.Error); - GlobalVars.UserConfiguration.SelectedClient = GlobalVars.DefaultClient; + GlobalVars.UserConfiguration.SelectedClient = GlobalVars.ProgramInformation.DefaultClient; ReadClientValues(ClientName); } else @@ -1238,7 +1238,7 @@ namespace NovetusLauncher { Process process = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo(); - startInfo.FileName = Directories.ClientDir + @"\\" + GlobalVars.RegisterClient1 + @"\\RobloxApp_studio.exe"; + startInfo.FileName = Directories.ClientDir + @"\\" + GlobalVars.ProgramInformation.RegisterClient1 + @"\\RobloxApp_studio.exe"; startInfo.Arguments = "/regserver"; startInfo.Verb = "runas"; process.StartInfo = startInfo; @@ -1246,7 +1246,7 @@ namespace NovetusLauncher Process process2 = new Process(); ProcessStartInfo startInfo2 = new ProcessStartInfo(); - startInfo2.FileName = Directories.ClientDir + @"\\" + GlobalVars.RegisterClient2 + @"\\RobloxApp_studio.exe"; + startInfo2.FileName = Directories.ClientDir + @"\\" + GlobalVars.ProgramInformation.RegisterClient2 + @"\\RobloxApp_studio.exe"; startInfo2.Arguments = "/regserver"; startInfo2.Verb = "runas"; process2.StartInfo = startInfo2; @@ -1516,7 +1516,7 @@ namespace NovetusLauncher private void button36_Click(object sender, EventArgs e) { - GlobalVars.UserConfiguration.OldLayout = false; + GlobalVars.UserConfiguration.LauncherLayout = LauncherLayout.Extended; WriteConfigValues(); Application.Restart(); } diff --git a/NovetusLauncher/NovetusLauncher/NovetusSettings.cs b/NovetusLauncher/NovetusLauncher/NovetusSettings.cs index 9f5b4fc..adf94f9 100644 --- a/NovetusLauncher/NovetusLauncher/NovetusSettings.cs +++ b/NovetusLauncher/NovetusLauncher/NovetusSettings.cs @@ -20,8 +20,8 @@ namespace NovetusLauncher { LauncherFuncs.Config(Directories.ConfigDir + "\\" + GlobalVars.ConfigName, false); checkBox5.Checked = GlobalVars.UserConfiguration.ReShade; - checkBox6.Checked = GlobalVars.ReShadeFPSDisplay; - checkBox7.Checked = GlobalVars.ReShadePerformanceMode; + checkBox6.Checked = GlobalVars.UserConfiguration.ReShadeFPSDisplay; + checkBox7.Checked = GlobalVars.UserConfiguration.ReShadePerformanceMode; switch (GlobalVars.UserConfiguration.GraphicsMode) { @@ -62,12 +62,12 @@ namespace NovetusLauncher private void checkBox6_CheckedChanged(object sender, EventArgs e) { - GlobalVars.ReShadeFPSDisplay = checkBox6.Checked; + GlobalVars.UserConfiguration.ReShadeFPSDisplay = checkBox6.Checked; } private void checkBox7_CheckedChanged(object sender, EventArgs e) { - GlobalVars.ReShadePerformanceMode = checkBox7.Checked; + GlobalVars.UserConfiguration.ReShadePerformanceMode = checkBox7.Checked; } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) diff --git a/NovetusLauncher/NovetusLauncher/Program.cs b/NovetusLauncher/NovetusLauncher/Program.cs index aa53b51..10d7c34 100644 --- a/NovetusLauncher/NovetusLauncher/Program.cs +++ b/NovetusLauncher/NovetusLauncher/Program.cs @@ -34,13 +34,15 @@ namespace NovetusLauncher { //read from our config to determine which clients to load. LauncherFuncs.Config(Directories.ConfigDir + "\\" + GlobalVars.ConfigName, false); - if (GlobalVars.UserConfiguration.OldLayout == false) - { - Application.Run(new MainForm()); - } - else + + switch (GlobalVars.UserConfiguration.LauncherLayout) { - Application.Run(new MainForm_legacy()); + case LauncherLayout.Compact: + Application.Run(new MainForm_legacy()); + break; + default: + Application.Run(new MainForm()); + break; } } else diff --git a/NovetusLauncher/NovetusLauncher/SDK/AssetLocalizer.cs b/NovetusLauncher/NovetusLauncher/SDK/AssetLocalizer.cs index 1fe3c1b..2597bc9 100644 --- a/NovetusLauncher/NovetusLauncher/SDK/AssetLocalizer.cs +++ b/NovetusLauncher/NovetusLauncher/SDK/AssetLocalizer.cs @@ -299,132 +299,132 @@ namespace NovetusLauncher } //meshes worker.ReportProgress(5); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Fonts); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Fonts, 1, 1, 1, 1); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Fonts); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Fonts, 1, 1, 1, 1); //skybox worker.ReportProgress(10); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Sky); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Sky, 1, 0, 0, 0); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Sky, 2, 0, 0, 0); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Sky, 3, 0, 0, 0); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Sky, 4, 0, 0, 0); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Sky, 5, 0, 0, 0); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Sky); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Sky, 1, 0, 0, 0); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Sky, 2, 0, 0, 0); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Sky, 3, 0, 0, 0); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Sky, 4, 0, 0, 0); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Sky, 5, 0, 0, 0); //decal worker.ReportProgress(15); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Decal); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Decal); //texture worker.ReportProgress(20); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Texture); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Texture); //tools and hopperbin worker.ReportProgress(25); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Tool); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Tool); worker.ReportProgress(30); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.HopperBin); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.HopperBin); //sound worker.ReportProgress(40); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Sound); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Sound); worker.ReportProgress(50); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.ImageLabel); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.ImageLabel); //clothing worker.ReportProgress(60); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Shirt); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Shirt); worker.ReportProgress(65); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.ShirtGraphic); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.ShirtGraphic); worker.ReportProgress(70); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Pants); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Pants); //scripts worker.ReportProgress(80); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Script); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Script); worker.ReportProgress(90); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.LocalScript); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.LocalScript); worker.ReportProgress(100); break; case RobloxFileType.RBXM: //meshes worker.ReportProgress(0); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Fonts); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Fonts, 1, 1, 1, 1); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Fonts); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Fonts, 1, 1, 1, 1); //skybox worker.ReportProgress(10); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Sky); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Sky, 1, 0, 0, 0); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Sky, 2, 0, 0, 0); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Sky, 3, 0, 0, 0); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Sky, 4, 0, 0, 0); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Sky, 5, 0, 0, 0); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Sky); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Sky, 1, 0, 0, 0); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Sky, 2, 0, 0, 0); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Sky, 3, 0, 0, 0); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Sky, 4, 0, 0, 0); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Sky, 5, 0, 0, 0); //decal worker.ReportProgress(15); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Decal); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Decal); //texture worker.ReportProgress(20); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Texture); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Texture); //tools and hopperbin worker.ReportProgress(25); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Tool); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Tool); worker.ReportProgress(30); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.HopperBin); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.HopperBin); //sound worker.ReportProgress(40); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Sound); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Sound); worker.ReportProgress(50); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.ImageLabel); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.ImageLabel); //clothing worker.ReportProgress(60); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Shirt); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Shirt); worker.ReportProgress(65); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.ShirtGraphic); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.ShirtGraphic); worker.ReportProgress(70); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Pants); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Pants); //scripts worker.ReportProgress(80); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Script); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Script); worker.ReportProgress(90); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.LocalScript); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.LocalScript); worker.ReportProgress(100); break; case RobloxFileType.Hat: //meshes worker.ReportProgress(0); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.ItemHatFonts, name, meshname); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.ItemHatFonts, 1, 1, 1, 1, name); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.ItemHatFonts, name, meshname); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.ItemHatFonts, 1, 1, 1, 1, name); worker.ReportProgress(25); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.ItemHatSound); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.ItemHatSound); //scripts worker.ReportProgress(50); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.Script); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.Script); worker.ReportProgress(75); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.LocalScript); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.LocalScript); worker.ReportProgress(100); break; case RobloxFileType.Head: //meshes worker.ReportProgress(0); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.ItemHeadFonts, name); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.ItemHeadFonts, 1, 1, 1, 1, name); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.ItemHeadFonts, name); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.ItemHeadFonts, 1, 1, 1, 1, name); worker.ReportProgress(100); break; case RobloxFileType.Face: //decal worker.ReportProgress(0); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.ItemFaceTexture, name); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.ItemFaceTexture, name); worker.ReportProgress(100); break; case RobloxFileType.TShirt: //texture worker.ReportProgress(0); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.ItemTShirtTexture, name); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.ItemTShirtTexture, name); worker.ReportProgress(100); break; case RobloxFileType.Shirt: //texture worker.ReportProgress(0); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.ItemShirtTexture, name); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.ItemShirtTexture, name); worker.ReportProgress(100); break; case RobloxFileType.Pants: //texture worker.ReportProgress(0); - RobloxXMLLocalizer.DownloadFromNodes(path, RobloxTypeDefs.ItemPantsTexture, name); + RobloxXMLLocalizer.DownloadFromNodes(path, RobloxDefs.ItemPantsTexture, name); worker.ReportProgress(100); break; default: diff --git a/NovetusLauncher/NovetusLauncher/SDK/ClientinfoCreator.cs b/NovetusLauncher/NovetusLauncher/SDK/ClientinfoCreator.cs index 3483771..5822e72 100644 --- a/NovetusLauncher/NovetusLauncher/SDK/ClientinfoCreator.cs +++ b/NovetusLauncher/NovetusLauncher/SDK/ClientinfoCreator.cs @@ -265,8 +265,7 @@ namespace NovetusLauncher checkBox4.Checked = Locked; } - bool bline1 = Convert.ToBoolean(usesplayername); - loadedClientInfo.UsesPlayerName = bline1; + loadedClientInfo.UsesPlayerName = Convert.ToBoolean(usesplayername); bool bline2 = Convert.ToBoolean(usesid); loadedClientInfo.UsesID = bline2; diff --git a/NovetusLauncher/NovetusLauncher/SDK/NovetusSDK.cs b/NovetusLauncher/NovetusLauncher/SDK/NovetusSDK.cs index 3c2793c..aabe807 100644 --- a/NovetusLauncher/NovetusLauncher/SDK/NovetusSDK.cs +++ b/NovetusLauncher/NovetusLauncher/SDK/NovetusSDK.cs @@ -34,8 +34,8 @@ namespace NovetusLauncher private void NovetusSDK_Load(object sender, EventArgs e) { - Text = "Novetus SDK " + GlobalVars.Version; - label1.Text = GlobalVars.Version; + Text = "Novetus SDK " + GlobalVars.ProgramInformation.Version; + label1.Text = GlobalVars.ProgramInformation.Version; } private void listBox1_SelectedIndexChanged(object sender, EventArgs e) diff --git a/NovetusLauncher/NovetusURI/URI/LoaderForm.cs b/NovetusLauncher/NovetusURI/URI/LoaderForm.cs index ad60155..dcff533 100644 --- a/NovetusLauncher/NovetusURI/URI/LoaderForm.cs +++ b/NovetusLauncher/NovetusURI/URI/LoaderForm.cs @@ -214,7 +214,7 @@ namespace NovetusURI if (!File.Exists(clientpath)) { MessageBox.Show("No clientinfo.nov detected with the client you chose. The client either cannot be loaded, or it is not available.", "Novetus Launcher - Error while loading client", MessageBoxButtons.OK, MessageBoxIcon.Error); - GlobalVars.UserConfiguration.SelectedClient = GlobalVars.DefaultClient; + GlobalVars.UserConfiguration.SelectedClient = GlobalVars.ProgramInformation.DefaultClient; ReadClientValues(ClientName); } else