/// <summary>
        /// Initialises the main menu.
        /// </summary>
        private static void BuildMainMenu()
        {
            // Create some UIs
            UIContainer Menu = new UIContainer(
                "Main Menu",
                Point2D.ScreenMiddle - new Point2D(100, 100),
                new Point2D(200, 200),
                MenuType.Auto
                );

            List <UIElement> MenuList = new List <UIElement>();

            MenuList.Add(
                new MenuElement(
                    "New Game",
                    new Action(() => { StateController.Instance.StartGame(); }),
                    "New Game",
                    Menu
                    )
                );

            MenuList.Add(
                new MenuElement(
                    "Quit",
                    new Action(() => { StateController.Instance.QuitToDesktop(); }),
                    "Quit",
                    Menu
                    )
                );
        }
Пример #2
0
 public MenuElement(String Title, Action ClickAction, String Name, UIContainer Container)
     : this(Title, ClickAction, Name, Point2D.Origin, Point2D.Origin, Container)
 {
     if (Container.Type != MenuType.Auto)
     {
         throw new InvalidMenuTypeException();
     }
 }
Пример #3
0
 /// <summary>
 /// Initialises the static members of UIContainer.
 /// </summary>
 static UIContainer()
 {
     UIContainer.GameWindow = new UIContainer(
         new List <UIElement>(),
         "GameWindow",
         Point2D.Origin,
         new Point2D(ScreenWidth(), ScreenHeight()),
         MenuType.Manual
         );
 }
Пример #4
0
        /// <summary>
        /// Initialises a new instance of the UIElement class with the given name, position and size, within the given UIContainer.
        /// </summary>
        /// <param name="Name">Name given to the UI element</param>
        /// <param name="Pos">Position of the UI element</param>
        /// <param name="Size">Size of the UI element</param>
        /// <param name="Container">UIContainer containing the new UIElement</param>
        public UIElement(String Name, Point2D Pos, Point2D Size, UIContainer Container)
        {
            this.Name      = Name;
            this.Pos       = Pos;
            this.Size      = Size;
            this.Container = Container;

            StateController.Instance.UIElementList.Add(this);
            StateController.Instance.IDrawableList.Add(this);
            if (this is IClickable)
            {
                StateController.Instance.IClickableList.Add(this as IClickable);
            }
        }
Пример #5
0
        public MenuElement(String Title, Action ClickAction, String Name, Point2D Pos, Point2D Size, UIContainer Container)
            : base(Name, Pos, Size, Container)
        {
            this.Text        = Title;
            this.ClickAction = ClickAction;

            if (!this.Container.ChildElements.Contains(this))
            {
                this.Container.ChildElements.Add(this);
            }
        }