mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 06:42:56 +08:00
Merge branch 'master' into open-profile-hotkey
This commit is contained in:
commit
6903ce1bcc
52
osu.Game.Rulesets.Mania.Tests/Skinning/TestSceneBarLine.cs
Normal file
52
osu.Game.Rulesets.Mania.Tests/Skinning/TestSceneBarLine.cs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
// 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 NUnit.Framework;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
|
using osu.Game.Rulesets.Mania.UI;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mania.Tests.Skinning
|
||||||
|
{
|
||||||
|
public class TestSceneBarLine : ManiaSkinnableTestScene
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestMinor()
|
||||||
|
{
|
||||||
|
AddStep("Create barlines", () => recreate());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void recreate(Func<IEnumerable<BarLine>>? createBarLines = null)
|
||||||
|
{
|
||||||
|
var stageDefinitions = new List<StageDefinition>
|
||||||
|
{
|
||||||
|
new StageDefinition { Columns = 4 },
|
||||||
|
};
|
||||||
|
|
||||||
|
SetContents(_ => new ManiaPlayfield(stageDefinitions).With(s =>
|
||||||
|
{
|
||||||
|
if (createBarLines != null)
|
||||||
|
{
|
||||||
|
var barLines = createBarLines();
|
||||||
|
|
||||||
|
foreach (var b in barLines)
|
||||||
|
s.Add(b);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 64; i++)
|
||||||
|
{
|
||||||
|
s.Add(new BarLine
|
||||||
|
{
|
||||||
|
StartTime = Time.Current + i * 500,
|
||||||
|
Major = i % 4 == 0,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,9 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||||
{
|
{
|
||||||
@ -16,21 +13,11 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class DrawableBarLine : DrawableManiaHitObject<BarLine>
|
public class DrawableBarLine : DrawableManiaHitObject<BarLine>
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Height of major bar line triangles.
|
|
||||||
/// </summary>
|
|
||||||
private const float triangle_height = 12;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Offset of the major bar line triangles from the sides of the bar line.
|
|
||||||
/// </summary>
|
|
||||||
private const float triangle_offset = 9;
|
|
||||||
|
|
||||||
public DrawableBarLine(BarLine barLine)
|
public DrawableBarLine(BarLine barLine)
|
||||||
: base(barLine)
|
: base(barLine)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
Height = 2f;
|
Height = barLine.Major ? 1.7f : 1.2f;
|
||||||
|
|
||||||
AddInternal(new Box
|
AddInternal(new Box
|
||||||
{
|
{
|
||||||
@ -38,34 +25,33 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
|||||||
Anchor = Anchor.BottomCentre,
|
Anchor = Anchor.BottomCentre,
|
||||||
Origin = Anchor.BottomCentre,
|
Origin = Anchor.BottomCentre,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = new Color4(255, 204, 33, 255),
|
Alpha = barLine.Major ? 0.5f : 0.2f
|
||||||
});
|
});
|
||||||
|
|
||||||
if (barLine.Major)
|
if (barLine.Major)
|
||||||
{
|
{
|
||||||
AddInternal(new EquilateralTriangle
|
Vector2 size = new Vector2(22, 6);
|
||||||
|
const float line_offset = 4;
|
||||||
|
|
||||||
|
AddInternal(new Circle
|
||||||
{
|
{
|
||||||
Name = "Left triangle",
|
Name = "Left line",
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.CentreRight,
|
||||||
Size = new Vector2(triangle_height),
|
|
||||||
X = -triangle_offset,
|
Size = size,
|
||||||
Rotation = 90
|
X = -line_offset,
|
||||||
});
|
});
|
||||||
|
|
||||||
AddInternal(new EquilateralTriangle
|
AddInternal(new Circle
|
||||||
{
|
{
|
||||||
Name = "Right triangle",
|
Name = "Right line",
|
||||||
Anchor = Anchor.BottomRight,
|
Anchor = Anchor.CentreRight,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.CentreLeft,
|
||||||
Size = new Vector2(triangle_height),
|
Size = size,
|
||||||
X = triangle_offset,
|
X = line_offset,
|
||||||
Rotation = -90
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!barLine.Major)
|
|
||||||
Alpha = 0.2f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateInitialTransforms()
|
protected override void UpdateInitialTransforms()
|
||||||
|
@ -134,6 +134,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
public void TestSoftDeleteSupport()
|
public void TestSoftDeleteSupport()
|
||||||
{
|
{
|
||||||
AddStep("set osu! ruleset", () => Ruleset.Value = rulesets.GetRuleset(0));
|
AddStep("set osu! ruleset", () => Ruleset.Value = rulesets.GetRuleset(0));
|
||||||
|
AddStep("clear mods", () => SelectedMods.Value = Array.Empty<Mod>());
|
||||||
AddStep("create content", () => Child = new ModPresetColumn
|
AddStep("create content", () => Child = new ModPresetColumn
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
@ -153,9 +154,11 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
foreach (var preset in r.All<ModPreset>())
|
foreach (var preset in r.All<ModPreset>())
|
||||||
preset.DeletePending = true;
|
preset.DeletePending = true;
|
||||||
}));
|
}));
|
||||||
AddUntilStep("no panels visible", () => this.ChildrenOfType<ModPresetPanel>().Count() == 0);
|
AddUntilStep("no panels visible", () => !this.ChildrenOfType<ModPresetPanel>().Any());
|
||||||
|
|
||||||
AddStep("undelete preset", () => Realm.Write(r =>
|
AddStep("select mods from first preset", () => SelectedMods.Value = new Mod[] { new OsuModDoubleTime(), new OsuModHardRock() });
|
||||||
|
|
||||||
|
AddStep("undelete presets", () => Realm.Write(r =>
|
||||||
{
|
{
|
||||||
foreach (var preset in r.All<ModPreset>())
|
foreach (var preset in r.All<ModPreset>())
|
||||||
preset.DeletePending = false;
|
preset.DeletePending = false;
|
||||||
|
@ -7,6 +7,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Localisation;
|
using osu.Game.Localisation;
|
||||||
@ -66,7 +67,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
if (!presets.Any())
|
if (!presets.Any())
|
||||||
{
|
{
|
||||||
ItemsFlow.RemoveAll(panel => panel is ModPresetPanel);
|
removeAndDisposePresetPanels();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,9 +76,15 @@ namespace osu.Game.Overlays.Mods
|
|||||||
Shear = Vector2.Zero
|
Shear = Vector2.Zero
|
||||||
}), loaded =>
|
}), loaded =>
|
||||||
{
|
{
|
||||||
ItemsFlow.RemoveAll(panel => panel is ModPresetPanel);
|
removeAndDisposePresetPanels();
|
||||||
ItemsFlow.AddRange(loaded);
|
ItemsFlow.AddRange(loaded);
|
||||||
}, (cancellationTokenSource = new CancellationTokenSource()).Token);
|
}, (cancellationTokenSource = new CancellationTokenSource()).Token);
|
||||||
|
|
||||||
|
void removeAndDisposePresetPanels()
|
||||||
|
{
|
||||||
|
foreach (var panel in ItemsFlow.OfType<ModPresetPanel>().ToArray())
|
||||||
|
panel.RemoveAndDisposeImmediately();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
|
@ -10,6 +10,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
|
using osu.Game.Online.Spectator;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
@ -46,6 +47,9 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
public readonly List<JudgementResult> Results = new List<JudgementResult>();
|
public readonly List<JudgementResult> Results = new List<JudgementResult>();
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private SpectatorClient spectatorClient { get; set; }
|
||||||
|
|
||||||
public TestPlayer(bool allowPause = true, bool showResults = true, bool pauseOnFocusLost = false)
|
public TestPlayer(bool allowPause = true, bool showResults = true, bool pauseOnFocusLost = false)
|
||||||
: base(new PlayerConfiguration
|
: base(new PlayerConfiguration
|
||||||
{
|
{
|
||||||
@ -98,5 +102,15 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
ScoreProcessor.NewJudgement += r => Results.Add(r);
|
ScoreProcessor.NewJudgement += r => Results.Add(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
|
// Specific to tests, the player can be disposed without OnExiting() ever being called.
|
||||||
|
// We should make sure that the gameplay session has finished even in this case.
|
||||||
|
if (LoadedBeatmapSuccessfully)
|
||||||
|
spectatorClient.EndPlaying(GameplayState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user