1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-19 19:33:22 +08:00

Merge pull request #616 from peppy/has-bindable-value

Update SliderBar to use IHasCurrentValue.
This commit is contained in:
Dan Balasescu 2017-04-10 19:49:13 +09:00 committed by GitHub
commit 4aadd3a8f8
9 changed files with 25 additions and 27 deletions

@ -1 +1 @@
Subproject commit bbfd0fc7a8f5293a0f853f51040b40808abbb459 Subproject commit 1490f003273d7aab6589e489f6e4b02d204c9f27

View File

@ -99,6 +99,7 @@ namespace osu.Desktop.VisualTests.Tests
AddToggleStep(@"auto", state => { auto = state; load(mode); }); AddToggleStep(@"auto", state => { auto = state; load(mode); });
BasicSliderBar<double> sliderBar;
Add(new Container Add(new Container
{ {
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
@ -107,16 +108,17 @@ namespace osu.Desktop.VisualTests.Tests
Children = new Drawable[] Children = new Drawable[]
{ {
new SpriteText { Text = "Playback Speed" }, new SpriteText { Text = "Playback Speed" },
new BasicSliderBar<double> sliderBar = new BasicSliderBar<double>
{ {
Width = 150, Width = 150,
Height = 10, Height = 10,
SelectionColor = Color4.Orange, SelectionColor = Color4.Orange,
Value = playbackSpeed
} }
} }
}); });
sliderBar.Current.BindTo(playbackSpeed);
framedClock.ProcessFrame(); framedClock.ProcessFrame();
var clockAdjustContainer = new Container var clockAdjustContainer = new Container

View File

@ -44,6 +44,8 @@ namespace osu.Desktop.VisualTests.Tests
kc.Add(new KeyCounterKeyboard(key)); kc.Add(new KeyCounterKeyboard(key));
}); });
TestSliderBar<int> sliderBar;
Add(new Container Add(new Container
{ {
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
@ -52,16 +54,17 @@ namespace osu.Desktop.VisualTests.Tests
Children = new Drawable[] Children = new Drawable[]
{ {
new SpriteText { Text = "FadeTime" }, new SpriteText { Text = "FadeTime" },
new TestSliderBar<int> sliderBar =new TestSliderBar<int>
{ {
Width = 150, Width = 150,
Height = 10, Height = 10,
SelectionColor = Color4.Orange, SelectionColor = Color4.Orange,
Value = bindable
} }
} }
}); });
sliderBar.Current.BindTo(bindable);
Add(kc); Add(kc);
} }
private class TestSliderBar<T> : SliderBar<T> where T : struct private class TestSliderBar<T> : SliderBar<T> where T : struct

View File

@ -46,6 +46,7 @@ namespace osu.Game.Configuration
Set(OsuConfig.AutomaticDownload, true).Disabled = true; Set(OsuConfig.AutomaticDownload, true).Disabled = true;
Set(OsuConfig.AutomaticDownloadNoVideo, false).Disabled = true; Set(OsuConfig.AutomaticDownloadNoVideo, false).Disabled = true;
Set(OsuConfig.BlockNonFriendPM, false).Disabled = true; Set(OsuConfig.BlockNonFriendPM, false).Disabled = true;
Set(OsuConfig.Bloom, false).Disabled = true;
Set(OsuConfig.BloomSoftening, false).Disabled = true; Set(OsuConfig.BloomSoftening, false).Disabled = true;
Set(OsuConfig.BossKeyFirstActivation, true).Disabled = true; Set(OsuConfig.BossKeyFirstActivation, true).Disabled = true;
Set(OsuConfig.ChatAudibleHighlight, true).Disabled = true; Set(OsuConfig.ChatAudibleHighlight, true).Disabled = true;

View File

@ -92,12 +92,6 @@ namespace osu.Game.Graphics.UserInterface
} }
} }
private readonly Bindable<bool> current = new Bindable<bool>(); public Bindable<bool> Current { get; } = new Bindable<bool>();
public Bindable<bool> Current
{
get { return current; }
set { current.BindTo(value); }
}
} }
} }

View File

@ -24,11 +24,8 @@ namespace osu.Game.Graphics.UserInterface
set set
{ {
bindable = value; bindable = value;
Current.BindTo(bindable);
if (bindable != null) if (value?.Disabled ?? true)
Current = bindable;
if (bindable?.Disabled ?? true)
Alpha = 0.3f; Alpha = 0.3f;
} }
} }
@ -72,13 +69,14 @@ namespace osu.Game.Graphics.UserInterface
labelSpriteText = new OsuSpriteText(), labelSpriteText = new OsuSpriteText(),
nub = new Nub nub = new Nub
{ {
Current = Current,
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
Margin = new MarginPadding { Right = 5 }, Margin = new MarginPadding { Right = 5 },
} }
}; };
nub.Current.BindTo(Current);
Current.ValueChanged += newValue => Current.ValueChanged += newValue =>
{ {
if (newValue) if (newValue)

View File

@ -33,8 +33,8 @@ namespace osu.Game.Overlays.Options
set set
{ {
bindable = value; bindable = value;
dropdown.Current = bindable; dropdown.Current.BindTo(bindable);
if (bindable.Disabled) if (value?.Disabled ?? true)
Alpha = 0.3f; Alpha = 0.3f;
} }
} }

View File

@ -27,12 +27,14 @@ namespace osu.Game.Overlays.Options
} }
} }
public BindableNumber<T> Bindable private Bindable<T> bindable;
public Bindable<T> Bindable
{ {
get { return slider.Value; }
set set
{ {
slider.Value = value; bindable = value;
slider.Current.BindTo(bindable);
if (value?.Disabled ?? true) if (value?.Disabled ?? true)
Alpha = 0.3f; Alpha = 0.3f;
} }

View File

@ -15,10 +15,8 @@ namespace osu.Game.Overlays.Options
set set
{ {
bindable = value; bindable = value;
Current.BindTo(bindable);
Current = bindable; if (value?.Disabled ?? true)
if (bindable?.Disabled ?? true)
Alpha = 0.3f; Alpha = 0.3f;
} }
} }