1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:12:54 +08:00

Merge branch 'master' into organize-room-pills

This commit is contained in:
Dean Herbert 2023-05-25 19:57:28 +09:00 committed by GitHub
commit a6a380dd41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 752 additions and 234 deletions

View File

@ -11,7 +11,7 @@
<AndroidManifestMerger>manifestmerger.jar</AndroidManifestMerger>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Framework.Android" Version="2023.513.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2023.521.0" />
</ItemGroup>
<ItemGroup>
<AndroidManifestOverlay Include="$(MSBuildThisFileDirectory)osu.Android\Properties\AndroidManifestOverlay.xml" />

View File

@ -9,6 +9,7 @@ using osu.Framework.Logging;
using osu.Game;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
using osu.Game.Screens.Play;
using Squirrel;
using Squirrel.SimpleSplat;
using LogLevel = Squirrel.SimpleSplat.LogLevel;
@ -36,6 +37,9 @@ namespace osu.Desktop.Updater
[Resolved]
private OsuGameBase game { get; set; } = null!;
[Resolved]
private ILocalUserPlayInfo? localUserInfo { get; set; }
[BackgroundDependencyLoader]
private void load(INotificationOverlay notifications)
{
@ -55,6 +59,10 @@ namespace osu.Desktop.Updater
try
{
// Avoid any kind of update checking while gameplay is running.
if (localUserInfo?.IsPlaying.Value == true)
return false;
updateManager ??= new GithubUpdateManager(@"https://github.com/ppy/osu", false, github_token, @"osulazer");
var info = await updateManager.CheckForUpdate(!useDeltaPatching).ConfigureAwait(false);

View File

@ -0,0 +1,337 @@
// 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.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Timing;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Taiko.Objects.Drawables;
using osu.Game.Rulesets.Taiko.UI;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Taiko.Tests
{
public partial class TestSceneDrumSampleTriggerSource : OsuTestScene
{
private readonly ManualClock manualClock = new ManualClock();
[Cached(typeof(IScrollingInfo))]
private ScrollingTestContainer.TestScrollingInfo info = new ScrollingTestContainer.TestScrollingInfo
{
Direction = { Value = ScrollingDirection.Left },
TimeRange = { Value = 200 },
};
private ScrollingHitObjectContainer hitObjectContainer = null!;
private TestDrumSampleTriggerSource triggerSource = null!;
[SetUp]
public void SetUp() => Schedule(() =>
{
hitObjectContainer = new ScrollingHitObjectContainer();
manualClock.CurrentTime = 0;
Child = new Container
{
Clock = new FramedClock(manualClock),
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
hitObjectContainer,
triggerSource = new TestDrumSampleTriggerSource(hitObjectContainer)
}
};
});
[Test]
public void TestNormalHit()
{
AddStep("add hit with normal samples", () =>
{
var hit = new Hit
{
StartTime = 100,
Samples = new List<HitSampleInfo>
{
new HitSampleInfo(HitSampleInfo.HIT_NORMAL)
}
};
hit.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
var drawableHit = new DrawableHit(hit);
hitObjectContainer.Add(drawableHit);
});
AddAssert("most valid object is hit", () => triggerSource.GetMostValidObject(), Is.InstanceOf<Hit>);
checkSound(HitType.Centre, HitSampleInfo.HIT_NORMAL, SampleControlPoint.DEFAULT_BANK);
checkSound(HitType.Rim, HitSampleInfo.HIT_CLAP, SampleControlPoint.DEFAULT_BANK);
AddStep("seek past hit", () => manualClock.CurrentTime = 200);
AddAssert("most valid object is hit", () => triggerSource.GetMostValidObject(), Is.InstanceOf<Hit>);
checkSound(HitType.Centre, HitSampleInfo.HIT_NORMAL, SampleControlPoint.DEFAULT_BANK);
checkSound(HitType.Rim, HitSampleInfo.HIT_CLAP, SampleControlPoint.DEFAULT_BANK);
}
[Test]
public void TestSoftHit()
{
AddStep("add hit with soft samples", () =>
{
var hit = new Hit
{
StartTime = 100,
Samples = new List<HitSampleInfo>
{
new HitSampleInfo(HitSampleInfo.HIT_NORMAL, "soft")
}
};
hit.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
var drawableHit = new DrawableHit(hit);
hitObjectContainer.Add(drawableHit);
});
AddAssert("most valid object is hit", () => triggerSource.GetMostValidObject(), Is.InstanceOf<Hit>);
checkSound(HitType.Centre, HitSampleInfo.HIT_NORMAL, "soft");
checkSound(HitType.Rim, HitSampleInfo.HIT_CLAP, "soft");
AddStep("seek past hit", () => manualClock.CurrentTime = 200);
AddAssert("most valid object is hit", () => triggerSource.GetMostValidObject(), Is.InstanceOf<Hit>);
checkSound(HitType.Centre, HitSampleInfo.HIT_NORMAL, "soft");
checkSound(HitType.Rim, HitSampleInfo.HIT_CLAP, "soft");
}
[Test]
public void TestDrumStrongHit()
{
AddStep("add strong hit with drum samples", () =>
{
var hit = new Hit
{
StartTime = 100,
Samples = new List<HitSampleInfo>
{
new HitSampleInfo(HitSampleInfo.HIT_NORMAL, "drum"),
new HitSampleInfo(HitSampleInfo.HIT_FINISH, "drum") // implies strong
}
};
hit.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
var drawableHit = new DrawableHit(hit);
hitObjectContainer.Add(drawableHit);
});
AddAssert("most valid object is strong nested hit", () => triggerSource.GetMostValidObject(), Is.InstanceOf<Hit.StrongNestedHit>);
checkSound(HitType.Centre, HitSampleInfo.HIT_NORMAL, "drum");
checkSound(HitType.Rim, HitSampleInfo.HIT_CLAP, "drum");
AddStep("seek past hit", () => manualClock.CurrentTime = 200);
AddAssert("most valid object is hit", () => triggerSource.GetMostValidObject(), Is.InstanceOf<Hit>);
checkSound(HitType.Centre, HitSampleInfo.HIT_NORMAL, "drum");
checkSound(HitType.Rim, HitSampleInfo.HIT_CLAP, "drum");
}
[Test]
public void TestNormalDrumRoll()
{
AddStep("add drum roll with normal samples", () =>
{
var drumRoll = new DrumRoll
{
StartTime = 100,
EndTime = 1100,
Samples = new List<HitSampleInfo>
{
new HitSampleInfo(HitSampleInfo.HIT_NORMAL)
}
};
drumRoll.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
var drawableDrumRoll = new DrawableDrumRoll(drumRoll);
hitObjectContainer.Add(drawableDrumRoll);
});
AddAssert("most valid object is drum roll tick", () => triggerSource.GetMostValidObject(), Is.InstanceOf<DrumRollTick>);
checkSound(HitType.Centre, HitSampleInfo.HIT_NORMAL, SampleControlPoint.DEFAULT_BANK);
checkSound(HitType.Rim, HitSampleInfo.HIT_CLAP, SampleControlPoint.DEFAULT_BANK);
AddStep("seek to middle of drum roll", () => manualClock.CurrentTime = 600);
AddAssert("most valid object is drum roll tick", () => triggerSource.GetMostValidObject(), Is.InstanceOf<DrumRollTick>);
checkSound(HitType.Centre, HitSampleInfo.HIT_NORMAL, SampleControlPoint.DEFAULT_BANK);
checkSound(HitType.Rim, HitSampleInfo.HIT_CLAP, SampleControlPoint.DEFAULT_BANK);
AddStep("seek past drum roll", () => manualClock.CurrentTime = 1200);
AddAssert("most valid object is drum roll", () => triggerSource.GetMostValidObject(), Is.InstanceOf<DrumRoll>);
checkSound(HitType.Centre, HitSampleInfo.HIT_NORMAL, SampleControlPoint.DEFAULT_BANK);
checkSound(HitType.Rim, HitSampleInfo.HIT_CLAP, SampleControlPoint.DEFAULT_BANK);
}
[Test]
public void TestSoftDrumRoll()
{
AddStep("add drum roll with soft samples", () =>
{
var drumRoll = new DrumRoll
{
StartTime = 100,
EndTime = 1100,
Samples = new List<HitSampleInfo>
{
new HitSampleInfo(HitSampleInfo.HIT_NORMAL, "soft")
}
};
drumRoll.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
var drawableDrumRoll = new DrawableDrumRoll(drumRoll);
hitObjectContainer.Add(drawableDrumRoll);
});
AddAssert("most valid object is drum roll tick", () => triggerSource.GetMostValidObject(), Is.InstanceOf<DrumRollTick>);
checkSound(HitType.Centre, HitSampleInfo.HIT_NORMAL, "soft");
checkSound(HitType.Rim, HitSampleInfo.HIT_CLAP, "soft");
AddStep("seek to middle of drum roll", () => manualClock.CurrentTime = 600);
AddAssert("most valid object is drum roll tick", () => triggerSource.GetMostValidObject(), Is.InstanceOf<DrumRollTick>);
checkSound(HitType.Centre, HitSampleInfo.HIT_NORMAL, "soft");
checkSound(HitType.Rim, HitSampleInfo.HIT_CLAP, "soft");
AddStep("seek past drum roll", () => manualClock.CurrentTime = 1200);
AddAssert("most valid object is drum roll", () => triggerSource.GetMostValidObject(), Is.InstanceOf<DrumRoll>);
checkSound(HitType.Centre, HitSampleInfo.HIT_NORMAL, "soft");
checkSound(HitType.Rim, HitSampleInfo.HIT_CLAP, "soft");
}
[Test]
public void TestDrumStrongDrumRoll()
{
AddStep("add strong drum roll with drum samples", () =>
{
var drumRoll = new DrumRoll
{
StartTime = 100,
EndTime = 1100,
Samples = new List<HitSampleInfo>
{
new HitSampleInfo(HitSampleInfo.HIT_NORMAL, "drum"),
new HitSampleInfo(HitSampleInfo.HIT_FINISH, "drum") // implies strong
}
};
drumRoll.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
var drawableDrumRoll = new DrawableDrumRoll(drumRoll);
hitObjectContainer.Add(drawableDrumRoll);
});
AddAssert("most valid object is drum roll tick's nested strong hit", () => triggerSource.GetMostValidObject(), Is.InstanceOf<DrumRollTick.StrongNestedHit>);
checkSound(HitType.Centre, HitSampleInfo.HIT_NORMAL, "drum");
checkSound(HitType.Rim, HitSampleInfo.HIT_CLAP, "drum");
AddStep("seek to middle of drum roll", () => manualClock.CurrentTime = 600);
AddAssert("most valid object is drum roll tick's nested strong hit", () => triggerSource.GetMostValidObject(), Is.InstanceOf<DrumRollTick.StrongNestedHit>);
checkSound(HitType.Centre, HitSampleInfo.HIT_NORMAL, "drum");
checkSound(HitType.Rim, HitSampleInfo.HIT_CLAP, "drum");
AddStep("seek past drum roll", () => manualClock.CurrentTime = 1200);
AddAssert("most valid object is drum roll", () => triggerSource.GetMostValidObject(), Is.InstanceOf<DrumRoll>);
checkSound(HitType.Centre, HitSampleInfo.HIT_NORMAL, "drum");
checkSound(HitType.Rim, HitSampleInfo.HIT_CLAP, "drum");
}
[Test]
public void TestNormalSwell()
{
AddStep("add swell with normal samples", () =>
{
var swell = new Swell
{
StartTime = 100,
EndTime = 1100,
Samples = new List<HitSampleInfo>
{
new HitSampleInfo(HitSampleInfo.HIT_NORMAL)
}
};
swell.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
var drawableSwell = new DrawableSwell(swell);
hitObjectContainer.Add(drawableSwell);
});
AddAssert("most valid object is swell tick", () => triggerSource.GetMostValidObject(), Is.InstanceOf<SwellTick>);
checkSound(HitType.Centre, HitSampleInfo.HIT_NORMAL, SampleControlPoint.DEFAULT_BANK);
checkSound(HitType.Rim, HitSampleInfo.HIT_CLAP, SampleControlPoint.DEFAULT_BANK);
AddStep("seek to middle of swell", () => manualClock.CurrentTime = 600);
AddAssert("most valid object is swell tick", () => triggerSource.GetMostValidObject(), Is.InstanceOf<SwellTick>);
checkSound(HitType.Centre, HitSampleInfo.HIT_NORMAL, SampleControlPoint.DEFAULT_BANK);
checkSound(HitType.Rim, HitSampleInfo.HIT_CLAP, SampleControlPoint.DEFAULT_BANK);
AddStep("seek past swell", () => manualClock.CurrentTime = 1200);
AddAssert("most valid object is swell", () => triggerSource.GetMostValidObject(), Is.InstanceOf<Swell>);
checkSound(HitType.Centre, HitSampleInfo.HIT_NORMAL, SampleControlPoint.DEFAULT_BANK);
checkSound(HitType.Rim, HitSampleInfo.HIT_CLAP, SampleControlPoint.DEFAULT_BANK);
}
[Test]
public void TestDrumSwell()
{
AddStep("add swell with drum samples", () =>
{
var swell = new Swell
{
StartTime = 100,
EndTime = 1100,
Samples = new List<HitSampleInfo>
{
new HitSampleInfo(HitSampleInfo.HIT_NORMAL, "drum")
}
};
swell.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
var drawableSwell = new DrawableSwell(swell);
hitObjectContainer.Add(drawableSwell);
});
AddAssert("most valid object is swell tick", () => triggerSource.GetMostValidObject(), Is.InstanceOf<SwellTick>);
checkSound(HitType.Centre, HitSampleInfo.HIT_NORMAL, "drum");
checkSound(HitType.Rim, HitSampleInfo.HIT_CLAP, "drum");
AddStep("seek to middle of swell", () => manualClock.CurrentTime = 600);
AddAssert("most valid object is swell tick", () => triggerSource.GetMostValidObject(), Is.InstanceOf<SwellTick>);
checkSound(HitType.Centre, HitSampleInfo.HIT_NORMAL, "drum");
checkSound(HitType.Rim, HitSampleInfo.HIT_CLAP, "drum");
AddStep("seek past swell", () => manualClock.CurrentTime = 1200);
AddAssert("most valid object is swell", () => triggerSource.GetMostValidObject(), Is.InstanceOf<Swell>);
checkSound(HitType.Centre, HitSampleInfo.HIT_NORMAL, "drum");
checkSound(HitType.Rim, HitSampleInfo.HIT_CLAP, "drum");
}
private void checkSound(HitType hitType, string expectedName, string expectedBank)
{
AddStep($"hit {hitType}", () => triggerSource.Play(hitType));
AddAssert($"last played sample is {expectedName}", () => triggerSource.LastPlayedSamples!.OfType<HitSampleInfo>().Single().Name, () => Is.EqualTo(expectedName));
AddAssert($"last played sample has {expectedBank} bank", () => triggerSource.LastPlayedSamples!.OfType<HitSampleInfo>().Single().Bank, () => Is.EqualTo(expectedBank));
}
private partial class TestDrumSampleTriggerSource : DrumSampleTriggerSource
{
public ISampleInfo[]? LastPlayedSamples { get; private set; }
public TestDrumSampleTriggerSource(HitObjectContainer hitObjectContainer)
: base(hitObjectContainer)
{
}
protected override void PlaySamples(ISampleInfo[] samples)
{
base.PlaySamples(samples);
LastPlayedSamples = samples;
}
public new HitObject GetMostValidObject() => base.GetMostValidObject();
}
}
}

View File

@ -118,6 +118,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{
public override bool RemoveWhenNotAlive => false;
}
// Most osu!taiko hitsounds are managed by the drum (see DrumSampleTriggerSource).
public override IEnumerable<HitSampleInfo> GetSamples() => Enumerable.Empty<HitSampleInfo>();
}
public abstract partial class DrawableTaikoHitObject<TObject> : DrawableTaikoHitObject
@ -157,9 +160,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
Content.Add(MainPiece = CreateMainPiece());
}
// Most osu!taiko hitsounds are managed by the drum (see DrumSampleMapping).
public override IEnumerable<HitSampleInfo> GetSamples() => Enumerable.Empty<HitSampleInfo>();
protected abstract SkinnableDrawable CreateMainPiece();
}
}

