Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added src/RomManager/Assets/Icons/Games/favourite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/RomManager/Assets/Icons/Games/unfavourite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 28 additions & 2 deletions src/RomManager/Models/Game.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using Avalonia.Platform;
using CommunityToolkit.Mvvm.ComponentModel;
using RomManager.Core.RegionDetection;
using RomManager.Models.FileTypes;
Expand All @@ -24,7 +26,18 @@
[ObservableProperty] private SystemInfo[] _systems;

[ObservableProperty] private Region[] _regions = [Region.Unknown];

[ObservableProperty] private CoverArtImage? _coverArtImage;
[ObservableProperty] private Manual? _manual;
[ObservableProperty] private RomFile? _romFile;
[ObservableProperty] private SaveGame? _saveGame;
[ObservableProperty] private Screenshot? _screenshot;
[ObservableProperty] private State[] _state;
[ObservableProperty] private TitleScreen? _titleScreen;
[ObservableProperty] private Video _video;
//probably delete
[ObservableProperty] private bool _showLogo = false ;
[ObservableProperty] private Bitmap? _favouritePAth;
[ObservableProperty] private bool? _isFavourite = false;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Don't introduce new properties
  2. Don't make a new property for binding "_isFavourite" use Info.IsFavorite

public void Load()
{
var art = Files.OfType<CoverArtImage>().FirstOrDefault();
Expand All @@ -33,6 +46,19 @@
CoverArt = new Bitmap(art.Filename);
}

Uri uri;
if (IsFavourite == true)
{
uri = new Uri("avares://RomManager/Assets/Icons/Games/favourite.png");
}
else
{
uri = new Uri("avares://RomManager/Assets/Icons/Games/unfavourite.png");
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using var stream = AssetLoader.Open(uri);
FavouritePAth = new Bitmap(stream);

Check notice on line 60 in src/RomManager/Models/Game.cs

View check run for this annotation

codefactor.io / CodeFactor

src/RomManager/Models/Game.cs#L60

Code should not contain multiple blank lines in a row. (SA1507)

Systems = Files.OfType<RomFile>().Select(f => f.SystemInfo).ToArray();

// Detect regions from the ROM file
Expand Down
5 changes: 5 additions & 0 deletions src/RomManager/Pages/LibraryPage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,16 @@
Width="18" HorizontalAlignment="Center" VerticalAlignment="Center"
Height="18"
ToolTip.Tip="{Binding Name}" />

</Border>
</DataTemplate>

</ItemsControl.ItemTemplate>
</ItemsControl>

<Image Source="{Binding FavouritePAth}"
Width="18" HorizontalAlignment="Right" VerticalAlignment="Top"
Height="18" IsVisible="True" />
<ItemsControl ItemsSource="{Binding Regions}"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Expand Down
2 changes: 2 additions & 0 deletions src/RomManager/ViewModels/LibraryPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
[ObservableProperty] private int _pageCount = 1;
[ObservableProperty] private int _pageSize = 30;
[ObservableProperty] private int _filteredGamesCount;

Check notice on line 30 in src/RomManager/ViewModels/LibraryPageViewModel.cs

View check run for this annotation

codefactor.io / CodeFactor

src/RomManager/ViewModels/LibraryPageViewModel.cs#L30

Code should not contain multiple blank lines in a row. (SA1507)


public LibraryPageViewModel(Core.RomManager romManager, FilenameFilterBuilder filenameFilterBuilder, IOptions<PathsConfiguration> pathsConfiguration)
{
_filenameFilterBuilder = filenameFilterBuilder;
Expand Down