using System; using Chernobyl.Collections.Generic.Event; using Chernobyl.Graphics.Texture; using Chernobyl.StateMachine; namespace Chernobyl.Interface.Menu.Game { /// /// The interface for a basic main menu in a video game. This type is used /// to help create main menus for video games. /// public class MainMenu : State { /// /// Initializes a new instance of the class. /// /// The instance that gives out services for use /// by this type and takes services from this type for use by other /// systems. /// The button that starts the game that has /// been selected or null if a default button should be created. public MainMenu(IEventCollection services, Button startButton) { StartButton = startButton; if(StartButton == null) { StartButton = new Button(services, new Texture2D(services, "data/images/play.tga")); StartButton.Translate(700, 100); } StartButton.OnUp += StartButtonOnUp; } /// /// The button that starts the game that has been selected. /// public Button StartButton { get; private set; } /// /// An event handler that is invoked when the /// is let up. This method will /// disable the . /// /// The instance that generated the event. /// The instance containing the /// event data. protected virtual void StartButtonOnUp(object sender, EventArgs e) { StartButton.ClickableRegion.Disable(); StartButton.DrawableParent = null; } } }