Explorar el Código

V1.0.0 (#68)

* Fix download queue.

* Remove unreferenced files.

* Fix logging, confused debugging efforts.

* Fix which button template to use. Seems to entirely correct UI.

* Fix some changes in Settings file that might cause exceptions.  SongLoader
changed name of CustomMaps level pack.

* Version bump.

* Fix #60.  Invalid editing playlist (moved beat saber location) would break
plugin favorites.

* Fix #51 Corrupted SongBrowserFavorites.json files.

* Fix #51, corrupted image file.

* Fix Sort/Filter button UI position.

* Work with Level packs created by Downloader.

* Disable playlist view for now.  Downloader shows them as level packs
anyway.
Halsafar hace 6 años
padre
commit
f6fafc4063

+ 8 - 1
SongBrowserPlugin/DataAccess/Playlist.cs

@@ -340,7 +340,14 @@ namespace SongBrowser.DataAccess
             Logger.Log($"Saving playlist \"{playlistTitle}\"...");
             try
             {
-                image = Sprites.SpriteToBase64(icon);
+                if (icon != null)
+                {
+                    image = Sprites.SpriteToBase64(icon);
+                }
+                else
+                {
+                    image = null;
+                }
                 playlistSongCount = songs.Count;
             }
             catch (Exception e)

+ 8 - 2
SongBrowserPlugin/DataAccess/SongBrowserModel.cs

@@ -350,7 +350,7 @@ namespace SongBrowser
         /// <summary>
         /// Get a copy of the unfiltered, unsorted list of songs from level packs.
         /// </summary>
-        public void UpdateLevelPackOriginalLists()
+        public void UpdateLevelPackOriginalLists(bool refreshOnlyUnknown)
         {
             BeatmapLevelPackSO[] levelPacks = Resources.FindObjectsOfTypeAll<BeatmapLevelPackSO>();
             foreach (BeatmapLevelPackSO levelPack in levelPacks)
@@ -365,6 +365,12 @@ namespace SongBrowser
                     continue;
                 }
 
+                if (refreshOnlyUnknown && _levelPackToSongs.ContainsKey(levelPack.packName))
+                {
+                    Logger.Debug("Already know about {0}, not refreshing...", levelPack.packName);
+                    continue;
+                }
+
                 _levelPackToSongs[levelPack.packName] = (beatmapLevelPack.beatmapLevelCollection as BeatmapLevelCollectionSO).GetPrivateField<BeatmapLevelSO[]>("_beatmapLevels").ToList();
                 Logger.Debug("Got {0} songs from level collections...", _levelPackToSongs[levelPack.packName].Count);
                 //_levelPackToSongs[levelPack.packName].ForEach(x => Logger.Debug("{0} by {1} = {2}", x.name, x.levelAuthorName, x.levelID));
@@ -515,7 +521,7 @@ namespace SongBrowser
             BeatmapLevelPackSO[] levelPacks = Resources.FindObjectsOfTypeAll<BeatmapLevelPackSO>();
             foreach (BeatmapLevelPackSO levelPack in levelPacks)
             {
-                if (!_levelPackToSongs.ContainsKey(levelPack.packName))
+                if (levelPack.packName == null || !_levelPackToSongs.ContainsKey(levelPack.packName))
                 {
                     Logger.Debug("We know nothing about pack: {0}", levelPack.packName);
                     continue;

+ 13 - 1
SongBrowserPlugin/DataAccess/SongBrowserSettings.cs

@@ -183,15 +183,27 @@ namespace SongBrowser.DataAccess
                 p.CreateNew(playlistPath);
             }
 
-            if (String.IsNullOrEmpty(retVal.currentEditingPlaylistFile))
+            // If we do not have an editing playlist or the current one is missing, reset to default.
+            if (String.IsNullOrEmpty(retVal.currentEditingPlaylistFile) || !File.Exists(retVal.currentEditingPlaylistFile))
             {
                 retVal.currentEditingPlaylistFile = playlistPath;
             }
 
+            ApplyFixes(retVal);
             
             return retVal;
         }
 
+        private static void ApplyFixes(SongBrowserSettings settings)
+        {
+            if (String.Equals(settings.currentLevelPackId, "CustomMaps"))
+            {
+                settings.currentLevelPackId = "ModdedCustomMaps";
+            }
+
+            settings.Save();
+        }
+
         /// <summary>
         /// Favorites used to exist as part of the song_browser_settings.xml
         /// This makes little sense now.  This is the upgrade path.

+ 1 - 1
SongBrowserPlugin/Plugin.cs

@@ -14,7 +14,7 @@ namespace SongBrowser
 {
     public class Plugin : IPlugin
     {
-        public const string VERSION_NUMBER = "3.0.6";
+        public const string VERSION_NUMBER = "4.0.0";
 
         public string Name
         {

+ 2 - 2
SongBrowserPlugin/Properties/AssemblyInfo.cs

@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("3.0.6")]
-[assembly: AssemblyFileVersion("3.0.6")]
+[assembly: AssemblyVersion("4.0.0")]
+[assembly: AssemblyFileVersion("4.0.0")]

+ 2 - 39
SongBrowserPlugin/SongBrowser.csproj

@@ -63,9 +63,8 @@
     <Reference Include="ProBuilderCore">
       <HintPath>C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\ProBuilderCore.dll</HintPath>
     </Reference>
-    <Reference Include="SongLoaderPlugin, Version=5.0.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Plugins\SongLoaderPlugin.dll</HintPath>
+    <Reference Include="SongLoader">
+      <HintPath>D:\Games\Steam\SteamApps\common\Beat Saber\Plugins\SongLoader.dll</HintPath>
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Data" />
@@ -100,10 +99,6 @@
       <SpecificVersion>False</SpecificVersion>
       <HintPath>C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
     </Reference>
-    <Reference Include="UnityEngine.TLSModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\..\..\..\Program Files\Oculus\Software\Software\hyperbolic-magnetism-beat-saber\Beat Saber_Data\Managed\UnityEngine.TLSModule.dll</HintPath>
-    </Reference>
     <Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
       <HintPath>C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.UI.dll</HintPath>
@@ -124,38 +119,6 @@
       <SpecificVersion>False</SpecificVersion>
       <HintPath>C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.UnityWebRequestWWWModule.dll</HintPath>
     </Reference>
-    <Reference Include="UnityEngine.VehiclesModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\..\..\..\Program Files\Oculus\Software\Software\hyperbolic-magnetism-beat-saber\Beat Saber_Data\Managed\UnityEngine.VehiclesModule.dll</HintPath>
-    </Reference>
-    <Reference Include="UnityEngine.VideoModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\..\..\..\Program Files\Oculus\Software\Software\hyperbolic-magnetism-beat-saber\Beat Saber_Data\Managed\UnityEngine.VideoModule.dll</HintPath>
-    </Reference>
-    <Reference Include="UnityEngine.VRModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\..\..\..\Program Files\Oculus\Software\Software\hyperbolic-magnetism-beat-saber\Beat Saber_Data\Managed\UnityEngine.VRModule.dll</HintPath>
-    </Reference>
-    <Reference Include="UnityEngine.WindModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\..\..\..\Program Files\Oculus\Software\Software\hyperbolic-magnetism-beat-saber\Beat Saber_Data\Managed\UnityEngine.WindModule.dll</HintPath>
-    </Reference>
-    <Reference Include="UnityEngine.XRModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\..\..\..\Program Files\Oculus\Software\Software\hyperbolic-magnetism-beat-saber\Beat Saber_Data\Managed\UnityEngine.XRModule.dll</HintPath>
-    </Reference>
-    <Reference Include="websocket-sharp, Version=1.0.2.32192, Culture=neutral, PublicKeyToken=5660b08a1845a91e, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\..\..\..\Program Files\Oculus\Software\Software\hyperbolic-magnetism-beat-saber\Beat Saber_Data\Managed\websocket-sharp.dll</HintPath>
-    </Reference>
-    <Reference Include="Zenject, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\..\..\..\Program Files\Oculus\Software\Software\hyperbolic-magnetism-beat-saber\Beat Saber_Data\Managed\Zenject.dll</HintPath>
-    </Reference>
-    <Reference Include="Zenject-usage, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\..\..\..\Program Files\Oculus\Software\Software\hyperbolic-magnetism-beat-saber\Beat Saber_Data\Managed\Zenject-usage.dll</HintPath>
-    </Reference>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="DataAccess\BeatSaverApi\BeatSaverApiResults.cs" />

+ 1 - 0
SongBrowserPlugin/SongBrowserApplication.cs

@@ -213,6 +213,7 @@ namespace SongBrowser
         private void HandleModeSelection(MainMenuViewController.MenuButton mode)
         {
             Logger.Trace("HandleModeSelection()");
+            _songBrowserUI.UpdateLevelPackModel(true);
             this._songBrowserUI.CreateUI(mode);
             StartCoroutine(this.UpdateBrowserUI());
         }

+ 12 - 10
SongBrowserPlugin/UI/Browser/SongBrowserUI.cs

@@ -237,8 +237,8 @@ namespace SongBrowser.UI
                 // Gather some transforms and templates to use.
                 RectTransform sortButtonTransform = this._levelSelectionNavigationController.transform as RectTransform;
                 RectTransform otherButtonTransform = this._levelDetailViewController.transform as RectTransform;
-                Button sortButtonTemplate = Resources.FindObjectsOfTypeAll<Button>().First(x => (x.name == "SettingsButton"));
-                Button otherButtonTemplate = Resources.FindObjectsOfTypeAll<Button>().First(x => (x.name == "SettingsButton"));
+                Button sortButtonTemplate = Resources.FindObjectsOfTypeAll<Button>().First(x => (x.name == "HowToPlayButton"));
+                Button otherButtonTemplate = Resources.FindObjectsOfTypeAll<Button>().First(x => (x.name == "HowToPlayButton"));
 
                 RectTransform playContainerRect = _standardLevelDetailView.GetComponentsInChildren<RectTransform>().First(x => x.name == "PlayContainer");
                 RectTransform playButtonsRect = playContainerRect.GetComponentsInChildren<RectTransform>().First(x => x.name == "PlayButtons");
@@ -252,12 +252,12 @@ namespace SongBrowser.UI
                 Sprite borderSprite = SongBrowserApplication.Instance.CachedIcons["RoundRectBigStroke"];            
 
                 // Create Sorting Songs By-Buttons
-                Logger.Debug("Creating sort by buttons...");
+                Logger.Debug("Start creation of UI...");
                 float buttonSpacing = 0.5f;                                
                 float fontSize = 2.0f;
                 float buttonWidth = 12.25f;
                 float buttonHeight = 5.0f;
-                float startButtonX = 24.50f;
+                float startButtonX = 22.50f;
                 float curButtonX = 0.0f;
                 float buttonY = -5.25f;
                 Vector2 iconButtonSize = new Vector2(buttonHeight, buttonHeight);
@@ -278,9 +278,11 @@ namespace SongBrowser.UI
                     OnClearButtonClickEvent();
                 });
 
-                startButtonX += (buttonHeight * 2.0f);
+                startButtonX += (buttonHeight);
 
                 // define sort buttons
+                Logger.Debug("Create sort buttons...");
+
                 string[] sortButtonNames = new string[]
                 {
                     "Song", "Author", "Newest", "Plays", "PP", "Difficult", "Random"
@@ -311,12 +313,12 @@ namespace SongBrowser.UI
                 // Create filter buttons
                 Logger.Debug("Creating filter buttons...");
 
-                float filterButtonX = curButtonX + (buttonWidth / 2.0f);
+                float filterButtonX = curButtonX + (buttonWidth);
 
                 List<Tuple<SongFilterMode, UnityEngine.Events.UnityAction, Sprite>> filterButtonSetup = new List<Tuple<SongFilterMode, UnityEngine.Events.UnityAction, Sprite>>()
                 {
                     Tuple.Create<SongFilterMode, UnityEngine.Events.UnityAction, Sprite>(SongFilterMode.Favorites, OnFavoriteFilterButtonClickEvent, Base64Sprites.StarFullIcon),
-                    Tuple.Create<SongFilterMode, UnityEngine.Events.UnityAction, Sprite>(SongFilterMode.Playlist, OnPlaylistButtonClickEvent, Base64Sprites.PlaylistIcon),
+                    //Tuple.Create<SongFilterMode, UnityEngine.Events.UnityAction, Sprite>(SongFilterMode.Playlist, OnPlaylistButtonClickEvent, Base64Sprites.PlaylistIcon),
                     Tuple.Create<SongFilterMode, UnityEngine.Events.UnityAction, Sprite>(SongFilterMode.Search, OnSearchButtonClickEvent, Base64Sprites.SearchIcon),
                 };
 
@@ -1362,7 +1364,7 @@ namespace SongBrowser.UI
                 return null;
             }
 
-            IBeatmapLevelPack levelPack = levelPackCollection.beatmapLevelPacks.ToList().First(x => x.packID == levelPackId);
+            IBeatmapLevelPack levelPack = levelPackCollection.beatmapLevelPacks.ToList().FirstOrDefault(x => x.packID == levelPackId);
             return levelPack;
         }
 
