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

Fix missing space in progress bar text.
Fix exceptions when loading with no settings or playlist files.
Handle creating new playlists properly.

Stephen Damm 6 éve
szülő
commit
a79e754b21

+ 18 - 8
SongBrowserPlugin/DataAccess/SongBrowserModel.cs

@@ -315,20 +315,30 @@ namespace SongBrowserPlugin
                 _log.Exception("FAILED TO CONVERT FAVORITES TO PLAYLIST!", e);
                 _log.Exception("FAILED TO CONVERT FAVORITES TO PLAYLIST!", e);
             }
             }
 
 
-            // load the current editing playlist
+            // load the current editing playlist or make one
             if (!String.IsNullOrEmpty(this.Settings.currentEditingPlaylistFile))
             if (!String.IsNullOrEmpty(this.Settings.currentEditingPlaylistFile))
             {
             {
                 CurrentEditingPlaylist = PlaylistsReader.ParsePlaylist(this.Settings.currentEditingPlaylistFile);
                 CurrentEditingPlaylist = PlaylistsReader.ParsePlaylist(this.Settings.currentEditingPlaylistFile);
-                if (CurrentEditingPlaylist != null)
+            }
+
+            if (CurrentEditingPlaylist == null)
+            {
+                CurrentEditingPlaylist = new Playlist
                 {
                 {
-                    CurrentEditingPlaylistLevelIds = new HashSet<string>();
-                    foreach (PlaylistSong ps in CurrentEditingPlaylist.Songs)
-                    {
-                        CurrentEditingPlaylistLevelIds.Add(ps.LevelId);
-                    }
-                }
+                    Title = "Song Browser Favorites",
+                    Author = "SongBrowserPlugin",
+                    Path = this.Settings.currentEditingPlaylistFile,
+                    Image = Base64Sprites.PlaylistIcon,
+                    Songs = new List<PlaylistSong>(),
+                };
             }
             }
 
 
+            CurrentEditingPlaylistLevelIds = new HashSet<string>();
+            foreach (PlaylistSong ps in CurrentEditingPlaylist.Songs)
+            {
+                CurrentEditingPlaylistLevelIds.Add(ps.LevelId);
+            }            
+
             // Actually sort and filter
             // Actually sort and filter
             this.ProcessSongList();
             this.ProcessSongList();
 
 

+ 7 - 1
SongBrowserPlugin/DataAccess/SongBrowserSettings.cs

@@ -158,7 +158,8 @@ namespace SongBrowserPlugin.DataAccess
             }
             }
 
 
             // Load Downloader favorites but only once, we'll convert them once, empty the song_browser_setting.xml favorites and never load it again.
             // Load Downloader favorites but only once, we'll convert them once, empty the song_browser_setting.xml favorites and never load it again.
-            if (retVal.Favorites.Count > 0)
+            String playlistPath = Path.Combine(Environment.CurrentDirectory, "Playlists", DefaultConvertedFavoritesPlaylistName);
+            if (!File.Exists(playlistPath))
             {
             {
                 if (File.Exists(SongBrowserSettings.DownloaderFavoritesFilePath()))
                 if (File.Exists(SongBrowserSettings.DownloaderFavoritesFilePath()))
                 {
                 {
@@ -167,6 +168,11 @@ namespace SongBrowserPlugin.DataAccess
                 }
                 }
             }
             }
 
 
+            if (String.IsNullOrEmpty(retVal.currentEditingPlaylistFile))
+            {
+                retVal.currentEditingPlaylistFile = playlistPath;
+            }
+
             return retVal;
             return retVal;
         }
         }
 
 

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

@@ -260,14 +260,15 @@ namespace SongBrowserPlugin.UI
                     ToggleSongInPlaylist();
                     ToggleSongInPlaylist();
                 });
                 });
 
 
+                /* TODO - address, this code now coupled with model load, oops.
                 if (_currentAddFavoriteButtonSprite == null)
                 if (_currentAddFavoriteButtonSprite == null)
                 {
                 {
-                    IStandardLevel level = this._levelListViewController.selectedLevel;
-                    if (level != null)
-                    {
-                        RefreshAddFavoriteButton(level.levelID);
-                    }                    
-                }
+                   IStandardLevel level = this._levelListViewController.selectedLevel;
+                   if (level != null)
+                   {
+                       RefreshAddFavoriteButton(level.levelID);
+                   }                    
+                }*/
 
 
                 // Create delete button
                 // Create delete button
                 _deleteButton = UIBuilder.CreateButton(otherButtonTransform, otherButtonTemplate, "Delete", fontSize, 46f, 0f, 15f, 5f);                
                 _deleteButton = UIBuilder.CreateButton(otherButtonTransform, otherButtonTemplate, "Delete", fontSize, 46f, 0f, 15f, 5f);                

+ 1 - 1
SongBrowserPlugin/UI/ProgressBar.cs

@@ -32,7 +32,7 @@ namespace SongBrowserPlugin.UI
         private static readonly Vector2 CanvasSize = new Vector2(200, 50);
         private static readonly Vector2 CanvasSize = new Vector2(200, 50);
 
 
         private static readonly Vector2 CreditPosition = new Vector2(50, 22);
         private static readonly Vector2 CreditPosition = new Vector2(50, 22);
-        private const string CreditText = "Song Browser Plugin <size=75%>" + Plugin.VERSION_NUMBER + "by Halsafar</size>";
+        private const string CreditText = "Song Browser Plugin <size=75%>" + Plugin.VERSION_NUMBER + " by Halsafar</size>";
         private const float CreditFontSize = 9f;
         private const float CreditFontSize = 9f;
         private static readonly Vector2 HeaderPosition = new Vector2(50, 15);
         private static readonly Vector2 HeaderPosition = new Vector2(50, 15);
         private static readonly Vector2 HeaderSize = new Vector2(200, 20);
         private static readonly Vector2 HeaderSize = new Vector2(200, 20);