/// <summary> /// Adds a new screen to the screen manager. /// </summary> public void AddScreen(vxGameBaseScreen screen, PlayerIndex?controllingPlayer) { //Console.WriteLine ("Adding Screen: " + screen.ToString ()); screen.IsInitialised = true; screen.ControllingPlayer = controllingPlayer; screen.vxEngine = this; screen.IsExiting = false; // If we have a graphics device, tell the screen to load content. if (isInitialized) { screen.LoadContent(); } screens.Add(screen); }
/// <summary> /// Removes a screen from the screen manager. You should normally /// use vxGameBaseScreen.ExitScreen instead of calling this directly, so /// the screen can gradually transition off rather than just being /// instantly removed. /// </summary> public void RemoveScreen(vxGameBaseScreen screen) { //Console.WriteLine ("Removing Screen: " + screen.ToString ()); // If we have a graphics device, tell the screen to unload content. if (isInitialized) { screen.UnloadContent(); } screens.Remove(screen); screensToUpdate.Remove(screen); // if there is a screen still in the manager, update TouchPanel // to respond to gestures that screen is interested in. if (screens.Count > 0) { } }
/// <summary> /// Allows each screen to run logic. /// </summary> public override void Update(GameTime gameTime) { #if !DEBUG if (vxCrashHandler.IsInitialised == false) { try { #endif Profile.Settings.Audio.Double_SFX_Volume = 0.2f; // tell the TimeRuler that we're starting a new frame. you always want // to call this at the start of Update DebugSystem.TimeRuler.StartFrame(); // Start measuring time for "Update". DebugSystem.TimeRuler.BeginMark("Update", Color.Red); //If the Debug Console is Open, Then don't update or take input if (!DebugSystem.DebugCommandUI.Focused) { // Read the keyboard and gamepad. InputManager.Update(gameTime); // Make a copy of the master screen list, to avoid confusion if // the process of updating one screen adds or removes others. screensToUpdate.Clear(); foreach (vxGameBaseScreen screen in screens) { screensToUpdate.Add(screen); } bool otherScreenHasFocus = !Game.IsActive; bool coveredByOtherScreen = false; // Loop as long as there are screens waiting to be updated. while (screensToUpdate.Count > 0) { // Pop the topmost screen off the waiting list. vxGameBaseScreen screen = screensToUpdate [screensToUpdate.Count - 1]; screensToUpdate.RemoveAt(screensToUpdate.Count - 1); // Update the screen. screen.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); if (screen.ScreenState == ScreenState.TransitionOn || screen.ScreenState == ScreenState.Active) { // If this is the first active screen we came across, // give it a chance to handle input. if (!otherScreenHasFocus) { screen.HandleInput(InputManager); otherScreenHasFocus = true; } // If this is an active non-popup, inform any subsequent // screens that they are covered by it. if (!screen.IsPopup) { coveredByOtherScreen = true; } } } // Print debug trace? if (_traceEnabled) { TraceScreens(); } } // Stop measuring time for "Update". DebugSystem.TimeRuler.EndMark("Update"); #if !DEBUG } catch (Exception ex) { vxCrashHandler.Init(this, ex); Crashed(); } } #endif }