├── Screenshot.png ├── SongBrowserPlugin ├── Assets │ ├── X.png │ ├── Graph.png │ ├── Speed.png │ ├── Search.png │ ├── DeleteIcon.png │ ├── RandomIcon.png │ ├── SongIcon.png │ ├── StarFull.png │ ├── DoubleArrow.png │ ├── PlaylistIcon.png │ └── NoteStartOffset.png ├── UI │ ├── Browser │ │ ├── SongFilterButton.cs │ │ ├── SongSortButton.cs │ │ └── BeatSaberUIController.cs │ ├── Views │ │ └── Settings.bsml │ ├── ViewControllers │ │ └── SettingsViewController.cs │ ├── Base64Sprites.cs │ └── ProgressBar.cs ├── Installers │ └── SongBrowserMenuInstallers.cs ├── manifest.json ├── Directory.Build.props ├── DataAccess │ ├── Playlist.cs │ └── SongBrowserModel.cs ├── Configuration │ ├── SongFilterMode.cs │ ├── SongSortMode.cs │ ├── SongMetadata.cs │ └── PluginConfig.cs ├── SongBrowser.sln ├── HarmonyPatches │ └── FlowCoordinator_PresentFlowCoordinator.cs ├── Plugin.cs ├── Internals │ ├── BeatSaberExtensions.cs │ └── BeatSaberUI.cs ├── SongBrowser.csproj ├── Directory.Build.targets └── SongBrowserApplication.cs ├── scripts └── clone_song.ps1 ├── .github └── FUNDING.yml ├── BeatModsReleaseTemplate.txt ├── LICENSE ├── README.md └── .gitignore /Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halsafar/BeatSaberSongBrowser/HEAD/Screenshot.png -------------------------------------------------------------------------------- /SongBrowserPlugin/Assets/X.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halsafar/BeatSaberSongBrowser/HEAD/SongBrowserPlugin/Assets/X.png -------------------------------------------------------------------------------- /SongBrowserPlugin/Assets/Graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halsafar/BeatSaberSongBrowser/HEAD/SongBrowserPlugin/Assets/Graph.png -------------------------------------------------------------------------------- /SongBrowserPlugin/Assets/Speed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halsafar/BeatSaberSongBrowser/HEAD/SongBrowserPlugin/Assets/Speed.png -------------------------------------------------------------------------------- /SongBrowserPlugin/Assets/Search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halsafar/BeatSaberSongBrowser/HEAD/SongBrowserPlugin/Assets/Search.png -------------------------------------------------------------------------------- /SongBrowserPlugin/Assets/DeleteIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halsafar/BeatSaberSongBrowser/HEAD/SongBrowserPlugin/Assets/DeleteIcon.png -------------------------------------------------------------------------------- /SongBrowserPlugin/Assets/RandomIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halsafar/BeatSaberSongBrowser/HEAD/SongBrowserPlugin/Assets/RandomIcon.png -------------------------------------------------------------------------------- /SongBrowserPlugin/Assets/SongIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halsafar/BeatSaberSongBrowser/HEAD/SongBrowserPlugin/Assets/SongIcon.png -------------------------------------------------------------------------------- /SongBrowserPlugin/Assets/StarFull.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halsafar/BeatSaberSongBrowser/HEAD/SongBrowserPlugin/Assets/StarFull.png -------------------------------------------------------------------------------- /SongBrowserPlugin/Assets/DoubleArrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halsafar/BeatSaberSongBrowser/HEAD/SongBrowserPlugin/Assets/DoubleArrow.png -------------------------------------------------------------------------------- /SongBrowserPlugin/Assets/PlaylistIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halsafar/BeatSaberSongBrowser/HEAD/SongBrowserPlugin/Assets/PlaylistIcon.png -------------------------------------------------------------------------------- /SongBrowserPlugin/Assets/NoteStartOffset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halsafar/BeatSaberSongBrowser/HEAD/SongBrowserPlugin/Assets/NoteStartOffset.png -------------------------------------------------------------------------------- /SongBrowserPlugin/UI/Browser/SongFilterButton.cs: -------------------------------------------------------------------------------- 1 | using SongBrowser.Configuration; 2 | using UnityEngine.UI; 3 | 4 | namespace SongBrowser.UI 5 | { 6 | class SongFilterButton 7 | { 8 | public SongFilterMode FilterMode; 9 | public Button Button; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SongBrowserPlugin/UI/Browser/SongSortButton.cs: -------------------------------------------------------------------------------- 1 | using SongBrowser.Configuration; 2 | using UnityEngine.UI; 3 | 4 | namespace SongBrowser.UI 5 | { 6 | public class SongSortButton 7 | { 8 | public SongSortMode SortMode; 9 | public Button Button; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SongBrowserPlugin/Installers/SongBrowserMenuInstallers.cs: -------------------------------------------------------------------------------- 1 | using SongBrowser.UI.ViewControllers; 2 | using Zenject; 3 | 4 | namespace SongBrowser.Installers 5 | { 6 | class SongBrowserMenuInstaller : Installer 7 | { 8 | public override void InstallBindings() 9 | { 10 | Container.BindInterfacesTo().AsSingle(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /scripts/clone_song.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Example script for cloning a song a bunch for testing large data sets. 3 | Careful with this. 4 | #> 5 | for($i=1;$i -le 2000;$i++) 6 | { 7 | copy-item Sunset -destination $i -Recurse 8 | (Get-Content $i\info.json).replace('Sunset', "Sunset$i") | Set-Content $i\info.json 9 | (Get-Content $i\info.json).replace('from Deemo', "SunsetAuthor$i") | Set-Content $i\info.json 10 | } -------------------------------------------------------------------------------- /SongBrowserPlugin/UI/Views/Settings.bsml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /SongBrowserPlugin/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/bsmg/BSIPA-MetadataFileSchema/master/Schema.json", 3 | "author": "Halsafar", 4 | "description": "Adds sort and filter features to the level selection UI.", 5 | "gameVersion": "1.21.0", 6 | "id": "SongBrowser", 7 | "name": "Song Browser", 8 | "version": "6.4.0", 9 | "dependsOn": { 10 | "SongCore": "^3.9.6", 11 | "SongDataCore": "^1.4.8", 12 | "BSIPA": "^4.2.2", 13 | "BS Utils": "^1.12.0", 14 | "BeatSaberMarkupLanguage": "^1.6.3", 15 | "BeatSaberPlaylistsLib": "^1.6.5", 16 | "SiraUtil": "^3.0.6" 17 | }, 18 | "misc": { 19 | "plugin-hint": "SongBrowser.Plugin" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: halsafar 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /BeatModsReleaseTemplate.txt: -------------------------------------------------------------------------------- 1 | SongBrowser 2 | 3 | 6.3.5 4 | 5 | BSIPA@4.2.2,BeatSaberMarkupLanguage@1.6.3,SongCore@3.9.6,SongDataCore@1.4.8,BeatSaberPlaylistsLib@1.6.5,BS Utils@1.12.0,SiraUtil@3.0.6 6 | 7 | Adds various sorting and filtering methods to the UI. Search, favorites, ranked, and unranked filters. Sort by BeatSaver and ScoreSaber statistics. Adds PP and other extra stats to the stat panel. 8 | https://github.com/halsafar/BeatSaberSongBrowser 9 | 10 | 11 | 12 | **Mod**: SongBrowser v6.3.5 13 | **Dependencies**: SongCore, BSLM, SongDataCore, SiraUtil, BeatSaberPlaylistsLib 14 | **Changelog**: 15 | - Working with BeatSaber 1.23.0 16 | **Download**: 17 | - https://github.com/halsafar/BeatSaberSongBrowser/releases/tag/6.3.5 18 | 19 | -------------------------------------------------------------------------------- /SongBrowserPlugin/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | true 9 | true 10 | true 11 | 12 | 13 | false 14 | true 15 | true 16 | 17 | -------------------------------------------------------------------------------- /SongBrowserPlugin/DataAccess/Playlist.cs: -------------------------------------------------------------------------------- 1 | using BeatSaberPlaylistsLib; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | 5 | 6 | namespace SongBrowser.DataAccess 7 | { 8 | class Playlist 9 | { 10 | internal static PlaylistManager defaultManager = BeatSaberPlaylistsLib.PlaylistManager.DefaultManager.CreateChildManager("SongBrowser"); 11 | 12 | public static BeatSaberPlaylistsLib.Types.IPlaylist CreateNew(string playlistName, IReadOnlyList beatmapLevels) 13 | { 14 | BeatSaberPlaylistsLib.Types.IPlaylist playlist = defaultManager.CreatePlaylist("", playlistName, "SongBrowser", ""); 15 | foreach (var beatmapLevel in beatmapLevels) 16 | { 17 | playlist.Add(beatmapLevel); 18 | } 19 | defaultManager.StorePlaylist(playlist); 20 | return playlist; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /SongBrowserPlugin/Configuration/SongFilterMode.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace SongBrowser.Configuration 3 | { 4 | public enum SongFilterMode 5 | { 6 | None, 7 | Playlist, 8 | Search, 9 | Ranked, 10 | Unranked, 11 | Played, 12 | Unplayed, 13 | Requirements, 14 | Easy, 15 | Normal, 16 | Hard, 17 | Expert, 18 | ExpertPlus, 19 | // For other mods that extend SongBrowser 20 | Custom, 21 | // Deprecated 22 | Favorites 23 | } 24 | 25 | static class SongFilterModeMethods 26 | { 27 | public static bool NeedsScoreSaberData(this SongFilterMode s) 28 | { 29 | switch (s) 30 | { 31 | case SongFilterMode.Ranked: 32 | case SongFilterMode.Unranked: 33 | return true; 34 | default: 35 | return false; 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Halsafar 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /SongBrowserPlugin/UI/ViewControllers/SettingsViewController.cs: -------------------------------------------------------------------------------- 1 | using BeatSaberMarkupLanguage.Attributes; 2 | using BeatSaberMarkupLanguage.Settings; 3 | using SongBrowser.Configuration; 4 | using System; 5 | using System.ComponentModel; 6 | using Zenject; 7 | 8 | namespace SongBrowser.UI.ViewControllers 9 | { 10 | public class SettingsViewController : IInitializable, IDisposable 11 | { 12 | [UIValue("random-instant-queue")] 13 | public bool DefaultAllowDuplicates 14 | { 15 | get => PluginConfig.Instance.RandomInstantQueueSong; 16 | set => PluginConfig.Instance.RandomInstantQueueSong = value; 17 | } 18 | 19 | [UIValue("experimental-scrape-meta-data")] 20 | public bool ScrapeSongMetaData 21 | { 22 | get => PluginConfig.Instance.ExperimentalScrapeSongMetaData; 23 | set => PluginConfig.Instance.ExperimentalScrapeSongMetaData = value; 24 | } 25 | 26 | public void Initialize() => BSMLSettings.instance.AddSettingsMenu(nameof(SongBrowser), "SongBrowser.UI.Views.Settings.bsml", this); 27 | public void Dispose() => BSMLSettings.instance.RemoveSettingsMenu(this); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /SongBrowserPlugin/SongBrowser.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27703.2026 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SongBrowser", "SongBrowser.csproj", "{6F9B6801-9F4B-4D1F-805D-271C95733814}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {6F9B6801-9F4B-4D1F-805D-271C95733814}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {6F9B6801-9F4B-4D1F-805D-271C95733814}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {6F9B6801-9F4B-4D1F-805D-271C95733814}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {6F9B6801-9F4B-4D1F-805D-271C95733814}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {15DAC411-1718-4755-BAE2-16A58BAA70BE} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /SongBrowserPlugin/Configuration/SongSortMode.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace SongBrowser.Configuration 3 | { 4 | public enum SongSortMode 5 | { 6 | Default, 7 | Author, 8 | Mapper, 9 | Original, 10 | Newest, 11 | YourPlayCount, 12 | Difficulty, 13 | Random, 14 | PP, 15 | UpVotes, 16 | Rating, 17 | Heat, 18 | PlayCount, 19 | Stars, 20 | Bpm, 21 | Length, 22 | Vanilla, 23 | LastPlayed, 24 | 25 | // Allow mods to extend functionality. 26 | Custom, 27 | 28 | // Deprecated 29 | Favorites, 30 | Playlist, 31 | Search 32 | } 33 | 34 | static class SongSortModeMethods 35 | { 36 | public static bool NeedsScoreSaberData(this SongSortMode s) 37 | { 38 | switch (s) 39 | { 40 | case SongSortMode.UpVotes: 41 | case SongSortMode.Rating: 42 | case SongSortMode.PlayCount: 43 | case SongSortMode.Heat: 44 | case SongSortMode.PP: 45 | case SongSortMode.Stars: 46 | return true; 47 | default: 48 | return false; 49 | } 50 | } 51 | 52 | public static bool NeedsRefresh(this SongSortMode s) 53 | { 54 | return s switch 55 | { 56 | SongSortMode.LastPlayed => true, 57 | _ => false, 58 | }; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /SongBrowserPlugin/HarmonyPatches/FlowCoordinator_PresentFlowCoordinator.cs: -------------------------------------------------------------------------------- 1 | 2 | using HarmonyLib; 3 | using HMUI; 4 | using System; 5 | 6 | namespace SongBrowser.HarmonyPatches 7 | { 8 | [HarmonyPatch(typeof(FlowCoordinator))] 9 | [HarmonyPatch("PresentFlowCoordinator", MethodType.Normal)] 10 | class FlowCoordinator_PresentFlowCoordinator 11 | { 12 | #pragma warning disable IDE0051 // Remove unused private members 13 | static void Prefix(FlowCoordinator flowCoordinator, Action finishedCallback = null, ViewController.AnimationDirection animationDirection = ViewController.AnimationDirection.Horizontal, bool immediately = false, bool replaceTopViewController = false) 14 | #pragma warning restore IDE0051 // Remove unused private members 15 | { 16 | var flowType = flowCoordinator.GetType(); 17 | if (flowType == typeof(SoloFreePlayFlowCoordinator)) 18 | { 19 | Plugin.Log.Info("Initializing SongBrowser for Single Player Mode"); 20 | SongBrowser.SongBrowserApplication.Instance.HandleSoloModeSelection(); 21 | } 22 | else if (flowType == typeof(MultiplayerLevelSelectionFlowCoordinator)) 23 | { 24 | Plugin.Log.Info("Initializing SongBrowser for Multiplayer Mode"); 25 | SongBrowser.SongBrowserApplication.Instance.HandleMultiplayerModeSelection(); 26 | } 27 | else if (flowType == typeof(PartyFreePlayFlowCoordinator)) 28 | { 29 | Plugin.Log.Info("Initializing SongBrowser for Party Mode"); 30 | SongBrowser.SongBrowserApplication.Instance.HandlePartyModeSelection(); 31 | } 32 | else if (flowType == typeof(CampaignFlowCoordinator)) 33 | { 34 | Plugin.Log.Info("Initializing SongBrowser for Multiplayer Mode"); 35 | SongBrowser.SongBrowserApplication.Instance.HandleCampaignModeSelection(); 36 | } 37 | 38 | return; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Beat Saber SongBrowser 2 | 3 | A plugin for customizing the in-game song browser. 4 | 5 | *This mod works on both the Steam and Oculus Store versions.* 6 | 7 | ## Screenshot 8 | 9 | ![Alt text](/Screenshot.png?raw=true "Screenshot") 10 | 11 | ## Features 12 | - Sorting methods: 13 | - Song: By song name (default). 14 | - Author: By song author name then by song name. 15 | - Original: Match the original sorting you would normally get after SongLoaderPlugin. 16 | - Newest: Sort by the date you downloaded the custom song. 17 | - YourPlays: Sort by your most played. 18 | - BPM: Beats Per Minute. 19 | - Time: Song duration/length. 20 | - PP: Performance points! Using @WesVleuten (Westar#0001) score saber data. 21 | - Star: Sort by ScoreSaber's Stars difficulty rating. 22 | - UpVotes: BeatSaver's upvote count. 23 | - Rating: BeatSaver's rating statistic. 24 | - PlayCount: BeatSaver's played count. 25 | - Random: Randomize the song list each time. 26 | - Filters: 27 | - Search (with keyboard support). 28 | - Favorites (all songs you have marked as a favorite). 29 | - Ranked. 30 | - Unranked. 31 | - Requirements (requires [CustomJSONData](https://github.com/Aeroluna/CustomJSONData) v2.0.0 or later). 32 | - UI Enhancements: 33 | - Display PP, STARS, and NJS. 34 | - Fast scroll buttons (jumps 10% of your song list in each press). 35 | - Delete button for custom songs. 36 | - Tips: 37 | - Sort buttons can be pressed a second time to invert the sorting. 38 | - Filters can be cancelled by selecting them again. 39 | 40 | ## Status 41 | - Working with BeatSaber 1.23.0 42 | 43 | ## Building on Windows 44 | To compile BeatSaberSongBrowser from source: 45 | 46 | 1. Install Beat Saber and Microsoft Visual Studio. 47 | 2. Download and extract the BeatSaberSongBrowser source code. 48 | 3. Create a new file `/SongBrowserPlugin/SongBrower.csproj.user` with the following. (Make sure to replace BeatSaberDir with your real Beat Saber installation folder) 49 | ``` 50 | 51 | 52 | 53 | ProjectFiles 54 | C:\Program Files (x86)\Steam\steamapps\common\Beat Saber 55 | 56 | 57 | ``` 58 | 4. Open `/BeatSaberSongBrowser/SongBrowser.sln` in Microsoft Visual Studio. 59 | 5. Build the project with *Build -> Build Solution*. 60 | 61 | -------------------------------------------------------------------------------- /SongBrowserPlugin/Configuration/SongMetadata.cs: -------------------------------------------------------------------------------- 1 | using IPA.Config.Stores.Attributes; 2 | using IPA.Config.Stores.Converters; 3 | using IPA.Utilities; 4 | using Newtonsoft.Json; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.IO; 8 | 9 | namespace SongBrowser.Configuration 10 | { 11 | internal class SongMetadataStore 12 | { 13 | public static SongMetadataStore Instance { get; set; } 14 | 15 | [JsonIgnore] 16 | private string _storePath; 17 | 18 | [UseConverter(typeof(DictionaryConverter))] 19 | [NonNullable] 20 | public virtual Dictionary Songs { get; set; } = new Dictionary(); 21 | 22 | private static void CreateEmptyStore(String storePath) 23 | { 24 | SongMetadataStore.Instance = new SongMetadataStore 25 | { 26 | _storePath = storePath 27 | }; 28 | } 29 | 30 | public static void Load() 31 | { 32 | string storePath = Path.Combine(UnityGame.UserDataPath, nameof(SongBrowser) + "SongMetadata" + ".json"); 33 | if (!File.Exists(storePath)) 34 | { 35 | SongMetadataStore.CreateEmptyStore(storePath); 36 | return; 37 | } 38 | 39 | try 40 | { 41 | Plugin.Log.Debug($"Loading SongMetaDataStore: {storePath}"); 42 | using StreamReader file = File.OpenText(storePath); 43 | JsonSerializer serializer = new JsonSerializer(); 44 | SongMetadataStore.Instance = (SongMetadataStore)serializer.Deserialize(file, typeof(SongMetadataStore)); 45 | SongMetadataStore.Instance._storePath = storePath; 46 | } 47 | catch (JsonReaderException e) 48 | { 49 | Plugin.Log.Critical($"Could not parse SongMetaDataStore: {e}"); 50 | Plugin.Log.Warn("SongMetaDataStore is corrupted, deleting, creating new store..."); 51 | File.Delete(storePath); 52 | SongMetadataStore.CreateEmptyStore(storePath); 53 | } 54 | } 55 | 56 | public virtual SongMetadata GetMetadataForLevelID(string levelID) 57 | { 58 | if (!Instance.Songs.ContainsKey(levelID)) 59 | { 60 | Instance.Songs.Add(levelID, new SongMetadata()); 61 | } 62 | return Instance.Songs[levelID]; 63 | } 64 | 65 | public void Save() 66 | { 67 | Plugin.Log.Debug($"Saving SongMetaDataStore: {this._storePath}"); 68 | 69 | using StreamWriter file = File.CreateText(this._storePath); 70 | 71 | JsonSerializerSettings opts = new JsonSerializerSettings 72 | { 73 | Formatting = Formatting.Indented 74 | }; 75 | JsonSerializer serializer = JsonSerializer.Create(opts); 76 | 77 | serializer.Serialize(file, this); 78 | } 79 | } 80 | 81 | internal class SongMetadata 82 | { 83 | [UseConverter] 84 | public virtual DateTime? AddedAt { get; set; } 85 | 86 | [UseConverter] 87 | public virtual DateTime? LastPlayed { get; set; } = null; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /SongBrowserPlugin/Plugin.cs: -------------------------------------------------------------------------------- 1 | using BS_Utils.Utilities; 2 | using IPA; 3 | using IPA.Config.Stores; 4 | using SongBrowser.UI; 5 | using System; 6 | using System.Linq; 7 | using System.Reflection; 8 | using IPA.Loader; 9 | using Config = IPA.Config.Config; 10 | using HarmonyLib; 11 | using SongBrowser.Installers; 12 | using SiraUtil.Zenject; 13 | 14 | namespace SongBrowser 15 | { 16 | [Plugin(RuntimeOptions.SingleStartInit)] 17 | public class Plugin 18 | { 19 | public static string VersionNumber { get; private set; } 20 | public static bool IsCustomJsonDataEnabled { get; private set; } 21 | public static Plugin Instance { get; private set; } 22 | public static IPA.Logging.Logger Log { get; private set; } 23 | 24 | public const string HarmonyId = "com.halsafar.BeatSaber.SongBrowserPlugin"; 25 | internal static Harmony harmony; 26 | 27 | [Init] 28 | public void Init(IPA.Logging.Logger logger, Zenjector zenjector, PluginMetadata metadata) 29 | { 30 | Log = logger; 31 | VersionNumber = metadata.HVersion?.ToString() ?? Assembly.GetExecutingAssembly().GetName().Version.ToString(3); 32 | harmony = new Harmony(HarmonyId); 33 | zenjector.Install(Location.Menu); 34 | } 35 | 36 | #region BSIPA Config 37 | [Init] 38 | public void InitWithConfig(Config conf) 39 | { 40 | Configuration.PluginConfig.Instance = conf.Generated(); 41 | if (Configuration.PluginConfig.Instance.ExperimentalScrapeSongMetaData) 42 | { 43 | Configuration.SongMetadataStore.Load(); 44 | } 45 | Log.Debug("SongBrowser Configs loaded"); 46 | } 47 | #endregion 48 | 49 | [OnStart] 50 | public void OnApplicationStart() 51 | { 52 | Instance = this; 53 | IsCustomJsonDataEnabled = PluginManager.EnabledPlugins.FirstOrDefault(p => p.Name == "CustomJSONData")?.HVersion >= new Hive.Versioning.Version("2.0.0"); 54 | Plugin.Log.Debug($"CustomJsonData Plugin Status: {IsCustomJsonDataEnabled}"); 55 | 56 | Base64Sprites.Init(); 57 | 58 | BSEvents.OnLoad(); 59 | BSEvents.lateMenuSceneLoadedFresh += OnMenuSceneLoadedFresh; 60 | } 61 | 62 | [OnExit] 63 | public void OnApplicationQuit() 64 | { 65 | if (Configuration.PluginConfig.Instance.ExperimentalScrapeSongMetaData) 66 | { 67 | Configuration.SongMetadataStore.Instance.Save(); 68 | } 69 | } 70 | 71 | private void OnMenuSceneLoadedFresh(ScenesTransitionSetupDataSO data) 72 | { 73 | try 74 | { 75 | SongBrowserApplication.OnLoad(); 76 | } 77 | catch (Exception e) 78 | { 79 | Plugin.Log.Critical($"Exception on fresh menu scene change: {e}"); 80 | } 81 | } 82 | 83 | [OnEnable] 84 | public void OnEnable() 85 | { 86 | harmony.PatchAll(Assembly.GetExecutingAssembly()); 87 | } 88 | 89 | [OnDisable] 90 | public void OnDisable() 91 | { 92 | Harmony.UnpatchID(HarmonyId); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /SongBrowserPlugin/Internals/BeatSaberExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using UnityEngine; 3 | using UnityEngine.Events; 4 | using UnityEngine.UI; 5 | using Image = UnityEngine.UI.Image; 6 | 7 | namespace SongBrowser.Internals 8 | { 9 | public static class BeatSaberUIExtensions 10 | { 11 | #region Button Extensions 12 | public static void SetButtonText(this Button _button, string _text) 13 | { 14 | HMUI.CurvedTextMeshPro textMesh = _button.GetComponentInChildren(); 15 | if (textMesh != null) 16 | { 17 | textMesh.SetText(_text); 18 | } 19 | } 20 | 21 | public static void SetButtonTextSize(this Button _button, float _fontSize) 22 | { 23 | var txtMesh = _button.GetComponentInChildren(); 24 | if (txtMesh != null) 25 | { 26 | txtMesh.fontSize = _fontSize; 27 | } 28 | } 29 | 30 | public static void ToggleWordWrapping(this Button _button, bool enableWordWrapping) 31 | { 32 | var txtMesh = _button.GetComponentInChildren(); 33 | if (txtMesh != null) 34 | { 35 | txtMesh.enableWordWrapping = enableWordWrapping; 36 | } 37 | } 38 | 39 | public static void SetButtonBackgroundActive(this Button parent, bool active) 40 | { 41 | HMUI.ImageView img = parent.GetComponentsInChildren().Last(x => x.name == "BG"); 42 | if (img != null) 43 | { 44 | img.gameObject.SetActive(active); 45 | } 46 | } 47 | 48 | public static void SetButtonUnderlineColor(this Button parent, Color color) 49 | { 50 | HMUI.ImageView img = parent.GetComponentsInChildren().FirstOrDefault(x => x.name == "Underline"); 51 | if (img != null) 52 | { 53 | img.color = color; 54 | } 55 | } 56 | 57 | public static void SetButtonBorder(this Button button, Color color) 58 | { 59 | HMUI.ImageView img = button.GetComponentsInChildren().FirstOrDefault(x => x.name == "Border"); 60 | if (img != null) 61 | { 62 | img.color0 = color; 63 | img.color1 = color; 64 | img.color = color; 65 | img.fillMethod = Image.FillMethod.Horizontal; 66 | img.SetAllDirty(); 67 | } 68 | } 69 | #endregion 70 | 71 | #region ViewController Extensions 72 | public static Button CreateUIButton(this HMUI.ViewController parent, string name, string buttonTemplate, Vector2 anchoredPosition, Vector2 sizeDelta, UnityAction onClick = null, string buttonText = "BUTTON") 73 | { 74 | Button btn = BeatSaberUI.CreateUIButton(name, parent.rectTransform, buttonTemplate, anchoredPosition, sizeDelta, onClick, buttonText); 75 | return btn; 76 | } 77 | public static Button CreateIconButton(this HMUI.ViewController parent, string name, string buttonTemplate, Vector2 anchoredPosition, Vector2 sizeDelta, UnityAction onClick, Sprite icon, string hint) 78 | { 79 | Button btn = BeatSaberUI.CreateIconButton(name, parent.rectTransform, buttonTemplate, anchoredPosition, sizeDelta, onClick, icon, hint); 80 | return btn; 81 | } 82 | #endregion 83 | } 84 | } -------------------------------------------------------------------------------- /SongBrowserPlugin/Configuration/PluginConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Runtime.CompilerServices; 4 | using IPA.Config.Stores; 5 | using IPA.Config.Stores.Attributes; 6 | using IPA.Config.Stores.Converters; 7 | 8 | [assembly: InternalsVisibleTo(GeneratedStore.AssemblyVisibilityTarget)] 9 | namespace SongBrowser.Configuration 10 | { 11 | public enum SortFilterStates 12 | { 13 | Disabled = 0, 14 | Enabled = 1, 15 | } 16 | 17 | internal class PluginConfig 18 | { 19 | public static PluginConfig Instance { get; set; } 20 | 21 | public virtual SongSortMode SortMode { get; set; } = SongSortMode.Original; 22 | 23 | [UseConverter(typeof(DictionaryConverter))] 24 | [NonNullable] 25 | public virtual Dictionary FilterModes { get; set; } = new Dictionary(); 26 | 27 | [UseConverter(typeof(ListConverter))] 28 | [NonNullable] 29 | public virtual List SearchTerms { get; set; } = new List(); 30 | 31 | public virtual string CurrentLevelId { get; set; } = default; 32 | 33 | public virtual string CurrentLevelCollectionName { get; set; } = default; 34 | 35 | public virtual string CurrentLevelCategoryName { get; set; } = default; 36 | 37 | public virtual bool RandomInstantQueueSong { get; set; } = false; 38 | 39 | public virtual bool ExperimentalScrapeSongMetaData { get; set; } = true; 40 | 41 | public virtual bool DeleteNumberedSongFolder { get; set; } = false; 42 | 43 | public virtual bool InvertSortResults { get; set; } = false; 44 | 45 | public virtual int RandomSongSeed { get; set; } = default; 46 | 47 | public virtual int MaxSearchTerms { get; set; } = 10; 48 | 49 | /// 50 | /// Call this to force BSIPA to update the config file. This is also called by BSIPA if it detects the file was modified. 51 | /// 52 | public virtual void Changed() 53 | { 54 | if (this.SearchTerms.Count > MaxSearchTerms) 55 | { 56 | this.SearchTerms.RemoveRange(MaxSearchTerms, this.SearchTerms.Count - MaxSearchTerms); 57 | } 58 | } 59 | 60 | /// 61 | /// Call this to have BSIPA copy the values from into this config. 62 | /// 63 | public virtual void CopyFrom(PluginConfig other) 64 | { 65 | 66 | } 67 | 68 | public void ResetSortMode() 69 | { 70 | SortMode = SongSortMode.Original; 71 | } 72 | 73 | public void ResetFilterMode() 74 | { 75 | FilterModes.Clear(); 76 | } 77 | 78 | public string GetFilterModeString() 79 | { 80 | string filterModeStr = null; 81 | foreach (var kvp in FilterModes) 82 | { 83 | if (kvp.Value == SortFilterStates.Enabled) 84 | { 85 | if (!string.IsNullOrEmpty(filterModeStr)) 86 | { 87 | filterModeStr = "Multiple"; 88 | break; 89 | } 90 | else 91 | { 92 | filterModeStr = kvp.Key.ToString(); 93 | } 94 | } 95 | } 96 | 97 | if (string.IsNullOrEmpty(filterModeStr)) 98 | { 99 | return SongFilterMode.None.ToString(); 100 | } 101 | 102 | return filterModeStr; 103 | } 104 | 105 | public bool IsFilterEnabled(SongFilterMode f) 106 | { 107 | if (FilterModes.ContainsKey(f.ToString())) 108 | return FilterModes[f.ToString()] == SortFilterStates.Enabled; 109 | 110 | return false; 111 | } 112 | 113 | public void SetFilterState(SongFilterMode f, SortFilterStates state) 114 | { 115 | FilterModes[f.ToString()] = state; 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /SongBrowserPlugin/UI/Base64Sprites.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Reflection; 4 | using System.Text.RegularExpressions; 5 | using UnityEngine; 6 | 7 | 8 | namespace SongBrowser.UI 9 | { 10 | class Base64Sprites 11 | { 12 | public static Sprite StarFullIcon; 13 | public static Sprite SpeedIcon; 14 | public static Sprite GraphIcon; 15 | public static Sprite DeleteIcon; 16 | public static Sprite XIcon; 17 | public static Sprite DoubleArrow; 18 | public static Sprite RandomIcon; 19 | public static Sprite NoteStartOffsetIcon; 20 | public static Sprite PlaylistIcon; 21 | 22 | public static void Init() 23 | { 24 | SpeedIcon = Base64Sprites.LoadSpriteFromResources("SongBrowser.Assets.Speed.png"); 25 | GraphIcon = Base64Sprites.LoadSpriteFromResources("SongBrowser.Assets.Graph.png"); 26 | XIcon = Base64Sprites.LoadSpriteFromResources("SongBrowser.Assets.X.png"); 27 | StarFullIcon = Base64Sprites.LoadSpriteFromResources("SongBrowser.Assets.StarFull.png"); 28 | DeleteIcon = Base64Sprites.LoadSpriteFromResources("SongBrowser.Assets.DeleteIcon.png"); 29 | DoubleArrow = Base64Sprites.LoadSpriteFromResources("SongBrowser.Assets.DoubleArrow.png"); 30 | RandomIcon = Base64Sprites.LoadSpriteFromResources("SongBrowser.Assets.RandomIcon.png"); 31 | NoteStartOffsetIcon = Base64Sprites.LoadSpriteFromResources("SongBrowser.Assets.NoteStartOffset.png"); 32 | PlaylistIcon = Base64Sprites.LoadSpriteFromResources("SongBrowser.Assets.PlaylistIcon.png"); 33 | } 34 | 35 | public static string SpriteToBase64(Sprite input) 36 | { 37 | return Convert.ToBase64String(input.texture.EncodeToPNG()); 38 | } 39 | 40 | public static Sprite Base64ToSprite(string base64) 41 | { 42 | // prune base64 encoded image header 43 | Regex r = new Regex(@"data:image.*base64,"); 44 | base64 = r.Replace(base64, ""); 45 | 46 | Sprite s; 47 | try 48 | { 49 | Texture2D tex = Base64ToTexture2D(base64); 50 | s = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), (Vector2.one / 2f)); 51 | } 52 | catch (Exception) 53 | { 54 | Plugin.Log.Critical("Exception loading texture from base64 data."); 55 | s = null; 56 | } 57 | 58 | return s; 59 | } 60 | 61 | public static Texture2D Base64ToTexture2D(string encodedData) 62 | { 63 | byte[] imageData = Convert.FromBase64String(encodedData); 64 | 65 | GetImageSize(imageData, out int width, out int height); 66 | 67 | Texture2D texture = new Texture2D(width, height, TextureFormat.ARGB32, false, true) 68 | { 69 | hideFlags = HideFlags.HideAndDontSave, 70 | filterMode = FilterMode.Trilinear 71 | }; 72 | texture.LoadImage(imageData); 73 | return texture; 74 | } 75 | 76 | private static void GetImageSize(byte[] imageData, out int width, out int height) 77 | { 78 | width = ReadInt(imageData, 3 + 15); 79 | height = ReadInt(imageData, 3 + 15 + 2 + 2); 80 | } 81 | 82 | private static int ReadInt(byte[] imageData, int offset) 83 | { 84 | return (imageData[offset] << 8) | imageData[offset + 1]; 85 | } 86 | 87 | public static Texture2D LoadTextureRaw(byte[] file) 88 | { 89 | if (file.Count() > 0) 90 | { 91 | Texture2D Tex2D = new Texture2D(2, 2, TextureFormat.RGBA32, false, false); 92 | if (Tex2D.LoadImage(file)) 93 | return Tex2D; 94 | } 95 | return null; 96 | } 97 | 98 | public static Texture2D LoadTextureFromResources(string resourcePath) 99 | { 100 | return LoadTextureRaw(GetResource(Assembly.GetCallingAssembly(), resourcePath)); 101 | } 102 | 103 | public static Sprite LoadSpriteRaw(byte[] image, float PixelsPerUnit = 100.0f) 104 | { 105 | return LoadSpriteFromTexture(LoadTextureRaw(image), PixelsPerUnit); 106 | } 107 | 108 | public static Sprite LoadSpriteFromTexture(Texture2D SpriteTexture, float PixelsPerUnit = 100.0f) 109 | { 110 | if (SpriteTexture) 111 | return Sprite.Create(SpriteTexture, new Rect(0, 0, SpriteTexture.width, SpriteTexture.height), new Vector2(0, 0), PixelsPerUnit); 112 | return null; 113 | } 114 | 115 | public static Sprite LoadSpriteFromResources(string resourcePath, float PixelsPerUnit = 100.0f) 116 | { 117 | return LoadSpriteRaw(GetResource(Assembly.GetCallingAssembly(), resourcePath), PixelsPerUnit); 118 | } 119 | 120 | public static byte[] GetResource(Assembly asm, string ResourceName) 121 | { 122 | System.IO.Stream stream = asm.GetManifestResourceStream(ResourceName); 123 | byte[] data = new byte[stream.Length]; 124 | stream.Read(data, 0, (int)stream.Length); 125 | return data; 126 | } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # MSTest test Results 33 | [Tt]est[Rr]esult*/ 34 | [Bb]uild[Ll]og.* 35 | 36 | # NUNIT 37 | *.VisualState.xml 38 | TestResult.xml 39 | 40 | # Build Results of an ATL Project 41 | [Dd]ebugPS/ 42 | [Rr]eleasePS/ 43 | dlldata.c 44 | 45 | # .NET Core 46 | project.lock.json 47 | project.fragment.lock.json 48 | artifacts/ 49 | **/Properties/launchSettings.json 50 | 51 | *_i.c 52 | *_p.c 53 | *_i.h 54 | *.ilk 55 | *.meta 56 | *.obj 57 | *.pch 58 | *.pdb 59 | *.pgc 60 | *.pgd 61 | *.rsp 62 | *.sbr 63 | *.tlb 64 | *.tli 65 | *.tlh 66 | *.tmp 67 | *.tmp_proj 68 | *.log 69 | *.vspscc 70 | *.vssscc 71 | .builds 72 | *.pidb 73 | *.svclog 74 | *.scc 75 | 76 | # Chutzpah Test files 77 | _Chutzpah* 78 | 79 | # Visual C++ cache files 80 | ipch/ 81 | *.aps 82 | *.ncb 83 | *.opendb 84 | *.opensdf 85 | *.sdf 86 | *.cachefile 87 | *.VC.db 88 | *.VC.VC.opendb 89 | 90 | # Visual Studio profiler 91 | *.psess 92 | *.vsp 93 | *.vspx 94 | *.sap 95 | 96 | # TFS 2012 Local Workspace 97 | $tf/ 98 | 99 | # Guidance Automation Toolkit 100 | *.gpState 101 | 102 | # ReSharper is a .NET coding add-in 103 | _ReSharper*/ 104 | *.[Rr]e[Ss]harper 105 | *.DotSettings.user 106 | 107 | # JustCode is a .NET coding add-in 108 | .JustCode 109 | 110 | # TeamCity is a build add-in 111 | _TeamCity* 112 | 113 | # DotCover is a Code Coverage Tool 114 | *.dotCover 115 | 116 | # Visual Studio code coverage results 117 | *.coverage 118 | *.coveragexml 119 | 120 | # NCrunch 121 | _NCrunch_* 122 | .*crunch*.local.xml 123 | nCrunchTemp_* 124 | 125 | # MightyMoose 126 | *.mm.* 127 | AutoTest.Net/ 128 | 129 | # Web workbench (sass) 130 | .sass-cache/ 131 | 132 | # Installshield output folder 133 | [Ee]xpress/ 134 | 135 | # DocProject is a documentation generator add-in 136 | DocProject/buildhelp/ 137 | DocProject/Help/*.HxT 138 | DocProject/Help/*.HxC 139 | DocProject/Help/*.hhc 140 | DocProject/Help/*.hhk 141 | DocProject/Help/*.hhp 142 | DocProject/Help/Html2 143 | DocProject/Help/html 144 | 145 | # Click-Once directory 146 | publish/ 147 | 148 | # Publish Web Output 149 | *.[Pp]ublish.xml 150 | *.azurePubxml 151 | # TODO: Comment the next line if you want to checkin your web deploy settings 152 | # but database connection strings (with potential passwords) will be unencrypted 153 | *.pubxml 154 | *.publishproj 155 | 156 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 157 | # checkin your Azure Web App publish settings, but sensitive information contained 158 | # in these scripts will be unencrypted 159 | PublishScripts/ 160 | 161 | # NuGet Packages 162 | *.nupkg 163 | # The packages folder can be ignored because of Package Restore 164 | **/packages/* 165 | # except build/, which is used as an MSBuild target. 166 | !**/packages/build/ 167 | # Uncomment if necessary however generally it will be regenerated when needed 168 | #!**/packages/repositories.config 169 | # NuGet v3's project.json files produces more ignorable files 170 | *.nuget.props 171 | *.nuget.targets 172 | 173 | # Microsoft Azure Build Output 174 | csx/ 175 | *.build.csdef 176 | 177 | # Microsoft Azure Emulator 178 | ecf/ 179 | rcf/ 180 | 181 | # Windows Store app package directories and files 182 | AppPackages/ 183 | BundleArtifacts/ 184 | Package.StoreAssociation.xml 185 | _pkginfo.txt 186 | 187 | # Visual Studio cache files 188 | # files ending in .cache can be ignored 189 | *.[Cc]ache 190 | # but keep track of directories ending in .cache 191 | !*.[Cc]ache/ 192 | 193 | # Others 194 | ClientBin/ 195 | ~$* 196 | *~ 197 | *.dbmdl 198 | *.dbproj.schemaview 199 | *.jfm 200 | *.pfx 201 | *.publishsettings 202 | orleans.codegen.cs 203 | 204 | # Since there are multiple workflows, uncomment next line to ignore bower_components 205 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 206 | #bower_components/ 207 | 208 | # RIA/Silverlight projects 209 | Generated_Code/ 210 | 211 | # Backup & report files from converting an old project file 212 | # to a newer Visual Studio version. Backup files are not needed, 213 | # because we have git ;-) 214 | _UpgradeReport_Files/ 215 | Backup*/ 216 | UpgradeLog*.XML 217 | UpgradeLog*.htm 218 | 219 | # SQL Server files 220 | *.mdf 221 | *.ldf 222 | *.ndf 223 | 224 | # Business Intelligence projects 225 | *.rdl.data 226 | *.bim.layout 227 | *.bim_*.settings 228 | 229 | # Microsoft Fakes 230 | FakesAssemblies/ 231 | 232 | # GhostDoc plugin setting file 233 | *.GhostDoc.xml 234 | 235 | # Node.js Tools for Visual Studio 236 | .ntvs_analysis.dat 237 | node_modules/ 238 | 239 | # Typescript v1 declaration files 240 | typings/ 241 | 242 | # Visual Studio 6 build log 243 | *.plg 244 | 245 | # Visual Studio 6 workspace options file 246 | *.opt 247 | 248 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 249 | *.vbw 250 | 251 | # Visual Studio LightSwitch build output 252 | **/*.HTMLClient/GeneratedArtifacts 253 | **/*.DesktopClient/GeneratedArtifacts 254 | **/*.DesktopClient/ModelManifest.xml 255 | **/*.Server/GeneratedArtifacts 256 | **/*.Server/ModelManifest.xml 257 | _Pvt_Extensions 258 | 259 | # Paket dependency manager 260 | .paket/paket.exe 261 | paket-files/ 262 | 263 | # FAKE - F# Make 264 | .fake/ 265 | 266 | # JetBrains Rider 267 | .idea/ 268 | *.sln.iml 269 | 270 | # CodeRush 271 | .cr/ 272 | 273 | # Python Tools for Visual Studio (PTVS) 274 | __pycache__/ 275 | *.pyc 276 | 277 | # Cake - Uncomment if you are using it 278 | # tools/** 279 | # !tools/packages.config 280 | 281 | # Telerik's JustMock configuration file 282 | *.jmconfig 283 | 284 | # BizTalk build output 285 | *.btp.cs 286 | *.btm.cs 287 | *.odx.cs 288 | *.xsd.cs 289 | -------------------------------------------------------------------------------- /SongBrowserPlugin/SongBrowser.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net48 5 | Library 6 | 8 7 | disable 8 | false 9 | SongBrowser 10 | ..\Refs 11 | $(LocalRefsDir) 12 | $(MSBuildProjectDirectory)\ 13 | 14 | 15 | 16 | full 17 | 18 | 19 | 20 | pdbonly 21 | 22 | 23 | 24 | True 25 | 26 | 27 | 28 | True 29 | True 30 | 31 | 32 | 33 | 34 | $(BeatSaberDir)\Libs\0Harmony.dll 35 | 36 | 37 | $(BeatSaberDir)\Libs\BeatSaberPlaylistsLib.dll 38 | False 39 | 40 | 41 | D:\Games\Steam\SteamApps\common\Beat Saber\Plugins\CustomJSONData.dll 42 | 43 | 44 | D:\Games\Steam\SteamApps\common\Beat Saber\Libs\Hive.Versioning.dll 45 | 46 | 47 | 48 | $(BeatSaberDir)\Plugins\SiraUtil.dll 49 | 50 | 51 | $(BeatSaberDir)\Beat Saber_Data\Managed\Unity.TextMeshPro.dll 52 | False 53 | 54 | 55 | $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll 56 | False 57 | 58 | 59 | $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.ImageConversionModule.dll 60 | False 61 | 62 | 63 | $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UI.dll 64 | False 65 | 66 | 67 | $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UIModule.dll 68 | False 69 | 70 | 71 | $(BeatSaberDir)\Beat Saber_Data\Managed\HMLib.dll 72 | False 73 | 74 | 75 | $(BeatSaberDir)\Beat Saber_Data\Managed\HMUI.dll 76 | False 77 | 78 | 79 | $(BeatSaberDir)\Beat Saber_Data\Managed\Polyglot.dll 80 | False 81 | 82 | 83 | $(BeatSaberDir)\Beat Saber_Data\Managed\VRUI.dll 84 | False 85 | 86 | 87 | $(BeatSaberDir)\Beat Saber_Data\Managed\Main.dll 88 | False 89 | 90 | 91 | $(BeatSaberDir)\Beat Saber_Data\Managed\BeatmapCore.dll 92 | False 93 | 94 | 95 | $(BeatSaberDir)\Libs\Newtonsoft.Json.dll 96 | False 97 | 98 | 99 | $(BeatSaberDir)\Libs\SemVer.dll 100 | False 101 | 102 | 103 | $(BeatSaberDir)\Beat Saber_Data\Managed\IPA.Loader.dll 104 | False 105 | 106 | 107 | False 108 | $(BeatSaberDir)\Plugins\BSML.dll 109 | 110 | 111 | $(BeatSaberDir)\Plugins\BS_Utils.dll 112 | 113 | 114 | $(BeatSaberDir)\Plugins\SongCore.dll 115 | False 116 | 117 | 118 | $(BeatSaberDir)\Plugins\SongDataCore.dll 119 | False 120 | 121 | 122 | $(BeatSaberDir)\Beat Saber_Data\Managed\Zenject.dll 123 | 124 | 125 | $(BeatSaberDir)\Beat Saber_Data\Managed\Zenject-usage.dll 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | all 144 | runtime; build; native; contentfiles; analyzers; buildtransitive 145 | 146 | 147 | -------------------------------------------------------------------------------- /SongBrowserPlugin/Directory.Build.targets: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 2.0 7 | 8 | false 9 | 10 | $(OutputPath)$(AssemblyName) 11 | 12 | $(OutputPath)Final 13 | True 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | $(BasePluginVersion) 30 | $(BasePluginVersion) 31 | $(BasePluginVersion) 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | $(AssemblyName) 41 | $(ArtifactName)-$(PluginVersion) 42 | $(ArtifactName)-bs$(GameVersion) 43 | $(ArtifactName)-$(CommitHash) 44 | 45 | 46 | 47 | 48 | 49 | 50 | $(AssemblyName) 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | $(AssemblyName) 65 | $(OutDir)zip\ 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | $(BeatSaberDir)\Plugins 79 | True 80 | Unable to copy assembly to game folder, did you set 'BeatSaberDir' correctly in your 'csproj.user' file? Plugins folder doesn't exist: '$(PluginDir)'. 81 | 82 | Unable to copy to Plugins folder, '$(BeatSaberDir)' does not appear to be a Beat Saber game install. 83 | 84 | Unable to copy to Plugins folder, 'BeatSaberDir' has not been set in your 'csproj.user' file. 85 | False 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | $(BeatSaberDir)\IPA\Pending\Plugins 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /SongBrowserPlugin/SongBrowserApplication.cs: -------------------------------------------------------------------------------- 1 | using SongBrowser.UI; 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Concurrent; 5 | using UnityEngine; 6 | 7 | namespace SongBrowser 8 | { 9 | public class SongBrowserApplication : MonoBehaviour 10 | { 11 | public static SongBrowserApplication Instance; 12 | 13 | // Song Browser UI Elements 14 | private SongBrowserUI _songBrowserUI; 15 | private SongBrowserModel _songBrowserModel; 16 | 17 | public static SongBrowser.UI.ProgressBar MainProgressBar; 18 | 19 | private bool _hasShownProgressBar = false; 20 | 21 | 22 | public SongBrowserModel Model 23 | { 24 | get 25 | { 26 | return _songBrowserModel; 27 | } 28 | } 29 | 30 | public SongBrowserUI Ui 31 | { 32 | get 33 | { 34 | return _songBrowserUI; 35 | } 36 | } 37 | 38 | /// 39 | /// Load the main song browser app. 40 | /// 41 | internal static void OnLoad() 42 | { 43 | if (Instance != null) 44 | { 45 | return; 46 | } 47 | 48 | new GameObject("Beat Saber SongBrowser Plugin").AddComponent(); 49 | 50 | SongBrowserApplication.MainProgressBar = SongBrowser.UI.ProgressBar.Create(); 51 | 52 | Plugin.Log.Info("SongBrowser Plugin OnLoad Complete"); 53 | } 54 | 55 | /// 56 | /// It has awaken! 57 | /// 58 | protected void Awake() 59 | { 60 | Plugin.Log.Trace("Awake-SongBrowserApplication()"); 61 | 62 | Instance = this; 63 | 64 | // Init Model, load settings 65 | _songBrowserModel = new SongBrowserModel(); 66 | _songBrowserModel.Init(); 67 | 68 | // Init browser UI 69 | _songBrowserUI = gameObject.AddComponent(); 70 | _songBrowserUI.Model = _songBrowserModel; 71 | } 72 | 73 | /// 74 | /// Acquire any UI elements from Beat saber that we need. Wait for the song list to be loaded. 75 | /// 76 | public void Start() 77 | { 78 | Plugin.Log.Trace("Start-SongBrowserApplication()"); 79 | 80 | SongDataCore.Plugin.Songs.OnDataFinishedProcessing += OnScoreSaberDataDownloaded; 81 | 82 | if (SongCore.Loader.AreSongsLoaded) 83 | { 84 | OnSongLoaderLoadedSongs(null, SongCore.Loader.CustomLevels); 85 | } 86 | else 87 | { 88 | SongCore.Loader.SongsLoadedEvent += OnSongLoaderLoadedSongs; 89 | } 90 | 91 | // Useful to dump game objects. 92 | /*foreach (RectTransform rect in Resources.FindObjectsOfTypeAll()) 93 | { 94 | Plugin.Log.Debug($"RectTransform: {rect.name}"); 95 | }*/ 96 | 97 | /*foreach (Sprite sprite in Resources.FindObjectsOfTypeAll()) 98 | { 99 | Plugin.Log.Debug($"Adding Icon: {sprite.name}"); 100 | }*/ 101 | } 102 | 103 | /// 104 | /// Only gets called once during boot of BeatSaber. 105 | /// 106 | /// 107 | /// 108 | private void OnSongLoaderLoadedSongs(SongCore.Loader loader, ConcurrentDictionary levels) 109 | { 110 | Plugin.Log.Trace("OnSongLoaderLoadedSongs-SongBrowserApplication()"); 111 | try 112 | { 113 | _songBrowserUI.UpdateLevelDataModel(); 114 | _songBrowserUI.RefreshSongList(); 115 | } 116 | catch (Exception e) 117 | { 118 | Plugin.Log.Critical($"Exception during OnSongLoaderLoadedSongs: {e}"); 119 | } 120 | } 121 | 122 | /// 123 | /// Inform browser score saber data is available. 124 | /// 125 | /// 126 | /// 127 | private void OnScoreSaberDataDownloaded() 128 | { 129 | Plugin.Log.Trace("OnScoreSaberDataDownloaded"); 130 | try 131 | { 132 | // It is okay if SongDataCore beats us to initialization 133 | if (_songBrowserUI == null) 134 | { 135 | return; 136 | } 137 | 138 | StartCoroutine(_songBrowserUI.AsyncWaitForSongUIUpdate()); 139 | } 140 | catch (Exception e) 141 | { 142 | Plugin.Log.Critical($"Exception during OnScoreSaberDataDownloaded: {e}"); 143 | } 144 | } 145 | 146 | /// 147 | /// Handle Solo Mode 148 | /// 149 | /// 150 | /// 151 | public void HandleSoloModeSelection() 152 | { 153 | Plugin.Log.Trace("HandleSoloModeSelection()"); 154 | HandleModeSelection(MainMenuViewController.MenuButton.SoloFreePlay); 155 | _songBrowserUI.Show(); 156 | } 157 | 158 | /// 159 | /// Handle Party Mode 160 | /// 161 | /// 162 | /// 163 | public void HandlePartyModeSelection() 164 | { 165 | Plugin.Log.Trace("HandlePartyModeSelection()"); 166 | HandleModeSelection(MainMenuViewController.MenuButton.Party); 167 | _songBrowserUI.Show(); 168 | } 169 | 170 | /// 171 | /// Handle Party Mode 172 | /// 173 | /// 174 | /// 175 | public void HandleCampaignModeSelection() 176 | { 177 | Plugin.Log.Trace("HandleCampaignModeSelection()"); 178 | HandleModeSelection(MainMenuViewController.MenuButton.SoloCampaign); 179 | _songBrowserUI.Hide(); 180 | } 181 | 182 | /// 183 | /// Handle Multiplayer Mode. 184 | /// Triggers when level select is clicked inside a host lobby. 185 | /// 186 | /// 187 | /// 188 | public void HandleMultiplayerModeSelection() 189 | { 190 | Plugin.Log.Trace("HandleCampaignModeSelection()"); 191 | HandleModeSelection(MainMenuViewController.MenuButton.Multiplayer); 192 | _songBrowserUI.Hide(); 193 | } 194 | 195 | /// 196 | /// Handle Mode 197 | /// 198 | /// 199 | /// 200 | private void HandleModeSelection(MainMenuViewController.MenuButton mode) 201 | { 202 | Plugin.Log.Trace("HandleModeSelection()"); 203 | _songBrowserUI.CreateUI(mode); 204 | 205 | if (!_hasShownProgressBar) 206 | { 207 | SongBrowserApplication.MainProgressBar.ShowMessage(""); 208 | _hasShownProgressBar = true; 209 | } 210 | 211 | StartCoroutine(UpdateBrowserUI()); 212 | } 213 | 214 | /// 215 | /// Wait until the end of the frame to finish updating everything. 216 | /// 217 | /// 218 | public IEnumerator UpdateBrowserUI() 219 | { 220 | yield return new WaitForEndOfFrame(); 221 | 222 | _songBrowserUI.UpdateLevelDataModel(); 223 | _songBrowserUI.UpdateLevelCollectionSelection(true); 224 | _songBrowserUI.RefreshSongList(); 225 | } 226 | } 227 | } 228 | -------------------------------------------------------------------------------- /SongBrowserPlugin/UI/ProgressBar.cs: -------------------------------------------------------------------------------- 1 | using SongCore.Utilities; 2 | using System.Collections; 3 | using System.Collections.Concurrent; 4 | using TMPro; 5 | using UnityEngine; 6 | using UnityEngine.SceneManagement; 7 | using UnityEngine.UI; 8 | using SongCore; 9 | 10 | namespace SongBrowser.UI 11 | { 12 | /// 13 | /// Taken from SongCore, modified 14 | /// 15 | public class ProgressBar : MonoBehaviour 16 | { 17 | private Canvas _canvas; 18 | private TMP_Text _authorNameText; 19 | private TMP_Text _pluginNameText; 20 | private TMP_Text _headerText; 21 | internal Image _loadingBackg; 22 | internal Image _loadingBar; 23 | 24 | private static readonly Vector3 Position = new Vector3(0, 0, 3f); 25 | private static readonly Vector3 Rotation = Vector3.zero; 26 | private static readonly Vector3 Scale = new Vector3(0.01f, 0.01f, 0.01f); 27 | 28 | private static readonly Vector2 CanvasSize = new Vector2(200, 50); 29 | 30 | private const string AuthorNameText = "Halsafar"; 31 | private const float AuthorNameFontSize = 7f; 32 | private static readonly Vector2 AuthorNamePosition = new Vector2(10, 31); 33 | 34 | private readonly string PluginNameText = $"Song Browser - v{Plugin.VersionNumber}"; 35 | private const float PluginNameFontSize = 9f; 36 | private static readonly Vector2 PluginNamePosition = new Vector2(10, 23); 37 | 38 | private static readonly Vector2 HeaderPosition = new Vector2(10, 15); 39 | private static readonly Vector2 HeaderSize = new Vector2(100, 20); 40 | private const string HeaderText = "Processing songs..."; 41 | private const float HeaderFontSize = 15f; 42 | 43 | private static readonly Vector2 LoadingBarSize = new Vector2(100, 10); 44 | private static readonly Color BackgroundColor = new Color(0, 0, 0, 0.2f); 45 | 46 | private bool _showingMessage; 47 | 48 | public static ProgressBar Create() 49 | { 50 | return new GameObject("SongBrowserLoadingStatus").AddComponent(); 51 | } 52 | 53 | public void ShowMessage(string message, float time) 54 | { 55 | StopAllCoroutines(); 56 | _showingMessage = true; 57 | _headerText.text = message; 58 | _loadingBar.enabled = false; 59 | _loadingBackg.enabled = false; 60 | gameObject.SetActive(true); 61 | StartCoroutine(DisableCanvasRoutine(time)); 62 | } 63 | 64 | public void ShowMessage(string message) 65 | { 66 | StopAllCoroutines(); 67 | _showingMessage = true; 68 | _headerText.text = message; 69 | _loadingBar.enabled = false; 70 | _loadingBackg.enabled = false; 71 | gameObject.SetActive(true); 72 | } 73 | 74 | protected void OnEnable() 75 | { 76 | SceneManager.activeSceneChanged += SceneManagerOnActiveSceneChanged; 77 | SongBrowserModel.didFinishProcessingSongs += SongBrowserFinishedProcessingSongs; 78 | } 79 | 80 | protected void OnDisable() 81 | { 82 | SceneManager.activeSceneChanged -= SceneManagerOnActiveSceneChanged; 83 | SongBrowserModel.didFinishProcessingSongs -= SongBrowserFinishedProcessingSongs; 84 | } 85 | 86 | private void SceneManagerOnActiveSceneChanged(Scene oldScene, Scene newScene) 87 | { 88 | if (newScene.name == "MenuCore") 89 | { 90 | if (_showingMessage) 91 | { 92 | gameObject.SetActive(true); 93 | } 94 | } 95 | else 96 | { 97 | gameObject.SetActive(false); 98 | } 99 | } 100 | 101 | private void SongBrowserFinishedProcessingSongs(ConcurrentDictionary customLevels) 102 | { 103 | _showingMessage = false; 104 | _headerText.text = customLevels.Count + " songs processed."; 105 | _loadingBar.enabled = false; 106 | _loadingBackg.enabled = false; 107 | StartCoroutine(DisableCanvasRoutine(7f)); 108 | } 109 | 110 | private IEnumerator DisableCanvasRoutine(float time) 111 | { 112 | yield return new WaitForSecondsRealtime(time); 113 | gameObject.SetActive(false); 114 | _showingMessage = false; 115 | } 116 | 117 | protected void Awake() 118 | { 119 | gameObject.transform.position = Position; 120 | gameObject.transform.eulerAngles = Rotation; 121 | gameObject.transform.localScale = Scale; 122 | 123 | _canvas = gameObject.AddComponent(); 124 | _canvas.renderMode = RenderMode.WorldSpace; 125 | gameObject.AddComponent().SetRadius(0f); 126 | gameObject.SetActive(false); 127 | 128 | var ct = _canvas.transform; 129 | ct.position = Position; 130 | ct.localScale = Scale; 131 | 132 | var rectTransform = _canvas.transform as RectTransform; 133 | rectTransform.sizeDelta = CanvasSize; 134 | 135 | _authorNameText = BeatSaberMarkupLanguage.BeatSaberUI.CreateText(_canvas.transform as RectTransform, AuthorNameText, AuthorNamePosition); 136 | rectTransform = _authorNameText.transform as RectTransform; 137 | rectTransform.SetParent(_canvas.transform, false); 138 | rectTransform.anchoredPosition = AuthorNamePosition; 139 | rectTransform.sizeDelta = HeaderSize; 140 | _authorNameText.text = AuthorNameText; 141 | _authorNameText.fontSize = AuthorNameFontSize; 142 | 143 | _pluginNameText = BeatSaberMarkupLanguage.BeatSaberUI.CreateText(_canvas.transform as RectTransform, PluginNameText, PluginNamePosition); 144 | rectTransform = _pluginNameText.transform as RectTransform; 145 | rectTransform.SetParent(_canvas.transform, false); 146 | rectTransform.sizeDelta = HeaderSize; 147 | rectTransform.anchoredPosition = PluginNamePosition; 148 | _pluginNameText.text = PluginNameText; 149 | _pluginNameText.fontSize = PluginNameFontSize; 150 | 151 | _headerText = BeatSaberMarkupLanguage.BeatSaberUI.CreateText(_canvas.transform as RectTransform, HeaderText, HeaderPosition); 152 | rectTransform = _headerText.transform as RectTransform; 153 | rectTransform.SetParent(_canvas.transform, false); 154 | rectTransform.anchoredPosition = HeaderPosition; 155 | rectTransform.sizeDelta = HeaderSize; 156 | _headerText.text = HeaderText; 157 | _headerText.fontSize = HeaderFontSize; 158 | 159 | _loadingBackg = new GameObject("Background").AddComponent(); 160 | rectTransform = _loadingBackg.transform as RectTransform; 161 | rectTransform.SetParent(_canvas.transform, false); 162 | rectTransform.sizeDelta = LoadingBarSize; 163 | _loadingBackg.color = BackgroundColor; 164 | 165 | _loadingBar = new GameObject("Loading Bar").AddComponent(); 166 | rectTransform = _loadingBar.transform as RectTransform; 167 | rectTransform.SetParent(_canvas.transform, false); 168 | rectTransform.sizeDelta = LoadingBarSize; 169 | var tex = Texture2D.whiteTexture; 170 | var sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.one * 0.5f, 100, 1); 171 | _loadingBar.sprite = sprite; 172 | _loadingBar.type = Image.Type.Filled; 173 | _loadingBar.fillMethod = Image.FillMethod.Horizontal; 174 | _loadingBar.color = new Color(1, 1, 1, 0.5f); 175 | 176 | DontDestroyOnLoad(gameObject); 177 | } 178 | 179 | protected void Update() 180 | { 181 | if (!_canvas.enabled) return; 182 | _loadingBar.fillAmount = Loader.LoadingProgress; 183 | 184 | _loadingBar.color = HSBColor.ToColor(new HSBColor(Mathf.PingPong(Time.time * 0.35f, 1), 1, 1)); 185 | _headerText.color = HSBColor.ToColor(new HSBColor(Mathf.PingPong(Time.time * 0.35f, 1), 1, 1)); 186 | } 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /SongBrowserPlugin/Internals/BeatSaberUI.cs: -------------------------------------------------------------------------------- 1 | using BeatSaberMarkupLanguage.Components; 2 | using HMUI; 3 | using IPA.Utilities; 4 | using System; 5 | using System.Linq; 6 | using TMPro; 7 | using UnityEngine; 8 | using UnityEngine.Events; 9 | using UnityEngine.UI; 10 | using VRUIControls; 11 | using Image = UnityEngine.UI.Image; 12 | 13 | namespace SongBrowser.Internals 14 | { 15 | public static class BeatSaberUI 16 | { 17 | private static PhysicsRaycasterWithCache _physicsRaycaster; 18 | public static PhysicsRaycasterWithCache PhysicsRaycasterWithCache 19 | { 20 | get 21 | { 22 | if (_physicsRaycaster == null) 23 | _physicsRaycaster = Resources.FindObjectsOfTypeAll().First().GetComponent().GetField("_physicsRaycaster"); 24 | return _physicsRaycaster; 25 | } 26 | } 27 | 28 | /// 29 | /// Creates a ViewController of type T, and marks it to not be destroyed. 30 | /// 31 | /// The variation of ViewController you want to create. 32 | /// The newly created ViewController of type T. 33 | public static T CreateViewController(string name) where T : ViewController 34 | { 35 | T vc = new GameObject(typeof(T).Name, typeof(VRGraphicRaycaster), typeof(CanvasGroup), typeof(T)).GetComponent(); 36 | vc.GetComponent().SetField("_physicsRaycaster", PhysicsRaycasterWithCache); 37 | 38 | vc.rectTransform.anchorMin = new Vector2(0f, 0f); 39 | vc.rectTransform.anchorMax = new Vector2(1f, 1f); 40 | vc.rectTransform.sizeDelta = new Vector2(0f, 0f); 41 | vc.rectTransform.anchoredPosition = new Vector2(0f, 0f); 42 | vc.gameObject.SetActive(false); 43 | vc.name = name; 44 | return vc; 45 | } 46 | 47 | public static T CreateCurvedViewController(string name, float curveRadius) where T : ViewController 48 | { 49 | T vc = new GameObject(typeof(T).Name, typeof(VRGraphicRaycaster), typeof(CurvedCanvasSettings), typeof(CanvasGroup), typeof(T)).GetComponent(); 50 | vc.GetComponent().SetField("_physicsRaycaster", PhysicsRaycasterWithCache); 51 | 52 | vc.GetComponent().SetRadius(curveRadius); 53 | 54 | vc.rectTransform.anchorMin = new Vector2(0f, 0f); 55 | vc.rectTransform.anchorMax = new Vector2(1f, 1f); 56 | vc.rectTransform.sizeDelta = new Vector2(0f, 0f); 57 | vc.rectTransform.anchoredPosition = new Vector2(0f, 0f); 58 | vc.gameObject.SetActive(false); 59 | return vc; 60 | } 61 | 62 | /// 63 | /// Create Base button 64 | /// 65 | /// 66 | /// 67 | /// 68 | /// 69 | public static Button CreateBaseButton(String name, RectTransform parent, String buttonTemplate) 70 | { 71 | Button btn = UnityEngine.Object.Instantiate(Resources.FindObjectsOfTypeAll