1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:07:52 +08:00

Merge branch 'master' into scoring-test-scene-mania

This commit is contained in:
Dean Herbert 2023-09-19 14:01:07 +09:00 committed by GitHub
commit 84d63f1445
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 296 additions and 7 deletions

View File

@ -19,6 +19,7 @@ namespace osu.Game.Rulesets.Osu.Tests
[TestCase("basic")]
[TestCase("colinear-perfect-curve")]
[TestCase("slider-ticks")]
[TestCase("slider-ticks-edge-case")]
[TestCase("repeat-slider")]
[TestCase("uneven-repeat-slider")]
[TestCase("old-stacking")]

View File

@ -16,6 +16,7 @@ using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Legacy;
using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Rulesets.Scoring;
@ -166,9 +167,11 @@ namespace osu.Game.Rulesets.Osu.Objects
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
double scoringDistance = BASE_SCORING_DISTANCE * difficulty.SliderMultiplier * SliderVelocityMultiplier;
Velocity = BASE_SCORING_DISTANCE * difficulty.SliderMultiplier / LegacyRulesetExtensions.GetPrecisionAdjustedBeatLength(this, timingPoint, OsuRuleset.SHORT_NAME);
// WARNING: this is intentionally not computed as `BASE_SCORING_DISTANCE * difficulty.SliderMultiplier`
// for backwards compatibility reasons (intentionally introducing floating point errors to match stable).
double scoringDistance = Velocity * timingPoint.BeatLength;
Velocity = scoringDistance / timingPoint.BeatLength;
TickDistance = GenerateTicks ? (scoringDistance / difficulty.SliderTickRate * TickDistanceMultiplier) : double.PositiveInfinity;
}

View File

@ -0,0 +1,39 @@
{
"Mappings": [
{
"StartTime": 7493.0,
"Objects": [
{
"StartTime": 7493.0,
"EndTime": 7493.0,
"X": 130.0,
"Y": 232.0,
"StackOffset": {
"X": 0.0,
"Y": 0.0
}
},
{
"StartTime": 7817.0,
"EndTime": 7817.0,
"X": 30.9946651,
"Y": 208.5157,
"StackOffset": {
"X": 0.0,
"Y": 0.0
}
},
{
"StartTime": 7843.0,
"EndTime": 7843.0,
"X": 33.7820168,
"Y": 208.9957,
"StackOffset": {
"X": 0.0,
"Y": 0.0
}
}
]
}
]
}

View File

@ -0,0 +1,31 @@
osu file format v14
[General]
StackLeniency: 0.7
[Difficulty]
HPDrainRate:3
CircleSize:3.4
OverallDifficulty:4
ApproachRate:5.5
SliderMultiplier:1.1
SliderTickRate:1
[Events]
//Background and Video events
0,0,"aa.jpg",0,0
//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]
6967,350.877192982456,6,2,1,55,1,0
6967,-100,3,2,1,55,0,0
7493,-111.111111111111,3,2,1,55,0,0
[HitObjects]
130,232,7493,6,0,P|78:218|28:208,1,101.82149697876,0|0,3:2|2:0,2:0:0:0:

View File

@ -32,8 +32,26 @@ namespace osu.Game.Tests.Chat
Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a gopher://really-old-protocol we don't support." });
Assert.AreEqual(result.Content, result.DisplayContent);
Assert.AreEqual(1, result.Links.Count);
Assert.AreEqual("gopher://really-old-protocol", result.Links[0].Url);
Assert.AreEqual(0, result.Links.Count);
}
[Test]
public void TestFakeProtocolLink()
{
Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a osunotarealprotocol://completely-made-up-protocol we don't support." });
Assert.AreEqual(result.Content, result.DisplayContent);
Assert.AreEqual(0, result.Links.Count);
}
[Test]
public void TestSupportedProtocolLinkParsing()
{
Message result = MessageFormatter.FormatMessage(new Message { Content = "forgotspacehttps://dev.ppy.sh joinmyosump://12345 jointheosu://chan/#english" });
Assert.AreEqual("https://dev.ppy.sh", result.Links[0].Url);
Assert.AreEqual("osump://12345", result.Links[1].Url);
Assert.AreEqual("osu://chan/#english", result.Links[2].Url);
}
[Test]

View File