View File

@ -3,11 +3,9 @@
#nullable disable
using System.Linq;
using osu.Game.Rulesets.Objects.Types;
using System.Threading;
using osu.Framework.Bindables;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Beatmaps.Formats;
@ -98,7 +96,7 @@ namespace osu.Game.Rulesets.Taiko.Objects
TickSpacing = tickSpacing,
StartTime = t,
IsStrong = IsStrong,
Samples = Samples.Where(s => s.Name == HitSampleInfo.HIT_FINISH).ToList()
Samples = Samples
});
first = false;
@ -109,7 +107,11 @@ namespace osu.Game.Rulesets.Taiko.Objects
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
protected override StrongNestedHitObject CreateStrongNestedHit(double startTime) => new StrongNestedHit { StartTime = startTime };
protected override StrongNestedHitObject CreateStrongNestedHit(double startTime) => new StrongNestedHit
{
StartTime = startTime,
Samples = Samples
};
public class StrongNestedHit : StrongNestedHitObject
{

View File

@ -33,7 +33,11 @@ namespace osu.Game.Rulesets.Taiko.Objects
public override double MaximumJudgementOffset => HitWindow;
protected override StrongNestedHitObject CreateStrongNestedHit(double startTime) => new StrongNestedHit { StartTime = startTime };
protected override StrongNestedHitObject CreateStrongNestedHit(double startTime) => new StrongNestedHit
{
StartTime = startTime,
Samples = Samples
};
public class StrongNestedHit : StrongNestedHitObject
{

View File

@ -72,7 +72,11 @@ namespace osu.Game.Rulesets.Taiko.Objects
}
}
protected override StrongNestedHitObject CreateStrongNestedHit(double startTime) => new StrongNestedHit { StartTime = startTime };
protected override StrongNestedHitObject CreateStrongNestedHit(double startTime) => new StrongNestedHit
{
StartTime = startTime,
Samples = Samples
};
public class StrongNestedHit : StrongNestedHitObject
{

View File

@ -33,7 +33,10 @@ namespace osu.Game.Rulesets.Taiko.Objects
for (int i = 0; i < RequiredHits; i++)
{
cancellationToken.ThrowIfCancellationRequested();
AddNested(new SwellTick());
AddNested(new SwellTick
{
Samples = Samples
});
}
}

