浏览代码

Merge pull request #80 from chrislee0419/devel

Accommodations for EnhancedSearchAndFilters mod
Halsafar 5 年之前
父节点
当前提交
7b66b1c590

+ 5 - 0
SongBrowserPlugin/DataAccess/SongBrowserModel.cs

@@ -35,6 +35,7 @@ namespace SongBrowser
 
         public BeatmapCharacteristicSO CurrentBeatmapCharacteristicSO;
 
+        public static Func<IBeatmapLevelPack, List<IPreviewBeatmapLevel>> CustomFilterHandler;
         public static Action<Dictionary<string, CustomPreviewBeatmapLevel>> didFinishProcessingSongs;
 
         /// <summary>
@@ -484,6 +485,10 @@ namespace SongBrowser
                 case SongFilterMode.Playlist:
                     filteredSongs = FilterPlaylist(pack);
                     break;
+                case SongFilterMode.Custom:
+                    Logger.Info("Song filter mode set to custom. Deferring filter behaviour to another mod.");
+                    filteredSongs = CustomFilterHandler != null ? CustomFilterHandler.Invoke(pack) : unsortedSongs;
+                    break;
                 case SongFilterMode.None:
                 default:
                     Logger.Info("No song filter selected...");

+ 4 - 1
SongBrowserPlugin/DataAccess/SongBrowserSettings.cs

@@ -39,7 +39,10 @@ namespace SongBrowser.DataAccess
         None,
         Favorites,
         Playlist,
-        Search
+        Search,
+
+        // For other mods that extend SongBrowser
+        Custom
     }
 
     [Serializable]

+ 6 - 2
SongBrowserPlugin/UI/Browser/SongBrowserUI.cs

@@ -525,7 +525,7 @@ namespace SongBrowser.UI
         /// <summary>
         /// Helper to reduce code duplication...
         /// </summary>
-        private void RefreshSongUI(bool scrollToLevel=true)
+        public void RefreshSongUI(bool scrollToLevel=true)
         {
             RefreshSongList(scrollToLevel);
             RefreshSortButtonUI();
@@ -1261,7 +1261,11 @@ namespace SongBrowser.UI
                 sortByDisplay = _model.Settings.sortMode.ToString();
             }
             _sortByDisplay.SetButtonText(sortByDisplay);
-            _filterByDisplay.SetButtonText(_model.Settings.filterMode.ToString());
+            if (_model.Settings.filterMode != SongFilterMode.Custom)
+            {
+                // Custom SongFilterMod implies that another mod has modified the text of this button (do not overwrite)
+                _filterByDisplay.SetButtonText(_model.Settings.filterMode.ToString());
+            }
         }
 
         /// <summary>