Browse Source

Ran code cleanup.

Halsafar 4 years ago
parent
commit
54e76f7cef

+ 13 - 10
SongBrowserPlugin/DataAccess/SongBrowserModel.cs

@@ -25,7 +25,7 @@ namespace SongBrowser
         private SongBrowserSettings _settings;
 
         // song list management
-        private double _customSongDirLastWriteTime = 0;        
+        private double _customSongDirLastWriteTime = 0;
         private Dictionary<String, double> _cachedLastWriteTimes;
         private Dictionary<string, int> _levelIdToPlayCount;
 
@@ -224,7 +224,7 @@ namespace SongBrowser
                 Logger.Debug("Cannot process songs yet, no level collection selected...");
                 return;
             }
-            
+
             Logger.Debug($"Using songs from level collection: {selectedBeatmapCollection.collectionName} [num={selectedBeatmapCollection.beatmapLevelCollection.beatmapLevels.Length}");
             unsortedSongs = selectedBeatmapCollection.beatmapLevelCollection.beatmapLevels.ToList();
 
@@ -357,11 +357,11 @@ namespace SongBrowser
             var _notAllowedCharacteristics = navController.GetPrivateField<BeatmapCharacteristicSO[]>("_notAllowedCharacteristics");
 
             Logger.Debug("Calling lcnvc.SetData...");
-            lcnvc.SetData(levelPack, 
+            lcnvc.SetData(levelPack,
                 true,
-                _showPlayerStatsInDetailView, 
+                _showPlayerStatsInDetailView,
                 !_hidePracticeButton,
-                _actionButtonText, 
+                _actionButtonText,
                 null,
                 _allowedBeatmapDifficultyMask,
                 _notAllowedCharacteristics);
@@ -433,7 +433,7 @@ namespace SongBrowser
                 double maxPP = 0.0;
                 if (SongDataCore.Plugin.Songs.Data.Songs.ContainsKey(hash))
                 {
-                     maxPP = SongDataCore.Plugin.Songs.Data.Songs[hash].diffs.Max(y => y.pp);
+                    maxPP = SongDataCore.Plugin.Songs.Data.Songs[hash].diffs.Max(y => y.pp);
                 }
 
                 if (maxPP > 0f)
@@ -552,7 +552,7 @@ namespace SongBrowser
                     var stars = 0.0;
                     if (SongDataCore.Plugin.Songs.Data.Songs.ContainsKey(hash))
                     {
-                        var diffs = SongDataCore.Plugin.Songs.Data.Songs[hash].diffs;   
+                        var diffs = SongDataCore.Plugin.Songs.Data.Songs[hash].diffs;
                         stars = diffs.Max(y => y.star);
                     }
 
@@ -622,7 +622,8 @@ namespace SongBrowser
             }
 
             return levelIds
