A game framework written with osu! in mind.
at master 48 lines 1.7 kB view raw
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. 2// See the LICENCE file in the repository root for full licence text. 3 4using System; 5using System.Collections.Generic; 6using osu.Framework.Bindables; 7using osu.Framework.Localisation; 8 9namespace osu.Framework.Graphics.UserInterface 10{ 11 public class MenuItem 12 { 13 /// <summary> 14 /// The text which this <see cref="MenuItem"/> displays. 15 /// </summary> 16 public readonly Bindable<LocalisableString> Text = new Bindable<LocalisableString>(string.Empty); 17 18 /// <summary> 19 /// The <see cref="Action"/> that is performed when this <see cref="MenuItem"/> is clicked. 20 /// </summary> 21 public readonly Bindable<Action> Action = new Bindable<Action>(); 22 23 /// <summary> 24 /// A list of items which are to be displayed in a sub-menu originating from this <see cref="MenuItem"/>. 25 /// </summary> 26 public IReadOnlyList<MenuItem> Items = Array.Empty<MenuItem>(); 27 28 /// <summary> 29 /// Creates a new <see cref="MenuItem"/>. 30 /// </summary> 31 /// <param name="text">The text to display.</param> 32 public MenuItem(LocalisableString text) 33 { 34 Text.Value = text; 35 } 36 37 /// <summary> 38 /// Creates a new <see cref="MenuItem"/>. 39 /// </summary> 40 /// <param name="text">The text to display.</param> 41 /// <param name="action">The <see cref="Action"/> to perform when clicked.</param> 42 public MenuItem(LocalisableString text, Action action) 43 : this(text) 44 { 45 Action.Value = action; 46 } 47 } 48}