Skip to content

Commit

Permalink
Merge pull request #1416 from Nexus-Mods/disable-multi-loadouts
Browse files Browse the repository at this point in the history
Disabled Creation of Multiple Loadouts for α Release
  • Loading branch information
Sewer56 committed May 23, 2024
2 parents 0b22b15 + fb04141 commit 8b9a358
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ await Parallel.ForEachAsync(files, async (file, _) =>
var (isCached, initialState) = await GetOrCreateInitialDiskState(installation);

using var tx = Connection.BeginTransaction();
var db = Connection.Db;
using var db = Connection.Db;

// We need to create a 'Vanilla State Loadout' for rolling back the game
// to the original state before NMA touched it, if we don't already
Expand All @@ -923,7 +923,7 @@ await Parallel.ForEachAsync(files, async (file, _) =>
{
await CreateVanillaStateLoadout(installation);
}

var loadout = new Loadout.Model(tx)
{
Db = db, // Has to be here to the installation resolves properly
Expand Down
49 changes: 26 additions & 23 deletions src/NexusMods.App.UI/Controls/GameWidget/GameWidget.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,35 +88,38 @@
</StackPanel>

<!-- ManagedGame -->
<Grid x:Name="ManagedGameStackPanel"
Grid.Row="2"
Margin="0,16,0,0"
VerticalAlignment="Center"
IsVisible="False"
RowDefinitions="*">
<Button Classes="Rounded Primary" x:Name="ViewGameButton" Margin="-6,0,4,0">
<Grid x:Name="ManagedGameGrid"
ColumnDefinitions="*, Auto, Auto"
Grid.Row="2"
IsVisible="False"
VerticalAlignment="Center"
HorizontalAlignment="Stretch"
Classes="Spacing-1"
Margin="4,16,-6,0">
<Button Classes="Rounded Primary" x:Name="ViewGameButton"
Margin="-6,0,4,0"
HorizontalAlignment="Stretch"
Grid.Column="0">
<StackPanel Orientation="Horizontal">
<icons:UnifiedIcon Size="20" Classes="Check" />
<TextBlock Classes="BodyMDNormal"
Text="{x:Static resources:Language.GameWidget__View}"/>
</StackPanel>
</Button>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Right"
Classes="Spacing-1"
Margin="4,0,-6,0">
<Button Classes="Rounded Primary"
HorizontalAlignment="Right"
x:Name="AddLoadoutButton"
IsVisible="True">
<icons:UnifiedIcon Classes="Add" />
</Button>
<Button Classes="Rounded Primary"
HorizontalAlignment="Right"
x:Name="RemoveGameButton">
<icons:UnifiedIcon Classes="DeleteForever" />
</Button>
</StackPanel>
<Button Classes="Rounded Primary"
HorizontalAlignment="Right"
x:Name="AddLoadoutButton"
IsVisible="True"
Margin="0,0,4,0"
Grid.Column="1">
<icons:UnifiedIcon Classes="Add" />
</Button>
<Button Classes="Rounded Primary"
HorizontalAlignment="Right"
x:Name="RemoveGameButton"
Grid.Column="2">
<icons:UnifiedIcon Classes="DeleteForever" />
</Button>
</Grid>

<!-- RemovingGame -->
Expand Down
5 changes: 4 additions & 1 deletion src/NexusMods.App.UI/Controls/GameWidget/GameWidget.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ public GameWidget()
{
DetectedGameStackPanel.IsVisible = state == GameWidgetState.DetectedGame;
AddingGameStackPanel.IsVisible = state == GameWidgetState.AddingGame;
ManagedGameStackPanel.IsVisible = state == GameWidgetState.ManagedGame;
ManagedGameGrid.IsVisible = state == GameWidgetState.ManagedGame;
RemovingGameStackPanel.IsVisible = state == GameWidgetState.RemovingGame;
GameWidgetBorder.Classes.ToggleIf("Disabled", state is GameWidgetState.AddingGame or GameWidgetState.RemovingGame);
if (!ViewModel!.CanAddMoreThanOneLoadout)
AddLoadoutButton.IsVisible = !ManagedGameGrid.IsVisible;
})
.DisposeWith(d);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.Extensions.Logging;
using NexusMods.Abstractions.GameLocators;
using NexusMods.Abstractions.Games;
using NexusMods.Abstractions.Settings;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;

Expand All @@ -14,9 +15,10 @@ public class GameWidgetViewModel : AViewModel<IGameWidgetViewModel>, IGameWidget
{
private readonly ILogger<GameWidgetViewModel> _logger;

public GameWidgetViewModel(ILogger<GameWidgetViewModel> logger)
public GameWidgetViewModel(ILogger<GameWidgetViewModel> logger, ISettingsManager settingsManager)
{
_logger = logger;
CanAddMoreThanOneLoadout = settingsManager.Get<ExperimentalSettings>().EnableMultipleLoadouts;

AddGameCommand = ReactiveCommand.Create(() => { });
ViewGameCommand = ReactiveCommand.Create(() => { });
Expand Down Expand Up @@ -77,4 +79,5 @@ public GameWidgetViewModel(ILogger<GameWidgetViewModel> logger)

[Reactive]
public GameWidgetState State { get; set; }
public bool CanAddMoreThanOneLoadout { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public interface IGameWidgetViewModel : IViewModelInterface
public ReactiveCommand<Unit,Unit> RemoveAllLoadoutsCommand { get; set; }

public GameWidgetState State { get; set; }
public bool CanAddMoreThanOneLoadout { get; }
}

public enum GameWidgetState : byte
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
using NexusMods.Abstractions.Settings;

namespace NexusMods.App;
namespace NexusMods.App.UI;

/// <summary>
/// Settings that give access to experimental features.
/// Settings that give access to experimental features in the UI.
/// </summary>
public record ExperimentalSettings : ISettings
{
/// <summary>
/// Enables games that are not enabled by default.
/// </summary>
public bool EnableAllGames { get; init; } = true;
public bool EnableAllGames { get; init; }
#if DEBUG
= true;
#endif

/// <summary>
/// Enables the ability to have multiple loadouts within the app.
/// </summary>
public bool EnableMultipleLoadouts { get; init; }
#if DEBUG
= true;
#endif

public static ISettingsBuilder Configure(ISettingsBuilder settingsBuilder)
{
Expand All @@ -22,11 +33,20 @@ public static ISettingsBuilder Configure(ISettingsBuilder settingsBuilder)
.AddToUI<ExperimentalSettings>(builder => builder
.AddPropertyToUI(x => x.EnableAllGames, propertybuilder => propertybuilder
.AddToSection(sectionId)
.WithDisplayName("Enable Unsupported Games")
.WithDisplayName("[Unsupported] Enable Unsupported Games")
.WithDescription("When set, 'work-in-progress' games that are not yet fully supported will be enabled in the UI.")
.UseBooleanContainer()
.RequiresRestart()
)
// Disabled until first Alpha Release ships.
#if DEBUG
.AddPropertyToUI(x => x.EnableMultipleLoadouts, propertybuilder => propertybuilder
.AddToSection(sectionId)
.WithDisplayName("(Experimental) Enable Multiple Loadouts")
.WithDescription("When set, you will be able to create multiple loadouts for a game.")
.UseBooleanContainer()
)
#endif
);
}
}
2 changes: 1 addition & 1 deletion src/NexusMods.App/NexusMods.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DefineConstants />
<DefineConstants />
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using NexusMods.Abstractions.Cli;
using NexusMods.Abstractions.FileStore;
using NexusMods.Abstractions.FileStore.ArchiveMetadata;
using NexusMods.Abstractions.GameLocators;
using NexusMods.Abstractions.Games;
using NexusMods.Abstractions.Games.Loadouts;
using NexusMods.Abstractions.Games.Trees;
Expand Down Expand Up @@ -41,7 +42,7 @@ public static IServiceCollection AddLoadoutManagementVerbs(this IServiceCollecti
.AddVerb(() => ListLoadouts)
.AddVerb(() => ListModContents)
.AddVerb(() => ListMods)
.AddVerb(() => ManageGame)
.AddVerb(() => CreateLoadout)
.AddVerb(() => RenameLoadout)
.AddVerb(() => RemoveLoadout);

Expand Down Expand Up @@ -213,9 +214,9 @@ private static async Task<int> RenameLoadout([Option("l", "loadout", "Loadout to
*/
}

[Verb("manage-game", "Create a Loadout for a given game")]
private static async Task<int> ManageGame([Injected] IRenderer renderer,
[Option("g", "game", "Game to create a loadoout for")] IGame game,
[Verb("create-loadout", "Create a Loadout for a given game")]
private static async Task<int> CreateLoadout([Injected] IRenderer renderer,
[Option("g", "game", "Game to create a loadout for")] IGame game,
[Option("v", "version", "Version of the game to manage")] Version version,
[Option("n", "name", "The name of the new loadout")] string name,
[Injected] CancellationToken token)
Expand Down
2 changes: 1 addition & 1 deletion tests/NexusMods.CLI.Tests/VerbTests/ModManagementVerbs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public async Task CanCreateAndManageLists()
{
var listName = Guid.NewGuid().ToString();

var log = await Run("manage-game", "-g", "stubbed-game", "-v",
var log = await Run("create-loadout", "-g", "stubbed-game", "-v",
stubbedGame.Installations.First().Version.ToString(), "-n", listName);

log = await Run("list-loadouts");
Expand Down

0 comments on commit 8b9a358

Please sign in to comment.