public void OnStart() { if (Instance != null) { return; } Instance = this; Dispatcher.Initialize(); // create our internal webclient WebClient = new WebClient(); SongBrowserPluginPresent = IPA.Loader.PluginManager.GetPlugin("Song Browser") != null; // setup handle for fresh menu scene changes BS_Utils.Utilities.BSEvents.OnLoad(); BS_Utils.Utilities.BSEvents.menuSceneLoadedFresh += OnMenuSceneLoadedFresh; // keep track of active scene BS_Utils.Utilities.BSEvents.menuSceneActive += () => { IsAtMainMenu = true; }; BS_Utils.Utilities.BSEvents.gameSceneActive += () => { IsAtMainMenu = false; }; // init sprites Base64Sprites.Init(); }
public void OnStart() { if (Instance != null) { return; } Instance = this; // create playlists folder if needed if (!Directory.Exists(DataPath)) { Directory.CreateDirectory(DataPath); } Dispatcher.Initialize(); // create our internal webclient WebClient = new WebClient(); // create udp listener UdpListener = new UdpListener(); SongBrowserPluginPresent = IPA.Loader.PluginManager.GetPlugin("Song Browser") != null; // setup handle for fresh menu scene changes BS_Utils.Utilities.BSEvents.OnLoad(); BS_Utils.Utilities.BSEvents.menuSceneLoadedFresh += OnMenuSceneLoadedFresh; // keep track of active scene BS_Utils.Utilities.BSEvents.menuSceneActive += () => { IsAtMainMenu = true; }; BS_Utils.Utilities.BSEvents.gameSceneActive += () => { IsAtMainMenu = false; }; // init sprites Base64Sprites.Init(); }
public IEnumerator SavePlaylistCoroutine(string path = "") { Logger.Log($"Saving playlist \"{playlistTitle}\"..."); try { image = Base64Sprites.SpriteToBase64(icon); songCount = songs.Count; }catch (Exception e) { Logger.Exception("Unable to save playlist! Exception: " + e); yield break; } foreach (PlaylistSong song in songs) { yield return(song.MatchKey()); } try { if (!string.IsNullOrEmpty(path)) { fileLoc = Path.GetFullPath(path); } File.WriteAllText(fileLoc, JsonConvert.SerializeObject(this)); Logger.Log("Playlist saved!"); } catch (Exception e) { Logger.Exception("Unable to save playlist! Exception: " + e); yield break; } }
public void OnApplicationStart() { SceneManager.sceneLoaded += SceneManager_sceneLoaded; SceneManager.activeSceneChanged += SceneManager_activeSceneChanged; Base64Sprites.Init(); }
public void OnApplicationStart() { BSEvents.OnLoad(); BSEvents.menuSceneLoadedFresh += OnMenuSceneLoadedFresh; config = new BS_Utils.Utilities.Config("MVP"); Base64Sprites.ConvertToSprites(); }
public void OnApplicationStart() { Instance = this; BSEvents.OnLoad(); BSEvents.menuSceneLoadedFresh += OnMenuSceneLoadedFresh; Base64Sprites.ConvertToSprites(); Application.logMessageReceived += LogCallback; }
public void OnApplicationStart() { BSMLSettings.instance.AddSettingsMenu("MVP", "MusicVideoPlayer.Views.settings.bsml", MVPSettings.instance); GameplaySetup.instance.AddTab("Video", "MusicVideoPlayer.Views.video-menu.bsml", VideoMenu.instance); BSEvents.OnLoad(); BSEvents.menuSceneLoadedFresh += OnMenuSceneLoadedFresh; Base64Sprites.ConvertToSprites(); }
public void OnApplicationStart() { Instance = this; Base64Sprites.Init(); BSEvents.OnLoad(); BSEvents.lateMenuSceneLoadedFresh += OnMenuSceneLoadedFresh; }
public void OnApplicationStart() { SceneManager.sceneLoaded += SceneManager_sceneLoaded; SceneManager.activeSceneChanged += SceneManager_activeSceneChanged; PluginConfig.LoadOrCreateConfig(); Base64Sprites.ConvertToSprites(); PlaylistsCollection.ReloadPlaylists(); SongLoader.SongsLoadedEvent += SongLoader_SongsLoadedEvent; }
public void OnApplicationStart() { Instance = this; IsCustomJsonDataEnabled = PluginManager.EnabledPlugins.FirstOrDefault(p => p.Name == "CustomJSONData")?.Version >= new SemVer.Version("2.0.0"); Base64Sprites.Init(); BSEvents.OnLoad(); BSEvents.lateMenuSceneLoadedFresh += OnMenuSceneLoadedFresh; }
public void OnApplicationStart() { // BSMLSettings.instance.AddSettingsMenu("Music Video Player", "MusicVideoPlayer.Views.settings.bsml", CVPSettings.instance); GameplaySetup.instance.AddTab("CustomVideo", "CustomVideoPlayer.Views.video-menu.bsml", VideoMenu.instance); BSEvents.OnLoad(); BSEvents.lateMenuSceneLoadedFresh += OnMenuSceneLoadedFresh; _harmonyInstance = new Harmony(HARMONY_ID); ApplyHarmonyPatches(); Base64Sprites.ConvertToSprites(); }
public void OnApplicationStart() { Settings.Init(); SettingsUI.CreateMenu(); GameplaySetup.instance.AddTab("Video", "MusicVideoPlayer.UI.Views.video-menu.bsml", VideoMenu.instance); BSEvents.OnLoad(); BSEvents.lateMenuSceneLoadedFresh += OnMenuSceneLoadedFresh; // BSEvents.menuSceneLoaded += OnMenuSceneLoaded; // BSEvents.menuSceneActive += OnMenuSceneLoaded; // BSEvents.gameSceneLoaded += OnMenuSceneLoaded; Base64Sprites.ConvertToSprites(); }
public void OnStart() { if (!Directory.Exists(DataPath)) { Directory.CreateDirectory(DataPath); } SongBrowserPluginPresent = PluginManager.GetPlugin("Song Browser") != null; BSEvents.lateMenuSceneLoadedFresh += this.BSEvents_lateMenuSceneLoadedFresh; // init sprites Base64Sprites.Init(); }
public void OnApplicationStart() { Instance = this; PluginConfig.LoadOrCreateConfig(); Base64Sprites.Init(); PlaylistsCollection.ReloadPlaylists(); SongCore.Loader.SongsLoadedEvent += SongCore_SongsLoadedEvent; BSEvents.OnLoad(); BSEvents.menuSceneLoadedFresh += OnMenuSceneLoadedFresh; }
public void OnApplicationStart() { SceneManager.sceneLoaded += SceneManager_sceneLoaded; SceneManager.activeSceneChanged += SceneManager_activeSceneChanged; PluginConfig.LoadOrCreateConfig(); Base64Sprites.Init(); PlaylistsCollection.ReloadPlaylists(); SongLoader.SongsLoadedEvent += SongLoader_SongsLoadedEvent; BSEvents.OnLoad(); BSEvents.menuSceneLoadedFresh += OnMenuSceneLoadedFresh; }
public void OnApplicationStart() { if (Instance != null) { return; } Instance = this; // setup handle for fresh menu scene changes CustomUI.Utilities.BSEvents.OnLoad(); CustomUI.Utilities.BSEvents.menuSceneLoadedFresh += OnMenuSceneLoadedFresh; // keep track of active scene CustomUI.Utilities.BSEvents.menuSceneActive += () => { IsAtMainMenu = true; }; CustomUI.Utilities.BSEvents.gameSceneActive += () => { IsAtMainMenu = false; }; // init sprites Base64Sprites.Init(); }
public void OnStart() { if (Instance != null) { return; } Instance = this; // create SRM UserDataFolder folder if needed, or rename old streamcore folder if (!Directory.Exists(DataPath)) { if (Directory.Exists(OldDataPath)) { Directory.Move(OldDataPath, DataPath); } else { Directory.CreateDirectory(DataPath); } } // initialize config RequestBotConfig = new RequestBotConfig(); Dispatcher.Initialize(); // create our internal webclient WebClient = new WebClient(); // create udp listener UdpListener = new UdpListener(); SongBrowserPluginPresent = IPA.Loader.PluginManager.GetPlugin("Song Browser") != null; ChatCorePluginPresent = IPA.Loader.PluginManager.GetPlugin("ChatCore") != null; // setup handle for fresh menu scene changes BS_Utils.Utilities.BSEvents.OnLoad(); BS_Utils.Utilities.BSEvents.lateMenuSceneLoadedFresh += OnLateMenuSceneLoadedFresh; // init sprites Base64Sprites.Init(); }
/// <summary> /// Favorites used to exist as part of the song_browser_settings.xml /// This makes little sense now. This is the upgrade path. /// Convert all existing favorites to the best of our effort into a playlist. /// </summary> /// <param name="levelIdToCustomLevel"></param> /// <param name="levelIdToSongVersion"></param> public void ConvertFavoritesToPlaylist(Dictionary <String, CustomPreviewBeatmapLevel> customSongsMap) { // map songs in case we are converting a huge list Dictionary <String, CustomPreviewBeatmapLevel> levelIdToCustomLevel = new Dictionary <string, CustomPreviewBeatmapLevel>(StringComparer.OrdinalIgnoreCase); foreach (var kp in customSongsMap) { if (levelIdToCustomLevel.ContainsKey(kp.Value.levelID)) { continue; } levelIdToCustomLevel.Add(kp.Value.levelID, kp.Value); } // Check if we have favorites to convert to the playlist if (this.Favorites.Count <= 0) { return; } // check if the playlist exists String playlistPath = Path.Combine(Environment.CurrentDirectory, "Playlists", DefaultConvertedFavoritesPlaylistName); bool playlistExists = false; if (File.Exists(playlistPath)) { playlistExists = true; } // abort here if playlist already exits. if (playlistExists) { Logger.Info("Not converting song_browser_setting.xml favorites because {0} already exists...", playlistPath); return; } Logger.Info("Converting {0} Favorites in song_browser_settings.xml to {1}...", this.Favorites.Count, playlistPath); // written like this in case we ever want to support adding to this playlist Playlist p = null; if (playlistExists) { p = Playlist.LoadPlaylist(playlistPath); } else { p = new Playlist { playlistTitle = "Song Browser Favorites", playlistAuthor = "SongBrowser", fileLoc = "", image = Base64Sprites.SpriteToBase64(Base64Sprites.BeastSaberLogo), songs = new List <PlaylistSong>(), }; } List <String> successfullyRemoved = new List <string>(); this.Favorites.RemoveWhere(levelId => { PlaylistSong playlistSong = new PlaylistSong { levelId = levelId }; if (levelIdToCustomLevel.ContainsKey(levelId)) { playlistSong.songName = levelIdToCustomLevel[levelId].songName; playlistSong.levelId = levelId; playlistSong.hash = CustomHelpers.GetSongHash(levelId); } else { // No easy way to look up original songs... They will still work but have wrong song name in playlist. playlistSong.levelId = levelId; playlistSong.hash = CustomHelpers.GetSongHash(levelId); playlistSong.key = ""; } p.songs.Add(playlistSong); return(true); }); p.SavePlaylist(playlistPath); if (String.IsNullOrEmpty(this.currentEditingPlaylistFile)) { this.currentEditingPlaylistFile = playlistPath; } this.Save(); }
private async void SetDataFromLevelAsync(SongRequest request, LevelListTableCell _tableCell, int row) { var favouritesBadge = _tableCell.GetField <Image, LevelListTableCell>("_favoritesBadgeImage"); favouritesBadge.enabled = false; var highlight = (request.requestInfo.Length > 0) && (request.requestInfo[0] == '!'); var msg = highlight ? "MSG" : ""; var hasMessage = (request.requestInfo.Length > 0) && (request.requestInfo[0] == '!'); var isChallenge = request.requestInfo.IndexOf("!challenge", StringComparison.OrdinalIgnoreCase) >= 0; var pp = ""; var ppvalue = request.song["pp"].AsInt; if (ppvalue > 0) { pp = $" {ppvalue} PP"; } var dt = new RequestBot.DynamicText().AddSong(request.song).AddUser(ref request.requestor); // Get basic fields dt.Add("Status", request.status.ToString()); dt.Add("Info", (request.requestInfo != "") ? " / " + request.requestInfo : ""); dt.Add("RequestTime", request.requestTime.ToLocalTime().ToString("hh:mm")); var songDurationText = _tableCell.GetField <TextMeshProUGUI, LevelListTableCell>("_songDurationText"); songDurationText.text = request.song["songlength"].Value; var songBpm = _tableCell.GetField <TextMeshProUGUI, LevelListTableCell>("_songBpmText"); (songBpm.transform as RectTransform).anchoredPosition = new Vector2(-2.5f, -1.8f); (songBpm.transform as RectTransform).sizeDelta += new Vector2(15f, 0f); var k = new List <string>(); if (hasMessage) { k.Add("MSG"); } if (isChallenge) { k.Add("VS"); } k.Add(request.song["id"]); songBpm.text = string.Join(" - ", k); var songBmpIcon = _tableCell.GetComponentsInChildren <Image>().LastOrDefault(c => string.Equals(c.name, "BpmIcon", StringComparison.OrdinalIgnoreCase)); if (songBmpIcon != null) { Destroy(songBmpIcon); } var songName = _tableCell.GetField <TextMeshProUGUI, LevelListTableCell>("_songNameText"); songName.richText = true; songName.text = $"{request.song["songName"].Value} <size=50%>{RequestBot.GetRating(ref request.song)} <color=#3fff3f>{pp}</color></size>"; var author = _tableCell.GetField <TextMeshProUGUI, LevelListTableCell>("_songAuthorText"); author.richText = true; author.text = dt.Parse(RequestBot.QueueListRow2); var image = _tableCell.GetField <Image, LevelListTableCell>("_coverImage"); var imageSet = false; if (SongCore.Loader.AreSongsLoaded) { var level = CustomLevelForRow(row); if (level != null) { // set image from song's cover image var sprite = await level.GetCoverImageAsync(System.Threading.CancellationToken.None); image.sprite = sprite; imageSet = true; } } if (!imageSet) { var url = request.song["coverURL"].Value; if (!_cachedTextures.TryGetValue(url, out var tex)) { var b = await Plugin.WebClient.DownloadImage($"{url}", System.Threading.CancellationToken.None); tex = new Texture2D(2, 2); tex.LoadImage(b); try { _cachedTextures.Add(url, tex); } catch (Exception) { // ignored } } image.sprite = Base64Sprites.Texture2DToSprite(tex); } UIHelper.AddHintText(_tableCell.transform as RectTransform, dt.Parse(RequestBot.SongHintText)); }
private static void GameplaySettingsUISetup() { /* * MODIFIERS */ Sprite sprite = Base64Sprites.Base64ToSprite("iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA3WAAAN1gGQb3mcAAAAB3RJTUUH4wINFyAWrJdsNwAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4yMfEgaZUAAAKSSURBVEhL3dbLq05RHMbxEzEhuQ0OBi4DDDAxcSlDE1ISCgMGDAgTt8iACRMlyW0kKSZMKIRcBsQAfwGRiUK5RLm9vs9u/XbrXefZ+30z9KvP6V3Puuxz9nv2Wnug0+n8q4d4UGR9s2GffuBnkfXNhn36fy68Cd+xIcuc9/hQZCWtobU2Zlmlq5GswR/8QtvF5ySuTzRXa2it1SmrdTUyOxAX1y9S9o9FXFify/61iItqrbK/9TuOi99I7WFYj8f4jSh9foR10BiNvYXGi4oNMwswCRNwD1Gf8CTR56i70FjN0Vy3ZsWGhdF4AdUr6PsagegfCX0d6lM9xyjkawxhw8JZqLTgRLgxor74BU/BjanZMDMDela/YVrK2mi8Hh/NmZ4yy4aZPVCdget3zkG1C66/oh/jsRN7k92I5/MyVCvRNbHFKqguQe250Jqxvq41Th0HUFacOneqVqezCLFwLxqr0ly1dYqVtV8d+tc/jKPJEcSjcBWq5YiFe1kB1RWovRBaM9Y/hMFyUukgVMfh+p0TUOlOuv6KDTOzoR1Im8SUlLXRmM/QbjYzZZYNCxehuo984yipL3a3C3BjajYsaAt8CdVJuDESt1hjNceNqdkwo1sdJ9EXqNxppdNI9RXzoDmzUI6r2TCJ8/RaautkUr3GcMQ43eK3UMX5fR2t57kNkR/im1Mmz6BagsiWKqCeIrIt0NzGiw8JoGe26RCP7VC7UuxEel5V5SOXv0wsS1mtq5Fsgx4Hd4gfQ1NpEyrHaw2ttTXLKl2NzBiTyVTorz5fOI1BuDl2rSFBD/vQVNvh5lg2bLEYep+6XbiJ+XBzLBv2oBeCN/iYaMPQQePGNrJhD3rL0It81DtMhhvboDPwF6eIOFNA61CjAAAAAElFTkSuQmCC"); ToggleOption lightshowModifier = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.ModifiersLeft, "Lightshow Only", hintText: "Disables all notes and sabers, allowing you to view the lightshow!", optionIcon: sprite); lightshowModifier.GetValue = ChromaConfig.LightshowModifier; lightshowModifier.OnToggle += LightshowToggled; /* * COLOURS */ GameplaySettingsUI.CreateSubmenuOption(GameplaySettingsPanels.PlayerSettingsRight, "Chroma Colours", "MainMenu", "CTC", "Choose your Colour Scheme and more!"); ToggleOption technicolourToggle = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.PlayerSettingsRight, "Technicolour", "CTC", "Enable/Disable Technicolour. See Technicolour options below."); technicolourToggle.GetValue = ChromaConfig.TechnicolourEnabled; technicolourToggle.OnToggle += TechnicolourToggled; technicolourToggle.AddConflict("RNG PLights"); /* * EVENTS */ GameplaySettingsUI.CreateSubmenuOption(GameplaySettingsPanels.PlayerSettingsRight, "Chroma Events", "MainMenu", "CTE", "Toggle RGB lighting and special events"); ToggleOption rgbLightsToggle = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.PlayerSettingsRight, "RGB Lights", "CTE", "Enable/Disable RGB lighting events."); rgbLightsToggle.GetValue = ChromaConfig.CustomColourEventsEnabled; rgbLightsToggle.OnToggle += RGBEventsToggled; rgbLightsToggle.AddConflict("Darth Maul"); ToggleOption specialEventsToggle = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.PlayerSettingsRight, "Special Events", "CTE", "Enable/Disable Special Events, such as note size changing, player heal/harm events, and rotation events."); specialEventsToggle.GetValue = ChromaConfig.CustomSpecialEventsEnabled; specialEventsToggle.OnToggle += SpecialEventsToggled; specialEventsToggle.AddConflict("Darth Maul"); GameplaySettingsUI.CreateSubmenuOption(GameplaySettingsPanels.PlayerSettingsRight, "Techni. Options", "CTC", "CTT", "Adjust Technicolour Settings."); List <Tuple <float, string> > technicolourOptions = new List <Tuple <float, string> > { { 0f, "OFF" }, { 1f, "WARM/COLD" }, { 2f, "EITHER" }, { 3f, "TRUE RANDOM" } }; //float[] techniOptions = new float[technicolourOptions.Count]; //for (int i = 0; i < technicolourOptions.Count; i++) techniOptions[i] = i; MultiSelectOption techniLights = GameplaySettingsUI.CreateListOption(GameplaySettingsPanels.PlayerSettingsRight, "Tech. Lights", "CTT", "Technicolour style of the lights."); for (int i = 0; i < technicolourOptions.Count; i++) { techniLights.AddOption(i, technicolourOptions[i].Item2); } techniLights.GetValue += delegate { return((int)ChromaConfig.TechnicolourLightsStyle); }; techniLights.OnChange += delegate(float value) { ColourManager.TechnicolourStyle style = ColourManager.GetTechnicolourStyleFromFloat(value); ChromaConfig.TechnicolourLightsStyle = style; }; MultiSelectOption techniLightsGrouping = GameplaySettingsUI.CreateListOption(GameplaySettingsPanels.PlayerSettingsRight, "Lights Grouping", "CTT", ChromaConfig.WaiverRead ? "The more isolated, the more intense. Isolated Event has the best performance.\n <color=red>Mayhem prevents fades and flashes from working properly</color>." : "Isolated Event for better performance, but more chaotic lighting"); techniLightsGrouping.AddOption(0f, "Standard"); techniLightsGrouping.AddOption(1f, "Isolated Event"); if (ChromaConfig.WaiverRead) { techniLightsGrouping.AddOption(2f, "Isolated (Mayhem)"); } techniLightsGrouping.GetValue += delegate { return((int)ChromaConfig.TechnicolourLightsGrouping); }; techniLightsGrouping.OnChange += delegate(float value) { ChromaConfig.TechnicolourLightsGrouping = ColourManager.GetTechnicolourLightsGroupingFromFloat(value); }; MultiSelectOption techniFrequency = GameplaySettingsUI.CreateListOption(GameplaySettingsPanels.PlayerSettingsRight, "Lights Freq", "CTT", "The higher the frequency, the more colour changes. 10% is default."); for (int i = 1; i <= 20; i++) { techniFrequency.AddOption(0.05f * i, i == 2 ? "10% (Def)" : (5f * i) + "%"); } techniFrequency.GetValue += delegate { return(ChromaConfig.TechnicolourLightsFrequency); }; techniFrequency.OnChange += delegate(float value) { ChromaConfig.TechnicolourLightsFrequency = value; }; /*ToggleOption techniIndividualLights = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.PlayerSettingsRight, "Isolated Lights", "CTT", "If enabled, Technicolour will only affect one light source at a time. This results in much, much more colour variety being possible, but also can look excessively chaotic."); * techniIndividualLights.GetValue = ChromaConfig.TechnicolourLightsIndividual; * techniIndividualLights.OnToggle += delegate (bool value) { * ChromaConfig.TechnicolourLightsIndividual = value; * };*/ /*MultiSelectOption techniBarriers = GameplaySettingsUI.CreateListOption(GameplaySettingsPanels.PlayerSettingsRight, "Tech. Walls", "CTT", "Technicolour style of the walls/barriers."); * for (int i = 0; i < technicolourOptions.Count; i++) techniBarriers.AddOption(i, technicolourOptions[i].Item2); * techniBarriers.GetValue += delegate { * return (int)ChromaConfig.TechnicolourWallsStyle; * }; * techniBarriers.OnChange += delegate (float value) { * ColourManager.TechnicolourStyle style = ColourManager.GetTechnicolourStyleFromFloat(value); * ChromaConfig.TechnicolourWallsStyle = style; * };*/ //Walls don't need to have other options since they only work nicely with Either ToggleOption techniWalls = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.PlayerSettingsRight, "Tech. Barriers", "CTT", "If enabled, Barriers will rainbowify!"); techniWalls.GetValue = ChromaConfig.TechnicolourWallsStyle == ColourManager.TechnicolourStyle.ANY_PALETTE; techniWalls.OnToggle += delegate(bool value) { ChromaConfig.TechnicolourWallsStyle = value ? ColourManager.TechnicolourStyle.ANY_PALETTE : ColourManager.TechnicolourStyle.OFF; }; MultiSelectOption techniBlocks = GameplaySettingsUI.CreateListOption(GameplaySettingsPanels.PlayerSettingsRight, "Tech. Blocks", "CTT", "Technicolour style of the blocks."); for (int i = 0; i < technicolourOptions.Count; i++) { techniBlocks.AddOption(i, technicolourOptions[i].Item2); } techniBlocks.GetValue += delegate { return((int)ChromaConfig.TechnicolourBlocksStyle); }; techniBlocks.OnChange += delegate(float value) { ColourManager.TechnicolourStyle style = ColourManager.GetTechnicolourStyleFromFloat(value); ChromaConfig.TechnicolourBlocksStyle = style; }; MultiSelectOption techniSsabers = GameplaySettingsUI.CreateListOption(GameplaySettingsPanels.PlayerSettingsRight, "Tech. Sabers", "CTT", "Technicolour style of the sabers."); for (int i = 0; i < technicolourOptions.Count; i++) { techniSsabers.AddOption(i, technicolourOptions[i].Item2); } techniSsabers.GetValue += delegate { return((int)ChromaConfig.TechnicolourSabersStyle); }; techniSsabers.OnChange += delegate(float value) { ColourManager.TechnicolourStyle style = ColourManager.GetTechnicolourStyleFromFloat(value); ChromaConfig.TechnicolourSabersStyle = style; }; ToggleOption techniSabersMismatch = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.PlayerSettingsRight, "Desync Sabers", "CTT", "If true, technicolour sabers will have their \"time\" start and progress differently, resulting in their colours not matching so often."); techniSabersMismatch.GetValue = !ChromaConfig.MatchTechnicolourSabers; techniSabersMismatch.OnToggle += TechnicolourSaberMismatchToggled; GameplaySubMenuCreatedEvent?.Invoke("CTC"); GameplaySubMenuCreatedEvent?.Invoke("CTE"); GameplaySubMenuCreatedEvent?.Invoke("CTT"); ExtensionGameplayMenusEvent?.Invoke(); }
/// <summary> /// Get the song cache from the game. /// </summary> public void UpdateLevelRecords() { Stopwatch timer = new Stopwatch(); timer.Start(); // Calculate some information about the custom song dir String customSongsPath = Path.Combine(Environment.CurrentDirectory, CUSTOM_SONGS_DIR); String revSlashCustomSongPath = customSongsPath.Replace('\\', '/'); double currentCustomSongDirLastWriteTIme = (File.GetLastWriteTimeUtc(customSongsPath) - EPOCH).TotalMilliseconds; bool customSongDirChanged = false; if (_customSongDirLastWriteTime != currentCustomSongDirLastWriteTIme) { customSongDirChanged = true; _customSongDirLastWriteTime = currentCustomSongDirLastWriteTIme; } if (!Directory.Exists(customSongsPath)) { Logger.Error("CustomSong directory is missing..."); return; } // Map some data for custom songs Regex r = new Regex(@"(\d+-\d+)", RegexOptions.IgnoreCase); Stopwatch lastWriteTimer = new Stopwatch(); lastWriteTimer.Start(); foreach (KeyValuePair <string, CustomPreviewBeatmapLevel> level in SongCore.Loader.CustomLevels) { // If we already know this levelID, don't both updating it. // SongLoader should filter duplicates but in case of failure we don't want to crash if (!_cachedLastWriteTimes.ContainsKey(level.Value.levelID) || customSongDirChanged) { double lastWriteTime = GetSongUserDate(level.Value); _cachedLastWriteTimes[level.Value.levelID] = lastWriteTime; } } lastWriteTimer.Stop(); Logger.Info("Determining song download time and determining mappings took {0}ms", lastWriteTimer.ElapsedMilliseconds); // Update song Infos, directory tree, and sort this.UpdatePlayCounts(); // Check if we need to upgrade settings file favorites try { this.Settings.ConvertFavoritesToPlaylist(SongCore.Loader.CustomLevels); } catch (Exception e) { Logger.Exception("FAILED TO CONVERT FAVORITES TO PLAYLIST!", e); } // load the current editing playlist or make one if (CurrentEditingPlaylist == null && !String.IsNullOrEmpty(this.Settings.currentEditingPlaylistFile)) { Logger.Debug("Loading playlist for editing: {0}", this.Settings.currentEditingPlaylistFile); CurrentEditingPlaylist = Playlist.LoadPlaylist(this.Settings.currentEditingPlaylistFile); PlaylistsCollection.MatchSongsForPlaylist(CurrentEditingPlaylist, true); } if (CurrentEditingPlaylist == null) { Logger.Debug("Current editing playlist does not exit, create..."); CurrentEditingPlaylist = new Playlist { playlistTitle = "Song Browser Favorites", playlistAuthor = "SongBrowser", fileLoc = this.Settings.currentEditingPlaylistFile, image = Base64Sprites.SpriteToBase64(Base64Sprites.BeastSaberLogo), songs = new List <PlaylistSong>(), }; } CurrentEditingPlaylistLevelIds = new HashSet <string>(); foreach (PlaylistSong ps in CurrentEditingPlaylist.songs) { // Sometimes we cannot match a song string levelId = null; if (ps.level != null) { levelId = ps.level.levelID; } else if (!String.IsNullOrEmpty(ps.levelId)) { levelId = ps.levelId; } else { //Logger.Debug("MISSING SONG {0}", ps.songName); continue; } CurrentEditingPlaylistLevelIds.Add(levelId); } // Signal complete if (SongCore.Loader.CustomLevels.Count > 0) { didFinishProcessingSongs?.Invoke(SongCore.Loader.CustomLevels); } timer.Stop(); Logger.Info("Updating songs infos took {0}ms", timer.ElapsedMilliseconds); }
/// <summary> /// Load the settings file for this plugin. /// If we fail to load return Default settings. /// </summary> /// <returns>SongBrowserSettings</returns> public static SongBrowserSettings Load() { Logger.Trace("Load()"); SongBrowserSettings retVal = null; // No Settings file. String settingsFilePath = SongBrowserSettings.SettingsPath(); if (File.Exists(settingsFilePath)) { // Deserialization from JSON FileStream fs = null; try { fs = File.OpenRead(settingsFilePath); XmlSerializer serializer = new XmlSerializer(typeof(SongBrowserSettings)); retVal = (SongBrowserSettings)serializer.Deserialize(fs); // Success loading, sane time to make a backup retVal.SaveBackup(); } catch (Exception e) { Logger.Exception("Unable to deserialize song browser settings file, using default settings: ", e); retVal = new SongBrowserSettings { DisableSavingSettings = true }; } finally { if (fs != null) { fs.Close(); } } } else { Logger.Debug("Settings file does not exist, returning defaults: " + settingsFilePath); retVal = new SongBrowserSettings(); } // check if the playlist directory exists, make it otherwise. String playlistDirPath = Path.Combine(Environment.CurrentDirectory, "Playlists"); if (!Directory.Exists(playlistDirPath)) { Directory.CreateDirectory(playlistDirPath); } // Load Downloader favorites but only once, we'll convert them once, empty the song_browser_setting.xml favorites and never load it again. String playlistPath = Path.Combine(Environment.CurrentDirectory, "Playlists", DefaultConvertedFavoritesPlaylistName); if (!File.Exists(playlistPath)) { if (File.Exists(SongBrowserSettings.DownloaderFavoritesFilePath())) { String[] downloaderFavorites = File.ReadAllLines(SongBrowserSettings.DownloaderFavoritesFilePath()); retVal.Favorites.UnionWith(downloaderFavorites); } Playlist p = new Playlist { playlistTitle = "Song Browser Favorites", playlistAuthor = "SongBrowser", fileLoc = "", image = Base64Sprites.SpriteToBase64(Base64Sprites.BeastSaberLogo), songs = new List <PlaylistSong>(), }; p.CreateNew(playlistPath); } // 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); }
public void Initialize() { try { IsInstalledSongBrowser = PluginManager.GetPlugin("Song Browser") != null; this.standardLevelDetailViewController = this.container.Resolve <StandardLevelDetailViewController>(); this.levelCollectionViewController = this.container.Resolve <LevelCollectionViewController>(); var standardLevelDetailView = this.standardLevelDetailViewController.GetPrivateField <StandardLevelDetailView>("_standardLevelDetailView"); Logger.Debug($"standardLevelDetailView is null? : {standardLevelDetailView == null}"); var playContainer = standardLevelDetailView.GetComponentsInChildren <RectTransform>().First(x => x.name == "BeatmapParamsPanel"); this._playButtons = standardLevelDetailView.GetComponentsInChildren <RectTransform>().First(x => x.name == "ActionButtons"); BSMLParser.instance?.Parse(Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), this.ResourceName), this.rectTransform.gameObject, this); var button = Resources.FindObjectsOfTypeAll <Button>().First(x => x.name == "PracticeButton").transform as RectTransform; #if DEBUG this._playlistButton = PlaylistUI.CreateIconButton("PlaylistButton", this._playButtons.transform as RectTransform, Vector2.zero, new Vector2(6f, button.sizeDelta.y), this.ShowModal, Base64Sprites.LoadSpriteFromResources("SongPlayListEditer.Resources.predator.png"), "PracticeButton"); this._playlistButton.GetComponentsInChildren <Image>().First(x => x.name == "Icon").transform.localScale *= 0.9f; this._playlistButton.gameObject.GetComponentsInChildren <LayoutElement>(true).FirstOrDefault().preferredWidth = 11f; #else if (DateTime.Now.Month == 4 && DateTime.Now.Day == 1) { this._playlistButton = PlaylistUI.CreateIconButton("PlaylistButton", this._playButtons.transform as RectTransform, Vector2.zero, new Vector2(6f, button.sizeDelta.y), this.ShowModal, Base64Sprites.LoadSpriteFromResources("SongPlayListEditer.Resources.predator.png"), "PracticeButton"); this._playlistButton.GetComponentsInChildren <Image>().First(x => x.name == "Icon").transform.localScale *= 0.9f; this._playlistButton.gameObject.GetComponentsInChildren <LayoutElement>(true).FirstOrDefault().preferredWidth = 11f; } else { this._playlistButton = PlaylistUI.CreateIconButton("PlaylistButton", this._playButtons.transform as RectTransform, Vector2.zero, new Vector2(6f, button.sizeDelta.y), this.ShowModal, Base64Sprites.LoadSpriteFromResources("SongPlayListEditer.Resources.round_playlist_add_white_18dp.png"), "PracticeButton"); this._playlistButton.GetComponentsInChildren <Image>().First(x => x.name == "Icon").transform.localScale *= 2.1f; } #endif Logger.Debug($"Button is null? : {this._playlistButton == null}"); Logger.Debug($"modal is null? : {this._modal == null}"); this._playlistButton.transform.SetSiblingIndex(PluginConfig.Instance.ButtonIndex); this._playlistButton.interactable = true; this.levelCollectionViewController.didSelectLevelEvent -= this.LevelCollectionViewController_didSelectLevelEvent; this.levelCollectionViewController.didSelectLevelEvent += this.LevelCollectionViewController_didSelectLevelEvent; PlaylistUI.ConvertIconButton(ref this._closeButton, new Vector2(50f, 50f), Base64Sprites.LoadSpriteFromResources("SongPlayListEditer.Resources.baseline_close_white_18dp.png")); this._closeButton.GetComponentsInChildren <Image>().First(x => x.name == "Icon").transform.localScale *= 1.2f; if (IsInstalledSongBrowser) { HMMainThreadDispatcher.instance.Enqueue(this.ResizeDeleteButton()); } } catch (Exception e) { Logger.Error(e); } }
public Playlist(JSONNode playlistNode) { string image = playlistNode["image"].Value; if (!string.IsNullOrEmpty(image)) { try { icon = Base64Sprites.Base64ToSprite(image.Substring(image.IndexOf(",") + 1)); } catch { Logger.Exception("Unable to convert playlist image to sprite!"); icon = Base64Sprites.BeastSaberLogo; } } else { icon = Base64Sprites.BeastSaberLogo; } playlistTitle = playlistNode["playlistTitle"]; playlistAuthor = playlistNode["playlistAuthor"]; customDetailUrl = playlistNode["customDetailUrl"]; customArchiveUrl = playlistNode["customArchiveUrl"]; if (!string.IsNullOrEmpty(customDetailUrl)) { if (!customDetailUrl.EndsWith("/")) { customDetailUrl += "/"; } Logger.Log("Found playlist with customDetailUrl! Name: " + playlistTitle + ", CustomDetailUrl: " + customDetailUrl); } if (!string.IsNullOrEmpty(customArchiveUrl) && customArchiveUrl.Contains("[KEY]")) { Logger.Log("Found playlist with customArchiveUrl! Name: " + playlistTitle + ", CustomArchiveUrl: " + customArchiveUrl); } songs = new List <PlaylistSong>(); foreach (JSONNode node in playlistNode["songs"].AsArray) { PlaylistSong song = new PlaylistSong(); song.key = node["key"]; song.songName = node["songName"]; song.levelId = node["levelId"]; songs.Add(song); } if (playlistNode["playlistSongCount"] != null) { songCount = playlistNode["playlistSongCount"].AsInt; } if (playlistNode["fileLoc"] != null) { fileLoc = playlistNode["fileLoc"]; } if (playlistNode["playlistURL"] != null) { fileLoc = playlistNode["playlistURL"]; } }