mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 16:27:26 +08:00
Move settings and bindables to a sane location
This commit is contained in:
parent
837958b254
commit
18f74b2840
@ -5,7 +5,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
@ -13,7 +12,6 @@ using osu.Framework.Input.Events;
|
|||||||
using osu.Framework.Input.States;
|
using osu.Framework.Input.States;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Overlays.Settings;
|
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Screens.Utility.SampleComponents;
|
using osu.Game.Screens.Utility.SampleComponents;
|
||||||
@ -21,7 +19,7 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Utility
|
namespace osu.Game.Screens.Utility
|
||||||
{
|
{
|
||||||
public class CircleGameplay : CompositeDrawable
|
public class CircleGameplay : LatencySampleComponent
|
||||||
{
|
{
|
||||||
private int nextLocation;
|
private int nextLocation;
|
||||||
|
|
||||||
@ -31,9 +29,7 @@ namespace osu.Game.Screens.Utility
|
|||||||
|
|
||||||
private double? lastGeneratedBeatTime;
|
private double? lastGeneratedBeatTime;
|
||||||
|
|
||||||
private static readonly BindableDouble beat_length = new BindableDouble(500) { MinValue = 200, MaxValue = 1000 };
|
private Container circles = null!;
|
||||||
private static readonly BindableDouble approach_rate_milliseconds = new BindableDouble(100) { MinValue = 50, MaxValue = 500 };
|
|
||||||
private static readonly BindableFloat spacing = new BindableFloat(0.2f) { MinValue = 0.05f, MaxValue = 0.4f };
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
@ -41,33 +37,6 @@ namespace osu.Game.Screens.Utility
|
|||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
new FillFlowContainer
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Width = 400,
|
|
||||||
Spacing = new Vector2(2),
|
|
||||||
Direction = FillDirection.Vertical,
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new SettingsSlider<double>
|
|
||||||
{
|
|
||||||
LabelText = "time spacing",
|
|
||||||
Current = beat_length
|
|
||||||
},
|
|
||||||
new SettingsSlider<float>
|
|
||||||
{
|
|
||||||
LabelText = "visual spacing",
|
|
||||||
Current = spacing
|
|
||||||
},
|
|
||||||
new SettingsSlider<double>
|
|
||||||
{
|
|
||||||
LabelText = "approach time",
|
|
||||||
Current = approach_rate_milliseconds
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
unstableRate = new OsuSpriteText
|
unstableRate = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
@ -75,22 +44,31 @@ namespace osu.Game.Screens.Utility
|
|||||||
Font = OsuFont.Default.With(size: 24),
|
Font = OsuFont.Default.With(size: 24),
|
||||||
Y = -100,
|
Y = -100,
|
||||||
},
|
},
|
||||||
|
circles = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SampleBPM.BindValueChanged(_ =>
|
||||||
|
{
|
||||||
|
circles.Clear();
|
||||||
|
lastGeneratedBeatTime = null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void UpdateAtLimitedRate(InputState inputState)
|
||||||
{
|
{
|
||||||
base.Update();
|
double beatLength = 60000 / SampleBPM.Value;
|
||||||
|
|
||||||
|
int nextBeat = (int)(Clock.CurrentTime / beatLength) + 1;
|
||||||
|
|
||||||
// We want to generate a few hit objects ahead of the current time (to allow them to animate).
|
// We want to generate a few hit objects ahead of the current time (to allow them to animate).
|
||||||
|
double generateUpTo = (nextBeat + 2) * beatLength;
|
||||||
int nextBeat = (int)(Clock.CurrentTime / beat_length.Value) + 1;
|
|
||||||
|
|
||||||
double generateUpTo = (nextBeat + 2) * beat_length.Value;
|
|
||||||
|
|
||||||
while (lastGeneratedBeatTime == null || lastGeneratedBeatTime < generateUpTo)
|
while (lastGeneratedBeatTime == null || lastGeneratedBeatTime < generateUpTo)
|
||||||
{
|
{
|
||||||
double time = ++nextBeat * beat_length.Value;
|
double time = ++nextBeat * beatLength;
|
||||||
|
|
||||||
if (time <= lastGeneratedBeatTime)
|
if (time <= lastGeneratedBeatTime)
|
||||||
continue;
|
continue;
|
||||||
@ -106,8 +84,8 @@ namespace osu.Game.Screens.Utility
|
|||||||
|
|
||||||
Vector2 location;
|
Vector2 location;
|
||||||
|
|
||||||
float spacingLow = 0.5f - spacing.Value;
|
float spacingLow = 0.5f - SampleVisualSpacing.Value;
|
||||||
float spacingHigh = 0.5f + spacing.Value;
|
float spacingHigh = 0.5f + SampleVisualSpacing.Value;
|
||||||
|
|
||||||
switch (nextLocation % 4)
|
switch (nextLocation % 4)
|
||||||
{
|
{
|
||||||
@ -128,7 +106,7 @@ namespace osu.Game.Screens.Utility
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddInternal(new SampleHitCircle(time)
|
circles.Add(new SampleHitCircle(time)
|
||||||
{
|
{
|
||||||
RelativePositionAxes = Axes.Both,
|
RelativePositionAxes = Axes.Both,
|
||||||
Position = location,
|
Position = location,
|
||||||
@ -139,7 +117,7 @@ namespace osu.Game.Screens.Utility
|
|||||||
private void hit(HitEvent h)
|
private void hit(HitEvent h)
|
||||||
{
|
{
|
||||||
hitEvents.Add(h);
|
hitEvents.Add(h);
|
||||||
unstableRate.Text = $"{hitEvents.CalculateUnstableRate():N1}";
|
unstableRate.Text = $"UR: {hitEvents.CalculateUnstableRate()}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SampleHitCircle : LatencySampleComponent
|
public class SampleHitCircle : LatencySampleComponent
|
||||||
@ -231,7 +209,7 @@ namespace osu.Game.Screens.Utility
|
|||||||
{
|
{
|
||||||
if (HitEvent == null)
|
if (HitEvent == null)
|
||||||
{
|
{
|
||||||
approach.Scale = new Vector2(1 + (float)MathHelper.Clamp((HitTime - Clock.CurrentTime) / approach_rate_milliseconds.Value, 0, 100));
|
approach.Scale = new Vector2(1 + (float)MathHelper.Clamp((HitTime - Clock.CurrentTime) / SampleApproachRate.Value, 0, 100));
|
||||||
Alpha = (float)MathHelper.Clamp((Clock.CurrentTime - HitTime + 600) / 400, 0, 1);
|
Alpha = (float)MathHelper.Clamp((Clock.CurrentTime - HitTime + 600) / 400, 0, 1);
|
||||||
|
|
||||||
if (Clock.CurrentTime > HitTime + 200)
|
if (Clock.CurrentTime > HitTime + 200)
|
||||||
|
@ -25,11 +25,13 @@ using osu.Game.Graphics;
|
|||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Overlays.Settings;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Utility
|
namespace osu.Game.Screens.Utility
|
||||||
{
|
{
|
||||||
|
[Cached]
|
||||||
public class LatencyCertifierScreen : OsuScreen
|
public class LatencyCertifierScreen : OsuScreen
|
||||||
{
|
{
|
||||||
private FrameSync previousFrameSyncMode;
|
private FrameSync previousFrameSyncMode;
|
||||||
@ -49,6 +51,10 @@ namespace osu.Game.Screens.Utility
|
|||||||
|
|
||||||
private readonly Container resultsArea;
|
private readonly Container resultsArea;
|
||||||
|
|
||||||
|
public readonly BindableDouble SampleBPM = new BindableDouble(120) { MinValue = 60, MaxValue = 300 };
|
||||||
|
public readonly BindableDouble SampleApproachRate = new BindableDouble(100) { MinValue = 50, MaxValue = 500 };
|
||||||
|
public readonly BindableFloat SampleVisualSpacing = new BindableFloat(0.2f) { MinValue = 0.05f, MaxValue = 0.3f };
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The rate at which the game host should attempt to run.
|
/// The rate at which the game host should attempt to run.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -84,6 +90,8 @@ namespace osu.Game.Screens.Utility
|
|||||||
private double lastPoll;
|
private double lastPoll;
|
||||||
private int pollingMax;
|
private int pollingMax;
|
||||||
|
|
||||||
|
private readonly FillFlowContainer settings;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private GameHost host { get; set; } = null!;
|
private GameHost host { get; set; } = null!;
|
||||||
|
|
||||||
@ -122,19 +130,30 @@ namespace osu.Game.Screens.Utility
|
|||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
},
|
},
|
||||||
explanatoryText = new OsuTextFlowContainer(cp => cp.Font = OsuFont.Default.With(size: 20))
|
settings = new FillFlowContainer
|
||||||
{
|
{
|
||||||
|
Name = "Settings",
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Padding = new MarginPadding(10),
|
||||||
|
Spacing = new Vector2(2),
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
Anchor = Anchor.BottomCentre,
|
Anchor = Anchor.BottomCentre,
|
||||||
Origin = Anchor.BottomCentre,
|
Origin = Anchor.BottomCentre,
|
||||||
TextAnchor = Anchor.TopCentre,
|
Child = explanatoryText = new OsuTextFlowContainer(cp => cp.Font = OsuFont.Default.With(size: 20))
|
||||||
RelativeSizeAxes = Axes.X,
|
{
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Text = @"Welcome to the latency certifier!
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
TextAnchor = Anchor.TopCentre,
|
||||||
|
Text = @"Welcome to the latency certifier!
|
||||||
Use the arrow keys, Z/X/F/J to control the display.
|
Use the arrow keys, Z/X/F/J to control the display.
|
||||||
Use the Tab key to change focus.
|
Use the Tab key to change focus.
|
||||||
Change display modes with Space.
|
Change display modes with Space.
|
||||||
Do whatever you need to try and perceive the difference in latency, then choose your best side.
|
Do whatever you need to try and perceive the difference in latency, then choose your best side.
|
||||||
",
|
",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
resultsArea = new Container
|
resultsArea = new Container
|
||||||
{
|
{
|
||||||
@ -423,6 +442,37 @@ Do whatever you need to try and perceive the difference in latency, then choose
|
|||||||
mainArea.Children.First(a => a != area).IsActiveArea.Value = false;
|
mainArea.Children.First(a => a != area).IsActiveArea.Value = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
settings.AddRange(new Drawable[]
|
||||||
|
{
|
||||||
|
new SettingsSlider<double>
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
RelativeSizeAxes = Axes.None,
|
||||||
|
Width = 400,
|
||||||
|
LabelText = "bpm",
|
||||||
|
Current = SampleBPM
|
||||||
|
},
|
||||||
|
new SettingsSlider<float>
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
RelativeSizeAxes = Axes.None,
|
||||||
|
Width = 400,
|
||||||
|
LabelText = "visual spacing",
|
||||||
|
Current = SampleVisualSpacing
|
||||||
|
},
|
||||||
|
new SettingsSlider<double>
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
RelativeSizeAxes = Axes.None,
|
||||||
|
Width = 400,
|
||||||
|
LabelText = "approach rate",
|
||||||
|
Current = SampleApproachRate
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void recordResult(bool correct)
|
private void recordResult(bool correct)
|
||||||
|
@ -14,6 +14,10 @@ namespace osu.Game.Screens.Utility.SampleComponents
|
|||||||
{
|
{
|
||||||
public abstract class LatencySampleComponent : CompositeDrawable
|
public abstract class LatencySampleComponent : CompositeDrawable
|
||||||
{
|
{
|
||||||
|
protected readonly BindableDouble SampleBPM = new BindableDouble();
|
||||||
|
protected readonly BindableDouble SampleApproachRate = new BindableDouble();
|
||||||
|
protected readonly BindableFloat SampleVisualSpacing = new BindableFloat();
|
||||||
|
|
||||||
protected readonly BindableBool IsActive = new BindableBool();
|
protected readonly BindableBool IsActive = new BindableBool();
|
||||||
|
|
||||||
private InputManager inputManager = null!;
|
private InputManager inputManager = null!;
|
||||||
@ -24,6 +28,14 @@ namespace osu.Game.Screens.Utility.SampleComponents
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
protected OverlayColourProvider OverlayColourProvider { get; private set; } = null!;
|
protected OverlayColourProvider OverlayColourProvider { get; private set; } = null!;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(LatencyCertifierScreen latencyCertifierScreen)
|
||||||
|
{
|
||||||
|
SampleBPM.BindTo(latencyCertifierScreen.SampleBPM);
|
||||||
|
SampleApproachRate.BindTo(latencyCertifierScreen.SampleApproachRate);
|
||||||
|
SampleVisualSpacing.BindTo(latencyCertifierScreen.SampleVisualSpacing);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
Loading…
Reference in New Issue
Block a user