Skip to content

Commit

Permalink
Minor improvements to legacy support, disabled by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
nrgill28 committed Apr 9, 2021
1 parent e237286 commit 2eabef1
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
15 changes: 12 additions & 3 deletions WurstMod/Runtime/Entrypoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Entrypoint()

// Config values
loadDebugLevels = Config.Bind("Debug", "LoadDebugLevels", false, "True if you want the included default levels to be loaded");
useLegacyLoadingMethod = Config.Bind("Debug", "UseLegacyLoadingMethod", true, $"True if you want to support loading legacy v1 or standalone levels from the {Constants.LegacyLevelsDirectory} folder");
useLegacyLoadingMethod = Config.Bind("Debug", "UseLegacyLoadingMethod", false, $"True if you want to support loading legacy v1 or standalone levels from the {Constants.LegacyLevelsDirectory} folder");

// Legacy support
if (useLegacyLoadingMethod.Value)
Expand All @@ -50,13 +50,22 @@ private void StagesOnSetup(SetupStage stage)
private void LevelLoader(Stage stage, Mod mod, IHandle handle)
{
// If the config has disabled loading the default included levels, return
if (!loadDebugLevels.Value && mod.Info.Guid == "wurstmod")
if (!loadDebugLevels.Value && mod.Info.Guid == "wurstmodders.wurstmod")
return;

// If this is the legacy stuff and we have that disabled, return
if (!useLegacyLoadingMethod.Value && mod.Info.Guid == "wurstmodders.wurstmod.legacy")
return;

// Try to make a level info from it
var level = LevelInfo.FromFrameworkMod(mod, handle);

if (!level.HasValue) Debug.LogError($"Level in {mod}, {handle} is not valid!");
if (!level.HasValue)
{
// Skip an error here because this will throw some errors on folders we know are invalid.
if (mod.Info.Guid != "wurstmodders.wurstmod.legacy")
Debug.LogError($"Level in {mod}, {handle} is not valid!");
}
else
{
CustomLevelFinder.ArchiveLevels.Add(level.Value);
Expand Down
3 changes: 2 additions & 1 deletion WurstMod/Shared/LevelInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public AssetBundle AssetBundle
}

// If somehow neither of the above two options match it's an invalid thing.
mod.Logger.LogError($"Level at {path} does not contain a valid manifest!");
if (mod.Info.Guid != "wurstmodders.wurstmod.legacy")
mod.Logger.LogError($"Level at {path} does not contain a valid manifest!");
return null;
}

Expand Down
3 changes: 3 additions & 0 deletions WurstMod/WurstMod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@
<Compile Include="UnityEditor\SceneExporters\TakeAndHoldExporter.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="legacyManifest.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="manifest.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand Down
18 changes: 18 additions & 0 deletions WurstMod/legacyManifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "WurstMod Legacy",
"authors": [
"Nathan Gill"
],
"guid": "wurstmodders.wurstmod.legacy",
"version": "1.0.0",
"require": "0.3.1",
"dependencies": {
"wurstmodders.wurstmod": "2.0.3"
},
"assets": {
"setup": {
"**.dll": "deli:assembly",
"**/": "wurstmodders.wurstmod:level"
}
}
}

0 comments on commit 2eabef1

Please sign in to comment.