mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 18:12:56 +08:00
Merge branch 'master' into ongoing-tracker-fix-more
This commit is contained in:
commit
f24a6178bc
@ -30,7 +30,7 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.6" />
|
||||||
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
|
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
|
||||||
<PackageReference Include="DiscordRichPresence" Version="1.0.169" />
|
<PackageReference Include="DiscordRichPresence" Version="1.0.175" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Resources">
|
<ItemGroup Label="Resources">
|
||||||
<EmbeddedResource Include="lazer.ico" />
|
<EmbeddedResource Include="lazer.ico" />
|
||||||
|
@ -243,7 +243,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (HandleUserInput)
|
if (HandleUserInput)
|
||||||
RotationTracker.Tracking = !Result.HasResult && (OsuActionInputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false);
|
{
|
||||||
|
bool isValidSpinningTime = Time.Current >= HitObject.StartTime && Time.Current <= HitObject.EndTime;
|
||||||
|
bool correctButtonPressed = (OsuActionInputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false);
|
||||||
|
|
||||||
|
RotationTracker.Tracking = !Result.HasResult
|
||||||
|
&& correctButtonPressed
|
||||||
|
&& isValidSpinningTime;
|
||||||
|
}
|
||||||
|
|
||||||
if (spinningSample != null && spinnerFrequencyModulate)
|
if (spinningSample != null && spinnerFrequencyModulate)
|
||||||
spinningSample.Frequency.Value = spinning_sample_modulated_base_frequency + Progress;
|
spinningSample.Frequency.Value = spinning_sample_modulated_base_frequency + Progress;
|
||||||
@ -255,6 +262,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
if (!SpmCounter.IsPresent && RotationTracker.Tracking)
|
if (!SpmCounter.IsPresent && RotationTracker.Tracking)
|
||||||
SpmCounter.FadeIn(HitObject.TimeFadeIn);
|
SpmCounter.FadeIn(HitObject.TimeFadeIn);
|
||||||
|
|
||||||
SpmCounter.SetRotation(Result.RateAdjustedRotation);
|
SpmCounter.SetRotation(Result.RateAdjustedRotation);
|
||||||
|
|
||||||
updateBonusScore();
|
updateBonusScore();
|
||||||
|
@ -4,16 +4,21 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Skinning.Default
|
namespace osu.Game.Rulesets.Osu.Skinning.Default
|
||||||
{
|
{
|
||||||
public class SpinnerSpmCounter : Container
|
public class SpinnerSpmCounter : Container
|
||||||
{
|
{
|
||||||
|
[Resolved]
|
||||||
|
private DrawableHitObject drawableSpinner { get; set; }
|
||||||
|
|
||||||
private readonly OsuSpriteText spmText;
|
private readonly OsuSpriteText spmText;
|
||||||
|
|
||||||
public SpinnerSpmCounter()
|
public SpinnerSpmCounter()
|
||||||
@ -38,6 +43,12 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
drawableSpinner.HitObjectApplied += resetState;
|
||||||
|
}
|
||||||
|
|
||||||
private double spm;
|
private double spm;
|
||||||
|
|
||||||
public double SpinsPerMinute
|
public double SpinsPerMinute
|
||||||
@ -82,5 +93,19 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
|||||||
|
|
||||||
records.Enqueue(new RotationRecord { Rotation = currentRotation, Time = Time.Current });
|
records.Enqueue(new RotationRecord { Rotation = currentRotation, Time = Time.Current });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void resetState(DrawableHitObject hitObject)
|
||||||
|
{
|
||||||
|
SpinsPerMinute = 0;
|
||||||
|
records.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
|
if (drawableSpinner != null)
|
||||||
|
drawableSpinner.HitObjectApplied -= resetState;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,5 +69,9 @@
|
|||||||
<Name>osu.Game</Name>
|
<Name>osu.Game</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup Label="Package References">
|
||||||
|
<PackageReference Include="DeepEqual" Version="2.0.0" />
|
||||||
|
<PackageReference Include="Moq" Version="4.16.0" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
@ -45,6 +45,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Package References">
|
<ItemGroup Label="Package References">
|
||||||
<PackageReference Include="DeepEqual" Version="2.0.0" />
|
<PackageReference Include="DeepEqual" Version="2.0.0" />
|
||||||
|
<PackageReference Include="Moq" Version="4.16.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
@ -129,5 +129,25 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
Assert.AreEqual(3456, ((StoryboardSprite)background.Elements.Single()).InitialPosition.X);
|
Assert.AreEqual(3456, ((StoryboardSprite)background.Elements.Single()).InitialPosition.X);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDecodeOutOfRangeLoopAnimationType()
|
||||||
|
{
|
||||||
|
var decoder = new LegacyStoryboardDecoder();
|
||||||
|
|
||||||
|
using (var resStream = TestResources.OpenResource("animation-types.osb"))
|
||||||
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
|
{
|
||||||
|
var storyboard = decoder.Decode(stream);
|
||||||
|
|
||||||
|
StoryboardLayer foreground = storyboard.Layers.Single(l => l.Depth == 0);
|
||||||
|
Assert.AreEqual(AnimationLoopType.LoopForever, ((StoryboardAnimation)foreground.Elements[0]).LoopType);
|
||||||
|
Assert.AreEqual(AnimationLoopType.LoopOnce, ((StoryboardAnimation)foreground.Elements[1]).LoopType);
|
||||||
|
Assert.AreEqual(AnimationLoopType.LoopForever, ((StoryboardAnimation)foreground.Elements[2]).LoopType);
|
||||||
|
Assert.AreEqual(AnimationLoopType.LoopOnce, ((StoryboardAnimation)foreground.Elements[3]).LoopType);
|
||||||
|
Assert.AreEqual(AnimationLoopType.LoopForever, ((StoryboardAnimation)foreground.Elements[4]).LoopType);
|
||||||
|
Assert.AreEqual(AnimationLoopType.LoopForever, ((StoryboardAnimation)foreground.Elements[5]).LoopType);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
160
osu.Game.Tests/Mods/ModUtilsTest.cs
Normal file
160
osu.Game.Tests/Mods/ModUtilsTest.cs
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
// 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.Linq;
|
||||||
|
using Moq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
|
using osu.Game.Utils;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Mods
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class ModUtilsTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestModIsCompatibleByItself()
|
||||||
|
{
|
||||||
|
var mod = new Mock<CustomMod1>();
|
||||||
|
Assert.That(ModUtils.CheckCompatibleSet(new[] { mod.Object }));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestIncompatibleThroughTopLevel()
|
||||||
|
{
|
||||||
|
var mod1 = new Mock<CustomMod1>();
|
||||||
|
var mod2 = new Mock<CustomMod2>();
|
||||||
|
|
||||||
|
mod1.Setup(m => m.IncompatibleMods).Returns(new[] { mod2.Object.GetType() });
|
||||||
|
|
||||||
|
// Test both orderings.
|
||||||
|
Assert.That(ModUtils.CheckCompatibleSet(new Mod[] { mod1.Object, mod2.Object }), Is.False);
|
||||||
|
Assert.That(ModUtils.CheckCompatibleSet(new Mod[] { mod2.Object, mod1.Object }), Is.False);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMultiModIncompatibleWithTopLevel()
|
||||||
|
{
|
||||||
|
var mod1 = new Mock<CustomMod1>();
|
||||||
|
|
||||||
|
// The nested mod.
|
||||||
|
var mod2 = new Mock<CustomMod2>();
|
||||||
|
mod2.Setup(m => m.IncompatibleMods).Returns(new[] { mod1.Object.GetType() });
|
||||||
|
|
||||||
|
var multiMod = new MultiMod(new MultiMod(mod2.Object));
|
||||||
|
|
||||||
|
// Test both orderings.
|
||||||
|
Assert.That(ModUtils.CheckCompatibleSet(new Mod[] { multiMod, mod1.Object }), Is.False);
|
||||||
|
Assert.That(ModUtils.CheckCompatibleSet(new Mod[] { mod1.Object, multiMod }), Is.False);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestTopLevelIncompatibleWithMultiMod()
|
||||||
|
{
|
||||||
|
// The nested mod.
|
||||||
|
var mod1 = new Mock<CustomMod1>();
|
||||||
|
var multiMod = new MultiMod(new MultiMod(mod1.Object));
|
||||||
|
|
||||||
|
var mod2 = new Mock<CustomMod2>();
|
||||||
|
mod2.Setup(m => m.IncompatibleMods).Returns(new[] { typeof(CustomMod1) });
|
||||||
|
|
||||||
|
// Test both orderings.
|
||||||
|
Assert.That(ModUtils.CheckCompatibleSet(new Mod[] { multiMod, mod2.Object }), Is.False);
|
||||||
|
Assert.That(ModUtils.CheckCompatibleSet(new Mod[] { mod2.Object, multiMod }), Is.False);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCompatibleMods()
|
||||||
|
{
|
||||||
|
var mod1 = new Mock<CustomMod1>();
|
||||||
|
var mod2 = new Mock<CustomMod2>();
|
||||||
|
|
||||||
|
// Test both orderings.
|
||||||
|
Assert.That(ModUtils.CheckCompatibleSet(new Mod[] { mod1.Object, mod2.Object }), Is.True);
|
||||||
|
Assert.That(ModUtils.CheckCompatibleSet(new Mod[] { mod2.Object, mod1.Object }), Is.True);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestIncompatibleThroughBaseType()
|
||||||
|
{
|
||||||
|
var mod1 = new Mock<CustomMod1>();
|
||||||
|
var mod2 = new Mock<CustomMod2>();
|
||||||
|
mod2.Setup(m => m.IncompatibleMods).Returns(new[] { typeof(Mod) });
|
||||||
|
|
||||||
|
// Test both orderings.
|
||||||
|
Assert.That(ModUtils.CheckCompatibleSet(new Mod[] { mod1.Object, mod2.Object }), Is.False);
|
||||||
|
Assert.That(ModUtils.CheckCompatibleSet(new Mod[] { mod2.Object, mod1.Object }), Is.False);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestAllowedThroughMostDerivedType()
|
||||||
|
{
|
||||||
|
var mod = new Mock<CustomMod1>();
|
||||||
|
Assert.That(ModUtils.CheckAllowed(new[] { mod.Object }, new[] { mod.Object.GetType() }));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestNotAllowedThroughBaseType()
|
||||||
|
{
|
||||||
|
var mod = new Mock<CustomMod1>();
|
||||||
|
Assert.That(ModUtils.CheckAllowed(new[] { mod.Object }, new[] { typeof(Mod) }), Is.False);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly object[] invalid_mod_test_scenarios =
|
||||||
|
{
|
||||||
|
// incompatible pair.
|
||||||
|
new object[]
|
||||||
|
{
|
||||||
|
new Mod[] { new OsuModDoubleTime(), new OsuModHalfTime() },
|
||||||
|
new[] { typeof(OsuModDoubleTime), typeof(OsuModHalfTime) }
|
||||||
|
},
|
||||||
|
// incompatible pair with derived class.
|
||||||
|
new object[]
|
||||||
|
{
|
||||||
|
new Mod[] { new OsuModNightcore(), new OsuModHalfTime() },
|
||||||
|
new[] { typeof(OsuModNightcore), typeof(OsuModHalfTime) }
|
||||||
|
},
|
||||||
|
// system mod.
|
||||||
|
new object[]
|
||||||
|
{
|
||||||
|
new Mod[] { new OsuModDoubleTime(), new OsuModTouchDevice() },
|
||||||
|
new[] { typeof(OsuModTouchDevice) }
|
||||||
|
},
|
||||||
|
// multi mod.
|
||||||
|
new object[]
|
||||||
|
{
|
||||||
|
new Mod[] { new MultiMod(new OsuModHalfTime()), new OsuModHalfTime() },
|
||||||
|
new[] { typeof(MultiMod) }
|
||||||
|
},
|
||||||
|
// valid pair.
|
||||||
|
new object[]
|
||||||
|
{
|
||||||
|
new Mod[] { new OsuModDoubleTime(), new OsuModHardRock() },
|
||||||
|
null
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
[TestCaseSource(nameof(invalid_mod_test_scenarios))]
|
||||||
|
public void TestInvalidModScenarios(Mod[] inputMods, Type[] expectedInvalid)
|
||||||
|
{
|
||||||
|
bool isValid = ModUtils.CheckValidForGameplay(inputMods, out var invalid);
|
||||||
|
|
||||||
|
Assert.That(isValid, Is.EqualTo(expectedInvalid == null));
|
||||||
|
|
||||||
|
if (isValid)
|
||||||
|
Assert.IsNull(invalid);
|
||||||
|
else
|
||||||
|
Assert.That(invalid?.Select(t => t.GetType()), Is.EquivalentTo(expectedInvalid));
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class CustomMod1 : Mod
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class CustomMod2 : Mod
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
osu.Game.Tests/Resources/animation-types.osb
Normal file
9
osu.Game.Tests/Resources/animation-types.osb
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
osu file format v14
|
||||||
|
|
||||||
|
[Events]
|
||||||
|
Animation,Foreground,Centre,"forever-string.png",330,240,10,108,LoopForever
|
||||||
|
Animation,Foreground,Centre,"once-string.png",330,240,10,108,LoopOnce
|
||||||
|
Animation,Foreground,Centre,"forever-number.png",330,240,10,108,0
|
||||||
|
Animation,Foreground,Centre,"once-number.png",330,240,10,108,1
|
||||||
|
Animation,Foreground,Centre,"undefined-number.png",330,240,10,108,16
|
||||||
|
Animation,Foreground,Centre,"omitted.png",330,240,10,108
|
113
osu.Game.Tests/Rulesets/Mods/ModTimeRampTest.cs
Normal file
113
osu.Game.Tests/Rulesets/Mods/ModTimeRampTest.cs
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
// 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.Audio.Track;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Rulesets.Mods
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class ModTimeRampTest
|
||||||
|
{
|
||||||
|
private const double start_time = 1000;
|
||||||
|
private const double duration = 9000;
|
||||||
|
|
||||||
|
private TrackVirtual track;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void SetUp()
|
||||||
|
{
|
||||||
|
track = new TrackVirtual(20_000);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(0, 1)]
|
||||||
|
[TestCase(start_time, 1)]
|
||||||
|
[TestCase(start_time + duration * ModTimeRamp.FINAL_RATE_PROGRESS / 2, 1.25)]
|
||||||
|
[TestCase(start_time + duration * ModTimeRamp.FINAL_RATE_PROGRESS, 1.5)]
|
||||||
|
[TestCase(start_time + duration, 1.5)]
|
||||||
|
[TestCase(15000, 1.5)]
|
||||||
|
public void TestModWindUp(double time, double expectedRate)
|
||||||
|
{
|
||||||
|
var beatmap = createSingleSpinnerBeatmap();
|
||||||
|
var mod = new ModWindUp();
|
||||||
|
mod.ApplyToBeatmap(beatmap);
|
||||||
|
mod.ApplyToTrack(track);
|
||||||
|
|
||||||
|
seekTrackAndUpdateMod(mod, time);
|
||||||
|
|
||||||
|
Assert.That(mod.SpeedChange.Value, Is.EqualTo(expectedRate));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(0, 1)]
|
||||||
|
[TestCase(start_time, 1)]
|
||||||
|
[TestCase(start_time + duration * ModTimeRamp.FINAL_RATE_PROGRESS / 2, 0.75)]
|
||||||
|
[TestCase(start_time + duration * ModTimeRamp.FINAL_RATE_PROGRESS, 0.5)]
|
||||||
|
[TestCase(start_time + duration, 0.5)]
|
||||||
|
[TestCase(15000, 0.5)]
|
||||||
|
public void TestModWindDown(double time, double expectedRate)
|
||||||
|
{
|
||||||
|
var beatmap = createSingleSpinnerBeatmap();
|
||||||
|
var mod = new ModWindDown
|
||||||
|
{
|
||||||
|
FinalRate = { Value = 0.5 }
|
||||||
|
};
|
||||||
|
mod.ApplyToBeatmap(beatmap);
|
||||||
|
mod.ApplyToTrack(track);
|
||||||
|
|
||||||
|
seekTrackAndUpdateMod(mod, time);
|
||||||
|
|
||||||
|
Assert.That(mod.SpeedChange.Value, Is.EqualTo(expectedRate));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(0, 1)]
|
||||||
|
[TestCase(start_time, 1)]
|
||||||
|
[TestCase(2 * start_time, 1.5)]
|
||||||
|
public void TestZeroDurationMap(double time, double expectedRate)
|
||||||
|
{
|
||||||
|
var beatmap = createSingleObjectBeatmap();
|
||||||
|
var mod = new ModWindUp();
|
||||||
|
mod.ApplyToBeatmap(beatmap);
|
||||||
|
mod.ApplyToTrack(track);
|
||||||
|
|
||||||
|
seekTrackAndUpdateMod(mod, time);
|
||||||
|
|
||||||
|
Assert.That(mod.SpeedChange.Value, Is.EqualTo(expectedRate));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void seekTrackAndUpdateMod(ModTimeRamp mod, double time)
|
||||||
|
{
|
||||||
|
track.Seek(time);
|
||||||
|
// update the mod via a fake playfield to re-calculate the current rate.
|
||||||
|
mod.Update(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Beatmap createSingleSpinnerBeatmap()
|
||||||
|
{
|
||||||
|
return new Beatmap
|
||||||
|
{
|
||||||
|
HitObjects =
|
||||||
|
{
|
||||||
|
new Spinner
|
||||||
|
{
|
||||||
|
StartTime = start_time,
|
||||||
|
Duration = duration
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Beatmap createSingleObjectBeatmap()
|
||||||
|
{
|
||||||
|
return new Beatmap
|
||||||
|
{
|
||||||
|
HitObjects =
|
||||||
|
{
|
||||||
|
new HitCircle { StartTime = start_time }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
// 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 NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osu.Game.Storyboards;
|
||||||
|
using osu.Game.Storyboards.Drawables;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
|
{
|
||||||
|
public class TestSceneStoryboardSamplePlayback : PlayerTestScene
|
||||||
|
{
|
||||||
|
private Storyboard storyboard;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuConfigManager config)
|
||||||
|
{
|
||||||
|
config.Set(OsuSetting.ShowStoryboard, true);
|
||||||
|
|
||||||
|
storyboard = new Storyboard();
|
||||||
|
var backgroundLayer = storyboard.GetLayer("Background");
|
||||||
|
backgroundLayer.Add(new StoryboardSampleInfo("Intro/welcome.mp3", time: -7000, volume: 20));
|
||||||
|
backgroundLayer.Add(new StoryboardSampleInfo("Intro/welcome.mp3", time: -5000, volume: 20));
|
||||||
|
backgroundLayer.Add(new StoryboardSampleInfo("Intro/welcome.mp3", time: 0, volume: 20));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestStoryboardSamplesStopDuringPause()
|
||||||
|
{
|
||||||
|
checkForFirstSamplePlayback();
|
||||||
|
|
||||||
|
AddStep("player paused", () => Player.Pause());
|
||||||
|
AddAssert("player is currently paused", () => Player.GameplayClockContainer.IsPaused.Value);
|
||||||
|
AddAssert("all storyboard samples stopped immediately", () => allStoryboardSamples.All(sound => !sound.IsPlaying));
|
||||||
|
|
||||||
|
AddStep("player resume", () => Player.Resume());
|
||||||
|
AddUntilStep("any storyboard samples playing after resume", () => allStoryboardSamples.Any(sound => sound.IsPlaying));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestStoryboardSamplesStopOnSkip()
|
||||||
|
{
|
||||||
|
checkForFirstSamplePlayback();
|
||||||
|
|
||||||
|
AddStep("skip intro", () => InputManager.Key(osuTK.Input.Key.Space));
|
||||||
|
AddAssert("all storyboard samples stopped immediately", () => allStoryboardSamples.All(sound => !sound.IsPlaying));
|
||||||
|
|
||||||
|
AddUntilStep("any storyboard samples playing after skip", () => allStoryboardSamples.Any(sound => sound.IsPlaying));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkForFirstSamplePlayback()
|
||||||
|
{
|
||||||
|
AddUntilStep("storyboard loaded", () => Player.Beatmap.Value.StoryboardLoaded);
|
||||||
|
AddUntilStep("any storyboard samples playing", () => allStoryboardSamples.Any(sound => sound.IsPlaying));
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerable<DrawableStoryboardSample> allStoryboardSamples => Player.ChildrenOfType<DrawableStoryboardSample>();
|
||||||
|
|
||||||
|
protected override bool AllowFail => false;
|
||||||
|
|
||||||
|
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
|
||||||
|
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new TestPlayer(true, false);
|
||||||
|
|
||||||
|
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) =>
|
||||||
|
new ClockBackedTestWorkingBeatmap(beatmap, storyboard ?? this.storyboard, Clock, Audio);
|
||||||
|
}
|
||||||
|
}
|
@ -11,8 +11,8 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.Drawables;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.UserInterface;
|
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
@ -20,6 +20,7 @@ using osu.Game.Rulesets.Osu;
|
|||||||
using osu.Game.Rulesets.Osu.Mods;
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
using osu.Game.Screens.OnlinePlay;
|
using osu.Game.Screens.OnlinePlay;
|
||||||
using osu.Game.Tests.Beatmaps;
|
using osu.Game.Tests.Beatmaps;
|
||||||
|
using osu.Game.Users;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
|
||||||
@ -241,7 +242,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void moveToItem(int index, Vector2? offset = null)
|
private void moveToItem(int index, Vector2? offset = null)
|
||||||
=> AddStep($"move mouse to item {index}", () => InputManager.MoveMouseTo(playlist.ChildrenOfType<OsuRearrangeableListItem<PlaylistItem>>().ElementAt(index), offset));
|
=> AddStep($"move mouse to item {index}", () => InputManager.MoveMouseTo(playlist.ChildrenOfType<DifficultyIcon>().ElementAt(index), offset));
|
||||||
|
|
||||||
private void moveToDragger(int index, Vector2? offset = null) => AddStep($"move mouse to dragger {index}", () =>
|
private void moveToDragger(int index, Vector2? offset = null) => AddStep($"move mouse to dragger {index}", () =>
|
||||||
{
|
{
|
||||||
@ -252,7 +253,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
private void moveToDeleteButton(int index, Vector2? offset = null) => AddStep($"move mouse to delete button {index}", () =>
|
private void moveToDeleteButton(int index, Vector2? offset = null) => AddStep($"move mouse to delete button {index}", () =>
|
||||||
{
|
{
|
||||||
var item = playlist.ChildrenOfType<OsuRearrangeableListItem<PlaylistItem>>().ElementAt(index);
|
var item = playlist.ChildrenOfType<OsuRearrangeableListItem<PlaylistItem>>().ElementAt(index);
|
||||||
InputManager.MoveMouseTo(item.ChildrenOfType<IconButton>().ElementAt(0), offset);
|
InputManager.MoveMouseTo(item.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(0), offset);
|
||||||
});
|
});
|
||||||
|
|
||||||
private void assertHandleVisibility(int index, bool visible)
|
private void assertHandleVisibility(int index, bool visible)
|
||||||
@ -260,7 +261,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
() => (playlist.ChildrenOfType<OsuRearrangeableListItem<PlaylistItem>.PlaylistItemHandle>().ElementAt(index).Alpha > 0) == visible);
|
() => (playlist.ChildrenOfType<OsuRearrangeableListItem<PlaylistItem>.PlaylistItemHandle>().ElementAt(index).Alpha > 0) == visible);
|
||||||
|
|
||||||
private void assertDeleteButtonVisibility(int index, bool visible)
|
private void assertDeleteButtonVisibility(int index, bool visible)
|
||||||
=> AddAssert($"delete button {index} {(visible ? "is" : "is not")} visible", () => (playlist.ChildrenOfType<IconButton>().ElementAt(2 + index * 2).Alpha > 0) == visible);
|
=> AddAssert($"delete button {index} {(visible ? "is" : "is not")} visible", () => (playlist.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(2 + index * 2).Alpha > 0) == visible);
|
||||||
|
|
||||||
private void createPlaylist(bool allowEdit, bool allowSelection)
|
private void createPlaylist(bool allowEdit, bool allowSelection)
|
||||||
{
|
{
|
||||||
@ -278,7 +279,21 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
playlist.Items.Add(new PlaylistItem
|
playlist.Items.Add(new PlaylistItem
|
||||||
{
|
{
|
||||||
ID = i,
|
ID = i,
|
||||||
Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo },
|
Beatmap =
|
||||||
|
{
|
||||||
|
Value = i % 2 == 1
|
||||||
|
? new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo
|
||||||
|
: new BeatmapInfo
|
||||||
|
{
|
||||||
|
Metadata = new BeatmapMetadata
|
||||||
|
{
|
||||||
|
Artist = "Artist",
|
||||||
|
Author = new User { Username = "Creator name here" },
|
||||||
|
Title = "Long title used to check background colour",
|
||||||
|
},
|
||||||
|
BeatmapSet = new BeatmapSetInfo()
|
||||||
|
}
|
||||||
|
},
|
||||||
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
||||||
RequiredMods =
|
RequiredMods =
|
||||||
{
|
{
|
||||||
|
@ -8,16 +8,16 @@ using osu.Game.Users;
|
|||||||
using osuTK;
|
using osuTK;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Overlays.Chat;
|
using osu.Game.Overlays.Chat;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Online
|
namespace osu.Game.Tests.Visual.Online
|
||||||
{
|
{
|
||||||
public class TestSceneStandAloneChatDisplay : OsuTestScene
|
public class TestSceneStandAloneChatDisplay : OsuManualInputManagerTestScene
|
||||||
{
|
{
|
||||||
private readonly Channel testChannel = new Channel();
|
|
||||||
|
|
||||||
private readonly User admin = new User
|
private readonly User admin = new User
|
||||||
{
|
{
|
||||||
Username = "HappyStick",
|
Username = "HappyStick",
|
||||||
@ -46,92 +46,97 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[Cached]
|
[Cached]
|
||||||
private ChannelManager channelManager = new ChannelManager();
|
private ChannelManager channelManager = new ChannelManager();
|
||||||
|
|
||||||
private readonly TestStandAloneChatDisplay chatDisplay;
|
private TestStandAloneChatDisplay chatDisplay;
|
||||||
private readonly TestStandAloneChatDisplay chatDisplay2;
|
private int messageIdSequence;
|
||||||
|
|
||||||
|
private Channel testChannel;
|
||||||
|
|
||||||
public TestSceneStandAloneChatDisplay()
|
public TestSceneStandAloneChatDisplay()
|
||||||
{
|
{
|
||||||
Add(channelManager);
|
Add(channelManager);
|
||||||
|
|
||||||
Add(chatDisplay = new TestStandAloneChatDisplay
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
Margin = new MarginPadding(20),
|
|
||||||
Size = new Vector2(400, 80)
|
|
||||||
});
|
|
||||||
|
|
||||||
Add(chatDisplay2 = new TestStandAloneChatDisplay(true)
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreRight,
|
|
||||||
Origin = Anchor.CentreRight,
|
|
||||||
Margin = new MarginPadding(20),
|
|
||||||
Size = new Vector2(400, 150)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
[SetUp]
|
||||||
|
public void SetUp() => Schedule(() =>
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
messageIdSequence = 0;
|
||||||
|
channelManager.CurrentChannel.Value = testChannel = new Channel();
|
||||||
|
|
||||||
channelManager.CurrentChannel.Value = testChannel;
|
Children = new[]
|
||||||
|
{
|
||||||
|
chatDisplay = new TestStandAloneChatDisplay
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
Margin = new MarginPadding(20),
|
||||||
|
Size = new Vector2(400, 80),
|
||||||
|
Channel = { Value = testChannel },
|
||||||
|
},
|
||||||
|
new TestStandAloneChatDisplay(true)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreRight,
|
||||||
|
Origin = Anchor.CentreRight,
|
||||||
|
Margin = new MarginPadding(20),
|
||||||
|
Size = new Vector2(400, 150),
|
||||||
|
Channel = { Value = testChannel },
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
chatDisplay.Channel.Value = testChannel;
|
[Test]
|
||||||
chatDisplay2.Channel.Value = testChannel;
|
public void TestManyMessages()
|
||||||
|
{
|
||||||
int sequence = 0;
|
AddStep("message from admin", () => testChannel.AddNewMessages(new Message(messageIdSequence++)
|
||||||
|
|
||||||
AddStep("message from admin", () => testChannel.AddNewMessages(new Message(sequence++)
|
|
||||||
{
|
{
|
||||||
Sender = admin,
|
Sender = admin,
|
||||||
Content = "I am a wang!"
|
Content = "I am a wang!"
|
||||||
}));
|
}));
|
||||||
|
|
||||||
AddStep("message from team red", () => testChannel.AddNewMessages(new Message(sequence++)
|
AddStep("message from team red", () => testChannel.AddNewMessages(new Message(messageIdSequence++)
|
||||||
{
|
{
|
||||||
Sender = redUser,
|
Sender = redUser,
|
||||||
Content = "I am team red."
|
Content = "I am team red."
|
||||||
}));
|
}));
|
||||||
|
|
||||||
AddStep("message from team red", () => testChannel.AddNewMessages(new Message(sequence++)
|
AddStep("message from team red", () => testChannel.AddNewMessages(new Message(messageIdSequence++)
|
||||||
{
|
{
|
||||||
Sender = redUser,
|
Sender = redUser,
|
||||||
Content = "I plan to win!"
|
Content = "I plan to win!"
|
||||||
}));
|
}));
|
||||||
|
|
||||||
AddStep("message from team blue", () => testChannel.AddNewMessages(new Message(sequence++)
|
AddStep("message from team blue", () => testChannel.AddNewMessages(new Message(messageIdSequence++)
|
||||||
{
|
{
|
||||||
Sender = blueUser,
|
Sender = blueUser,
|
||||||
Content = "Not on my watch. Prepare to eat saaaaaaaaaand. Lots and lots of saaaaaaand."
|
Content = "Not on my watch. Prepare to eat saaaaaaaaaand. Lots and lots of saaaaaaand."
|
||||||
}));
|
}));
|
||||||
|
|
||||||
AddStep("message from admin", () => testChannel.AddNewMessages(new Message(sequence++)
|
AddStep("message from admin", () => testChannel.AddNewMessages(new Message(messageIdSequence++)
|
||||||
{
|
{
|
||||||
Sender = admin,
|
Sender = admin,
|
||||||
Content = "Okay okay, calm down guys. Let's do this!"
|
Content = "Okay okay, calm down guys. Let's do this!"
|
||||||
}));
|
}));
|
||||||
|
|
||||||
AddStep("message from long username", () => testChannel.AddNewMessages(new Message(sequence++)
|
AddStep("message from long username", () => testChannel.AddNewMessages(new Message(messageIdSequence++)
|
||||||
{
|
{
|
||||||
Sender = longUsernameUser,
|
Sender = longUsernameUser,
|
||||||
Content = "Hi guys, my new username is lit!"
|
Content = "Hi guys, my new username is lit!"
|
||||||
}));
|
}));
|
||||||
|
|
||||||
AddStep("message with new date", () => testChannel.AddNewMessages(new Message(sequence++)
|
AddStep("message with new date", () => testChannel.AddNewMessages(new Message(messageIdSequence++)
|
||||||
{
|
{
|
||||||
Sender = longUsernameUser,
|
Sender = longUsernameUser,
|
||||||
Content = "Message from the future!",
|
Content = "Message from the future!",
|
||||||
Timestamp = DateTimeOffset.Now
|
Timestamp = DateTimeOffset.Now
|
||||||
}));
|
}));
|
||||||
|
|
||||||
AddUntilStep("ensure still scrolled to bottom", () => chatDisplay.ScrolledToBottom);
|
checkScrolledToBottom();
|
||||||
|
|
||||||
const int messages_per_call = 10;
|
const int messages_per_call = 10;
|
||||||
AddRepeatStep("add many messages", () =>
|
AddRepeatStep("add many messages", () =>
|
||||||
{
|
{
|
||||||
for (int i = 0; i < messages_per_call; i++)
|
for (int i = 0; i < messages_per_call; i++)
|
||||||
{
|
{
|
||||||
testChannel.AddNewMessages(new Message(sequence++)
|
testChannel.AddNewMessages(new Message(messageIdSequence++)
|
||||||
{
|
{
|
||||||
Sender = longUsernameUser,
|
Sender = longUsernameUser,
|
||||||
Content = "Many messages! " + Guid.NewGuid(),
|
Content = "Many messages! " + Guid.NewGuid(),
|
||||||
@ -153,9 +158,133 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("ensure still scrolled to bottom", () => chatDisplay.ScrolledToBottom);
|
checkScrolledToBottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests that when a message gets wrapped by the chat display getting contracted while scrolled to bottom, the chat will still keep scrolling down.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestMessageWrappingKeepsAutoScrolling()
|
||||||
|
{
|
||||||
|
fillChat();
|
||||||
|
|
||||||
|
// send message with short words for text wrapping to occur when contracting chat.
|
||||||
|
sendMessage();
|
||||||
|
|
||||||
|
AddStep("contract chat", () => chatDisplay.Width -= 100);
|
||||||
|
checkScrolledToBottom();
|
||||||
|
|
||||||
|
AddStep("send another message", () => testChannel.AddNewMessages(new Message(messageIdSequence++)
|
||||||
|
{
|
||||||
|
Sender = admin,
|
||||||
|
Content = "As we were saying...",
|
||||||
|
}));
|
||||||
|
|
||||||
|
checkScrolledToBottom();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestUserScrollOverride()
|
||||||
|
{
|
||||||
|
fillChat();
|
||||||
|
|
||||||
|
sendMessage();
|
||||||
|
checkScrolledToBottom();
|
||||||
|
|
||||||
|
AddStep("User scroll up", () =>
|
||||||
|
{
|
||||||
|
InputManager.MoveMouseTo(chatDisplay.ScreenSpaceDrawQuad.Centre);
|
||||||
|
InputManager.PressButton(MouseButton.Left);
|
||||||
|
InputManager.MoveMouseTo(chatDisplay.ScreenSpaceDrawQuad.Centre + new Vector2(0, chatDisplay.ScreenSpaceDrawQuad.Height));
|
||||||
|
InputManager.ReleaseButton(MouseButton.Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
checkNotScrolledToBottom();
|
||||||
|
sendMessage();
|
||||||
|
checkNotScrolledToBottom();
|
||||||
|
|
||||||
|
AddRepeatStep("User scroll to bottom", () =>
|
||||||
|
{
|
||||||
|
InputManager.MoveMouseTo(chatDisplay.ScreenSpaceDrawQuad.Centre);
|
||||||
|
InputManager.PressButton(MouseButton.Left);
|
||||||
|
InputManager.MoveMouseTo(chatDisplay.ScreenSpaceDrawQuad.Centre - new Vector2(0, chatDisplay.ScreenSpaceDrawQuad.Height));
|
||||||
|
InputManager.ReleaseButton(MouseButton.Left);
|
||||||
|
}, 5);
|
||||||
|
|
||||||
|
checkScrolledToBottom();
|
||||||
|
sendMessage();
|
||||||
|
checkScrolledToBottom();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestLocalEchoMessageResetsScroll()
|
||||||
|
{
|
||||||
|
fillChat();
|
||||||
|
|
||||||
|
sendMessage();
|
||||||
|
checkScrolledToBottom();
|
||||||
|
|
||||||
|
AddStep("User scroll up", () =>
|
||||||
|
{
|
||||||
|
InputManager.MoveMouseTo(chatDisplay.ScreenSpaceDrawQuad.Centre);
|
||||||
|
InputManager.PressButton(MouseButton.Left);
|
||||||
|
InputManager.MoveMouseTo(chatDisplay.ScreenSpaceDrawQuad.Centre + new Vector2(0, chatDisplay.ScreenSpaceDrawQuad.Height));
|
||||||
|
InputManager.ReleaseButton(MouseButton.Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
checkNotScrolledToBottom();
|
||||||
|
sendMessage();
|
||||||
|
checkNotScrolledToBottom();
|
||||||
|
|
||||||
|
sendLocalMessage();
|
||||||
|
checkScrolledToBottom();
|
||||||
|
|
||||||
|
sendMessage();
|
||||||
|
checkScrolledToBottom();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillChat()
|
||||||
|
{
|
||||||
|
AddStep("fill chat", () =>
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
testChannel.AddNewMessages(new Message(messageIdSequence++)
|
||||||
|
{
|
||||||
|
Sender = longUsernameUser,
|
||||||
|
Content = $"some stuff {Guid.NewGuid()}",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
checkScrolledToBottom();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendMessage()
|
||||||
|
{
|
||||||
|
AddStep("send lorem ipsum", () => testChannel.AddNewMessages(new Message(messageIdSequence++)
|
||||||
|
{
|
||||||
|
Sender = longUsernameUser,
|
||||||
|
Content = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et bibendum velit.",
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendLocalMessage()
|
||||||
|
{
|
||||||
|
AddStep("send local echo", () => testChannel.AddLocalEcho(new LocalEchoMessage
|
||||||
|
{
|
||||||
|
Sender = longUsernameUser,
|
||||||
|
Content = "This is a local echo message.",
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkScrolledToBottom() =>
|
||||||
|
AddUntilStep("is scrolled to bottom", () => chatDisplay.ScrolledToBottom);
|
||||||
|
|
||||||
|
private void checkNotScrolledToBottom() =>
|
||||||
|
AddUntilStep("not scrolled to bottom", () => !chatDisplay.ScrolledToBottom);
|
||||||
|
|
||||||
private class TestStandAloneChatDisplay : StandAloneChatDisplay
|
private class TestStandAloneChatDisplay : StandAloneChatDisplay
|
||||||
{
|
{
|
||||||
public TestStandAloneChatDisplay(bool textbox = false)
|
public TestStandAloneChatDisplay(bool textbox = false)
|
||||||
@ -165,7 +294,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
|
|
||||||
protected DrawableChannel DrawableChannel => InternalChildren.OfType<DrawableChannel>().First();
|
protected DrawableChannel DrawableChannel => InternalChildren.OfType<DrawableChannel>().First();
|
||||||
|
|
||||||
protected OsuScrollContainer ScrollContainer => (OsuScrollContainer)((Container)DrawableChannel.Child).Child;
|
protected UserTrackingScrollContainer ScrollContainer => (UserTrackingScrollContainer)((Container)DrawableChannel.Child).Child;
|
||||||
|
|
||||||
public FillFlowContainer FillFlow => (FillFlowContainer)ScrollContainer.Child;
|
public FillFlowContainer FillFlow => (FillFlowContainer)ScrollContainer.Child;
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
@ -28,12 +27,7 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
{
|
{
|
||||||
base.SetUpSteps();
|
base.SetUpSteps();
|
||||||
|
|
||||||
AddStep("push screen", () => LoadScreen(loungeScreen = new PlaylistsLoungeSubScreen
|
AddStep("push screen", () => LoadScreen(loungeScreen = new PlaylistsLoungeSubScreen()));
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Width = 0.5f,
|
|
||||||
}));
|
|
||||||
|
|
||||||
AddUntilStep("wait for present", () => loungeScreen.IsCurrentScreen());
|
AddUntilStep("wait for present", () => loungeScreen.IsCurrentScreen());
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
|
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
|
||||||
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
|
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
|
||||||
|
<PackageReference Include="Moq" Version="4.16.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Project">
|
<PropertyGroup Label="Project">
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
|
@ -139,7 +139,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
// this is random as hell but taken straight from osu-stable.
|
// this is random as hell but taken straight from osu-stable.
|
||||||
frameDelay = Math.Round(0.015 * frameDelay) * 1.186 * (1000 / 60f);
|
frameDelay = Math.Round(0.015 * frameDelay) * 1.186 * (1000 / 60f);
|
||||||
|
|
||||||
var loopType = split.Length > 8 ? (AnimationLoopType)Enum.Parse(typeof(AnimationLoopType), split[8]) : AnimationLoopType.LoopForever;
|
var loopType = split.Length > 8 ? parseAnimationLoopType(split[8]) : AnimationLoopType.LoopForever;
|
||||||
storyboardSprite = new StoryboardAnimation(path, origin, new Vector2(x, y), frameCount, frameDelay, loopType);
|
storyboardSprite = new StoryboardAnimation(path, origin, new Vector2(x, y), frameCount, frameDelay, loopType);
|
||||||
storyboard.GetLayer(layer).Add(storyboardSprite);
|
storyboard.GetLayer(layer).Add(storyboardSprite);
|
||||||
break;
|
break;
|
||||||
@ -341,6 +341,12 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private AnimationLoopType parseAnimationLoopType(string value)
|
||||||
|
{
|
||||||
|
var parsed = (AnimationLoopType)Enum.Parse(typeof(AnimationLoopType), value);
|
||||||
|
return Enum.IsDefined(typeof(AnimationLoopType), parsed) ? parsed : AnimationLoopType.LoopForever;
|
||||||
|
}
|
||||||
|
|
||||||
private void handleVariables(string line)
|
private void handleVariables(string line)
|
||||||
{
|
{
|
||||||
var pair = SplitKeyVal(line, '=');
|
var pair = SplitKeyVal(line, '=');
|
||||||
|
@ -25,6 +25,8 @@ namespace osu.Game.Graphics.Containers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UserScrolling { get; private set; }
|
public bool UserScrolling { get; private set; }
|
||||||
|
|
||||||
|
public void CancelUserScroll() => UserScrolling = false;
|
||||||
|
|
||||||
public UserTrackingScrollContainer()
|
public UserTrackingScrollContainer()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -45,5 +47,11 @@ namespace osu.Game.Graphics.Containers
|
|||||||
UserScrolling = false;
|
UserScrolling = false;
|
||||||
base.ScrollTo(value, animated, distanceDecay);
|
base.ScrollTo(value, animated, distanceDecay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public new void ScrollToEnd(bool animated = true, bool allowDuringDrag = false)
|
||||||
|
{
|
||||||
|
UserScrolling = false;
|
||||||
|
base.ScrollToEnd(animated, allowDuringDrag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,54 +4,38 @@
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Online;
|
using osu.Game.Online;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
{
|
{
|
||||||
public class DownloadButton : OsuAnimatedButton
|
public class DownloadButton : GrayButton
|
||||||
{
|
{
|
||||||
public readonly Bindable<DownloadState> State = new Bindable<DownloadState>();
|
|
||||||
|
|
||||||
private readonly SpriteIcon icon;
|
|
||||||
private readonly SpriteIcon checkmark;
|
|
||||||
private readonly Box background;
|
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuColour colours { get; set; }
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
|
public readonly Bindable<DownloadState> State = new Bindable<DownloadState>();
|
||||||
|
|
||||||
|
private SpriteIcon checkmark;
|
||||||
|
|
||||||
public DownloadButton()
|
public DownloadButton()
|
||||||
|
: base(FontAwesome.Solid.Download)
|
||||||
{
|
{
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
background = new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Depth = float.MaxValue
|
|
||||||
},
|
|
||||||
icon = new SpriteIcon
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Size = new Vector2(13),
|
|
||||||
Icon = FontAwesome.Solid.Download,
|
|
||||||
},
|
|
||||||
checkmark = new SpriteIcon
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
X = 8,
|
|
||||||
Size = Vector2.Zero,
|
|
||||||
Icon = FontAwesome.Solid.Check,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
|
AddInternal(checkmark = new SpriteIcon
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
X = 8,
|
||||||
|
Size = Vector2.Zero,
|
||||||
|
Icon = FontAwesome.Solid.Check,
|
||||||
|
});
|
||||||
|
|
||||||
State.BindValueChanged(updateState, true);
|
State.BindValueChanged(updateState, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,27 +44,27 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
switch (state.NewValue)
|
switch (state.NewValue)
|
||||||
{
|
{
|
||||||
case DownloadState.NotDownloaded:
|
case DownloadState.NotDownloaded:
|
||||||
background.FadeColour(colours.Gray4, 500, Easing.InOutExpo);
|
Background.FadeColour(colours.Gray4, 500, Easing.InOutExpo);
|
||||||
icon.MoveToX(0, 500, Easing.InOutExpo);
|
Icon.MoveToX(0, 500, Easing.InOutExpo);
|
||||||
checkmark.ScaleTo(Vector2.Zero, 500, Easing.InOutExpo);
|
checkmark.ScaleTo(Vector2.Zero, 500, Easing.InOutExpo);
|
||||||
TooltipText = "Download";
|
TooltipText = "Download";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DownloadState.Downloading:
|
case DownloadState.Downloading:
|
||||||
background.FadeColour(colours.Blue, 500, Easing.InOutExpo);
|
Background.FadeColour(colours.Blue, 500, Easing.InOutExpo);
|
||||||
icon.MoveToX(0, 500, Easing.InOutExpo);
|
Icon.MoveToX(0, 500, Easing.InOutExpo);
|
||||||
checkmark.ScaleTo(Vector2.Zero, 500, Easing.InOutExpo);
|
checkmark.ScaleTo(Vector2.Zero, 500, Easing.InOutExpo);
|
||||||
TooltipText = "Downloading...";
|
TooltipText = "Downloading...";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DownloadState.Importing:
|
case DownloadState.Importing:
|
||||||
background.FadeColour(colours.Yellow, 500, Easing.InOutExpo);
|
Background.FadeColour(colours.Yellow, 500, Easing.InOutExpo);
|
||||||
TooltipText = "Importing";
|
TooltipText = "Importing";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DownloadState.LocallyAvailable:
|
case DownloadState.LocallyAvailable:
|
||||||
background.FadeColour(colours.Green, 500, Easing.InOutExpo);
|
Background.FadeColour(colours.Green, 500, Easing.InOutExpo);
|
||||||
icon.MoveToX(-8, 500, Easing.InOutExpo);
|
Icon.MoveToX(-8, 500, Easing.InOutExpo);
|
||||||
checkmark.ScaleTo(new Vector2(13), 500, Easing.InOutExpo);
|
checkmark.ScaleTo(new Vector2(13), 500, Easing.InOutExpo);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
48
osu.Game/Graphics/UserInterface/GrayButton.cs
Normal file
48
osu.Game/Graphics/UserInterface/GrayButton.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// 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.Shapes;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Graphics.UserInterface
|
||||||
|
{
|
||||||
|
public class GrayButton : OsuAnimatedButton
|
||||||
|
{
|
||||||
|
protected SpriteIcon Icon { get; private set; }
|
||||||
|
protected Box Background { get; private set; }
|
||||||
|
|
||||||
|
private readonly IconUsage icon;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
|
public GrayButton(IconUsage icon)
|
||||||
|
{
|
||||||
|
this.icon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
Background = new Box
|
||||||
|
{
|
||||||
|
Colour = colours.Gray4,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Depth = float.MaxValue
|
||||||
|
},
|
||||||
|
Icon = new SpriteIcon
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(13),
|
||||||
|
Icon = icon,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -468,6 +468,12 @@ namespace osu.Game
|
|||||||
private void modsChanged(ValueChangedEvent<IReadOnlyList<Mod>> mods)
|
private void modsChanged(ValueChangedEvent<IReadOnlyList<Mod>> mods)
|
||||||
{
|
{
|
||||||
updateModDefaults();
|
updateModDefaults();
|
||||||
|
|
||||||
|
if (!ModUtils.CheckValidForGameplay(mods.NewValue, out var invalid))
|
||||||
|
{
|
||||||
|
// ensure we always have a valid set of mods.
|
||||||
|
SelectedMods.Value = mods.NewValue.Except(invalid).ToArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateModDefaults()
|
private void updateModDefaults()
|
||||||
|
@ -16,6 +16,7 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Chat
|
namespace osu.Game.Overlays.Chat
|
||||||
@ -24,7 +25,7 @@ namespace osu.Game.Overlays.Chat
|
|||||||
{
|
{
|
||||||
public readonly Channel Channel;
|
public readonly Channel Channel;
|
||||||
protected FillFlowContainer ChatLineFlow;
|
protected FillFlowContainer ChatLineFlow;
|
||||||
private OsuScrollContainer scroll;
|
private ChannelScrollContainer scroll;
|
||||||
|
|
||||||
private bool scrollbarVisible = true;
|
private bool scrollbarVisible = true;
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ namespace osu.Game.Overlays.Chat
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Masking = true,
|
Masking = true,
|
||||||
Child = scroll = new OsuScrollContainer
|
Child = scroll = new ChannelScrollContainer
|
||||||
{
|
{
|
||||||
ScrollbarVisible = scrollbarVisible,
|
ScrollbarVisible = scrollbarVisible,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -80,12 +81,6 @@ namespace osu.Game.Overlays.Chat
|
|||||||
Channel.PendingMessageResolved += pendingMessageResolved;
|
Channel.PendingMessageResolved += pendingMessageResolved;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
scrollToEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
@ -113,8 +108,6 @@ namespace osu.Game.Overlays.Chat
|
|||||||
ChatLineFlow.Clear();
|
ChatLineFlow.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shouldScrollToEnd = scroll.IsScrolledToEnd(10) || !chatLines.Any() || newMessages.Any(m => m is LocalMessage);
|
|
||||||
|
|
||||||
// Add up to last Channel.MAX_HISTORY messages
|
// Add up to last Channel.MAX_HISTORY messages
|
||||||
var displayMessages = newMessages.Skip(Math.Max(0, newMessages.Count() - Channel.MAX_HISTORY));
|
var displayMessages = newMessages.Skip(Math.Max(0, newMessages.Count() - Channel.MAX_HISTORY));
|
||||||
|
|
||||||
@ -153,8 +146,10 @@ namespace osu.Game.Overlays.Chat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldScrollToEnd)
|
// due to the scroll adjusts from old messages removal above, a scroll-to-end must be enforced,
|
||||||
scrollToEnd();
|
// to avoid making the container think the user has scrolled back up and unwantedly disable auto-scrolling.
|
||||||
|
if (newMessages.Any(m => m is LocalMessage))
|
||||||
|
scroll.ScrollToEnd();
|
||||||
});
|
});
|
||||||
|
|
||||||
private void pendingMessageResolved(Message existing, Message updated) => Schedule(() =>
|
private void pendingMessageResolved(Message existing, Message updated) => Schedule(() =>
|
||||||
@ -178,8 +173,6 @@ namespace osu.Game.Overlays.Chat
|
|||||||
|
|
||||||
private IEnumerable<ChatLine> chatLines => ChatLineFlow.Children.OfType<ChatLine>();
|
private IEnumerable<ChatLine> chatLines => ChatLineFlow.Children.OfType<ChatLine>();
|
||||||
|
|
||||||
private void scrollToEnd() => ScheduleAfterChildren(() => scroll.ScrollToEnd());
|
|
||||||
|
|
||||||
public class DaySeparator : Container
|
public class DaySeparator : Container
|
||||||
{
|
{
|
||||||
public float TextSize
|
public float TextSize
|
||||||
@ -243,5 +236,51 @@ namespace osu.Game.Overlays.Chat
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An <see cref="OsuScrollContainer"/> with functionality to automatically scroll whenever the maximum scrollable distance increases.
|
||||||
|
/// </summary>
|
||||||
|
private class ChannelScrollContainer : UserTrackingScrollContainer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The chat will be automatically scrolled to end if and only if
|
||||||
|
/// the distance between the current scroll position and the end of the scroll
|
||||||
|
/// is less than this value.
|
||||||
|
/// </summary>
|
||||||
|
private const float auto_scroll_leniency = 10f;
|
||||||
|
|
||||||
|
private float? lastExtent;
|
||||||
|
|
||||||
|
protected override void OnUserScroll(float value, bool animated = true, double? distanceDecay = default)
|
||||||
|
{
|
||||||
|
base.OnUserScroll(value, animated, distanceDecay);
|
||||||
|
lastExtent = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
// If the user has scrolled to the bottom of the container, we should resume tracking new content.
|
||||||
|
if (UserScrolling && IsScrolledToEnd(auto_scroll_leniency))
|
||||||
|
CancelUserScroll();
|
||||||
|
|
||||||
|
// If the user hasn't overridden our behaviour and there has been new content added to the container, we should update our scroll position to track it.
|
||||||
|
bool requiresScrollUpdate = !UserScrolling && (lastExtent == null || Precision.AlmostBigger(ScrollableExtent, lastExtent.Value));
|
||||||
|
|
||||||
|
if (requiresScrollUpdate)
|
||||||
|
{
|
||||||
|
// Schedule required to allow FillFlow to be the correct size.
|
||||||
|
Schedule(() =>
|
||||||
|
{
|
||||||
|
if (!UserScrolling)
|
||||||
|
{
|
||||||
|
ScrollToEnd();
|
||||||
|
lastExtent = ScrollableExtent;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,26 +11,23 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using Humanizer;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Mods
|
namespace osu.Game.Overlays.Mods
|
||||||
{
|
{
|
||||||
public abstract class ModSection : Container
|
public class ModSection : CompositeDrawable
|
||||||
{
|
{
|
||||||
private readonly OsuSpriteText headerLabel;
|
private readonly Drawable header;
|
||||||
|
|
||||||
public FillFlowContainer<ModButtonEmpty> ButtonsContainer { get; }
|
public FillFlowContainer<ModButtonEmpty> ButtonsContainer { get; }
|
||||||
|
|
||||||
public Action<Mod> Action;
|
public Action<Mod> Action;
|
||||||
protected abstract Key[] ToggleKeys { get; }
|
|
||||||
public abstract ModType ModType { get; }
|
|
||||||
|
|
||||||
public string Header
|
public Key[] ToggleKeys;
|
||||||
{
|
|
||||||
get => headerLabel.Text;
|
public readonly ModType ModType;
|
||||||
set => headerLabel.Text = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Mod> SelectedMods => buttons.Select(b => b.SelectedMod).Where(m => m != null);
|
public IEnumerable<Mod> SelectedMods => buttons.Select(b => b.SelectedMod).Where(m => m != null);
|
||||||
|
|
||||||
@ -61,7 +58,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
if (modContainers.Length == 0)
|
if (modContainers.Length == 0)
|
||||||
{
|
{
|
||||||
ModIconsLoaded = true;
|
ModIconsLoaded = true;
|
||||||
headerLabel.Hide();
|
header.Hide();
|
||||||
Hide();
|
Hide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -76,7 +73,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
buttons = modContainers.OfType<ModButton>().ToArray();
|
buttons = modContainers.OfType<ModButton>().ToArray();
|
||||||
|
|
||||||
headerLabel.FadeIn(200);
|
header.FadeIn(200);
|
||||||
this.FadeIn(200);
|
this.FadeIn(200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,23 +150,19 @@ namespace osu.Game.Overlays.Mods
|
|||||||
button.Deselect();
|
button.Deselect();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ModSection()
|
public ModSection(ModType type)
|
||||||
{
|
{
|
||||||
|
ModType = type;
|
||||||
|
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
|
|
||||||
Origin = Anchor.TopCentre;
|
Origin = Anchor.TopCentre;
|
||||||
Anchor = Anchor.TopCentre;
|
Anchor = Anchor.TopCentre;
|
||||||
|
|
||||||
Children = new Drawable[]
|
InternalChildren = new[]
|
||||||
{
|
{
|
||||||
headerLabel = new OsuSpriteText
|
header = CreateHeader(type.Humanize(LetterCasing.Title)),
|
||||||
{
|
|
||||||
Origin = Anchor.TopLeft,
|
|
||||||
Anchor = Anchor.TopLeft,
|
|
||||||
Position = new Vector2(0f, 0f),
|
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.Bold)
|
|
||||||
},
|
|
||||||
ButtonsContainer = new FillFlowContainer<ModButtonEmpty>
|
ButtonsContainer = new FillFlowContainer<ModButtonEmpty>
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
@ -185,5 +178,11 @@ namespace osu.Game.Overlays.Mods
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual Drawable CreateHeader(string text) => new OsuSpriteText
|
||||||
|
{
|
||||||
|
Font = OsuFont.GetFont(weight: FontWeight.Bold),
|
||||||
|
Text = text
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ using osu.Game.Graphics.Containers;
|
|||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Overlays.Mods.Sections;
|
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -190,13 +189,31 @@ namespace osu.Game.Overlays.Mods
|
|||||||
Width = content_width,
|
Width = content_width,
|
||||||
LayoutDuration = 200,
|
LayoutDuration = 200,
|
||||||
LayoutEasing = Easing.OutQuint,
|
LayoutEasing = Easing.OutQuint,
|
||||||
Children = new ModSection[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
new DifficultyReductionSection { Action = modButtonPressed },
|
CreateModSection(ModType.DifficultyReduction).With(s =>
|
||||||
new DifficultyIncreaseSection { Action = modButtonPressed },
|
{
|
||||||
new AutomationSection { Action = modButtonPressed },
|
s.ToggleKeys = new[] { Key.Q, Key.W, Key.E, Key.R, Key.T, Key.Y, Key.U, Key.I, Key.O, Key.P };
|
||||||
new ConversionSection { Action = modButtonPressed },
|
s.Action = modButtonPressed;
|
||||||
new FunSection { Action = modButtonPressed },
|
}),
|
||||||
|
CreateModSection(ModType.DifficultyIncrease).With(s =>
|
||||||
|
{
|
||||||
|
s.ToggleKeys = new[] { Key.A, Key.S, Key.D, Key.F, Key.G, Key.H, Key.J, Key.K, Key.L };
|
||||||
|
s.Action = modButtonPressed;
|
||||||
|
}),
|
||||||
|
CreateModSection(ModType.Automation).With(s =>
|
||||||
|
{
|
||||||
|
s.ToggleKeys = new[] { Key.Z, Key.X, Key.C, Key.V, Key.B, Key.N, Key.M };
|
||||||
|
s.Action = modButtonPressed;
|
||||||
|
}),
|
||||||
|
CreateModSection(ModType.Conversion).With(s =>
|
||||||
|
{
|
||||||
|
s.Action = modButtonPressed;
|
||||||
|
}),
|
||||||
|
CreateModSection(ModType.Fun).With(s =>
|
||||||
|
{
|
||||||
|
s.Action = modButtonPressed;
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -454,6 +471,13 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
private void refreshSelectedMods() => SelectedMods.Value = ModSectionsContainer.Children.SelectMany(s => s.SelectedMods).ToArray();
|
private void refreshSelectedMods() => SelectedMods.Value = ModSectionsContainer.Children.SelectMany(s => s.SelectedMods).ToArray();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a <see cref="ModSection"/> that groups <see cref="Mod"/>s with the same <see cref="ModType"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="type">The <see cref="ModType"/> of <see cref="Mod"/>s in the section.</param>
|
||||||
|
/// <returns>The <see cref="ModSection"/>.</returns>
|
||||||
|
protected virtual ModSection CreateModSection(ModType type) => new ModSection(type);
|
||||||
|
|
||||||
#region Disposal
|
#region Disposal
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
|
@ -1,19 +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 osu.Game.Rulesets.Mods;
|
|
||||||
using osuTK.Input;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Mods.Sections
|
|
||||||
{
|
|
||||||
public class AutomationSection : ModSection
|
|
||||||
{
|
|
||||||
protected override Key[] ToggleKeys => new[] { Key.Z, Key.X, Key.C, Key.V, Key.B, Key.N, Key.M };
|
|
||||||
public override ModType ModType => ModType.Automation;
|
|
||||||
|
|
||||||
public AutomationSection()
|
|
||||||
{
|
|
||||||
Header = @"Automation";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +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 osu.Game.Rulesets.Mods;
|
|
||||||
using osuTK.Input;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Mods.Sections
|
|
||||||
{
|
|
||||||
public class ConversionSection : ModSection
|
|
||||||
{
|
|
||||||
protected override Key[] ToggleKeys => null;
|
|
||||||
public override ModType ModType => ModType.Conversion;
|
|
||||||
|
|
||||||
public ConversionSection()
|
|
||||||
{
|
|
||||||
Header = @"Conversion";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +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 osu.Game.Rulesets.Mods;
|
|
||||||
using osuTK.Input;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Mods.Sections
|
|
||||||
{
|
|
||||||
public class DifficultyIncreaseSection : ModSection
|
|
||||||
{
|
|
||||||
protected override Key[] ToggleKeys => new[] { Key.A, Key.S, Key.D, Key.F, Key.G, Key.H, Key.J, Key.K, Key.L };
|
|
||||||
public override ModType ModType => ModType.DifficultyIncrease;
|
|
||||||
|
|
||||||
public DifficultyIncreaseSection()
|
|
||||||
{
|
|
||||||
Header = @"Difficulty Increase";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +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 osu.Game.Rulesets.Mods;
|
|
||||||
using osuTK.Input;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Mods.Sections
|
|
||||||
{
|
|
||||||
public class DifficultyReductionSection : ModSection
|
|
||||||
{
|
|
||||||
protected override Key[] ToggleKeys => new[] { Key.Q, Key.W, Key.E, Key.R, Key.T, Key.Y, Key.U, Key.I, Key.O, Key.P };
|
|
||||||
public override ModType ModType => ModType.DifficultyReduction;
|
|
||||||
|
|
||||||
public DifficultyReductionSection()
|
|
||||||
{
|
|
||||||
Header = @"Difficulty Reduction";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +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 osu.Game.Rulesets.Mods;
|
|
||||||
using osuTK.Input;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Mods.Sections
|
|
||||||
{
|
|
||||||
public class FunSection : ModSection
|
|
||||||
{
|
|
||||||
protected override Key[] ToggleKeys => null;
|
|
||||||
public override ModType ModType => ModType.Fun;
|
|
||||||
|
|
||||||
public FunSection()
|
|
||||||
{
|
|
||||||
Header = @"Fun";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The point in the beatmap at which the final ramping rate should be reached.
|
/// The point in the beatmap at which the final ramping rate should be reached.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private const double final_rate_progress = 0.75f;
|
public const double FINAL_RATE_PROGRESS = 0.75f;
|
||||||
|
|
||||||
[SettingSource("Initial rate", "The starting speed of the track")]
|
[SettingSource("Initial rate", "The starting speed of the track")]
|
||||||
public abstract BindableNumber<double> InitialRate { get; }
|
public abstract BindableNumber<double> InitialRate { get; }
|
||||||
@ -66,17 +66,18 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
|
|
||||||
public virtual void ApplyToBeatmap(IBeatmap beatmap)
|
public virtual void ApplyToBeatmap(IBeatmap beatmap)
|
||||||
{
|
{
|
||||||
HitObject lastObject = beatmap.HitObjects.LastOrDefault();
|
|
||||||
|
|
||||||
SpeedChange.SetDefault();
|
SpeedChange.SetDefault();
|
||||||
|
|
||||||
beginRampTime = beatmap.HitObjects.FirstOrDefault()?.StartTime ?? 0;
|
double firstObjectStart = beatmap.HitObjects.FirstOrDefault()?.StartTime ?? 0;
|
||||||
finalRateTime = final_rate_progress * (lastObject?.GetEndTime() ?? 0);
|
double lastObjectEnd = beatmap.HitObjects.LastOrDefault()?.GetEndTime() ?? 0;
|
||||||
|
|
||||||
|
beginRampTime = firstObjectStart;
|
||||||
|
finalRateTime = firstObjectStart + FINAL_RATE_PROGRESS * (lastObjectEnd - firstObjectStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Update(Playfield playfield)
|
public virtual void Update(Playfield playfield)
|
||||||
{
|
{
|
||||||
applyRateAdjustment((track.CurrentTime - beginRampTime) / finalRateTime);
|
applyRateAdjustment((track.CurrentTime - beginRampTime) / Math.Max(1, finalRateTime - beginRampTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -109,7 +109,16 @@ namespace osu.Game.Screens.Edit
|
|||||||
if (Beatmap.Value is DummyWorkingBeatmap)
|
if (Beatmap.Value is DummyWorkingBeatmap)
|
||||||
{
|
{
|
||||||
isNewBeatmap = true;
|
isNewBeatmap = true;
|
||||||
Beatmap.Value = beatmapManager.CreateNew(Ruleset.Value, api.LocalUser.Value);
|
|
||||||
|
var newBeatmap = beatmapManager.CreateNew(Ruleset.Value, api.LocalUser.Value);
|
||||||
|
|
||||||
|
// this is a bit haphazard, but guards against setting the lease Beatmap bindable if
|
||||||
|
// the editor has already been exited.
|
||||||
|
if (!ValidForPush)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// this probably shouldn't be set in the asynchronous load method, but everything following relies on it.
|
||||||
|
Beatmap.Value = newBeatmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
beatDivisor.Value = Beatmap.Value.BeatmapInfo.BeatDivisor;
|
beatDivisor.Value = Beatmap.Value.BeatmapInfo.BeatDivisor;
|
||||||
|
@ -124,101 +124,111 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
modDisplay.Current.Value = requiredMods.ToArray();
|
modDisplay.Current.Value = requiredMods.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Drawable CreateContent() => maskingContainer = new Container
|
protected override Drawable CreateContent()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
Action<SpriteText> fontParameters = s => s.Font = OsuFont.Default.With(weight: FontWeight.SemiBold);
|
||||||
Height = 50,
|
|
||||||
Masking = true,
|
return maskingContainer = new Container
|
||||||
CornerRadius = 10,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
{
|
||||||
new Box // A transparent box that forces the border to be drawn if the panel background is opaque
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = 50,
|
||||||
|
Masking = true,
|
||||||
|
CornerRadius = 10,
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
new Box // A transparent box that forces the border to be drawn if the panel background is opaque
|
||||||
Alpha = 0,
|
|
||||||
AlwaysPresent = true
|
|
||||||
},
|
|
||||||
new PanelBackground
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Beatmap = { BindTarget = beatmap }
|
|
||||||
},
|
|
||||||
new FillFlowContainer
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Padding = new MarginPadding { Left = 8 },
|
|
||||||
Spacing = new Vector2(8, 0),
|
|
||||||
Direction = FillDirection.Horizontal,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
{
|
||||||
difficultyIconContainer = new Container
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = 0,
|
||||||
|
AlwaysPresent = true
|
||||||
|
},
|
||||||
|
new PanelBackground
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Beatmap = { BindTarget = beatmap }
|
||||||
|
},
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Padding = new MarginPadding { Left = 8 },
|
||||||
|
Spacing = new Vector2(8, 0),
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
difficultyIconContainer = new Container
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
},
|
|
||||||
new FillFlowContainer
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Direction = FillDirection.Vertical,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
{
|
||||||
beatmapText = new LinkFlowContainer { AutoSizeAxes = Axes.Both },
|
Anchor = Anchor.CentreLeft,
|
||||||
new FillFlowContainer
|
Origin = Anchor.CentreLeft,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
beatmapText = new LinkFlowContainer(fontParameters) { AutoSizeAxes = Axes.Both },
|
||||||
Direction = FillDirection.Horizontal,
|
new FillFlowContainer
|
||||||
Spacing = new Vector2(10f, 0),
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
{
|
||||||
new FillFlowContainer
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Spacing = new Vector2(10f, 0),
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
new FillFlowContainer
|
||||||
Direction = FillDirection.Horizontal,
|
|
||||||
Spacing = new Vector2(10f, 0),
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
{
|
||||||
authorText = new LinkFlowContainer { AutoSizeAxes = Axes.Both },
|
AutoSizeAxes = Axes.Both,
|
||||||
explicitContentPill = new ExplicitContentBeatmapPill
|
Direction = FillDirection.Horizontal,
|
||||||
|
Spacing = new Vector2(10f, 0),
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
Alpha = 0f,
|
authorText = new LinkFlowContainer(fontParameters) { AutoSizeAxes = Axes.Both },
|
||||||
Anchor = Anchor.CentreLeft,
|
explicitContentPill = new ExplicitContentBeatmapPill
|
||||||
Origin = Anchor.CentreLeft,
|
{
|
||||||
Margin = new MarginPadding { Top = 3f },
|
Alpha = 0f,
|
||||||
}
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
Margin = new MarginPadding { Top = 3f },
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
new Container
|
||||||
new Container
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Child = modDisplay = new ModDisplay
|
|
||||||
{
|
{
|
||||||
Scale = new Vector2(0.4f),
|
Anchor = Anchor.CentreLeft,
|
||||||
DisplayUnrankedText = false,
|
Origin = Anchor.CentreLeft,
|
||||||
ExpansionMode = ExpansionMode.AlwaysExpanded
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Child = modDisplay = new ModDisplay
|
||||||
|
{
|
||||||
|
Scale = new Vector2(0.4f),
|
||||||
|
DisplayUnrankedText = false,
|
||||||
|
ExpansionMode = ExpansionMode.AlwaysExpanded
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreRight,
|
||||||
|
Origin = Anchor.CentreRight,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Spacing = new Vector2(5),
|
||||||
|
X = -10,
|
||||||
|
ChildrenEnumerable = CreateButtons().Select(button => button.With(b =>
|
||||||
|
{
|
||||||
|
b.Anchor = Anchor.Centre;
|
||||||
|
b.Origin = Anchor.Centre;
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
},
|
|
||||||
new FillFlowContainer
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreRight,
|
|
||||||
Origin = Anchor.CentreRight,
|
|
||||||
Direction = FillDirection.Horizontal,
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
X = -18,
|
|
||||||
ChildrenEnumerable = CreateButtons()
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
protected virtual IEnumerable<Drawable> CreateButtons() =>
|
protected virtual IEnumerable<Drawable> CreateButtons() =>
|
||||||
new Drawable[]
|
new Drawable[]
|
||||||
@ -227,14 +237,29 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
{
|
{
|
||||||
Size = new Vector2(50, 30)
|
Size = new Vector2(50, 30)
|
||||||
},
|
},
|
||||||
new IconButton
|
new PlaylistRemoveButton
|
||||||
{
|
{
|
||||||
Icon = FontAwesome.Solid.MinusSquare,
|
Size = new Vector2(30, 30),
|
||||||
Alpha = allowEdit ? 1 : 0,
|
Alpha = allowEdit ? 1 : 0,
|
||||||
Action = () => RequestDeletion?.Invoke(Model),
|
Action = () => RequestDeletion?.Invoke(Model),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public class PlaylistRemoveButton : GrayButton
|
||||||
|
{
|
||||||
|
public PlaylistRemoveButton()
|
||||||
|
: base(FontAwesome.Solid.MinusSquare)
|
||||||
|
{
|
||||||
|
TooltipText = "Remove from playlist";
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
Icon.Scale = new Vector2(0.8f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
{
|
{
|
||||||
if (allowSelection)
|
if (allowSelection)
|
||||||
@ -318,24 +343,18 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
Colour = Color4.Black,
|
Colour = Color4.Black,
|
||||||
Width = 0.4f,
|
Width = 0.4f,
|
||||||
},
|
},
|
||||||
// Piecewise-linear gradient with 3 segments to make it appear smoother
|
// Piecewise-linear gradient with 2 segments to make it appear smoother
|
||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = ColourInfo.GradientHorizontal(Color4.Black, new Color4(0f, 0f, 0f, 0.9f)),
|
Colour = ColourInfo.GradientHorizontal(Color4.Black, new Color4(0f, 0f, 0f, 0.7f)),
|
||||||
Width = 0.05f,
|
Width = 0.4f,
|
||||||
},
|
},
|
||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = ColourInfo.GradientHorizontal(new Color4(0f, 0f, 0f, 0.9f), new Color4(0f, 0f, 0f, 0.1f)),
|
Colour = ColourInfo.GradientHorizontal(new Color4(0f, 0f, 0f, 0.7f), new Color4(0, 0, 0, 0.4f)),
|
||||||
Width = 0.2f,
|
Width = 0.4f,
|
||||||
},
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = ColourInfo.GradientHorizontal(new Color4(0f, 0f, 0f, 0.1f), new Color4(0, 0, 0, 0)),
|
|
||||||
Width = 0.05f,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
|||||||
Child = new GridContainer
|
Child = new GridContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = 300,
|
Height = 500,
|
||||||
Content = new[]
|
Content = new[]
|
||||||
{
|
{
|
||||||
new Drawable[]
|
new Drawable[]
|
||||||
|
@ -353,7 +353,7 @@ namespace osu.Game.Screens.Play
|
|||||||
},
|
},
|
||||||
skipOverlay = new SkipOverlay(DrawableRuleset.GameplayStartTime)
|
skipOverlay = new SkipOverlay(DrawableRuleset.GameplayStartTime)
|
||||||
{
|
{
|
||||||
RequestSkip = GameplayClockContainer.Skip
|
RequestSkip = performUserRequestedSkip
|
||||||
},
|
},
|
||||||
FailOverlay = new FailOverlay
|
FailOverlay = new FailOverlay
|
||||||
{
|
{
|
||||||
@ -488,6 +488,17 @@ namespace osu.Game.Screens.Play
|
|||||||
this.Exit();
|
this.Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void performUserRequestedSkip()
|
||||||
|
{
|
||||||
|
// user requested skip
|
||||||
|
// disable sample playback to stop currently playing samples and perform skip
|
||||||
|
samplePlaybackDisabled.Value = true;
|
||||||
|
GameplayClockContainer.Skip();
|
||||||
|
|
||||||
|
// return samplePlaybackDisabled.Value to what is defined by the beatmap's current state
|
||||||
|
updateSampleDisabledState();
|
||||||
|
}
|
||||||
|
|
||||||
private void performUserRequestedExit()
|
private void performUserRequestedExit()
|
||||||
{
|
{
|
||||||
if (ValidForResume && HasFailed && !FailOverlay.IsPresent)
|
if (ValidForResume && HasFailed && !FailOverlay.IsPresent)
|
||||||
|
@ -43,26 +43,28 @@ namespace osu.Game.Skinning
|
|||||||
if (samplePlaybackDisabler != null)
|
if (samplePlaybackDisabler != null)
|
||||||
{
|
{
|
||||||
samplePlaybackDisabled.BindTo(samplePlaybackDisabler.SamplePlaybackDisabled);
|
samplePlaybackDisabled.BindTo(samplePlaybackDisabler.SamplePlaybackDisabled);
|
||||||
samplePlaybackDisabled.BindValueChanged(disabled =>
|
samplePlaybackDisabled.BindValueChanged(SamplePlaybackDisabledChanged);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void SamplePlaybackDisabledChanged(ValueChangedEvent<bool> disabled)
|
||||||
|
{
|
||||||
|
if (!RequestedPlaying) return;
|
||||||
|
|
||||||
|
// let non-looping samples that have already been started play out to completion (sounds better than abruptly cutting off).
|
||||||
|
if (!Looping) return;
|
||||||
|
|
||||||
|
cancelPendingStart();
|
||||||
|
|
||||||
|
if (disabled.NewValue)
|
||||||
|
base.Stop();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// schedule so we don't start playing a sample which is no longer alive.
|
||||||
|
scheduledStart = Schedule(() =>
|
||||||
{
|
{
|
||||||
if (!RequestedPlaying) return;
|
if (RequestedPlaying)
|
||||||
|
base.Play();
|
||||||
// let non-looping samples that have already been started play out to completion (sounds better than abruptly cutting off).
|
|
||||||
if (!Looping) return;
|
|
||||||
|
|
||||||
cancelPendingStart();
|
|
||||||
|
|
||||||
if (disabled.NewValue)
|
|
||||||
base.Stop();
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// schedule so we don't start playing a sample which is no longer alive.
|
|
||||||
scheduledStart = Schedule(() =>
|
|
||||||
{
|
|
||||||
if (RequestedPlaying)
|
|
||||||
base.Play();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,21 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void SamplePlaybackDisabledChanged(ValueChangedEvent<bool> disabled)
|
||||||
|
{
|
||||||
|
if (!RequestedPlaying) return;
|
||||||
|
|
||||||
|
if (!Looping && disabled.NewValue)
|
||||||
|
{
|
||||||
|
// the default behaviour for sample disabling is to allow one-shot samples to play out.
|
||||||
|
// storyboards regularly have long running samples that can cause this behaviour to lead to unintended results.
|
||||||
|
// for this reason, we immediately stop such samples.
|
||||||
|
Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
base.SamplePlaybackDisabledChanged(disabled);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
133
osu.Game/Utils/ModUtils.cs
Normal file
133
osu.Game/Utils/ModUtils.cs
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
// 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.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
|
namespace osu.Game.Utils
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A set of utilities to handle <see cref="Mod"/> combinations.
|
||||||
|
/// </summary>
|
||||||
|
public static class ModUtils
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Checks that all <see cref="Mod"/>s are compatible with each-other, and that all appear within a set of allowed types.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The allowed types must contain exact <see cref="Mod"/> types for the respective <see cref="Mod"/>s to be allowed.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="combination">The <see cref="Mod"/>s to check.</param>
|
||||||
|
/// <param name="allowedTypes">The set of allowed <see cref="Mod"/> types.</param>
|
||||||
|
/// <returns>Whether all <see cref="Mod"/>s are compatible with each-other and appear in the set of allowed types.</returns>
|
||||||
|
public static bool CheckCompatibleSetAndAllowed(IEnumerable<Mod> combination, IEnumerable<Type> allowedTypes)
|
||||||
|
{
|
||||||
|
// Prevent multiple-enumeration.
|
||||||
|
var combinationList = combination as ICollection<Mod> ?? combination.ToArray();
|
||||||
|
return CheckCompatibleSet(combinationList, out _) && CheckAllowed(combinationList, allowedTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks that all <see cref="Mod"/>s in a combination are compatible with each-other.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="combination">The <see cref="Mod"/> combination to check.</param>
|
||||||
|
/// <returns>Whether all <see cref="Mod"/>s in the combination are compatible with each-other.</returns>
|
||||||
|
public static bool CheckCompatibleSet(IEnumerable<Mod> combination)
|
||||||
|
=> CheckCompatibleSet(combination, out _);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks that all <see cref="Mod"/>s in a combination are compatible with each-other.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="combination">The <see cref="Mod"/> combination to check.</param>
|
||||||
|
/// <param name="invalidMods">Any invalid mods in the set.</param>
|
||||||
|
/// <returns>Whether all <see cref="Mod"/>s in the combination are compatible with each-other.</returns>
|
||||||
|
public static bool CheckCompatibleSet(IEnumerable<Mod> combination, [NotNullWhen(false)] out List<Mod>? invalidMods)
|
||||||
|
{
|
||||||
|
combination = FlattenMods(combination).ToArray();
|
||||||
|
invalidMods = null;
|
||||||
|
|
||||||
|
foreach (var mod in combination)
|
||||||
|
{
|
||||||
|
foreach (var type in mod.IncompatibleMods)
|
||||||
|
{
|
||||||
|
foreach (var invalid in combination.Where(m => type.IsInstanceOfType(m)))
|
||||||
|
{
|
||||||
|
invalidMods ??= new List<Mod>();
|
||||||
|
invalidMods.Add(invalid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return invalidMods == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks that all <see cref="Mod"/>s in a combination appear within a set of allowed types.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The set of allowed types must contain exact <see cref="Mod"/> types for the respective <see cref="Mod"/>s to be allowed.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="combination">The <see cref="Mod"/> combination to check.</param>
|
||||||
|
/// <param name="allowedTypes">The set of allowed <see cref="Mod"/> types.</param>
|
||||||
|
/// <returns>Whether all <see cref="Mod"/>s in the combination are allowed.</returns>
|
||||||
|
public static bool CheckAllowed(IEnumerable<Mod> combination, IEnumerable<Type> allowedTypes)
|
||||||
|
{
|
||||||
|
var allowedSet = new HashSet<Type>(allowedTypes);
|
||||||
|
|
||||||
|
return combination.SelectMany(FlattenMod)
|
||||||
|
.All(m => allowedSet.Contains(m.GetType()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check the provided combination of mods are valid for a local gameplay session.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mods">The mods to check.</param>
|
||||||
|
/// <param name="invalidMods">Invalid mods, if any were found. Can be null if all mods were valid.</param>
|
||||||
|
/// <returns>Whether the input mods were all valid. If false, <paramref name="invalidMods"/> will contain all invalid entries.</returns>
|
||||||
|
public static bool CheckValidForGameplay(IEnumerable<Mod> mods, out List<Mod>? invalidMods)
|
||||||
|
{
|
||||||
|
mods = mods.ToArray();
|
||||||
|
|
||||||
|
CheckCompatibleSet(mods, out invalidMods);
|
||||||
|
|
||||||
|
foreach (var mod in mods)
|
||||||
|
{
|
||||||
|
if (mod.Type == ModType.System || !mod.HasImplementation || mod is MultiMod)
|
||||||
|
{
|
||||||
|
invalidMods ??= new List<Mod>();
|
||||||
|
invalidMods.Add(mod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return invalidMods == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Flattens a set of <see cref="Mod"/>s, returning a new set with all <see cref="MultiMod"/>s removed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mods">The set of <see cref="Mod"/>s to flatten.</param>
|
||||||
|
/// <returns>The new set, containing all <see cref="Mod"/>s in <paramref name="mods"/> recursively with all <see cref="MultiMod"/>s removed.</returns>
|
||||||
|
public static IEnumerable<Mod> FlattenMods(IEnumerable<Mod> mods) => mods.SelectMany(FlattenMod);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Flattens a <see cref="Mod"/>, returning a set of <see cref="Mod"/>s in-place of any <see cref="MultiMod"/>s.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mod">The <see cref="Mod"/> to flatten.</param>
|
||||||
|
/// <returns>A set of singular "flattened" <see cref="Mod"/>s</returns>
|
||||||
|
public static IEnumerable<Mod> FlattenMod(Mod mod)
|
||||||
|
{
|
||||||
|
if (mod is MultiMod multi)
|
||||||
|
{
|
||||||
|
foreach (var m in multi.Mods.SelectMany(FlattenMod))
|
||||||
|
yield return m;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
yield return mod;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -23,7 +23,7 @@ namespace osu.Game.Utils
|
|||||||
|
|
||||||
var options = new SentryOptions
|
var options = new SentryOptions
|
||||||
{
|
{
|
||||||
Dsn = new Dsn("https://5e342cd55f294edebdc9ad604d28bbd3@sentry.io/1255255"),
|
Dsn = "https://5e342cd55f294edebdc9ad604d28bbd3@sentry.io/1255255",
|
||||||
Release = game.Version
|
Release = game.Version
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@
|
|||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2021.128.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2021.128.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1202.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1202.0" />
|
||||||
<PackageReference Include="Sentry" Version="2.1.8" />
|
<PackageReference Include="Sentry" Version="3.0.1" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.26.0" />
|
<PackageReference Include="SharpCompress" Version="0.27.1" />
|
||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -89,10 +89,10 @@
|
|||||||
<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="2021.128.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2021.128.0" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.26.0" />
|
<PackageReference Include="SharpCompress" Version="0.27.1" />
|
||||||
<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" />
|
||||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework.NativeLibs" Version="2020.923.0" ExcludeAssets="all" />
|
<PackageReference Include="ppy.osu.Framework.NativeLibs" Version="2021.115.0" ExcludeAssets="all" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
Reference in New Issue
Block a user