mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 02:22:56 +08:00
Merge branch 'master' into flashlight-dim
This commit is contained in:
commit
9da13cb463
@ -0,0 +1,150 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Timing;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
|
{
|
||||||
|
public class TestCaseFrameStabilityContainer : OsuTestCase
|
||||||
|
{
|
||||||
|
private readonly ManualClock manualClock;
|
||||||
|
|
||||||
|
private readonly Container mainContainer;
|
||||||
|
|
||||||
|
private ClockConsumingChild consumer;
|
||||||
|
|
||||||
|
public TestCaseFrameStabilityContainer()
|
||||||
|
{
|
||||||
|
Child = mainContainer = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Clock = new FramedClock(manualClock = new ManualClock()),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestLargeJumps()
|
||||||
|
{
|
||||||
|
seekManualTo(0);
|
||||||
|
createStabilityContainer();
|
||||||
|
seekManualTo(100000);
|
||||||
|
|
||||||
|
confirmSeek(100000);
|
||||||
|
checkFrameCount(6000);
|
||||||
|
|
||||||
|
seekManualTo(0);
|
||||||
|
|
||||||
|
confirmSeek(0);
|
||||||
|
checkFrameCount(12000);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSmallJumps()
|
||||||
|
{
|
||||||
|
seekManualTo(0);
|
||||||
|
createStabilityContainer();
|
||||||
|
seekManualTo(40);
|
||||||
|
|
||||||
|
confirmSeek(40);
|
||||||
|
checkFrameCount(3);
|
||||||
|
|
||||||
|
seekManualTo(0);
|
||||||
|
|
||||||
|
confirmSeek(0);
|
||||||
|
checkFrameCount(6);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSingleFrameJump()
|
||||||
|
{
|
||||||
|
seekManualTo(0);
|
||||||
|
createStabilityContainer();
|
||||||
|
seekManualTo(8);
|
||||||
|
confirmSeek(8);
|
||||||
|
checkFrameCount(1);
|
||||||
|
|
||||||
|
seekManualTo(16);
|
||||||
|
confirmSeek(16);
|
||||||
|
checkFrameCount(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestInitialSeek()
|
||||||
|
{
|
||||||
|
seekManualTo(100000);
|
||||||
|
createStabilityContainer();
|
||||||
|
|
||||||
|
confirmSeek(100000);
|
||||||
|
checkFrameCount(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createStabilityContainer() => AddStep("create container", () => mainContainer.Child = new FrameStabilityContainer().WithChild(consumer = new ClockConsumingChild()));
|
||||||
|
|
||||||
|
private void seekManualTo(double time) => AddStep($"seek manual clock to {time}", () => manualClock.CurrentTime = time);
|
||||||
|
|
||||||
|
private void confirmSeek(double time) => AddUntilStep($"wait for seek to {time}", () => consumer.Clock.CurrentTime == time);
|
||||||
|
|
||||||
|
private void checkFrameCount(int frames) =>
|
||||||
|
AddAssert($"elapsed frames is {frames}", () => consumer.ElapsedFrames == frames);
|
||||||
|
|
||||||
|
public class ClockConsumingChild : CompositeDrawable
|
||||||
|
{
|
||||||
|
private readonly OsuSpriteText text;
|
||||||
|
private readonly OsuSpriteText text2;
|
||||||
|
private readonly OsuSpriteText text3;
|
||||||
|
|
||||||
|
public ClockConsumingChild()
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre;
|
||||||
|
Origin = Anchor.Centre;
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
text = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
},
|
||||||
|
text2 = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
},
|
||||||
|
text3 = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ElapsedFrames;
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
if (Clock.ElapsedFrameTime != 0)
|
||||||
|
ElapsedFrames++;
|
||||||
|
|
||||||
|
text.Text = $"current time: {Clock.CurrentTime:F0}";
|
||||||
|
if (Clock.ElapsedFrameTime != 0)
|
||||||
|
text2.Text = $"last elapsed frame time: {Clock.ElapsedFrameTime:F0}";
|
||||||
|
text3.Text = $"total frames: {ElapsedFrames:F0}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,21 +10,25 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
|
using osu.Game.Tests.Beatmaps;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Gameplay
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
{
|
{
|
||||||
public class TestCasePlayerLoader : ManualInputManagerTestCase
|
public class TestCasePlayerLoader : ManualInputManagerTestCase
|
||||||
{
|
{
|
||||||
private PlayerLoader loader;
|
private PlayerLoader loader;
|
||||||
private readonly OsuScreenStack stack;
|
private OsuScreenStack stack;
|
||||||
|
|
||||||
public TestCasePlayerLoader()
|
[SetUp]
|
||||||
|
public void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
InputManager.Add(stack = new OsuScreenStack { RelativeSizeAxes = Axes.Both });
|
InputManager.Child = stack = new OsuScreenStack { RelativeSizeAxes = Axes.Both };
|
||||||
}
|
Beatmap.Value = new TestWorkingBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo), Clock);
|
||||||
|
});
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestLoadContinuation()
|
public void TestLoadContinuation()
|
||||||
@ -33,8 +37,6 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
||||||
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
|
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
|
||||||
AddUntilStep("wait for no longer current", () => !loader.IsCurrentScreen());
|
AddUntilStep("wait for no longer current", () => !loader.IsCurrentScreen());
|
||||||
AddStep("exit loader", () => loader.Exit());
|
|
||||||
AddUntilStep("wait for no longer alive", () => !loader.IsAlive);
|
|
||||||
AddStep("load slow dummy beatmap", () =>
|
AddStep("load slow dummy beatmap", () =>
|
||||||
{
|
{
|
||||||
SlowLoadPlayer slow = null;
|
SlowLoadPlayer slow = null;
|
||||||
@ -58,41 +60,25 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddStep("load player", () =>
|
AddStep("load player", () =>
|
||||||
{
|
{
|
||||||
Mods.Value = new[] { gameMod = new TestMod() };
|
Mods.Value = new[] { gameMod = new TestMod() };
|
||||||
InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre);
|
stack.Push(loader = new PlayerLoader(() => player = new TestPlayer()));
|
||||||
stack.Push(new PlayerLoader(() => player = new TestPlayer()));
|
|
||||||
});
|
|
||||||
|
|
||||||
AddUntilStep("wait for player to become current", () =>
|
|
||||||
{
|
|
||||||
if (player.IsCurrentScreen())
|
|
||||||
{
|
|
||||||
playerMod1 = (TestMod)player.Mods.Value.Single();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for loader to become current", () => loader.IsCurrentScreen());
|
||||||
|
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
|
||||||
|
AddUntilStep("wait for player to be current", () => player.IsCurrentScreen());
|
||||||
|
AddStep("retrieve mods", () => playerMod1 = (TestMod)player.Mods.Value.Single());
|
||||||
AddAssert("game mods not applied", () => gameMod.Applied == false);
|
AddAssert("game mods not applied", () => gameMod.Applied == false);
|
||||||
AddAssert("player mods applied", () => playerMod1.Applied);
|
AddAssert("player mods applied", () => playerMod1.Applied);
|
||||||
|
|
||||||
AddStep("restart player", () =>
|
AddStep("restart player", () =>
|
||||||
{
|
{
|
||||||
|
var lastPlayer = player;
|
||||||
player = null;
|
player = null;
|
||||||
player.Restart();
|
lastPlayer.Restart();
|
||||||
});
|
|
||||||
|
|
||||||
AddUntilStep("wait for player to become current", () =>
|
|
||||||
{
|
|
||||||
if (player.IsCurrentScreen())
|
|
||||||
{
|
|
||||||
playerMod2 = (TestMod)player.Mods.Value.Single();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for player to be current", () => player.IsCurrentScreen());
|
||||||
|
AddStep("retrieve mods", () => playerMod2 = (TestMod)player.Mods.Value.Single());
|
||||||
AddAssert("game mods not applied", () => gameMod.Applied == false);
|
AddAssert("game mods not applied", () => gameMod.Applied == false);
|
||||||
AddAssert("player has different mods", () => playerMod1 != playerMod2);
|
AddAssert("player has different mods", () => playerMod1 != playerMod2);
|
||||||
AddAssert("player mods applied", () => playerMod2.Applied);
|
AddAssert("player mods applied", () => playerMod2.Applied);
|
||||||
|
@ -23,7 +23,11 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
|
|
||||||
public TestCaseLoaderAnimation()
|
public TestCaseLoaderAnimation()
|
||||||
{
|
{
|
||||||
Child = logo = new OsuLogo { Depth = float.MinValue };
|
Child = logo = new OsuLogo
|
||||||
|
{
|
||||||
|
Alpha = 0,
|
||||||
|
Depth = float.MinValue
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -39,7 +43,7 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
LoadScreen(loader);
|
LoadScreen(loader);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("loaded", () =>
|
AddUntilStep("loaded", () =>
|
||||||
{
|
{
|
||||||
logoVisible = loader.Logo?.Alpha > 0;
|
logoVisible = loader.Logo?.Alpha > 0;
|
||||||
return loader.Logo != null && loader.ScreenLoaded;
|
return loader.Logo != null && loader.ScreenLoaded;
|
||||||
|
@ -68,6 +68,8 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
private const double sixty_frame_time = 1000.0 / 60;
|
private const double sixty_frame_time = 1000.0 / 60;
|
||||||
|
|
||||||
|
private bool firstConsumption = true;
|
||||||
|
|
||||||
public override bool UpdateSubTree()
|
public override bool UpdateSubTree()
|
||||||
{
|
{
|
||||||
requireMoreUpdateLoops = true;
|
requireMoreUpdateLoops = true;
|
||||||
@ -103,7 +105,18 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (Math.Abs(manualClock.CurrentTime - newProposedTime) > sixty_frame_time * 1.2f)
|
if (firstConsumption)
|
||||||
|
{
|
||||||
|
// On the first update, frame-stability seeking would result in unexpected/unwanted behaviour.
|
||||||
|
// Instead we perform an initial seek to the proposed time.
|
||||||
|
manualClock.CurrentTime = newProposedTime;
|
||||||
|
|
||||||
|
// do a second process to clear out ElapsedTime
|
||||||
|
framedClock.ProcessFrame();
|
||||||
|
|
||||||
|
firstConsumption = false;
|
||||||
|
}
|
||||||
|
else if (Math.Abs(manualClock.CurrentTime - newProposedTime) > sixty_frame_time * 1.2f)
|
||||||
{
|
{
|
||||||
newProposedTime = newProposedTime > manualClock.CurrentTime
|
newProposedTime = newProposedTime > manualClock.CurrentTime
|
||||||
? Math.Min(newProposedTime, manualClock.CurrentTime + sixty_frame_time)
|
? Math.Min(newProposedTime, manualClock.CurrentTime + sixty_frame_time)
|
||||||
|
@ -92,13 +92,6 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
|
|
||||||
zoomedContent.Width = DrawWidth * currentZoom;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnScroll(ScrollEvent e)
|
protected override bool OnScroll(ScrollEvent e)
|
||||||
{
|
{
|
||||||
if (e.IsPrecise)
|
if (e.IsPrecise)
|
||||||
@ -169,6 +162,11 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
float targetOffset = expectedWidth * (focusPoint / contentSize) - focusOffset;
|
float targetOffset = expectedWidth * (focusPoint / contentSize) - focusOffset;
|
||||||
|
|
||||||
d.currentZoom = newZoom;
|
d.currentZoom = newZoom;
|
||||||
|
|
||||||
|
d.zoomedContent.Width = d.DrawWidth * d.currentZoom;
|
||||||
|
// Temporarily here to make sure ScrollTo gets the correct DrawSize for scrollable area.
|
||||||
|
// TODO: Make sure draw size gets invalidated properly on the framework side, and remove this once it is.
|
||||||
|
d.Invalidate(Invalidation.DrawSize);
|
||||||
d.ScrollTo(targetOffset, false);
|
d.ScrollTo(targetOffset, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
public void SetUpSteps()
|
public void SetUpSteps()
|
||||||
{
|
{
|
||||||
AddStep(ruleset.RulesetInfo.Name, loadPlayer);
|
AddStep(ruleset.RulesetInfo.Name, loadPlayer);
|
||||||
AddUntilStep(() => Player.IsLoaded, "player loaded");
|
AddUntilStep(() => Player.IsLoaded && Player.Alpha == 1, "player loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual IBeatmap CreateBeatmap(Ruleset ruleset) => new TestBeatmap(ruleset.RulesetInfo);
|
protected virtual IBeatmap CreateBeatmap(Ruleset ruleset) => new TestBeatmap(ruleset.RulesetInfo);
|
||||||
|
@ -105,8 +105,8 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.128.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.128.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2019.415.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2019.425.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.415.0" />
|
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.425.0" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.22.0" />
|
<PackageReference Include="SharpCompress" Version="0.22.0" />
|
||||||
<PackageReference Include="NUnit" Version="3.11.0" />
|
<PackageReference Include="NUnit" Version="3.11.0" />
|
||||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||||
|
Loading…
Reference in New Issue
Block a user