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

Merge branch 'master' into mania-config-lookup-refactor

This commit is contained in:
Dean Herbert 2020-04-03 22:22:59 +09:00 committed by GitHub
commit 53c99d137a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 251 additions and 67 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="RiderProjectSettingsUpdater"> <component name="RiderProjectSettingsUpdater">
<option name="vcsConfiguration" value="1" /> <option name="vcsConfiguration" value="2" />
</component> </component>
</project> </project>

View File

@ -51,7 +51,7 @@
<Reference Include="Java.Interop" /> <Reference Include="Java.Interop" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.402.1" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2020.403.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.402.0" /> <PackageReference Include="ppy.osu.Framework.Android" Version="2020.403.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -384,7 +384,7 @@ namespace osu.Game.Rulesets.Catch.UI
} }
currentCatcher.Show(); currentCatcher.Show();
(currentCatcher.Drawable as IAnimation)?.GotoFrame(0); (currentCatcher.Drawable as IFramedAnimation)?.GotoFrame(0);
} }
private void beginTrail() private void beginTrail()

View File

@ -36,7 +36,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
// This animation is discarded and re-queried with the appropriate frame length afterwards. // This animation is discarded and re-queried with the appropriate frame length afterwards.
var tmp = skin.GetAnimation(imageName, true, false); var tmp = skin.GetAnimation(imageName, true, false);
double frameLength = 0; double frameLength = 0;
if (tmp is IAnimation tmpAnimation && tmpAnimation.FrameCount > 0) if (tmp is IFramedAnimation tmpAnimation && tmpAnimation.FrameCount > 0)
frameLength = Math.Max(1000 / 60.0, 170.0 / tmpAnimation.FrameCount); frameLength = Math.Max(1000 / 60.0, 170.0 / tmpAnimation.FrameCount);
explosion = skin.GetAnimation(imageName, true, false, startAtCurrentTime: true, frameLength: frameLength).With(d => explosion = skin.GetAnimation(imageName, true, false, startAtCurrentTime: true, frameLength: frameLength).With(d =>

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

@ -4,31 +4,28 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation;
using osuTK; using osuTK;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Audio;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Taiko.Audio;
using osu.Game.Rulesets.Taiko.UI; using osu.Game.Rulesets.Taiko.UI;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Taiko.Tests namespace osu.Game.Rulesets.Taiko.Tests
{ {
[TestFixture] [TestFixture]
public class TestSceneInputDrum : OsuTestScene public class TestSceneInputDrum : SkinnableTestScene
{ {
public override IReadOnlyList<Type> RequiredTypes => new[] public override IReadOnlyList<Type> RequiredTypes => new[]
{ {
typeof(InputDrum), typeof(InputDrum),
typeof(DrumSampleMapping),
typeof(HitSampleInfo),
typeof(SampleControlPoint)
}; };
public TestSceneInputDrum() [BackgroundDependencyLoader]
private void load()
{ {
Add(new TaikoInputManager(new RulesetInfo { ID = 1 }) SetContents(() => new TaikoInputManager(new RulesetInfo { ID = 1 })
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Child = new Container Child = new Container

View File

@ -0,0 +1,144 @@
// 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.Sprites;
using osu.Framework.Input.Bindings;
using osu.Game.Rulesets.Taiko.Audio;
using osu.Game.Skinning;
using osuTK;
namespace osu.Game.Rulesets.Taiko.Skinning
{
/// <summary>
/// A component of the playfield that captures input and displays input as a drum.
/// </summary>
internal class LegacyInputDrum : Container
{
public LegacyInputDrum()
{
AutoSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load(ISkinSource skin)
{
Children = new Drawable[]
{
new Sprite
{
Texture = skin.GetTexture("taiko-bar-left")
},
new LegacyHalfDrum(false)
{
Name = "Left Half",
RelativeSizeAxes = Axes.Both,
Width = 0.5f,
RimAction = TaikoAction.LeftRim,
CentreAction = TaikoAction.LeftCentre
},
new LegacyHalfDrum(true)
{
Name = "Right Half",
Anchor = Anchor.TopRight,
RelativeSizeAxes = Axes.Both,
Width = 0.5f,
Scale = new Vector2(-1, 1),
RimAction = TaikoAction.RightRim,
CentreAction = TaikoAction.RightCentre
}
};
}
/// <summary>
/// A half-drum. Contains one centre and one rim hit.
/// </summary>
private class LegacyHalfDrum : Container, IKeyBindingHandler<TaikoAction>
{
/// <summary>
/// The key to be used for the rim of the half-drum.
/// </summary>
public TaikoAction RimAction;
/// <summary>
/// The key to be used for the centre of the half-drum.
/// </summary>
public TaikoAction CentreAction;
private readonly Sprite rimHit;
private readonly Sprite centreHit;
[Resolved]
private DrumSampleMapping sampleMappings { get; set; }
public LegacyHalfDrum(bool flipped)
{
Masking = true;
Children = new Drawable[]
{
rimHit = new Sprite
{
Anchor = flipped ? Anchor.CentreRight : Anchor.CentreLeft,
Origin = flipped ? Anchor.CentreLeft : Anchor.CentreRight,
Scale = new Vector2(-1, 1),
Alpha = 0,
},
centreHit = new Sprite
{
Anchor = flipped ? Anchor.CentreRight : Anchor.CentreLeft,
Origin = flipped ? Anchor.CentreRight : Anchor.CentreLeft,
Alpha = 0,
}
};
}
[BackgroundDependencyLoader]
private void load(ISkinSource skin)
{
rimHit.Texture = skin.GetTexture(@"taiko-drum-outer");
centreHit.Texture = skin.GetTexture(@"taiko-drum-inner");
}
public bool OnPressed(TaikoAction action)
{
Drawable target = null;
var drumSample = sampleMappings.SampleAt(Time.Current);
if (action == CentreAction)
{
target = centreHit;
drumSample.Centre?.Play();
}
else if (action == RimAction)
{
target = rimHit;
drumSample.Rim?.Play();
}
if (target != null)
{
const float alpha_amount = 1;
const float down_time = 80;
const float up_time = 50;
target.Animate(
t => t.FadeTo(Math.Min(target.Alpha + alpha_amount, 1), down_time)
).Then(
t => t.FadeOut(up_time)
);
}
return false;
}
public void OnReleased(TaikoAction action)
{
}
}
}
}

View File

@ -20,7 +20,22 @@ namespace osu.Game.Rulesets.Taiko.Skinning
this.source = source; this.source = source;
} }
public Drawable GetDrawableComponent(ISkinComponent component) => source.GetDrawableComponent(component); public Drawable GetDrawableComponent(ISkinComponent component)
{
if (!(component is TaikoSkinComponent taikoComponent))
return null;
switch (taikoComponent.Component)
{
case TaikoSkinComponents.InputDrum:
if (GetTexture("taiko-bar-left") != null)
return new LegacyInputDrum();
return null;
}
return source.GetDrawableComponent(component);
}
public Texture GetTexture(string componentName) => source.GetTexture(componentName); public Texture GetTexture(string componentName) => source.GetTexture(componentName);

View File

@ -5,5 +5,6 @@ namespace osu.Game.Rulesets.Taiko
{ {
public enum TaikoSkinComponents public enum TaikoSkinComponents
{ {
InputDrum,
} }
} }

View File

@ -12,6 +12,7 @@ using osu.Framework.Input.Bindings;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Taiko.Audio; using osu.Game.Rulesets.Taiko.Audio;
using osu.Game.Skinning;
namespace osu.Game.Rulesets.Taiko.UI namespace osu.Game.Rulesets.Taiko.UI
{ {
@ -22,11 +23,12 @@ namespace osu.Game.Rulesets.Taiko.UI
{ {
private const float middle_split = 0.025f; private const float middle_split = 0.025f;
private readonly ControlPointInfo controlPoints; [Cached]
private DrumSampleMapping sampleMapping;
public InputDrum(ControlPointInfo controlPoints) public InputDrum(ControlPointInfo controlPoints)
{ {
this.controlPoints = controlPoints; sampleMapping = new DrumSampleMapping(controlPoints);
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
FillMode = FillMode.Fit; FillMode = FillMode.Fit;
@ -35,35 +37,37 @@ namespace osu.Game.Rulesets.Taiko.UI
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
var sampleMappings = new DrumSampleMapping(controlPoints); Child = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.InputDrum), _ => new Container
Children = new Drawable[]
{ {
new TaikoHalfDrum(false, sampleMappings) RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{ {
Name = "Left Half", new TaikoHalfDrum(false)
Anchor = Anchor.Centre, {
Origin = Anchor.CentreRight, Name = "Left Half",
RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre,
RelativePositionAxes = Axes.X, Origin = Anchor.CentreRight,
X = -middle_split / 2, RelativeSizeAxes = Axes.Both,
RimAction = TaikoAction.LeftRim, RelativePositionAxes = Axes.X,
CentreAction = TaikoAction.LeftCentre X = -middle_split / 2,
}, RimAction = TaikoAction.LeftRim,
new TaikoHalfDrum(true, sampleMappings) CentreAction = TaikoAction.LeftCentre
{ },
Name = "Right Half", new TaikoHalfDrum(true)
Anchor = Anchor.Centre, {
Origin = Anchor.CentreLeft, Name = "Right Half",
RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre,
RelativePositionAxes = Axes.X, Origin = Anchor.CentreLeft,
X = middle_split / 2, RelativeSizeAxes = Axes.Both,
RimAction = TaikoAction.RightRim, RelativePositionAxes = Axes.X,
CentreAction = TaikoAction.RightCentre X = middle_split / 2,
RimAction = TaikoAction.RightRim,
CentreAction = TaikoAction.RightCentre
}
} }
}; });
AddRangeInternal(sampleMappings.Sounds); AddRangeInternal(sampleMapping.Sounds);
} }
/// <summary> /// <summary>
@ -86,12 +90,11 @@ namespace osu.Game.Rulesets.Taiko.UI
private readonly Sprite centre; private readonly Sprite centre;
private readonly Sprite centreHit; private readonly Sprite centreHit;
private readonly DrumSampleMapping sampleMappings; [Resolved]
private DrumSampleMapping sampleMappings { get; set; }
public TaikoHalfDrum(bool flipped, DrumSampleMapping sampleMappings) public TaikoHalfDrum(bool flipped)
{ {
this.sampleMappings = sampleMappings;
Masking = true; Masking = true;
Children = new Drawable[] Children = new Drawable[]

View File

@ -127,6 +127,31 @@ namespace osu.Game.Tests.Beatmaps.Formats
.Assert(); .Assert();
} }
[Test]
public void TestGetJsonDecoder()
{
Decoder<Beatmap> decoder;
using (var stream = TestResources.OpenResource(normal))
using (var sr = new LineBufferedReader(stream))
{
var legacyDecoded = new LegacyBeatmapDecoder { ApplyOffsets = false }.Decode(sr);
using (var memStream = new MemoryStream())
using (var memWriter = new StreamWriter(memStream))
using (var memReader = new LineBufferedReader(memStream))
{
memWriter.Write(legacyDecoded.Serialize());
memWriter.Flush();
memStream.Position = 0;
decoder = Decoder.GetDecoder<Beatmap>(memReader);
}
}
Assert.IsInstanceOf(typeof(JsonBeatmapDecoder), decoder);
}
/// <summary> /// <summary>
/// Reads a .osu file first with a <see cref="LegacyBeatmapDecoder"/>, serializes the resulting <see cref="Beatmap"/> to JSON /// Reads a .osu file first with a <see cref="LegacyBeatmapDecoder"/>, serializes the resulting <see cref="Beatmap"/> to JSON
/// and then deserializes the result back into a <see cref="Beatmap"/> through an <see cref="JsonBeatmapDecoder"/>. /// and then deserializes the result back into a <see cref="Beatmap"/> through an <see cref="JsonBeatmapDecoder"/>.

View File

@ -22,7 +22,6 @@ namespace osu.Game.Tests.Visual.Menus
{ {
typeof(StartupScreen), typeof(StartupScreen),
typeof(IntroScreen), typeof(IntroScreen),
typeof(OsuScreen),
typeof(IntroTestScene), typeof(IntroTestScene),
}; };

View File

@ -16,7 +16,7 @@ namespace osu.Game.Tournament.Components
{ {
private readonly string filename; private readonly string filename;
private readonly bool drawFallbackGradient; private readonly bool drawFallbackGradient;
private VideoSprite video; private Video video;
private ManualClock manualClock; private ManualClock manualClock;
@ -33,7 +33,7 @@ namespace osu.Game.Tournament.Components
if (stream != null) if (stream != null)
{ {
InternalChild = video = new VideoSprite(stream, false) InternalChild = video = new Video(stream, false)
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fit, FillMode = FillMode.Fit,

View File

@ -63,7 +63,7 @@ namespace osu.Game.Beatmaps.Formats
if (line == null) if (line == null)
throw new IOException("Unknown file format (null)"); throw new IOException("Unknown file format (null)");
var decoder = typedDecoders.Select(d => line.StartsWith(d.Key, StringComparison.InvariantCulture) ? d.Value : null).FirstOrDefault(); var decoder = typedDecoders.Where(d => line.StartsWith(d.Key, StringComparison.InvariantCulture)).Select(d => d.Value).FirstOrDefault();
// it's important the magic does NOT get consumed here, since sometimes it's part of the structure // it's important the magic does NOT get consumed here, since sometimes it's part of the structure
// (see JsonBeatmapDecoder - the magic string is the opening brace) // (see JsonBeatmapDecoder - the magic string is the opening brace)

View File

@ -270,10 +270,9 @@ namespace osu.Game.Screens.Menu
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
InternalChild = new VideoSprite(videoStream, false) InternalChild = new Video(videoStream, false)
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Clock = new FramedOffsetClock(Clock) { Offset = -logo_1 }
}; };
} }
} }

View File

@ -8,7 +8,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Animations; using osu.Framework.Graphics.Animations;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Timing;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
@ -28,7 +27,7 @@ namespace osu.Game.Skinning
var animation = new SkinnableTextureAnimation(startAtCurrentTime) var animation = new SkinnableTextureAnimation(startAtCurrentTime)
{ {
DefaultFrameLength = frameLength ?? getFrameLength(source, applyConfigFrameRate, textures), DefaultFrameLength = frameLength ?? getFrameLength(source, applyConfigFrameRate, textures),
Repeat = looping, Loop = looping,
}; };
foreach (var t in textures) foreach (var t in textures)
@ -71,7 +70,10 @@ namespace osu.Game.Skinning
base.LoadComplete(); base.LoadComplete();
if (timeReference != null) if (timeReference != null)
Clock = new FramedOffsetClock(timeReference.Clock) { Offset = -timeReference.AnimationStartTime }; {
Clock = timeReference.Clock;
PlaybackPosition = timeReference.AnimationStartTime - timeReference.Clock.CurrentTime;
}
} }
} }

View File

@ -108,7 +108,7 @@ namespace osu.Game.Storyboards.Drawables
Animation = animation; Animation = animation;
Origin = animation.Origin; Origin = animation.Origin;
Position = animation.InitialPosition; Position = animation.InitialPosition;
Repeat = animation.LoopType == AnimationLoopType.LoopForever; Loop = animation.LoopType == AnimationLoopType.LoopForever;
LifetimeStart = animation.StartTime; LifetimeStart = animation.StartTime;
LifetimeEnd = animation.EndTime; LifetimeEnd = animation.EndTime;

View File

@ -8,7 +8,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Graphics.Video; using osu.Framework.Graphics.Video;
using osu.Framework.Timing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
namespace osu.Game.Storyboards.Drawables namespace osu.Game.Storyboards.Drawables
@ -16,7 +15,7 @@ namespace osu.Game.Storyboards.Drawables
public class DrawableStoryboardVideo : CompositeDrawable public class DrawableStoryboardVideo : CompositeDrawable
{ {
public readonly StoryboardVideo Video; public readonly StoryboardVideo Video;
private VideoSprite videoSprite; private Video video;
public override bool RemoveWhenNotAlive => false; public override bool RemoveWhenNotAlive => false;
@ -40,14 +39,14 @@ namespace osu.Game.Storyboards.Drawables
if (stream == null) if (stream == null)
return; return;
InternalChild = videoSprite = new VideoSprite(stream, false) InternalChild = video = new Video(stream, false)
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fill, FillMode = FillMode.Fill,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Alpha = 0, Alpha = 0,
Clock = new FramedOffsetClock(Clock) { Offset = -Video.StartTime } PlaybackPosition = Video.StartTime
}; };
} }
@ -55,10 +54,10 @@ namespace osu.Game.Storyboards.Drawables
{ {
base.LoadComplete(); base.LoadComplete();
if (videoSprite == null) return; if (video == null) return;
using (videoSprite.BeginAbsoluteSequence(0)) using (video.BeginAbsoluteSequence(0))
videoSprite.FadeIn(500); video.FadeIn(500);
} }
} }
} }

