Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into docs-070
Browse files Browse the repository at this point in the history
  • Loading branch information
Pickysaurus committed Nov 26, 2024
2 parents 297f7b4 + b079ec3 commit b05cd84
Show file tree
Hide file tree
Showing 32 changed files with 832 additions and 395 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.ComponentModel;
using NexusMods.Abstractions.Loadouts;

namespace NexusMods.Abstractions.Games;
Expand All @@ -17,10 +18,75 @@ public interface ISortableItemProviderFactory
/// <summary>
/// Returns id of the type of the loadout
/// </summary>
Guid StaticSortOrderTypeId { get; }
Guid SortOrderTypeId { get; }

/// <summary>
/// Display name for this sort order type
/// Display name for this sort order type
/// </summary>
string SortOrderName { get; }

/// <summary>
/// Short descriptive title for the load order, describing the override behavior of the sort order
/// </summary>
/// <example>
/// "Last Loaded plugin Wins"
/// </example>
/// <remarks>
/// Avoid using "higher" or "lower" terms, as the index numbers can be sorted both in ascending or descending order,
/// making their meaning ambiguous.
/// </remarks>
string OverrideInfoTitle { get; }

/// <summary>
/// Heading for more details load order override information
/// </summary>
/// <example>
/// "Load Order for REDmods in Cyberpunk 2077 - First Loaded Wins"
/// </example>
string OverrideInfoHeading { get; }

/// <summary>
/// Detailed description of the load order and its override behavior
/// </summary>
string OverrideInfoMessage { get; }

/// <summary>
/// Short tooltip message to explain the winning index number in the load order
/// </summary>
string WinnerIndexToolTip { get; }

/// <summary>
/// Header text for the index column
/// </summary>
string IndexColumnHeader { get; }

/// <summary>
/// Header text for the name column
/// </summary>
string NameColumnHeader { get; }

/// <summary>
/// Title text to display in case there are no sortable items to sort
/// </summary>
string EmptyStateMessageTitle { get; }

/// <summary>
/// Contents text to display in case there are no sortable items to sort
/// </summary>
string EmptyStateMessageContents { get; }

/// <summary>
/// Default direction (ascending/descending) in which sortIndexes should be sorted and displayed
/// </summary>
/// <remarks>
/// Usually ascending, but could be different depending on what the community prefers and is used to
/// </remarks>
ListSortDirection SortDirectionDefault { get; }

/// <summary>
/// Defines whether smaller or greater index numbers win in case of conflicts between items in sorting order
/// </summary>
IndexOverrideBehavior IndexOverrideBehavior { get; }
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace NexusMods.Abstractions.Games;

