/// <summary> /// Loads the gameplay screen (audio, md5 hashes, etc.) /// </summary> private void LoadGameplayScreen() { // Stop the current audio and load it again before moving onto the next state. try { AudioEngine.LoadCurrentTrack(); } catch (AudioEngineException e) { Logger.Error(e, LogType.Runtime); Logger.Warning("Audio file could not be loaded, but proceeding anyway!", LogType.Runtime); } // Get the MD5 Hash of the played map and change the state. var quaPath = $"{ConfigManager.SongDirectory}/{MapManager.Selected.Value.Directory}/{MapManager.Selected.Value.Path}"; // Get the Md5 of the played map string md5; switch (MapManager.Selected.Value.Game) { case MapGame.Quaver: md5 = MapsetHelper.GetMd5Checksum(quaPath); break; case MapGame.Osu: md5 = MapsetHelper.GetMd5Checksum($"{MapManager.OsuSongsFolder}/{MapManager.Selected.Value.Directory}/{MapManager.Selected.Value.Path}"); break; default: throw new ArgumentOutOfRangeException(); } Exit(() => new GameplayScreen(MapManager.Selected.Value.Qua, md5, new List <Score>(), Replay, false, 0, false, SpectatorClient)); }
/// <summary> /// </summary> public SelectScreen() { // Go to the import screen if we've imported a map not on the select screen if (MapsetImporter.Queue.Count > 0 || MapDatabaseCache.LoadedMapsFromOtherGames != ConfigManager.AutoLoadOsuBeatmaps.Value || QuaverSettingsDatabaseCache.OutdatedMaps.Count != 0) { Exit(() => new ImportingScreen()); return; } // Grab the mapsets available to the user according to their previous search term. AvailableMapsets = MapsetHelper.SearchMapsets(MapManager.Mapsets, PreviousSearchTerm); // If no mapsets were found, just default to all of them. if (AvailableMapsets.Count == 0) { AvailableMapsets = MapManager.Mapsets; } AvailableMapsets = MapsetHelper.OrderMapsetsByConfigValue(AvailableMapsets); Logger.Debug($"There are currently: {AvailableMapsets.Count} available mapsets to play in select.", LogType.Runtime); DiscordHelper.Presence.Details = "Selecting a song"; DiscordHelper.Presence.State = "In the menus"; DiscordRpc.UpdatePresence(ref DiscordHelper.Presence); ConfigManager.AutoLoadOsuBeatmaps.ValueChanged += OnAutoLoadOsuBeatmapsChanged; View = new SelectScreenView(this); }
/// <summary> /// </summary> public SelectScreen(MultiplayerScreen screen = null) { MultiplayerScreen = screen; // Go to the import screen if we've imported a map not on the select screen if (MapsetImporter.Queue.Count > 0 || QuaverSettingsDatabaseCache.OutdatedMaps.Count != 0 || MapDatabaseCache.MapsToUpdate.Count != 0) { Exit(() => new ImportingScreen()); return; } // Grab the mapsets available to the user according to their previous search term. AvailableMapsets = MapsetHelper.SearchMapsets(MapManager.Mapsets, PreviousSearchTerm); // If no mapsets were found, just default to all of them. if (AvailableMapsets.Count == 0) { AvailableMapsets = MapManager.Mapsets; } AvailableMapsets = MapsetHelper.OrderMapsetsByConfigValue(AvailableMapsets); Logger.Debug($"There are currently: {AvailableMapsets.Count} available mapsets to play in select.", LogType.Runtime); if (OnlineManager.CurrentGame == null) { DiscordHelper.Presence.Details = "Selecting a song"; DiscordHelper.Presence.State = "In the menus"; DiscordRpc.UpdatePresence(ref DiscordHelper.Presence); } else { OnlineManager.Client?.SetGameCurrentlySelectingMap(true); } ConfigManager.AutoLoadOsuBeatmaps.ValueChanged += OnAutoLoadOsuBeatmapsChanged; ConfigManager.DisplayFailedLocalScores.ValueChanged += OnDisplayFailedScoresChanged; var game = GameBase.Game as QuaverGame; var cursor = game?.GlobalUserInterface.Cursor; cursor.Alpha = 1; // Let spectators know that we're selecting a new song if (OnlineManager.IsBeingSpectated) { OnlineManager.Client?.SendReplaySpectatorFrames(SpectatorClientStatus.SelectingSong, -1, new List <ReplayFrame>()); } View = new SelectScreenView(this); }
/// <summary> /// Creates the textbox to search for mapsets. /// </summary> private void CreateSearchBox() { SearchBox = new Textbox(new ScalableVector2(518, 30), Fonts.Exo2Bold, 13) { Parent = TextSearch, Position = new ScalableVector2(TextSearch.Width + 5, 0), Alignment = Alignment.MidLeft, Tint = Colors.DarkGray, Alpha = 0.75f, AllowSubmission = false, RawText = SelectScreen.PreviousSearchTerm, InputText = { Tint = Color.White, Text = SelectScreen.PreviousSearchTerm }, StoppedTypingActionCalltime = 300, OnStoppedTyping = (text) => { SelectScreen.PreviousSearchTerm = text; var selectScreen = View.Screen as SelectScreen; lock (selectScreen.AvailableMapsets) { selectScreen.AvailableMapsets = MapsetHelper.OrderMapsetsByConfigValue( MapsetHelper.SearchMapsets(MapManager.Mapsets, text)); View.MapsetScrollContainer.InitializeWithNewSets(); UpdateMapsetsFoundText(); } } }; SearchBox.AddBorder(Colors.MainAccent); var searchIcon = new Sprite() { Parent = SearchBox, Alignment = Alignment.MidRight, X = -15, Image = FontAwesome.Get(FontAwesomeIcon.fa_magnifying_glass), Size = new ScalableVector2(15, 15) }; }
/// <summary> /// Creates the button to select to order by artist. /// </summary> private void CreateOrderByArtistButton() { ButtonOrderByArtist = new SelectableBorderedTextButton("Artist", ColorHelper.HexToColor("#75e475"), ConfigManager.SelectOrderMapsetsBy.Value == OrderMapsetsBy.Artist) { Parent = OrderBy, X = OrderBy.Width + 10, Text = { Font = Fonts.Exo2SemiBold, FontSize = 13, ForceDrawAtSize = true, Alignment = Alignment.TopLeft }, Border = { Visible = false } }; ButtonOrderByArtist.Clicked += (sender, args) => { if (ConfigManager.SelectOrderMapsetsBy.Value == OrderMapsetsBy.Artist) { return; } ConfigManager.SelectOrderMapsetsBy.Value = OrderMapsetsBy.Artist; var selectScreen = View.Screen as SelectScreen; lock (selectScreen.AvailableMapsets) { selectScreen.AvailableMapsets = MapsetHelper.OrderMapsetsByConfigValue(selectScreen.AvailableMapsets); View.MapsetScrollContainer.InitializeWithNewSets(); } }; ButtonOrderByArtist.Size = new ScalableVector2(ButtonOrderByArtist.Text.Width + 20, ButtonOrderByArtist.Text.Height + 8); }
/// <summary> /// Creates the button to order mapsets by their creator. /// </summary> private void CreateOrderByCreatorButton() { ButtonOrderByCreator = new SelectableBorderedTextButton("Creator", ColorHelper.HexToColor("#75e475"), ConfigManager.SelectOrderMapsetsBy.Value == OrderMapsetsBy.Creator) { Parent = OrderBy, X = ButtonOrderByTitle.X + ButtonOrderByTitle.Width - 5, Y = ButtonOrderByArtist.Y, Text = { Font = Fonts.Exo2SemiBold, FontSize = 13, Alignment = Alignment.TopLeft }, Border = { Visible = false } }; ButtonOrderByCreator.Clicked += (o, e) => { if (ConfigManager.SelectOrderMapsetsBy.Value == OrderMapsetsBy.Creator) { return; } ConfigManager.SelectOrderMapsetsBy.Value = OrderMapsetsBy.Creator; var selectScreen = View.Screen as SelectScreen; lock (selectScreen.AvailableMapsets) { selectScreen.AvailableMapsets = MapsetHelper.OrderMapsetsByConfigValue(selectScreen.AvailableMapsets); View.MapsetScrollContainer.InitializeWithNewSets(); } }; ButtonOrderByCreator.Size = new ScalableVector2(ButtonOrderByCreator.Text.Width + 20, ButtonOrderByCreator.Text.Height + 8); }
/// <summary> /// Called after all maps have been imported to the database. /// </summary> private void OnImportCompletion() { Logger.Important($"Map import has completed", LogType.Runtime); if (SelectScreen.PreviousSearchTerm != "") { SelectScreen.PreviousSearchTerm = ""; } if (OnlineManager.CurrentGame != null && MultiplayerScreen != null) { MapManager.Selected.Value = PreviouslySelectedMap; var selectScreen = ScreenManager.Screens.ToList().Find(x => x is SelectScreen) as SelectScreen; var selectScreenView = selectScreen?.View as SelectScreenView; if (selectScreen != null) { selectScreen.AvailableMapsets = MapsetHelper.OrderMapsetsByConfigValue(MapManager.Mapsets); } selectScreenView?.MapsetScrollContainer.InitializeWithNewSets(); RemoveTopScreen(MultiplayerScreen); var view = (MultiplayerScreenView)MultiplayerScreen.View; view.Map.UpdateContent(); } else { Exit(() => { AudioEngine.Track?.Fade(10, 300); return(new SelectScreen(MultiplayerScreen)); }); } }