/// <inheritdoc /> /// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> protected override void Update(GameTime gameTime) { if (!IsReadyToUpdate) { return; } base.Update(gameTime); if (SteamManager.IsInitialized) { SteamAPI.RunCallbacks(); } // Run scheduled background tasks CommonTaskScheduler.Run(); BackgroundManager.Update(gameTime); BackgroundHelper.Update(gameTime); NotificationManager.Update(gameTime); ChatManager.Update(gameTime); DialogManager.Update(gameTime); HandleGlobalInput(gameTime); QuaverScreenManager.Update(gameTime); Transitioner.Update(gameTime); SkinManager.HandleSkinReloading(); LimitFpsOnInactiveWindow(); }
/// <summary> /// Restarts the game if the user is holding down the key for a specified amount of time /// /// </summary> private void HandlePlayRestart(double dt) { if (KeyboardManager.IsUniqueKeyPress(ConfigManager.KeyRestartMap.Value)) { IsRestartingPlay = true; } // Grab a reference to the ScreenView. var screenView = (GameplayScreenView)View; if (KeyboardManager.CurrentState.IsKeyDown(ConfigManager.KeyRestartMap.Value) && IsRestartingPlay) { RestartKeyHoldTime += dt; // Fade in the transitioner. if (!screenView.FadingOnRestartKeyPress) { screenView.FadingOnRestartKeyPress = true; screenView.FadingOnRestartKeyRelease = false; screenView.Transitioner.Animations.Clear(); screenView.Transitioner.Animations.Add(new Animation(AnimationProperty.Alpha, Easing.Linear, screenView.Transitioner.Alpha, 1, 100)); } // Restart the map if the user has held it down for if (RestartKeyHoldTime >= 200) { SkinManager.Skin.SoundRetry.CreateChannel().Play(); // Use ChangeScreen here to give instant feedback. Can't be threaded if (InReplayMode) { QuaverScreenManager.ChangeScreen(new GameplayScreen(Map, MapHash, LocalScores, LoadedReplay)); } else { QuaverScreenManager.ChangeScreen(new GameplayScreen(Map, MapHash, LocalScores)); } } return; } RestartKeyHoldTime = 0; IsRestartingPlay = false; // Set it so that it's not fading in on restart anymore. if (!screenView.FadingOnRestartKeyRelease && screenView.FadingOnRestartKeyPress) { screenView.FadingOnRestartKeyPress = false; screenView.FadingOnRestartKeyRelease = true; screenView.Transitioner.Animations.Clear(); screenView.Transitioner.Animations.Add(new Animation(AnimationProperty.Alpha, Easing.Linear, 1, 0, 200)); } }
/// <summary> /// Will restart the screen appropriately. /// </summary> public void Retry() { GameBase.Game.GlobalUserInterface.Cursor.Alpha = 0; SkinManager.Skin.SoundRetry.CreateChannel().Play(); // Use ChangeScreen here to give instant feedback. Can't be threaded if (IsPlayTesting) { QuaverScreenManager.ChangeScreen(new GameplayScreen(OriginalEditorMap, MapHash, LocalScores, null, true, PlayTestAudioTime)); } else if (InReplayMode) { QuaverScreenManager.ChangeScreen(new GameplayScreen(Map, MapHash, LocalScores, LoadedReplay)); } else { QuaverScreenManager.ChangeScreen(new GameplayScreen(Map, MapHash, LocalScores)); } }
/// <inheritdoc /> /// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { base.LoadContent(); Resources.AddStore(new DllResourceStore("Quaver.Resources.dll")); SteamManager.SendAvatarRetrievalRequest(SteamUser.GetSteamID().m_SteamID); // Load all game assets. Fonts.Load(); BackgroundHelper.Initialize(); // Load the user's skin SkinManager.Load(); // Create the global FPS counter. CreateFpsCounter(); VolumeController = new VolumeController() { Parent = GlobalUserInterface }; BackgroundManager.Initialize(); Transitioner.Initialize(); // Make the cursor appear over the volume controller. ListHelper.Swap(GlobalUserInterface.Children, GlobalUserInterface.Children.IndexOf(GlobalUserInterface.Cursor), GlobalUserInterface.Children.IndexOf(VolumeController)); IsReadyToUpdate = true; Logger.Debug($"Currently running Quaver version: `{Version}`", LogType.Runtime); #if VISUAL_TESTS Window.Title = $"Quaver Visual Test Runner"; #else Window.Title = !IsDeployedBuild ? $"Quaver - {Version}" : $"Quaver v{Version}"; QuaverScreenManager.ScheduleScreenChange(() => new MenuScreen()); #endif }
/// <inheritdoc /> /// <summary> /// Ctor /// </summary> /// <param name="screen"></param> public PauseScreen(GameplayScreen screen) { Screen = screen; // Background Background = new Sprite() { Parent = this, Size = new ScalableVector2(WindowManager.Width, WindowManager.Height), Alpha = 0, Image = SkinManager.Skin.PauseBackground, }; // Continue Button Continue = new ImageButton(SkinManager.Skin.PauseContinue, (o, e) => { if (!Screen.IsPaused) { return; } Screen.Pause(); }) { Parent = this, Alignment = Alignment.MidLeft, Y = -150, X = -SkinManager.Skin.PauseContinue.Width, Alpha = 1, UsePreviousSpriteBatchOptions = true }; Continue.Size = new ScalableVector2(Continue.Image.Width, Continue.Image.Height); // Retry Button Retry = new ImageButton(SkinManager.Skin.PauseRetry, (o, e) => { if (!Screen.IsPaused) { return; } SkinManager.Skin.SoundRetry.CreateChannel().Play(); QuaverScreenManager.ChangeScreen(new GameplayScreen(Screen.Map, Screen.MapHash, Screen.LocalScores)); }) { Parent = this, Alignment = Alignment.MidLeft, Y = 20, X = -SkinManager.Skin.PauseRetry.Width, Alpha = 1, UsePreviousSpriteBatchOptions = true }; Retry.Size = new ScalableVector2(Retry.Image.Width, Retry.Image.Height); // Quit Button Quit = new ImageButton(SkinManager.Skin.PauseBack, (o, e) => { if (!Screen.IsPaused) { return; } Screen.IsPaused = false; Screen.ForceFail = true; Screen.HasQuit = true; // Make sure the screen transitioner isn't faded out at all var screenView = (GameplayScreenView)Screen.View; screenView.Transitioner.Alpha = 0; }) { Parent = this, Alignment = Alignment.MidLeft, Y = 190, X = -SkinManager.Skin.PauseBack.Width, Alpha = 1, UsePreviousSpriteBatchOptions = true }; Quit.Size = new ScalableVector2(Quit.Image.Width, Quit.Image.Height); }
/// <inheritdoc /> /// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> protected override void Update(GameTime gameTime) { if (!IsReadyToUpdate) { return; } base.Update(gameTime); if (SteamManager.IsInitialized) { SteamAPI.RunCallbacks(); } // Run scheduled background tasks CommonTaskScheduler.Run(); BackgroundManager.Update(gameTime); BackgroundHelper.Update(gameTime); NotificationManager.Update(gameTime); ChatManager.Update(gameTime); DialogManager.Update(gameTime); // Handles FPS limiter changes if (KeyboardManager.IsUniqueKeyPress(Keys.F7)) { var index = (int)ConfigManager.FpsLimiterType.Value; if (index + 1 < Enum.GetNames(typeof(FpsLimitType)).Length) { ConfigManager.FpsLimiterType.Value = (FpsLimitType)index + 1; } else { ConfigManager.FpsLimiterType.Value = FpsLimitType.Unlimited; } switch (ConfigManager.FpsLimiterType.Value) { case FpsLimitType.Unlimited: NotificationManager.Show(NotificationLevel.Info, "FPS is now unlimited."); break; case FpsLimitType.Limited: NotificationManager.Show(NotificationLevel.Info, $"FPS is now limited to: 240 FPS"); break; case FpsLimitType.Vsync: NotificationManager.Show(NotificationLevel.Info, $"Vsync Enabled"); break; case FpsLimitType.Custom: NotificationManager.Show(NotificationLevel.Info, $"FPS is now custom limited to: {ConfigManager.CustomFpsLimit.Value}"); break; default: throw new ArgumentOutOfRangeException(); } } QuaverScreenManager.Update(gameTime); Transitioner.Update(gameTime); }