Update with framework bindable changes

This commit is contained in:
smoogipoo
2019-02-21 18:56:34 +09:00
parent d637b184e4
commit bca347427f
195 changed files with 567 additions and 555 deletions

View File

@ -90,7 +90,7 @@ namespace osu.Game.Graphics.Containers
switch (visibility)
{
case Visibility.Visible:
if (OverlayActivationMode != OverlayActivation.Disabled)
if (OverlayActivationMode.Value != OverlayActivation.Disabled)
{
if (PlaySamplesOnStateChange) samplePopIn?.Play();
}

View File

@ -45,7 +45,7 @@ namespace osu.Game.Graphics.Containers
parallaxEnabled = config.GetBindable<bool>(OsuSetting.MenuParallax);
parallaxEnabled.ValueChanged += delegate
{
if (!parallaxEnabled)
if (!parallaxEnabled.Value)
{
content.MoveTo(Vector2.Zero, firstUpdate ? 0 : 1000, Easing.OutQuint);
content.Scale = new Vector2(1 + System.Math.Abs(ParallaxAmount));
@ -65,7 +65,7 @@ namespace osu.Game.Graphics.Containers
{
base.Update();
if (parallaxEnabled)
if (parallaxEnabled.Value)
{
Vector2 offset = (input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.Position) - DrawSize / 2) * ParallaxAmount;

View File

@ -74,10 +74,10 @@ namespace osu.Game.Graphics.Containers
}
}
private void scaleChanged(float value)
private void scaleChanged(ValueChangedEvent<float> args)
{
this.ScaleTo(new Vector2(value), 500, Easing.Out);
this.ResizeTo(new Vector2(1 / value), 500, Easing.Out);
this.ScaleTo(new Vector2(args.NewValue), 500, Easing.Out);
this.ResizeTo(new Vector2(1 / args.NewValue), 500, Easing.Out);
}
}
@ -108,7 +108,7 @@ namespace osu.Game.Graphics.Containers
sizableContainer.FinishTransforms();
}
private bool requiresBackgroundVisible => (scalingMode == ScalingMode.Everything || scalingMode == ScalingMode.ExcludeOverlays) && (sizeX.Value != 1 || sizeY.Value != 1);
private bool requiresBackgroundVisible => (scalingMode.Value == ScalingMode.Everything || scalingMode.Value == ScalingMode.ExcludeOverlays) && (sizeX.Value != 1 || sizeY.Value != 1);
private void updateSize()
{
@ -137,8 +137,8 @@ namespace osu.Game.Graphics.Containers
bool scaling = targetMode == null || scalingMode.Value == targetMode;
var targetSize = scaling ? new Vector2(sizeX, sizeY) : Vector2.One;
var targetPosition = scaling ? new Vector2(posX, posY) * (Vector2.One - targetSize) : Vector2.Zero;
var targetSize = scaling ? new Vector2(sizeX.Value, sizeY.Value) : Vector2.One;
var targetPosition = scaling ? new Vector2(posX.Value, posY.Value) * (Vector2.One - targetSize) : Vector2.Zero;
bool requiresMasking = scaling && targetSize != Vector2.One;
if (requiresMasking)

View File

@ -80,7 +80,7 @@ namespace osu.Game.Graphics.Cursor
activeCursor.AdditiveLayer.FadeInFromZero(800, Easing.OutQuint);
}
if (e.Button == MouseButton.Left && cursorRotate)
if (e.Button == MouseButton.Left && cursorRotate.Value)
{
dragRotationState = DragRotationState.DragStarted;
positionMouseDown = e.MousePosition;
@ -156,7 +156,7 @@ namespace osu.Game.Graphics.Cursor
};
cursorScale = config.GetBindable<double>(OsuSetting.MenuCursorSize);
cursorScale.ValueChanged += newScale => cursorContainer.Scale = new Vector2((float)newScale * base_scale);
cursorScale.ValueChanged += e => cursorContainer.Scale = new Vector2((float)e.NewValue * base_scale);
cursorScale.TriggerChange();
}
}

View File

