private Menu CreateMapSelectionMenu() { SpriteFont font = Load.LoadFont("Fonts/font"); MapList list = Content.Load<MapList>("XmlData/Maps/maplist"); List<MenuItem> items = new List<MenuItem>(); for (int i = 0; i < list.allMaps.Count; i++) { MenuItem menuItem = new MenuItem("Menus/Buttons/button", Rectangle.Empty); menuItem.Text.Text.Append(list.allMaps[i]); menuItem.Text.Font = font; menuItem.Text.Color = Color.DarkOrange; menuItem.Text.Visible = true; menuItem.AddText(); menuItem.Color = Color.GhostWhite; menuItem.ClickedAction = () => { SelectedMap(menuItem.Text.Text.ToString()); StartGame(); }; items.Add(menuItem); } BasicMenu menu = new ListItemMenu("Menus/Backgrounds/background", new Rectangle(0, 0, displayWidth, displayHeight), "Map Selection",listItems: items); menu.Color = Color.PaleVioletRed; Button previous, next; TextButton back; previous = new Button("Graphics/leftArrow", Rectangle.Empty) { Name = "previous button" }; next = new Button("Graphics/rightArrow", Rectangle.Empty) { Name = "next button" }; back = new TextButton("Menus/Buttons/Button", new Rectangle(50, 400, 50, 20)) { Name = "back button" }; back.Text.Text.Append("BACK"); back.Text.Font = font; back.Text.Position = new Vector2(back.X_Coordinate + 5, back.Y_Coordinate); back.Text.Visible = true; back.Text.Color = Color.Chartreuse; back.Visible = true; back.AddText(); menu.TextButtons.Add(back); ListItemMenu itemMenu = menu as ListItemMenu; previous.ClickedAction = () => { itemMenu.priviousItem(); }; next.ClickedAction = () => { itemMenu.nextItem(); }; back.ClickedAction = () => { menuOrganizer.Nav_PreviousMenu(); }; IEnumerable<Button> navButtons = new Button[2] { previous, next }; itemMenu.NavButtons.AddRange(navButtons); itemMenu.CreatePlan = () => { Rectangle selectedItemPosition, nextItemPosition, previousItemPosition, nextButtonPosition, previousButtonPosition; previousItemPosition = new Rectangle(130, 200, 125, 100); selectedItemPosition = new Rectangle(260, 175, 225, 150); nextItemPosition = new Rectangle(490, 200, 125, 100); previousButtonPosition = new Rectangle(25, 225, 50, 50); nextButtonPosition = new Rectangle(670, 225, 50, 50); FloorPlan floorPlan = new FloorPlan(); floorPlan.AddDrawling(itemMenu.Previous, new BaseObject (string.Empty, previousItemPosition)); floorPlan.AddDrawling(itemMenu.Selected, new BaseObject(string.Empty, selectedItemPosition)); floorPlan.AddDrawling(itemMenu.Next, new BaseObject(string.Empty, nextItemPosition)); floorPlan.AddDrawling(itemMenu.PreviousButton, new BaseObject(string.Empty, previousButtonPosition)); floorPlan.AddDrawling(itemMenu.NextButton, new BaseObject(string.Empty, nextButtonPosition)); return floorPlan; }; itemMenu.PositionAnBind(); return menu; }
private void UpDateSelectedItem() { selectedItem = ListItems[SelectedItemIndex]; PlanChanged(); }
private Menu CreateGameSelectionMenu() { SpriteFont font = Load.LoadFont("Fonts/font"); List<MenuItem> items = new List<MenuItem>(); MenuItem item = new MenuItem("Menus/Buttons/button", Rectangle.Empty); item.Text.Text.Append("CLASSIC MAZE"); item.Text.Font = font; item.Text.Visible = true; item.Text.Color = Color.Aquamarine; item.AddText(); item.Color = Color.Chartreuse; item.ClickedAction = () => { SelectedGame(item.Text.Text.ToString()); ActivateMenu("Map Selection"); }; items.Add(item); BasicMenu menu = new ListItemMenu("Menus/Backgrounds/background", new Rectangle(0, 0, displayWidth, displayHeight), "Map Selection", listItems: items); menu.Color = Color.MediumVioletRed; Button previous, next; TextButton back; previous = new Button("Graphics/leftArrow", Rectangle.Empty) { Name = "previous button" }; next = new Button("Graphics/rightArrow", Rectangle.Empty) { Name = "next button" }; back = new TextButton("Menus/Buttons/Button", new Rectangle(50, 400, 50,20)) { Name = "back button" }; back.Text.Text.Append("BACK"); back.Text.Font = font; back.Text.Position = new Vector2(back.X_Coordinate + 5, back.Y_Coordinate); back.Text.Visible = true; back.Text.Color = Color.Black; back.Visible = true; back.AddText(); menu.TextButtons.Add(back); ListItemMenu itemMenu = menu as ListItemMenu; previous.ClickedAction = () => { itemMenu.priviousItem(); }; next.ClickedAction = () => { itemMenu.nextItem(); }; back.ClickedAction = () => { menuOrganizer.Nav_PreviousMenu(); }; IEnumerable<Button> navButtons = new Button[2] { previous, next, }; itemMenu.NavButtons.AddRange(navButtons); itemMenu.CreatePlan = () => { Rectangle selectedItemPosition, nextItemPosition, previousItemPosition, nextButtonPosition, previousButtonPosition; previousItemPosition = new Rectangle(130, 200, 125, 100); selectedItemPosition = new Rectangle(260, 175, 225, 150); nextItemPosition = new Rectangle(490, 200, 125, 100); previousButtonPosition = new Rectangle(25, 225, 50, 50); nextButtonPosition = new Rectangle(670, 225, 50, 50); FloorPlan floorPlan = new FloorPlan(); floorPlan.AddDrawling(itemMenu.Previous, new BaseObject(string.Empty, previousItemPosition)); floorPlan.AddDrawling(itemMenu.Selected, new BaseObject(string.Empty, selectedItemPosition)); floorPlan.AddDrawling(itemMenu.Next, new BaseObject(string.Empty, nextItemPosition)); floorPlan.AddDrawling(itemMenu.PreviousButton, new BaseObject(string.Empty, previousButtonPosition)); floorPlan.AddDrawling(itemMenu.NextButton, new BaseObject(string.Empty, nextButtonPosition)); return floorPlan; }; itemMenu.PositionAnBind(); return menu; }
public ListItemMenu(string texturePath, Rectangle rectangle, string name, int initalIndex = 0, Func<FloorPlan> createPlanFunc = null, List<Button> navButtons = null, List<MenuItem> listItems = null) : base(texturePath, rectangle, name) { this.NavButtons = (navButtons == null) ? new List<Button>() : navButtons; this.ListItems = (listItems == null) ? new List<MenuItem>() : listItems; if (createPlanFunc == null) floorPlan = new FloorPlan(); else { this.CreatePlan = createPlanFunc; floorPlan = CreatePlan(); } if (NavButtons.Count > 0) PositionNavButtons(); SetSelectedItemIndex(initalIndex); if (listItems.Count > 0) UpDateSelectedItem(); else selectedItem = new MenuItem(string.Empty, Rectangle.Empty); }