2017-02-07 12:59:30 +08: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-02-07 12:52:19 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using osu.Framework.Configuration;
|
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Options
|
|
|
|
|
{
|
|
|
|
|
public class OptionTextBox : OsuTextBox
|
|
|
|
|
{
|
|
|
|
|
private Bindable<string> bindable;
|
|
|
|
|
|
|
|
|
|
public Bindable<string> Bindable
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (bindable != null)
|
|
|
|
|
bindable.ValueChanged -= bindableValueChanged;
|
|
|
|
|
bindable = value;
|
|
|
|
|
if (bindable != null)
|
|
|
|
|
{
|
2017-02-27 22:37:38 +08:00
|
|
|
|
Text = bindable.Value;
|
2017-02-07 12:52:19 +08:00
|
|
|
|
bindable.ValueChanged += bindableValueChanged;
|
|
|
|
|
}
|
2017-02-13 23:35:24 +08:00
|
|
|
|
|
|
|
|
|
if (bindable?.Disabled ?? true)
|
|
|
|
|
Alpha = 0.3f;
|
2017-02-07 12:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-08 13:01:17 +08:00
|
|
|
|
|
|
|
|
|
public OptionTextBox()
|
2016-11-11 07:15:30 +08:00
|
|
|
|
{
|
2017-02-08 13:01:17 +08:00
|
|
|
|
OnChange += onChange;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onChange(TextBox sender, bool newText)
|
|
|
|
|
{
|
|
|
|
|
if (bindable != null)
|
|
|
|
|
bindable.Value = Text;
|
2017-02-07 12:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void bindableValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Text = bindable.Value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
|
{
|
|
|
|
|
if (bindable != null)
|
|
|
|
|
bindable.ValueChanged -= bindableValueChanged;
|
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-11 07:15:30 +08:00
|
|
|
|
}
|