From 607d0bcbb44951bee5093afd6505820ff02002b9 Mon Sep 17 00:00:00 2001 From: Bitl Date: Fri, 13 Jan 2023 14:21:14 -0700 Subject: [PATCH] move files, remove many #if clauses --- Novetus/NovetusCore/Classes/Downloader.cs | 7 -- Novetus/NovetusCore/Classes/INIFile.cs | 5 -- .../StorageAndFunctions/ClientManagement.cs | 65 +------------------ .../StorageAndFunctions/FileManagement.cs | 52 --------------- .../StorageAndFunctions/GlobalPaths.cs | 1 + .../StorageAndFunctions/NovetusFuncs.cs | 5 -- .../NovetusCore/StorageAndFunctions/Util.cs | 4 +- .../NovetusLauncher/Forms/NovetusConsole.cs | 4 +- .../Forms/SDK/ClientScriptDocumentation.cs | 2 +- 9 files changed, 8 insertions(+), 137 deletions(-) diff --git a/Novetus/NovetusCore/Classes/Downloader.cs b/Novetus/NovetusCore/Classes/Downloader.cs index 225e9f0..0553751 100644 --- a/Novetus/NovetusCore/Classes/Downloader.cs +++ b/Novetus/NovetusCore/Classes/Downloader.cs @@ -103,14 +103,9 @@ namespace Novetus.Core { read = DownloadFile(fileURL, name); } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif downloadOutcome = "Error when downloading file: " + ex.Message; } finally @@ -214,9 +209,7 @@ namespace Novetus.Core } catch (Exception e) { -#if URI || LAUNCHER || BASICLAUNCHER Util.LogExceptions(e); -#endif if (e is WebException && bytesProcessed == 0) { WebException ex = (WebException)e; diff --git a/Novetus/NovetusCore/Classes/INIFile.cs b/Novetus/NovetusCore/Classes/INIFile.cs index 3e4236c..80e1ca8 100644 --- a/Novetus/NovetusCore/Classes/INIFile.cs +++ b/Novetus/NovetusCore/Classes/INIFile.cs @@ -86,14 +86,9 @@ namespace Novetus.Core return false; } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif return false; } } diff --git a/Novetus/NovetusCore/StorageAndFunctions/ClientManagement.cs b/Novetus/NovetusCore/StorageAndFunctions/ClientManagement.cs index 3965103..829f9c9 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/ClientManagement.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/ClientManagement.cs @@ -47,14 +47,9 @@ namespace Novetus.Core GenerateDefaultClientInfo(Path.GetDirectoryName(clientpath)); ReadClientValues(name, initial); } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif Util.ConsolePrint("ERROR - Failed to generate default clientinfo.nov. Info: " + ex.Message, 2); Util.ConsolePrint("Loading default client '" + GlobalVars.ProgramInformation.DefaultClient + "'", 4); name = GlobalVars.ProgramInformation.DefaultClient; @@ -230,14 +225,9 @@ namespace Novetus.Core LoadClientValues(info, clientpath); return info; } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif return null; } } @@ -634,14 +624,9 @@ namespace Novetus.Core } } } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif return; } } @@ -700,14 +685,9 @@ namespace Novetus.Core ApplyClientSettings(info, ClientName, GraphicsMode, MeshDetail, ShadingQuality, MaterialQuality, AA, AASamples, Bevels, Shadows_2008, Shadows_2007, Style_2007, GFXQualityLevel, WindowResolution, FullscreenResolution, ModernResolution); } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif return; } } @@ -739,14 +719,9 @@ namespace Novetus.Core fixedfile = RobloxXML.RemoveInvalidXmlChars(RobloxXML.ReplaceHexadecimalSymbols(oldfile)); doc = XDocument.Parse(fixedfile); } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif return; } @@ -789,14 +764,9 @@ namespace Novetus.Core RobloxXML.EditRenderSettings(doc, "Resolution", ModernResolution.ToString(), XMLTypes.Token); } } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif return; } finally @@ -809,14 +779,9 @@ namespace Novetus.Core } } } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif return; } } @@ -1266,17 +1231,12 @@ namespace Novetus.Core #if URI ValidateFiles(line, validstart, validend, label); #else - ValidateFiles(line, validstart, validend); + ValidateFiles(line, validstart, validend); #endif } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif continue; } } @@ -1287,17 +1247,12 @@ namespace Novetus.Core #if URI ValidateFiles(line, validv2, "", label); #else - ValidateFiles(line, validv2, ""); + ValidateFiles(line, validv2, ""); #endif } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif continue; } } @@ -1413,11 +1368,7 @@ namespace Novetus.Core GlobalVars.ValidatedExtraFiles = 0; } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) -#else - catch (Exception) -#endif { #if URI UpdateStatus(label, "Error: " + ex.Message); @@ -1431,9 +1382,7 @@ namespace Novetus.Core MessageBox.Show("Failed to launch Novetus. (Error: " + ex.Message + ")", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } #endif -#if URI || LAUNCHER || BASICLAUNCHER Util.LogExceptions(ex); -#endif #if URI //toss the exception back to the URI @@ -1702,14 +1651,9 @@ namespace Novetus.Core return result; } } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif return ""; } } @@ -1805,14 +1749,9 @@ namespace Novetus.Core return source; } } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif return source; } } diff --git a/Novetus/NovetusCore/StorageAndFunctions/FileManagement.cs b/Novetus/NovetusCore/StorageAndFunctions/FileManagement.cs index af0bb27..59a4baf 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/FileManagement.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/FileManagement.cs @@ -336,14 +336,9 @@ namespace Novetus.Core group.Header = group.Header + " (" + group.Items.Count + ")"; }*/ } -#if URI || LAUNCHER || CMD || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif } } @@ -360,14 +355,9 @@ namespace Novetus.Core return Bmp; } -#if URI || LAUNCHER || CMD || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif return null; } } @@ -600,9 +590,7 @@ namespace Novetus.Core catch (Exception ex) { installOutcome = "Error when installing icon: " + ex.Message; -#if URI || LAUNCHER || BASICLAUNCHER Util.LogExceptions(ex); -#endif } } } @@ -697,14 +685,9 @@ namespace Novetus.Core GlobalVars.UserConfiguration.MapPath = GlobalPaths.MapsDir + @"\\" + GlobalVars.ProgramInformation.DefaultMap; GlobalVars.UserConfiguration.MapPathSnip = GlobalPaths.MapsDirBase + @"\\" + GlobalVars.ProgramInformation.DefaultMap; } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif ReadInfoFile(infopath, other); } } @@ -958,14 +941,9 @@ namespace Novetus.Core Config(cfgpath, true); } } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif Config(cfgpath, true); } } @@ -1128,14 +1106,9 @@ namespace Novetus.Core GlobalVars.UserCustomization.ExtraSelectionIsHat = ValueBool(extraishat, DefaultCustomization.ExtraSelectionIsHat); GlobalVars.UserCustomization.ShowHatsInExtra = ValueBool(showhatsonextra, DefaultCustomization.ShowHatsInExtra); } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif Customization(cfgpath, true); } } @@ -1251,14 +1224,9 @@ namespace Novetus.Core break; } } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif ReShadeValues(cfgpath, true, setglobals); } } @@ -1281,14 +1249,9 @@ namespace Novetus.Core goto Failure; } } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif goto Failure; } @@ -1319,14 +1282,9 @@ namespace Novetus.Core goto Failure; } } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif goto Failure; } @@ -1394,14 +1352,9 @@ namespace Novetus.Core download.InitDownloadNoDialog(path); return GlobalPaths.AssetCacheAssetsGameDir + download.fileName; } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif } } @@ -1444,14 +1397,9 @@ namespace Novetus.Core return RobloxXML.GetURLInNodes(doc, assetCacheDef.Class, assetCacheDef.Id[0], item); } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif } } diff --git a/Novetus/NovetusCore/StorageAndFunctions/GlobalPaths.cs b/Novetus/NovetusCore/StorageAndFunctions/GlobalPaths.cs index c34341d..fc95c47 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/GlobalPaths.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/GlobalPaths.cs @@ -29,6 +29,7 @@ namespace Novetus.Core public static readonly string AddonNovetusExts = AddonDir + @"\\novetusexts"; public static readonly string NovetusExtsWebProxy = AddonNovetusExts + @"\\webproxy"; public static readonly string MapsDirCustom = MapsDir + @"\\Custom"; + public static readonly string MiscDir = BasePath + @"\\misc"; public static readonly string MapsDirBase = "maps"; public static readonly string BaseGameDir = "rbxasset://../../../"; public static readonly string AltBaseGameDir = "rbxasset://"; diff --git a/Novetus/NovetusCore/StorageAndFunctions/NovetusFuncs.cs b/Novetus/NovetusCore/StorageAndFunctions/NovetusFuncs.cs index baec1b7..21f8e71 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/NovetusFuncs.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/NovetusFuncs.cs @@ -233,14 +233,9 @@ namespace Novetus.Core { ipAddress = new WebClient().DownloadString("https://ipv4.icanhazip.com/").TrimEnd(); } -#if URI || LAUNCHER || BASICLAUNCHER catch (Exception ex) { Util.LogExceptions(ex); -#else - catch (Exception) - { -#endif ipAddress = "localhost"; } diff --git a/Novetus/NovetusCore/StorageAndFunctions/Util.cs b/Novetus/NovetusCore/StorageAndFunctions/Util.cs index 08cccfc..4556020 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/Util.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/Util.cs @@ -587,18 +587,18 @@ namespace Novetus.Core } } -#if LAUNCHER || URI || BASICLAUNCHER public static void LogExceptions(Exception ex) { string message = (ex.Message != null ? ex.Message.ToString() : "N/A"); ConsolePrint(ex.Source + " Exception: " + message, 2, true); +#if LAUNCHER || URI || BASICLAUNCHER LogPrint("EXCEPTION|MESSAGE: " + message, 2); LogPrint("EXCEPTION|STACK TRACE: " + (!string.IsNullOrWhiteSpace(ex.StackTrace) ? ex.StackTrace : "N/A"), 2); LogPrint("EXCEPTION|ADDITIONAL INFO: " + (ex != null ? ex.ToString() : "N/A"), 2); - } #endif + } //https://stackoverflow.com/questions/27108264/how-to-properly-make-a-http-web-get-request diff --git a/Novetus/NovetusLauncher/Forms/NovetusConsole.cs b/Novetus/NovetusLauncher/Forms/NovetusConsole.cs index 25804dd..b08938b 100644 --- a/Novetus/NovetusLauncher/Forms/NovetusConsole.cs +++ b/Novetus/NovetusLauncher/Forms/NovetusConsole.cs @@ -494,7 +494,7 @@ namespace NovetusLauncher { ClearConsole(); Util.ConsolePrint("Help:", 3, true, false); - Util.ReadTextFileWithColor(GlobalPaths.BasePath + "\\" + GlobalPaths.ConsoleHelpFileName, false); + Util.ReadTextFileWithColor(GlobalPaths.MiscDir + "\\" + GlobalPaths.ConsoleHelpFileName, false); Util.ConsolePrint(GlobalVars.Important2, 0, true, false); ScrollToTop(); } @@ -503,7 +503,7 @@ namespace NovetusLauncher { ClearConsole(); Util.ConsolePrint("ClientScript Documentation:", 3, true); - Util.ReadTextFileWithColor(GlobalPaths.BasePath + "\\" + GlobalPaths.ClientScriptDocumentationFileName, false); + Util.ReadTextFileWithColor(GlobalPaths.MiscDir + "\\" + GlobalPaths.ClientScriptDocumentationFileName, false); ScrollToTop(); } diff --git a/Novetus/NovetusLauncher/Forms/SDK/ClientScriptDocumentation.cs b/Novetus/NovetusLauncher/Forms/SDK/ClientScriptDocumentation.cs index 76f4103..019ef4b 100644 --- a/Novetus/NovetusLauncher/Forms/SDK/ClientScriptDocumentation.cs +++ b/Novetus/NovetusLauncher/Forms/SDK/ClientScriptDocumentation.cs @@ -18,7 +18,7 @@ public partial class ClientScriptDocumentation : Form #region Form Events void ClientScriptDocumentationLoad(object sender, EventArgs e) { - richTextBox1.Text = File.ReadAllText(GlobalPaths.BasePath + "\\documentation.txt"); + richTextBox1.Text = File.ReadAllText(GlobalPaths.MiscDir + "\\" + GlobalPaths.ClientScriptDocumentationFileName); } #endregion }