public override void Reset() { base.Reset(); string[] testItems = new string[10]; for (int i = 0; i < 10; i++) { testItems[i] = @"test " + i; } styledDropDownMenu = new StyledDropDownMenu { Width = 150, Position = new Vector2(200, 70), Description = @"Drop-down menu", Depth = 1, Items = testItems.Select(i => new KeyValuePair <string, string>(i, i)), SelectedIndex = 4, }; Add(styledDropDownMenu); }
public override void Reset() { base.Reset(); // Creating drop-down for beatmaps dropDownMenu = new DropDownMenu <BeatmapExample> { Width = 150, Position = new Vector2(200, 20), Description = @"Beatmap selector example", Items = new DropDownMenuItem <BeatmapExample>[] { new DropDownMenuHeader <BeatmapExample>("Ranked"), new DropDownMenuItem <BeatmapExample>( "Example", new BeatmapExample { Name = @"Example", Mapper = @"peppy", Status = BeatmapExampleStatus.Ranked, } ), new DropDownMenuItem <BeatmapExample>( "Make up!", new BeatmapExample { Name = @"Make up!", Mapper = @"peppy", Status = BeatmapExampleStatus.Ranked, } ), new DropDownMenuItem <BeatmapExample>( "Platinum", new BeatmapExample { Name = @"Platinum", Mapper = @"arflyte", Status = BeatmapExampleStatus.Ranked, } ), }, }; Add(dropDownMenu); // Adding more items after init dropDownMenu.AddItem(new DropDownMenuHeader <BeatmapExample>("Not submitted")); dropDownMenu.AddItem(new DropDownMenuItem <BeatmapExample>( "Lorem ipsum dolor sit amed", new BeatmapExample { Name = @"Lorem ipsum dolor sit amed", Mapper = @"Plato", Status = BeatmapExampleStatus.NotSubmitted, }) ); // Setting default index and event handler dropDownMenu.SelectedIndex = 0; dropDownMenu.ValueChanged += DropDownBox_ValueChanged; labelSelectedMap = new SpriteText { Text = @"Waiting for map...", Position = new Vector2(450, 20), }; Add(labelSelectedMap); labelNewMap = new SpriteText { Text = @"", Position = new Vector2(450, 60), }; Add(labelNewMap); // Styled drop-down example StyledDropDownMenuItem[] testItems = new StyledDropDownMenuItem[10]; for (int i = 0; i < 10; i++) { testItems[i] = new StyledDropDownMenuItem(@"test " + i); } styledDropDownMenu = new StyledDropDownMenu { Width = 150, Position = new Vector2(200, 70), Description = @"Drop-down menu with style", Depth = -1, Items = testItems, SelectedIndex = 4, }; Add(styledDropDownMenu); AddButton(@"+ beatmap", delegate { string[] mapNames = { "Cool", "Stylish", "Philosofical", "Tekno" }; string[] mapperNames = { "peppy", "arflyte", "Plato", "BanchoBot" }; BeatmapExample newMap = new BeatmapExample { Name = mapNames[RNG.Next(mapNames.Length)], Mapper = mapperNames[RNG.Next(mapperNames.Length)], Status = BeatmapExampleStatus.NotSubmitted, }; dropDownMenu.AddItem(new DropDownMenuItem <BeatmapExample>(newMap.Name, newMap)); labelNewMap.Text = $@"Added ""{newMap.Name}"" by {newMap.Mapper} as {newMap.Status}"; }); }