From d241bef8dbe679bc968b6dd434ef0b3f2fb65030 Mon Sep 17 00:00:00 2001 From: Meivyn <793322+Meivyn@users.noreply.github.com> Date: Wed, 19 Jun 2024 00:02:44 -0400 Subject: [PATCH] Fix grid not being always resized --- ...LevelCollectionsGridViewAnimatorPatches.cs | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/PlaylistManager/AffinityPatches/AnnotatedBeatmapLevelCollectionsGridViewAnimatorPatches.cs b/PlaylistManager/AffinityPatches/AnnotatedBeatmapLevelCollectionsGridViewAnimatorPatches.cs index db9636a..b6ea4bd 100644 --- a/PlaylistManager/AffinityPatches/AnnotatedBeatmapLevelCollectionsGridViewAnimatorPatches.cs +++ b/PlaylistManager/AffinityPatches/AnnotatedBeatmapLevelCollectionsGridViewAnimatorPatches.cs @@ -11,37 +11,27 @@ namespace PlaylistManager.AffinityPatches { public class AnnotatedBeatmapLevelCollectionsGridViewAnimatorPatches : IAffinity { - private readonly AnnotatedBeatmapLevelCollectionsViewController _annotatedBeatmapLevelCollectionsTableViewController; private readonly SelectLevelCategoryViewController _selectLevelCategoryViewController; private int _originalColumnCount; private Vector2 _originalScreenSize; private bool _isGridViewResized; - public AnnotatedBeatmapLevelCollectionsGridViewAnimatorPatches(AnnotatedBeatmapLevelCollectionsViewController annotatedBeatmapLevelCollectionsTableViewController, SelectLevelCategoryViewController selectLevelCategoryViewController) + public AnnotatedBeatmapLevelCollectionsGridViewAnimatorPatches(SelectLevelCategoryViewController selectLevelCategoryViewController) { - _annotatedBeatmapLevelCollectionsTableViewController = annotatedBeatmapLevelCollectionsTableViewController; _selectLevelCategoryViewController = selectLevelCategoryViewController; } - // TODO: Doesn't resize on internal restart. [AffinityPatch(typeof(AnnotatedBeatmapLevelCollectionsGridView), nameof(AnnotatedBeatmapLevelCollectionsGridView.SetData))] [AffinityPrefix] - private void AddColumnsAndResize(AnnotatedBeatmapLevelCollectionsGridView __instance, IReadOnlyList annotatedBeatmapLevelCollections) + private void ResizeGridView(AnnotatedBeatmapLevelCollectionsGridView __instance, IReadOnlyList annotatedBeatmapLevelCollections) { - if (__instance._gridView._dataSource == null) - { - return; - } - if (_originalColumnCount == default) { _originalColumnCount = __instance._gridView._columnCount; } var selectedLevelCategory = _selectLevelCategoryViewController.selectedLevelCategory; - var animator = _annotatedBeatmapLevelCollectionsTableViewController._annotatedBeatmapLevelCollectionsGridView._animator; - if (selectedLevelCategory == SelectLevelCategoryViewController.LevelCategory.CustomSongs) { // Number of columns for max visible row count before it starts clipping with the ground. @@ -52,8 +42,8 @@ private void AddColumnsAndResize(AnnotatedBeatmapLevelCollectionsGridView __inst __instance._gridView._visibleColumnCount -= 1; var rectTransform = (RectTransform)__instance._gridView.transform; - rectTransform.sizeDelta -= new Vector2(animator._columnWidth, 0); - rectTransform.anchoredPosition -= new Vector2(animator._columnWidth / 2, 0); + rectTransform.sizeDelta -= new Vector2(__instance._cellWidth, 0); + rectTransform.anchoredPosition -= new Vector2(__instance._cellWidth / 2, 0); _isGridViewResized = true; } @@ -67,8 +57,8 @@ private void AddColumnsAndResize(AnnotatedBeatmapLevelCollectionsGridView __inst __instance._gridView._visibleColumnCount += 1; var rectTransform = (RectTransform)__instance._gridView.transform; - rectTransform.sizeDelta += new Vector2(animator._columnWidth, 0); - rectTransform.anchoredPosition += new Vector2(animator._columnWidth / 2, 0); + rectTransform.sizeDelta += new Vector2(__instance._cellWidth, 0); + rectTransform.anchoredPosition += new Vector2(__instance._cellWidth / 2, 0); _isGridViewResized = false; }