示例#1
0
        /// <summary>
        /// </summary>
        private void CreateExportButton()
        {
            CalibrateOffsetButton = new BorderedTextButton("Calibrate", Colors.MainAccent)
            {
                Parent    = this,
                X         = -50,
                Alignment = Alignment.MidRight,
                Height    = 30,
                Width     = 225,
                Text      =
                {
                    Font     = Fonts.SourceSansProSemiBold,
                    FontSize = 12
                }
            };

            CalibrateOffsetButton.Clicked += (o, e) =>
            {
                var game = (QuaverGame)GameBase.Game;

                if (game.CurrentScreen.Type == QuaverScreenType.Editor)
                {
                    NotificationManager.Show(NotificationLevel.Warning, "Finish what you're doing before calibrating a new offset");
                    return;
                }

                var path = $"Quaver.Resources/Maps/Offset/offset.qua";

                var qua = Qua.Parse(GameBase.Game.Resources.Get(path));

                if (AudioEngine.Track != null && !AudioEngine.Track.IsDisposed && AudioEngine.Track.IsPlaying)
                {
                    AudioEngine.Track.Pause();
                }

                game.CurrentScreen?.Exit(() =>
                {
                    MapManager.Selected.Value     = Map.FromQua(qua, path, true);
                    MapManager.Selected.Value.Qua = qua;

                    // Make the user not allow to fail.
                    ModManager.RemoveAllMods();
                    ModManager.AddMod(ModIdentifier.NoFail);

                    // Load the background (usually the default one)
                    BackgroundHelper.Load(MapManager.Selected.Value);
                    DialogManager.Dismiss(Dialog);

                    return(new GameplayScreen(qua, "", new List <Score>(), null, false, 0, true));
                });
            };
        }
示例#2
0
        /// <summary>
        ///     Makes sure that the background of the map is up-to-date.
        /// </summary>
        public void HandleBackgroundChange()
        {
            // If we've already got the background loaded up, then use it.
            if (BackgroundHelper.Map != null && MapManager.GetBackgroundPath(BackgroundHelper.Map) == MapManager.GetBackgroundPath(MapManager.Selected.Value))
            {
                BackgroundHelper.Background.Image = BackgroundHelper.BlurredTexture;
                BackgroundHelper.FadeIn(0.5f);
                return;
            }

            // Otherwise queue a load on it.
            BackgroundHelper.Load(MapManager.Selected.Value);
        }
示例#3
0
        /// <summary>
        ///     Loads the new background and performs a fade in animation
        /// </summary>
        private void LoadNewBackgroundIfNecessary(Map previousMap)
        {
            if (previousMap != null && MapManager.GetBackgroundPath(previousMap) == MapManager.GetBackgroundPath(MapManager.Selected.Value))
            {
                return;
            }

            View.Banner?.Brightness?.ClearAnimations();
            View.Banner?.Brightness?.Animations.Add(new Animation(AnimationProperty.Alpha, Easing.Linear, View.Banner.Brightness.Alpha, 1, 200));

            BackgroundHelper.FadeToBlack();
            BackgroundHelper.Load(MapManager.Selected.Value);
        }
        /// <summary>
        /// </summary>
        private void CreateBackground()
        {
            Background = new BackgroundImage(UserInterface.BlankBox, 100, false);
            BackgroundHelper.Loaded += OnBackgroundLoaded;

            if (BackgroundHelper.Map == MapManager.Selected.Value)
            {
                Background.Image = BackgroundHelper.RawTexture;
                FadeBackgroundIn();
                return;
            }

            BackgroundHelper.Load(MapManager.Selected.Value);
        }
        /// <summary>
        /// </summary>
        /// <param name="screen"></param>
        /// <param name="file"></param>
        private static void OnConfirm(EditorScreen screen, string file)
        {
            var view = screen.View as EditorScreenView;

            view?.FadeBackgroundOut();

            var fileName = Path.GetFileName(file);

            try
            {
                File.Copy(file, ConfigManager.SongDirectory + "/" + MapManager.Selected.Value.Directory + "/" + fileName, true);
            }
            catch (Exception)
            {
                // ignored
            }

            screen.WorkingMap.BackgroundFile         = fileName;
            MapManager.Selected.Value.BackgroundPath = fileName;

            BackgroundHelper.Load(MapManager.Selected.Value);
            screen.Save();
        }
