]> git.r.bdr.sh - rbdr/super-polarity/blame - SuperPolarity/ScreenManager.cs
Update README
[rbdr/super-polarity] / SuperPolarity / ScreenManager.cs
CommitLineData
9ad526c0 1using System;
74c15570
BB
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using Microsoft.Xna.Framework;
6using Microsoft.Xna.Framework.Graphics;
7
8namespace SuperPolarity
9{
10 static class ScreenManager
11 {
12 static Stack<Screen> Screens;
13 static SuperPolarity Game;
14
15 static ScreenManager()
16 {
17 Screens = new Stack<Screen>();
18 }
19
20 static public void Push(Screen screen)
21 {
b587e9d8
BB
22 if (Screens.Count > 0)
23 {
24 Screens.Peek().Active = false;
25 }
26
27 screen.LoadContent();
28 screen.Active = true;
74c15570
BB
29 Screens.Push(screen);
30 }
31
32 static public void Pop()
33 {
b587e9d8
BB
34 var screen = Screens.Pop();
35 screen.Active = false;
36 screen.CleanUp();
37 Screens.Peek().Active = true;
74c15570
BB
38 }
39
40 static public void Update(GameTime gameTime)
41 {
42 Screens.Peek().Update(gameTime);
43 }
44
45 static public void Draw(SpriteBatch spriteBatch)
46 {
b587e9d8 47 Screens.Peek().Draw(spriteBatch);
74c15570
BB
48 }
49
50 internal static void SetGame(SuperPolarity game)
51 {
52 Game = game;
53 }
54 }
55}