/// <summary>
        ///     Creates the option buttons.
        /// </summary>
        public void CreateModsDialogOptions()
        {
            Options.Add(new DrawableModifierOption(this, "OFF", (o, e) =>
            {
                foreach (var mod in Modifiers)
                {
                    if (ModManager.Mods.HasFlag(mod.ModIdentifier))
                    {
                        ModManager.RemoveMod(mod.ModIdentifier);
                    }
                }

                Description = DefaultDescription;
            }));

            foreach (var mod in Modifiers)
            {
                if (!mod.AllowedInMultiplayer)
                {
                    continue;
                }

                Options.Add(new DrawableModifierOption(this, mod.Name, (o, e) =>
                {
                    if (!ModManager.Mods.HasFlag(mod.ModIdentifier))
                    {
                        ModManager.AddMod(mod.ModIdentifier);
                    }

                    Description = mod.Description;
                }));
            }
        }
示例#2
0
        /// <summary>
        ///     Called when the selected value changes
        /// </summary>
        /// <param name="val"></param>
        /// <param name="index"></param>
        private static void OnSelected(string val, int index)
        {
            if (val == "1.0x")
            {
                ModManager.RemoveSpeedMods();
                return;
            }

            ModManager.AddMod(ModHelper.GetModsFromRate(float.Parse(val.Replace("x", ""))));
        }
 /// <summary>
 /// Adds the specified mod or profile to the mod manager.
 /// </summary>
 /// <param name="p_strFilePath">The path or URL of the mod to add to the mod manager.</param>
 public void AddMod(string p_strFilePath)
 {
     if (p_strFilePath.Contains("profiles"))
     {
     }
     else
     {
         Trace.TraceInformation("Adding Mod to running instance of client: " + p_strFilePath);
         ModManager.AddMod(p_strFilePath, ConfirmFileOverwrite);
         BringToFront();
     }
 }
示例#4
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));
                });
            };
        }
示例#5
0
        /// <summary>
        ///     Adds all modifiers that were present in the replay.
        /// </summary>
        private static void AddModsFromReplay(Replay replay)
        {
            // Remove all the current mods that we have on.
            ModManager.RemoveAllMods();

            // Put on the mods from the replay.);
            for (var i = 0; i <= Math.Log((int)replay.Mods, 2); i++)
            {
                var mod = (ModIdentifier)Math.Pow(2, i);

                if (!replay.Mods.HasFlag(mod))
                {
                    continue;
                }

                ModManager.AddMod(mod);
            }
        }
示例#6
0
        /// <summary>
        ///     Adds all modifiers that were present in the loaded replay (if there is one.)
        /// </summary>
        private void AddModsFromReplay()
        {
            // Add the correct mods on if we're in replay mode.
            if (!InReplayMode)
                return;

            // Remove all the current mods that we have on.
            ModManager.RemoveAllMods();

            // Put on the mods from the replay.);
            for (var i = 0; i <= Math.Log((int)LoadedReplay.Mods, 2); i++)
            {
                var mod = (ModIdentifier)Math.Pow(2, i);

                if (!LoadedReplay.Mods.HasFlag(mod))
                    continue;

                ModManager.AddMod(mod);
            }
        }
示例#7
0
 /// <summary>
 ///     Creates the option buttons.
 /// </summary>
 private void CreateModsDialogOptions()
 {
     Options.Add(new DrawableModifierOption(this, "OFF", (o, e) =>
     {
         if (ModManager.Mods.HasFlag(Modifier.ModIdentifier))
         {
             ModManager.RemoveMod(Modifier.ModIdentifier);
         }
     })
     {
         Width = 60,
     });
     Options.Add(new DrawableModifierOption(this, "ON", (o, e) =>
     {
         if (!ModManager.Mods.HasFlag(Modifier.ModIdentifier))
         {
             ModManager.AddMod(Modifier.ModIdentifier);
         }
     })
     {
         Width = 60,
     });
 }
        /// <summary>
        ///     Adds all modifiers from a mod enum combo
        /// </summary>
        public static void AddModsFromIdentifiers(ModIdentifier mods)
        {
            // Remove all the current mods that we have on.
            ModManager.RemoveAllMods();

            for (var i = 0; i <= Math.Log((long)mods, 2); i++)
            {
                var mod = (ModIdentifier)((long)Math.Pow(2, i));

                if (!mods.HasFlag(mod))
                {
                    continue;
                }

                try
                {
                    ModManager.AddMod(mod);
                }
                catch (Exception e)
                {
                    Logger.Error(e, LogType.Runtime);
                }
            }
        }
 /// <summary>
 /// Installs the specified mod.
 /// </summary>
 /// <param name="p_strPath">The path to the mod to install.</param>
 protected void AddMod(string p_strPath)
 {
     IBackgroundTask bgtAddingTask = ModManager.AddMod(p_strPath, ConfirmFileOverwrite);
 }
