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> /// 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 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> /// 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(); }