View File

@ -22,8 +22,8 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.402.1" /> <PackageReference Include="ppy.osu.Framework" Version="2020.403.0" />
<PackageReference Include="ppy.osu.Framework" Version="2020.402.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2020.403.0" />
<PackageReference Include="Sentry" Version="2.1.1" /> <PackageReference Include="Sentry" Version="2.1.1" />
<PackageReference Include="SharpCompress" Version="0.24.0" /> <PackageReference Include="SharpCompress" Version="0.24.0" />
<PackageReference Include="NUnit" Version="3.12.0" /> <PackageReference Include="NUnit" Version="3.12.0" />

View File

@ -70,8 +70,8 @@
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http" />
</ItemGroup> </ItemGroup>
<ItemGroup Label="Package References"> <ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.402.1" /> <PackageReference Include="ppy.osu.Framework.iOS" Version="2020.403.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.402.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2020.403.0" />
</ItemGroup> </ItemGroup>
<!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. --> <!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. -->
<ItemGroup Label="Transitive Dependencies"> <ItemGroup Label="Transitive Dependencies">
@ -79,7 +79,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="ppy.osu.Framework" Version="2020.402.0" /> <PackageReference Include="ppy.osu.Framework" Version="2020.403.0" />
<PackageReference Include="SharpCompress" Version="0.24.0" /> <PackageReference Include="SharpCompress" Version="0.24.0" />
<PackageReference Include="NUnit" Version="3.12.0" /> <PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" /> <PackageReference Include="SharpRaven" Version="2.4.0" />