public void AddScreen(Data.UI.Interfaces.IGameScreen screen, bool loaded = false) { screen.StateManager = this; if (!loaded) { screen.Initialize(); } if (screen is IDrawable) { var dScreen = screen as IDrawable; if (!loaded) { dScreen.LoadContent(); } if (dScreen.CoversOthers) { foreach (IDrawable oScreen in _gameScreens) { oScreen.IsCovered = true; oScreen.OnTop = false; } dScreen.OnTop = true; dScreen.IsCovered = false; } } if (screen is IInputReciever) { var iScreen = screen as IInputReciever; var inputScreens = from s in _gameScreens where s is IInputReciever select s; foreach (IInputReciever oScreen in inputScreens) { oScreen.HasFocus = false; } InputManager.RegisterScreen(iScreen); iScreen.HasFocus = true; } if (_gameScreens.Count > 0 && _gameScreens.Last.Value is SystemScreens.LoadingScreen) { _gameScreens.AddBefore(_gameScreens.Last, screen); } else { _gameScreens.AddLast(screen); } }
public void AddScreen(Data.UI.Interfaces.IGameScreen screen, bool loaded = false) { screen.StateManager = this; if (_ready && !loaded) { screen.Initialize(); screen.LoadContent(); } if (screen.GetsInput) { screen.HasFocus = true; InputManager.RegisterScreen(screen); if (_gameScreens.Count > 0) { var oldScreen = _gameScreens.First; do { oldScreen.Value.HasFocus = false; oldScreen = oldScreen.Next; } while (oldScreen != null); } } if (screen.CoversOthers) { screen.HasFocus = true; if (_gameScreens.Count > 0) { var oldScreen = _gameScreens.First; do { oldScreen.Value.IsCovered = true; oldScreen = oldScreen.Next; } while (oldScreen != null); } _gameScreens.AddLast(screen); } else { _gameScreens.AddBefore(_gameScreens.Last, screen); } }