Skip to content

Commit

Permalink
Merge branch 'master' into fix-per-ruleset-hud-positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
bdach authored Jan 22, 2024
2 parents 99d3fcc + 15df6b1 commit b8dd78e
Show file tree
Hide file tree
Showing 74 changed files with 506 additions and 462 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class VisualTestRunner
[STAThread]
public static int Main(string[] args)
{
using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu", new HostOptions { BindIPC = true }))
using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu"))
{
host.Run(new OsuTestBrowser());
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>
<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class VisualTestRunner
[STAThread]
public static int Main(string[] args)
{
using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu", new HostOptions { BindIPC = true }))
using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu"))
{
host.Run(new OsuTestBrowser());
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>
<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class VisualTestRunner
[STAThread]
public static int Main(string[] args)
{
using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu", new HostOptions { BindIPC = true }))
using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu"))
{
host.Run(new OsuTestBrowser());
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>
<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class VisualTestRunner
[STAThread]
public static int Main(string[] args)
{
using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu", new HostOptions { BindIPC = true }))
using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu"))
{
host.Run(new OsuTestBrowser());
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>
<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion osu.Desktop/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static void Main(string[] args)
}
}

using (DesktopGameHost host = Host.GetSuitableDesktopHost(gameName, new HostOptions { BindIPC = !tournamentClient }))
using (DesktopGameHost host = Host.GetSuitableDesktopHost(gameName, new HostOptions { IPCPort = !tournamentClient ? OsuGame.IPC_PORT : null }))
{
if (!host.IsPrimaryInstance)
{
Expand Down
4 changes: 2 additions & 2 deletions osu.Desktop/osu.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
<ProjectReference Include="..\osu.Game.Rulesets.Taiko\osu.Game.Rulesets.Taiko.csproj" />
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="Clowd.Squirrel" Version="2.10.2" />
<PackageReference Include="Clowd.Squirrel" Version="2.11.1" />
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
<PackageReference Include="System.IO.Packaging" Version="7.0.0" />
<PackageReference Include="System.IO.Packaging" Version="8.0.0" />
<PackageReference Include="DiscordRichPresence" Version="1.2.1.24" />
</ItemGroup>
<ItemGroup Label="Resources">
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Benchmarks/osu.Game.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.9" />
<PackageReference Include="nunit" Version="3.13.3" />
<PackageReference Include="nunit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\osu.TestProject.props" />
<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
<PropertyGroup Label="Project">
Expand Down
38 changes: 17 additions & 21 deletions osu.Game.Rulesets.Mania.Tests/Skinning/TestSceneBarLine.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.UI;
Expand All @@ -16,37 +14,35 @@ public partial class TestSceneBarLine : ManiaSkinnableTestScene
[Test]
public void TestMinor()
{
AddStep("Create barlines", () => recreate());
AddStep("Create barlines", recreate);
}

private void recreate(Func<IEnumerable<BarLine>>? createBarLines = null)
private void recreate()
{
var stageDefinitions = new List<StageDefinition>
{
new StageDefinition(4),
};

SetContents(_ => new ManiaPlayfield(stageDefinitions).With(s =>
SetContents(_ =>
{
if (createBarLines != null)
{
var barLines = createBarLines();

foreach (var b in barLines)
s.Add(b);
var maniaPlayfield = new ManiaPlayfield(stageDefinitions);

return;
}

for (int i = 0; i < 64; i++)
// Must be scheduled so the pool is loaded before we try and retrieve from it.
Schedule(() =>
{
s.Add(new BarLine
for (int i = 0; i < 64; i++)
{
StartTime = Time.Current + i * 500,
Major = i % 4 == 0,
});
}
}));
maniaPlayfield.Add(new BarLine
{
StartTime = Time.Current + i * 500,
Major = i % 4 == 0,
});
}
});

return maniaPlayfield;
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\osu.TestProject.props" />
<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
<PropertyGroup Label="Project">
Expand Down
47 changes: 24 additions & 23 deletions osu.Game.Rulesets.Osu.Tests/TestSceneDrawableJudgement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ public partial class TestSceneDrawableJudgement : OsuSkinnableTestScene
[Resolved]
private OsuConfigManager config { get; set; } = null!;

private readonly List<DrawablePool<TestDrawableOsuJudgement>> pools;
private readonly List<DrawablePool<TestDrawableOsuJudgement>> pools = new List<DrawablePool<TestDrawableOsuJudgement>>();

public TestSceneDrawableJudgement()
[TestCaseSource(nameof(validResults))]
public void Test(HitResult result)
{
pools = new List<DrawablePool<TestDrawableOsuJudgement>>();

foreach (HitResult result in Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Skip(1))
showResult(result);
showResult(result);
}

private static IEnumerable<HitResult> validResults => Enum.GetValues<HitResult>().Skip(1);

[Test]
public void TestHitLightingDisabled()
{
Expand Down Expand Up @@ -72,32 +72,33 @@ private void showResult(HitResult result)
pools.Add(pool = new DrawablePool<TestDrawableOsuJudgement>(1));
else
{
pool = pools[poolIndex];

// We need to make sure neither the pool nor the judgement get disposed when new content is set, and they both share the same parent.
pool = pools[poolIndex];
((Container)pool.Parent!).Clear(false);
}

var container = new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
pool,
pool.Get(j => j.Apply(new JudgementResult(new HitObject
{
StartTime = Time.Current
}, new Judgement())
{
Type = result,
}, null)).With(j =>
{
j.Anchor = Anchor.Centre;
j.Origin = Anchor.Centre;
})
}
Child = pool,
};

// Must be scheduled so the pool is loaded before we try and retrieve from it.
Schedule(() =>
{
container.Add(pool.Get(j => j.Apply(new JudgementResult(new HitObject
{
StartTime = Time.Current
}, new Judgement())
{
Type = result,
}, null)).With(j =>
{
j.Anchor = Anchor.Centre;
j.Origin = Anchor.Centre;
}));
});

poolIndex++;
return container;
});
Expand Down
39 changes: 35 additions & 4 deletions osu.Game.Rulesets.Osu.Tests/TestSceneSliderApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void TestApplyNewSlider()
{
DrawableSlider dho = null;

AddStep("create slider", () => Child = dho = new DrawableSlider(prepareObject(new Slider
AddStep("create slider", () => Child = dho = new DrawableSlider(applyDefaults(new Slider
{
Position = new Vector2(256, 192),
IndexInCurrentCombo = 0,
Expand All @@ -47,7 +47,7 @@ public void TestApplyNewSlider()

AddWaitStep("wait for progression", 1);

AddStep("apply new slider", () => dho.Apply(prepareObject(new Slider
AddStep("apply new slider", () => dho.Apply(applyDefaults(new Slider
{
Position = new Vector2(256, 192),
ComboIndex = 1,
Expand Down Expand Up @@ -75,7 +75,7 @@ public void TestBallTintChangedOnAccentChange()
Child = new SkinProvidingContainer(provider)
{
RelativeSizeAxes = Axes.Both,
Child = dho = new DrawableSlider(prepareObject(new Slider
Child = dho = new DrawableSlider(applyDefaults(new Slider
{
Position = new Vector2(256, 192),
IndexInCurrentCombo = 0,
Expand All @@ -97,7 +97,38 @@ public void TestBallTintChangedOnAccentChange()
AddAssert("ball is red", () => dho.ChildrenOfType<LegacySliderBall>().Single().BallColour == Color4.Red);
}

private Slider prepareObject(Slider slider)
[Test]
public void TestIncreaseRepeatCount()
{
DrawableSlider dho = null;

AddStep("create slider", () =>
{
Child = dho = new DrawableSlider(applyDefaults(new Slider
{
Position = new Vector2(256, 192),
IndexInCurrentCombo = 0,
StartTime = Time.Current,
Path = new SliderPath(PathType.LINEAR, new[]
{
Vector2.Zero,
new Vector2(150, 100),
new Vector2(300, 0),
})
}));
});

AddStep("increase repeat count", () =>
{
dho.HitObject.RepeatCount++;
applyDefaults(dho.HitObject);
});

AddAssert("repeat got custom anchor", () =>
dho.ChildrenOfType<DrawableSliderRepeat>().Single().RelativeAnchorPosition == Vector2.Divide(dho.SliderBody!.PathOffset, dho.DrawSize));
}

private Slider applyDefaults(Slider slider)
{
slider.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
return slider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
<PropertyGroup Label="Project">
Expand Down
10 changes: 6 additions & 4 deletions osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public partial class DrawableSlider : DrawableOsuHitObject
private Container<DrawableSliderRepeat> repeatContainer;
private PausableSkinnableSound slidingSample;

private readonly LayoutValue drawSizeLayout;
private readonly LayoutValue relativeAnchorPositionLayout;

public DrawableSlider()
: this(null)
Expand All @@ -85,7 +85,7 @@ public DrawableSlider([CanBeNull] Slider s = null)
AlwaysPresent = true,
Alpha = 0
};
AddLayout(drawSizeLayout = new LayoutValue(Invalidation.DrawSize | Invalidation.MiscGeometry));
AddLayout(relativeAnchorPositionLayout = new LayoutValue(Invalidation.DrawSize | Invalidation.MiscGeometry));
}

[BackgroundDependencyLoader]
Expand Down Expand Up @@ -190,6 +190,8 @@ protected override void AddNestedHitObject(DrawableHitObject hitObject)
repeatContainer.Add(repeat);
break;
}

relativeAnchorPositionLayout.Invalidate();
}

protected override void ClearNestedHitObjects()
Expand Down Expand Up @@ -265,14 +267,14 @@ protected override void UpdateAfterChildren()
Size = SliderBody?.Size ?? Vector2.Zero;
OriginPosition = SliderBody?.PathOffset ?? Vector2.Zero;

if (!drawSizeLayout.IsValid)
if (!relativeAnchorPositionLayout.IsValid)
{
Vector2 pos = Vector2.Divide(OriginPosition, DrawSize);
foreach (var obj in NestedHitObjects)
obj.RelativeAnchorPosition = pos;
Ball.RelativeAnchorPosition = pos;

drawSizeLayout.Validate();
relativeAnchorPositionLayout.Validate();
}
}

Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Osu/Skinning/Argon/ArgonCursor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace osu.Game.Rulesets.Osu.Skinning.Argon
{
public partial class ArgonCursor : OsuCursorSprite
public partial class ArgonCursor : SkinnableCursor
{
public ArgonCursor()
{
Expand Down
Loading

0 comments on commit b8dd78e

Please sign in to comment.