]>
Commit | Line | Data |
---|---|---|
1 | using System; | |
2 | using System.Collections.Generic; | |
3 | using System.Linq; | |
4 | using System.Text; | |
5 | using Microsoft.Xna.Framework; | |
6 | using Microsoft.Xna.Framework.Graphics; | |
7 | ||
8 | namespace 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 | { | |
22 | if (Screens.Count > 0) | |
23 | { | |
24 | Screens.Peek().Active = false; | |
25 | } | |
26 | ||
27 | screen.LoadContent(); | |
28 | screen.Active = true; | |
29 | Screens.Push(screen); | |
30 | } | |
31 | ||
32 | static public void Pop() | |
33 | { | |
34 | var screen = Screens.Pop(); | |
35 | screen.Active = false; | |
36 | screen.CleanUp(); | |
37 | Screens.Peek().Active = true; | |
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 | { | |
47 | Screens.Peek().Draw(spriteBatch); | |
48 | } | |
49 | ||
50 | internal static void SetGame(SuperPolarity game) | |
51 | { | |
52 | Game = game; | |
53 | } | |
54 | } | |
55 | } |