diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-03-29 23:58:06 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-09-14 17:02:11 -0400 |
commit | 34633cfed9efb8a53b148584c1b3909bac69372f (patch) | |
tree | c2633dcbc28934c8016766bd768dd1280e7e56ce /src/SMAPI.ModBuildConfig/Framework/ModFileManager.cs | |
parent | f78502a3a4a133b93cf9bf01eb426867e7798045 (diff) | |
download | SMAPI-34633cfed9efb8a53b148584c1b3909bac69372f.tar.gz SMAPI-34633cfed9efb8a53b148584c1b3909bac69372f.tar.bz2 SMAPI-34633cfed9efb8a53b148584c1b3909bac69372f.zip |
bundle assets folder into mods by default
Diffstat (limited to 'src/SMAPI.ModBuildConfig/Framework/ModFileManager.cs')
-rw-r--r-- | src/SMAPI.ModBuildConfig/Framework/ModFileManager.cs | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/SMAPI.ModBuildConfig/Framework/ModFileManager.cs b/src/SMAPI.ModBuildConfig/Framework/ModFileManager.cs index 4af3100f..6c11b0fe 100644 --- a/src/SMAPI.ModBuildConfig/Framework/ModFileManager.cs +++ b/src/SMAPI.ModBuildConfig/Framework/ModFileManager.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text.RegularExpressions; using StardewModdingAPI.Toolkit.Serialisation; using StardewModdingAPI.Toolkit.Serialisation.Models; +using StardewModdingAPI.Toolkit.Utilities; namespace StardewModdingAPI.ModBuildConfig.Framework { @@ -61,18 +62,33 @@ namespace StardewModdingAPI.ModBuildConfig.Framework hasProjectTranslations = true; } + // project assets folder + bool hasAssetsFolder = false; + DirectoryInfo assetsFolder = new DirectoryInfo(Path.Combine(projectDir, "assets")); + if (assetsFolder.Exists) + { + foreach (FileInfo file in assetsFolder.EnumerateFiles("*", SearchOption.AllDirectories)) + { + string relativePath = PathUtilities.GetRelativePath(projectDir, file.FullName); + this.Files[relativePath] = file; + } + hasAssetsFolder = true; + } + // build output DirectoryInfo buildFolder = new DirectoryInfo(targetDir); foreach (FileInfo file in buildFolder.EnumerateFiles("*", SearchOption.AllDirectories)) { - // get relative paths - string relativePath = file.FullName.Replace(buildFolder.FullName, ""); - string relativeDirPath = file.Directory.FullName.Replace(buildFolder.FullName, ""); + // get path info + string relativePath = PathUtilities.GetRelativePath(buildFolder.FullName, file.FullName); + string[] segments = PathUtilities.GetSegments(relativePath); - // prefer project manifest/i18n files + // prefer project manifest/i18n/assets files if (hasProjectManifest && this.EqualsInvariant(relativePath, this.ManifestFileName)) continue; - if (hasProjectTranslations && this.EqualsInvariant(relativeDirPath, "i18n")) + if (hasProjectTranslations && this.EqualsInvariant(segments[0], "i18n")) + continue; + if (hasAssetsFolder && this.EqualsInvariant(segments[0], "assets")) continue; // handle ignored files @@ -149,6 +165,8 @@ namespace StardewModdingAPI.ModBuildConfig.Framework /// <param name="other">The string to compare with.</param> private bool EqualsInvariant(string str, string other) { + if (str == null) + return other == null; return str.Equals(other, StringComparison.InvariantCultureIgnoreCase); } } |