add Initialize() to IWindow & refactor uses of IWindow

GitOrigin-RevId: fa4c2f04d3182cd37f85cfd03e6a2025b4e4d4f7
This commit is contained in:
Colin McMillen 2019-12-04 17:09:02 -05:00
parent bb5aab6495
commit 92f4558c18
2 changed files with 7 additions and 6 deletions

View File

@ -2,6 +2,7 @@
namespace Jumpy {
public interface IWindow {
void SetFullScreen(bool fullScreen, Game game, GraphicsDeviceManager graphics);
void Initialize(GameWindow window, GraphicsDeviceManager graphics);
void SetFullScreen(bool fullScreen);
}
}

View File

@ -11,7 +11,7 @@ namespace Jumpy {
SpriteFont font;
KeyboardInput keyboardInput = new KeyboardInput();
bool fullScreen = false;
IWindow window;
IWindow display;
public JumpyGame() {
graphics = new GraphicsDeviceManager(this);
@ -21,9 +21,9 @@ namespace Jumpy {
// Performs initialization that's needed before starting to run.
protected override void Initialize() {
window = (IWindow) Services.GetService(typeof(IWindow));
window.SetFullScreen(fullScreen, this, graphics);
display = (IWindow) Services.GetService(typeof(IWindow));
display.Initialize(Window, graphics);
display.SetFullScreen(fullScreen);
base.Initialize();
}
@ -45,7 +45,7 @@ namespace Jumpy {
if (keysDown.Contains(Keys.F12)) {
fullScreen = !fullScreen;
window.SetFullScreen(fullScreen, this, graphics);
display.SetFullScreen(fullScreen);
}
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||