@ -127,7 +127,7 @@ namespace osu.Game.Graphics
{
base.Update();
if (cursorVisibility == false && Interlocked.CompareExchange(ref screenShotTasks, 0, 0) == 0)
if (cursorVisibility.Value == false && Interlocked.CompareExchange(ref screenShotTasks, 0, 0) == 0)
cursorVisibility.Value = true;
}

View File

@ -27,12 +27,12 @@ namespace osu.Game.Graphics.UserInterface
{
Height = 32;
TabContainer.Spacing = new Vector2(padding, 0f);
Current.ValueChanged += tab =>
Current.ValueChanged += e =>
{
foreach (var t in TabContainer.Children.OfType<BreadcrumbTabItem>())
{
var tIndex = TabContainer.IndexOf(t);
var tabIndex = TabContainer.IndexOf(TabMap[tab]);
var tabIndex = TabContainer.IndexOf(TabMap[e.NewValue]);
t.State = tIndex < tabIndex ? Visibility.Hidden : Visibility.Visible;
t.Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, Easing.OutQuint);

View File

@ -242,9 +242,9 @@ namespace osu.Game.Graphics.UserInterface
Selected.Value = false;
}
private void selectionChanged(bool isSelected)
private void selectionChanged(ValueChangedEvent<bool> args)
{
if (isSelected)
if (args.NewValue)
{
spriteText.TransformSpacingTo(hoverSpacing, hover_duration, Easing.OutElastic);
colourContainer.ResizeTo(new Vector2(hover_width, 1f), hover_duration, Easing.OutElastic);

View File

@ -41,9 +41,9 @@ namespace osu.Game.Graphics.UserInterface
},
};
Current.ValueChanged += newValue =>
Current.ValueChanged += e =>
{
if (newValue)
if (e.NewValue)
fill.FadeIn(200, Easing.OutQuint);
else
fill.FadeTo(0.01f, 200, Easing.OutQuint); //todo: remove once we figure why containers aren't drawing at all times

View File

@ -73,7 +73,7 @@ namespace osu.Game.Graphics.UserInterface
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Enabled.BindValueChanged(enabled => this.FadeColour(enabled ? Color4.White : colours.Gray9, 200, Easing.OutQuint), true);
Enabled.BindValueChanged(e => this.FadeColour(e.NewValue ? Color4.White : colours.Gray9, 200, Easing.OutQuint), true);
}
protected override bool OnHover(HoverEvent e)

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
@ -46,13 +47,13 @@ namespace osu.Game.Graphics.UserInterface
new HoverClickSounds(HoverSampleSet.Loud),
});
Enabled.ValueChanged += enabled_ValueChanged;
Enabled.ValueChanged += enabledChanged;
Enabled.TriggerChange();
}
private void enabled_ValueChanged(bool enabled)
private void enabledChanged(ValueChangedEvent<bool> e)
{
this.FadeColour(enabled ? Color4.White : Color4.Gray, 200, Easing.OutQuint);
this.FadeColour(e.NewValue ? Color4.White : Color4.Gray, 200, Easing.OutQuint);
}
protected override bool OnHover(HoverEvent e)

View File

@ -86,9 +86,9 @@ namespace osu.Game.Graphics.UserInterface
{
base.LoadComplete();
Current.ValueChanged += newValue =>
Current.ValueChanged += e =>
{
if (newValue)
if (e.NewValue)
sampleChecked?.Play();
else
sampleUnchecked?.Play();

View File

@ -95,7 +95,7 @@ namespace osu.Game.Graphics.UserInterface
protected override void LoadComplete()
{
base.LoadComplete();
CurrentNumber.BindValueChanged(updateTooltipText, true);
CurrentNumber.BindValueChanged(e => updateTooltipText(e.NewValue), true);
}
protected override bool OnHover(HoverEvent e)

View File

@ -107,7 +107,7 @@ namespace osu.Game.Graphics.UserInterface
set
{
accentColour = value;
if (!Active)
if (!Active.Value)
Text.Colour = value;
}
}
@ -128,14 +128,14 @@ namespace osu.Game.Graphics.UserInterface
protected override bool OnHover(HoverEvent e)
{
if (!Active)
if (!Active.Value)
fadeActive();
return true;
}
protected override void OnHoverLost(HoverLostEvent e)
{
if (!Active)
if (!Active.Value)
fadeInactive();
}
@ -173,7 +173,7 @@ namespace osu.Game.Graphics.UserInterface
new HoverClickSounds()
};
Active.BindValueChanged(val => Text.Font = val ? @"Exo2.0-Bold" : @"Exo2.0", true);
Active.BindValueChanged(e => Text.Font = e.NewValue ? "Exo2.0-Bold" : @"Exo2.0", true);
}
protected override void OnActivated() => fadeActive();

