Exemple #1
0
        /// <summary>
        /// Creates a Main Menu
        /// </summary>
        public static Menu createMainMenu(MultiController controllers, List<Controller> allControllers, Rectangle bounds)
        {
            Menu MainMenu = new Menu(controllers, bounds);
            MainMenu.BaseFrame.Layout = Layout.VerticalShared;

            new Label(MainMenu.BaseFrame, "Display Spring Demo") { Scale = new Vector2(2, 2), FontColor = Color.White };

            ScrollList sl = new ScrollList(MainMenu.BaseFrame);
            sl.Focus = true;
            sl.LayoutStretch = 4;
            sl.Scale = new Vector2(2,2);

            Label lbl = new Label(sl, "Frames Menu");
            lbl.OnA = delegate() { MainMenu.ActiveSubMenu = new FrameMenu(controllers, allControllers, bounds); };
            lbl = new Label(sl, "Open submenu of this menu (recursion!)");
            lbl.OnA = delegate() { MainMenu.ActiveSubMenu = MenuCreator.createMainMenu(controllers, allControllers, bounds); };
            lbl = new Label(sl, "Scroll List Menu");
            lbl.OnA = delegate() { MainMenu.ActiveSubMenu = new ButtonScrollListMenu(controllers, allControllers, bounds); };
            lbl = new Label(sl, "Multi Texture Menu");
            lbl.OnA = delegate() { MainMenu.ActiveSubMenu = new MultiTextureMenu(controllers, allControllers, bounds); };
            lbl = new Label(sl, "Input Menu");
            lbl.OnA = delegate() { MainMenu.ActiveSubMenu = new InputMenu(controllers, allControllers, bounds); };
            lbl = new Label(sl, "Option Button Menu");
            lbl.OnA = delegate() { MainMenu.ActiveSubMenu = new OptionButtonMenu(controllers, allControllers, bounds); };
            lbl = new Label(sl, "Exit");
            lbl.OnA = delegate() { MainMenu.Close(); };
            return MainMenu;
        }
Exemple #2
0
        /// <summary>
        /// Creates a Main Menu
        /// </summary>
        public static Menu createMainMenu(MultiController controllers, List<Controller> allControllers, Rectangle bounds, GameManager pmanager, Boolean recommencer = false)
        {
            Menu MainMenu = new Menu(controllers, bounds);
            MainMenu.BaseFrame.Layout = Layout.VerticalShared;

            new Label(MainMenu.BaseFrame, "Asteroids") { Scale = new Vector2(2, 2), FontColor = Color.White };

            ScrollList sl = new ScrollList(MainMenu.BaseFrame);
            sl.Focus = true;
            sl.LayoutStretch = 4;
            sl.Scale = new Vector2(2, 2);

            Label lbl = new Label(sl, (recommencer ? "Restart" : "Start"));
            lbl.OnA = delegate() { MainMenu.Close(); };

            lbl = new Label(sl, "Choose Level");
            lbl.OnA = delegate()
            {
                MainMenu.ActiveSubMenu = new ChooseLevelMenu(controllers, allControllers, bounds, pmanager);
                MainMenu.ActiveSubMenu.OnClosing = delegate() { MainMenu.Close(); };
            };

            /*lbl = new Label(sl, "Options");
            lbl.OnA = delegate()
            {
                //MainMenu.ActiveSubMenu = new OptionButtonMenu(controllers, allControllers, bounds);
            };*/

            lbl = new Label(sl, "Exit");
            lbl.OnA = delegate() { MainMenu.Close(); pmanager._game.Exit(); };
            return MainMenu;
        }
