瀏覽代碼

Improvements:
- code cleanup
- reference SongLoader project, remove SimpleJSON.cs because of this
- bind to SongLoader event to sort the songs

Stephen Damm 6 年之前
父節點
當前提交
2790d771f4
共有 3 個文件被更改,包括 17 次插入1380 次删除
  1. 0 1367
      SongBrowserPlugin/SimpleJSON.cs
  2. 12 8
      SongBrowserPlugin/SongBrowser.cs
  3. 5 5
      SongBrowserPlugin/SongBrowserPlugin.csproj

文件差異過大導致無法顯示
+ 0 - 1367
SongBrowserPlugin/SimpleJSON.cs


+ 12 - 8
SongBrowserPlugin/SongBrowser.cs

@@ -102,9 +102,6 @@ namespace SongBrowserPlugin
 
             try
             {
-                //RectTransform rect = _songSelectionMasterView.transform.parent as RectTransform;
-                //rect. = new Vector2(rect.sizeDelta.x+100, rect.sizeDelta.y+100);
-
                 // Create Sorting Songs By-Buttons
                 // Fav button
                 _favoriteButton = UIBuilder.CreateUIButton(_songSelectRectTransform, "QuitButton", _buttonInstance);
@@ -165,16 +162,13 @@ namespace SongBrowserPlugin
             //_log.Debug("scene.buildIndex==" + scene.buildIndex);
             try
             {
-                if (scene.buildIndex == 1 || scene.buildIndex == -1)
+                if (scene.buildIndex == SongBrowser.MenuIndex || scene.buildIndex == -1)
                 {
                     _log.Debug("SceneManagerOnActiveSceneChanged - binding to UI");
 
                     MainMenuViewController _mainMenuViewController = Resources.FindObjectsOfTypeAll<MainMenuViewController>().First();
-                    Button _buttonInstance = Resources.FindObjectsOfTypeAll<Button>().First(x => (x.name == "FreePlayButton"));
-                    _buttonInstance.onClick.AddListener(delegate ()
-                    {
 
-                    });
+                    SongLoaderPlugin.SongLoader.SongsLoaded.AddListener(OnSongLoaderLoadedSongs);
 
                     //SongListTableView table = Resources.FindObjectsOfTypeAll<SongListTableView>().FirstOrDefault();
                     //table.songListTableViewDidSelectRow += OnDidSelectSongRow;
@@ -188,6 +182,16 @@ namespace SongBrowserPlugin
         }
 
         /// <summary>
+        /// Song Loader has loaded the songs, lets sort them.
+        /// </summary>
+        private void OnSongLoaderLoadedSongs()
+        {
+            _log.Debug("--OnSongLoaderLoadedSongs");
+            ProcessSongList();
+            RefreshSongList();
+        }
+
+        /// <summary>
         /// Adjust UI based on song selected.
         /// </summary>
         /// <param name="songListViewController"></param>

+ 5 - 5
SongBrowserPlugin/SongBrowserPlugin.csproj

@@ -41,6 +41,9 @@
     <Reference Include="IllusionPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
       <HintPath>D:\Games\Steam\SteamApps\common\Beat Saber\Beat Saber_Data\Managed\IllusionPlugin.dll</HintPath>
     </Reference>
+    <Reference Include="SongLoaderPlugin">
+      <HintPath>D:\Games\Steam\SteamApps\common\Beat Saber\Plugins\SongLoaderPlugin.dll</HintPath>
+    </Reference>
     <Reference Include="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
       <HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\System.dll</HintPath>
     </Reference>
@@ -78,7 +81,6 @@
   <ItemGroup>
     <Compile Include="Logger.cs" />
     <Compile Include="ReflectionUtil.cs" />
-    <Compile Include="SimpleJSON.cs" />
     <Compile Include="SongBrowser.cs" />
     <Compile Include="Plugin.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
@@ -86,14 +88,12 @@
     <Compile Include="UIBuilder.cs" />
   </ItemGroup>
   <ItemGroup>
-
+    <Folder Include="Internals\" />
   </ItemGroup>
   <ItemGroup>
     <None Include="packages.config" />
   </ItemGroup>
-  <ItemGroup>
-    <Folder Include="Internals\" />
-  </ItemGroup>
+  <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
          Other similar extension points exist, see Microsoft.Common.targets.