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; }
ScrollList createScrollList(Item parent) { ScrollList sl = new ScrollList(parent); sl.ViewCount = 2; Button btn = new Button(sl, App.Button, "Button texture"); btn = new Button(sl, App.Button, App.menuButtonHighlighted, "Highlight texture") { Scale = new Vector2(1.35f, 1.35f) }; btn = new Button(sl, App.Button, "White Font") { Scale = new Vector2(1.35f, 1.35f), }; btn.TextLabel.FontFocusColor = Color.White; btn = new Button(sl, App.Button, App.menuButtonHighlighted, "Swap Scroll Position"); btn.OnA = delegate() { sl.KeepFocus = true; //This prevents button from losing focus in a delegate invoke cycle if (sl.ScrollPosition == ScrollList.ScrollBarPosition.Left) sl.ScrollPosition = ScrollList.ScrollBarPosition.Right; else sl.ScrollPosition = ScrollList.ScrollBarPosition.Left; }; return sl; }
/// <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> /// 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> /// 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; }
ScrollList createScrollList(Item parent) { ScrollList sl = new ScrollList(parent); sl.ViewCount = 10; for (int i = 0; i < manager._lstLevels.Count; i++) { int noLevel = i; Button btn = new Button(sl, App.Button, App.menuButtonHighlighted, manager._lstLevels[noLevel].GetName() /* "Level " + (noLevel + 1)*/) { Scale = new Vector2(1f, 1f) }; btn.OnA = delegate() { manager.nivCourant = manager._lstLevels[noLevel]; this.Close(); }; } return sl; }
/// <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 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; }
/// <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; }