-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #210 from anno-mods/devel/load_order_sort
Load Order Display
- Loading branch information
Showing
18 changed files
with
328 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
ModManager_Classes/Models/Attributes/ConcreteAttributes/GenericModContextAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Imya.Utils; | ||
|
||
namespace Imya.Models.Attributes | ||
{ | ||
public class GenericModContextAttribute : IAttribute | ||
{ | ||
public AttributeType AttributeType { get; init; } | ||
public IText Description { get; init; } | ||
public IEnumerable<Mod> Context { get; init; } | ||
|
||
bool IAttribute.MultipleAllowed => true; | ||
|
||
public GenericModContextAttribute() | ||
{ | ||
Context = Enumerable.Empty<Mod>(); | ||
} | ||
} | ||
} |
24 changes: 0 additions & 24 deletions
24
ModManager_Classes/Models/Attributes/ConcreteAttributes/ModCompabilityIssueAttribute.cs
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
ModManager_Classes/Models/Attributes/CyclicDependencyAttributeFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Imya.Utils; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Imya.Models.Attributes | ||
{ | ||
public class CyclicDependencyAttributeFactory | ||
{ | ||
public static IAttribute Get(IEnumerable<Mod> context) | ||
{ | ||
return new GenericModContextAttribute() | ||
{ | ||
AttributeType = AttributeType.CyclicDependency, | ||
Description = new SimpleText( | ||
String.Format(TextManager.Instance.GetText("ATTRIBUTE_CYCLIC_DEPENDENCY").Text, | ||
String.Join(',', context.Select(x => $"[{x.Category}] {x.Name}")))), | ||
Context = context | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
ModManager_Classes/Models/Attributes/ModCompabilityAttributeFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Imya.Utils; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Imya.Models.Attributes | ||
{ | ||
public class ModCompabilityAttributeFactory | ||
{ | ||
public static IAttribute Get(IEnumerable<Mod> context) | ||
{ | ||
return new GenericModContextAttribute() | ||
{ | ||
AttributeType = AttributeType.ModCompabilityIssue, | ||
Description = new SimpleText( | ||
String.Format(TextManager.Instance.GetText("ATTRIBUTE_COMPABILITYERROR").Text, | ||
String.Join(',', context.Select(x => $"[{x.Category}] {x.Name}")))), | ||
Context = context | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
ModManager_Classes/Validation/CyclicDependencyValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Imya.Models; | ||
using Imya.Models.Attributes; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.CompilerServices; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Imya.Validation | ||
{ | ||
internal class CyclicDependencyValidator : IModValidator | ||
{ | ||
public void Validate(IEnumerable<Mod> changed, IReadOnlyCollection<Mod> all) | ||
{ | ||
foreach (Mod x in all) | ||
x.Attributes.RemoveAttributesByType(AttributeType.CyclicDependency); | ||
foreach (Mod x in changed) | ||
{ | ||
var cyclics = CyclicDependencies(x, all); | ||
if (cyclics.Count() > 0) | ||
{ | ||
x.Attributes.Add(CyclicDependencyAttributeFactory.Get(cyclics)); | ||
} | ||
} | ||
} | ||
|
||
private IEnumerable<Mod> CyclicDependencies(Mod x, IReadOnlyCollection<Mod> others) | ||
{ | ||
if (!x.IsActive) | ||
return Enumerable.Empty<Mod>(); | ||
|
||
return others.Where(y => | ||
y.IsActive && (y.Modinfo?.LoadAfterIds?.Contains(x.ModID) ?? false) | ||
&& (x.Modinfo?.LoadAfterIds?.Contains(y.ModID) ?? false)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.