@ -260,6 +260,12 @@ namespace osu.Game.Tests.Visual.Beatmaps
AddStep($"set {scheme} scheme", () => Child = createContent(scheme, creationFunc));
}
[Test]
public void TestNano()
{
createTestCase(beatmapSetInfo => new BeatmapCardNano(beatmapSetInfo));
}
[Test]
public void TestNormal()
{

View File

@ -67,6 +67,11 @@ namespace osu.Game.Tests.Visual.Gameplay
private Player loadPlayerFor(RulesetInfo rulesetInfo)
{
// if a player screen is present already, we must exit that before loading another one,
// otherwise it'll crash on SpectatorClient.BeginPlaying being called while client is in "playing" state already.
if (Stack.CurrentScreen is Player)
Stack.Exit();
Ruleset.Value = rulesetInfo;
var ruleset = rulesetInfo.CreateInstance();

View File

@ -64,6 +64,9 @@ namespace osu.Game.Tests.Visual.Online
addMessageWithChecks("test!");
addMessageWithChecks("dev.ppy.sh!");
addMessageWithChecks("https://dev.ppy.sh!", 1, expectedActions: LinkAction.External);
addMessageWithChecks("http://dev.ppy.sh!", 1, expectedActions: LinkAction.External);
addMessageWithChecks("forgothttps://dev.ppy.sh!", 1, expectedActions: LinkAction.External);
addMessageWithChecks("forgothttp://dev.ppy.sh!", 1, expectedActions: LinkAction.External);
addMessageWithChecks("00:12:345 (1,2) - Test?", 1, expectedActions: LinkAction.OpenEditorTimestamp);
addMessageWithChecks("Wiki link for tasty [[Performance Points]]", 1, expectedActions: LinkAction.OpenWiki);
addMessageWithChecks("(osu forums)[https://dev.ppy.sh/forum] (old link format)", 1, expectedActions: LinkAction.External);
@ -84,9 +87,11 @@ namespace osu.Game.Tests.Visual.Online
addMessageWithChecks("feels important", 0, true, true);
addMessageWithChecks("likes to post this [https://dev.ppy.sh/home link].", 1, true, true, expectedActions: LinkAction.External);
addMessageWithChecks("Join my multiplayer game osump://12346.", 1, expectedActions: LinkAction.JoinMultiplayerMatch);
addMessageWithChecks("Join my multiplayer gameosump://12346.", 1, expectedActions: LinkAction.JoinMultiplayerMatch);
addMessageWithChecks("Join my [multiplayer game](osump://12346).", 1, expectedActions: LinkAction.JoinMultiplayerMatch);
addMessageWithChecks($"Join my [#english]({OsuGameBase.OSU_PROTOCOL}chan/#english).", 1, expectedActions: LinkAction.OpenChannel);
addMessageWithChecks($"Join my {OsuGameBase.OSU_PROTOCOL}chan/#english.", 1, expectedActions: LinkAction.OpenChannel);
addMessageWithChecks($"Join my{OsuGameBase.OSU_PROTOCOL}chan/#english.", 1, expectedActions: LinkAction.OpenChannel);
addMessageWithChecks("Join my #english or #japanese channels.", 2, expectedActions: new[] { LinkAction.OpenChannel, LinkAction.OpenChannel });
addMessageWithChecks("Join my #english or #nonexistent #hashtag channels.", 1, expectedActions: LinkAction.OpenChannel);
addMessageWithChecks("Hello world\uD83D\uDE12(<--This is an emoji). There are more:\uD83D\uDE10\uD83D\uDE00,\uD83D\uDE20");

View File

@ -89,6 +89,9 @@ namespace osu.Game.Beatmaps.Drawables.Cards
{
switch (size)
{
case BeatmapCardSize.Nano:
return new BeatmapCardNano(beatmapSet);
case BeatmapCardSize.Normal:
return new BeatmapCardNormal(beatmapSet, allowExpansion);

View File

@ -0,0 +1,166 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
using osu.Game.Resources.Localisation.Web;
using osuTK;
namespace osu.Game.Beatmaps.Drawables.Cards
{
public partial class BeatmapCardNano : BeatmapCard
{
protected override Drawable IdleContent => idleBottomContent;
protected override Drawable DownloadInProgressContent => downloadProgressBar;
private const float height = 60;
private const float width = 300;
private const float cover_width = 80;
[Cached]
private readonly BeatmapCardContent content;
private BeatmapCardThumbnail thumbnail = null!;
private CollapsibleButtonContainer buttonContainer = null!;
private FillFlowContainer idleBottomContent = null!;
private BeatmapCardDownloadProgressBar downloadProgressBar = null!;
[Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!;
public BeatmapCardNano(APIBeatmapSet beatmapSet)
: base(beatmapSet, false)
{
content = new BeatmapCardContent(height);
}
[BackgroundDependencyLoader]
private void load()
{
Width = width;
Height = height;
Child = content.With(c =>
{
c.MainContent = new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
thumbnail = new BeatmapCardThumbnail(BeatmapSet)
{
Name = @"Left (icon) area",
Size = new Vector2(cover_width, height),
Padding = new MarginPadding { Right = CORNER_RADIUS },
},
buttonContainer = new CollapsibleButtonContainer(BeatmapSet)
{
X = cover_width - CORNER_RADIUS,
Width = width - cover_width + CORNER_RADIUS,
FavouriteState = { BindTarget = FavouriteState },
ButtonsCollapsedWidth = CORNER_RADIUS,
ButtonsExpandedWidth = 30,
Children = new Drawable[]
{
new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
new TruncatingSpriteText
{
Text = new RomanisableString(BeatmapSet.TitleUnicode, BeatmapSet.Title),
Font = OsuFont.Default.With(size: 19, weight: FontWeight.SemiBold),
RelativeSizeAxes = Axes.X,
},
new TruncatingSpriteText
{
Text = createArtistText(),
Font = OsuFont.Default.With(size: 16, weight: FontWeight.SemiBold),
RelativeSizeAxes = Axes.X,
},
}
},
new Container
{
Name = @"Bottom content",
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Children = new Drawable[]
{
idleBottomContent = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 3),
AlwaysPresent = true,
Children = new Drawable[]
{
new LinkFlowContainer(s =>
{
s.Shadow = false;
s.Font = OsuFont.GetFont(size: 16, weight: FontWeight.SemiBold);
}).With(d =>
{
d.AutoSizeAxes = Axes.Both;
d.Margin = new MarginPadding { Top = 2 };
d.AddText("mapped by ", t => t.Colour = colourProvider.Content2);
d.AddUserLink(BeatmapSet.Author);
}),
}
},
downloadProgressBar = new BeatmapCardDownloadProgressBar
{
RelativeSizeAxes = Axes.X,
Height = 6,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
State = { BindTarget = DownloadTracker.State },
Progress = { BindTarget = DownloadTracker.Progress }
}
}
}
}
}
}
};
c.ExpandedContent = new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Horizontal = 10, Vertical = 13 },
Child = new BeatmapCardDifficultyList(BeatmapSet)
};
c.Expanded.BindTarget = Expanded;
});
}
private LocalisableString createArtistText()
{
var romanisableArtist = new RomanisableString(BeatmapSet.ArtistUnicode, BeatmapSet.Artist);
return BeatmapsetsStrings.ShowDetailsByArtist(romanisableArtist);
}
protected override void UpdateState()
{
base.UpdateState();
bool showDetails = IsHovered;
buttonContainer.ShowDetails.Value = showDetails;
thumbnail.Dimmed.Value = showDetails;
}
}
}

