コード例 #1
0
ファイル: ScreenManager.cs プロジェクト: thexa4/ticktick
        /// <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);
        }
コード例 #2
0
ファイル: ScreenManager.cs プロジェクト: thexa4/ticktick
        /// <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();
        }
コード例 #3
0
ファイル: ScreenManager.cs プロジェクト: thexa4/ticktick
        /// <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
ファイル: ScreenManager.cs プロジェクト: thexa4/ticktick
        /// <summary>
        /// Adds a new screen to the screen manager.
        /// </summary>
        /// <param name="screen">Screen to add</param>
        public void AddScreen(GameScreen screen)
        {
            screen.ScreenManager = this;
            screen.InputManager = this.InputManager;

            screen.Initialize();

            // If we have a graphics device, tell the screen to load content.
            if (_graphicsDeviceService != null && _graphicsDeviceService.GraphicsDevice != null)
                screen.LoadContent(new ContentManager(Game.Services, "Content"));

            lock (_screens)
                _screens.Add(screen);

            // Process post actions
            screen.AfterScreenIsAdded();
        }