View File

@ -0,0 +1,31 @@
osu file format v14
[Events]
//Background and Video events
0,0,"BG.jpg",0,0
Video,0,"video.avi"
//Break Periods
//Storyboard Layer 0 (Background)
//Storyboard Layer 1 (Fail)
//Storyboard Layer 2 (Pass)
//Storyboard Layer 3 (Foreground)
//Storyboard Layer 4 (Overlay)
//Storyboard Sound Samples
[TimingPoints]
1674,333.333333333333,4,2,1,70,1,0
1674,-100,4,2,1,70,0,0
3340,-100,4,2,1,70,0,0
3507,-100,4,2,1,70,0,0
3673,-100,4,2,1,70,0,0
[Colours]
Combo1 : 240,80,80
Combo2 : 171,252,203
Combo3 : 128,128,255
Combo4 : 249,254,186
[HitObjects]
148,303,1674,5,6,3:2:0:0:
378,252,1840,1,0,0:0:0:0:
389,270,2340,5,2,0:1:0:0:

View File

@ -42,7 +42,8 @@ namespace osu.Game.Tests.Visual.Editing
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(90, 90)
Size = new Vector2(90, 90),
Scale = new Vector2(3),
}
};
});
@ -64,17 +65,24 @@ namespace osu.Game.Tests.Visual.Editing
InputManager.MoveMouseTo(tickMarkerHead.ScreenSpaceDrawQuad.Centre);
InputManager.PressButton(MouseButton.Left);
});
AddStep("move to 8 and release", () =>
AddStep("move to 1", () => InputManager.MoveMouseTo(getPositionForDivisor(1)));
AddStep("move to 16 and release", () =>
{
InputManager.MoveMouseTo(tickSliderBar.ScreenSpaceDrawQuad.Centre);
InputManager.MoveMouseTo(getPositionForDivisor(16));
InputManager.ReleaseButton(MouseButton.Left);
});
AddAssert("divisor is 8", () => bindableBeatDivisor.Value == 8);
AddAssert("divisor is 16", () => bindableBeatDivisor.Value == 16);
AddStep("hold marker", () => InputManager.PressButton(MouseButton.Left));
AddStep("move to 16", () => InputManager.MoveMouseTo(getPositionForDivisor(16)));
AddStep("move to ~10 and release", () =>
AddStep("move to ~6 and release", () =>
{
InputManager.MoveMouseTo(getPositionForDivisor(6));
InputManager.ReleaseButton(MouseButton.Left);
});
AddAssert("divisor clamped to 8", () => bindableBeatDivisor.Value == 8);
AddStep("move to ~10 and click", () =>
{
InputManager.MoveMouseTo(getPositionForDivisor(10));
InputManager.PressButton(MouseButton.Left);
InputManager.ReleaseButton(MouseButton.Left);
});
AddAssert("divisor clamped to 8", () => bindableBeatDivisor.Value == 8);
@ -82,12 +90,11 @@ namespace osu.Game.Tests.Visual.Editing
private Vector2 getPositionForDivisor(int divisor)
{
float relativePosition = (float)Math.Clamp(divisor, 0, 16) / 16;
var sliderDrawQuad = tickSliderBar.ScreenSpaceDrawQuad;
return new Vector2(
sliderDrawQuad.TopLeft.X + sliderDrawQuad.Width * relativePosition,
sliderDrawQuad.Centre.Y
);
float localX = (1 - 1 / (float)divisor) * tickSliderBar.UsableWidth + tickSliderBar.RangePadding;
return tickSliderBar.ToScreenSpace(new Vector2(
localX,
tickSliderBar.DrawHeight / 2
));
}
[Test]

View File

@ -1,57 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using NUnit.Framework;
using osu.Framework.Extensions;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Rulesets.Mania;
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.GameplayTest;
using osu.Game.Screens.Select;
using osu.Game.Tests.Resources;
namespace osu.Game.Tests.Visual.Editing
{
public partial class TestSceneEditorNavigation : OsuGameTestScene
{
[Test]
public void TestEditorGameplayTestAlwaysUsesOriginalRuleset()
{
BeatmapSetInfo beatmapSet = null!;
AddStep("import test beatmap", () => Game.BeatmapManager.Import(TestResources.GetTestBeatmapForImport()).WaitSafely());
AddStep("retrieve beatmap", () => beatmapSet = Game.BeatmapManager.QueryBeatmapSet(set => !set.Protected).AsNonNull().Value.Detach());
AddStep("present beatmap", () => Game.PresentBeatmap(beatmapSet));
AddUntilStep("wait for song select",
() => Game.Beatmap.Value.BeatmapSetInfo.Equals(beatmapSet)
&& Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect
&& songSelect.IsLoaded);
AddStep("switch ruleset", () => Game.Ruleset.Value = new ManiaRuleset().RulesetInfo);
AddStep("open editor", () => ((PlaySongSelect)Game.ScreenStack.CurrentScreen).Edit(beatmapSet.Beatmaps.First(beatmap => beatmap.Ruleset.OnlineID == 0)));
AddUntilStep("wait for editor open", () => Game.ScreenStack.CurrentScreen is Editor editor && editor.ReadyForUse);
AddStep("test gameplay", () => ((Editor)Game.ScreenStack.CurrentScreen).TestGameplay());
AddUntilStep("wait for player", () =>
{
// notifications may fire at almost any inopportune time and cause annoying test failures.
// relentlessly attempt to dismiss any and all interfering overlays, which includes notifications.
// this is theoretically not foolproof, but it's the best that can be done here.
Game.CloseAllOverlays();
return Game.ScreenStack.CurrentScreen is EditorPlayer editorPlayer && editorPlayer.IsLoaded;
});
AddAssert("current ruleset is osu!", () => Game.Ruleset.Value.Equals(new OsuRuleset().RulesetInfo));
AddStep("exit to song select", () => Game.PerformFromScreen(_ => { }, typeof(PlaySongSelect).Yield()));
AddUntilStep("wait for song select", () => Game.ScreenStack.CurrentScreen is PlaySongSelect);
AddAssert("previous ruleset restored", () => Game.Ruleset.Value.Equals(new ManiaRuleset().RulesetInfo));
}
}
}

View File

@ -92,6 +92,20 @@ namespace osu.Game.Tests.Visual.Editing
hitObjectHasVelocity(1, 5);
}
[Test]
public void TestUndo()
{
clickDifficultyPiece(1);
velocityPopoverHasSingleValue(2);
setVelocityViaPopover(5);
hitObjectHasVelocity(1, 5);
dismissPopover();
AddStep("undo", () => Editor.Undo());
hitObjectHasVelocity(1, 2);
}
[Test]
public void TestMultipleSelectionWithSameSliderVelocity()
{

View File

@ -109,6 +109,21 @@ namespace osu.Game.Tests.Visual.Editing
hitObjectHasSampleBank(1, "drum");
}
[Test]
public void TestUndo()
{
clickSamplePiece(1);
samplePopoverHasSingleBank("soft");
samplePopoverHasSingleVolume(60);
setVolumeViaPopover(90);
hitObjectHasSampleVolume(1, 90);
dismissPopover();
AddStep("undo", () => Editor.Undo());
hitObjectHasSampleVolume(1, 60);
}
[Test]
public void TestMultipleSelectionWithSameSampleVolume()
{

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -8,6 +9,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Timing;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Formats;
using osu.Game.IO;
@ -42,6 +44,18 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("Load storyboard with missing video", () => loadStoryboard("storyboard_no_video.osu"));
}
[Test]
public void TestVideoSize()
{
AddStep("load storyboard with only video", () =>
{
// LegacyStoryboardDecoder doesn't parse WidescreenStoryboard, so it is set manually
loadStoryboard("storyboard_only_video.osu", s => s.BeatmapInfo.WidescreenStoryboard = false);
});
AddAssert("storyboard is correct width", () => Precision.AlmostEquals(storyboard?.Width ?? 0f, 480 * 16 / 9f));
}
[BackgroundDependencyLoader]
private void load()
{
@ -102,7 +116,7 @@ namespace osu.Game.Tests.Visual.Gameplay
decoupledClock.ChangeSource(Beatmap.Value.Track);
}
private void loadStoryboard(string filename)
private void loadStoryboard(string filename, Action<Storyboard>? setUpStoryboard = null)
{
Storyboard loaded;
@ -113,6 +127,8 @@ namespace osu.Game.Tests.Visual.Gameplay
loaded = decoder.Decode(bfr);
}
setUpStoryboard?.Invoke(loaded);
loadStoryboard(loaded);
}
}

