2017-02-07 04:59:30 +00:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-03-21 23:49:21 +00:00
|
|
|
|
using System.Collections.Generic;
|
2016-12-01 21:36:04 +00:00
|
|
|
|
using osu.Framework.Configuration;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2017-01-31 09:53:52 +00:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2017-02-03 10:13:10 +00:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2016-12-01 21:36:04 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Options
|
|
|
|
|
{
|
2017-03-22 14:32:32 +00:00
|
|
|
|
public class OptionDropdown<T> : FillFlowContainer
|
2016-12-01 21:36:04 +00:00
|
|
|
|
{
|
2017-03-23 04:41:50 +00:00
|
|
|
|
private readonly Dropdown<T> dropdown;
|
|
|
|
|
private readonly SpriteText text;
|
2017-01-31 09:37:11 +00:00
|
|
|
|
|
2016-12-01 22:33:30 +00:00
|
|
|
|
public string LabelText
|
2016-12-01 21:36:04 +00:00
|
|
|
|
{
|
|
|
|
|
get { return text.Text; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
text.Text = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-01-31 09:37:11 +00:00
|
|
|
|
|
2016-12-01 21:36:04 +00:00
|
|
|
|
public Bindable<T> Bindable
|
|
|
|
|
{
|
|
|
|
|
get { return bindable; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
bindable = value;
|
2017-03-21 23:49:21 +00:00
|
|
|
|
dropdown.SelectedValue.BindTo(bindable);
|
2017-03-09 07:07:34 +00:00
|
|
|
|
if (bindable.Disabled)
|
2017-02-13 15:35:24 +00:00
|
|
|
|
Alpha = 0.3f;
|
2016-12-01 21:36:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Bindable<T> bindable;
|
|
|
|
|
|
2017-02-06 00:21:26 +00:00
|
|
|
|
private IEnumerable<KeyValuePair<string, T>> items;
|
|
|
|
|
public IEnumerable<KeyValuePair<string, T>> Items
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return items;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
items = value;
|
2017-03-21 23:49:21 +00:00
|
|
|
|
if (dropdown != null)
|
2017-02-06 00:21:26 +00:00
|
|
|
|
dropdown.Items = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-22 14:32:32 +00:00
|
|
|
|
public OptionDropdown()
|
2016-12-01 21:36:04 +00:00
|
|
|
|
{
|
2017-02-06 00:21:26 +00:00
|
|
|
|
Items = new KeyValuePair<string, T>[0];
|
|
|
|
|
|
2017-03-04 10:00:17 +00:00
|
|
|
|
Direction = FillDirection.Vertical;
|
2016-12-01 21:36:04 +00:00
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-01-31 09:53:52 +00:00
|
|
|
|
text = new OsuSpriteText {
|
2017-01-31 09:37:11 +00:00
|
|
|
|
Alpha = 0,
|
|
|
|
|
},
|
2017-03-22 14:32:32 +00:00
|
|
|
|
dropdown = new OsuDropdown<T>
|
2016-12-01 21:36:04 +00:00
|
|
|
|
{
|
|
|
|
|
Margin = new MarginPadding { Top = 5 },
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-02-27 14:37:38 +00:00
|
|
|
|
Items = Items,
|
2016-12-01 21:36:04 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-12-02 11:35:55 +00:00
|
|
|
|
}
|