-                .OrderByDescending(x => {
+                .OrderByDescending(x =>
+                {
                     var hash = SongBrowserModel.GetSongHash(x.levelID);
                     if (SongDataCore.Plugin.Songs.Data.Songs.ContainsKey(hash))
                     {
@@ -684,7 +685,8 @@ namespace SongBrowser
             }
 
             return levelIds
-                .OrderByDescending(x => {
+                .OrderByDescending(x =>
+                {
                     var hash = SongBrowserModel.GetSongHash(x.levelID);
                     if (SongDataCore.Plugin.Songs.Data.Songs.ContainsKey(hash))
                     {
@@ -715,7 +717,8 @@ namespace SongBrowser
             }
 
             return levelIds
-                .OrderByDescending(x => {
+                .OrderByDescending(x =>
+                {
                     var hash = SongBrowserModel.GetSongHash(x.levelID);
                     if (SongDataCore.Plugin.Songs.Data.Songs.ContainsKey(hash))
                     {

+ 1 - 1
SongBrowserPlugin/DataAccess/SongBrowserSettings.cs

@@ -16,7 +16,7 @@ namespace SongBrowser.DataAccess
         Default,
         Author,
         Original,
-        Newest,        
+        Newest,
         YourPlayCount,
         Difficulty,
         Random,

+ 0 - 1
SongBrowserPlugin/Internals/BeatSaberExtensions.cs

@@ -3,7 +3,6 @@ using UnityEngine;
 using UnityEngine.Events;
 using UnityEngine.UI;
 using Image = UnityEngine.UI.Image;
-using Logger = SongBrowser.Logging.Logger;
 
 namespace SongBrowser.Internals
 {

+ 1 - 2
SongBrowserPlugin/Internals/BeatSaberUI.cs

@@ -4,12 +4,11 @@ using System;
 using System.Linq;
 using TMPro;
 using UnityEngine;
+using UnityEngine.Events;
 using UnityEngine.UI;
 using VRUIControls;
-using Object = UnityEngine.Object;
 using Image = UnityEngine.UI.Image;
 using Logger = SongBrowser.Logging.Logger;
-using UnityEngine.Events;
 
 namespace SongBrowser.Internals
 {

+ 5 - 5
SongBrowserPlugin/Plugin.cs

@@ -1,8 +1,8 @@
-using SongBrowser.UI;
-using Logger = SongBrowser.Logging.Logger;
-using System;
+using BS_Utils.Utilities;
 using IPA;
-using BS_Utils.Utilities;
+using SongBrowser.UI;
+using System;
+using Logger = SongBrowser.Logging.Logger;
 
 namespace SongBrowser
 {
@@ -32,7 +32,7 @@ namespace SongBrowser
 
         [OnExit]
         public void OnApplicationQuit()
-        {            
+        {
         }
 
         private void OnMenuSceneLoadedFresh(ScenesTransitionSetupDataSO data)

+ 3 - 5
SongBrowserPlugin/SongBrowserApplication.cs

@@ -1,9 +1,7 @@
-using SongBrowser.DataAccess;
-using SongBrowser.UI;
+using SongBrowser.UI;
 using System;
 using System.Collections;
 using System.Collections.Concurrent;
-using System.Collections.Generic;
 using System.Linq;
 using UnityEngine;
 using UnityEngine.UI;
@@ -33,7 +31,7 @@ namespace SongBrowser
         /// Load the main song browser app.
         /// </summary>
         internal static void OnLoad()
-        {            
+        {
             if (Instance != null)
             {
                 return;
@@ -41,7 +39,7 @@ namespace SongBrowser
 
             new GameObject("Beat Saber SongBrowser Plugin").AddComponent<SongBrowserApplication>();
 
-            SongBrowserApplication.MainProgressBar = SongBrowser.UI.ProgressBar.Create();            
+            SongBrowserApplication.MainProgressBar = SongBrowser.UI.ProgressBar.Create();
 
             Console.WriteLine("SongBrowser Plugin Loaded()");
         }

+ 1 - 1
SongBrowserPlugin/UI/Base64Sprites.cs

@@ -37,7 +37,7 @@ namespace SongBrowser.UI
         {
             // prune base64 encoded image header
             Regex r = new Regex(@"data:image.*base64,");
-            base64 = r.Replace(base64, "");            
+            base64 = r.Replace(base64, "");
 
             Sprite s = null;
             try

+ 7 - 7
SongBrowserPlugin/UI/Browser/BeatSaberUIController.cs

@@ -1,6 +1,5 @@
 using BS_Utils.Utilities;
 using HMUI;
-using IPA.Utilities;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -211,7 +210,7 @@ namespace SongBrowser.DataAccess
                 Logger.Debug("Current selected level collection is null for some reason...");
                 return null;
             }
-            
+
             return levelCollection.beatmapLevelCollection.beatmapLevels;
         }
 
@@ -235,7 +234,8 @@ namespace SongBrowser.DataAccess
                 try
                 {
                     category = (SelectLevelCategoryViewController.LevelCategory)Enum.Parse(typeof(SelectLevelCategoryViewController.LevelCategory), levelCategoryName, true);
-                } catch (Exception)
+                }
+                catch (Exception)
                 {
                     // invalid input
                     return;
@@ -250,7 +250,7 @@ namespace SongBrowser.DataAccess
                 }
 
                 Logger.Info("Selecting level collection: {0}", collection.collectionName);
-                
+
                 var selectLeveCategoryViewController = LevelFilteringNavigationController.GetComponentInChildren<SelectLevelCategoryViewController>();
                 var iconSegementController = selectLeveCategoryViewController.GetComponentInChildren<IconSegmentedControl>();
 
@@ -258,9 +258,9 @@ namespace SongBrowser.DataAccess
                                         select x.levelCategory).ToList().IndexOf(category);
 
                 iconSegementController.SelectCellWithNumber(selectCellNumber);
-                LevelFilteringNavigationController.SelectAnnotatedBeatmapLevelCollection(collection as IBeatmapLevelPack);                
+                LevelFilteringNavigationController.SelectAnnotatedBeatmapLevelCollection(collection as IBeatmapLevelPack);
                 LevelFilteringNavigationController.UpdateSecondChildControllerContent(category);
-                
+
                 Logger.Debug("Done selecting level collection!");
             }
             catch (Exception e)
@@ -340,7 +340,7 @@ namespace SongBrowser.DataAccess
                 LevelCollectionTableView.HandleDidSelectRowEvent(tableView, selectedIndex);
             }
             tableView.ScrollToCellWithIdx(selectedIndex, TableViewScroller.ScrollPositionType.Beginning, true);
-            tableView.SelectCellWithIdx(selectedIndex);            
+            tableView.SelectCellWithIdx(selectedIndex);
         }
 
         /// <summary>

+ 24 - 25
SongBrowserPlugin/UI/Browser/SongBrowserUI.cs

@@ -1,16 +1,16 @@
-using UnityEngine;
-using System.Linq;
-using System;
-using System.Collections.Generic;
-using UnityEngine.UI;
+using BeatSaberMarkupLanguage.Components;
 using HMUI;
 using SongBrowser.DataAccess;
-using Logger = SongBrowser.Logging.Logger;
-using System.Collections;
-using SongCore.Utilities;
 using SongBrowser.Internals;
+using SongCore.Utilities;
 using SongDataCore.BeatStar;
-using BeatSaberMarkupLanguage.Components;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine;
+using UnityEngine.UI;
+using Logger = SongBrowser.Logging.Logger;
 
 namespace SongBrowser.UI
 {
@@ -58,7 +58,7 @@ namespace SongBrowser.UI
         private Button _clearSortFilterButton;
 
         private SimpleDialogPromptViewController _deleteDialog;
-        private Button _deleteButton;        
+        private Button _deleteButton;
 
         private Button _pageUpFastButton;
         private Button _pageDownFastButton;
@@ -84,7 +84,7 @@ namespace SongBrowser.UI
         }
 
         private bool _uiCreated = false;
-        
+
         private UIState _currentUiState = UIState.Disabled;
 
         private bool _asyncUpdating = false;
@@ -189,9 +189,9 @@ namespace SongBrowser.UI
 
             // clear button
             _clearSortFilterButton = _viewController.CreateIconButton(
-                "ClearSortAndFilterButton", 
-                "PracticeButton", 
-                new Vector2(clearButtonX, clearButtonY), 
+                "ClearSortAndFilterButton",
+                "PracticeButton",
+                new Vector2(clearButtonX, clearButtonY),
                 new Vector2(randomButtonWidth, randomButtonWidth),
                 () =>
                 {
@@ -203,14 +203,14 @@ namespace SongBrowser.UI
                     {
                         OnClearButtonClickEvent();
                     }
-                }, 
+                },
                 Base64Sprites.XIcon);
             _clearSortFilterButton.SetButtonBackgroundActive(false);
 
             // create SortBy button and its display
             float curX = sortByButtonX;
 
-            Logger.Debug("Creating Sort By...");            
+            Logger.Debug("Creating Sort By...");
             _sortByButton = _viewController.CreateUIButton("sortBy", "PracticeButton", new Vector2(curX, buttonY), new Vector2(outerButtonWidth, buttonHeight), () =>
             {
                 RefreshOuterUIState(UIState.SortBy);
@@ -525,7 +525,7 @@ namespace SongBrowser.UI
         /// <summary>
         /// Helper to reduce code duplication...
         /// </summary>
-        public void RefreshSongUI(bool scrollToLevel=true)
+        public void RefreshSongUI(bool scrollToLevel = true)
         {
             if (!_uiCreated)
             {
@@ -592,7 +592,7 @@ namespace SongBrowser.UI
         /// <param name="arg2"></param>
         /// <param name="arg3"></param>
         /// <param name="arg4"></param>
-        private void _levelFilteringNavController_didSelectAnnotatedBeatmapLevelCollectionEvent(LevelFilteringNavigationController arg1, IAnnotatedBeatmapLevelCollection arg2, 
+        private void _levelFilteringNavController_didSelectAnnotatedBeatmapLevelCollectionEvent(LevelFilteringNavigationController arg1, IAnnotatedBeatmapLevelCollection arg2,
             GameObject arg3, BeatmapCharacteristicSO arg4)
         {
             Logger.Trace("_levelFilteringNavController_didSelectAnnotatedBeatmapLevelCollectionEvent(levelCollection={0})", arg2);
@@ -744,7 +744,7 @@ namespace SongBrowser.UI
             Logger.Debug($"FilterButton {mode} clicked.");
 
             var curCollection = _beatUi.GetCurrentSelectedAnnotatedBeatmapLevelCollection();
-            if (_lastLevelCollection == null || 
+            if (_lastLevelCollection == null ||
                 (curCollection != null &&
                 curCollection.collectionName != SongBrowserModel.FilteredSongsCollectionName &&
                 curCollection.collectionName != SongBrowserModel.PlaylistSongsCollectionName))
@@ -974,7 +974,7 @@ namespace SongBrowser.UI
                     }
                 });
             _beatUi.LevelSelectionFlowCoordinator.InvokePrivateMethod("PresentViewController", new object[] { _deleteDialog, null, false });
-        }        
+        }
 
         /// <summary>
         /// Display the search keyboard
@@ -1041,12 +1041,12 @@ namespace SongBrowser.UI
             {
                 newRow = totalSize - 1;
             }
-            
+
             Logger.Debug("jumpDirection: {0}, newRow: {1}", jumpDirection, newRow);
             _beatUi.SelectAndScrollToLevel(levels[newRow].levelID);
             RefreshQuickScrollButtons();
         }
-        
+
         /// <summary>
         /// Update GUI elements that show score saber data.
         /// </summary>
@@ -1094,7 +1094,7 @@ namespace SongBrowser.UI
             {
                 BeatSaberUI.SetStatButtonText(_ppStatButton, "NA");
                 BeatSaberUI.SetStatButtonText(_starStatButton, "NA");
-            }                
+            }
 
             Logger.Debug("Done refreshing score saber stats.");
         }
@@ -1112,7 +1112,7 @@ namespace SongBrowser.UI
         /// Update interactive state of the quick scroll buttons.
         /// </summary>
         private void RefreshQuickScrollButtons()
-        {         
+        {
             if (!_uiCreated)
             {
                 return;
@@ -1388,4 +1388,3 @@ namespace SongBrowser.UI
         }
     }
 }
- 

+ 3 - 3
SongBrowserPlugin/UI/ProgressBar.cs

@@ -1,10 +1,10 @@
-using System.Collections;
+using SongCore.Utilities;
+using System.Collections;
+using System.Collections.Concurrent;
 using TMPro;
 using UnityEngine;
 using UnityEngine.SceneManagement;
 using UnityEngine.UI;
-using SongCore.Utilities;
-using System.Collections.Concurrent;
 
 namespace SongBrowser.UI
 {