View File

@ -3,15 +3,61 @@
using System.Linq;
using NUnit.Framework;
using osu.Framework.Extensions;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Rulesets.Mania;
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.GameplayTest;
using osu.Game.Screens.Menu;
using osu.Game.Screens.Select;
using osu.Game.Tests.Resources;
using osuTK.Input;
namespace osu.Game.Tests.Visual.Navigation
{
public partial class TestSceneBeatmapEditorNavigation : OsuGameTestScene
{
[Test]
public void TestEditorGameplayTestAlwaysUsesOriginalRuleset()
{
BeatmapSetInfo beatmapSet = null!;
AddStep("import test beatmap", () => Game.BeatmapManager.Import(TestResources.GetTestBeatmapForImport()).WaitSafely());
AddStep("retrieve beatmap", () => beatmapSet = Game.BeatmapManager.QueryBeatmapSet(set => !set.Protected).AsNonNull().Value.Detach());
AddStep("present beatmap", () => Game.PresentBeatmap(beatmapSet));
AddUntilStep("wait for song select",
() => Game.Beatmap.Value.BeatmapSetInfo.Equals(beatmapSet)
&& Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect
&& songSelect.IsLoaded);
AddStep("switch ruleset", () => Game.Ruleset.Value = new ManiaRuleset().RulesetInfo);
AddStep("open editor", () => ((PlaySongSelect)Game.ScreenStack.CurrentScreen).Edit(beatmapSet.Beatmaps.First(beatmap => beatmap.Ruleset.OnlineID == 0)));
AddUntilStep("wait for editor open", () => Game.ScreenStack.CurrentScreen is Editor editor && editor.ReadyForUse);
AddStep("test gameplay", () => ((Editor)Game.ScreenStack.CurrentScreen).TestGameplay());
AddUntilStep("wait for player", () =>
{
// notifications may fire at almost any inopportune time and cause annoying test failures.
// relentlessly attempt to dismiss any and all interfering overlays, which includes notifications.
// this is theoretically not foolproof, but it's the best that can be done here.
Game.CloseAllOverlays();
return Game.ScreenStack.CurrentScreen is EditorPlayer editorPlayer && editorPlayer.IsLoaded;
});
AddAssert("current ruleset is osu!", () => Game.Ruleset.Value.Equals(new OsuRuleset().RulesetInfo));
AddStep("exit to song select", () => Game.PerformFromScreen(_ => { }, typeof(PlaySongSelect).Yield()));
AddUntilStep("wait for song select", () => Game.ScreenStack.CurrentScreen is PlaySongSelect);
AddAssert("previous ruleset restored", () => Game.Ruleset.Value.Equals(new ManiaRuleset().RulesetInfo));
}
/// <summary>
/// When entering the editor, a new beatmap is created as part of the asynchronous load process.
/// This test ensures that in the case of an early exit from the editor (ie. while it's still loading)
@ -38,5 +84,63 @@ namespace osu.Game.Tests.Visual.Navigation
BeatmapSetInfo[] allBeatmapSets() => Game.Realm.Run(realm => realm.All<BeatmapSetInfo>().Where(x => !x.DeletePending).ToArray());
}
[Test]
public void TestExitEditorWithoutSelection()
{
BeatmapSetInfo beatmapSet = null!;
AddStep("import test beatmap", () => Game.BeatmapManager.Import(TestResources.GetTestBeatmapForImport()).WaitSafely());
AddStep("retrieve beatmap", () => beatmapSet = Game.BeatmapManager.QueryBeatmapSet(set => !set.Protected).AsNonNull().Value.Detach());
AddStep("present beatmap", () => Game.PresentBeatmap(beatmapSet));
AddUntilStep("wait for song select",
() => Game.Beatmap.Value.BeatmapSetInfo.Equals(beatmapSet)
&& Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect
&& songSelect.IsLoaded);
AddStep("open editor", () => ((PlaySongSelect)Game.ScreenStack.CurrentScreen).Edit(beatmapSet.Beatmaps.First(beatmap => beatmap.Ruleset.OnlineID == 0)));
AddUntilStep("wait for editor open", () => Game.ScreenStack.CurrentScreen is Editor editor && editor.ReadyForUse);
AddStep("escape once", () => InputManager.Key(Key.Escape));
AddUntilStep("wait for editor exit", () => Game.ScreenStack.CurrentScreen is not Editor);
}
[Test]
public void TestExitEditorWithSelection()
{
BeatmapSetInfo beatmapSet = null!;
AddStep("import test beatmap", () => Game.BeatmapManager.Import(TestResources.GetTestBeatmapForImport()).WaitSafely());
AddStep("retrieve beatmap", () => beatmapSet = Game.BeatmapManager.QueryBeatmapSet(set => !set.Protected).AsNonNull().Value.Detach());
AddStep("present beatmap", () => Game.PresentBeatmap(beatmapSet));
AddUntilStep("wait for song select",
() => Game.Beatmap.Value.BeatmapSetInfo.Equals(beatmapSet)
&& Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect
&& songSelect.IsLoaded);
AddStep("open editor", () => ((PlaySongSelect)Game.ScreenStack.CurrentScreen).Edit(beatmapSet.Beatmaps.First(beatmap => beatmap.Ruleset.OnlineID == 0)));
AddUntilStep("wait for editor open", () => Game.ScreenStack.CurrentScreen is Editor editor && editor.ReadyForUse);
AddStep("make selection", () =>
{
var beatmap = getEditorBeatmap();
beatmap.SelectedHitObjects.AddRange(beatmap.HitObjects.Take(5));
});
AddAssert("selection exists", () => getEditorBeatmap().SelectedHitObjects, () => Has.Count.GreaterThan(0));
AddStep("escape once", () => InputManager.Key(Key.Escape));
AddAssert("selection empty", () => getEditorBeatmap().SelectedHitObjects, () => Has.Count.Zero);
AddStep("escape again", () => InputManager.Key(Key.Escape));
AddUntilStep("wait for editor exit", () => Game.ScreenStack.CurrentScreen is not Editor);
}
private EditorBeatmap getEditorBeatmap() => ((Editor)Game.ScreenStack.CurrentScreen).ChildrenOfType<EditorBeatmap>().Single();
}
}

