Skip to content

Commit a7ae9af

Browse files
authored
Added: 'Warning' Dialog for Managing Game (#2916)
* Added: 'Warning' Dialog for Managing Game * Added: Missing Cancel/Continue Text * Added: Proper spacing to dialog via class * Removed: Invalid XML Comment
1 parent c480ccd commit a7ae9af

File tree

10 files changed

+162
-0
lines changed

10 files changed

+162
-0
lines changed

src/NexusMods.App.UI/NexusMods.App.UI.csproj

+7
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,13 @@
738738
<Compile Update="Pages\Sorting\LoadOrder\TreeDataGrid\LoadOrderDataProvider.cs">
739739
<DependentUpon>ILoadOrderDataProvider.cs</DependentUpon>
740740
</Compile>
741+
<Compile Update="Overlays\ManageGame\ManageGameWarningView.axaml.cs">
742+
<DependentUpon>MetricsOptInView.axaml</DependentUpon>
743+
<SubType>Code</SubType>
744+
</Compile>
745+
<Compile Update="Overlays\ManageGame\ManageGameWarningViewModel.cs">
746+
<DependentUpon>IManageGameWarningViewModel.cs</DependentUpon>
747+
</Compile>
741748
</ItemGroup>
742749

743750
<ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace NexusMods.App.UI.Overlays.ManageGameWarning;
2+
3+
public interface IManageGameWarningViewModel : IOverlayViewModel<bool>
4+
{
5+
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<reactiveUi:ReactiveUserControl
2+
x:TypeArguments="manageGameWarning:IManageGameWarningViewModel"
3+
xmlns="https://github.com/avaloniaui"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:base="clr-namespace:NexusMods.App.UI.Overlays.Generic.MessageBox.Base"
8+
xmlns:reactiveUi="http://reactiveui.net"
9+
xmlns:resources="clr-namespace:NexusMods.App.UI.Resources"
10+
xmlns:manageGameWarning="clr-namespace:NexusMods.App.UI.Overlays.ManageGameWarning"
11+
mc:Ignorable="d" d:DesignWidth="800"
12+
x:Class="NexusMods.App.UI.Overlays.ManageGameWarning.ManageGameWarningView">
13+
<base:MessageBoxBackground MinWidth="300" MaxWidth="576">
14+
<base:MessageBoxBackground.TopContent>
15+
<StackPanel Orientation="Vertical" Margin="24" Classes="Spacing-6">
16+
17+
<!-- Title -->
18+
<DockPanel HorizontalAlignment="Stretch" Margin="0,0,0,16">
19+
<TextBlock x:Name="HeadingText" DockPanel.Dock="Left" Text="{x:Static resources:Language.ManageGameWarning_Title}" />
20+
</DockPanel>
21+
22+
<!-- Message -->
23+
<!-- If you have existing mods, they will be detected and can be used alongside the app in the ‘External Changes’ page. -->
24+
<TextBlock x:Name="MessageTextBlock" TextWrapping="WrapWithOverflow" Text="{x:Static resources:Language.ManageGameWarning_Desc1}" />
25+
26+
<!-- Message (Bold) -->
27+
<!-- To keep any mods you want to save, please back them up before continuing. -->
28+
<TextBlock x:Name="MessageTextBlockBold" TextWrapping="WrapWithOverflow" Text="{x:Static resources:Language.ManageGameWarning_Desc2}" />
29+
</StackPanel>
30+
31+
</base:MessageBoxBackground.TopContent>
32+
33+
<base:MessageBoxBackground.BottomContent>
34+
35+
<!-- Buttons -->
36+
<StackPanel Orientation="Horizontal" Margin="24" VerticalAlignment="Center" HorizontalAlignment="Right" Classes="Spacing-6">
37+
38+
<Button x:Name="CancelButton"
39+
Classes="Standard Tertiary"
40+
HorizontalAlignment="Right"
41+
VerticalAlignment="Center">
42+
<TextBlock Text="{x:Static resources:Language.ManageGameWarning_Cancel}" />
43+
</Button>
44+
<Button x:Name="OkButton"
45+
Classes="Standard Primary"
46+
HorizontalAlignment="Right"
47+
VerticalAlignment="Center">
48+
<TextBlock Text="{x:Static resources:Language.ManageGameWarning_Continue}" />
49+
</Button>
50+
</StackPanel>
51+
52+
</base:MessageBoxBackground.BottomContent>
53+
</base:MessageBoxBackground>
54+
</reactiveUi:ReactiveUserControl>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Avalonia.ReactiveUI;
2+
using ReactiveUI;
3+
namespace NexusMods.App.UI.Overlays.ManageGameWarning;
4+
5+
/// <summary>
6+
/// This is a variant of an 'OkCancel' messagebox with some small customizations that prevent
7+
/// subclassing of the 'OkCancel' messagebox (e.g. runs of bold, no cross, etc.)
8+
///
9+
/// 'If you have existing mods, they will be detected and can be used alongside the app in the ‘External Changes’ page.'
10+
/// ...
11+
/// </summary>
12+
public partial class ManageGameWarningView : ReactiveUserControl<IManageGameWarningViewModel>
13+
{
14+
public ManageGameWarningView()
15+
{
16+
InitializeComponent();
17+
18+
ViewForMixins.WhenActivated(this, _ =>
19+
{
20+
OkButton.Command = ReactiveCommand.Create(() =>
21+
{
22+
ViewModel!.Complete(true);
23+
});
24+
25+
CancelButton.Command = ReactiveCommand.Create(() =>
26+
{
27+
ViewModel!.Complete(false);
28+
});
29+
});
30+
}
31+
}
32+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
using JetBrains.Annotations;
2+
namespace NexusMods.App.UI.Overlays.ManageGameWarning;
3+
4+
[UsedImplicitly]
5+
public class ManageGameWarningViewModel : AOverlayViewModel<IManageGameWarningViewModel, bool>, IManageGameWarningViewModel { }

src/NexusMods.App.UI/Pages/MyGames/MyGamesViewModel.cs

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
using NexusMods.App.UI.Extensions;
3333
using NexusMods.App.UI.Overlays;
3434
using NexusMods.App.UI.Overlays.AlphaWarning;
35+
using NexusMods.App.UI.Overlays.ManageGameWarning;
3536
using NexusMods.App.UI.Pages.LibraryPage;
3637
using NexusMods.Collections;
3738
using NexusMods.CrossPlatform.Process;
@@ -119,6 +120,10 @@ public MyGamesViewModel(
119120
vm.AddGameCommand = ReactiveCommand.CreateFromTask(async () =>
120121
{
121122
if (GetJobRunningForGameInstallation(installation).IsT1) return;
123+
124+
// Warn the user about overrides, if they deny, do not add the game
125+
var result = await overlayController.EnqueueAndWait(new ManageGameWarningViewModel());
126+
if (!result) return;
122127

123128
vm.State = GameWidgetState.AddingGame;
124129
await Task.Run(async () => await ManageGame(installation));

src/NexusMods.App.UI/Resources/Language.Designer.cs

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/NexusMods.App.UI/Resources/Language.resx

+15
Original file line numberDiff line numberDiff line change
@@ -923,4 +923,19 @@ To apply changes or launch the game again, please close the game first.</value>
923923
<data name="CollectionDownloadViewModel_StatsRating_ToolTip" xml:space="preserve">
924924
<value>Success Rating</value>
925925
</data>
926+
<data name="ManageGameWarning_Title" xml:space="preserve">
927+
<value>Managing this game will affect existing mods</value>
928+
</data>
929+
<data name="ManageGameWarning_Desc1" xml:space="preserve">
930+
<value>If you have existing mods, they will be detected and can be used alongside the app in the ‘External Changes’ page.

However, if you later stop managing this game or uninstall the app, those mods will be permanently removed from your game folder.</value>
931+
</data>
932+
<data name="ManageGameWarning_Desc2" xml:space="preserve">
933+
<value>To keep any mods you want to save, please back them up before continuing.</value>
934+
</data>
935+
<data name="ManageGameWarning_Cancel" xml:space="preserve">
936+
<value>Cancel</value>
937+
</data>
938+
<data name="ManageGameWarning_Continue" xml:space="preserve">
939+
<value>Continue</value>
940+
</data>
926941
</root>

src/NexusMods.App.UI/Services.cs

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
using NexusMods.App.UI.Overlays.Generic.MessageBox.OkCancel;
3232
using NexusMods.App.UI.Overlays.LibraryDeleteConfirmation;
3333
using NexusMods.App.UI.Overlays.Login;
34+
using NexusMods.App.UI.Overlays.ManageGameWarning;
3435
using NexusMods.App.UI.Overlays.MetricsOptIn;
3536
using NexusMods.App.UI.Overlays.Updater;
3637
using NexusMods.App.UI.Pages;
@@ -56,6 +57,7 @@
5657
using NexusMods.Paths;
5758
using ReactiveUI;
5859
using ImageButton = NexusMods.App.UI.Controls.Spine.Buttons.Image.ImageButton;
60+
using ManageGameWarningView = NexusMods.App.UI.Overlays.ManageGameWarning.ManageGameWarningView;
5961
using NexusLoginOverlayView = NexusMods.App.UI.Overlays.Login.NexusLoginOverlayView;
6062
using SettingToggleControl = NexusMods.App.UI.Controls.Settings.SettingEntries.SettingToggleControl;
6163

@@ -110,6 +112,7 @@ public static IServiceCollection AddUI(this IServiceCollection c)
110112
.AddViewModel<LoadoutLeftMenuViewModel, ILoadoutLeftMenuViewModel>()
111113
.AddViewModel<FileTreeNodeViewModel, IFileTreeNodeViewModel>()
112114
.AddViewModel<ApplyDiffViewModel, IApplyDiffViewModel>()
115+
.AddViewModel<ManageGameWarningViewModel, IManageGameWarningViewModel>()
113116

114117
// Views
115118
.AddView<CollectionCardView, ICollectionCardViewModel>()
@@ -130,6 +133,7 @@ public static IServiceCollection AddUI(this IServiceCollection c)
130133
.AddView<MessageBoxOkView, IMessageBoxOkViewModel>()
131134
.AddView<MessageBoxOkCancelView, IMessageBoxOkCancelViewModel>()
132135
.AddView<LoginMessageBoxView, ILoginMessageBoxViewModel>()
136+
.AddView<ManageGameWarningView, IManageGameWarningViewModel>()
133137
.AddView<UpdaterView, IUpdaterViewModel>()
134138
.AddView<LoadoutLeftMenuView, ILoadoutLeftMenuViewModel>()
135139
.AddView<ApplyControlView, IApplyControlViewModel>()

src/Themes/NexusMods.Themes.NexusFluentDark/Styles/UserControls/MessageBox/MessageBoxStyles.axaml

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
<Style Selector="^ TextBlock#MessageTextBlock">
3131
<Setter Property="Theme" Value="{StaticResource BodyMDNormalTheme}" />
3232
</Style>
33+
34+
<Style Selector="^ TextBlock#MessageTextBlockBold">
35+
<Setter Property="Theme" Value="{StaticResource BodyMDBoldTheme}" />
36+
</Style>
3337
</Style>
3438

3539
</Styles>

0 commit comments

Comments
 (0)