mirror of
https://github.com/osukey/osukey.git
synced 2025-05-09 23:57:18 +09:00
Improve the way bindings are done
This commit is contained in:
parent
51a9dd038e
commit
05a13d4d39
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using JetBrains.Annotations;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
@ -14,7 +13,6 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Framework.Graphics.Transforms;
|
using osu.Framework.Graphics.Transforms;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.MathUtils;
|
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
@ -31,6 +29,9 @@ namespace osu.Game.Overlays.Volume
|
|||||||
private readonly Color4 meterColour;
|
private readonly Color4 meterColour;
|
||||||
private readonly string name;
|
private readonly string name;
|
||||||
|
|
||||||
|
private OsuSpriteText text;
|
||||||
|
private BufferedContainer maxGlow;
|
||||||
|
|
||||||
public VolumeMeter(string name, float circleSize, Color4 meterColour)
|
public VolumeMeter(string name, float circleSize, Color4 meterColour)
|
||||||
{
|
{
|
||||||
this.circleSize = circleSize;
|
this.circleSize = circleSize;
|
||||||
@ -69,9 +70,7 @@ namespace osu.Game.Overlays.Volume
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
OsuSpriteText text;
|
|
||||||
CircularProgress bgProgress;
|
CircularProgress bgProgress;
|
||||||
BufferedContainer maxGlow;
|
|
||||||
|
|
||||||
Add(new CircularContainer
|
Add(new CircularContainer
|
||||||
{
|
{
|
||||||
@ -122,33 +121,36 @@ namespace osu.Game.Overlays.Volume
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Bindable.ValueChanged += newVolume => this.TransformTo("circleBindable", newVolume * 0.75, 250, Easing.OutQuint);
|
Bindable.ValueChanged += newVolume => { this.TransformTo("DisplayVolume", newVolume, 400, Easing.OutQuint); };
|
||||||
volumeCircle.Current.ValueChanged += newVolume => //by using this event we sync the meter with the text. newValue has to be divided by 0.75 to give the actual percentage
|
|
||||||
|
bgProgress.Current.Value = 0.75f;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double displayVolume;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is needed because <see cref="TransformCustom{TValue,T}"/> doesn't support <see cref="Bindable{T}"/>
|
||||||
|
/// </summary>
|
||||||
|
protected double DisplayVolume
|
||||||
|
{
|
||||||
|
get => displayVolume;
|
||||||
|
set
|
||||||
{
|
{
|
||||||
if (Precision.DefinitelyBigger(newVolume, 0.74))
|
displayVolume = value;
|
||||||
|
|
||||||
|
if (displayVolume > 0.99f)
|
||||||
{
|
{
|
||||||
text.Text = "MAX";
|
text.Text = "MAX";
|
||||||
maxGlow.EffectColour = meterColour.Opacity(2f);
|
maxGlow.EffectColour = meterColour.Opacity(2f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (text.Text == "MAX")
|
maxGlow.EffectColour = Color4.Transparent;
|
||||||
maxGlow.EffectColour = Color4.Transparent;
|
text.Text = Math.Round(displayVolume * 100).ToString(CultureInfo.CurrentCulture);
|
||||||
text.Text = Math.Round(newVolume / 0.0075).ToString(CultureInfo.CurrentCulture);
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
bgProgress.Current.Value = 0.75f;
|
volumeCircle.Current.Value = displayVolume * 0.75f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This is needed because <see cref="TransformCustom{TValue,T}"/> doesn't support <see cref="Bindable{T}"/>
|
|
||||||
/// </summary>
|
|
||||||
[UsedImplicitly]
|
|
||||||
private double circleBindable
|
|
||||||
{
|
|
||||||
get => volumeCircle.Current;
|
|
||||||
set => volumeCircle.Current.Value = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double Volume
|
public double Volume
|
||||||
|
Loading…
x
Reference in New Issue
Block a user