/// <summary>
/// Defines whether smaller or greater index numbers win in case of conflicts between items in sorting order
/// </summary>
public enum IndexOverrideBehavior
{
/// <summary>
/// Items with Smaller index numbers win in case of conflicts with greater index number items
/// </summary>
SmallerIndexWins,

/// <summary>
/// Items with Greater index numbers win in case of conflicts with smaller index number items
/// </summary>
GreaterIndexWins,
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ public partial class LocalFile : IModelDefinition
/// <summary>
/// The MD5 hash value of the file.
/// </summary>
public static readonly Md5Attribute Md5 = new(Namespace, nameof(Md5)) { IsOptional = true };
public static readonly Md5Attribute Md5 = new(Namespace, nameof(Md5)) { IsOptional = true, IsIndexed = true };
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,13 @@ public partial class LoadoutItem : IModelDefinition
/// Optional parent of the item.
/// </summary>
public static readonly ReferenceAttribute<LoadoutItemGroup> Parent = new(Namespace, nameof(Parent)) { IsIndexed = true, IsOptional = true };

[PublicAPI]
public partial struct ReadOnly
{
/// <summary>
/// True if this item contains a parent, else false.
/// </summary>
public bool HasParent() => this.Contains(LoadoutItem.Parent);
}
}
2 changes: 1 addition & 1 deletion src/Examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ and [Using Workspaces](https://nexus-mods.github.io/NexusMods.App/development-gu
- [TreeDataGrid](./TreeDataGrid/README.md)
- [Basic TreeDataGrid](./TreeDataGrid/Basic)
- [TreeDataGrid With Single Custom Column](./TreeDataGrid/SingleColumn)
- Further explained in [UI Coding Guidelines](../../docs/development-guidelines/UICodingGuidelines.md#trees-with-columns-treedatagrid).
- Further explained in [UI Coding Guidelines](../../docs/developers/development-guidelines/UICodingGuidelines.md#trees-with-columns-treedatagrid).
2 changes: 1 addition & 1 deletion src/Examples/TreeDataGrid/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# TreeDataGrid Examples

Feel free to use these as a template when adding new trees.
These are further described in [UI Coding Guidelines](../../../docs/development-guidelines/UICodingGuidelines.md#trees-with-columns-treedatagrid).
These are further described in [UI Coding Guidelines](../../../docs/developers/development-guidelines/UICodingGuidelines.md#trees-with-columns-treedatagrid).

- [Basic TreeDataGrid](./Basic)
- This is the most basic example of a TreeDataGrid.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using NexusMods.Abstractions.Diagnostics;
using NexusMods.Abstractions.Diagnostics.Emitters;
using NexusMods.Abstractions.Loadouts;
using NexusMods.Abstractions.Loadouts.Extensions;
using NexusMods.Abstractions.Resources;
using NexusMods.Games.MountAndBlade2Bannerlord.Models;
namespace NexusMods.Games.MountAndBlade2Bannerlord.Diagnostics;
Expand Down Expand Up @@ -36,7 +37,12 @@ public async IAsyncEnumerable<Diagnostic> Diagnose(Loadout.ReadOnly loadout, Can
foreach (var module in modulesAndMods)
{
var mod = module.Item1;
var isEnabled = !mod.AsLoadoutItemGroup().AsLoadoutItem().IsDisabled;
var loadoutItem = mod.AsLoadoutItemGroup().AsLoadoutItem();

// Note(sewer): We create a LoadoutItemGroup for each module, which is a child of the one
// used for the archive. Since in theory the item can be disabled at any level
// in the tree, we need to check if the parent is disabled.
var isEnabled = loadoutItem.IsEnabled();
isEnabledDict[module.Item2] = isEnabled;
}

Expand All @@ -50,6 +56,9 @@ public async IAsyncEnumerable<Diagnostic> Diagnose(Loadout.ReadOnly loadout, Can
foreach (var moduleAndMod in isEnabledDict)
{
var moduleInfo = moduleAndMod.Key;
if (!moduleAndMod.Value)
continue;

// Note(sewer): All modules are valid by definition
// All modules are selected by definition.
foreach (var diagnostic in ModuleUtilities.ValidateModuleEx(modulesOnly, moduleInfo, module => isEnabledDict.ContainsKey(module), _ => true, false).Select(x => CreateDiagnostic(x)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ private async Task PersistSortableEntries(List<RedModSortableItem> orderList)
var newSortOrder = new Abstractions.Loadouts.SortOrder.New(ts)
{
LoadoutId = loadoutId,
SortOrderTypeId = parentFactory.StaticSortOrderTypeId,
SortOrderTypeId = parentFactory.SortOrderTypeId,
};

var newRedModSortOrder = new RedModSortOrder.New(ts, newSortOrder.SortOrderId)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.ComponentModel;
using System.Diagnostics;
using DynamicData;
using NexusMods.Abstractions.Games;
Expand All @@ -11,9 +12,34 @@ public class RedModSortableItemProviderFactory : ISortableItemProviderFactory
{
private readonly IConnection _connection;
private readonly Dictionary<LoadoutId, RedModSortableItemProvider> _providers = new();
private static readonly Guid StaticTypeId = new("9120C6F5-E0DD-4AD2-A99E-836F56796950");

public Guid StaticSortOrderTypeId { get; } = new("9120C6F5-E0DD-4AD2-A99E-836F56796950");
public string SortOrderName { get; } = "REDmod Load Order";
public Guid SortOrderTypeId => StaticTypeId;

public string SortOrderName => "REDmod Load Order";

public string OverrideInfoTitle => "First Loaded REDmod Wins";

public string OverrideInfoHeading => "Load Order for REDmods in Cyberpunk 2077 - First Loaded Wins";

public string OverrideInfoMessage => """
Some Cyberpunk 2077 mods use REDmods modules to alter core gameplay elements. If two REDmods modify the same part of the game, the one loaded first will take priority and overwrite changes from those loaded later.
For example, the 1st position overwrites the 2nd, the 2nd overwrites the 3rd, and so on.
""";

public string WinnerIndexToolTip => "The REDmod that will overwrite all others";

public string IndexColumnHeader => "Load Order";

public string NameColumnHeader => "REDmod Name";

public string EmptyStateMessageTitle => "No REDmods detected";
public string EmptyStateMessageContents => "Some mods contain REDmods modules that can alter core gameplay elements. When detected they will appear here for load order configuration.";

public ListSortDirection SortDirectionDefault => ListSortDirection.Ascending;

public IndexOverrideBehavior IndexOverrideBehavior => IndexOverrideBehavior.SmallerIndexWins;

public RedModSortableItemProviderFactory(IConnection connection)
{
Expand Down Expand Up @@ -56,7 +82,7 @@ public RedModSortableItemProviderFactory(IConnection connection)
Debug.Assert(false, $"RedModSortableItemProviderFactory: provider not found for loadout {removal.Current.LoadoutId}");
continue;
}

// TODO: Delete SortOrder and SortableItem entities from DB if it isn't done in Synchronizer.DeleteLoadout()
provider.Dispose();
}
Expand All @@ -74,5 +100,4 @@ public ILoadoutSortableItemProvider GetLoadoutSortableItemProvider(LoadoutId loa

throw new InvalidOperationException($"RedModSortableItemProviderFactory: provider not found for loadout {loadoutId}");
}

}
2 changes: 1 addition & 1 deletion src/NexusMods.App.UI/Overlays/AOverlayViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public IOverlayController Controller
private readonly TaskCompletionSource _taskCompletionSource = new();
public Task CompletionTask => _taskCompletionSource.Task;

public void Close()
public virtual void Close()
{
Debug.Assert(Controller != null, "Controller != null");
if (Status == Status.Closed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,19 @@ public LoginMessageBoxViewModel(ISettingsManager settingsManager, ILoginManager
CancelCommand = ReactiveCommand.Create(Close);
}

public override void Close()
{
_settingsManager.Update<LoginSettings>(settings => settings with { HasShownModal = true });
base.Close();
}

public ReactiveCommand<Unit, Unit> OkCommand { get; }
public ReactiveCommand<Unit, Unit> CancelCommand { get; }

public bool MaybeShow()
{
if (_settingsManager.Get<LoginSettings>().HasShownModal) return false;
_settingsManager.Update<LoginSettings>(settings => settings with { HasShownModal = true });
if (_settingsManager.Get<LoginSettings>().HasShownModal)
return false;

_overlayController.Enqueue(this);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using NexusMods.App.UI.Windows;
using NexusMods.App.UI.WorkspaceSystem;
using NexusMods.Paths;
using R3;

namespace NexusMods.App.UI.Pages.CollectionDownload;

Expand All @@ -21,7 +22,7 @@ public CollectionDownloadDesignViewModel() : base(new DesignWindowManager()) { }
public string AuthorName => "Lowtonotolerance";

public string Summary =>
"Aims to improves vanilla gameplay while adding minimal additional content. Aims to improves vanilla gameplay while adding minimal additional content. Aims to improves vanilla gameplay while adding minimal additional content. Aims to improves vanilla gameplay while adding minimal additional content.";
"1.6.14 The story of Stardew Valley expands outside of Pelican Town with this expanded collection designed to stay true to the original game. Created with co-op in mind, perfect for experienced solo-players. Easy install, includes configuration.";

public string Category => "Themed";
public bool IsAdult => true;
Expand All @@ -35,4 +36,7 @@ public CollectionDownloadDesignViewModel() : base(new DesignWindowManager()) { }
public Bitmap TileImage { get; } = new(AssetLoader.Open(new Uri("avares://NexusMods.App.UI/Assets/DesignTime/collection_tile_image.png")));
public Bitmap BackgroundImage { get; } = new(AssetLoader.Open(new Uri("avares://NexusMods.App.UI/Assets/DesignTime/header-background.webp")));
public string CollectionStatusText { get; } = "0 of 9 mods downloaded";

public ReactiveCommand<Unit> DownloadAllCommand { get; } = new ReactiveCommand();
public ReactiveCommand<Unit> InstallCollectionCommand { get; } = new ReactiveCommand();
}
Loading

0 comments on commit b05cd84

Please sign in to comment.