示例#6
0
        /// <summary>
        /// </summary>
        public void UpdateContent()
        {
            Map map;

            if (MapManager.Selected.Value?.Md5Checksum == Game.MapMd5)
            {
                map = MapManager.Selected.Value;
            }
            else
            {
                map = MapManager.FindMapFromMd5(Game.MapMd5);

                // In the event that we don't have the correct version, try to find the
                // alternative one. This is commonly used for situations where one has osu!
                // beatmaps auto-loaded and someone downloads and converts the file to .qua format
                if (map == null && Game.MapMd5 != Game.AlternativeMd5)
                {
                    map = MapManager.FindMapFromMd5(Game.AlternativeMd5);
                }

                MapManager.Selected.Value = map;
            }

            HasMap = map != null;

            if (OnlineManager.CurrentGame.HostSelectingMap)
            {
                ArtistTitle.Text      = "Host is currently selecting a map!";
                Mode.Text             = "Please wait...";
                Creator.Text          = "";
                DifficultyName.Text   = "";
                DifficultyRating.Text = "";
            }
            else
            {
                var diffName = GetDifficultyName();

                ArtistTitle.Text = Game.Map.Replace($"[{diffName}]", "");
                Mode.Text        = $"[{ModeHelper.ToShortHand((GameMode) Game.GameMode)}]";
                Creator.Tint     = Color.White;

                DifficultyRating.Text = map != null ? $"{map.DifficultyFromMods(ModManager.Mods):0.00}" : $"{Game.DifficultyRating:0.00}";
                DifficultyRating.Tint = ColorHelper.DifficultyToColor((float)(map?.DifficultyFromMods(ModManager.Mods) ?? Game.DifficultyRating));
                DifficultyRating.X    = Mode.X + Mode.Width + 8;
                DifficultyName.X      = DifficultyRating.X + DifficultyRating.Width + 2;
                DifficultyName.Text   = " - \"" + diffName + "\"";
            }

            var game = (QuaverGame)GameBase.Game;

            if (map != null)
            {
                ArtistTitle.Tint = Color.White;

                var length = TimeSpan.FromMilliseconds(map.SongLength / ModHelper.GetRateFromMods(ModManager.Mods));
                var time   = length.Hours > 0 ? length.ToString(@"hh\:mm\:ss") : length.ToString(@"mm\:ss");

                if (OnlineManager.CurrentGame.HostSelectingMap)
                {
                    Creator.Text = "";
                }
                else
                {
                    Creator.Text = $"By: {map.Creator} | Length: {time} | BPM: {(int) (map.Bpm * ModHelper.GetRateFromMods(ModManager.Mods))} " +
                                   $"| LNs: {(int) map.LNPercentage}%";
                }

                // Inform the server that we now have the map if we didn't before.
                if (OnlineManager.CurrentGame.PlayersWithoutMap.Contains(OnlineManager.Self.OnlineUser.Id))
                {
                    OnlineManager.Client.HasMultiplayerGameMap();
                }

                if (game.CurrentScreen.Type == QuaverScreenType.Lobby || game.CurrentScreen.Type == QuaverScreenType.Multiplayer ||
                    QuaverScreenManager.QueuedScreen.Type == QuaverScreenType.Multiplayer ||
                    AudioEngine.Map != map)
                {
                    if (BackgroundHelper.Map != MapManager.Selected.Value)
                    {
                        Background.Alpha = 0;

                        var view = Screen.View as MultiplayerScreenView;
                        view?.FadeBackgroundOut();
                        BackgroundHelper.Load(map);
                    }

                    ThreadScheduler.Run(() =>
                    {
                        try
                        {
                            if (AudioEngine.Map != map)
                            {
                                if (!HasMap)
                                {
                                    return;
                                }

                                AudioEngine.LoadCurrentTrack();
                                AudioEngine.Track.Play();
                            }
                        }
                        catch (Exception e)
                        {
                            // ignored
                        }
                    });
                }
            }
            // Let the server know that we don't have the selected map
            else
            {
                ArtistTitle.Tint = Color.Red;

                Creator.Text = Game.MapId != -1 ? "You don't have this map. Click to download!" : "You don't have this map. Download not available!";
                Creator.Tint = Colors.SecondaryAccent;

                if (!OnlineManager.CurrentGame.PlayersWithoutMap.Contains(OnlineManager.Self.OnlineUser.Id))
                {
                    OnlineManager.Client.DontHaveMultiplayerGameMap();
                }

                if (!AudioEngine.Track.IsStopped)
                {
                    AudioEngine.Track.Stop();
                }

                MapManager.Selected.Value = MapManager.Mapsets.First().Maps.First();
            }
        }