View File

@ -8,6 +8,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards
/// </summary>
public enum BeatmapCardSize
{
Nano,
Normal,
Extra
}

View File

@ -36,9 +36,10 @@ namespace osu.Game.Beatmaps
BeatmapSet = new BeatmapSetInfo(),
Difficulty = new BeatmapDifficulty
{
DrainRate = 0,
CircleSize = 0,
DrainRate = 0,
OverallDifficulty = 0,
ApproachRate = 0,
},
Ruleset = new DummyRuleset().RulesetInfo
}, audio)

View File

@ -19,7 +19,7 @@ namespace osu.Game.IO.Archives
this.stream = stream;
}
public override Stream GetStream(string name) => new MemoryStream(stream.GetBuffer(), 0, (int)stream.Length);
public override Stream GetStream(string name) => new MemoryStream(stream.ToArray(), 0, (int)stream.Length);
public override void Dispose()
{

View File

@ -28,7 +28,7 @@ namespace osu.Game.Online.Chat
// http[s]://<domain>.<tld>[:port][/path][?query][#fragment]
private static readonly Regex advanced_link_regex = new Regex(
// protocol
@"(?<link>[a-z]*?:\/\/" +
@"(?<link>(https?|osu(mp)?):\/\/" +
// domain + tld
@"(?<domain>(?:[a-z0-9]\.|[a-z0-9][a-z0-9-]*[a-z0-9]\.)*[a-z0-9-]*[a-z0-9]" +
// port (optional)

View File

@ -22,8 +22,12 @@ namespace osu.Game.Overlays.BeatmapListing
public BeatmapListingCardSizeTabControl()
{
AutoSizeAxes = Axes.Both;
Items = new[] { BeatmapCardSize.Normal, BeatmapCardSize.Extra };
}
protected override bool AddEnumEntriesAutomatically => false;
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
{
AutoSizeAxes = Axes.Both,

View File

@ -12,6 +12,7 @@ using osu.Framework.Testing;
using osu.Game.Configuration;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Play;
namespace osu.Game.Tests.Visual
{
@ -79,6 +80,11 @@ namespace osu.Game.Tests.Visual
protected void LoadPlayer(Mod[] mods)
{
// if a player screen is present already, we must exit that before loading another one,
// otherwise it'll crash on SpectatorClient.BeginPlaying being called while client is in "playing" state already.
if (Stack.CurrentScreen is Player)
Stack.Exit();
var ruleset = CreatePlayerRuleset();
Ruleset.Value = ruleset.RulesetInfo;