Skip to content

Commit

Permalink
Rename markers
Browse files Browse the repository at this point in the history
  • Loading branch information
erri120 committed Jul 31, 2024
1 parent da41345 commit 4e56c06
Show file tree
Hide file tree
Showing 25 changed files with 36 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public static LoadoutFile.New ToLoadoutFile(
LoadoutItem = new LoadoutItem.New(tx, id)
{
LoadoutId = loadoutId,
IsIsDisabledMarker = false,
Name = input.Item.Value.FileName,
ParentId = parent,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public partial class LibraryArchive : IModelDefinition
/// <summary>
/// Marker.
/// </summary>
public static readonly MarkerAttribute IsLibraryArchiveMarker = new(Namespace, nameof(IsLibraryArchiveMarker));
public static readonly MarkerAttribute Archive = new(Namespace, nameof(Archive));

/// <summary>
/// Back-reference to all files inside the archive.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ protected LoadoutOverridesGroupId GetOrCreateOverridesGroup(ITransaction tx, Loa
OverridesForId = loadout,
LoadoutItemGroup = new LoadoutItemGroup.New(tx, id)
{
IsIsLoadoutItemGroupMarker = true,
IsGroup = true,
LoadoutItem = new LoadoutItem.New(tx, id)
{
Name = "Overrides",
Expand Down Expand Up @@ -225,7 +225,7 @@ public SyncTree BuildSyncTree(DiskStateTree currentState, DiskStateTree previous
/// </summary>
private static bool FileIsEnabled(LoadoutItem.ReadOnly arg)
{
return !arg.GetThisAndParents().Any(f => f.Contains(LoadoutItem.IsDisabledMarker));
return !arg.GetThisAndParents().Any(f => f.Contains(LoadoutItem.Disabled));
}

/// <inheritdoc />
Expand Down Expand Up @@ -381,7 +381,7 @@ private void WarnOfUnableToExtract(SyncActionGroupings<SyncTreeNode> groupings)
{
var delete = new DeletedFile.New(tx, out var id)
{
IsIsDeletedFileMarker = true,
Reason = "Reified delete",
LoadoutItemWithTargetPath = new LoadoutItemWithTargetPath.New(tx, id)
{
TargetPath = item.Path,
Expand Down Expand Up @@ -800,7 +800,7 @@ private LoadoutGameFilesGroup.New CreateLoadoutGameFilesGroup(LoadoutId loadout,
GameMetadataId = installation.GameMetadataId,
LoadoutItemGroup = new LoadoutItemGroup.New(tx, id)
{
IsIsLoadoutItemGroupMarker = true,
IsGroup = true,
LoadoutItem = new LoadoutItem.New(tx, id)
{
Name = "Game Files",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class DeletedFile : IModelDefinition
private const string Namespace = "NexusMods.Loadouts.DeletedFile";

/// <summary>
/// Marker.
/// Reason.
/// </summary>
public static readonly MarkerAttribute IsDeletedFileMarker = new(Namespace, nameof(IsDeletedFileMarker));
public static readonly StringAttribute Reason = new(Namespace, nameof(Reason));
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ public static class LoadoutExtensions
{
public static IEnumerable<LoadoutItemGroup.ReadOnly> GetEnabledGroups(this Loadout.ReadOnly loadout)
{
return loadout.Items.OfTypeLoadoutItemGroup().Where(group => !group.AsLoadoutItem().IsIsDisabledMarker);
return loadout.Items.OfTypeLoadoutItemGroup().Where(group => !group.AsLoadoutItem().IsDisabled);
}



private static IEnumerable<Mod.ReadOnly> GetEnabledMods(this Loadout.ReadOnly loadout, bool onlyEnabledMods)
{
var enumerable = onlyEnabledMods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ public static class LoadoutItemExtensions
/// </summary>
public static bool IsEnabled(this LoadoutItem.ReadOnly item)
{
return !item.GetThisAndParents().Any(i => i.IsIsDisabledMarker);
return !item.GetThisAndParents().Any(i => i.IsDisabled);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public partial class LoadoutItem : IModelDefinition
/// <remarks>
/// The exact meaning of a "disabled" loadout item is up to the implementations.
/// </remarks>
public static readonly MarkerAttribute IsDisabledMarker = new(Namespace, nameof(IsDisabledMarker));
public static readonly MarkerAttribute Disabled = new(Namespace, nameof(Disabled));

/// <summary>
/// Loadout that contains the item.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public partial class LoadoutItemGroup : IModelDefinition
/// <summary>
/// Marker.
/// </summary>
public static readonly MarkerAttribute IsLoadoutItemGroupMarker = new(Namespace, nameof(IsLoadoutItemGroupMarker));
public static readonly MarkerAttribute Group = new(Namespace, nameof(Group));

/// <summary>
/// Children of the group.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,14 @@ public override async ValueTask<InstallerResult> ExecuteAsync(
var loadoutItem = new LoadoutItem.New(tx)
{
LoadoutId = loadout.Id,
IsIsDisabledMarker = false,
Name = infoJson.Name,
ParentId = loadoutGroup.Id,
};

var groupItem = new LoadoutItemGroup.New(tx, loadoutItem.Id)
{
LoadoutItem = loadoutItem,
IsIsLoadoutItemGroupMarker = true,
IsGroup = true,
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ public override ValueTask<InstallerResult> ExecuteAsync(
Name = relativePath.Name,
LoadoutId = loadout.Id,
ParentId = loadoutGroup.Id,
IsIsDisabledMarker = false,
},
},
Hash = file.Item.LibraryFile.Value.Hash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private static IEnumerable<Diagnostic> DiagnoseDisabledDependencies(
.Where(kv =>
{
var (loadoutItemId, _) = kv;
return !SMAPIModLoadoutItem.Load(loadout.Db, loadoutItemId).AsLoadoutItemGroup().AsLoadoutItem().IsIsDisabledMarker;
return !SMAPIModLoadoutItem.Load(loadout.Db, loadoutItemId).AsLoadoutItemGroup().AsLoadoutItem().IsDisabled;
})
.Select(kv =>
{
Expand All @@ -87,7 +87,7 @@ private static IEnumerable<Diagnostic> DiagnoseDisabledDependencies(
var disabledDependencies = requiredDependencies
.Select(uniqueIdToLoadoutItemId.GetValueOrDefault)
.Where(id => id != default(SMAPIModLoadoutItemId))
.Where(id => !SMAPIModLoadoutItem.Load(loadout.Db, id).AsLoadoutItemGroup().AsLoadoutItem().IsIsDisabledMarker)
.Where(id => !SMAPIModLoadoutItem.Load(loadout.Db, id).AsLoadoutItemGroup().AsLoadoutItem().IsDisabled)
.ToArray();
return (Id: loadoutItemId, DisabledDependencies: disabledDependencies);
Expand Down Expand Up @@ -118,7 +118,7 @@ private async Task<IEnumerable<Diagnostic>> DiagnoseMissingDependencies(
.Where(kv =>
{
var (loadoutItemId, _) = kv;
return !SMAPIModLoadoutItem.Load(loadout.Db, loadoutItemId).AsLoadoutItemGroup().AsLoadoutItem().IsIsDisabledMarker;
return !SMAPIModLoadoutItem.Load(loadout.Db, loadoutItemId).AsLoadoutItemGroup().AsLoadoutItem().IsDisabled;
})
.Select(kv =>
{
Expand Down
4 changes: 2 additions & 2 deletions src/Games/NexusMods.Games.StardewValley/Emitters/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static bool TryGetSMAPI(Loadout.ReadOnly loadout, out SMAPILoadoutItem.Re
var foundSMAPI = loadout.Items
.OfTypeLoadoutItemGroup()
.OfTypeSMAPILoadoutItem()
.TryGetFirst(x => !x.AsLoadoutItemGroup().AsLoadoutItem().IsIsDisabledMarker, out smapi);
.TryGetFirst(x => !x.AsLoadoutItemGroup().AsLoadoutItem().IsDisabled, out smapi);

return foundSMAPI;
}
Expand All @@ -36,7 +36,7 @@ public static bool TryGetSMAPI(Loadout.ReadOnly loadout, out SMAPILoadoutItem.Re
var asyncEnumerable = loadout.Items
.OfTypeLoadoutItemGroup()
.OfTypeSMAPIModLoadoutItem()
.Where(x => !onlyEnabledMods || !x.AsLoadoutItemGroup().AsLoadoutItem().IsIsDisabledMarker)
.Where(x => !onlyEnabledMods || !x.AsLoadoutItemGroup().AsLoadoutItem().IsDisabled)
.ToAsyncEnumerable()
.ConfigureAwait(continueOnCapturedContext: false)
.WithCancellation(cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public async IAsyncEnumerable<Diagnostic> Diagnose(
yield break;
}

var isSMAPIEnabled = smapiLoadoutItems.Any(x => !x.AsLoadoutItemGroup().AsLoadoutItem().IsIsDisabledMarker);
var isSMAPIEnabled = smapiLoadoutItems.Any(x => !x.AsLoadoutItemGroup().AsLoadoutItem().IsDisabled);
if (isSMAPIEnabled) yield break;

yield return Diagnostics.CreateSMAPIRequiredButDisabled(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public override async ValueTask<InstallerResult> ExecuteAsync(
{
_ = new SMAPIModDatabaseLoadoutFile.New(transaction, entityId)
{
IsIsModDatabaseFileMarker = true,
IsModDatabaseFile = true,
LoadoutFile = loadoutFile,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public override async ValueTask<InstallerResult> ExecuteAsync(

var smapiModGroup = new LoadoutItemGroup.New(transaction, out var smapiModEntityId)
{
IsIsLoadoutItemGroupMarker = true,
IsGroup = true,
LoadoutItem = new LoadoutItem.New(transaction, smapiModEntityId)
{
Name = manifest.Name,
Expand Down Expand Up @@ -153,7 +153,7 @@ public override async ValueTask<InstallerResult> ExecuteAsync(
manifestLoadoutItemId = entityId;
_ = new SMAPIManifestLoadoutFile.New(transaction, entityId)
{
IsIsManifestMarker = true,
IsManifestFile = true,
LoadoutFile = loadoutFile,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ public partial class SMAPIManifestLoadoutFile : IModelDefinition
{
private const string Namespace = "NexusMods.StardewValley.SMAPIManifestLoadoutFile";

public static readonly MarkerAttribute IsManifestMarker = new(Namespace, nameof(IsManifestMarker));
public static readonly MarkerAttribute ManifestFile = new(Namespace, nameof(ManifestFile));
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ public partial class SMAPIModDatabaseLoadoutFile : IModelDefinition
{
private const string Namespace = "NexusMods.StardewValley.SMAPIModDatabaseLoadoutFile";

public static readonly MarkerAttribute IsModDatabaseFileMarker = new(Namespace, nameof(IsModDatabaseFileMarker));
public static readonly MarkerAttribute ModDatabaseFile = new(Namespace, nameof(ModDatabaseFile));
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private static bool TryGetSMAPIMod(RelativePath modDirectoryName, Loadout.ReadOn
var manifestFilePath = new GamePath(LocationId.Game, Constants.ModsFolder.Join(modDirectoryName).Join(Constants.ManifestFile));

if (!LoadoutItemWithTargetPath.FindByTargetPath(db, manifestFilePath)
.TryGetFirst(x => x.AsLoadoutItem().LoadoutId == loadout && x.Contains(SMAPIManifestLoadoutFile.IsManifestMarker), out var file))
.TryGetFirst(x => x.AsLoadoutItem().LoadoutId == loadout && x.Contains(SMAPIManifestLoadoutFile.ManifestFile), out var file))
{
mod = default(SMAPIModLoadoutItem.ReadOnly);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ModEnabledViewModel(IConnection conn)
this.WhenAnyValue(vm => vm.Row)
.Select(groupId => LoadoutItemGroup.Observe(_connection, groupId))
.Switch()
.Select(group => !group.AsLoadoutItem().IsIsDisabledMarker)
.Select(group => !group.AsLoadoutItem().IsDisabled)
.BindToVM(this, vm => vm.Enabled)
.DisposeWith(d);
});
Expand All @@ -42,13 +42,13 @@ public ModEnabledViewModel(IConnection conn)
tx.Add(Row.Value, static (txInner, db, id) =>
{
var item = LoadoutItem.Load(db, id);
if (item.IsIsDisabledMarker)
if (item.IsDisabled)
{
txInner.Retract(item.Id, LoadoutItem.IsDisabledMarker, Null.Instance);
txInner.Retract(item.Id, LoadoutItem.Disabled, Null.Instance);
}
else
{
txInner.Add(item.Id, LoadoutItem.IsDisabledMarker, Null.Instance);
txInner.Add(item.Id, LoadoutItem.Disabled, Null.Instance);
}
});
Expand All @@ -62,6 +62,6 @@ public int Compare(LoadoutItemGroupId a, LoadoutItemGroupId b)
var db = _connection.Db;
var aEnt = LoadoutItemGroup.Load(db, a);
var bEnt = LoadoutItemGroup.Load(db, b);
return aEnt.AsLoadoutItem().IsIsDisabledMarker.CompareTo(bEnt.AsLoadoutItem().IsIsDisabledMarker);
return aEnt.AsLoadoutItem().IsDisabled.CompareTo(bEnt.AsLoadoutItem().IsDisabled);
}
}
2 changes: 1 addition & 1 deletion src/NexusMods.Library/AddLibraryFileJobWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protected override async Task<JobResult> ExecuteAsync(AddLibraryFileJob job, Can
job.LibraryArchive = new LibraryArchive.New(job.Transaction, job.EntityId.Value)
{
LibraryFile = job.LibraryFile.Value,
IsIsLibraryArchiveMarker = true,
IsArchive = true,
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/NexusMods.Library/InstallLoadoutItemJobWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected override async Task<JobResult> ExecuteAsync(InstallLoadoutItemJob job,
var transaction = job.Connection.BeginTransaction();
var loadoutGroup = new LoadoutItemGroup.New(transaction, out var groupId)
{
IsIsLoadoutItemGroupMarker = true,
IsGroup = true,
LoadoutItem = new LoadoutItem.New(transaction, groupId)
{
Name = job.LibraryItem.Name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public async Task PathBasedDiagnosticEmittersLookAtTheCorrectPaths(Type diagnost
{
var dependencyMod = LoadoutItemGroup.Load(Connection.Db, loadout.Items.First(m => m.Name == "DependencyMod").Id);
using var tx = Connection.BeginTransaction();
tx.Add(dependencyMod, LoadoutItem.IsDisabledMarker, Null.Instance);
tx.Add(dependencyMod, LoadoutItem.Disabled, Null.Instance);
await tx.Commit();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task FilesInModFoldersAreMovedIntoMods()
{
LoadoutItemGroup = new LoadoutItemGroup.New(tx, modId)
{
IsIsLoadoutItemGroupMarker = true,
IsGroup = true,
LoadoutItem = new LoadoutItem.New(tx, modId)
{
LoadoutId = loadout,
Expand All @@ -39,7 +39,7 @@ public async Task FilesInModFoldersAreMovedIntoMods()
},
ManifestId = new SMAPIManifestLoadoutFile.New(tx, out var fileId)
{
IsIsManifestMarker = true,
IsManifestFile = true,
LoadoutFile = new LoadoutFile.New(tx, fileId)
{
Hash = manifestHash,
Expand Down
2 changes: 1 addition & 1 deletion tests/Games/NexusMods.Games.TestFramework/AGameTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected LoadoutItemGroupId AddEmptyGroup(ITransaction tx, LoadoutId loadoutId,
{
var mod = new LoadoutItemGroup.New(tx, out var id)
{
IsIsLoadoutItemGroupMarker = true,
IsGroup = true,
LoadoutItem = new LoadoutItem.New(tx, id)
{
LoadoutId = loadoutId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected ALibraryArchiveInstallerTests(IServiceProvider serviceProvider) : base

var loadoutGroup = new LoadoutItemGroup.New(tx, out var groupId)
{
IsIsLoadoutItemGroupMarker = true,
IsGroup = true,
LoadoutItem = new LoadoutItem.New(tx, groupId)
{
Name = libraryItem.Name,
Expand Down

0 comments on commit 4e56c06

Please sign in to comment.