コード例 #1
0
        /// <summary>
        /// Exits all screens
        /// </summary>
        public void ExitAll()
        {
            GameScreen[] to_remove = null;
            lock (_screens)
            {
                to_remove = new GameScreen[_screens.Count];
                _screens.CopyTo(to_remove);
            }

            foreach (GameScreen i_screen in to_remove)
                i_screen.ExitScreen();
        }
コード例 #2
0
        /// <summary>
        /// Removes a screen from the screen manager. You should normally
        /// use <see cref="GameScreen"/>.ExitScreen instead of calling this directly, so
        /// the screen can gradually transition off rather than just being
        /// instantly removed.
        /// </summary>
        public void RemoveScreen(GameScreen screen)
        {
            // If we have a graphics device, tell the screen to unload content.
            if ((_graphicsDeviceService != null) &&
                (_graphicsDeviceService.GraphicsDevice != null))
            {
                screen.UnloadContent();
            }
            // Remove the screen from the arrays
            lock (_screens)
                _screens.Remove(screen);

            lock (_screensToUpdate)
                _screensToUpdate.Remove(screen);
            // Dispose the Screen (Release it's Content)
            screen.Dispose();

            this.OnResize -= screen.DoResize;
        }
コード例 #3
0
        /// <summary>
        /// Removes all screens but argument screen
        /// </summary>
        /// <param name="excluded_screen"></param>
        public void RemoveAllBut(GameScreen excludedScreen)
        {
            List<GameScreen> i_screensToRemove = new List<GameScreen>();

            lock (_screens)
                foreach (GameScreen i_screen in _screens)
                    if (i_screen != excludedScreen)
                        i_screensToRemove.Add(i_screen);

            foreach (GameScreen i_screen in i_screensToRemove)
                RemoveScreen(i_screen);

            i_screensToRemove.Clear();
        }
コード例 #4
0
        /// <summary>
        /// Adds a new screen to the screen manager.
        /// </summary>
        public void AddScreen(GameScreen screen)
        {
            screen.ScreenManager = this;
            screen.Game = this.Game;

            this.OnResize += screen.DoResize;

            // Initialize this Screen
            screen.Initialize();

#if !SILVERLIGHT
            // If we have a graphics device, tell the screen to load content.
            if ((_graphicsDeviceService != null) &&
                (_graphicsDeviceService.GraphicsDevice != null))
            {
            #endif
                // Load the Content
                screen.LoadContent(new ContentManager(Game.Services, "Content"));
            #if !SILVERLIGHT
            }
#endif
            // Actually Add the screen to the list
            lock (_screens)
                _screens.Add(screen);
            // Process post actions
            screen.PostProcessing();

        }