View File

@ -31,7 +31,7 @@ namespace osu.Game.Graphics.UserInterface
{
accentColour = value;
if (Current)
if (Current.Value)
{
text.Colour = AccentColour;
icon.Colour = AccentColour;
@ -67,7 +67,7 @@ namespace osu.Game.Graphics.UserInterface
protected override void OnHoverLost(HoverLostEvent e)
{
if (!Current)
if (!Current.Value)
fadeOut();
base.OnHoverLost(e);
@ -118,9 +118,9 @@ namespace osu.Game.Graphics.UserInterface
}
};
Current.ValueChanged += v =>
Current.ValueChanged += e =>
{
if (v)
if (e.NewValue)
{
fadeIn();
icon.Icon = FontAwesome.fa_check_circle_o;

View File

@ -59,7 +59,7 @@ namespace osu.Game.Graphics.UserInterface
new HoverClickSounds()
};
Active.BindValueChanged(val => Text.Font = val ? @"Exo2.0-Bold" : @"Exo2.0", true);
Active.BindValueChanged(e => Text.Font = e.NewValue ? @"Exo2.0-Bold" : @"Exo2.0", true);
}
[BackgroundDependencyLoader]
@ -70,14 +70,14 @@ namespace osu.Game.Graphics.UserInterface
protected override bool OnHover(HoverEvent e)
{
if (!Active)
if (!Active.Value)
slideActive();
return true;
}
protected override void OnHoverLost(HoverLostEvent e)
{
if (!Active)
if (!Active.Value)
slideInactive();
}

View File

@ -41,7 +41,7 @@ namespace osu.Game.Graphics.UserInterface
public override void Increment(double amount)
{
Current.Value = Current + amount;
Current.Value = Current.Value + amount;
}
}
}

View File

@ -95,11 +95,11 @@ namespace osu.Game.Graphics.UserInterface
TextSize = 40;
AutoSizeAxes = Axes.Both;
DisplayedCount = Current;
DisplayedCount = Current.Value;
Current.ValueChanged += newValue =>
Current.ValueChanged += e =>
{
if (IsLoaded) TransformCount(displayedCount, newValue);
if (IsLoaded) TransformCount(displayedCount, e.NewValue);
};
}
@ -107,7 +107,7 @@ namespace osu.Game.Graphics.UserInterface
{
base.LoadComplete();
DisplayedCountSpriteText.Text = FormatCount(Current);
DisplayedCountSpriteText.Text = FormatCount(Current.Value);
}
/// <summary>
@ -126,7 +126,7 @@ namespace osu.Game.Graphics.UserInterface
public virtual void StopRolling()
{
FinishTransforms(false, nameof(DisplayedCount));
DisplayedCount = Current;
DisplayedCount = Current.Value;
}
/// <summary>

View File

@ -52,7 +52,7 @@ namespace osu.Game.Graphics.UserInterface
public override void Increment(double amount)
{
Current.Value = Current + amount;
Current.Value = Current.Value + amount;
}
}
}

View File

@ -19,7 +19,7 @@ namespace osu.Game.Graphics.UserInterface
onPushed(null, stack.CurrentScreen);
Current.ValueChanged += newScreen => newScreen.MakeCurrent();
Current.ValueChanged += e => e.NewValue.MakeCurrent();
}
private void onPushed(IScreen lastScreen, IScreen newScreen)

View File

@ -33,7 +33,7 @@ namespace osu.Game.Graphics.UserInterface
public override void Increment(int amount)
{
Current.Value = Current + amount;
Current.Value = Current.Value + amount;
}
}
}