Update UI control access in line with framework changes.

This commit is contained in:
Dean Herbert
2017-04-10 14:31:08 +09:00
parent d2a889d2bb
commit bb4a909de5
11 changed files with 58 additions and 127 deletions

View File

@ -23,16 +23,10 @@ namespace osu.Game.Graphics.UserInterface
{
set
{
if (bindable != null)
bindable.ValueChanged -= bindableValueChanged;
bindable = value;
if (bindable != null)
{
bool state = State == CheckboxState.Checked;
if (state != bindable.Value)
State = bindable.Value ? CheckboxState.Checked : CheckboxState.Unchecked;
bindable.ValueChanged += bindableValueChanged;
}
Current = bindable;
if (bindable?.Disabled ?? true)
Alpha = 0.3f;
@ -78,23 +72,20 @@ namespace osu.Game.Graphics.UserInterface
labelSpriteText = new OsuSpriteText(),
nub = new Nub
{
Current = Current,
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Margin = new MarginPadding { Right = 5 },
}
};
}
private void bindableValueChanged(bool isChecked)
{
State = isChecked ? CheckboxState.Checked : CheckboxState.Unchecked;
}
protected override void Dispose(bool isDisposing)
{
if (bindable != null)
bindable.ValueChanged -= bindableValueChanged;
base.Dispose(isDisposing);
Current.ValueChanged += newValue =>
{
if (newValue)
sampleChecked?.Play();
else
sampleUnchecked?.Play();
};
}
protected override bool OnHover(InputState state)
@ -117,23 +108,5 @@ namespace osu.Game.Graphics.UserInterface
sampleChecked = audio.Sample.Get(@"Checkbox/check-on");
sampleUnchecked = audio.Sample.Get(@"Checkbox/check-off");
}
protected override void OnChecked()
{
sampleChecked?.Play();
nub.State = CheckboxState.Checked;
if (bindable != null)
bindable.Value = true;
}
protected override void OnUnchecked()
{
sampleUnchecked?.Play();
nub.State = CheckboxState.Unchecked;
if (bindable != null)
bindable.Value = false;
}
}
}