View File

@ -17,6 +17,7 @@ namespace osu.Game.Graphics.Containers
{
public const float APPEAR_DURATION = 800;
public const float DISAPPEAR_DURATION = 500;
public const float SHADOW_OPACITY = 0.2f;
private const Easing easing_show = Easing.OutSine;
private const Easing easing_hide = Easing.InSine;

View File

@ -12,6 +12,7 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Platform;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Online.API;
@ -35,6 +36,9 @@ namespace osu.Game.Online.Chat
[Resolved]
private ChannelManager channelManager { get; set; }
[Resolved]
private GameHost host { get; set; }
private Bindable<bool> notifyOnUsername;
private Bindable<bool> notifyOnPrivateMessage;
@ -89,8 +93,8 @@ namespace osu.Game.Online.Chat
if (channel == null)
return;
// Only send notifications, if ChatOverlay and the target channel aren't visible.
if (chatOverlay.IsPresent && channelManager.CurrentChannel.Value == channel)
// Only send notifications if ChatOverlay or the target channel aren't visible, or if the window is unfocused
if (chatOverlay.IsPresent && channelManager.CurrentChannel.Value == channel && host.IsActive.Value)
return;
foreach (var message in messages.OrderByDescending(m => m.Id))
@ -99,6 +103,7 @@ namespace osu.Game.Online.Chat
if (message.Id <= channel.LastReadId)
return;
// ignore notifications triggered by local user's own chat messages
if (message.Sender.Id == localUser.Value.Id)
continue;

View File

@ -56,6 +56,7 @@ namespace osu.Game.Overlays
{
Colour = Color4.Black.Opacity(0),
Type = EdgeEffectType.Shadow,
Hollow = true,
Radius = 10
};
@ -101,7 +102,7 @@ namespace osu.Game.Overlays
protected override void PopIn()
{
base.PopIn();
FadeEdgeEffectTo(0.4f, WaveContainer.APPEAR_DURATION, Easing.Out);
FadeEdgeEffectTo(WaveContainer.SHADOW_OPACITY, WaveContainer.APPEAR_DURATION, Easing.Out);
}
protected override void PopOut()

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using System;
using System.Collections.Generic;
using osu.Framework.Allocation;
@ -13,7 +11,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Framework.Platform;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
@ -27,8 +24,8 @@ namespace osu.Game.Overlays.News
private readonly APINewsPost post;
private Box background;
private TextFlowContainer main;
private Box background = null!;
private TextFlowContainer main = null!;
public NewsCard(APINewsPost post)
{
@ -41,12 +38,12 @@ namespace osu.Game.Overlays.News
}
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider, GameHost host)
private void load(OverlayColourProvider colourProvider, OsuGame? game)
{
if (post.Slug != null)
{
TooltipText = "view in browser";
Action = () => host.OpenUrlExternally("https://osu.ppy.sh/home/news/" + post.Slug);
Action = () => game?.OpenUrlExternally(@"/home/news/" + post.Slug);
}
AddRange(new Drawable[]

View File

@ -20,7 +20,7 @@ using System.Diagnostics;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Platform;
using osu.Game.Online.Chat;
namespace osu.Game.Overlays.News.Sidebar
{
@ -59,7 +59,7 @@ namespace osu.Game.Overlays.News.Sidebar
new PostsContainer
{
Expanded = { BindTarget = Expanded },
Children = posts.Select(p => new PostButton(p)).ToArray()
Children = posts.Select(p => new PostLink(p)).ToArray()
}
}
};
@ -123,35 +123,14 @@ namespace osu.Game.Overlays.News.Sidebar
}
}
private partial class PostButton : OsuHoverContainer
private partial class PostLink : LinkFlowContainer
{
protected override IEnumerable<Drawable> EffectTargets => new[] { text };
private readonly TextFlowContainer text;
private readonly APINewsPost post;
public PostButton(APINewsPost post)
public PostLink(APINewsPost post)
: base(t => t.Font = OsuFont.GetFont(size: 12))
{
this.post = post;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Child = text = new TextFlowContainer(t => t.Font = OsuFont.GetFont(size: 12))
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Text = post.Title
};
}
[BackgroundDependencyLoader]
private void load(OverlayColourProvider overlayColours, GameHost host)
{
IdleColour = overlayColours.Light2;
HoverColour = overlayColours.Light1;
TooltipText = "view in browser";
Action = () => host.OpenUrlExternally("https://osu.ppy.sh/home/news/" + post.Slug);
AddLink(post.Title, LinkAction.External, @"/home/news/" + post.Slug, "view in browser");
}
}

