Skip to content

Commit

Permalink
Merge pull request #2366 from Nexus-Mods/fix/mygames-empty-nogames
Browse files Browse the repository at this point in the history
Added empty text when no game installs found
  • Loading branch information
Al12rs authored Dec 11, 2024
2 parents fcc46e3 + 46df0d1 commit aee540d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ public MiniGameWidget()
this.WhenAnyValue(view => view.ViewModel!.GameInstallations)
.Subscribe(installations =>
{
var tooltip = string.Join(", ", installations!.Select(installation => installation.Store.ToString()));
if(installations is null)
return;

var tooltip = string.Join(", ", installations.Select(installation => installation.Store.ToString()));
ToolTip.SetTip(IsFoundTextBlock, tooltip);
}
)
Expand Down
4 changes: 4 additions & 0 deletions src/NexusMods.App.UI/Pages/MyGames/MyGamesView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
<TextBlock Text="Add games to get started"
Theme="{StaticResource HeadingXSSemiTheme}"
Foreground="{StaticResource NeutralStrongBrush}" />
<TextBlock x:Name="NoGamesDetectedText"
Text="No games detected"
Theme="{StaticResource BodyMDNormalTheme}"
Foreground="{StaticResource NeutralSubduedBrush}" />
<ItemsControl
x:Name="DetectedGamesItemsControl">
<ItemsControl.ItemsPanel>
Expand Down
42 changes: 26 additions & 16 deletions src/NexusMods.App.UI/Pages/MyGames/MyGamesView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,31 @@ public MyGamesView()
InitializeComponent();

this.WhenActivated(d =>
{
this.WhenAnyValue(view => view.ViewModel!.InstalledGames)
.BindToView(this, view => view.DetectedGamesItemsControl.ItemsSource)
.DisposeWith(d);

this.WhenAnyValue(view => view.ViewModel!.SupportedGames)
.BindToView(this, view => view.SupportedGamesItemsControl.ItemsSource)
.DisposeWith(d);

this.BindCommand(ViewModel, vm => vm.GiveFeedbackCommand, view => view.GiveFeedbackButton)
.DisposeWith(d);

this.BindCommand(ViewModel, vm => vm.OpenRoadmapCommand, view => view.OpenRoadmapButton)
.DisposeWith(d);
});
{
this.WhenAnyValue(view => view.ViewModel!.InstalledGames)
.BindToView(this, view => view.DetectedGamesItemsControl.ItemsSource)
.DisposeWith(d);

this.WhenAnyValue(view => view.ViewModel!.SupportedGames)
.BindToView(this, view => view.SupportedGamesItemsControl.ItemsSource)
.DisposeWith(d);

this.BindCommand(ViewModel, vm => vm.GiveFeedbackCommand, view => view.GiveFeedbackButton)
.DisposeWith(d);

this.BindCommand(ViewModel, vm => vm.OpenRoadmapCommand, view => view.OpenRoadmapButton)
.DisposeWith(d);

this.WhenAnyValue(view => view.ViewModel!.InstalledGames.Count)
.Select(installedCount => installedCount == 0)
.Subscribe(isEmpty =>
{
NoGamesDetectedText.IsVisible = isEmpty;
DetectedGamesItemsControl.IsVisible = !isEmpty;
}
)
.DisposeWith(d);
}
);
}
}

0 comments on commit aee540d

Please sign in to comment.