Beispiel #1
0
        /// <summary>
        /// Unload your graphics content.
        /// </summary>
        protected override void UnloadContent()
        {
            ScreenStack.UnloadContent();

            DrawHelper?.Dispose();
            DrawHelper = null;
        }
Beispiel #2
0
        /// <summary>
        /// Load your graphics content.
        /// </summary>
        protected override void LoadContent()
        {
            SpriteBatch = new SpriteBatch(GraphicsDevice);

            DrawHelper = new DrawHelper(GraphicsDevice, SpriteBatch);

            ScreenStack.LoadContent();
        }
Beispiel #3
0
        public void RemoveScreens <T>() where T : IScreen
        {
            var screens = ScreenStack.FindScreens <T>().ToList();

            foreach (var screen in screens)
            {
                RemoveScreen(screen);
            }
        }
Beispiel #4
0
 /// <summary>
 /// Tells each screen to draw itself.
 /// </summary>
 public override void Draw(GameTime gameTime)
 {
     try
     {
         ScreenStack.Draw(gameTime);
     }
     catch (Exception ex)
     {
         ErrorScreen(ex);
     }
 }
Beispiel #5
0
        /// <summary>
        /// Removes a screen from the screen manager. You should normally
        /// use GameScreen.ExitScreen instead of calling this directly, so
        /// the screen can gradually transition off rather than just being
        /// instantly removed.
        /// </summary>
        public virtual void RemoveScreen(IScreen screen)
        {
            // If we have a graphics device, tell the screen to unload content.
            if (Initialized)
            {
                screen.UnloadContent();
            }

            ScreenStack.RemoveScreen(screen);

            //reset the times of all the rest of teh screens
            var widgetScreens = ScreenStack.Screens.OfType <WidgetScreen>();

            foreach (var curScreen in widgetScreens)
            {
                curScreen.ResetInputTimer();
            }
        }
Beispiel #6
0
        /// <summary>
        /// Constructs a new screen manager component.
        /// </summary>
        public ScreenManager(Game game, ScreenStackDelegate mainMenuStack)
            : base(game)
        {
            Initialized   = false;
            MainMenuStack = mainMenuStack;

            ScreenStack = new ScreenStack();

            ClearColor = new Color(0.0f, 0.1f, 0.2f);

            //get the touch service
            Input = game.Services.GetService <IInputHandler>();

            if (null == Input)
            {
                throw new Exception("Cannot initialize ScreenManager without first adding IInputHandler service");
            }

            game.Components.Add(this);
            game.Services.AddService(typeof(IScreenManager), this);

            //When using render targets, don't clear the screen!!!
            GraphicsDevice.PresentationParameters.RenderTargetUsage = RenderTargetUsage.PreserveContents;
        }
Beispiel #7
0
 public List <T> FindScreens <T>() where T : IScreen
 {
     return(ScreenStack.FindScreens <T>().ToList());
 }
Beispiel #8
0
 public override void Update(GameTime gameTime)
 {
     ScreenStack.Update(gameTime, Input, !Game.IsActive);
 }