diff --git a/NewHorizons/Builder/Props/DialogueBuilder.cs b/NewHorizons/Builder/Props/DialogueBuilder.cs index 39712108..b20a57d5 100644 --- a/NewHorizons/Builder/Props/DialogueBuilder.cs +++ b/NewHorizons/Builder/Props/DialogueBuilder.cs @@ -87,7 +87,7 @@ namespace NewHorizons.Builder.Props var dialogueTree = conversationZone.AddComponent(); - var xml = File.ReadAllText(mod.Manifest.ModFolderPath + info.xmlFile); + var xml = File.ReadAllText(Path.Combine(mod.Manifest.ModFolderPath, info.xmlFile)); var text = new TextAsset(xml); // Text assets need a name to be used with VoiceMod diff --git a/NewHorizons/Builder/Props/NomaiTextBuilder.cs b/NewHorizons/Builder/Props/NomaiTextBuilder.cs index f0e093d2..981f447d 100644 --- a/NewHorizons/Builder/Props/NomaiTextBuilder.cs +++ b/NewHorizons/Builder/Props/NomaiTextBuilder.cs @@ -2,12 +2,12 @@ using NewHorizons.External.Modules; using NewHorizons.Handlers; using NewHorizons.Utility; using OWML.Common; -using Enum = System.Enum; using System.Collections.Generic; using System.IO; using System.Linq; using System.Xml; using UnityEngine; +using Enum = System.Enum; using Logger = NewHorizons.Utility.Logger; using Random = UnityEngine.Random; namespace NewHorizons.Builder.Props @@ -108,7 +108,7 @@ namespace NewHorizons.Builder.Props { if (_scrollPrefab == null) InitPrefabs(); - var xmlPath = File.ReadAllText(mod.ModHelper.Manifest.ModFolderPath + info.xmlFile); + var xmlPath = File.ReadAllText(Path.Combine(mod.ModHelper.Manifest.ModFolderPath, info.xmlFile)); switch (info.type) { diff --git a/NewHorizons/Builder/Props/ProjectionBuilder.cs b/NewHorizons/Builder/Props/ProjectionBuilder.cs index e80d451d..32876489 100644 --- a/NewHorizons/Builder/Props/ProjectionBuilder.cs +++ b/NewHorizons/Builder/Props/ProjectionBuilder.cs @@ -4,6 +4,7 @@ using NewHorizons.Utility; using OWML.Common; using System; using System.Collections.Generic; +using System.IO; using System.Threading; using UnityEngine; using static NewHorizons.External.Modules.PropModule; @@ -346,8 +347,7 @@ namespace NewHorizons.Builder.Props } else { - // Don't use Path.Combine here else you break the Vision - imageLoader.PathsToLoad.Add((i, mod.ModHelper.Manifest.ModFolderPath + slideInfo.imagePath)); + imageLoader.PathsToLoad.Add((i, Path.Combine(mod.ModHelper.Manifest.ModFolderPath, slideInfo.imagePath))); } AddModules(slideInfo, ref slide, mod); diff --git a/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs b/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs index a5c18d78..9e82ae8b 100644 --- a/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs +++ b/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs @@ -4,6 +4,7 @@ using NewHorizons.Handlers; using NewHorizons.Utility; using System; using System.Collections.Generic; +using System.IO; using System.Xml.Linq; using UnityEngine; using Logger = NewHorizons.Utility.Logger; @@ -53,7 +54,7 @@ namespace NewHorizons.Builder.ShipLog public static void AddBodyToShipLog(ShipLogManager manager, NewHorizonsBody body) { string systemName = body.Config.starSystem; - XElement astroBodyFile = XElement.Load(body.Mod.ModHelper.Manifest.ModFolderPath + "/" + body.Config.ShipLog.xmlFile); + XElement astroBodyFile = XElement.Load(Path.Combine(body.Mod.ModHelper.Manifest.ModFolderPath, body.Config.ShipLog.xmlFile)); XElement astroBodyId = astroBodyFile.Element("ID"); if (astroBodyId == null) { diff --git a/NewHorizons/Handlers/AudioTypeHandler.cs b/NewHorizons/Handlers/AudioTypeHandler.cs index 698514c8..70878ae3 100644 --- a/NewHorizons/Handlers/AudioTypeHandler.cs +++ b/NewHorizons/Handlers/AudioTypeHandler.cs @@ -2,6 +2,7 @@ using NewHorizons.Utility; using OWML.Common; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using UnityEngine; using Logger = NewHorizons.Utility.Logger; @@ -65,7 +66,7 @@ namespace NewHorizons.Handlers var id = mod.ModHelper.Manifest.UniqueName + "_" + audioPath; if (_customAudioTypes.TryGetValue(id, out audioType)) return audioType; - var audioClip = AudioUtilities.LoadAudio(mod.ModHelper.Manifest.ModFolderPath + "/" + audioPath); + var audioClip = AudioUtilities.LoadAudio(Path.Combine(mod.ModHelper.Manifest.ModFolderPath, audioPath)); if (audioClip == null) { diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index ef13942d..96e670d7 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -167,7 +167,7 @@ namespace NewHorizons TextTranslation.Get().SetLanguage(TextTranslation.Get().GetLanguage()); } - LoadTranslations(Instance.ModHelper.Manifest.ModFolderPath + "Assets/", this); + LoadTranslations(Path.Combine(Instance.ModHelper.Manifest.ModFolderPath, "Assets/"), this); } public void Awake() diff --git a/NewHorizons/NewHorizonsApi.cs b/NewHorizons/NewHorizonsApi.cs index 4924834f..a4da089f 100644 --- a/NewHorizons/NewHorizonsApi.cs +++ b/NewHorizons/NewHorizonsApi.cs @@ -36,10 +36,10 @@ namespace NewHorizons if (name == null) return; var relativePath = $"temp/{name}.json"; - var fullPath = Main.Instance.ModHelper.Manifest.ModFolderPath + relativePath; - if (!Directory.Exists(Main.Instance.ModHelper.Manifest.ModFolderPath + "temp")) + var fullPath = Path.Combine(Main.Instance.ModHelper.Manifest.ModFolderPath, relativePath); + if (!Directory.Exists(Path.Combine(Main.Instance.ModHelper.Manifest.ModFolderPath, "temp"))) { - Directory.CreateDirectory(Main.Instance.ModHelper.Manifest.ModFolderPath + "temp"); + Directory.CreateDirectory(Path.Combine(Main.Instance.ModHelper.Manifest.ModFolderPath, "temp")); } JsonHelper.SaveJsonObject(fullPath, config); var body = Main.Instance.LoadConfig(Main.Instance, relativePath); @@ -126,7 +126,7 @@ namespace NewHorizons var planet = Main.BodyDict[Main.Instance.CurrentStarSystem].Find((b) => b.Config.name == bodyName); return planet == null ? null - : QueryJson(outType, planet.Mod.ModHelper.Manifest.ModFolderPath + planet.RelativePath, jsonPath); + : QueryJson(outType, Path.Combine(planet.Mod.ModHelper.Manifest.ModFolderPath, planet.RelativePath), jsonPath); } public object QuerySystem(Type outType, string jsonPath) @@ -134,7 +134,7 @@ namespace NewHorizons var system = Main.SystemDict[Main.Instance.CurrentStarSystem]; return system == null ? null - : QueryJson(outType, system.Mod.ModHelper.Manifest.ModFolderPath + system.RelativePath, jsonPath); + : QueryJson(outType, Path.Combine(system.Mod.ModHelper.Manifest.ModFolderPath, system.RelativePath), jsonPath); } public GameObject SpawnObject(GameObject planet, Sector sector, string propToCopyPath, Vector3 position, Vector3 eulerAngles, diff --git a/NewHorizons/OtherMods/VoiceActing/VoiceHandler.cs b/NewHorizons/OtherMods/VoiceActing/VoiceHandler.cs index 65f66b79..ed7142de 100644 --- a/NewHorizons/OtherMods/VoiceActing/VoiceHandler.cs +++ b/NewHorizons/OtherMods/VoiceActing/VoiceHandler.cs @@ -38,10 +38,10 @@ namespace NewHorizons.OtherMods.VoiceActing { foreach (var mod in Main.Instance.GetDependants().Append(Main.Instance)) { - var folder = $"{mod.ModHelper.Manifest.ModFolderPath}voicemod"; + var folder = Path.Combine(mod.ModHelper.Manifest.ModFolderPath, "voicemod"); if (!Directory.Exists(folder)) { // Fallback to PascalCase bc it used to be like that - folder = $"{mod.ModHelper.Manifest.ModFolderPath}VoiceMod"; + folder = Path.Combine(mod.ModHelper.Manifest.ModFolderPath, "VoiceMod"); } if (Directory.Exists(folder)) { diff --git a/NewHorizons/Utility/AssetBundleUtilities.cs b/NewHorizons/Utility/AssetBundleUtilities.cs index 29841acd..263e08bb 100644 --- a/NewHorizons/Utility/AssetBundleUtilities.cs +++ b/NewHorizons/Utility/AssetBundleUtilities.cs @@ -1,4 +1,4 @@ -using OWML.Common; +using OWML.Common; using System; using System.Collections.Generic; using System.IO; @@ -34,7 +34,7 @@ namespace NewHorizons.Utility } else { - var completePath = mod.ModHelper.Manifest.ModFolderPath + assetBundleRelativeDir; + var completePath = Path.Combine(mod.ModHelper.Manifest.ModFolderPath, assetBundleRelativeDir); bundle = AssetBundle.LoadFromFile(completePath); if (bundle == null) { diff --git a/NewHorizons/Utility/AudioUtilities.cs b/NewHorizons/Utility/AudioUtilities.cs index d78e5b53..4a6801b7 100644 --- a/NewHorizons/Utility/AudioUtilities.cs +++ b/NewHorizons/Utility/AudioUtilities.cs @@ -1,6 +1,7 @@ using OWML.Common; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Threading.Tasks; using UnityEngine; @@ -19,7 +20,7 @@ namespace NewHorizons.Utility { try { - var clip = LoadAudio(mod.ModHelper.Manifest.ModFolderPath + "/" + audio); + var clip = LoadAudio(Path.Combine(mod.ModHelper.Manifest.ModFolderPath, audio)); source._audioLibraryClip = AudioType.None; source._clipArrayIndex = 0; source._clipArrayLength = 0; diff --git a/NewHorizons/Utility/DebugMenu/DebugMenu.cs b/NewHorizons/Utility/DebugMenu/DebugMenu.cs index be19c867..ca54f738 100644 --- a/NewHorizons/Utility/DebugMenu/DebugMenu.cs +++ b/NewHorizons/Utility/DebugMenu/DebugMenu.cs @@ -210,7 +210,7 @@ namespace NewHorizons.Utility.DebugMenu continue; } - loadedConfigFiles[folder + body.RelativePath] = body.Config; + loadedConfigFiles[Path.Combine(folder, body.RelativePath)] = body.Config; submenus.ForEach(submenu => submenu.LoadConfigFile(this, body.Config)); } } @@ -235,9 +235,9 @@ namespace NewHorizons.Utility.DebugMenu try { - var path = loadedMod.ModHelper.Manifest.ModFolderPath + backupFolderName + relativePath; + var path = Path.Combine(loadedMod.ModHelper.Manifest.ModFolderPath, backupFolderName, relativePath); Logger.LogVerbose($"Backing up... {relativePath} to {path}"); - var oldPath = loadedMod.ModHelper.Manifest.ModFolderPath + relativePath; + var oldPath = Path.Combine(loadedMod.ModHelper.Manifest.ModFolderPath, relativePath); var directoryName = Path.GetDirectoryName(path); Directory.CreateDirectory(directoryName); @@ -254,7 +254,7 @@ namespace NewHorizons.Utility.DebugMenu try { Logger.Log($"Saving... {relativePath} to {filePath}"); - var path = loadedMod.ModHelper.Manifest.ModFolderPath + relativePath; + var path = Path.Combine(loadedMod.ModHelper.Manifest.ModFolderPath, relativePath); var directoryName = Path.GetDirectoryName(path); Directory.CreateDirectory(directoryName); diff --git a/NewHorizons/Utility/ImageUtilities.cs b/NewHorizons/Utility/ImageUtilities.cs index cf884938..db33fd99 100644 --- a/NewHorizons/Utility/ImageUtilities.cs +++ b/NewHorizons/Utility/ImageUtilities.cs @@ -17,14 +17,14 @@ namespace NewHorizons.Utility public static bool IsTextureLoaded(IModBehaviour mod, string filename) { - var path = mod.ModHelper.Manifest.ModFolderPath + filename; + var path = Path.Combine(mod.ModHelper.Manifest.ModFolderPath, filename); return _loadedTextures.ContainsKey(path); } public static Texture2D GetTexture(IModBehaviour mod, string filename, bool useMipmaps = true, bool wrap = false) { // Copied from OWML but without the print statement lol - var path = mod.ModHelper.Manifest.ModFolderPath + filename; + var path = Path.Combine(mod.ModHelper.Manifest.ModFolderPath, filename); if (_loadedTextures.ContainsKey(path)) { Logger.LogVerbose($"Already loaded image at path: {path}"); @@ -53,7 +53,7 @@ namespace NewHorizons.Utility public static void DeleteTexture(IModBehaviour mod, string filename, Texture2D texture) { - var path = mod.ModHelper.Manifest.ModFolderPath + filename; + var path = Path.Combine(mod.ModHelper.Manifest.ModFolderPath, filename); if (_loadedTextures.ContainsKey(path)) { if (_loadedTextures[path] == texture)