Skip to content

Commit

Permalink
include sub mod ids in dependency validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobharder committed Apr 30, 2023
1 parent bfc85b6 commit 4b2084a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
23 changes: 23 additions & 0 deletions ModManager_Classes/Models/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,25 @@ public Mod (string folderName, Modinfo? modinfo, string basePath)
// TODO move to separate async?
var info = new DirectoryInfo(FullModPath);
SizeInMB = (float)Math.Round((decimal)info.EnumerateFiles("*", SearchOption.AllDirectories).Sum(x => x.Length) / 1024 / 1024, 1);

string[] modinfos = Directory.GetFiles(Path.Combine(basePath, folderName), "modinfo.json", SearchOption.AllDirectories);
if (modinfos.Length > 1)
{
SubMods = new List<Mod>();
foreach (var submodinfo in modinfos)
{
if (submodinfo == Path.Combine(basePath, folderName, "modinfo.json"))
{
continue;
}

Mod? submod = TryFromFolder(Path.GetDirectoryName(submodinfo) ?? "");
if (submod is not null)
{
SubMods.Add(submod);
}
}
}
}

public void InitImageAsFilepath(String ImagePath)
Expand Down Expand Up @@ -310,6 +329,10 @@ public bool IsUpdateOf(Mod? target)
}
#endregion

#region Sub mods
public List<Mod>? SubMods { get; private set; }
#endregion

public ModStatus GetStatus()
{
return (Attributes.GetByType(AttributeType.ModStatus) as ModStatusAttribute)?.Status ?? ModStatus.Default;
Expand Down
4 changes: 3 additions & 1 deletion ModManager_Classes/Validation/ModCompatibilityValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ private static IEnumerable<string> GetUnresolvedDependencies(Modinfo modinfo, IR

foreach (var dep in modinfo.ModDependencies)
{
if (!collection.Any(x => x.Modinfo.ModID is not null && x.Modinfo.ModID.Equals(dep) && x.IsActiveAndValid))
if (!collection.Any(x => x.Modinfo.ModID is not null
&& (x.Modinfo.ModID.Equals(dep) || x.SubMods?.Find(submod => submod.ModID.Equals(dep)) is not null)
&& x.IsActiveAndValid))
yield return dep;
}
}
Expand Down

0 comments on commit 4b2084a

Please sign in to comment.