Просмотр исходного кода

Remove quick page up and down code that was doing nothing.
Adjust level pack events so we do half as much work.
Fixes possible exception when selecting level packs causing ScrollToLevel
to attempt to scroll to an invalid index.

Stephen Damm 6 лет назад
Родитель
Сommit
fa1c9ecd63
1 измененных файлов с 25 добавлено и 43 удалено
  1. 25 43
      SongBrowserPlugin/UI/Browser/SongBrowserUI.cs

+ 25 - 43
SongBrowserPlugin/UI/Browser/SongBrowserUI.cs

@@ -592,14 +592,7 @@ namespace SongBrowserPlugin.UI
 
             try
             {
-                // reset filter mode always here
-                this._model.Settings.filterMode = SongFilterMode.None;
-                this._model.Settings.Save();
-
-                this._model.SetCurrentLevelPack(arg2);
-                this._model.ProcessSongList();
-
-                RefreshSongList();
+                //RefreshSongList();
                 RefreshSortButtonUI();
                 RefreshQuickScrollButtons();
             }
@@ -621,6 +614,13 @@ namespace SongBrowserPlugin.UI
 
             try
             {
+                // reset filter mode always here
+                this._model.Settings.filterMode = SongFilterMode.None;
+                this._model.Settings.Save();
+
+                this._model.SetCurrentLevelPack(arg2);
+                this._model.ProcessSongList();
+
                 RefreshSongList();
                 RefreshSortButtonUI();
                 RefreshQuickScrollButtons();
@@ -1166,48 +1166,26 @@ namespace SongBrowserPlugin.UI
         /// Update interactive state of the quick scroll buttons.
         /// </summary>
         private void RefreshQuickScrollButtons()
-        {
-            // if you are ever viewing the song list with less than 5 songs the up/down buttons do not exist.
-            // just try and fetch them and ignore the exception.
-            if (_tableViewPageUpButton == null)
-            {
-                try
-                {
-                    _tableViewPageUpButton = _levelPackLevelsTableViewRectTransform.GetComponentsInChildren<Button>().First(x => x.name == "PageUpButton");
-                    (_tableViewPageUpButton.transform as RectTransform).anchoredPosition = new Vector2(0f, -1f);
-                }
-                catch (Exception)
-                {
-                    // We don't care if this fails.
-                    return;
-                }
-            }
-
-            if (_tableViewPageDownButton == null)
-            {
-                try
-                {
-                    _tableViewPageDownButton = _levelPackLevelsTableViewRectTransform.GetComponentsInChildren<Button>().First(x => x.name == "PageDownButton");
-                    (_tableViewPageDownButton.transform as RectTransform).anchoredPosition = new Vector2(0f, 1f);
-                }
-                catch (Exception)
-                {
-                    // We don't care if this fails.
-                    return;
-                }
-            }
-
+        {         
             // Refresh the fast scroll buttons
             if (_tableViewPageUpButton != null && _pageUpFastButton != null)
             {
                 _pageUpFastButton.interactable = _tableViewPageUpButton.interactable;
                 _pageUpFastButton.gameObject.SetActive(_tableViewPageUpButton.IsActive());
             }
+            else
+            {
+                _pageUpFastButton.gameObject.SetActive(false);
+            }
 
-            if (_tableViewPageDownButton != null && _pageUpFastButton != null)
+            if (_tableViewPageDownButton != null && _pageDownFastButton != null)
             {
                 _pageDownFastButton.interactable = _tableViewPageDownButton.interactable;
-                _pageDownFastButton.gameObject.SetActive(_tableViewPageDownButton.IsActive());
+                _pageDownFastButton.gameObject.SetActive(_tableViewPageDownButton.IsActive());                
+            }
+            else
+            {
+                _pageDownFastButton.gameObject.SetActive(false);
             }
         }
 
@@ -1587,11 +1565,15 @@ namespace SongBrowserPlugin.UI
                     this._model.SetCurrentLevelPack(levelPack);
                     this._model.ProcessSongList();
 
-                    _levelPacksTableView.didSelectPackEvent += _levelPacksTableView_didSelectPackEvent;
                     _levelPackViewController.didSelectPackEvent += _levelPackViewController_didSelectPackEvent;
-
+                    _levelPacksTableView.didSelectPackEvent += _levelPacksTableView_didSelectPackEvent;
+                    
                     return true;
                 }
+                else
+                {
+                    this._model.SetCurrentLevelPack(currentSelected);
+                }
             }
 
             return false;