示例#10
0
        /// <summary>
        ///     Pauses the game.
        /// </summary>
        internal void Pause(GameTime gameTime = null)
        {
            // Don't allow pausing if the play is already finished.
            if (IsPlayComplete)
            {
                return;
            }

            // Grab the casted version of the screenview.
            var screenView = (GameplayScreenView)View;

            // Handle pause.
            // Spectating is an exception here because we're not technically "paused"
            if (!IsPaused || SpectatorClient != null)
            {
                // Handle cases where someone (a developer) calls pause but there is not GameTime.
                // shouldn't ever happen though.
                if (gameTime == null)
                {
                    const string log = "Cannot pause if GameTime is null";
                    Logger.Error(log, LogType.Runtime);
                    throw new InvalidOperationException(log);
                }

                // Increase the time the pause key has been held.
                TimePauseKeyHeld += gameTime.ElapsedGameTime.TotalMilliseconds;

                screenView.Transitioner.Alpha = MathHelper.Lerp(screenView.Transitioner.Alpha, 1,
                                                                (float)Math.Min(gameTime.ElapsedGameTime.TotalMilliseconds / TimeToHoldPause, 1));

                // Make the user hold the pause key down before pausing if tap to pause is disabled.
                if (!ConfigManager.TapToPause.Value && TimePauseKeyHeld < TimeToHoldPause)
                {
                    return;
                }

                IsPaused           = true;
                IsResumeInProgress = false;
                PauseCount++;
                GameBase.Game.GlobalUserInterface.Cursor.Alpha = 1;

                // Exit right away if playing a replay.
                if (InReplayMode)
                {
                    CustomAudioSampleCache.StopAll();
                    ModManager.RemoveAllMods();

                    if (SpectatorClient != null)
                    {
                        OnlineManager.Client?.StopSpectating();
                    }

                    Exit(() => new SelectScreen());
                    return;
                }

                // Show notification to the user that their score is invalid.
                NotificationManager.Show(NotificationLevel.Warning, "WARNING! Your score will not be submitted due to pausing during gameplay!");

                // Add the pause mod to their score.
                if (!ModManager.IsActivated(ModIdentifier.Paused))
                {
                    ModManager.AddMod(ModIdentifier.Paused);
                    ReplayCapturer.Replay.Mods  |= ModIdentifier.Paused;
                    Ruleset.ScoreProcessor.Mods |= ModIdentifier.Paused;
                }

                try
                {
                    AudioEngine.Track.Pause();
                }
                catch (Exception)
                {
                    // ignored
                }

                CustomAudioSampleCache.PauseAll();

                DiscordHelper.Presence.State        = $"Paused for the {StringHelper.AddOrdinal(PauseCount)} time";
                DiscordHelper.Presence.EndTimestamp = 0;
                DiscordRpc.UpdatePresence(ref DiscordHelper.Presence);

                OnlineManager.Client?.UpdateClientStatus(GetClientStatus());

                // Fade in the transitioner.
                screenView.Transitioner.Animations.Clear();
                screenView.Transitioner.Animations.Add(new Animation(AnimationProperty.Alpha, Easing.Linear, screenView.Transitioner.Alpha, 0.75f, 400));

                // Activate pause menu
                screenView.PauseScreen?.Activate();
                return;
            }

            if (IsResumeInProgress)
            {
                return;
            }

            // Setting the resume time in this case allows us to give the user time to react
            // with a delay before starting the audio track again.
            // When that resume time is past the specific set offset, it'll unpause the game.
            IsResumeInProgress = true;
            ResumeTime         = GameBase.Game.TimeRunning;

            // Fade screen transitioner
            screenView.Transitioner.Animations.Clear();
            var alphaTransformation = new Animation(AnimationProperty.Alpha, Easing.Linear, 0.75f, 0, 400);

            screenView.Transitioner.Animations.Add(alphaTransformation);

            // Deactivate pause screen.
            screenView.PauseScreen?.Deactivate();
            SetRichPresence();
            OnlineManager.Client?.UpdateClientStatus(GetClientStatus());
            GameBase.Game.GlobalUserInterface.Cursor.Alpha = 0;
        }