Beispiel #1
0
        /// <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)
            };
        }