Forráskód Böngészése

Store random song seed in settings. Only update when pressed.
Fixes random order changing after every song.

Stephen Damm 6 éve
szülő
commit
f56d90fbf9

+ 2 - 2
SongBrowserPlugin/DataAccess/SongBrowserModel.cs

@@ -807,9 +807,9 @@ namespace SongBrowserPlugin
 
         private void SortRandom(List<StandardLevelSO> levels)
         {
-            _log.Info("Sorting song list by random...");
+            _log.Info("Sorting song list by random (seed={0})...", this.Settings.randomSongSeed);
 
-            System.Random rnd = new System.Random(Guid.NewGuid().GetHashCode());
+            System.Random rnd = new System.Random(this.Settings.randomSongSeed);
 
             _sortedSongs = levels
                 .OrderBy(x => rnd.Next())

+ 1 - 0
SongBrowserPlugin/DataAccess/SongBrowserSettings.cs

@@ -55,6 +55,7 @@ namespace SongBrowserPlugin.DataAccess
         public bool folderSupportEnabled = false;
         public bool randomInstantQueue = false;
         public bool deleteNumberedSongFolder = true;
+        public int randomSongSeed;
 
         [XmlIgnore]
         [NonSerialized]

+ 7 - 1
SongBrowserPlugin/UI/Browser/SongBrowserUI.cs

@@ -352,7 +352,13 @@ namespace SongBrowserPlugin.UI
             _model.Settings.sortMode = sortMode;
             _model.Settings.Save();
 
-            //this._model.ProcessSongList();
+            // update the seed
+            if (_model.Settings.sortMode == SongSortMode.Random)
+            {
+                this.Model.Settings.randomSongSeed = Guid.NewGuid().GetHashCode();
+                this.Model.Settings.Save();
+            }
+
             UpdateSongList();
             RefreshSongList();