Collections are packages of their own
A collection is no longer a file inside a mod: it is a package (folder or zip) named after its id with collection.json, cover and optional locale/, shipped in collections/ next to the mods or kept by the player in user://collections/. Covers and texts come from the package; mods do not ship collections.
This commit is contained in:
1 parent
0d1f73f19e
commit
2cc409f12a
3 files changed
+20
-7
No files matched your search
@@ -26,12 +26,17 @@ namespace Cthangover.LocaleAtlas
|
||||
/// <item>manifest — <c>mod_<id>_name</c>/<c>_desc</c> used by the mod manager
|
||||
/// (optional: the manifest text is the fallback).</item>
|
||||
/// </list>
|
||||
/// Collection files (<c>collections/*.json</c>) are also checked for inline
|
||||
/// <c>locale</c> entries: a literal <c>name</c>/<c>description</c> is the
|
||||
/// <c>en</c> text, every other project language needs a <c>locale</c> entry.
|
||||
/// Collection packages come as sources named <see cref="CollectionSourcePrefix"/>
|
||||
/// + id: their <c>locale/</c> files are declarations like a mod's, and their
|
||||
/// <c>collection.json</c> is checked for inline <c>locale</c> entries — a
|
||||
/// literal <c>name</c>/<c>description</c> is the <c>en</c> text, every other
|
||||
/// project language needs a <c>locale</c> entry.
|
||||
/// </summary>
|
||||
public static class LocaleAtlasBuilder
|
||||
{
|
||||
/// <summary>Source id prefix of a collection package (<c>collection:<id></c>), as opposed to a mod.</summary>
|
||||
public const string CollectionSourcePrefix = "collection:";
|
||||
|
||||
/// <summary>Language of literal collection texts (fallback in <c>ModCollection.GetLocalizedName</c>).</summary>
|
||||
public const string CollectionBaseLanguage = "en";
|
||||
|
||||
@@ -66,6 +71,8 @@ namespace Cthangover.LocaleAtlas
|
||||
result.Mods.Add(modId);
|
||||
ScanLocaleFiles(modId, provider, result);
|
||||
ScanReferences(modId, provider, result, collections, documents);
|
||||
if (modId.StartsWith(CollectionSourcePrefix, StringComparison.Ordinal))
|
||||
continue;
|
||||
result.References.Add(new LocaleReference { Key = $"mod_{modId}_name", ModId = modId, File = "manifest.json", Via = "manifest", Optional = true });
|
||||
result.References.Add(new LocaleReference { Key = $"mod_{modId}_desc", ModId = modId, File = "manifest.json", Via = "manifest", Optional = true });
|
||||
}
|
||||
@@ -229,7 +236,7 @@ namespace Cthangover.LocaleAtlas
|
||||
AddMatches(SceneText, text, file, modId, "scene", result);
|
||||
break;
|
||||
case ".json":
|
||||
var isCollection = file.StartsWith("collections/", StringComparison.Ordinal);
|
||||
var isCollection = file == "collection.json" && modId.StartsWith(CollectionSourcePrefix, StringComparison.Ordinal);
|
||||
if (!isCollection)
|
||||
AddMatches(JsonTextField, text, file, modId, "json", result);
|
||||
AddMatches(JsonAtKey, text, file, modId, isCollection ? "collection" : "json", result);
|
||||
|
||||
@@ -91,6 +91,12 @@ namespace Cthangover.LocaleAtlas
|
||||
result.Add((info.Id, info.FileProvider));
|
||||
}
|
||||
|
||||
foreach (var collection in ModCollectionStore.LoadAll())
|
||||
{
|
||||
if (collection.Package != null)
|
||||
result.Add((LocaleAtlasBuilder.CollectionSourcePrefix + collection.Id, collection.Package));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user