View File

@ -5,9 +5,11 @@ using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Localisation;
using osu.Framework.Logging;
@ -16,6 +18,7 @@ using osu.Game.Graphics.Containers;
using osu.Game.Overlays.Notifications;
using osu.Game.Resources.Localisation.Web;
using osuTK;
using osuTK.Graphics;
using NotificationsStrings = osu.Game.Localisation.NotificationsStrings;
namespace osu.Game.Overlays
@ -72,6 +75,14 @@ namespace osu.Game.Overlays
mainContent = new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
EdgeEffect = new EdgeEffectParameters
{
Colour = Color4.Black.Opacity(0),
Type = EdgeEffectType.Shadow,
Radius = 10,
Hollow = true,
},
Children = new Drawable[]
{
new Box
@ -199,6 +210,7 @@ namespace osu.Game.Overlays
this.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint);
mainContent.FadeTo(1, TRANSITION_LENGTH, Easing.OutQuint);
mainContent.FadeEdgeEffectTo(WaveContainer.SHADOW_OPACITY, WaveContainer.APPEAR_DURATION, Easing.Out);
toastTray.FlushAllToasts();
}
@ -211,6 +223,7 @@ namespace osu.Game.Overlays
this.MoveToX(WIDTH, TRANSITION_LENGTH, Easing.OutQuint);
mainContent.FadeTo(0, TRANSITION_LENGTH, Easing.OutQuint);
mainContent.FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.In);
}
private void notificationClosed() => Schedule(() =>

View File

@ -193,25 +193,17 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
currentDisplay.BindValueChanged(display => Schedule(() =>
{
// there is no easy way to perform an atomic swap on the `resolutions` list, which is bound to the dropdown via `ItemSource`.
// this means, if the old resolution isn't saved, the `RemoveRange()` call below will cause `resolutionDropdown.Current` to reset value,
// therefore making it impossible to select any dropdown value other than "Default".
// to circumvent this locally, store the old value here, so that we can attempt to restore it later.
var oldResolution = resolutionDropdown.Current.Value;
resolutions.RemoveRange(1, resolutions.Count - 1);
if (display.NewValue != null)
if (display.NewValue == null)
{
resolutions.AddRange(display.NewValue.DisplayModes
.Where(m => m.Size.Width >= 800 && m.Size.Height >= 600)
.OrderByDescending(m => Math.Max(m.Size.Height, m.Size.Width))
.Select(m => m.Size)
.Distinct());
resolutions.Clear();
return;
}
if (resolutions.Contains(oldResolution))
resolutionDropdown.Current.Value = oldResolution;
resolutions.ReplaceRange(1, resolutions.Count - 1, display.NewValue.DisplayModes
.Where(m => m.Size.Width >= 800 && m.Size.Height >= 600)
.OrderByDescending(m => Math.Max(m.Size.Height, m.Size.Width))
.Select(m => m.Size)
.Distinct());
updateDisplaySettingsVisibility();
}), true);

View File

@ -10,15 +10,18 @@ using System.Threading.Tasks;
using osuTK;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Settings;
using osuTK.Graphics;
namespace osu.Game.Overlays
{
@ -105,6 +108,14 @@ namespace osu.Game.Overlays
Add(SectionsContainer = new SettingsSectionsContainer
{
Masking = true,
EdgeEffect = new EdgeEffectParameters
{
Colour = Color4.Black.Opacity(0),
Type = EdgeEffectType.Shadow,
Hollow = true,
Radius = 10
},
MaskingSmoothness = 0,
RelativeSizeAxes = Axes.Both,
ExpandableHeader = CreateHeader(),
SelectedSection = { BindTarget = CurrentSection },
@ -156,6 +167,8 @@ namespace osu.Game.Overlays
ContentContainer.MoveToX(ExpandedPosition, TRANSITION_LENGTH, Easing.OutQuint);
SectionsContainer.FadeEdgeEffectTo(WaveContainer.SHADOW_OPACITY, WaveContainer.APPEAR_DURATION, Easing.Out);
// delay load enough to ensure it doesn't overlap with the initial animation.
// this is done as there is still a brief stutter during load completion which is more visible if the transition is in progress.
// the eventual goal would be to remove the need for this by splitting up load into smaller work pieces, or fixing the remaining
@ -175,6 +188,7 @@ namespace osu.Game.Overlays
{
base.PopOut();
SectionsContainer.FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.In);
ContentContainer.MoveToX(-WIDTH + ExpandedPosition, TRANSITION_LENGTH, Easing.OutQuint);
Sidebar?.MoveToX(-sidebar_width, TRANSITION_LENGTH, Easing.OutQuint);

View File

@ -113,7 +113,7 @@ namespace osu.Game.Overlays.SkinEditor
if (replayGeneratingMod != null)
screen.Push(new PlayerLoader(() => new ReplayPlayer((beatmap, mods) => replayGeneratingMod.CreateScoreFromReplayData(beatmap, mods))));
}, new[] { typeof(Player), typeof(SongSelect) })
}, new[] { typeof(Player), typeof(PlaySongSelect) })
},
}
},

View File

