Fixed incorrect item selection in gallery view for entries with duplicate package names
Updated GalleryView selection logic to consistently use unique release name (SubItems[ReleaseNameIndex]) instead of non-unique package name, which fixes incorrect item selections in gallery view for entries with duplicate package names
This commit is contained in:
@@ -1399,17 +1399,17 @@ public class FastGalleryPanel : Control
|
||||
_favoritesCache = new HashSet<string>(SettingsManager.Instance.FavoritedGames, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public void ScrollToPackage(string packageName)
|
||||
public void ScrollToPackage(string releaseName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(packageName) || _items == null || _items.Count == 0)
|
||||
if (string.IsNullOrEmpty(releaseName) || _items == null || _items.Count == 0)
|
||||
return;
|
||||
|
||||
// Find the index of the item with the matching package name
|
||||
// Find the index of the item with the matching release name
|
||||
for (int i = 0; i < _items.Count; i++)
|
||||
{
|
||||
var item = _items[i];
|
||||
if (item.SubItems.Count > 2 &&
|
||||
item.SubItems[2].Text.Equals(packageName, StringComparison.OrdinalIgnoreCase))
|
||||
if (item.SubItems.Count > 1 &&
|
||||
item.SubItems[1].Text.Equals(releaseName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Calculate the row this item is in
|
||||
int row = i / _columns;
|
||||
|
||||
24
MainForm.cs
24
MainForm.cs
@@ -6151,13 +6151,13 @@ function onYouTubeIframeAPIReady() {
|
||||
private void btnViewToggle_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Capture currently selected item before switching views
|
||||
string selectedPackageName = null;
|
||||
string selectedReleaseName = null;
|
||||
if (gamesListView.SelectedItems.Count > 0)
|
||||
{
|
||||
var selectedItem = gamesListView.SelectedItems[0];
|
||||
if (selectedItem.SubItems.Count > 2)
|
||||
if (selectedItem.SubItems.Count > 1)
|
||||
{
|
||||
selectedPackageName = selectedItem.SubItems[SideloaderRCLONE.PackageNameIndex].Text;
|
||||
selectedReleaseName = selectedItem.SubItems[SideloaderRCLONE.ReleaseNameIndex].Text;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6179,9 +6179,9 @@ function onYouTubeIframeAPIReady() {
|
||||
PopulateGalleryView();
|
||||
|
||||
// Scroll to the previously selected item in gallery view
|
||||
if (!string.IsNullOrEmpty(selectedPackageName) && _fastGallery != null)
|
||||
if (!string.IsNullOrEmpty(selectedReleaseName) && _fastGallery != null)
|
||||
{
|
||||
_fastGallery.ScrollToPackage(selectedPackageName);
|
||||
_fastGallery.ScrollToPackage(selectedReleaseName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6283,7 +6283,6 @@ function onYouTubeIframeAPIReady() {
|
||||
var item = _fastGallery.GetItemAtIndex(itemIndex);
|
||||
if (item == null || item.SubItems.Count <= 2) return;
|
||||
|
||||
string packageName = item.SubItems[SideloaderRCLONE.PackageNameIndex].Text;
|
||||
string releaseName = item.SubItems[SideloaderRCLONE.ReleaseNameIndex].Text;
|
||||
string gameName = item.SubItems[SideloaderRCLONE.GameNameIndex].Text;
|
||||
|
||||
@@ -6294,10 +6293,11 @@ function onYouTubeIframeAPIReady() {
|
||||
listItem.Selected = false;
|
||||
}
|
||||
|
||||
// Find and select the matching item in gamesListView
|
||||
// Find and select the matching item in gamesListView using release name
|
||||
foreach (ListViewItem listItem in gamesListView.Items)
|
||||
{
|
||||
if (listItem.SubItems.Count > 2 && listItem.SubItems[2].Text == packageName)
|
||||
if (listItem.SubItems.Count > 1 &&
|
||||
listItem.SubItems[SideloaderRCLONE.ReleaseNameIndex].Text.Equals(releaseName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
listItem.Selected = true;
|
||||
listItem.EnsureVisible();
|
||||
@@ -6319,7 +6319,8 @@ function onYouTubeIframeAPIReady() {
|
||||
var item = _fastGallery.GetItemAtIndex(itemIndex);
|
||||
if (item == null || item.SubItems.Count <= 2) return;
|
||||
|
||||
string packageName = item.SubItems[2].Text;
|
||||
// Use release name to match the correct entry
|
||||
string releaseName = item.SubItems[SideloaderRCLONE.ReleaseNameIndex].Text;
|
||||
|
||||
// Clear all selections first - must deselect each item individually
|
||||
// because SelectedItems.Clear() doesn't work reliably when ListView is hidden
|
||||
@@ -6328,10 +6329,11 @@ function onYouTubeIframeAPIReady() {
|
||||
listItem.Selected = false;
|
||||
}
|
||||
|
||||
// Find and select the matching item in gamesListView, then trigger download
|
||||
// Find and select the matching item in gamesListView by release name
|
||||
foreach (ListViewItem listItem in gamesListView.Items)
|
||||
{
|
||||
if (listItem.SubItems.Count > 2 && listItem.SubItems[2].Text == packageName)
|
||||
if (listItem.SubItems.Count > 1 &&
|
||||
listItem.SubItems[SideloaderRCLONE.ReleaseNameIndex].Text.Equals(releaseName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
listItem.Selected = true;
|
||||
downloadInstallGameButton_Click(downloadInstallGameButton, EventArgs.Empty);
|
||||
|
||||
Reference in New Issue
Block a user