mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 00:43:22 +08:00
Merge branch 'gcc-abstraction' into multiplayer-spectator-screen
This commit is contained in:
commit
e78ef05fcf
@ -52,6 +52,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.412.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.416.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.419.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -384,16 +384,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
{
|
||||
updateTrailVisibility();
|
||||
|
||||
if (hyperDashing)
|
||||
{
|
||||
this.FadeColour(hyperDashColour, HYPER_DASH_TRANSITION_DURATION, Easing.OutQuint);
|
||||
this.FadeTo(0.2f, HYPER_DASH_TRANSITION_DURATION, Easing.OutQuint);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.FadeColour(Color4.White, HYPER_DASH_TRANSITION_DURATION, Easing.OutQuint);
|
||||
this.FadeTo(1f, HYPER_DASH_TRANSITION_DURATION, Easing.OutQuint);
|
||||
}
|
||||
this.FadeColour(hyperDashing ? hyperDashColour : Color4.White, HYPER_DASH_TRANSITION_DURATION, Easing.OutQuint);
|
||||
}
|
||||
|
||||
private void updateTrailVisibility() => trails.DisplayTrail = Dashing || HyperDashing;
|
||||
|
@ -10,6 +10,7 @@ using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Osu.Edit.Checks;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
|
||||
@ -30,25 +31,23 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
|
||||
[Test]
|
||||
public void TestCircleInCenter()
|
||||
{
|
||||
var beatmap = new Beatmap<HitObject>
|
||||
assertOk(new Beatmap<HitObject>
|
||||
{
|
||||
HitObjects = new List<HitObject>
|
||||
{
|
||||
new HitCircle
|
||||
{
|
||||
StartTime = 3000,
|
||||
Position = playfield_centre // Playfield is 640 x 480.
|
||||
Position = playfield_centre
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Assert.That(check.Run(beatmap), Is.Empty);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCircleNearEdge()
|
||||
{
|
||||
var beatmap = new Beatmap<HitObject>
|
||||
assertOk(new Beatmap<HitObject>
|
||||
{
|
||||
HitObjects = new List<HitObject>
|
||||
{
|
||||
@ -58,15 +57,13 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
|
||||
Position = new Vector2(5, 5)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Assert.That(check.Run(beatmap), Is.Empty);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCircleNearEdgeStackedOffscreen()
|
||||
{
|
||||
var beatmap = new Beatmap<HitObject>
|
||||
assertOffscreenCircle(new Beatmap<HitObject>
|
||||
{
|
||||
HitObjects = new List<HitObject>
|
||||
{
|
||||
@ -77,15 +74,13 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
|
||||
StackHeight = 5
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
assertOffscreenCircle(beatmap);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCircleOffscreen()
|
||||
{
|
||||
var beatmap = new Beatmap<HitObject>
|
||||
assertOffscreenCircle(new Beatmap<HitObject>
|
||||
{
|
||||
HitObjects = new List<HitObject>
|
||||
{
|
||||
@ -95,15 +90,13 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
|
||||
Position = new Vector2(0, 0)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
assertOffscreenCircle(beatmap);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSliderInCenter()
|
||||
{
|
||||
var beatmap = new Beatmap<HitObject>
|
||||
assertOk(new Beatmap<HitObject>
|
||||
{
|
||||
HitObjects = new List<HitObject>
|
||||
{
|
||||
@ -118,15 +111,13 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
|
||||
}),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Assert.That(check.Run(beatmap), Is.Empty);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSliderNearEdge()
|
||||
{
|
||||
var beatmap = new Beatmap<HitObject>
|
||||
assertOk(new Beatmap<HitObject>
|
||||
{
|
||||
HitObjects = new List<HitObject>
|
||||
{
|
||||
@ -141,15 +132,13 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
|
||||
}),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Assert.That(check.Run(beatmap), Is.Empty);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSliderNearEdgeStackedOffscreen()
|
||||
{
|
||||
var beatmap = new Beatmap<HitObject>
|
||||
assertOffscreenSlider(new Beatmap<HitObject>
|
||||
{
|
||||
HitObjects = new List<HitObject>
|
||||
{
|
||||
@ -165,15 +154,13 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
|
||||
StackHeight = 5
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
assertOffscreenSlider(beatmap);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSliderOffscreenStart()
|
||||
{
|
||||
var beatmap = new Beatmap<HitObject>
|
||||
assertOffscreenSlider(new Beatmap<HitObject>
|
||||
{
|
||||
HitObjects = new List<HitObject>
|
||||
{
|
||||
@ -188,15 +175,13 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
|
||||
}),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
assertOffscreenSlider(beatmap);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSliderOffscreenEnd()
|
||||
{
|
||||
var beatmap = new Beatmap<HitObject>
|
||||
assertOffscreenSlider(new Beatmap<HitObject>
|
||||
{
|
||||
HitObjects = new List<HitObject>
|
||||
{
|
||||
@ -211,15 +196,13 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
|
||||
}),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
assertOffscreenSlider(beatmap);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSliderOffscreenPath()
|
||||
{
|
||||
var beatmap = new Beatmap<HitObject>
|
||||
assertOffscreenSlider(new Beatmap<HitObject>
|
||||
{
|
||||
HitObjects = new List<HitObject>
|
||||
{
|
||||
@ -236,14 +219,17 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
|
||||
}),
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
assertOffscreenSlider(beatmap);
|
||||
private void assertOk(IBeatmap beatmap)
|
||||
{
|
||||
Assert.That(check.Run(beatmap, new TestWorkingBeatmap(beatmap)), Is.Empty);
|
||||
}
|
||||
|
||||
private void assertOffscreenCircle(IBeatmap beatmap)
|
||||
{
|
||||
var issues = check.Run(beatmap).ToList();
|
||||
var issues = check.Run(beatmap, new TestWorkingBeatmap(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckOffscreenObjects.IssueTemplateOffscreenCircle);
|
||||
@ -251,7 +237,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
|
||||
|
||||
private void assertOffscreenSlider(IBeatmap beatmap)
|
||||
{
|
||||
var issues = check.Run(beatmap).ToList();
|
||||
var issues = check.Run(beatmap, new TestWorkingBeatmap(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckOffscreenObjects.IssueTemplateOffscreenSlider);
|
||||
|
@ -31,9 +31,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Checks
|
||||
new IssueTemplateOffscreenSlider(this)
|
||||
};
|
||||
|
||||
public IEnumerable<Issue> Run(IBeatmap beatmap)
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, IWorkingBeatmap workingBeatmap)
|
||||
{
|
||||
foreach (var hitobject in beatmap.HitObjects)
|
||||
foreach (var hitobject in playableBeatmap.HitObjects)
|
||||
{
|
||||
switch (hitobject)
|
||||
{
|
||||
|
@ -17,6 +17,9 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
new CheckOffscreenObjects()
|
||||
};
|
||||
|
||||
public IEnumerable<Issue> Run(IBeatmap beatmap) => checks.SelectMany(check => check.Run(beatmap));
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, WorkingBeatmap workingBeatmap)
|
||||
{
|
||||
return checks.SelectMany(check => check.Run(playableBeatmap, workingBeatmap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,30 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Mods
|
||||
{
|
||||
public class OsuModBarrelRoll : Mod, IUpdatableByPlayfield, IApplicableToDrawableRuleset<OsuHitObject>
|
||||
public class OsuModBarrelRoll : Mod, IUpdatableByPlayfield, IApplicableToDrawableRuleset<OsuHitObject>, IApplicableToDrawableHitObjects
|
||||
{
|
||||
private float currentRotation;
|
||||
|
||||
[SettingSource("Roll speed", "Rotations per minute")]
|
||||
public BindableNumber<double> SpinSpeed { get; } = new BindableDouble(0.5)
|
||||
{
|
||||
MinValue = 0.02,
|
||||
MaxValue = 4,
|
||||
MaxValue = 12,
|
||||
Precision = 0.01,
|
||||
};
|
||||
|
||||
@ -30,9 +36,11 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
public override string Description => "The whole playfield is on a wheel!";
|
||||
public override double ScoreMultiplier => 1;
|
||||
|
||||
public override string SettingDescription => $"{SpinSpeed.Value} rpm {Direction.Value.GetDescription().ToLowerInvariant()}";
|
||||
|
||||
public void Update(Playfield playfield)
|
||||
{
|
||||
playfield.Rotation = (Direction.Value == RotationDirection.CounterClockwise ? -1 : 1) * 360 * (float)(playfield.Time.Current / 60000 * SpinSpeed.Value);
|
||||
playfield.Rotation = currentRotation = (Direction.Value == RotationDirection.Counterclockwise ? -1 : 1) * 360 * (float)(playfield.Time.Current / 60000 * SpinSpeed.Value);
|
||||
}
|
||||
|
||||
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
|
||||
@ -40,5 +48,21 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
// scale the playfield to allow all hitobjects to stay within the visible region.
|
||||
drawableRuleset.Playfield.Scale = new Vector2(OsuPlayfield.BASE_SIZE.Y / OsuPlayfield.BASE_SIZE.X);
|
||||
}
|
||||
|
||||
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
|
||||
{
|
||||
foreach (var d in drawables)
|
||||
{
|
||||
d.OnUpdate += _ =>
|
||||
{
|
||||
switch (d)
|
||||
{
|
||||
case DrawableHitCircle circle:
|
||||
circle.CirclePiece.Rotation = -currentRotation;
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +34,9 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
var osuObject = (OsuHitObject)drawable.HitObject;
|
||||
Vector2 origin = drawable.Position;
|
||||
|
||||
// Wiggle the repeat points with the slider instead of independently.
|
||||
// Wiggle the repeat points and the tail with the slider instead of independently.
|
||||
// Also fixes an issue with repeat points being positioned incorrectly.
|
||||
if (osuObject is SliderRepeat)
|
||||
if (osuObject is SliderRepeat || osuObject is SliderTailCircle)
|
||||
return;
|
||||
|
||||
Random objRand = new Random((int)osuObject.StartTime);
|
||||
|
@ -66,7 +66,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
return true;
|
||||
},
|
||||
},
|
||||
CirclePiece = new SkinnableDrawable(new OsuSkinComponent(CirclePieceComponent), _ => new MainCirclePiece()),
|
||||
CirclePiece = new SkinnableDrawable(new OsuSkinComponent(CirclePieceComponent), _ => new MainCirclePiece())
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
ApproachCircle = new ApproachCircle
|
||||
{
|
||||
Alpha = 0,
|
||||
|
@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
base.PopIn();
|
||||
|
||||
GameplayCursor.ActiveCursor.Hide();
|
||||
cursorScaleContainer.MoveTo(GameplayCursor.ActiveCursor.Position);
|
||||
cursorScaleContainer.Position = ToLocalSpace(GameplayCursor.ActiveCursor.ScreenSpaceDrawQuad.Centre);
|
||||
clickToResumeCursor.Appear();
|
||||
|
||||
if (localCursorContainer == null)
|
||||
|
@ -168,6 +168,8 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
protected override Texture GetBackground() => throw new NotImplementedException();
|
||||
|
||||
protected override Track GetBeatmapTrack() => throw new NotImplementedException();
|
||||
|
||||
public override Stream GetStream(string storagePath) => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
114
osu.Game.Tests/Editing/Checks/CheckAudioQualityTest.cs
Normal file
114
osu.Game.Tests/Editing/Checks/CheckAudioQualityTest.cs
Normal file
@ -0,0 +1,114 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit.Checks;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
[TestFixture]
|
||||
public class CheckAudioQualityTest
|
||||
{
|
||||
private CheckAudioQuality check;
|
||||
private IBeatmap beatmap;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
check = new CheckAudioQuality();
|
||||
beatmap = new Beatmap<HitObject>
|
||||
{
|
||||
BeatmapInfo = new BeatmapInfo
|
||||
{
|
||||
Metadata = new BeatmapMetadata { AudioFile = "abc123.jpg" }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMissing()
|
||||
{
|
||||
// While this is a problem, it is out of scope for this check and is caught by a different one.
|
||||
beatmap.Metadata.AudioFile = null;
|
||||
|
||||
var mock = new Mock<IWorkingBeatmap>();
|
||||
mock.SetupGet(w => w.Beatmap).Returns(beatmap);
|
||||
mock.SetupGet(w => w.Track).Returns((Track)null);
|
||||
|
||||
Assert.That(check.Run(beatmap, mock.Object), Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAcceptable()
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(192);
|
||||
|
||||
Assert.That(check.Run(beatmap, mock.Object), Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNullBitrate()
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(null);
|
||||
|
||||
var issues = check.Run(beatmap, mock.Object).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckAudioQuality.IssueTemplateNoBitrate);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestZeroBitrate()
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(0);
|
||||
|
||||
var issues = check.Run(beatmap, mock.Object).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckAudioQuality.IssueTemplateNoBitrate);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTooHighBitrate()
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(320);
|
||||
|
||||
var issues = check.Run(beatmap, mock.Object).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckAudioQuality.IssueTemplateTooHighBitrate);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTooLowBitrate()
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(64);
|
||||
|
||||
var issues = check.Run(beatmap, mock.Object).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckAudioQuality.IssueTemplateTooLowBitrate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the mock of the working beatmap with the given audio properties.
|
||||
/// </summary>
|
||||
/// <param name="audioBitrate">The bitrate of the audio file the beatmap uses.</param>
|
||||
private Mock<IWorkingBeatmap> getMockWorkingBeatmap(int? audioBitrate)
|
||||
{
|
||||
var mockTrack = new Mock<Track>();
|
||||
mockTrack.SetupGet(t => t.Bitrate).Returns(audioBitrate);
|
||||
|
||||
var mockWorkingBeatmap = new Mock<IWorkingBeatmap>();
|
||||
mockWorkingBeatmap.SetupGet(w => w.Beatmap).Returns(beatmap);
|
||||
mockWorkingBeatmap.SetupGet(w => w.Track).Returns(mockTrack.Object);
|
||||
|
||||
return mockWorkingBeatmap;
|
||||
}
|
||||
}
|
||||
}
|
130
osu.Game.Tests/Editing/Checks/CheckBackgroundQualityTest.cs
Normal file
130
osu.Game.Tests/Editing/Checks/CheckBackgroundQualityTest.cs
Normal file
@ -0,0 +1,130 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit.Checks;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using FileInfo = osu.Game.IO.FileInfo;
|
||||
|
||||
namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
[TestFixture]
|
||||
public class CheckBackgroundQualityTest
|
||||
{
|
||||
private CheckBackgroundQuality check;
|
||||
private IBeatmap beatmap;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
check = new CheckBackgroundQuality();
|
||||
beatmap = new Beatmap<HitObject>
|
||||
{
|
||||
BeatmapInfo = new BeatmapInfo
|
||||
{
|
||||
Metadata = new BeatmapMetadata { BackgroundFile = "abc123.jpg" },
|
||||
BeatmapSet = new BeatmapSetInfo
|
||||
{
|
||||
Files = new List<BeatmapSetFileInfo>(new[]
|
||||
{
|
||||
new BeatmapSetFileInfo
|
||||
{
|
||||
Filename = "abc123.jpg",
|
||||
FileInfo = new FileInfo
|
||||
{
|
||||
Hash = "abcdef"
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMissing()
|
||||
{
|
||||
// While this is a problem, it is out of scope for this check and is caught by a different one.
|
||||
beatmap.Metadata.BackgroundFile = null;
|
||||
var mock = getMockWorkingBeatmap(null, System.Array.Empty<byte>());
|
||||
|
||||
Assert.That(check.Run(beatmap, mock.Object), Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAcceptable()
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(new Texture(1920, 1080));
|
||||
|
||||
Assert.That(check.Run(beatmap, mock.Object), Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTooHighResolution()
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(new Texture(3840, 2160));
|
||||
|
||||
var issues = check.Run(beatmap, mock.Object).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckBackgroundQuality.IssueTemplateTooHighResolution);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLowResolution()
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(new Texture(640, 480));
|
||||
|
||||
var issues = check.Run(beatmap, mock.Object).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckBackgroundQuality.IssueTemplateLowResolution);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTooLowResolution()
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(new Texture(100, 100));
|
||||
|
||||
var issues = check.Run(beatmap, mock.Object).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckBackgroundQuality.IssueTemplateTooLowResolution);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTooUncompressed()
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(new Texture(1920, 1080), new byte[1024 * 1024 * 3]);
|
||||
|
||||
var issues = check.Run(beatmap, mock.Object).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckBackgroundQuality.IssueTemplateTooUncompressed);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the mock of the working beatmap with the given background and filesize.
|
||||
/// </summary>
|
||||
/// <param name="background">The texture of the background.</param>
|
||||
/// <param name="fileBytes">The bytes that represent the background file.</param>
|
||||
private Mock<IWorkingBeatmap> getMockWorkingBeatmap(Texture background, [CanBeNull] byte[] fileBytes = null)
|
||||
{
|
||||
var stream = new MemoryStream(fileBytes ?? new byte[1024 * 1024]);
|
||||
|
||||
var mock = new Mock<IWorkingBeatmap>();
|
||||
mock.SetupGet(w => w.Beatmap).Returns(beatmap);
|
||||
mock.SetupGet(w => w.Background).Returns(background);
|
||||
mock.Setup(w => w.GetStream(It.IsAny<string>())).Returns(stream);
|
||||
|
||||
return mock;
|
||||
}
|
||||
}
|
||||
}
|
@ -5,21 +5,23 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Rulesets.Edit.Checks;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
|
||||
namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
[TestFixture]
|
||||
public class CheckBackgroundTest
|
||||
public class CheckFilePresenceTest
|
||||
{
|
||||
private CheckBackground check;
|
||||
private CheckBackgroundPresence check;
|
||||
private IBeatmap beatmap;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
check = new CheckBackground();
|
||||
check = new CheckBackgroundPresence();
|
||||
beatmap = new Beatmap<HitObject>
|
||||
{
|
||||
BeatmapInfo = new BeatmapInfo
|
||||
@ -29,7 +31,11 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
Files = new List<BeatmapSetFileInfo>(new[]
|
||||
{
|
||||
new BeatmapSetFileInfo { Filename = "abc123.jpg" }
|
||||
new BeatmapSetFileInfo
|
||||
{
|
||||
Filename = "abc123.jpg",
|
||||
FileInfo = new FileInfo { Hash = "abcdef" }
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -39,7 +45,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
[Test]
|
||||
public void TestBackgroundSetAndInFiles()
|
||||
{
|
||||
Assert.That(check.Run(beatmap), Is.Empty);
|
||||
Assert.That(check.Run(beatmap, new TestWorkingBeatmap(beatmap)), Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -47,10 +53,10 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
beatmap.BeatmapInfo.BeatmapSet.Files.Clear();
|
||||
|
||||
var issues = check.Run(beatmap).ToList();
|
||||
var issues = check.Run(beatmap, new TestWorkingBeatmap(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckBackground.IssueTemplateDoesNotExist);
|
||||
Assert.That(issues.Single().Template is CheckFilePresence.IssueTemplateDoesNotExist);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -58,10 +64,10 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
beatmap.Metadata.BackgroundFile = null;
|
||||
|
||||
var issues = check.Run(beatmap).ToList();
|
||||
var issues = check.Run(beatmap, new TestWorkingBeatmap(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckBackground.IssueTemplateNoneSet);
|
||||
Assert.That(issues.Single().Template is CheckFilePresence.IssueTemplateNoneSet);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Tests.Gameplay
|
||||
{
|
||||
[HeadlessTest]
|
||||
public class TestSceneGameplayClockContainer : OsuTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestStartThenElapsedTime()
|
||||
{
|
||||
GameplayClockContainer gcc = null;
|
||||
|
||||
AddStep("create container", () =>
|
||||
{
|
||||
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||
working.LoadTrack();
|
||||
|
||||
Add(gcc = new MasterGameplayClockContainer(working, 0));
|
||||
});
|
||||
|
||||
AddStep("start track", () => gcc.Start());
|
||||
AddUntilStep("elapsed greater than zero", () => gcc.GameplayClock.ElapsedFrameTime > 0);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Tests.Gameplay
|
||||
{
|
||||
[HeadlessTest]
|
||||
public class TestSceneMasterGameplayClockContainer : OsuTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestStartThenElapsedTime()
|
||||
{
|
||||
GameplayClockContainer gcc = null;
|
||||
|
||||
AddStep("create container", () =>
|
||||
{
|
||||
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||
working.LoadTrack();
|
||||
|
||||
Add(gcc = new MasterGameplayClockContainer(working, 0));
|
||||
});
|
||||
|
||||
AddStep("start clock", () => gcc.Start());
|
||||
AddUntilStep("elapsed greater than zero", () => gcc.GameplayClock.ElapsedFrameTime > 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestElapseThenReset()
|
||||
{
|
||||
GameplayClockContainer gcc = null;
|
||||
|
||||
AddStep("create container", () =>
|
||||
{
|
||||
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||
working.LoadTrack();
|
||||
|
||||
Add(gcc = new MasterGameplayClockContainer(working, 0));
|
||||
});
|
||||
|
||||
AddStep("start clock", () => gcc.Start());
|
||||
AddUntilStep("current time greater 2000", () => gcc.GameplayClock.CurrentTime > 2000);
|
||||
|
||||
double timeAtReset = 0;
|
||||
AddStep("reset clock", () =>
|
||||
{
|
||||
timeAtReset = gcc.GameplayClock.CurrentTime;
|
||||
gcc.Reset();
|
||||
});
|
||||
|
||||
AddAssert("current time < time at reset", () => gcc.GameplayClock.CurrentTime < timeAtReset);
|
||||
}
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Storyboards;
|
||||
@ -67,17 +68,47 @@ namespace osu.Game.Tests.Gameplay
|
||||
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||
working.LoadTrack();
|
||||
|
||||
Add(gameplayContainer = new MasterGameplayClockContainer(working, 0));
|
||||
|
||||
gameplayContainer.Add(sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
|
||||
Add(gameplayContainer = new MasterGameplayClockContainer(working, 0)
|
||||
{
|
||||
Clock = gameplayContainer.GameplayClock
|
||||
IsPaused = { Value = true },
|
||||
Child = new FrameStabilityContainer
|
||||
{
|
||||
Child = sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
AddStep("reset clock", () => gameplayContainer.Start());
|
||||
|
||||
AddUntilStep("sample played", () => sample.RequestedPlaying);
|
||||
AddUntilStep("sample has lifetime end", () => sample.LifetimeEnd < double.MaxValue);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSampleHasLifetimeEndWithInitialClockTime()
|
||||
{
|
||||
GameplayClockContainer gameplayContainer = null;
|
||||
DrawableStoryboardSample sample = null;
|
||||
|
||||
AddStep("create container", () =>
|
||||
{
|
||||
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||
working.LoadTrack();
|
||||
|
||||
Add(gameplayContainer = new MasterGameplayClockContainer(working, 1000, true)
|
||||
{
|
||||
IsPaused = { Value = true },
|
||||
Child = new FrameStabilityContainer
|
||||
{
|
||||
Child = sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
AddStep("start time", () => gameplayContainer.Start());
|
||||
|
||||
AddUntilStep("sample playback succeeded", () => sample.LifetimeEnd < double.MaxValue);
|
||||
AddUntilStep("sample not played", () => !sample.RequestedPlaying);
|
||||
AddUntilStep("sample has lifetime end", () => sample.LifetimeEnd < double.MaxValue);
|
||||
}
|
||||
|
||||
[TestCase(typeof(OsuModDoubleTime), 1.5)]
|
||||
|
47
osu.Game.Tests/NonVisual/SessionStaticsTest.cs
Normal file
47
osu.Game.Tests/NonVisual/SessionStaticsTest.cs
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Input;
|
||||
|
||||
namespace osu.Game.Tests.NonVisual
|
||||
{
|
||||
[TestFixture]
|
||||
public class SessionStaticsTest
|
||||
{
|
||||
private SessionStatics sessionStatics;
|
||||
private IdleTracker sessionIdleTracker;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
sessionStatics = new SessionStatics();
|
||||
sessionIdleTracker = new GameIdleTracker(1000);
|
||||
|
||||
sessionStatics.SetValue(Static.LoginOverlayDisplayed, true);
|
||||
sessionStatics.SetValue(Static.MutedAudioNotificationShownOnce, true);
|
||||
sessionStatics.SetValue(Static.LowBatteryNotificationShownOnce, true);
|
||||
sessionStatics.SetValue(Static.LastHoverSoundPlaybackTime, (double?)1d);
|
||||
|
||||
sessionIdleTracker.IsIdle.BindValueChanged(e =>
|
||||
{
|
||||
if (e.NewValue)
|
||||
sessionStatics.ResetValues();
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Timeout(2000)]
|
||||
public void TestSessionStaticsReset()
|
||||
{
|
||||
sessionIdleTracker.IsIdle.BindValueChanged(e =>
|
||||
{
|
||||
Assert.IsTrue(sessionStatics.GetBindable<bool>(Static.LoginOverlayDisplayed).IsDefault);
|
||||
Assert.IsTrue(sessionStatics.GetBindable<bool>(Static.MutedAudioNotificationShownOnce).IsDefault);
|
||||
Assert.IsTrue(sessionStatics.GetBindable<bool>(Static.LowBatteryNotificationShownOnce).IsDefault);
|
||||
Assert.IsTrue(sessionStatics.GetBindable<double?>(Static.LastHoverSoundPlaybackTime).IsDefault);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -81,6 +81,13 @@ namespace osu.Game.Tests.Visual.Components
|
||||
[Test]
|
||||
public void TestMovement()
|
||||
{
|
||||
checkIdleStatus(1, false);
|
||||
checkIdleStatus(2, false);
|
||||
checkIdleStatus(3, false);
|
||||
checkIdleStatus(4, false);
|
||||
|
||||
waitForAllIdle();
|
||||
|
||||
AddStep("move to top right", () => InputManager.MoveMouseTo(box2));
|
||||
|
||||
checkIdleStatus(1, true);
|
||||
@ -102,6 +109,8 @@ namespace osu.Game.Tests.Visual.Components
|
||||
[Test]
|
||||
public void TestTimings()
|
||||
{
|
||||
waitForAllIdle();
|
||||
|
||||
AddStep("move to centre", () => InputManager.MoveMouseTo(Content));
|
||||
|
||||
checkIdleStatus(1, false);
|
||||
@ -140,7 +149,7 @@ namespace osu.Game.Tests.Visual.Components
|
||||
|
||||
private void waitForAllIdle()
|
||||
{
|
||||
AddUntilStep("Wait for all idle", () => box1.IsIdle && box2.IsIdle && box3.IsIdle && box4.IsIdle);
|
||||
AddUntilStep("wait for all idle", () => box1.IsIdle && box2.IsIdle && box3.IsIdle && box4.IsIdle);
|
||||
}
|
||||
|
||||
private class IdleTrackingBox : CompositeDrawable
|
||||
@ -149,7 +158,7 @@ namespace osu.Game.Tests.Visual.Components
|
||||
|
||||
public bool IsIdle => idleTracker.IsIdle.Value;
|
||||
|
||||
public IdleTrackingBox(double timeToIdle)
|
||||
public IdleTrackingBox(int timeToIdle)
|
||||
{
|
||||
Box box;
|
||||
|
||||
@ -158,7 +167,7 @@ namespace osu.Game.Tests.Visual.Components
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
idleTracker = new IdleTracker(timeToIdle),
|
||||
idleTracker = new GameIdleTracker(timeToIdle),
|
||||
box = new Box
|
||||
{
|
||||
Colour = Color4.White,
|
||||
|
@ -3,12 +3,16 @@
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osuTK;
|
||||
|
||||
@ -110,8 +114,9 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddAssert("duration matches", () => ((Spinner)EditorBeatmap.HitObjects.Single()).Duration == 5000);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCopyPaste()
|
||||
[TestCase(false)]
|
||||
[TestCase(true)]
|
||||
public void TestCopyPaste(bool deselectAfterCopy)
|
||||
{
|
||||
var addedObject = new HitCircle { StartTime = 1000 };
|
||||
|
||||
@ -123,11 +128,22 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
AddStep("move forward in time", () => EditorClock.Seek(2000));
|
||||
|
||||
if (deselectAfterCopy)
|
||||
{
|
||||
AddStep("deselect", () => EditorBeatmap.SelectedHitObjects.Clear());
|
||||
|
||||
AddUntilStep("timeline selection box is not visible", () => Editor.ChildrenOfType<Timeline>().First().ChildrenOfType<SelectionHandler>().First().Alpha == 0);
|
||||
AddUntilStep("composer selection box is not visible", () => Editor.ChildrenOfType<HitObjectComposer>().First().ChildrenOfType<SelectionHandler>().First().Alpha == 0);
|
||||
}
|
||||
|
||||
AddStep("paste hitobject", () => Editor.Paste());
|
||||
|
||||
AddAssert("are two objects", () => EditorBeatmap.HitObjects.Count == 2);
|
||||
|
||||
AddAssert("new object selected", () => EditorBeatmap.SelectedHitObjects.Single().StartTime == 2000);
|
||||
|
||||
AddUntilStep("timeline selection box is visible", () => Editor.ChildrenOfType<Timeline>().First().ChildrenOfType<SelectionHandler>().First().Alpha > 0);
|
||||
AddUntilStep("composer selection box is visible", () => Editor.ChildrenOfType<HitObjectComposer>().First().ChildrenOfType<SelectionHandler>().First().Alpha > 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -130,9 +130,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
public double GameplayClockTime => GameplayClockContainer.GameplayClock.CurrentTime;
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
protected override void Update()
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
base.Update();
|
||||
|
||||
if (!FirstFrameClockTime.HasValue)
|
||||
{
|
||||
|
@ -118,8 +118,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
public void TestBasic()
|
||||
{
|
||||
AddStep("move to center", () => InputManager.MoveMouseTo(recordingManager.ScreenSpaceDrawQuad.Centre));
|
||||
AddUntilStep("one frame recorded", () => replay.Frames.Count == 1);
|
||||
AddAssert("position matches", () => playbackManager.ChildrenOfType<Box>().First().Position == recordingManager.ChildrenOfType<Box>().First().Position);
|
||||
AddUntilStep("at least one frame recorded", () => replay.Frames.Count > 0);
|
||||
AddUntilStep("position matches", () => playbackManager.ChildrenOfType<Box>().First().Position == recordingManager.ChildrenOfType<Box>().First().Position);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -139,14 +139,16 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
public void TestLimitedFrameRate()
|
||||
{
|
||||
ScheduledDelegate moveFunction = null;
|
||||
int initialFrameCount = 0;
|
||||
|
||||
AddStep("lower rate", () => recorder.RecordFrameRate = 2);
|
||||
AddStep("count frames", () => initialFrameCount = replay.Frames.Count);
|
||||
AddStep("move to center", () => InputManager.MoveMouseTo(recordingManager.ScreenSpaceDrawQuad.Centre));
|
||||
AddStep("much move", () => moveFunction = Scheduler.AddDelayed(() =>
|
||||
InputManager.MoveMouseTo(InputManager.CurrentState.Mouse.Position + new Vector2(-1, 0)), 10, true));
|
||||
AddWaitStep("move", 10);
|
||||
AddStep("stop move", () => moveFunction.Cancel());
|
||||
AddAssert("less than 10 frames recorded", () => replay.Frames.Count < 10);
|
||||
AddAssert("less than 10 frames recorded", () => replay.Frames.Count - initialFrameCount < 10);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -0,0 +1,70 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestSceneLabelledColourPalette : OsuTestScene
|
||||
{
|
||||
private LabelledColourPalette component;
|
||||
|
||||
[Test]
|
||||
public void TestPalette([Values] bool hasDescription)
|
||||
{
|
||||
createColourPalette(hasDescription);
|
||||
|
||||
AddRepeatStep("add random colour", () => component.Colours.Add(randomColour()), 4);
|
||||
|
||||
AddStep("set custom prefix", () => component.ColourNamePrefix = "Combo");
|
||||
|
||||
AddRepeatStep("remove random colour", () =>
|
||||
{
|
||||
if (component.Colours.Count > 0)
|
||||
component.Colours.RemoveAt(RNG.Next(component.Colours.Count));
|
||||
}, 8);
|
||||
}
|
||||
|
||||
private void createColourPalette(bool hasDescription = false)
|
||||
{
|
||||
AddStep("create component", () =>
|
||||
{
|
||||
Child = new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Width = 500,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Child = component = new LabelledColourPalette
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
ColourNamePrefix = "My colour #"
|
||||
}
|
||||
};
|
||||
|
||||
component.Label = "a sample component";
|
||||
component.Description = hasDescription ? "this text describes the component" : string.Empty;
|
||||
|
||||
component.Colours.AddRange(new[]
|
||||
{
|
||||
Color4.DarkRed,
|
||||
Color4.Aquamarine,
|
||||
Color4.Goldenrod,
|
||||
Color4.Gainsboro
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private Color4 randomColour() => new Color4(
|
||||
RNG.NextSingle(),
|
||||
RNG.NextSingle(),
|
||||
RNG.NextSingle(),
|
||||
1);
|
||||
}
|
||||
}
|
@ -167,7 +167,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
GetModButton(mod).SelectNext(1);
|
||||
|
||||
public void SetModSettingsWidth(float newWidth) =>
|
||||
ModSettingsContainer.Width = newWidth;
|
||||
ModSettingsContainer.Parent.Width = newWidth;
|
||||
}
|
||||
|
||||
public class TestRulesetInfo : RulesetInfo
|
||||
|
@ -52,6 +52,8 @@ namespace osu.Game.Tests
|
||||
|
||||
protected override Waveform GetWaveform() => new Waveform(trackStore.GetStream(firstAudioFile));
|
||||
|
||||
public override Stream GetStream(string storagePath) => null;
|
||||
|
||||
protected override Track GetBeatmapTrack() => trackStore.Get(firstAudioFile);
|
||||
|
||||
private string firstAudioFile
|
||||
|
@ -532,6 +532,7 @@ namespace osu.Game.Beatmaps
|
||||
protected override IBeatmap GetBeatmap() => beatmap;
|
||||
protected override Texture GetBackground() => null;
|
||||
protected override Track GetBeatmapTrack() => null;
|
||||
public override Stream GetStream(string storagePath) => null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Logging;
|
||||
@ -36,7 +36,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
try
|
||||
{
|
||||
using (var stream = new LineBufferedReader(resources.Files.GetStream(getPathForFile(BeatmapInfo.Path))))
|
||||
using (var stream = new LineBufferedReader(GetStream(BeatmapSetInfo.GetPathForFile(BeatmapInfo.Path))))
|
||||
return Decoder.GetDecoder<Beatmap>(stream).Decode(stream);
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -46,8 +46,6 @@ namespace osu.Game.Beatmaps
|
||||
}
|
||||
}
|
||||
|
||||
private string getPathForFile(string filename) => BeatmapSetInfo.Files.SingleOrDefault(f => string.Equals(f.Filename, filename, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath;
|
||||
|
||||
protected override bool BackgroundStillValid(Texture b) => false; // bypass lazy logic. we want to return a new background each time for refcounting purposes.
|
||||
|
||||
protected override Texture GetBackground()
|
||||
@ -57,7 +55,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
try
|
||||
{
|
||||
return resources.LargeTextureStore.Get(getPathForFile(Metadata.BackgroundFile));
|
||||
return resources.LargeTextureStore.Get(BeatmapSetInfo.GetPathForFile(Metadata.BackgroundFile));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -73,7 +71,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
try
|
||||
{
|
||||
return resources.Tracks.Get(getPathForFile(Metadata.AudioFile));
|
||||
return resources.Tracks.Get(BeatmapSetInfo.GetPathForFile(Metadata.AudioFile));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -89,7 +87,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
try
|
||||
{
|
||||
var trackData = resources.Files.GetStream(getPathForFile(Metadata.AudioFile));
|
||||
var trackData = GetStream(BeatmapSetInfo.GetPathForFile(Metadata.AudioFile));
|
||||
return trackData == null ? null : new Waveform(trackData);
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -105,7 +103,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
try
|
||||
{
|
||||
using (var stream = new LineBufferedReader(resources.Files.GetStream(getPathForFile(BeatmapInfo.Path))))
|
||||
using (var stream = new LineBufferedReader(GetStream(BeatmapSetInfo.GetPathForFile(BeatmapInfo.Path))))
|
||||
{
|
||||
var decoder = Decoder.GetDecoder<Storyboard>(stream);
|
||||
|
||||
@ -114,7 +112,7 @@ namespace osu.Game.Beatmaps
|
||||
storyboard = decoder.Decode(stream);
|
||||
else
|
||||
{
|
||||
using (var secondaryStream = new LineBufferedReader(resources.Files.GetStream(getPathForFile(BeatmapSetInfo.StoryboardFile))))
|
||||
using (var secondaryStream = new LineBufferedReader(GetStream(BeatmapSetInfo.GetPathForFile(BeatmapSetInfo.StoryboardFile))))
|
||||
storyboard = decoder.Decode(stream, secondaryStream);
|
||||
}
|
||||
}
|
||||
@ -142,6 +140,8 @@ namespace osu.Game.Beatmaps
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public override Stream GetStream(string storagePath) => resources.Files.GetStream(storagePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,13 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
public string StoryboardFile => Files?.Find(f => f.Filename.EndsWith(".osb", StringComparison.OrdinalIgnoreCase))?.Filename;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the storage path for the file in this beatmapset with the given filename, if any exists, otherwise null.
|
||||
/// The path returned is relative to the user file storage.
|
||||
/// </summary>
|
||||
/// <param name="filename">The name of the file to get the storage path of.</param>
|
||||
public string GetPathForFile(string filename) => Files?.SingleOrDefault(f => string.Equals(f.Filename, filename, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath;
|
||||
|
||||
public List<BeatmapSetFileInfo> Files { get; set; }
|
||||
|
||||
public override string ToString() => Metadata?.ToString() ?? base.ToString();
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Audio;
|
||||
@ -48,6 +49,8 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
protected override Track GetBeatmapTrack() => GetVirtualTrack();
|
||||
|
||||
public override Stream GetStream(string storagePath) => null;
|
||||
|
||||
private class DummyRulesetInfo : RulesetInfo
|
||||
{
|
||||
public override Ruleset CreateInstance() => new DummyRuleset();
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Rulesets;
|
||||
@ -41,6 +42,11 @@ namespace osu.Game.Beatmaps
|
||||
/// </summary>
|
||||
ISkin Skin { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the <see cref="Track"/> which this <see cref="WorkingBeatmap"/> has loaded.
|
||||
/// </summary>
|
||||
Track Track { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a playable <see cref="IBeatmap"/> from <see cref="Beatmap"/> using the applicable converters for a specific <see cref="RulesetInfo"/>.
|
||||
/// <para>
|
||||
@ -67,5 +73,11 @@ namespace osu.Game.Beatmaps
|
||||
/// </remarks>
|
||||
/// <returns>A fresh track instance, which will also be available via <see cref="Track"/>.</returns>
|
||||
Track LoadTrack();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the stream of the file from the given storage path.
|
||||
/// </summary>
|
||||
/// <param name="storagePath">The storage path to the file.</param>
|
||||
Stream GetStream(string storagePath);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,16 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace osu.Game.Beatmaps.Timing
|
||||
{
|
||||
public enum TimeSignatures
|
||||
{
|
||||
[Description("4/4")]
|
||||
SimpleQuadruple = 4,
|
||||
|
||||
[Description("3/4")]
|
||||
SimpleTriple = 3
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@ -326,6 +327,8 @@ namespace osu.Game.Beatmaps
|
||||
protected virtual ISkin GetSkin() => new DefaultSkin();
|
||||
private readonly RecyclableLazy<ISkin> skin;
|
||||
|
||||
public abstract Stream GetStream(string storagePath);
|
||||
|
||||
public class RecyclableLazy<T>
|
||||
{
|
||||
private Lazy<T> lazy;
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays;
|
||||
@ -12,14 +13,18 @@ namespace osu.Game.Configuration
|
||||
/// </summary>
|
||||
public class SessionStatics : InMemoryConfigManager<Static>
|
||||
{
|
||||
protected override void InitialiseDefaults()
|
||||
protected override void InitialiseDefaults() => ResetValues();
|
||||
|
||||
public void ResetValues()
|
||||
{
|
||||
SetDefault(Static.LoginOverlayDisplayed, false);
|
||||
SetDefault(Static.MutedAudioNotificationShownOnce, false);
|
||||
SetDefault(Static.LowBatteryNotificationShownOnce, false);
|
||||
SetDefault(Static.LastHoverSoundPlaybackTime, (double?)null);
|
||||
SetDefault<APISeasonalBackgrounds>(Static.SeasonalBackgrounds, null);
|
||||
ensureDefault(SetDefault(Static.LoginOverlayDisplayed, false));
|
||||
ensureDefault(SetDefault(Static.MutedAudioNotificationShownOnce, false));
|
||||
ensureDefault(SetDefault(Static.LowBatteryNotificationShownOnce, false));
|
||||
ensureDefault(SetDefault(Static.LastHoverSoundPlaybackTime, (double?)null));
|
||||
ensureDefault(SetDefault<APISeasonalBackgrounds>(Static.SeasonalBackgrounds, null));
|
||||
}
|
||||
|
||||
private void ensureDefault<T>(Bindable<T> bindable) => bindable.SetDefault();
|
||||
}
|
||||
|
||||
public enum Static
|
||||
|
@ -94,6 +94,18 @@ namespace osu.Game.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a foreground text colour that is supposed to contrast well with
|
||||
/// the supplied <paramref name="backgroundColour"/>.
|
||||
/// </summary>
|
||||
public static Color4 ForegroundTextColourFor(Color4 backgroundColour)
|
||||
{
|
||||
// formula taken from the RGB->YIQ conversions: https://en.wikipedia.org/wiki/YIQ
|
||||
// brightness here is equivalent to the Y component in the above colour model, which is a rough estimate of lightness.
|
||||
float brightness = 0.299f * backgroundColour.R + 0.587f * backgroundColour.G + 0.114f * backgroundColour.B;
|
||||
return Gray(brightness > 0.5f ? 0.2f : 0.9f);
|
||||
}
|
||||
|
||||
// See https://github.com/ppy/osu-web/blob/master/resources/assets/less/colors.less
|
||||
public readonly Color4 PurpleLighter = Color4Extensions.FromHex(@"eeeeff");
|
||||
public readonly Color4 PurpleLight = Color4Extensions.FromHex(@"aa88ff");
|
||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
AddInternal(checkmark = new SpriteIcon
|
||||
Add(checkmark = new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
|
107
osu.Game/Graphics/UserInterfaceV2/ColourDisplay.cs
Normal file
107
osu.Game/Graphics/UserInterfaceV2/ColourDisplay.cs
Normal file
@ -0,0 +1,107 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterfaceV2
|
||||
{
|
||||
/// <summary>
|
||||
/// A component which displays a colour along with related description text.
|
||||
/// </summary>
|
||||
public class ColourDisplay : CompositeDrawable, IHasCurrentValue<Color4>
|
||||
{
|
||||
private readonly BindableWithCurrent<Color4> current = new BindableWithCurrent<Color4>();
|
||||
|
||||
private Box fill;
|
||||
private OsuSpriteText colourHexCode;
|
||||
private OsuSpriteText colourName;
|
||||
|
||||
public Bindable<Color4> Current
|
||||
{
|
||||
get => current.Current;
|
||||
set => current.Current = value;
|
||||
}
|
||||
|
||||
private LocalisableString name;
|
||||
|
||||
public LocalisableString ColourName
|
||||
{
|
||||
get => name;
|
||||
set
|
||||
{
|
||||
if (name == value)
|
||||
return;
|
||||
|
||||
name = value;
|
||||
|
||||
colourName.Text = name;
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Width = 100;
|
||||
|
||||
InternalChild = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 10),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new CircularContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 100,
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
fill = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
colourHexCode = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = OsuFont.Default.With(size: 12)
|
||||
}
|
||||
}
|
||||
},
|
||||
colourName = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
current.BindValueChanged(_ => updateColour(), true);
|
||||
}
|
||||
|
||||
private void updateColour()
|
||||
{
|
||||
fill.Colour = current.Value;
|
||||
colourHexCode.Text = current.Value.ToHex();
|
||||
colourHexCode.Colour = OsuColour.ForegroundTextColourFor(current.Value);
|
||||
}
|
||||
}
|
||||
}
|
119
osu.Game/Graphics/UserInterfaceV2/ColourPalette.cs
Normal file
119
osu.Game/Graphics/UserInterfaceV2/ColourPalette.cs
Normal file
@ -0,0 +1,119 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterfaceV2
|
||||
{
|
||||
/// <summary>
|
||||
/// A component which displays a collection of colours in individual <see cref="ColourDisplay"/>s.
|
||||
/// </summary>
|
||||
public class ColourPalette : CompositeDrawable
|
||||
{
|
||||
public BindableList<Color4> Colours { get; } = new BindableList<Color4>();
|
||||
|
||||
private string colourNamePrefix = "Colour";
|
||||
|
||||
public string ColourNamePrefix
|
||||
{
|
||||
get => colourNamePrefix;
|
||||
set
|
||||
{
|
||||
if (colourNamePrefix == value)
|
||||
return;
|
||||
|
||||
colourNamePrefix = value;
|
||||
|
||||
if (IsLoaded)
|
||||
reindexItems();
|
||||
}
|
||||
}
|
||||
|
||||
private FillFlowContainer<ColourDisplay> palette;
|
||||
private Container placeholder;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
palette = new FillFlowContainer<ColourDisplay>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Spacing = new Vector2(10),
|
||||
Direction = FillDirection.Full
|
||||
},
|
||||
placeholder = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Child = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Text = "(none)",
|
||||
Font = OsuFont.Default.With(weight: FontWeight.Bold)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Colours.BindCollectionChanged((_, __) => updatePalette(), true);
|
||||
FinishTransforms(true);
|
||||
}
|
||||
|
||||
private const int fade_duration = 200;
|
||||
|
||||
private void updatePalette()
|
||||
{
|
||||
palette.Clear();
|
||||
|
||||
if (Colours.Any())
|
||||
{
|
||||
palette.FadeIn(fade_duration, Easing.OutQuint);
|
||||
placeholder.FadeOut(fade_duration, Easing.OutQuint);
|
||||
}
|
||||
else
|
||||
{
|
||||
palette.FadeOut(fade_duration, Easing.OutQuint);
|
||||
placeholder.FadeIn(fade_duration, Easing.OutQuint);
|
||||
}
|
||||
|
||||
foreach (var item in Colours)
|
||||
{
|
||||
palette.Add(new ColourDisplay
|
||||
{
|
||||
Current = { Value = item }
|
||||
});
|
||||
}
|
||||
|
||||
reindexItems();
|
||||
}
|
||||
|
||||
private void reindexItems()
|
||||
{
|
||||
int index = 1;
|
||||
|
||||
foreach (var colour in palette)
|
||||
{
|
||||
colour.ColourName = $"{colourNamePrefix} {index}";
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
26
osu.Game/Graphics/UserInterfaceV2/LabelledColourPalette.cs
Normal file
26
osu.Game/Graphics/UserInterfaceV2/LabelledColourPalette.cs
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Bindables;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterfaceV2
|
||||
{
|
||||
public class LabelledColourPalette : LabelledDrawable<ColourPalette>
|
||||
{
|
||||
public LabelledColourPalette()
|
||||
: base(true)
|
||||
{
|
||||
}
|
||||
|
||||
public BindableList<Color4> Colours => Component.Colours;
|
||||
|
||||
public string ColourNamePrefix
|
||||
{
|
||||
get => Component.ColourNamePrefix;
|
||||
set => Component.ColourNamePrefix = value;
|
||||
}
|
||||
|
||||
protected override ColourPalette CreateComponent() => new ColourPalette();
|
||||
}
|
||||
}
|
@ -42,6 +42,12 @@ namespace osu.Game.Input
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
updateLastInteractionTime();
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
@ -577,6 +577,15 @@ namespace osu.Game
|
||||
|
||||
dependencies.CacheAs(idleTracker = new GameIdleTracker(6000));
|
||||
|
||||
var sessionIdleTracker = new GameIdleTracker(300000);
|
||||
sessionIdleTracker.IsIdle.BindValueChanged(idle =>
|
||||
{
|
||||
if (idle.NewValue)
|
||||
SessionStatics.ResetValues();
|
||||
});
|
||||
|
||||
Add(sessionIdleTracker);
|
||||
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
new VolumeControlReceptor
|
||||
|
@ -61,6 +61,8 @@ namespace osu.Game
|
||||
|
||||
protected OsuConfigManager LocalConfig;
|
||||
|
||||
protected SessionStatics SessionStatics { get; private set; }
|
||||
|
||||
protected BeatmapManager BeatmapManager;
|
||||
|
||||
protected ScoreManager ScoreManager;
|
||||
@ -289,7 +291,7 @@ namespace osu.Game
|
||||
if (powerStatus != null)
|
||||
dependencies.CacheAs(powerStatus);
|
||||
|
||||
dependencies.Cache(new SessionStatics());
|
||||
dependencies.Cache(SessionStatics = new SessionStatics());
|
||||
dependencies.Cache(new OsuColour());
|
||||
|
||||
RegisterImportHandler(BeatmapManager);
|
||||
|
@ -245,15 +245,21 @@ namespace osu.Game.Overlays.Mods
|
||||
},
|
||||
}
|
||||
},
|
||||
ModSettingsContainer = new ModSettingsContainer
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Width = 0.3f,
|
||||
Alpha = 0,
|
||||
Padding = new MarginPadding(30),
|
||||
SelectedMods = { BindTarget = SelectedMods },
|
||||
Width = 0.3f,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
ModSettingsContainer = new ModSettingsContainer
|
||||
{
|
||||
Alpha = 0,
|
||||
SelectedMods = { BindTarget = SelectedMods },
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
|
@ -44,6 +44,9 @@ namespace osu.Game.Overlays.Volume
|
||||
|
||||
protected override bool OnScroll(ScrollEvent e)
|
||||
{
|
||||
if (e.ScrollDelta.Y == 0)
|
||||
return false;
|
||||
|
||||
// forward any unhandled mouse scroll events to the volume control.
|
||||
ScrollActionRequested?.Invoke(GlobalAction.IncreaseVolume, e.ScrollDelta.Y, e.IsPrecise);
|
||||
return true;
|
||||
|
@ -245,6 +245,9 @@ namespace osu.Game.Overlays.Volume
|
||||
|
||||
private void adjust(double delta, bool isPrecise)
|
||||
{
|
||||
if (delta == 0)
|
||||
return;
|
||||
|
||||
// every adjust increment increases the rate at which adjustments happen up to a cutoff.
|
||||
// this debounce will reset on inactivity.
|
||||
accelerationDebounce?.Cancel();
|
||||
|
@ -16,9 +16,18 @@ namespace osu.Game.Rulesets.Edit
|
||||
{
|
||||
private readonly List<ICheck> checks = new List<ICheck>
|
||||
{
|
||||
new CheckBackground(),
|
||||
// Resources
|
||||
new CheckBackgroundPresence(),
|
||||
new CheckBackgroundQuality(),
|
||||
|
||||
// Audio
|
||||
new CheckAudioPresence(),
|
||||
new CheckAudioQuality()
|
||||
};
|
||||
|
||||
public IEnumerable<Issue> Run(IBeatmap beatmap) => checks.SelectMany(check => check.Run(beatmap));
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, WorkingBeatmap workingBeatmap)
|
||||
{
|
||||
return checks.SelectMany(check => check.Run(playableBeatmap, workingBeatmap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
15
osu.Game/Rulesets/Edit/Checks/CheckAudioPresence.cs
Normal file
15
osu.Game/Rulesets/Edit/Checks/CheckAudioPresence.cs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Checks
|
||||
{
|
||||
public class CheckAudioPresence : CheckFilePresence
|
||||
{
|
||||
protected override CheckCategory Category => CheckCategory.Audio;
|
||||
protected override string TypeOfFile => "audio";
|
||||
protected override string GetFilename(IBeatmap playableBeatmap) => playableBeatmap.Metadata?.AudioFile;
|
||||
}
|
||||
}
|
75
osu.Game/Rulesets/Edit/Checks/CheckAudioQuality.cs
Normal file
75
osu.Game/Rulesets/Edit/Checks/CheckAudioQuality.cs
Normal file
@ -0,0 +1,75 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Checks
|
||||
{
|
||||
public class CheckAudioQuality : ICheck
|
||||
{
|
||||
// This is a requirement as stated in the Ranking Criteria.
|
||||
// See https://osu.ppy.sh/wiki/en/Ranking_Criteria#rules.4
|
||||
private const int max_bitrate = 192;
|
||||
|
||||
// "A song's audio file /.../ must be of reasonable quality. Try to find the highest quality source file available"
|
||||
// There not existing a version with a bitrate of 128 kbps or higher is extremely rare.
|
||||
private const int min_bitrate = 128;
|
||||
|
||||
public CheckMetadata Metadata { get; } = new CheckMetadata(CheckCategory.Audio, "Too high or low audio bitrate");
|
||||
|
||||
public IEnumerable<IssueTemplate> PossibleTemplates => new IssueTemplate[]
|
||||
{
|
||||
new IssueTemplateTooHighBitrate(this),
|
||||
new IssueTemplateTooLowBitrate(this),
|
||||
new IssueTemplateNoBitrate(this)
|
||||
};
|
||||
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, IWorkingBeatmap workingBeatmap)
|
||||
{
|
||||
var audioFile = playableBeatmap.Metadata?.AudioFile;
|
||||
if (audioFile == null)
|
||||
yield break;
|
||||
|
||||
var track = workingBeatmap.Track;
|
||||
|
||||
if (track?.Bitrate == null || track.Bitrate.Value == 0)
|
||||
yield return new IssueTemplateNoBitrate(this).Create();
|
||||
else if (track.Bitrate.Value > max_bitrate)
|
||||
yield return new IssueTemplateTooHighBitrate(this).Create(track.Bitrate.Value);
|
||||
else if (track.Bitrate.Value < min_bitrate)
|
||||
yield return new IssueTemplateTooLowBitrate(this).Create(track.Bitrate.Value);
|
||||
}
|
||||
|
||||
public class IssueTemplateTooHighBitrate : IssueTemplate
|
||||
{
|
||||
public IssueTemplateTooHighBitrate(ICheck check)
|
||||
: base(check, IssueType.Problem, "The audio bitrate ({0} kbps) exceeds {1} kbps.")
|
||||
{
|
||||
}
|
||||
|
||||
public Issue Create(int bitrate) => new Issue(this, bitrate, max_bitrate);
|
||||
}
|
||||
|
||||
public class IssueTemplateTooLowBitrate : IssueTemplate
|
||||
{
|
||||
public IssueTemplateTooLowBitrate(ICheck check)
|
||||
: base(check, IssueType.Problem, "The audio bitrate ({0} kbps) is lower than {1} kbps.")
|
||||
{
|
||||
}
|
||||
|
||||
public Issue Create(int bitrate) => new Issue(this, bitrate, min_bitrate);
|
||||
}
|
||||
|
||||
public class IssueTemplateNoBitrate : IssueTemplate
|
||||
{
|
||||
public IssueTemplateNoBitrate(ICheck check)
|
||||
: base(check, IssueType.Error, "The audio bitrate could not be retrieved.")
|
||||
{
|
||||
}
|
||||
|
||||
public Issue Create() => new Issue(this);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Checks
|
||||
{
|
||||
public class CheckBackground : ICheck
|
||||
{
|
||||
public CheckMetadata Metadata { get; } = new CheckMetadata(CheckCategory.Resources, "Missing background");
|
||||
|
||||
public IEnumerable<IssueTemplate> PossibleTemplates => new IssueTemplate[]
|
||||
{
|
||||
new IssueTemplateNoneSet(this),
|
||||
new IssueTemplateDoesNotExist(this)
|
||||
};
|
||||
|
||||
public IEnumerable<Issue> Run(IBeatmap beatmap)
|
||||
{
|
||||
if (beatmap.Metadata.BackgroundFile == null)
|
||||
{
|
||||
yield return new IssueTemplateNoneSet(this).Create();
|
||||
|
||||
yield break;
|
||||
}
|
||||
|
||||
// If the background is set, also make sure it still exists.
|
||||
|
||||
var set = beatmap.BeatmapInfo.BeatmapSet;
|
||||
var file = set.Files.FirstOrDefault(f => f.Filename == beatmap.Metadata.BackgroundFile);
|
||||
|
||||
if (file != null)
|
||||
yield break;
|
||||
|
||||
yield return new IssueTemplateDoesNotExist(this).Create(beatmap.Metadata.BackgroundFile);
|
||||
}
|
||||
|
||||
public class IssueTemplateNoneSet : IssueTemplate
|
||||
{
|
||||
public IssueTemplateNoneSet(ICheck check)
|
||||
: base(check, IssueType.Problem, "No background has been set.")
|
||||
{
|
||||
}
|
||||
|
||||
public Issue Create() => new Issue(this);
|
||||
}
|
||||
|
||||
public class IssueTemplateDoesNotExist : IssueTemplate
|
||||
{
|
||||
public IssueTemplateDoesNotExist(ICheck check)
|
||||
: base(check, IssueType.Problem, "The background file \"{0}\" does not exist.")
|
||||
{
|
||||
}
|
||||
|
||||
public Issue Create(string filename) => new Issue(this, filename);
|
||||
}
|
||||
}
|
||||
}
|
15
osu.Game/Rulesets/Edit/Checks/CheckBackgroundPresence.cs
Normal file
15
osu.Game/Rulesets/Edit/Checks/CheckBackgroundPresence.cs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Checks
|
||||
{
|
||||
public class CheckBackgroundPresence : CheckFilePresence
|
||||
{
|
||||
protected override CheckCategory Category => CheckCategory.Resources;
|
||||
protected override string TypeOfFile => "background";
|
||||
protected override string GetFilename(IBeatmap playableBeatmap) => playableBeatmap.Metadata?.BackgroundFile;
|
||||
}
|
||||
}
|
98
osu.Game/Rulesets/Edit/Checks/CheckBackgroundQuality.cs
Normal file
98
osu.Game/Rulesets/Edit/Checks/CheckBackgroundQuality.cs
Normal file
@ -0,0 +1,98 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Checks
|
||||
{
|
||||
public class CheckBackgroundQuality : ICheck
|
||||
{
|
||||
// These are the requirements as stated in the Ranking Criteria.
|
||||
// See https://osu.ppy.sh/wiki/en/Ranking_Criteria#rules.5
|
||||
private const int min_width = 160;
|
||||
private const int max_width = 2560;
|
||||
private const int min_height = 120;
|
||||
private const int max_height = 1440;
|
||||
private const double max_filesize_mb = 2.5d;
|
||||
|
||||
// It's usually possible to find a higher resolution of the same image if lower than these.
|
||||
private const int low_width = 960;
|
||||
private const int low_height = 540;
|
||||
|
||||
public CheckMetadata Metadata { get; } = new CheckMetadata(CheckCategory.Resources, "Too high or low background resolution");
|
||||
|
||||
public IEnumerable<IssueTemplate> PossibleTemplates => new IssueTemplate[]
|
||||
{
|
||||
new IssueTemplateTooHighResolution(this),
|
||||
new IssueTemplateTooLowResolution(this),
|
||||
new IssueTemplateTooUncompressed(this)
|
||||
};
|
||||
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, IWorkingBeatmap workingBeatmap)
|
||||
{
|
||||
var backgroundFile = playableBeatmap.Metadata?.BackgroundFile;
|
||||
if (backgroundFile == null)
|
||||
yield break;
|
||||
|
||||
var texture = workingBeatmap.Background;
|
||||
if (texture == null)
|
||||
yield break;
|
||||
|
||||
if (texture.Width > max_width || texture.Height > max_height)
|
||||
yield return new IssueTemplateTooHighResolution(this).Create(texture.Width, texture.Height);
|
||||
|
||||
if (texture.Width < min_width || texture.Height < min_height)
|
||||
yield return new IssueTemplateTooLowResolution(this).Create(texture.Width, texture.Height);
|
||||
else if (texture.Width < low_width || texture.Height < low_height)
|
||||
yield return new IssueTemplateLowResolution(this).Create(texture.Width, texture.Height);
|
||||
|
||||
string storagePath = playableBeatmap.BeatmapInfo.BeatmapSet.GetPathForFile(backgroundFile);
|
||||
double filesizeMb = workingBeatmap.GetStream(storagePath).Length / (1024d * 1024d);
|
||||
|
||||
if (filesizeMb > max_filesize_mb)
|
||||
yield return new IssueTemplateTooUncompressed(this).Create(filesizeMb);
|
||||
}
|
||||
|
||||
public class IssueTemplateTooHighResolution : IssueTemplate
|
||||
{
|
||||
public IssueTemplateTooHighResolution(ICheck check)
|
||||
: base(check, IssueType.Problem, "The background resolution ({0} x {1}) exceeds {2} x {3}.")
|
||||
{
|
||||
}
|
||||
|
||||
public Issue Create(double width, double height) => new Issue(this, width, height, max_width, max_height);
|
||||
}
|
||||
|
||||
public class IssueTemplateTooLowResolution : IssueTemplate
|
||||
{
|
||||
public IssueTemplateTooLowResolution(ICheck check)
|
||||
: base(check, IssueType.Problem, "The background resolution ({0} x {1}) is lower than {2} x {3}.")
|
||||
{
|
||||
}
|
||||
|
||||
public Issue Create(double width, double height) => new Issue(this, width, height, min_width, min_height);
|
||||
}
|
||||
|
||||
public class IssueTemplateLowResolution : IssueTemplate
|
||||
{
|
||||
public IssueTemplateLowResolution(ICheck check)
|
||||
: base(check, IssueType.Warning, "The background resolution ({0} x {1}) is lower than {2} x {3}.")
|
||||
{
|
||||
}
|
||||
|
||||
public Issue Create(double width, double height) => new Issue(this, width, height, low_width, low_height);
|
||||
}
|
||||
|
||||
public class IssueTemplateTooUncompressed : IssueTemplate
|
||||
{
|
||||
public IssueTemplateTooUncompressed(ICheck check)
|
||||
: base(check, IssueType.Problem, "The background filesize ({0:0.##} MB) exceeds {1} MB.")
|
||||
{
|
||||
}
|
||||
|
||||
public Issue Create(double actualMb) => new Issue(this, actualMb, max_filesize_mb);
|
||||
}
|
||||
}
|
||||
}
|
63
osu.Game/Rulesets/Edit/Checks/CheckFilePresence.cs
Normal file
63
osu.Game/Rulesets/Edit/Checks/CheckFilePresence.cs
Normal file
@ -0,0 +1,63 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Checks
|
||||
{
|
||||
public abstract class CheckFilePresence : ICheck
|
||||
{
|
||||
protected abstract CheckCategory Category { get; }
|
||||
protected abstract string TypeOfFile { get; }
|
||||
protected abstract string GetFilename(IBeatmap playableBeatmap);
|
||||
|
||||
public CheckMetadata Metadata => new CheckMetadata(Category, $"Missing {TypeOfFile}");
|
||||
|
||||
public IEnumerable<IssueTemplate> PossibleTemplates => new IssueTemplate[]
|
||||
{
|
||||
new IssueTemplateNoneSet(this),
|
||||
new IssueTemplateDoesNotExist(this)
|
||||
};
|
||||
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, IWorkingBeatmap workingBeatmap)
|
||||
{
|
||||
var filename = GetFilename(playableBeatmap);
|
||||
|
||||
if (filename == null)
|
||||
{
|
||||
yield return new IssueTemplateNoneSet(this).Create(TypeOfFile);
|
||||
|
||||
yield break;
|
||||
}
|
||||
|
||||
// If the file is set, also make sure it still exists.
|
||||
var storagePath = playableBeatmap.BeatmapInfo.BeatmapSet.GetPathForFile(filename);
|
||||
if (storagePath != null)
|
||||
yield break;
|
||||
|
||||
yield return new IssueTemplateDoesNotExist(this).Create(TypeOfFile, filename);
|
||||
}
|
||||
|
||||
public class IssueTemplateNoneSet : IssueTemplate
|
||||
{
|
||||
public IssueTemplateNoneSet(ICheck check)
|
||||
: base(check, IssueType.Problem, "No {0} has been set.")
|
||||
{
|
||||
}
|
||||
|
||||
public Issue Create(string typeOfFile) => new Issue(this, typeOfFile);
|
||||
}
|
||||
|
||||
public class IssueTemplateDoesNotExist : IssueTemplate
|
||||
{
|
||||
public IssueTemplateDoesNotExist(ICheck check)
|
||||
: base(check, IssueType.Problem, "The {0} file \"{1}\" does not exist.")
|
||||
{
|
||||
}
|
||||
|
||||
public Issue Create(string typeOfFile, string filename) => new Issue(this, typeOfFile, filename);
|
||||
}
|
||||
}
|
||||
}
|
@ -24,7 +24,8 @@ namespace osu.Game.Rulesets.Edit.Checks.Components
|
||||
/// <summary>
|
||||
/// Runs this check and returns any issues detected for the provided beatmap.
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The beatmap to run the check on.</param>
|
||||
public IEnumerable<Issue> Run(IBeatmap beatmap);
|
||||
/// <param name="playableBeatmap">The playable beatmap of the beatmap to run the check on.</param>
|
||||
/// <param name="workingBeatmap">The working beatmap of the beatmap to run the check on.</param>
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, IWorkingBeatmap workingBeatmap);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// </summary>
|
||||
public interface IBeatmapVerifier
|
||||
{
|
||||
public IEnumerable<Issue> Run(IBeatmap beatmap);
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, WorkingBeatmap workingBeatmap);
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,12 @@ namespace osu.Game.Rulesets.UI
|
||||
spectatorStreaming?.EndPlaying();
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
recordFrame(false);
|
||||
}
|
||||
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
{
|
||||
recordFrame(false);
|
||||
|
@ -33,10 +33,14 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// </summary>
|
||||
public class SelectionHandler : CompositeDrawable, IKeyBindingHandler<PlatformAction>, IHasContextMenu
|
||||
{
|
||||
/// <summary>
|
||||
/// The currently selected blueprints.
|
||||
/// Should be used when operations are dealing directly with the visible blueprints.
|
||||
/// For more general selection operations, use <see cref="osu.Game.Screens.Edit.EditorBeatmap.SelectedHitObjects"/> instead.
|
||||
/// </summary>
|
||||
public IEnumerable<SelectionBlueprint> SelectedBlueprints => selectedBlueprints;
|
||||
private readonly List<SelectionBlueprint> selectedBlueprints;
|
||||
|
||||
public int SelectedCount => selectedBlueprints.Count;
|
||||
private readonly List<SelectionBlueprint> selectedBlueprints;
|
||||
|
||||
private Drawable content;
|
||||
|
||||
@ -295,7 +299,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// </summary>
|
||||
private void updateVisibility()
|
||||
{
|
||||
int count = selectedBlueprints.Count;
|
||||
int count = EditorBeatmap.SelectedHitObjects.Count;
|
||||
|
||||
selectionDetailsText.Text = count > 0 ? count.ToString() : string.Empty;
|
||||
|
||||
|
@ -158,10 +158,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
circle.Colour = comboColour;
|
||||
|
||||
var col = circle.Colour.TopLeft.Linear;
|
||||
float brightness = col.R + col.G + col.B;
|
||||
|
||||
// decide the combo index colour based on brightness?
|
||||
colouredComponents.Colour = OsuColour.Gray(brightness > 0.5f ? 0.2f : 0.9f);
|
||||
colouredComponents.Colour = OsuColour.ForegroundTextColourFor(col);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
|
@ -46,6 +46,7 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
public readonly IBeatmap PlayableBeatmap;
|
||||
|
||||
[CanBeNull]
|
||||
public readonly ISkin BeatmapSkin;
|
||||
|
||||
[Resolved]
|
||||
|
@ -9,6 +9,7 @@ using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Edit
|
||||
@ -19,7 +20,7 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
protected const float ROW_HEIGHT = 25;
|
||||
|
||||
protected const int TEXT_SIZE = 14;
|
||||
public const int TEXT_SIZE = 14;
|
||||
|
||||
protected readonly FillFlowContainer<RowBackground> BackgroundFlow;
|
||||
|
||||
@ -93,10 +94,10 @@ namespace osu.Game.Screens.Edit
|
||||
private Color4 colourSelected;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private void load(OverlayColourProvider colours)
|
||||
{
|
||||
hoveredBackground.Colour = colourHover = colours.BlueDarker;
|
||||
colourSelected = colours.YellowDarker;
|
||||
hoveredBackground.Colour = colourHover = colours.Background1;
|
||||
colourSelected = colours.Colour3;
|
||||
}
|
||||
|
||||
private bool selected;
|
||||
|
@ -116,6 +116,8 @@ namespace osu.Game.Screens.Edit
|
||||
protected override Texture GetBackground() => throw new NotImplementedException();
|
||||
|
||||
protected override Track GetBeatmapTrack() => throw new NotImplementedException();
|
||||
|
||||
public override Stream GetStream(string storagePath) => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
61
osu.Game/Screens/Edit/RoundedContentEditorScreen.cs
Normal file
61
osu.Game/Screens/Edit/RoundedContentEditorScreen.cs
Normal file
@ -0,0 +1,61 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Screens.Edit
|
||||
{
|
||||
public class RoundedContentEditorScreen : EditorScreen
|
||||
{
|
||||
public const int HORIZONTAL_PADDING = 100;
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
[Cached]
|
||||
protected readonly OverlayColourProvider ColourProvider;
|
||||
|
||||
private Container roundedContent;
|
||||
|
||||
protected override Container<Drawable> Content => roundedContent;
|
||||
|
||||
public RoundedContentEditorScreen(EditorScreenMode mode)
|
||||
: base(mode)
|
||||
{
|
||||
ColourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
base.Content.Add(new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding(50),
|
||||
Child = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
CornerRadius = 10,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = ColourProvider.Dark4,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
roundedContent = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
37
osu.Game/Screens/Edit/Setup/ColoursSection.cs
Normal file
37
osu.Game/Screens/Edit/Setup/ColoursSection.cs
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Setup
|
||||
{
|
||||
internal class ColoursSection : SetupSection
|
||||
{
|
||||
public override LocalisableString Title => "Colours";
|
||||
|
||||
private LabelledColourPalette comboColours;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
comboColours = new LabelledColourPalette
|
||||
{
|
||||
Label = "Hitcircle / Slider Combos",
|
||||
ColourNamePrefix = "Combo"
|
||||
}
|
||||
};
|
||||
|
||||
var colours = Beatmap.BeatmapSkin?.GetConfig<GlobalSkinColours, IReadOnlyList<Color4>>(GlobalSkinColours.ComboColours)?.Value;
|
||||
if (colours != null)
|
||||
comboColours.Colours.AddRange(colours);
|
||||
}
|
||||
}
|
||||
}
|
@ -3,24 +3,12 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Setup
|
||||
{
|
||||
public class SetupScreen : EditorScreen
|
||||
public class SetupScreen : RoundedContentEditorScreen
|
||||
{
|
||||
public const int HORIZONTAL_PADDING = 100;
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
[Cached]
|
||||
protected readonly OverlayColourProvider ColourProvider;
|
||||
|
||||
[Cached]
|
||||
private SectionsContainer<SetupSection> sections = new SectionsContainer<SetupSection>();
|
||||
|
||||
@ -30,42 +18,26 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
public SetupScreen()
|
||||
: base(EditorScreenMode.SongSetup)
|
||||
{
|
||||
ColourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Child = new Container
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding(50),
|
||||
Child = new Container
|
||||
sections = new SectionsContainer<SetupSection>
|
||||
{
|
||||
FixedHeader = header,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
CornerRadius = 10,
|
||||
Children = new Drawable[]
|
||||
Children = new SetupSection[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = ColourProvider.Dark4,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
sections = new SectionsContainer<SetupSection>
|
||||
{
|
||||
FixedHeader = header,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new SetupSection[]
|
||||
{
|
||||
new ResourcesSection(),
|
||||
new MetadataSection(),
|
||||
new DifficultySection(),
|
||||
}
|
||||
},
|
||||
new ResourcesSection(),
|
||||
new MetadataSection(),
|
||||
new DifficultySection(),
|
||||
new ColoursSection()
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
|
||||
public SetupScreenTabControl()
|
||||
{
|
||||
TabContainer.Margin = new MarginPadding { Horizontal = SetupScreen.HORIZONTAL_PADDING };
|
||||
TabContainer.Margin = new MarginPadding { Horizontal = RoundedContentEditorScreen.HORIZONTAL_PADDING };
|
||||
|
||||
AddInternal(background = new Box
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Vertical = 10,
|
||||
Horizontal = SetupScreen.HORIZONTAL_PADDING
|
||||
Horizontal = RoundedContentEditorScreen.HORIZONTAL_PADDING
|
||||
};
|
||||
|
||||
InternalChild = new FillFlowContainer
|
||||
|
@ -6,15 +6,15 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Timing
|
||||
{
|
||||
public class ControlPointSettings : CompositeDrawable
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private void load(OverlayColourProvider colours)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
@ -22,7 +22,7 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = colours.Gray3,
|
||||
Colour = colours.Background4,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new OsuScrollContainer
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
@ -12,8 +13,8 @@ using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Screens.Edit.Timing.RowAttributes;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Timing
|
||||
{
|
||||
@ -25,6 +26,8 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
[Resolved]
|
||||
private EditorClock clock { get; set; }
|
||||
|
||||
public const float TIMING_COLUMN_WIDTH = 220;
|
||||
|
||||
public IEnumerable<ControlPointGroup> ControlGroups
|
||||
{
|
||||
set
|
||||
@ -66,44 +69,62 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
{
|
||||
var columns = new List<TableColumn>
|
||||
{
|
||||
new TableColumn(string.Empty, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
||||
new TableColumn("Time", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
||||
new TableColumn(),
|
||||
new TableColumn("Time", Anchor.CentreLeft, new Dimension(GridSizeMode.Absolute, TIMING_COLUMN_WIDTH)),
|
||||
new TableColumn("Attributes", Anchor.CentreLeft),
|
||||
};
|
||||
|
||||
return columns.ToArray();
|
||||
}
|
||||
|
||||
private Drawable[] createContent(int index, ControlPointGroup group) => new Drawable[]
|
||||
private Drawable[] createContent(int index, ControlPointGroup group)
|
||||
{
|
||||
new OsuSpriteText
|
||||
return new Drawable[]
|
||||
{
|
||||
Text = $"#{index + 1}",
|
||||
Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold),
|
||||
Margin = new MarginPadding(10)
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = group.Time.ToEditorFormattedString(),
|
||||
Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold)
|
||||
},
|
||||
null,
|
||||
new ControlGroupAttributes(group),
|
||||
};
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = TIMING_COLUMN_WIDTH,
|
||||
Spacing = new Vector2(5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = group.Time.ToEditorFormattedString(),
|
||||
Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold),
|
||||
Width = 60,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
},
|
||||
new ControlGroupAttributes(group, c => c is TimingControlPoint)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
}
|
||||
}
|
||||
},
|
||||
new ControlGroupAttributes(group, c => !(c is TimingControlPoint))
|
||||
};
|
||||
}
|
||||
|
||||
private class ControlGroupAttributes : CompositeDrawable
|
||||
{
|
||||
private readonly Func<ControlPoint, bool> matchFunction;
|
||||
|
||||
private readonly IBindableList<ControlPoint> controlPoints = new BindableList<ControlPoint>();
|
||||
|
||||
private readonly FillFlowContainer fill;
|
||||
|
||||
public ControlGroupAttributes(ControlPointGroup group)
|
||||
public ControlGroupAttributes(ControlPointGroup group, Func<ControlPoint, bool> matchFunction)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
this.matchFunction = matchFunction;
|
||||
|
||||
AutoSizeAxes = Axes.X;
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
|
||||
InternalChild = fill = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
AutoSizeAxes = Axes.X,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(2)
|
||||
};
|
||||
@ -128,30 +149,30 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
|
||||
private void createChildren()
|
||||
{
|
||||
fill.ChildrenEnumerable = controlPoints.Select(createAttribute).Where(c => c != null);
|
||||
fill.ChildrenEnumerable = controlPoints
|
||||
.Where(matchFunction)
|
||||
.Select(createAttribute)
|
||||
.Where(c => c != null)
|
||||
// arbitrary ordering to make timing points first.
|
||||
// probably want to explicitly define order in the future.
|
||||
.OrderByDescending(c => c.GetType().Name);
|
||||
}
|
||||
|
||||
private Drawable createAttribute(ControlPoint controlPoint)
|
||||
{
|
||||
Color4 colour = controlPoint.GetRepresentingColour(colours);
|
||||
|
||||
switch (controlPoint)
|
||||
{
|
||||
case TimingControlPoint timing:
|
||||
return new RowAttribute("timing", () => $"{60000 / timing.BeatLength:n1}bpm {timing.TimeSignature}", colour);
|
||||
return new TimingRowAttribute(timing);
|
||||
|
||||
case DifficultyControlPoint difficulty:
|
||||
|
||||
return new RowAttribute("difficulty", () => $"{difficulty.SpeedMultiplier:n2}x", colour);
|
||||
return new DifficultyRowAttribute(difficulty);
|
||||
|
||||
case EffectControlPoint effect:
|
||||
return new RowAttribute("effect", () => string.Join(" ",
|
||||
effect.KiaiMode ? "Kiai" : string.Empty,
|
||||
effect.OmitFirstBarLine ? "NoBarLine" : string.Empty
|
||||
).Trim(), colour);
|
||||
return new EffectRowAttribute(effect);
|
||||
|
||||
case SampleControlPoint sample:
|
||||
return new RowAttribute("sample", () => $"{sample.SampleBank} {sample.SampleVolume}%", colour);
|
||||
return new SampleRowAttribute(sample);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -1,33 +1,35 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK.Graphics;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Timing
|
||||
{
|
||||
public class RowAttribute : CompositeDrawable, IHasTooltip
|
||||
public class RowAttribute : CompositeDrawable
|
||||
{
|
||||
private readonly string header;
|
||||
private readonly Func<string> content;
|
||||
private readonly Color4 colour;
|
||||
protected readonly ControlPoint Point;
|
||||
|
||||
public RowAttribute(string header, Func<string> content, Color4 colour)
|
||||
private readonly string label;
|
||||
|
||||
protected FillFlowContainer Content { get; private set; }
|
||||
|
||||
public RowAttribute(ControlPoint point, string label)
|
||||
{
|
||||
this.header = header;
|
||||
this.content = content;
|
||||
this.colour = colour;
|
||||
Point = point;
|
||||
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private void load(OsuColour colours, OverlayColourProvider overlayColours)
|
||||
{
|
||||
AutoSizeAxes = Axes.X;
|
||||
|
||||
@ -37,27 +39,43 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
Origin = Anchor.CentreLeft;
|
||||
|
||||
Masking = true;
|
||||
CornerRadius = 5;
|
||||
CornerRadius = 3;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = colour,
|
||||
Colour = overlayColours.Background4,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new OsuSpriteText
|
||||
Content = new FillFlowContainer
|
||||
{
|
||||
Padding = new MarginPadding(2),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = OsuFont.Default.With(weight: FontWeight.SemiBold, size: 12),
|
||||
Text = header,
|
||||
Colour = colours.Gray0
|
||||
},
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
AutoSizeAxes = Axes.X,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Margin = new MarginPadding { Horizontal = 5 },
|
||||
Spacing = new Vector2(5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Circle
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Colour = Point.GetRepresentingColour(colours),
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Size = new Vector2(4, 0.6f),
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Padding = new MarginPadding(3),
|
||||
Font = OsuFont.Default.With(weight: FontWeight.Bold, size: 12),
|
||||
Text = label,
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public string TooltipText => content();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Timing.RowAttributes
|
||||
{
|
||||
public class AttributeProgressBar : ProgressBar
|
||||
{
|
||||
private readonly ControlPoint controlPoint;
|
||||
|
||||
public AttributeProgressBar(ControlPoint controlPoint)
|
||||
: base(false)
|
||||
{
|
||||
this.controlPoint = controlPoint;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, OverlayColourProvider overlayColours)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft;
|
||||
Origin = Anchor.CentreLeft;
|
||||
|
||||
Masking = true;
|
||||
|
||||
RelativeSizeAxes = Axes.None;
|
||||
|
||||
Size = new Vector2(80, 8);
|
||||
CornerRadius = Height / 2;
|
||||
|
||||
BackgroundColour = overlayColours.Background6;
|
||||
FillColour = controlPoint.GetRepresentingColour(colours);
|
||||
}
|
||||
}
|
||||
}
|
32
osu.Game/Screens/Edit/Timing/RowAttributes/AttributeText.cs
Normal file
32
osu.Game/Screens/Edit/Timing/RowAttributes/AttributeText.cs
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Timing.RowAttributes
|
||||
{
|
||||
public class AttributeText : OsuSpriteText
|
||||
{
|
||||
private readonly ControlPoint controlPoint;
|
||||
|
||||
public AttributeText(ControlPoint controlPoint)
|
||||
{
|
||||
this.controlPoint = controlPoint;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft;
|
||||
Origin = Anchor.CentreLeft;
|
||||
|
||||
Padding = new MarginPadding(6);
|
||||
Font = OsuFont.Default.With(weight: FontWeight.Bold, size: 12);
|
||||
Colour = controlPoint.GetRepresentingColour(colours);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Timing.RowAttributes
|
||||
{
|
||||
public class DifficultyRowAttribute : RowAttribute
|
||||
{
|
||||
private readonly BindableNumber<double> speedMultiplier;
|
||||
|
||||
private OsuSpriteText text;
|
||||
|
||||
public DifficultyRowAttribute(DifficultyControlPoint difficulty)
|
||||
: base(difficulty, "difficulty")
|
||||
{
|
||||
speedMultiplier = difficulty.SpeedMultiplierBindable.GetBoundCopy();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Content.AddRange(new Drawable[]
|
||||
{
|
||||
new AttributeProgressBar(Point)
|
||||
{
|
||||
Current = speedMultiplier,
|
||||
},
|
||||
text = new AttributeText(Point)
|
||||
{
|
||||
Width = 40,
|
||||
},
|
||||
});
|
||||
|
||||
speedMultiplier.BindValueChanged(_ => updateText(), true);
|
||||
}
|
||||
|
||||
private void updateText() => text.Text = $"{speedMultiplier.Value:n2}x";
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Timing.RowAttributes
|
||||
{
|
||||
public class EffectRowAttribute : RowAttribute
|
||||
{
|
||||
private readonly Bindable<bool> kiaiMode;
|
||||
private readonly Bindable<bool> omitBarLine;
|
||||
private AttributeText kiaiModeBubble;
|
||||
private AttributeText omitBarLineBubble;
|
||||
|
||||
public EffectRowAttribute(EffectControlPoint effect)
|
||||
: base(effect, "effect")
|
||||
{
|
||||
kiaiMode = effect.KiaiModeBindable.GetBoundCopy();
|
||||
omitBarLine = effect.OmitFirstBarLineBindable.GetBoundCopy();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Content.AddRange(new Drawable[]
|
||||
{
|
||||
kiaiModeBubble = new AttributeText(Point) { Text = "kiai" },
|
||||
omitBarLineBubble = new AttributeText(Point) { Text = "no barline" },
|
||||
});
|
||||
|
||||
kiaiMode.BindValueChanged(enabled => kiaiModeBubble.FadeTo(enabled.NewValue ? 1 : 0), true);
|
||||
omitBarLine.BindValueChanged(enabled => omitBarLineBubble.FadeTo(enabled.NewValue ? 1 : 0), true);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Timing.RowAttributes
|
||||
{
|
||||
public class SampleRowAttribute : RowAttribute
|
||||
{
|
||||
private AttributeText sampleText;
|
||||
private OsuSpriteText volumeText;
|
||||
|
||||
private readonly Bindable<string> sampleBank;
|
||||
private readonly BindableNumber<int> volume;
|
||||
|
||||
public SampleRowAttribute(SampleControlPoint sample)
|
||||
: base(sample, "sample")
|
||||
{
|
||||
sampleBank = sample.SampleBankBindable.GetBoundCopy();
|
||||
volume = sample.SampleVolumeBindable.GetBoundCopy();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
AttributeProgressBar progress;
|
||||
|
||||
Content.AddRange(new Drawable[]
|
||||
{
|
||||
sampleText = new AttributeText(Point),
|
||||
progress = new AttributeProgressBar(Point),
|
||||
volumeText = new AttributeText(Point)
|
||||
{
|
||||
Width = 40,
|
||||
},
|
||||
});
|
||||
|
||||
volume.BindValueChanged(vol =>
|
||||
{
|
||||
progress.Current.Value = vol.NewValue / 100f;
|
||||
updateText();
|
||||
}, true);
|
||||
|
||||
sampleBank.BindValueChanged(_ => updateText(), true);
|
||||
}
|
||||
|
||||
private void updateText()
|
||||
{
|
||||
volumeText.Text = $"{volume.Value}%";
|
||||
sampleText.Text = $"{sampleBank.Value}";
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Timing.RowAttributes
|
||||
{
|
||||
public class TimingRowAttribute : RowAttribute
|
||||
{
|
||||
private readonly BindableNumber<double> beatLength;
|
||||
private readonly Bindable<TimeSignatures> timeSignature;
|
||||
private OsuSpriteText text;
|
||||
|
||||
public TimingRowAttribute(TimingControlPoint timing)
|
||||
: base(timing, "timing")
|
||||
{
|
||||
timeSignature = timing.TimeSignatureBindable.GetBoundCopy();
|
||||
beatLength = timing.BeatLengthBindable.GetBoundCopy();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Content.Add(text = new AttributeText(Point));
|
||||
|
||||
timeSignature.BindValueChanged(_ => updateText());
|
||||
beatLength.BindValueChanged(_ => updateText(), true);
|
||||
}
|
||||
|
||||
private void updateText() =>
|
||||
text.Text = $"{60000 / beatLength.Value:n1}bpm {timeSignature.Value.GetDescription()}";
|
||||
}
|
||||
}
|
@ -8,8 +8,9 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Timing
|
||||
{
|
||||
@ -23,7 +24,7 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
|
||||
protected Bindable<T> ControlPoint { get; } = new Bindable<T>();
|
||||
|
||||
private const float header_height = 20;
|
||||
private const float header_height = 50;
|
||||
|
||||
[Resolved]
|
||||
protected EditorBeatmap Beatmap { get; private set; }
|
||||
@ -35,7 +36,7 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
protected IEditorChangeHandler ChangeHandler { get; private set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private void load(OverlayColourProvider colours)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeDuration = 200;
|
||||
@ -46,19 +47,17 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = colours.Gray1,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = header_height,
|
||||
Padding = new MarginPadding { Horizontal = 10 },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
checkbox = new OsuCheckbox
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
LabelText = typeof(T).Name.Replace(nameof(Beatmaps.ControlPoints.ControlPoint), string.Empty)
|
||||
}
|
||||
}
|
||||
@ -72,12 +71,13 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = colours.Gray2,
|
||||
Colour = colours.Background3,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
Flow = new FillFlowContainer
|
||||
{
|
||||
Padding = new MarginPadding(10),
|
||||
Padding = new MarginPadding(20),
|
||||
Spacing = new Vector2(20),
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
|
@ -8,15 +8,14 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Timing
|
||||
{
|
||||
public class TimingScreen : EditorScreenWithTimeline
|
||||
public class TimingScreen : RoundedContentEditorScreen
|
||||
{
|
||||
[Cached]
|
||||
private Bindable<ControlPointGroup> selectedGroup = new Bindable<ControlPointGroup>();
|
||||
@ -26,28 +25,26 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
{
|
||||
}
|
||||
|
||||
protected override Drawable CreateMainContent() => new GridContainer
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ColumnDimensions = new[]
|
||||
Add(new GridContainer
|
||||
{
|
||||
new Dimension(),
|
||||
new Dimension(GridSizeMode.Absolute, 200),
|
||||
},
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ColumnDimensions = new[]
|
||||
{
|
||||
new ControlPointList(),
|
||||
new ControlPointSettings(),
|
||||
new Dimension(),
|
||||
new Dimension(GridSizeMode.Absolute, 350),
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
protected override void OnTimelineLoaded(TimelineArea timelineArea)
|
||||
{
|
||||
base.OnTimelineLoaded(timelineArea);
|
||||
timelineArea.Timeline.Zoom = timelineArea.Timeline.MinZoom;
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
new ControlPointList(),
|
||||
new ControlPointSettings(),
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public class ControlPointList : CompositeDrawable
|
||||
@ -70,17 +67,24 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
private IEditorChangeHandler changeHandler { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private void load(OverlayColourProvider colours)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
const float margins = 10;
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = colours.Gray0,
|
||||
Colour = colours.Background3,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new Box
|
||||
{
|
||||
Colour = colours.Background2,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = ControlPointTable.TIMING_COLUMN_WIDTH + margins,
|
||||
},
|
||||
new OsuScrollContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
@ -92,7 +96,7 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Margin = new MarginPadding(10),
|
||||
Margin = new MarginPadding(margins),
|
||||
Spacing = new Vector2(5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -106,9 +110,9 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
},
|
||||
new OsuButton
|
||||
{
|
||||
Text = "+",
|
||||
Text = "+ Add at current time",
|
||||
Action = addNew,
|
||||
Size = new Vector2(30, 30),
|
||||
Size = new Vector2(160, 30),
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
},
|
||||
|
@ -7,16 +7,17 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Verify
|
||||
{
|
||||
public class VerifyScreen : EditorScreen
|
||||
public class VerifyScreen : RoundedContentEditorScreen
|
||||
{
|
||||
[Cached]
|
||||
private Bindable<Issue> selectedIssue = new Bindable<Issue>();
|
||||
@ -32,7 +33,6 @@ namespace osu.Game.Screens.Edit.Verify
|
||||
Child = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding(20),
|
||||
Child = new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
@ -61,7 +61,10 @@ namespace osu.Game.Screens.Edit.Verify
|
||||
private EditorClock clock { get; set; }
|
||||
|
||||
[Resolved]
|
||||
protected EditorBeatmap Beatmap { get; private set; }
|
||||
private IBindable<WorkingBeatmap> workingBeatmap { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private EditorBeatmap beatmap { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private Bindable<Issue> selectedIssue { get; set; }
|
||||
@ -70,10 +73,10 @@ namespace osu.Game.Screens.Edit.Verify
|
||||
private BeatmapVerifier generalVerifier;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private void load(OverlayColourProvider colours)
|
||||
{
|
||||
generalVerifier = new BeatmapVerifier();
|
||||
rulesetVerifier = Beatmap.BeatmapInfo.Ruleset?.CreateInstance()?.CreateBeatmapVerifier();
|
||||
rulesetVerifier = beatmap.BeatmapInfo.Ruleset?.CreateInstance()?.CreateBeatmapVerifier();
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
@ -81,7 +84,7 @@ namespace osu.Game.Screens.Edit.Verify
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = colours.Gray0,
|
||||
Colour = colours.Background2,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new OsuScrollContainer
|
||||
@ -119,10 +122,10 @@ namespace osu.Game.Screens.Edit.Verify
|
||||
|
||||
private void refresh()
|
||||
{
|
||||
var issues = generalVerifier.Run(Beatmap);
|
||||
var issues = generalVerifier.Run(beatmap, workingBeatmap.Value);
|
||||
|
||||
if (rulesetVerifier != null)
|
||||
issues = issues.Concat(rulesetVerifier.Run(Beatmap));
|
||||
issues = issues.Concat(rulesetVerifier.Run(beatmap, workingBeatmap.Value));
|
||||
|
||||
table.Issues = issues
|
||||
.OrderBy(issue => issue.Template.Type)
|
||||
|
@ -30,17 +30,22 @@ namespace osu.Game.Screens.Play
|
||||
/// </summary>
|
||||
protected readonly DecoupleableInterpolatingFramedClock AdjustableSource;
|
||||
|
||||
/// <summary>
|
||||
/// The source clock.
|
||||
/// </summary>
|
||||
protected IClock SourceClock { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GameplayClockContainer"/>.
|
||||
/// </summary>
|
||||
/// <param name="sourceClock">The source <see cref="IClock"/> used for timing.</param>
|
||||
protected GameplayClockContainer(IClock sourceClock)
|
||||
{
|
||||
SourceClock = sourceClock;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
AdjustableSource = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
||||
AdjustableSource.ChangeSource(sourceClock);
|
||||
|
||||
IsPaused.BindValueChanged(OnIsPausedChanged);
|
||||
}
|
||||
|
||||
@ -59,6 +64,9 @@ namespace osu.Game.Screens.Play
|
||||
/// </summary>
|
||||
public virtual void Start()
|
||||
{
|
||||
// Ensure that the source clock is set.
|
||||
ChangeSource(SourceClock);
|
||||
|
||||
if (!AdjustableSource.IsRunning)
|
||||
{
|
||||
// Seeking the decoupled clock to its current time ensures that its source clock will be seeked to the same time
|
||||
@ -75,7 +83,13 @@ namespace osu.Game.Screens.Play
|
||||
/// Seek to a specific time in gameplay.
|
||||
/// </summary>
|
||||
/// <param name="time">The destination time to seek to.</param>
|
||||
public virtual void Seek(double time) => AdjustableSource.Seek(time);
|
||||
public virtual void Seek(double time)
|
||||
{
|
||||
AdjustableSource.Seek(time);
|
||||
|
||||
// Manually process to make sure the gameplay clock is correctly updated after a seek.
|
||||
GameplayClock.UnderlyingClock.ProcessFrame();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops gameplay.
|
||||
@ -83,17 +97,25 @@ namespace osu.Game.Screens.Play
|
||||
public virtual void Stop() => IsPaused.Value = true;
|
||||
|
||||
/// <summary>
|
||||
/// Restarts gameplay.
|
||||
/// Resets this <see cref="GameplayClockContainer"/> and the source to an initial state ready for gameplay.
|
||||
/// </summary>
|
||||
public virtual void Restart()
|
||||
public virtual void Reset()
|
||||
{
|
||||
AdjustableSource.Seek(0);
|
||||
Seek(0);
|
||||
|
||||
// Manually stop the source in order to not affect the IsPaused state.
|
||||
AdjustableSource.Stop();
|
||||
|
||||
if (!IsPaused.Value)
|
||||
Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the source clock.
|
||||
/// </summary>
|
||||
/// <param name="sourceClock">The new source.</param>
|
||||
protected void ChangeSource(IClock sourceClock) => AdjustableSource.ChangeSource(SourceClock = sourceClock);
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
if (!IsPaused.Value)
|
||||
|
@ -33,7 +33,7 @@ namespace osu.Game.Screens.Play
|
||||
/// </summary>
|
||||
public const double MINIMUM_SKIP_TIME = 1000;
|
||||
|
||||
protected Track Track => (Track)AdjustableSource.Source;
|
||||
protected Track Track => (Track)SourceClock;
|
||||
|
||||
public readonly BindableNumber<double> UserPlaybackRate = new BindableDouble(1)
|
||||
{
|
||||
@ -54,8 +54,9 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private FramedOffsetClock userOffsetClock;
|
||||
private FramedOffsetClock platformOffsetClock;
|
||||
private LocalGameplayClock localGameplayClock;
|
||||
private MasterGameplayClock masterGameplayClock;
|
||||
private Bindable<double> userAudioOffset;
|
||||
private double startOffset;
|
||||
|
||||
public MasterGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStartTime, bool startAtGameplayStart = false)
|
||||
: base(beatmap.Track)
|
||||
@ -74,27 +75,25 @@ namespace osu.Game.Screens.Play
|
||||
userAudioOffset.BindValueChanged(offset => userOffsetClock.Offset = offset.NewValue, true);
|
||||
|
||||
// sane default provided by ruleset.
|
||||
double startTime = gameplayStartTime;
|
||||
startOffset = gameplayStartTime;
|
||||
|
||||
if (!startAtGameplayStart)
|
||||
{
|
||||
startTime = Math.Min(0, startTime);
|
||||
startOffset = Math.Min(0, startOffset);
|
||||
|
||||
// if a storyboard is present, it may dictate the appropriate start time by having events in negative time space.
|
||||
// this is commonly used to display an intro before the audio track start.
|
||||
double? firstStoryboardEvent = beatmap.Storyboard.EarliestEventTime;
|
||||
if (firstStoryboardEvent != null)
|
||||
startTime = Math.Min(startTime, firstStoryboardEvent.Value);
|
||||
startOffset = Math.Min(startOffset, firstStoryboardEvent.Value);
|
||||
|
||||
// some beatmaps specify a current lead-in time which should be used instead of the ruleset-provided value when available.
|
||||
// this is not available as an option in the live editor but can still be applied via .osu editing.
|
||||
if (beatmap.BeatmapInfo.AudioLeadIn > 0)
|
||||
startTime = Math.Min(startTime, firstHitObjectTime - beatmap.BeatmapInfo.AudioLeadIn);
|
||||
startOffset = Math.Min(startOffset, firstHitObjectTime - beatmap.BeatmapInfo.AudioLeadIn);
|
||||
}
|
||||
|
||||
Seek(startTime);
|
||||
|
||||
AdjustableSource.ProcessFrame();
|
||||
Seek(startOffset);
|
||||
}
|
||||
|
||||
protected override void OnIsPausedChanged(ValueChangedEvent<bool> isPaused)
|
||||
@ -106,6 +105,12 @@ namespace osu.Game.Screens.Play
|
||||
this.TransformBindableTo(pauseFreqAdjust, 1, 200, Easing.In);
|
||||
}
|
||||
|
||||
public override void Start()
|
||||
{
|
||||
addSourceClockAdjustments();
|
||||
base.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Seek to a specific time in gameplay.
|
||||
/// </summary>
|
||||
@ -118,15 +123,6 @@ namespace osu.Game.Screens.Play
|
||||
// remove the offset component here because most of the time we want the seek to be aligned to gameplay, not the audio track.
|
||||
// we may want to consider reversing the application of offsets in the future as it may feel more correct.
|
||||
base.Seek(time - totalOffset);
|
||||
|
||||
// manually process frame to ensure GameplayClock is correctly updated after a seek.
|
||||
userOffsetClock.ProcessFrame();
|
||||
}
|
||||
|
||||
public override void Restart()
|
||||
{
|
||||
updateRate();
|
||||
base.Restart();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -146,6 +142,12 @@ namespace osu.Game.Screens.Play
|
||||
Seek(skipTarget);
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
Seek(startOffset);
|
||||
}
|
||||
|
||||
protected override GameplayClock CreateGameplayClock(IFrameBasedClock source)
|
||||
{
|
||||
// Lazer's audio timings in general doesn't match stable. This is the result of user testing, albeit limited.
|
||||
@ -155,7 +157,7 @@ namespace osu.Game.Screens.Play
|
||||
// the final usable gameplay clock with user-set offsets applied.
|
||||
userOffsetClock = new HardwareCorrectionOffsetClock(platformOffsetClock);
|
||||
|
||||
return localGameplayClock = new LocalGameplayClock(userOffsetClock);
|
||||
return masterGameplayClock = new MasterGameplayClock(userOffsetClock);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -164,12 +166,13 @@ namespace osu.Game.Screens.Play
|
||||
public void StopUsingBeatmapClock()
|
||||
{
|
||||
removeSourceClockAdjustments();
|
||||
AdjustableSource.ChangeSource(new TrackVirtual(beatmap.Track.Length));
|
||||
ChangeSource(new TrackVirtual(beatmap.Track.Length));
|
||||
addSourceClockAdjustments();
|
||||
}
|
||||
|
||||
private bool speedAdjustmentsApplied;
|
||||
|
||||
private void updateRate()
|
||||
private void addSourceClockAdjustments()
|
||||
{
|
||||
if (speedAdjustmentsApplied)
|
||||
return;
|
||||
@ -177,8 +180,8 @@ namespace osu.Game.Screens.Play
|
||||
Track.AddAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust);
|
||||
Track.AddAdjustment(AdjustableProperty.Tempo, UserPlaybackRate);
|
||||
|
||||
localGameplayClock.MutableNonGameplayAdjustments.Add(pauseFreqAdjust);
|
||||
localGameplayClock.MutableNonGameplayAdjustments.Add(UserPlaybackRate);
|
||||
masterGameplayClock.MutableNonGameplayAdjustments.Add(pauseFreqAdjust);
|
||||
masterGameplayClock.MutableNonGameplayAdjustments.Add(UserPlaybackRate);
|
||||
|
||||
speedAdjustmentsApplied = true;
|
||||
}
|
||||
@ -191,8 +194,8 @@ namespace osu.Game.Screens.Play
|
||||
Track.RemoveAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust);
|
||||
Track.RemoveAdjustment(AdjustableProperty.Tempo, UserPlaybackRate);
|
||||
|
||||
localGameplayClock.MutableNonGameplayAdjustments.Remove(pauseFreqAdjust);
|
||||
localGameplayClock.MutableNonGameplayAdjustments.Remove(UserPlaybackRate);
|
||||
masterGameplayClock.MutableNonGameplayAdjustments.Remove(pauseFreqAdjust);
|
||||
masterGameplayClock.MutableNonGameplayAdjustments.Remove(UserPlaybackRate);
|
||||
|
||||
speedAdjustmentsApplied = false;
|
||||
}
|
||||
@ -215,13 +218,13 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
}
|
||||
|
||||
private class LocalGameplayClock : GameplayClock
|
||||
private class MasterGameplayClock : GameplayClock
|
||||
{
|
||||
public readonly List<Bindable<double>> MutableNonGameplayAdjustments = new List<Bindable<double>>();
|
||||
|
||||
public override IEnumerable<Bindable<double>> NonGameplayAdjustments => MutableNonGameplayAdjustments;
|
||||
|
||||
public LocalGameplayClock(FramedOffsetClock underlyingClock)
|
||||
public MasterGameplayClock(FramedOffsetClock underlyingClock)
|
||||
: base(underlyingClock)
|
||||
{
|
||||
}
|
||||
|
@ -811,7 +811,7 @@ namespace osu.Game.Screens.Play
|
||||
if (GameplayClockContainer.GameplayClock.IsRunning)
|
||||
throw new InvalidOperationException($"{nameof(StartGameplay)} should not be called when the gameplay clock is already running");
|
||||
|
||||
GameplayClockContainer.Restart();
|
||||
GameplayClockContainer.Reset();
|
||||
}
|
||||
|
||||
public override void OnSuspending(IScreen next)
|
||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
public double Length => !DrawableSamples.Any() ? 0 : DrawableSamples.Max(sample => sample.Length);
|
||||
|
||||
protected bool RequestedPlaying { get; private set; }
|
||||
public bool RequestedPlaying { get; private set; }
|
||||
|
||||
public PausableSkinnableSound()
|
||||
{
|
||||
|
@ -61,28 +61,32 @@ namespace osu.Game.Storyboards.Drawables
|
||||
{
|
||||
base.Update();
|
||||
|
||||
// Check if we've yet to pass the sample start time.
|
||||
if (Time.Current < sampleInfo.StartTime)
|
||||
{
|
||||
// We've rewound before the start time of the sample
|
||||
Stop();
|
||||
|
||||
// In the case that the user fast-forwards to a point far beyond the start time of the sample,
|
||||
// we want to be able to fall into the if-conditional below (therefore we must not have a life time end)
|
||||
// Playback has stopped, but if the user fast-forwards to a point after the start time of the sample then
|
||||
// we must not have a lifetime end in order to continue receiving updates and start the sample below.
|
||||
LifetimeStart = sampleInfo.StartTime;
|
||||
LifetimeEnd = double.MaxValue;
|
||||
|
||||
return;
|
||||
}
|
||||
else if (Time.Current - Time.Elapsed <= sampleInfo.StartTime)
|
||||
|
||||
// Ensure that we've elapsed from a point before the sample's start time before playing.
|
||||
if (Time.Current - Time.Elapsed <= sampleInfo.StartTime)
|
||||
{
|
||||
// We've passed the start time of the sample. We only play the sample if we're within an allowable range
|
||||
// from the sample's start, to reduce layering if we've been fast-forwarded far into the future
|
||||
if (!RequestedPlaying && Time.Current - sampleInfo.StartTime < allowable_late_start)
|
||||
Play();
|
||||
|
||||
// In the case that the user rewinds to a point far behind the start time of the sample,
|
||||
// we want to be able to fall into the if-conditional above (therefore we must not have a life time start)
|
||||
LifetimeStart = double.MinValue;
|
||||
LifetimeEnd = sampleInfo.StartTime;
|
||||
}
|
||||
|
||||
// Playback has started, but if the user rewinds to a point before the start time of the sample then
|
||||
// we must not have a lifetime start in order to continue receiving updates and stop the sample above.
|
||||
LifetimeStart = double.MinValue;
|
||||
LifetimeEnd = sampleInfo.StartTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -215,6 +215,8 @@ namespace osu.Game.Tests.Beatmaps
|
||||
|
||||
protected override Track GetBeatmapTrack() => throw new NotImplementedException();
|
||||
|
||||
public override Stream GetStream(string storagePath) => throw new NotImplementedException();
|
||||
|
||||
protected override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap, Ruleset ruleset)
|
||||
{
|
||||
var converter = base.CreateBeatmapConverter(beatmap, ruleset);
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.IO;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
@ -35,6 +36,8 @@ namespace osu.Game.Tests.Beatmaps
|
||||
|
||||
protected override Storyboard GetStoryboard() => storyboard ?? base.GetStoryboard();
|
||||
|
||||
public override Stream GetStream(string storagePath) => null;
|
||||
|
||||
protected override Texture GetBackground() => null;
|
||||
|
||||
protected override Track GetBeatmapTrack() => null;
|
||||
|
@ -29,7 +29,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.NETCore.Targets" Version="3.1.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2021.416.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2021.419.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.412.0" />
|
||||
<PackageReference Include="Sentry" Version="3.2.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.28.1" />
|
||||
|
@ -70,7 +70,7 @@
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="Package References">
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.416.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.419.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.412.0" />
|
||||
</ItemGroup>
|
||||
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
|
||||
@ -93,7 +93,7 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2021.416.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2021.419.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.28.1" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||
|
Loading…
Reference in New Issue
Block a user