feat(bookmark): ゲームのお気に入り(ブックマーク)登録機能および優先ソート・フィルターを追加
- GameItemBase に IsBookmarked プロパティおよび関連バインディング項目を追加 - 一覧カード内星アイコン、詳細ヘッダーボタン、右クリックコンテキストメニューからブックマーク切替可能に - ソート順に「★ ブックマーク優先」を追加し、サブフィルターに「★ ブックマークのみ」絞り込みを追加 - キャッシュ保存(UnifiedGameCacheEntry)にブックマーク状態を永続化し次回起動時も保持 - ステータスバーにブックマーク登録件数の集計表示を追加
This commit is contained in:
1 parent
59519208f3
commit
c0989362a9
6 files changed
+119
-4
No files matched your search
@@ -51,7 +51,8 @@ namespace GameLauncher.Engines.Unity
|
||||
FolderLastModifiedAsc = 3, // フォルダ更新日時 (古い順)
|
||||
TitleAsc = 4, // タイトル (昇順)
|
||||
TitleDesc = 5, // タイトル (降順)
|
||||
FolderNameAsc = 6 // フォルダ名 (昇順)
|
||||
FolderNameAsc = 6, // フォルダ名 (昇順)
|
||||
BookmarkedFirst = 7 // ★ ブックマーク優先
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+22
-1
@@ -339,6 +339,7 @@
|
||||
<TextBlock Text="並び順:" FontSize="12" Foreground="{StaticResource TextSecondary}" VerticalAlignment="Center" Margin="0,0,6,0"/>
|
||||
<ComboBox x:Name="cmbSortOrder" Width="205" Height="34" Style="{StaticResource DarkModernComboBox}"
|
||||
SelectionChanged="cmbSortOrder_SelectionChanged">
|
||||
<ComboBoxItem Content="★ ブックマーク優先" Tag="BookmarkedFirst"/>
|
||||
<ComboBoxItem Content="最終実行日時 (新しい順)" Tag="LastLaunchedDesc" IsSelected="True"/>
|
||||
<ComboBoxItem Content="最終実行日時 (古い順)" Tag="LastLaunchedAsc"/>
|
||||
<ComboBoxItem Content="フォルダ更新日時 (新しい順)" Tag="FolderLastModifiedDesc"/>
|
||||
@@ -384,6 +385,9 @@
|
||||
|
||||
<!-- サブフィルター群(状態・形式の追加絞り込み) -->
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<!-- ブックマークのみ絞り込み -->
|
||||
<CheckBox x:Name="chkFilterBookmarkedOnly" Content="★ ブックマークのみ" Margin="0,0,12,0" Foreground="#FFEAA7" FontWeight="Bold" Checked="FilterChanged" Unchecked="FilterChanged"/>
|
||||
|
||||
<!-- Unityバックエンド切り替え(Unityタブ選択時のみ表示) -->
|
||||
<StackPanel x:Name="pnlUnityBackendFilter" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,0,12,0" Visibility="Collapsed">
|
||||
<TextBlock Text="形式:" FontSize="11" Foreground="{StaticResource TextSecondary}" VerticalAlignment="Center" Margin="0,0,4,0"/>
|
||||
@@ -422,6 +426,7 @@
|
||||
<ListBox.ContextMenu>
|
||||
<ContextMenu x:Name="listContextMenu" ContextMenuOpening="listContextMenu_ContextMenuOpening">
|
||||
<MenuItem Header="🚀 このゲームを起動" Click="MenuLaunch_Click"/>
|
||||
<MenuItem x:Name="menuToggleBookmark" Header="★ ブックマーク登録/解除" Click="MenuToggleBookmark_Click"/>
|
||||
<Separator Background="{StaticResource BorderBrushColor}"/>
|
||||
|
||||
<!-- ツクール専用メニュー項目 -->
|
||||
@@ -493,10 +498,17 @@
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- タイトル・フォルダ名・日付 -->
|
||||
<!-- タイトル・ブックマーク・フォルダ名・日付 -->
|
||||
<StackPanel Grid.Column="1" VerticalAlignment="Center" Margin="10,0,10,0">
|
||||
<DockPanel LastChildFill="True">
|
||||
<Button DockPanel.Dock="Right" Style="{StaticResource ModernButton}"
|
||||
Padding="6,1" Margin="6,0,0,0" VerticalAlignment="Center"
|
||||
Content="{Binding BookmarkIcon}" Foreground="{Binding BookmarkBrush}"
|
||||
ToolTip="{Binding BookmarkTooltip}" FontSize="13" FontWeight="Bold"
|
||||
Click="btnCardBookmark_Click" Focusable="False"/>
|
||||
<TextBlock Text="{Binding Title}" FontSize="14" FontWeight="SemiBold"
|
||||
Foreground="{StaticResource TextPrimary}" TextTrimming="CharacterEllipsis"/>
|
||||
</DockPanel>
|
||||
<Grid Margin="0,3,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
@@ -805,8 +817,17 @@
|
||||
</Grid>
|
||||
</Border>
|
||||
<StackPanel Grid.Column="1" VerticalAlignment="Center">
|
||||
<DockPanel LastChildFill="True">
|
||||
<!-- 詳細ヘッダー用ブックマーク切り替えボタン -->
|
||||
<Button x:Name="btnDetailBookmark" DockPanel.Dock="Right" Style="{StaticResource ModernButton}"
|
||||
Padding="8,3" Margin="6,0,0,0" VerticalAlignment="Center"
|
||||
Content="{Binding SelectedItem.BookmarkButtonText, ElementName=lstGames}"
|
||||
Foreground="{Binding SelectedItem.BookmarkBrush, ElementName=lstGames}"
|
||||
ToolTip="{Binding SelectedItem.BookmarkTooltip, ElementName=lstGames}"
|
||||
FontSize="12" FontWeight="Bold" Click="btnDetailBookmark_Click"/>
|
||||
<TextBlock x:Name="lblSelectedTitle" Text="{Binding SelectedItem.Title, ElementName=lstGames}"
|
||||
FontSize="17" FontWeight="Bold" Foreground="{StaticResource TextPrimary}" TextWrapping="Wrap"/>
|
||||
</DockPanel>
|
||||
|
||||
<!-- 種別バッジライン -->
|
||||
<WrapPanel Orientation="Horizontal" Margin="0,4,0,0">
|
||||
|
||||
+52
-1
@@ -155,6 +155,7 @@ namespace GameLauncher
|
||||
chkFilterAsarOnly.IsChecked = _config.TkoolFilterAsarOnly;
|
||||
chkFilterRgssOnly.IsChecked = _config.TkoolFilterRgssOnly;
|
||||
chkFilterSaveOnly.IsChecked = _config.UnityFilterSaveOnly;
|
||||
chkFilterBookmarkedOnly.IsChecked = _config.FilterBookmarkedOnly;
|
||||
}
|
||||
|
||||
private void SaveConfig()
|
||||
@@ -183,6 +184,7 @@ namespace GameLauncher
|
||||
_config.TkoolFilterAsarOnly = chkFilterAsarOnly.IsChecked == true;
|
||||
_config.TkoolFilterRgssOnly = chkFilterRgssOnly.IsChecked == true;
|
||||
_config.UnityFilterSaveOnly = chkFilterSaveOnly.IsChecked == true;
|
||||
_config.FilterBookmarkedOnly = chkFilterBookmarkedOnly.IsChecked == true;
|
||||
|
||||
var options = new JsonSerializerOptions
|
||||
{
|
||||
@@ -482,6 +484,7 @@ namespace GameLauncher
|
||||
}
|
||||
|
||||
// 3. 追加属性フィルター(全タブ共通)
|
||||
if (chkFilterBookmarkedOnly.IsChecked == true && !game.IsBookmarked) return false;
|
||||
if (chkFilterModdedOnly.IsChecked == true && !game.IsModded) return false;
|
||||
if (chkFilterAsarOnly.IsChecked == true && (game is not TkoolGameItem tgAsar || !tgAsar.IsAsar)) return false;
|
||||
if (chkFilterRgssOnly.IsChecked == true && (game is not TkoolGameItem tgRgss || !tgRgss.HasRgssArchive)) return false;
|
||||
@@ -551,8 +554,9 @@ namespace GameLauncher
|
||||
int srpgCount = _games.Count(g => g is TkoolGameItem tg && tg.IsSrpgStudio);
|
||||
int nwjsCount = _games.Count(g => g is TkoolGameItem tg && tg.IsNwjs);
|
||||
int unityCount = _games.Count(g => g is UnityGameItem);
|
||||
int bookmarkCount = _games.Count(g => g.IsBookmarked);
|
||||
|
||||
lblStatusSummary.Text = $"総ゲーム数: {total} 件 | 表示: {visible} 件";
|
||||
lblStatusSummary.Text = $"総ゲーム数: {total} 件 | 表示: {visible} 件 | ★ ブックマーク: {bookmarkCount} 件";
|
||||
lblStatusBreakdown.Text = $"(ツクールMV/MZ: {tkoolCount}, ツクールVX系: {rgssCount}, ティラノ: {tyranoCount}, ウディタ: {wolfCount}, SRPG Studio: {srpgCount}, NW.js: {nwjsCount}, Unity: {unityCount})";
|
||||
}
|
||||
|
||||
@@ -1091,6 +1095,53 @@ namespace GameLauncher
|
||||
btnToggleDetails.Content = collapse ? "▸ 詳細を表示" : "▾ 詳細を折りたたむ";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 指定ゲームのブックマーク状態を切り替え、キャッシュに即時永続化します。
|
||||
/// </summary>
|
||||
/// <param name="game">対象ゲーム</param>
|
||||
private void ToggleGameBookmark(GameItemBase? game)
|
||||
{
|
||||
if (game == null) return;
|
||||
|
||||
game.IsBookmarked = !game.IsBookmarked;
|
||||
this._scannerService.SaveCache(this._games);
|
||||
|
||||
if (this.chkFilterBookmarkedOnly.IsChecked == true || this._gameComparer.SortOrder == GameSortOrder.BookmarkedFirst)
|
||||
{
|
||||
this._gamesView?.Refresh();
|
||||
}
|
||||
|
||||
this.UpdateStatusLabels();
|
||||
this.AppendLog($"[ブックマーク{(game.IsBookmarked ? "登録" : "解除")}] {game.Title}");
|
||||
}
|
||||
|
||||
/// <summary>一覧カード内のブックマークボタン クリック時</summary>
|
||||
private void btnCardBookmark_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is Button btn && btn.DataContext is GameItemBase game)
|
||||
{
|
||||
this.ToggleGameBookmark(game);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>詳細パネル固定ヘッダーのブックマークボタン クリック時</summary>
|
||||
private void btnDetailBookmark_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (this.lstGames.SelectedItem is GameItemBase game)
|
||||
{
|
||||
this.ToggleGameBookmark(game);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>コンテキストメニューのブックマーク切り替え クリック時</summary>
|
||||
private void MenuToggleBookmark_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (this.lstGames.SelectedItem is GameItemBase game)
|
||||
{
|
||||
this.ToggleGameBookmark(game);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task RestoreAsarForGame(TkoolGameItem tg)
|
||||
{
|
||||
if (!tg.IsAsar || string.IsNullOrEmpty(tg.AsarPath) || string.IsNullOrEmpty(tg.AsarExtractedDirPath)) return;
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace GameLauncher.Models
|
||||
private ImageSource? _iconImage;
|
||||
private DateTime? _lastLaunched;
|
||||
private DateTime? _folderLastModified;
|
||||
private bool _isBookmarked;
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
@@ -99,6 +100,31 @@ namespace GameLauncher.Models
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>ユーザーによるブックマーク登録状態</summary>
|
||||
public bool IsBookmarked
|
||||
{
|
||||
get => this._isBookmarked;
|
||||
set
|
||||
{
|
||||
if (this._isBookmarked != value)
|
||||
{
|
||||
this._isBookmarked = value;
|
||||
this.OnPropertyChanged();
|
||||
this.OnPropertyChanged(nameof(this.BookmarkIcon));
|
||||
this.OnPropertyChanged(nameof(this.BookmarkTooltip));
|
||||
this.OnPropertyChanged(nameof(this.BookmarkButtonText));
|
||||
this.OnPropertyChanged(nameof(this.BookmarkBrush));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string BookmarkIcon => this._isBookmarked ? "★" : "☆";
|
||||
public string BookmarkTooltip => this._isBookmarked ? "ブックマーク解除" : "ブックマークに追加";
|
||||
public string BookmarkButtonText => this._isBookmarked ? "★ ブックマーク中" : "☆ ブックマーク";
|
||||
public Brush BookmarkBrush => this._isBookmarked
|
||||
? new SolidColorBrush(Color.FromRgb(0xFD, 0xCB, 0x6E))
|
||||
: new SolidColorBrush(Color.FromArgb(0x88, 0xAA, 0xAA, 0xBB));
|
||||
|
||||
/// <summary>ゲームエンジンの種別</summary>
|
||||
public abstract GameEngineKind EngineKind { get; }
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace GameLauncher.Models
|
||||
public bool TkoolFilterAsarOnly { get; set; }
|
||||
public bool TkoolFilterRgssOnly { get; set; }
|
||||
public bool TkoolFilterAllRgss { get; set; }
|
||||
public bool FilterBookmarkedOnly { get; set; }
|
||||
public string UnityBackendFilter { get; set; } = "All";
|
||||
public bool UnityFilterSaveOnly { get; set; }
|
||||
}
|
||||
@@ -56,8 +57,9 @@ namespace GameLauncher.Models
|
||||
if (x is not GameItemBase a || y is not GameItemBase b)
|
||||
return 0;
|
||||
|
||||
return SortOrder switch
|
||||
return this.SortOrder switch
|
||||
{
|
||||
GameSortOrder.BookmarkedFirst => CompareBookmarkedFirst(a, b),
|
||||
GameSortOrder.LastLaunchedDesc => CompareNullableDateTimeDesc(a.LastLaunched, b.LastLaunched, a.Title, b.Title),
|
||||
GameSortOrder.LastLaunchedAsc => CompareNullableDateTimeAsc(a.LastLaunched, b.LastLaunched, a.Title, b.Title),
|
||||
GameSortOrder.FolderLastModifiedDesc => CompareNullableDateTimeDesc(a.FolderLastModified, b.FolderLastModified, a.Title, b.Title),
|
||||
@@ -69,6 +71,15 @@ namespace GameLauncher.Models
|
||||
};
|
||||
}
|
||||
|
||||
private static int CompareBookmarkedFirst(GameItemBase a, GameItemBase b)
|
||||
{
|
||||
if (a.IsBookmarked != b.IsBookmarked)
|
||||
{
|
||||
return a.IsBookmarked ? -1 : 1;
|
||||
}
|
||||
return CompareNullableDateTimeDesc(a.LastLaunched, b.LastLaunched, a.Title, b.Title);
|
||||
}
|
||||
|
||||
private static int CompareNullableDateTimeDesc(DateTime? d1, DateTime? d2, string title1, string title2)
|
||||
{
|
||||
if (d1.HasValue && d2.HasValue)
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace GameLauncher.Services
|
||||
public string ExecutablePath { get; set; } = string.Empty;
|
||||
public DateTime? LastLaunched { get; set; }
|
||||
public DateTime? FolderLastModified { get; set; }
|
||||
public bool IsBookmarked { get; set; }
|
||||
|
||||
// ツクール / ティラノ専用
|
||||
public string PluginsJsPath { get; set; } = string.Empty;
|
||||
@@ -150,6 +151,7 @@ namespace GameLauncher.Services
|
||||
UnityVersion = entry.UnityVersion,
|
||||
LastLaunched = entry.LastLaunched,
|
||||
FolderLastModified = entry.FolderLastModified,
|
||||
IsBookmarked = entry.IsBookmarked,
|
||||
HasSaveData = entry.HasSaveData
|
||||
});
|
||||
}
|
||||
@@ -168,6 +170,7 @@ namespace GameLauncher.Services
|
||||
ApplyMod = entry.ApplyMod,
|
||||
LastLaunched = entry.LastLaunched,
|
||||
FolderLastModified = entry.FolderLastModified,
|
||||
IsBookmarked = entry.IsBookmarked,
|
||||
IsModded = false,
|
||||
IsAsar = entry.IsAsar,
|
||||
IsAsarExtracted = entry.IsAsarExtracted,
|
||||
@@ -431,6 +434,7 @@ namespace GameLauncher.Services
|
||||
ExecutablePath = ug.ExecutablePath,
|
||||
LastLaunched = ug.LastLaunched,
|
||||
FolderLastModified = ug.FolderLastModified,
|
||||
IsBookmarked = ug.IsBookmarked,
|
||||
DataDirectoryPath = ug.DataDirectoryPath,
|
||||
CompanyName = ug.CompanyName,
|
||||
ProductName = ug.ProductName,
|
||||
@@ -450,6 +454,7 @@ namespace GameLauncher.Services
|
||||
ExecutablePath = tg.ExecutablePath,
|
||||
LastLaunched = tg.LastLaunched,
|
||||
FolderLastModified = tg.FolderLastModified,
|
||||
IsBookmarked = tg.IsBookmarked,
|
||||
PluginsJsPath = tg.PluginsJsPath,
|
||||
PluginsDirPath = tg.PluginsDirPath,
|
||||
TkoolEngineType = (int)tg.EngineType,
|
||||
|
||||
Reference in new issue
Block a user