@ -58,7 +58,7 @@ namespace osu.Game.Rulesets.UI
PlaySamples(samples);
}
protected void PlaySamples(ISampleInfo[] samples) => Schedule(() =>
protected virtual void PlaySamples(ISampleInfo[] samples) => Schedule(() =>
{
var hitSound = getNextSample();
hitSound.Samples = samples;

View File

@ -154,12 +154,15 @@ namespace osu.Game.Screens.Edit
/// </summary>
/// <param name="index">The 0-based beat index.</param>
/// <param name="beatDivisor">The beat divisor.</param>
/// <param name="validDivisors">The list of valid divisors which can be chosen from. Assumes ordered from low to high. Defaults to <see cref="PREDEFINED_DIVISORS"/> if omitted.</param>
/// <returns>The applicable divisor.</returns>
public static int GetDivisorForBeatIndex(int index, int beatDivisor)
public static int GetDivisorForBeatIndex(int index, int beatDivisor, int[] validDivisors = null)
{
validDivisors ??= PREDEFINED_DIVISORS;
int beat = index % beatDivisor;
foreach (int divisor in PREDEFINED_DIVISORS)
foreach (int divisor in validDivisors)
{
if ((beat * divisor) % beatDivisor == 0)
return divisor;

View File

@ -383,7 +383,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
CurrentNumber.BindTo(this.beatDivisor = beatDivisor);
Padding = new MarginPadding { Horizontal = 5 };
RangePadding = 5;
Padding = new MarginPadding { Horizontal = RangePadding };
}
protected override void LoadComplete()
@ -398,15 +399,20 @@ namespace osu.Game.Screens.Edit.Compose.Components
ClearInternal();
CurrentNumber.ValueChanged -= moveMarker;
foreach (int divisor in beatDivisor.ValidDivisors.Value.Presets)
int largestDivisor = beatDivisor.ValidDivisors.Value.Presets.Last();
for (int tickIndex = 0; tickIndex <= largestDivisor; tickIndex++)
{
AddInternal(new Tick(divisor)
int divisor = BindableBeatDivisor.GetDivisorForBeatIndex(tickIndex, largestDivisor, (int[])beatDivisor.ValidDivisors.Value.Presets);
bool isSolidTick = divisor * (largestDivisor - tickIndex) == largestDivisor;
AddInternal(new Tick(divisor, isSolidTick)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.Centre,
RelativePositionAxes = Axes.Both,
Colour = BindableBeatDivisor.GetColourFor(divisor, colours),
X = getMappedPosition(divisor),
X = tickIndex / (float)largestDivisor,
});
}
@ -418,6 +424,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
private void moveMarker(ValueChangedEvent<int> divisor)
{
marker.MoveToX(getMappedPosition(divisor.NewValue), 100, Easing.OutQuint);
foreach (Tick tick in InternalChildren.OfType<Tick>().Where(t => !t.AlwaysDisplayed))
{
tick.FadeTo(divisor.NewValue % tick.Divisor == 0 ? 0.2f : 0f, 100, Easing.OutQuint);
}
}
protected override void UpdateValue(float value)
@ -483,13 +494,22 @@ namespace osu.Game.Screens.Edit.Compose.Components
OnUserChange(Current.Value);
}
private float getMappedPosition(float divisor) => MathF.Pow((divisor - 1) / (beatDivisor.ValidDivisors.Value.Presets.Last() - 1), 0.90f);
private float getMappedPosition(float divisor) => 1 - 1 / divisor;
private partial class Tick : Circle
{
public Tick(int divisor)
public readonly bool AlwaysDisplayed;
public readonly int Divisor;
public Tick(int divisor, bool alwaysDisplayed)
{
AlwaysDisplayed = alwaysDisplayed;
Divisor = divisor;
Size = new Vector2(6f, 12) * BindableBeatDivisor.GetSize(divisor);
Alpha = alwaysDisplayed ? 1 : 0;
InternalChild = new Box { RelativeSizeAxes = Axes.Both };
}
}

View File

@ -16,6 +16,7 @@ using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings;
using osu.Game.Rulesets.Edit;
using osuTK;
using osuTK.Input;
@ -26,7 +27,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// A container which provides a "blueprint" display of items.
/// Includes selection and manipulation support via a <see cref="Components.SelectionHandler{T}"/>.
/// </summary>
public abstract partial class BlueprintContainer<T> : CompositeDrawable, IKeyBindingHandler<PlatformAction>
public abstract partial class BlueprintContainer<T> : CompositeDrawable, IKeyBindingHandler<PlatformAction>, IKeyBindingHandler<GlobalAction>
where T : class
{
protected DragBox DragBox { get; private set; }
@ -279,6 +280,30 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
}
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
if (e.Repeat)
return false;
switch (e.Action)
{
case GlobalAction.Back:
if (SelectedItems.Count > 0)
{
DeselectAll();
return true;
}
break;
}
return false;
}
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
{
}
#region Blueprint Addition/Removal
protected virtual void AddBlueprintFor(T item)

View File

@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
@ -15,7 +16,9 @@ using osu.Framework.Graphics.Textures;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Beatmaps.Formats;
using osu.Game.Extensions;
using osu.Game.IO;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Skinning;
using Decoder = osu.Game.Beatmaps.Formats.Decoder;
@ -42,6 +45,7 @@ namespace osu.Game.Screens.Edit
editorBeatmap.BeginChange();
processHitObjects(result, () => newBeatmap ??= readBeatmap(newState));
processTimingPoints(() => newBeatmap ??= readBeatmap(newState));
processHitObjectLocalData(() => newBeatmap ??= readBeatmap(newState));
editorBeatmap.EndChange();
}
@ -87,6 +91,41 @@ namespace osu.Game.Screens.Edit
}
}
private void processHitObjectLocalData(Func<IBeatmap> getNewBeatmap)
{
// This method handles data that are stored in control points in the legacy format,
// but were moved to the hitobjects themselves in lazer.
// Specifically, the data being referred to here consists of: slider velocity and sample information.
// For simplicity, this implementation relies on the editor beatmap already having the same hitobjects in sequence as the new beatmap.
// To guarantee that, `processHitObjects()` must be ran prior to this method for correct operation.
// This is done to avoid the necessity of reimplementing/reusing parts of LegacyBeatmapDecoder that already treat this data correctly.
var oldObjects = editorBeatmap.HitObjects;
var newObjects = getNewBeatmap().HitObjects;
Debug.Assert(oldObjects.Count == newObjects.Count);
foreach (var (oldObject, newObject) in oldObjects.Zip(newObjects))
{
// if `oldObject` and `newObject` are the same, it means that `oldObject` was inserted into `editorBeatmap` by `processHitObjects()`.
// in that case, there is nothing to do (and some of the subsequent changes may even prove destructive).
if (ReferenceEquals(oldObject, newObject))
continue;
if (oldObject is IHasSliderVelocity oldWithVelocity && newObject is IHasSliderVelocity newWithVelocity)
oldWithVelocity.SliderVelocity = newWithVelocity.SliderVelocity;
oldObject.Samples = newObject.Samples;
if (oldObject is IHasRepeats oldWithRepeats && newObject is IHasRepeats newWithRepeats)
{
oldWithRepeats.NodeSamples.Clear();
oldWithRepeats.NodeSamples.AddRange(newWithRepeats.NodeSamples);
}
}
}
private void findChangedIndices(DiffResult result, LegacyDecoder<Beatmap>.Section section, out List<int> removedIndices, out List<int> addedIndices)
{
removedIndices = new List<int>();

View File

@ -233,7 +233,13 @@ namespace osu.Game.Screens
/// </summary>
protected virtual void LogoArriving(OsuLogo logo, bool resuming)
{
ApplyLogoArrivingDefaults(logo);
logo.Action = null;
logo.FadeOut(300, Easing.OutQuint);
logo.Anchor = Anchor.TopLeft;
logo.Origin = Anchor.Centre;
logo.RelativePositionAxes = Axes.Both;
logo.Triangles = true;
logo.Ripple = true;
}
private void applyArrivingDefaults(bool isResuming)
@ -244,22 +250,6 @@ namespace osu.Game.Screens
}, true);
}
/// <summary>
/// Applies default animations to an arriving logo.
/// Todo: This should not exist.
/// </summary>
/// <param name="logo">The logo to apply animations to.</param>
public static void ApplyLogoArrivingDefaults(OsuLogo logo)
{
logo.Action = null;
logo.FadeOut(300, Easing.OutQuint);
logo.Anchor = Anchor.TopLeft;
logo.Origin = Anchor.Centre;
logo.RelativePositionAxes = Axes.Both;
logo.Triangles = true;
logo.Ripple = true;
}
private void onExitingLogo()
{
logo?.AppendAnimatingAction(() => LogoExiting(logo), false);

View File

@ -23,7 +23,6 @@ namespace osu.Game.Screens.Play
public Func<Task<ScoreInfo>> SaveReplay;
public override string Header => "failed";
public override string Description => "you're dead, try again?";
[BackgroundDependencyLoader]
private void load(OsuColour colours)

View File

@ -1,12 +1,9 @@
// 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.
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using Humanizer;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
@ -38,8 +35,8 @@ namespace osu.Game.Screens.Play
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
public Action OnRetry;
public Action OnQuit;
public Action? OnRetry;
public Action? OnQuit;
/// <summary>
/// Action that is invoked when <see cref="GlobalAction.Back"/> is triggered.
@ -53,12 +50,13 @@ namespace osu.Game.Screens.Play
public abstract string Header { get; }
public abstract string Description { get; }
protected SelectionCycleFillFlowContainer<DialogButton> InternalButtons;
protected SelectionCycleFillFlowContainer<DialogButton> InternalButtons = null!;
public IReadOnlyList<DialogButton> Buttons => InternalButtons;
private FillFlowContainer retryCounterContainer;
private TextFlowContainer playInfoText = null!;
[Resolved]
private GlobalActionContainer globalAction { get; set; } = null!;
protected GameplayMenuOverlay()
{
@ -86,36 +84,13 @@ namespace osu.Game.Screens.Play
Anchor = Anchor.Centre,
Children = new Drawable[]
{
new FillFlowContainer
new OsuSpriteText
{
Text = Header,
Font = OsuFont.GetFont(size: 48),
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 20),
Children = new Drawable[]
{
new OsuSpriteText
{
Text = Header,
Font = OsuFont.GetFont(size: 30),
Spacing = new Vector2(5, 0),
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Colour = colours.Yellow,
Shadow = true,
ShadowColour = new Color4(0, 0, 0, 0.25f)
},
new OsuSpriteText
{
Text = Description,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Shadow = true,
ShadowColour = new Color4(0, 0, 0, 0.25f)
}
}
Colour = colours.Yellow,
},
InternalButtons = new SelectionCycleFillFlowContainer<DialogButton>
{
@ -132,10 +107,11 @@ namespace osu.Game.Screens.Play
Radius = 50
},
},
retryCounterContainer = new FillFlowContainer
playInfoText = new OsuTextFlowContainer(cp => cp.Font = OsuFont.GetFont(size: 18))
{
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
TextAnchor = Anchor.TopCentre,
AutoSizeAxes = Axes.Both,
}
}
@ -157,7 +133,8 @@ namespace osu.Game.Screens.Play
return;
retries = value;
if (retryCounterContainer != null)
if (IsLoaded)
updateRetryCount();
}
}
@ -170,7 +147,7 @@ namespace osu.Game.Screens.Play
protected override bool OnMouseMove(MouseMoveEvent e) => true;
protected void AddButton(string text, Color4 colour, Action action)
protected void AddButton(string text, Color4 colour, Action? action)
{
var button = new Button
{
@ -222,30 +199,9 @@ namespace osu.Game.Screens.Play
// "You've retried 1,065 times in this session"
// "You've retried 1 time in this session"
retryCounterContainer.Children = new Drawable[]
{
new OsuSpriteText
{
Text = "You've retried ",
Shadow = true,
ShadowColour = new Color4(0, 0, 0, 0.25f),
Font = OsuFont.GetFont(size: 18),
},
new OsuSpriteText
{
Text = "time".ToQuantity(retries),
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 18),
Shadow = true,
ShadowColour = new Color4(0, 0, 0, 0.25f),
},
new OsuSpriteText
{
Text = " in this session",
Shadow = true,
ShadowColour = new Color4(0, 0, 0, 0.25f),
Font = OsuFont.GetFont(size: 18),
}
};
playInfoText.Clear();
playInfoText.AddText("Retry count: ");
playInfoText.AddText(retries.ToString(), cp => cp.Font = cp.Font.With(weight: FontWeight.Bold));
}
private partial class Button : DialogButton
@ -260,9 +216,6 @@ namespace osu.Game.Screens.Play
}
}
[Resolved]
private GlobalActionContainer globalAction { get; set; }
protected override bool Handle(UIEvent e)
{
switch (e)

View File

@ -24,7 +24,6 @@ namespace osu.Game.Screens.Play
public override bool IsPresent => base.IsPresent || pauseLoop.IsPlaying;
public override string Header => "paused";
public override string Description => "you're not going to do what i think you're going to do, are ya?";
private SkinnableSound pauseLoop;

View File

@ -69,7 +69,7 @@ namespace osu.Game.Storyboards.Drawables
Size = new Vector2(640, 480);
bool onlyHasVideoElements = Storyboard.Layers.SelectMany(l => l.Elements).Any(e => !(e is StoryboardVideo));
bool onlyHasVideoElements = Storyboard.Layers.SelectMany(l => l.Elements).All(e => e is StoryboardVideo);
Width = Height * (storyboard.BeatmapInfo.WidescreenStoryboard || onlyHasVideoElements ? 16 / 9f : 4 / 3f);

View File

@ -30,13 +30,13 @@
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="7.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Toolkit.HighPerformance" Version="7.1.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="ppy.LocalisationAnalyser" Version="2022.809.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Realm" Version="10.20.0" />
<PackageReference Include="ppy.osu.Framework" Version="2023.513.0" />
<PackageReference Include="ppy.osu.Framework" Version="2023.521.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2023.510.0" />
<PackageReference Include="Sentry" Version="3.28.1" />
<PackageReference Include="SharpCompress" Version="0.32.2" />

View File

@ -16,6 +16,6 @@
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Framework.iOS" Version="2023.513.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2023.521.0" />
</ItemGroup>
</Project>