Exemple #3
0
        /// <summary>
        /// Creates a Death Menu
        /// </summary>
        public static Menu createDeathMenu(MultiController controllers, List<Controller> allControllers, Rectangle bounds, GameManager pmanager)
        {
            Menu MainMenu = new Menu(controllers, bounds);
            MainMenu.BaseFrame.Layout = Layout.VerticalShared;

            new Label(MainMenu.BaseFrame, "You D.I.E.D.!!!!!") { Scale = new Vector2(2, 2), FontColor = new Color(200,0,0), Animation = AnimateType.Size };
            new Label(MainMenu.BaseFrame, "Score Level '" + pmanager.nivCourant.GetName() + "': " + pmanager._playerScore.ToString()) { Scale = new Vector2(2, 2), FontColor = Color.White };

            ScrollList sl = new ScrollList(MainMenu.BaseFrame);
            sl.Focus = true;
            sl.LayoutStretch = 4;
            sl.Scale = new Vector2(2, 2);

            Label lbl = new Label(sl, "Try Again!");
            lbl.OnA = delegate() { MainMenu.Close(); };
            lbl.FontColor = Color.DarkBlue;
            lbl.FontFocusColor = Color.DarkRed;

            lbl = new Label(sl, "Choose Level");
            lbl.OnA = delegate()
            {
                MainMenu.ActiveSubMenu = new ChooseLevelMenu(controllers, allControllers, bounds, pmanager);
                MainMenu.ActiveSubMenu.OnClosing = delegate() { MainMenu.Close(); };
            };
            lbl.FontColor = Color.DarkBlue;
            lbl.FontFocusColor = Color.DarkRed;

            lbl = new Label(sl, "Quit");
            lbl.OnA = delegate() { MainMenu.Close(); pmanager._game.Exit(); };
            lbl.FontColor = Color.DarkBlue;
            lbl.FontFocusColor = Color.DarkRed;
            return MainMenu;
        }
        /// <summary>
        /// Sample Button Scroll List Menu
        /// </summary>
        public MultiTextureMenu(MultiController controllers, List<Controller> allControllers, Rectangle bounds)
            : base(controllers, bounds)
        {
            Label lbl = new Label(BaseFrame,
                "Create MultiTextures by placing items in a Frame\n" +
                "Press A (Enter) to change alignment on Frame\n" +
                "Left Thumbstick (Arrow Keys) to move around\n" +
                "+/- to scale\nStart or Space to reset");
            lbl.Depth += .11f;

            BaseFrame.InputState = ButtonState.Continuous;

            multiFrame = new Frame(BaseFrame, new Vector2(400, 200))
            {
                HorizontalAlignment = HAlign.Left,
                VerticalAlignment = VAlign.Top,
            };

            Sprite background = new Sprite(multiFrame, Item.ButtonTexture)
            {
                HorizontalAlignment = HAlign.Stretch,
                VerticalAlignment = VAlign.Stretch,
            };
            background.Depth += .1f;

            new Label(multiFrame, "Left") { HorizontalAlignment = HAlign.Left };
            new Label(multiFrame, "Bot Left") { HorizontalAlignment = HAlign.Left, VerticalAlignment = VAlign.Bottom };
            new Label(multiFrame, "Bot Right") { HorizontalAlignment = HAlign.Right, VerticalAlignment = VAlign.Bottom };
            new Label(multiFrame, "Top") { VerticalAlignment = VAlign.Top };
            new Label(multiFrame, "Top left") { VerticalAlignment = VAlign.Top, HorizontalAlignment = HAlign.Left };
            new Label(multiFrame, "Top right") { VerticalAlignment = VAlign.Top, HorizontalAlignment = HAlign.Right };
            new Label(multiFrame, "Bottom") { VerticalAlignment = VAlign.Bottom };
            new Label(multiFrame, "Right") { HorizontalAlignment = HAlign.Right };
            new Label(multiFrame, "400x200 frame\nTop Left Aligned");

            int at = 4;
            multiFrame.OnA = delegate()
            {
                multiFrame.KeepFocus = true;

                if (at == 0)
                {
                    multiFrame.HorizontalAlignment = HAlign.Right;
                    multiFrame.VerticalAlignment = VAlign.Top;
                }
                else if (at == 1)
                    multiFrame.VerticalAlignment = VAlign.Bottom;
                else if (at == 2)
                    multiFrame.HorizontalAlignment = HAlign.Left;
                else if (at == 3)
                    multiFrame.VerticalAlignment = VAlign.Top;
                else if (at == 4)
                {
                    multiFrame.HorizontalAlignment = HAlign.Center;
                    multiFrame.VerticalAlignment = VAlign.Center;
                    at = -1;
                }

                at++;
            };

            BaseFrame.OnUp = delegate()
            {
                BaseFrame.KeepFocus = true;

                multiFrame.Offset -= Vector2.UnitY * 15;
            };

            BaseFrame.OnDown = delegate()
            {
                BaseFrame.KeepFocus = true;

                multiFrame.Offset += Vector2.UnitY * 15;
            };

            BaseFrame.OnLeft = delegate()
            {
                BaseFrame.KeepFocus = true;

                multiFrame.Offset -= Vector2.UnitX * 15;
            };

            BaseFrame.OnRight = delegate()
            {
                BaseFrame.KeepFocus = true;

                multiFrame.Offset += Vector2.UnitX * 15;
            };

            BaseFrame.OnStart = delegate()
            {
                BaseFrame.KeepFocus = true;
                multiFrame.Scale = Vector2.One;
                multiFrame.Offset = Vector2.Zero;
                multiFrame.HorizontalAlignment = HAlign.Left;
                multiFrame.VerticalAlignment = VAlign.Top;
            };

            Reset();
        }
