public DropDownMenu(GameScreen screen, DisplayLayer drawOrder, int itemNum, MenuItemInfo info) : base(screen, drawOrder, itemNum, info) { // drop-down menu dropdown = new VerticalMenu (screen, new WidgetInfo (), DisplayLayer.SubMenu); dropdown.ItemForegroundColor = DropDownForegroundColor; dropdown.ItemBackgroundColor = DropDownBackgroundColor; dropdown.ItemAlignX = HorizontalAlignment.Left; dropdown.ItemAlignY = VerticalAlignment.Center; dropdown.Border = new Border (new Color (0xb4, 0xff, 0x00), 5, 5, 0, 0); dropdown.IsVisible = false; // selected value MenuItemInfo valueInfo = new MenuItemInfo () { Text = "---", RelativePosition = () => ValuePosition (0), RelativeSize = () => ValueSize (0), OnClick = () => info.OnClick (), }; selected = new MenuButton (screen, DisplayLayer.MenuItem, 0, valueInfo); selected.Info.ForegroundColor = () => DropDownForegroundColor (selected.ItemState); selected.Info.BackgroundColor = () => DropDownBackgroundColor (selected.ItemState); // action to open the drop-down menu info.OnClick = () => { GameScreens.VideoOptionScreen.Collapse (this); if (dropdown.IsVisible == true) { dropdown.IsVisible = false; } else { dropdown.IsVisible = true; } }; }
public override void Initialize() { base.Initialize (); // create a new SpriteBatch, which can be used to draw textures spriteBatch = new SpriteBatch (device); // menu menu.ItemForegroundColor = ForegroundColor; menu.ItemBackgroundColor = BackgroundColor; menu.ItemAlignX = HorizontalAlignment.Left; menu.ItemAlignY = VerticalAlignment.Center; MenuItemInfo info; info = new MenuItemInfo (text: "Video", onClick: () => NextState = GameScreens.VideoOptionScreen); menu.AddButton (info.AddKey (Keys.V)); info = new MenuItemInfo (text: "Audio", onClick: () => NextState = GameScreens.OptionScreen); menu.AddButton (info.AddKey (Keys.A)); info = new MenuItemInfo (text: "Controls", onClick: () => NextState = GameScreens.OptionScreen); menu.AddButton (info.AddKey (Keys.C)); info = new MenuItemInfo (text: "Knots", onClick: () => NextState = GameScreens.OptionScreen); menu.AddButton (info.AddKey (Keys.K)); info = new MenuItemInfo (text: "Back", onClick: () => NextState = GameScreens.StartScreen); menu.AddButton (info.AddKey (Keys.Escape)); // lines HfGDesign.AddLinePoints (ref LinePoints, 0, 50, 30, 970, 970, 50, 1000 ); }
public ConfirmDialog(GameScreen screen, WidgetInfo info, DisplayLayer drawOrder) : base(screen, info, drawOrder) { // text Text = new string[] {}; // actions Action onYesClick = () => { OnYesClick (); if (CanClose) { Done (); } }; Action onNoClick = () => { OnNoClick (); Done (); }; Action onCancelClick = () => { OnCancelClick (); Done (); }; // buttons buttons.RelativeItemPosition = RelativeButtonPosition; buttons.RelativeItemSize = RelativeButtonSize; var itemInfo = new MenuItemInfo () { Text = "Yes", OnClick = onYesClick }; buttons.AddButton (itemInfo); itemInfo = new MenuItemInfo () { Text = "No", OnClick = onNoClick }; buttons.AddButton (itemInfo); itemInfo = new MenuItemInfo () { Text = "Cancel", OnClick = onCancelClick }; buttons.AddButton (itemInfo); }
private void assignMenuItemInfo(ref MenuItemInfo info, int num, MenuItem item) { if (RelativeItemPosition != null) { info.RelativePosition = () => RelativeItemPosition (num); } if (RelativeItemSize != null) { info.RelativeSize = () => RelativeItemSize (num); } if (ItemForegroundColor != null) { info.ForegroundColor = () => ItemForegroundColor (item.ItemState); } if (ItemBackgroundColor != null) { info.BackgroundColor = () => ItemBackgroundColor (item.ItemState); } if (ItemAlignX.HasValue) { info.AlignX = ItemAlignX.Value; } if (ItemAlignY.HasValue) { info.AlignY = ItemAlignY.Value; } }
public virtual void AddDropDown(MenuItemInfo info, DistinctOptionInfo option) { int num = Items.Count; DropDownMenu item = new DropDownMenu (screen, ItemDisplayLayer, num, info); assignMenuItemInfo (ref info, num, item); item.AddEntries (option); Items.Add (item); }
public virtual void AddDropDown(MenuItemInfo info, DropDownMenuItem[] items, DropDownMenuItem defaultItem) { int num = Items.Count; DropDownMenu item = new DropDownMenu (screen, ItemDisplayLayer, num, info); assignMenuItemInfo (ref info, num, item); item.AddEntries (items, defaultItem); Items.Add (item); }
public virtual MenuButton AddButton(MenuItemInfo info) { int num = Items.Count; MenuButton item = new MenuButton (screen, ItemDisplayLayer, num, info); assignMenuItemInfo (ref info, num, item); Items.Add (item); return item; }
public MenuButton(GameScreen screen, DisplayLayer drawOrder, int itemNum, MenuItemInfo info) : base(screen, drawOrder, itemNum, info) { }
/// <summary> /// Initializes a new instance of the <see cref="TestGame1.MenuItem"/> class. /// </summary> public MenuItem(GameScreen screen, DisplayLayer drawOrder, int itemNum, MenuItemInfo info) : base(screen, info, drawOrder, itemNum) { // create a sprite batch spriteBatch = new SpriteBatch (screen.device); }
public override MenuButton AddButton(MenuItemInfo info) { int num = Items.Count; info.RelativePosition = () => RelativeItemPosition (num); info.RelativeSize = () => RelativeItemSize (num); return base.AddButton (info); }
public override void AddDropDown(MenuItemInfo info, DistinctOptionInfo option) { int num = Items.Count; info.RelativePosition = () => RelativeItemPosition (num); info.RelativeSize = () => RelativeItemSize (num); base.AddDropDown (info, option); }
public override void AddDropDown(MenuItemInfo info, DropDownMenuItem[] items, DropDownMenuItem defaultItem) { base.AddDropDown (info, items, defaultItem); }
private void AddFileToList(string filename) { string hashcode = FileUtility.GetHash(filename); bool isValid = fileIndex.Contains (hashcode); if (!isValid) { try { // load the knot and look for exceptions fileFormat.Load (filename); isValid = true; fileIndex.Add (hashcode); } catch (Exception ex) { Console.WriteLine (ex); isValid = false; } } if (isValid) { KnotMetaData meta = fileFormat.LoadMetaData(filename); Action LoadFile = () => { // delegate to load the file //if (knotInfo.IsValid) { Console.WriteLine ("File is valid: " + meta); GameScreens.CreativeMode.Knot = fileFormat.Load(filename); NextState = GameScreens.CreativeMode; //} else { // Console.WriteLine ("File is invalid: " + knotInfo); //} }; string name = meta.Name.Length > 0 ? meta.Name : filename; MenuItemInfo info = new MenuItemInfo (text: name, onClick: LoadFile); menu.AddButton (info); } }
private void AddDefaultKnots() { /* Action RandomKnot = () => { __Knot knot = __Knot.RandomKnot (20, format); Console.WriteLine ("Random Knot: " + knot.Info); GameScreens.CreativeMode.Knot = knot; NextState = GameScreens.CreativeMode; }; */ Action DefaultKnot = () => { Knot knot = new Knot (); Console.WriteLine ("Default Knot: " + knot); GameScreens.CreativeMode.Knot = knot; NextState = GameScreens.CreativeMode; }; MenuItemInfo info = new MenuItemInfo (text: "New Knot", onClick: DefaultKnot); menu.AddButton (info); /* info = new MenuItemInfo (text: "New Random Knot", onClick: RandomKnot); menu.AddButton (info); */ }