@@ -1532,9 +1534,9 @@ namespace SongBrowser.UI
         /// <summary>
         /// Update the level pack model.
         /// </summary>
-        public void UpdateLevelPackModel()
+        public void UpdateLevelPackModel(bool refreshOnlyUnknown=false)
         {
-            _model.UpdateLevelPackOriginalLists();
+            _model.UpdateLevelPackOriginalLists(refreshOnlyUnknown);
         }
 
         /// <summary>

+ 2 - 2
SongBrowserPlugin/UI/DownloadQueue/DownloadQueueTableCell.cs

@@ -27,7 +27,7 @@ namespace SongBrowser.UI.DownloadQueue
 
             _authorText = GetComponentsInChildren<TextMeshProUGUI>().First(x => x.name == "Author");
             _songNameText = GetComponentsInChildren<TextMeshProUGUI>().First(x => x.name == "SongName");
-            _coverImage = GetComponentsInChildren<UnityEngine.UI.Image>().First(x => x.name == "CoverImage");
+            _coverRawImage = GetComponentsInChildren<UnityEngine.UI.RawImage>().First(x => x.name == "CoverImage");
             _bgImage = GetComponentsInChildren<UnityEngine.UI.Image>().First(x => x.name == "BG");
             _highlightImage = GetComponentsInChildren<UnityEngine.UI.Image>().First(x => x.name == "Highlight");
             _beatmapCharacteristicAlphas = new float[0];
@@ -41,7 +41,7 @@ namespace SongBrowser.UI.DownloadQueue
 
             _songNameText.text = string.Format("{0}\n<size=80%>{1}</size>", song.songName, song.songSubName);
             _authorText.text = song.authorName;
-            StartCoroutine(LoadScripts.LoadSpriteCoroutine(song.coverUrl, (cover) => { _coverImage.sprite = cover; }));
+            StartCoroutine(LoadScripts.LoadSpriteCoroutine(song.coverUrl, (cover) => { _coverRawImage.texture = cover.texture; }));
 
             _bgImage.enabled = true;
             _bgImage.sprite = Sprite.Create((new Texture2D(1, 1)), new Rect(0, 0, 1, 1), Vector2.one / 2f);