示例#7
0
        /// <summary>
        /// </summary>
        public MultiplayerMap(MultiplayerScreen screen, MultiplayerGame game) : base(new ScalableVector2(682, 86), new ScalableVector2(682, 86))
        {
            Screen = screen;
            Game   = game;
            Size   = new ScalableVector2(650, 86);
            Image  = UserInterface.MapPanel;

            DownloadButton = new ImageButton(UserInterface.BlankBox, OnDownloadButtonClicked)
            {
                Parent    = this,
                Alignment = Alignment.MidCenter,
                Size      = new ScalableVector2(Width - 4, Height - 4),
                Alpha     = 0
            };

            Background = new Sprite
            {
                Parent    = this,
                Size      = new ScalableVector2(Height * 1.70f, Height - 4),
                Alignment = Alignment.MidLeft,
                X         = 2,
                Image     = MapManager.Selected.Value == BackgroundHelper.Map && MapManager.Selected.Value.Md5Checksum == Game.MapMd5 ? BackgroundHelper.RawTexture: UserInterface.MenuBackground,
                Alpha     = MapManager.Selected.Value == BackgroundHelper.Map && MapManager.Selected.Value.Md5Checksum == Game.MapMd5 ? 1 : 0
            };

            AddContainedDrawable(Background);

            var diffName = GetDifficultyName();

            ArtistTitle = new SpriteTextBitmap(FontsBitmap.GothamRegular, game.Map.Replace($"[{diffName}]", ""))
            {
                Parent   = this,
                X        = Background.X + Background.Width + 16,
                Y        = 12,
                FontSize = 16
            };

            AddContainedDrawable(ArtistTitle);

            Mode = new SpriteTextBitmap(FontsBitmap.GothamRegular, "[" + ModeHelper.ToShortHand((GameMode)game.GameMode) + "]")
            {
                Parent   = this,
                X        = ArtistTitle.X,
                Y        = ArtistTitle.Y + ArtistTitle.Height + 8,
                FontSize = 14
            };

            AddContainedDrawable(Mode);

            DifficultyRating = new SpriteTextBitmap(FontsBitmap.GothamRegular, $"{game.DifficultyRating:0.00}")
            {
                Parent   = this,
                X        = Mode.X + Mode.Width + 8,
                Y        = Mode.Y,
                FontSize = 14,
                Tint     = ColorHelper.DifficultyToColor((float)game.DifficultyRating)
            };

            AddContainedDrawable(DifficultyRating);

            DifficultyName = new SpriteTextBitmap(FontsBitmap.GothamRegular, " - \"" + diffName + "\"")
            {
                Parent   = this,
                X        = DifficultyRating.X + DifficultyRating.Width + 2,
                Y        = Mode.Y,
                FontSize = 14,
            };

            AddContainedDrawable(DifficultyName);

            Creator = new SpriteTextBitmap(FontsBitmap.GothamRegular, "Mods: None")
            {
                Parent   = this,
                X        = Mode.X,
                Y        = DifficultyRating.Y + DifficultyRating.Height + 8,
                FontSize = DifficultyRating.FontSize
            };

            AddContainedDrawable(Creator);

            BackgroundHelper.Loaded += OnBackgroundLoaded;
            OnlineManager.Client.OnGameMapChanged       += OnGameMapChanged;
            OnlineManager.Client.OnChangedModifiers     += OnChangedModifiers;
            OnlineManager.Client.OnGameHostSelectingMap += OnGameHostSelectingMap;
            ModManager.ModsChanged += OnModsChanged;

            BackgroundHelper.Load(MapManager.Selected.Value);
            UpdateContent();
        }