Exemple #5
0
        private void Initialize(Texture2D background, Texture2D focused, string text)
        {
            if (background == null && focused == null)
                throw new Exception("Cannot create a button with no background or focus background");

            if (background != null)
            {
                m_bg = new Sprite(this, background);
                m_bg.Fade = false;
            }
            if (focused != null)
            {
                m_focused = new Sprite(this, focused);
                m_focused.Fade = false;
            }

            if (Background != null)
            {
                if (FocusTexture != null && (FocusTexture.Height != Background.Height || FocusTexture.Width != Background.Width))
                    Console.WriteLine("Warning: The background and highlighed textures should be the same size");
            }

            //TODO: make sure height and width of button are correct with label
            m_label = new Label(this, text);
            m_label.Animation = AnimateType.None;
            m_label.FocusSound = null;
            m_label.Fade = false;

            Animation = AnimateType.Size;

            forceRefresh();
        }
Exemple #6
0
        /// <summary>
        /// Creates a Win Menu
        /// </summary>
        public static Menu createWinMenu(MultiController controllers, List<Controller> allControllers, Rectangle bounds, GameManager pmanager)
        {
            Menu MainMenu = new Menu(controllers, bounds);
            MainMenu.BaseFrame.Layout = Layout.VerticalShared;

            new Label(MainMenu.BaseFrame, "Level succes!") { Scale = new Vector2(2, 2), FontColor = Color.White };
            new Label(MainMenu.BaseFrame, "Score Level '" + pmanager.nivCourant.GetName() + "': " + pmanager._playerScore.ToString()) { Scale = new Vector2(2, 2), FontColor = Color.White };

            ScrollList sl = new ScrollList(MainMenu.BaseFrame);
            sl.Focus = true;
            sl.LayoutStretch = 4;
            sl.Scale = new Vector2(2, 2);

            Label lbl = new Label(sl, "Next Level");
            lbl.OnA = delegate() { MainMenu.Close(); };

            lbl = new Label(sl, "Choose Level");
            lbl.OnA = delegate()
            {
                MainMenu.ActiveSubMenu = new ChooseLevelMenu(controllers, allControllers, bounds, pmanager);
                MainMenu.ActiveSubMenu.OnClosing = delegate() { MainMenu.Close(); };
            };

            lbl = new Label(sl, "Exit");
            lbl.OnA = delegate() { MainMenu.Close(); pmanager._game.Exit(); };
            return MainMenu;
        }
Exemple #7
0
        /// <summary>
        /// Creates a Pause Menu
        /// </summary>
        public static Menu createPauseMenu(MultiController controllers, List<Controller> allControllers, Rectangle bounds, GameManager pmanager)
        {
            Menu MainMenu = new Menu(controllers, bounds);
            MainMenu.BaseFrame.Layout = Layout.VerticalShared;

            new Label(MainMenu.BaseFrame, "Score Level '" + pmanager.nivCourant.GetName() + "': " + pmanager._playerScore.ToString()) { Scale = new Vector2(2, 2), FontColor = Color.White };
            new Label(MainMenu.BaseFrame, "Levels Completed : " + pmanager._levelsCompleted.ToString()) { Scale = new Vector2(2, 2), FontColor = Color.White };
            new Label(MainMenu.BaseFrame, "Lives Lost : " + pmanager._playerDeaths.ToString()) { Scale = new Vector2(2, 2), FontColor = Color.White };
            new Label(MainMenu.BaseFrame, "Asteroids Destroyed : " + pmanager._astKilled.ToString()) { Scale = new Vector2(2, 2), FontColor = Color.White };
            new Label(MainMenu.BaseFrame, "Ennemy Ships Destroyed : " + pmanager._enemiKilled.ToString()) { Scale = new Vector2(2, 2), FontColor = Color.White };

            ScrollList sl = new ScrollList(MainMenu.BaseFrame);
            sl.Focus = true;
            sl.LayoutStretch = 4;
            sl.Scale = new Vector2(2, 2);

            Label lbl = new Label(sl, "Resume");
            lbl.OnA = delegate() { MainMenu.Close(); };
            lbl.FontColor = Color.DarkBlue;
            lbl.FontFocusColor = Color.DarkRed;

            lbl = new Label(sl, "Quit");
            lbl.OnA = delegate() { MainMenu.Close(); pmanager._game.Exit(); };
            lbl.FontColor = Color.DarkBlue;
            lbl.FontFocusColor = Color.DarkRed;
            return MainMenu;
        }