/// <summary> /// Exits a screen and switches the active screen to its owner. /// </summary> /// <param name="screen">The screen to exit.</param> /// <param name="exitMessage">An exit message.</param> public static void ExitScreen(Screen screen, string exitMessage) { Screen parent = screen.Owner; RemoveScreen(screen, false); activeScreen = parent; parent.Start(exitMessage); }
/// <summary> /// Initializes this screen. /// </summary> /// <param name="owner">The screen that is creating this one.</param> /// <param name="parameters"> /// Parameters to specify how the screen should be initialized. /// Contains a path to the level file to load. /// </param> public override void Initialize(Screen owner, string parameters) { // level = new Level(); //level.Sections.Add(new Section(level)); // temporary level.ContentFolderPaths = new List<string>() { // System.IO.Directory.GetCurrentDirectory() + @"\TestPackage" }; level = new IO.LevelSerializers.Serializer003().Deserialize(System.IO.File.ReadAllText(parameters)); level.Path = parameters; level.Initialize(); }
/// <summary> /// Adds a screen to the manager. /// </summary> /// <param name="parent">The screen that owns the screen to add.</param> /// <param name="child">The screen to add.</param> public static void AddScreen(Screen parent, Screen child) { var childNode = new Hierarchy<Screen>(child); var parentNode = screens.Search(parent); if (parentNode != null) { parentNode.Add(childNode); } else { throw new ArgumentException("ScreenManager.AddScreen(Screen, Screen): Could not find the screen's parent node."); } }
/// <summary> /// Switches to another screen. /// </summary> /// <param name="switchTo">The screen to switch to.</param> public static void SwitchScreen(Screen switchTo) { if (screens.Search(switchTo) != null) { activeScreen.Stop(); switchTo.LoadContent(); activeScreen = switchTo; activeScreen.Start(); } else { throw new ArgumentException("ScreenManager.SwitchScreen(Screen): The screen to switch to was not present in the manager. Please use the AddScreen(Screen, string) method to add it first."); } }
/// <summary> /// Sets the highest screen in the hierarchy. This screen has no owner. /// </summary> /// <param name="screen">The screen to set as root.</param> /// <param name="parameters"> /// Parameters that are used to determine certain settings of a screen. /// Varies by screen; check the documentation. /// </param> public static void SetRootScreen(Screen screen, string parameters) { screens.Data = screen; activeScreen = screen; activeScreen.Initialize(null, parameters); activeScreen.Start(); }
/// <summary> /// Removes a screen from the manager. /// </summary> /// <param name="screen">The screen to remove.</param> /// <param name="removeChildren"> /// If true, all child screens are removed. If false, all child screens /// are assigned to their grandparent. /// </param> public static void RemoveScreen(Screen screen, bool removeChildren) { var screenNode = screens.Search(screen); var parentNode = screenNode.Parent; if (screenNode == null) { return; } if (!removeChildren) { // Move all screens one level up foreach (var child in screenNode.Children) { parentNode.Add(child); } } parentNode.Remove(screenNode); }
/// <summary> /// Initializes this screen. /// </summary> /// <param name="owner">The screen that has created this one.</param> /// <param name="parameters"> /// This screen accepts no parameters, use String.Empty. /// </param> public override void Initialize(Screen owner, string parameters) { Owner = owner; Effect = new FadeEffect(); Effect.Set(EffectDirection.Forward, Color.BlueViolet); }
/// <summary> /// Initializes this screen. /// </summary> /// <param name="owner">The screen that is creating this one.</param> /// <param name="parameters">Parameters are unused.</param> public override void Initialize(Screen owner, string parameters) { Effect = new FadeEffect(); }
/// <summary> /// Initializes this screen. /// </summary> /// <param name="owner">The screen that is creating this one.</param> /// <param name="parameters"> /// Parameters that are used to determine certain settings of a screen. /// Varies by screen; check the documentation. /// </param> public abstract void Initialize(Screen owner, string parameters);