/// <summary> /// Sample Button Scroll List Menu /// </summary> public ButtonScrollListMenu(MultiController controllers, List<Controller> allControllers, Rectangle bounds) : base(controllers, bounds) { BaseFrame.Layout = Layout.VerticalShared; //Create a title, and scale the text so it is a little bigger new Label(BaseFrame, "This menu shows a sample of buttons in a scroll list.") { Scale = new Vector2(1.25f, 1.25f), FontColor = Color.Gold }; sl = new ScrollList(BaseFrame, 3) { Direction = ScrollList.Orientation.Horizontal, LayoutStretch = 2, ScrollPosition = ScrollList.ScrollBarPosition.Left, //left means top for horizontal orientation HorizontalAlignment = HAlign.Stretch }; createScrollList(sl); ScrollList tsl = createScrollList(sl); tsl.Scale *= 2f; tsl = createScrollList(sl); tsl.Scale *= 0.5f; tsl = createScrollList(sl); tsl = createScrollList(sl); tsl.Scale *= 2f; Reset(); }
/// <summary> /// Sample Button Scroll List Menu /// </summary> public ChooseLevelMenu(MultiController controllers, List<Controller> allControllers, Rectangle bounds, GameManager pmanager) : base(controllers, bounds) { manager = pmanager; BaseFrame.Layout = Layout.None; //Create a title, and scale the text so it is a little bigger new Label(BaseFrame, "List of levels") { Scale = new Vector2(2f, 2f), FontColor = Color.Gold , VerticalAlignment = VAlign.Top }; sl = new ScrollList(BaseFrame, 10) { Direction = ScrollList.Orientation.Horizontal, LayoutStretch = 5, ScrollPosition = ScrollList.ScrollBarPosition.Left, //left means top for horizontal orientation HorizontalAlignment = HAlign.Center }; createScrollList(sl); /* ScrollList tsl = createScrollList(sl); tsl.Scale *= 2f; tsl = createScrollList(sl); tsl.Scale *= 0.5f; tsl = createScrollList(sl); tsl = createScrollList(sl); tsl.Scale *= 2f; */ Reset(); }
/// <summary> /// Create a StackedItem with parents size. /// </summary> public OptionList(Item parent, MultiController controllers) : base(parent) { Animation = AnimateType.None; ItemController = controllers; Initialize(); }
/// <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; }
/// <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; }
public InputMenu(MultiController controllers, List<Controller> allControllers, Rectangle bounds) : base(controllers, bounds) { BaseFrame.Layout = Frame.LayoutType.HorizontalShared; ScrollList leftList = new ScrollList(BaseFrame); Frame statusFrame = new Frame(BaseFrame) { Layout = Frame.LayoutType.Vertical }; new Label(statusFrame, "Using ButtonState " + leftList.InputState.ToString()); new Label(statusFrame, "Using ButtonState " + leftList.InputState.ToString()); ScrollList rightList = new ScrollList(BaseFrame); leftList.OnRight = delegate() { rightList.Focus = true; }; rightList.OnLeft = delegate() { leftList.Focus = true; }; OptionList options = new OptionList(leftList); Button btn = new Button(options, "Pressed") { FocusTexture = null, OnFocus = delegate() { } }; btn.TextLabel.FontFocusColor = Color.White; btn = new Button(options, "Released") { FocusTexture = null }; btn.TextLabel.FontFocusColor = Color.White; btn = new Button(options, "Held") { FocusTexture = null }; btn.TextLabel.FontFocusColor = Color.White; btn = new Button(options, "Continuous") { FocusTexture = null }; btn.TextLabel.FontFocusColor = Color.White; DefaultItem = leftList; }
/// <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; }
/// <summary> /// default constructor for a menu /// </summary> /// <param name="c">Controllers that the menu receives input from</param> /// <param name="bounds">Bounds the menu will reside in</param> public Menu(MultiController c, Rectangle bounds) { if(m_font == null) throw new Exception("Error: Cannot construct a menu without calling Menu.LoadContent()"); m_defaultItem = m_baseFrame; m_closeSound = DefaultCloseSound; m_bounds = bounds; m_controllers = c; m_baseFrame = new Frame(null); m_baseFrame.ItemController = m_controllers; LayoutSize = new Vector2(bounds.Width, bounds.Height); Init(); }
/// <summary> /// Sample Button Scroll List Menu /// </summary> public OptionButtonMenu(MultiController controllers, List<Controller> allControllers, Rectangle bounds) : base(controllers, bounds) { BaseFrame.Layout = Layout.VerticalShared; new Label(BaseFrame, "Left, Right controls index of OptionButton") { VerticalAlignment = VAlign.Bottom }; ScrollList sl = new ScrollList(BaseFrame) { LayoutStretch = 3 }; OptionList options = createOptionButton(sl, "Arrows Out"); options.ArrowsOut = true; createOptionButton(sl, "Arrows In"); DefaultItem = sl; }
/// <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; }
/// <summary> /// Sample Frame Menu /// </summary> public FrameMenu(MultiController controllers, List<Controller> allControllers, Rectangle bounds) : base(controllers, bounds) { stack = new StackedItem(BaseFrame); Frame menu_left = new Frame(stack) { SizePolicy = Frame.SizeType.Maximum }; Frame menu_mid = new Frame(stack) { SizePolicy = Frame.SizeType.Maximum }; Frame menu_right = new Frame(stack) { SizePolicy = Frame.SizeType.Maximum }; stack.CurrentIndex = 1; stack.OnRight = delegate() { stack.KeepFocus = true; stack.CurrentIndex++; }; stack.OnLeft = delegate() { stack.KeepFocus = true; stack.CurrentIndex--; }; new Button(menu_mid, "Top left aligned") { HorizontalAlignment = HAlign.Left, VerticalAlignment = VAlign.Top }; new Button(menu_mid, "Top right aligned") { HorizontalAlignment = HAlign.Right, VerticalAlignment = VAlign.Top }; new Button(menu_mid, "Bot left aligned") { HorizontalAlignment = HAlign.Left, VerticalAlignment = VAlign.Bottom }; new Button(menu_mid, "Bot right aligned") { HorizontalAlignment = HAlign.Right, VerticalAlignment = VAlign.Bottom }; new Button(menu_mid, "Bot aligned") { VerticalAlignment = VAlign.Bottom }; new Button(menu_mid, "Top aligned") { VerticalAlignment = VAlign.Top }; new Button(menu_mid, Item.ArrowRight, "Alignment Stretch") { HorizontalAlignment = HAlign.Right, LabelStyle = Button.Style.LabelLeft }; new Button(menu_mid, Item.ArrowLeft, "Size policies") { HorizontalAlignment = HAlign.Left, LabelStyle = Button.Style.LabelRight }; new Label(menu_mid, "Buttons with Alignments\nThese menus are in a stacked item.\nThis allows the left and right to\nswitch menus easily"); new Label(menu_right, "Alignment Stretch"); new Button(menu_right, "Top Horizontal Stretch (menuTwo Width)") { VerticalAlignment = VAlign.Top, HorizontalAlignment = HAlign.Stretch }; new Button(menu_right, "Bottom Horizontal Stretch (menuTwo Width)") { VerticalAlignment = VAlign.Bottom, HorizontalAlignment = HAlign.Stretch }; Frame constrainingFrame = new Frame(menu_right) { SizePolicy = Frame.SizeType.Fixed, HorizontalAlignment = HAlign.Right }; Button vertBtn = new Button(constrainingFrame, "Alignment Right\nVertical Align Stretch\nFixed height (500 px)") { VerticalAlignment = VAlign.Stretch, Animation = AnimateType.None, }; constrainingFrame.FixedSize = new Vector2(vertBtn.MeasureWidth, 500); new Button(menu_right, Item.ArrowLeft, "Alignments") { HorizontalAlignment = HAlign.Left, LabelStyle = Button.Style.LabelRight }; new Label(menu_left, "Size policies") { Offset = new Vector2(0, -250) }; Frame topSharedFrame = new Frame(menu_left) { Layout = Frame.LayoutType.HorizontalShared, VerticalAlignment = VAlign.Top }; new Button(topSharedFrame, "Top Aligned"){ Animation = AnimateType.None, HorizontalAlignment = HAlign.Left }; new Button(topSharedFrame, "Horizontal Layout"){ Animation = AnimateType.None }; new Button(topSharedFrame, "Sharing"){ Animation = AnimateType.None }; new Button(topSharedFrame, "Screen Width"){ Animation = AnimateType.None, HorizontalAlignment = HAlign.Right }; Frame leftSharedFrame = new Frame(menu_left) { Layout = Frame.LayoutType.VerticalShared, HorizontalAlignment = HAlign.Left }; new Button(leftSharedFrame, "Left Aligned"){ Animation = AnimateType.None }; new Button(leftSharedFrame, "Vertical Layout"){ Animation = AnimateType.None }; new Button(leftSharedFrame, "Sharing"){ Animation = AnimateType.None }; new Button(leftSharedFrame, "Screen Height"){ Animation = AnimateType.None }; Frame greedyMiddleFrame = new Frame(menu_left) { Padding = 0, Layout = Frame.LayoutType.Vertical }; new Button(greedyMiddleFrame, "Center Aligned") { Animation = AnimateType.None }; new Button(greedyMiddleFrame, "Vertical Layout"){ Animation = AnimateType.None }; new Button(greedyMiddleFrame, "Not Sharing"){ Animation = AnimateType.None }; new Button(greedyMiddleFrame, "Screen Height"){ Animation = AnimateType.None }; Frame greedyBottomFrame = new Frame(menu_left) { Padding = 0, Layout = Frame.LayoutType.HorizontalShared, VerticalAlignment = VAlign.Bottom }; Button temp = new Button(greedyBottomFrame, "Bottom Aligned") { Animation = AnimateType.None, HorizontalAlignment = HAlign.Left }; new Button(greedyBottomFrame, "Horizontal Layout") { Animation = AnimateType.None }; new Button(greedyBottomFrame, "Sharing") { Animation = AnimateType.None }; new Button(greedyBottomFrame, "Screen Width") { Animation = AnimateType.None, HorizontalAlignment = HAlign.Right }; new Button(menu_left, Item.ArrowRight, "Alignments") { HorizontalAlignment = HAlign.Right, LabelStyle = Button.Style.LabelLeft }; Reset(); }
/// <summary> /// Create and empty ScrollList /// </summary> public ScrollList(Item parent, MultiController c) : base(parent, c) { Initialize(-1); }
/// <summary> /// Create an empty scroll list that can only show up to 'viewCount' items at one time /// without needing a ScrollBar present. /// </summary> public ScrollList(Item parent, MultiController c, int viewCount) : base(parent, c) { Initialize(viewCount); }
/// <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(); }
/// <summary> /// Create a menu item with specific background and focus background with text /// </summary> public Button(Item parent, MultiController c, Texture2D background, Texture2D focused, string text) : base(parent, c) { Initialize(background, focused, text); }
/// <summary> /// Create a button with specific background /// </summary> public Button(Item parent, MultiController c, Texture2D background) : base(parent, c) { Initialize(background, null, ""); }
/// <summary> /// Create a default button with a label /// </summary> public Button(Item parent, MultiController c, string label) : base(parent, c) { Initialize(Button.ButtonTexture, Button.ButtonHighlightTexture, label); }
/// <summary> /// Create a default button /// </summary> public Button(Item parent, MultiController c) : base(parent, c) { Initialize(Button.ButtonTexture, Button.ButtonHighlightTexture, ""); }
/// <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; }