Merge branch 'master' into play-to-gameplay

This commit is contained in:
Dean Herbert 2019-09-03 11:42:15 +09:00 committed by GitHub
commit 0261456d5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
53 changed files with 1432 additions and 103 deletions

View File

@ -61,6 +61,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.830.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.830.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.830.1" />
</ItemGroup>
</Project>

View File

@ -4,7 +4,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup>
<PropertyGroup Label="Project">

View File

@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Catch
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new CatchBeatmapConverter(beatmap);
public override IBeatmapProcessor CreateBeatmapProcessor(IBeatmap beatmap) => new CatchBeatmapProcessor(beatmap);
public const string SHORT_NAME = "catch";
public const string SHORT_NAME = "fruits";
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
{

View File

@ -4,7 +4,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup>
<PropertyGroup Label="Project">

View File

@ -4,7 +4,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup>
<PropertyGroup Label="Project">

View File

@ -101,7 +101,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
return !hasFont(font)
? null
: new LegacySpriteText(this, font)
: new LegacySpriteText(source, font)
{
// Spacing value was reverse-engineered from the ratio of the rendered sprite size in the visual inspector vs the actual texture size
Scale = new Vector2(0.96f),
@ -112,13 +112,19 @@ namespace osu.Game.Rulesets.Osu.Skinning
return null;
}
public Texture GetTexture(string componentName) => null;
public Texture GetTexture(string componentName) => source.GetTexture(componentName);
public SampleChannel GetSample(ISampleInfo sample) => null;
public SampleChannel GetSample(ISampleInfo sample) => source.GetSample(sample);
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration
=> configuration.Value is TConfiguration conf ? query.Invoke(conf) : default;
{
TValue val;
if (configuration.Value is TConfiguration conf && (val = query.Invoke(conf)) != null)
return val;
private bool hasFont(string fontName) => GetTexture($"{fontName}-0") != null;
return source.GetValue(query);
}
private bool hasFont(string fontName) => source.GetTexture($"{fontName}-0") != null;
}
}

View File

@ -0,0 +1,74 @@
// 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.Game.Beatmaps;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Judgements;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Screens.Play;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Taiko.Tests
{
public class TestSceneSwellJudgements : PlayerTestScene
{
protected new TestPlayer Player => (TestPlayer)base.Player;
public TestSceneSwellJudgements()
: base(new TaikoRuleset())
{
}
[Test]
public void TestZeroTickTimeOffsets()
{
AddUntilStep("gameplay finished", () => Player.ScoreProcessor.HasCompleted);
AddAssert("all tick offsets are 0", () => Player.Results.Where(r => r.Judgement is TaikoSwellTickJudgement).All(r => r.TimeOffset == 0));
}
protected override bool Autoplay => true;
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
{
var beatmap = new Beatmap<TaikoHitObject>
{
BeatmapInfo = { Ruleset = new TaikoRuleset().RulesetInfo },
HitObjects =
{
new Swell
{
StartTime = 1000,
Duration = 1000,
}
}
};
return beatmap;
}
protected override Player CreatePlayer(Ruleset ruleset) => new TestPlayer();
protected class TestPlayer : Player
{
public readonly List<JudgementResult> Results = new List<JudgementResult>();
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
public TestPlayer()
: base(false, false)
{
}
[BackgroundDependencyLoader]
private void load()
{
ScoreProcessor.NewJudgement += r => Results.Add(r);
}
}
}
}

View File

@ -4,7 +4,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup>
<PropertyGroup Label="Project">

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 osu.Framework.Graphics;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
@ -14,7 +15,13 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{
}
public void TriggerResult(HitResult type) => ApplyResult(r => r.Type = type);
protected override void UpdateInitialTransforms() => this.FadeOut();
public void TriggerResult(HitResult type)
{
HitObject.StartTime = Time.Current;
ApplyResult(r => r.Type = type);
}
protected override void CheckForResult(bool userTriggered, double timeOffset)
{

View File

@ -0,0 +1,119 @@
// 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.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Catch.Objects;
using System;
using System.Collections.Generic;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring;
using osu.Framework.MathUtils;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Screens.Play.HUD.HitErrorMeters;
namespace osu.Game.Tests.Visual.Gameplay
{
public class TestSceneBarHitErrorMeter : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(HitErrorMeter),
};
private HitErrorMeter meter;
private HitErrorMeter meter2;
private HitWindows hitWindows;
public TestSceneBarHitErrorMeter()
{
recreateDisplay(new OsuHitWindows(), 5);
AddRepeatStep("New random judgement", () => newJudgement(), 40);
AddRepeatStep("New max negative", () => newJudgement(-hitWindows.HalfWindowFor(HitResult.Meh)), 20);
AddRepeatStep("New max positive", () => newJudgement(hitWindows.HalfWindowFor(HitResult.Meh)), 20);
AddStep("New fixed judgement (50ms)", () => newJudgement(50));
}
[Test]
public void TestOsu()
{
AddStep("OD 1", () => recreateDisplay(new OsuHitWindows(), 1));
AddStep("OD 10", () => recreateDisplay(new OsuHitWindows(), 10));
}
[Test]
public void TestTaiko()
{
AddStep("OD 1", () => recreateDisplay(new TaikoHitWindows(), 1));
AddStep("OD 10", () => recreateDisplay(new TaikoHitWindows(), 10));
}
[Test]
public void TestMania()
{
AddStep("OD 1", () => recreateDisplay(new ManiaHitWindows(), 1));
AddStep("OD 10", () => recreateDisplay(new ManiaHitWindows(), 10));
}
[Test]
public void TestCatch()
{
AddStep("OD 1", () => recreateDisplay(new CatchHitWindows(), 1));
AddStep("OD 10", () => recreateDisplay(new CatchHitWindows(), 10));
}
private void recreateDisplay(HitWindows hitWindows, float overallDifficulty)
{
this.hitWindows = hitWindows;
hitWindows?.SetDifficulty(overallDifficulty);
Clear();
Add(new FillFlowContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Direction = FillDirection.Vertical,
AutoSizeAxes = Axes.Both,
Children = new[]
{
new SpriteText { Text = $@"Great: {hitWindows?.Great}" },
new SpriteText { Text = $@"Good: {hitWindows?.Good}" },
new SpriteText { Text = $@"Meh: {hitWindows?.Meh}" },
}
});
Add(meter = new BarHitErrorMeter(hitWindows, true)
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
});
Add(meter2 = new BarHitErrorMeter(hitWindows, false)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
});
}
private void newJudgement(double offset = 0)
{
var judgement = new JudgementResult(new Judgement())
{
TimeOffset = offset == 0 ? RNG.Next(-150, 150) : offset,
Type = HitResult.Perfect,
};
meter.OnNewJudgement(judgement);
meter2.OnNewJudgement(judgement);
}
}
}

View File

@ -176,6 +176,8 @@ namespace osu.Game.Tests.Visual.Online
HasVideo = true,
HasStoryboard = true,
Covers = new BeatmapSetOnlineCovers(),
Language = new BeatmapSetOnlineLanguage { Id = 3, Name = "English" },
Genre = new BeatmapSetOnlineGenre { Id = 4, Name = "Rock" },
},
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() },
Beatmaps = new List<BeatmapInfo>

View File

@ -0,0 +1,246 @@
// 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.Game.Overlays.Profile.Sections.Kudosu;
using System.Collections.Generic;
using System;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics;
using osu.Game.Online.API.Requests.Responses;
using osu.Framework.Extensions.IEnumerableExtensions;
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneKudosuHistory : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(DrawableKudosuHistoryItem),
};
private readonly Box background;
public TestSceneKudosuHistory()
{
FillFlowContainer<DrawableKudosuHistoryItem> content;
AddRange(new Drawable[]
{
background = new Box
{
RelativeSizeAxes = Axes.Both,
},
content = new FillFlowContainer<DrawableKudosuHistoryItem>
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.X,
Width = 0.7f,
AutoSizeAxes = Axes.Y,
}
});
items.ForEach(t => content.Add(new DrawableKudosuHistoryItem(t)));
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
background.Colour = colours.GreySeafoam;
}
private readonly IEnumerable<APIKudosuHistory> items = new[]
{
new APIKudosuHistory
{
Amount = 10,
CreatedAt = new DateTimeOffset(new DateTime(2011, 11, 11)),
Source = KudosuSource.DenyKudosu,
Action = KudosuAction.Reset,
Post = new APIKudosuHistory.ModdingPost
{
Title = @"Random post 1",
Url = @"https://osu.ppy.sh/b/1234",
},
Giver = new APIKudosuHistory.KudosuGiver
{
Username = @"Username1",
Url = @"https://osu.ppy.sh/u/1234"
}
},
new APIKudosuHistory
{
Amount = 5,
CreatedAt = new DateTimeOffset(new DateTime(2012, 10, 11)),
Source = KudosuSource.Forum,
Action = KudosuAction.Give,
Post = new APIKudosuHistory.ModdingPost
{
Title = @"Random post 2",
Url = @"https://osu.ppy.sh/b/1234",
},
Giver = new APIKudosuHistory.KudosuGiver
{
Username = @"Username2",
Url = @"https://osu.ppy.sh/u/1234"
}
},
new APIKudosuHistory
{
Amount = 8,
CreatedAt = new DateTimeOffset(new DateTime(2013, 9, 11)),
Source = KudosuSource.Forum,
Action = KudosuAction.Reset,
Post = new APIKudosuHistory.ModdingPost
{
Title = @"Random post 3",
Url = @"https://osu.ppy.sh/b/1234",
},
Giver = new APIKudosuHistory.KudosuGiver
{
Username = @"Username3",
Url = @"https://osu.ppy.sh/u/1234"
}
},
new APIKudosuHistory
{
Amount = 7,
CreatedAt = new DateTimeOffset(new DateTime(2014, 8, 11)),
Source = KudosuSource.Forum,
Action = KudosuAction.Revoke,
Post = new APIKudosuHistory.ModdingPost
{
Title = @"Random post 4",
Url = @"https://osu.ppy.sh/b/1234",
},
Giver = new APIKudosuHistory.KudosuGiver
{
Username = @"Username4",
Url = @"https://osu.ppy.sh/u/1234"
}
},
new APIKudosuHistory
{
Amount = 100,
CreatedAt = new DateTimeOffset(new DateTime(2015, 7, 11)),
Source = KudosuSource.Vote,
Action = KudosuAction.Give,
Post = new APIKudosuHistory.ModdingPost
{
Title = @"Random post 5",
Url = @"https://osu.ppy.sh/b/1234",
},
Giver = new APIKudosuHistory.KudosuGiver
{
Username = @"Username5",
Url = @"https://osu.ppy.sh/u/1234"
}
},
new APIKudosuHistory
{
Amount = 20,
CreatedAt = new DateTimeOffset(new DateTime(2016, 6, 11)),
Source = KudosuSource.Vote,
Action = KudosuAction.Reset,
Post = new APIKudosuHistory.ModdingPost
{
Title = @"Random post 6",
Url = @"https://osu.ppy.sh/b/1234",
},
Giver = new APIKudosuHistory.KudosuGiver
{
Username = @"Username6",
Url = @"https://osu.ppy.sh/u/1234"
}
},
new APIKudosuHistory
{
Amount = 11,
CreatedAt = new DateTimeOffset(new DateTime(2016, 6, 11)),
Source = KudosuSource.AllowKudosu,
Action = KudosuAction.Give,
Post = new APIKudosuHistory.ModdingPost
{
Title = @"Random post 7",
Url = @"https://osu.ppy.sh/b/1234",
},
Giver = new APIKudosuHistory.KudosuGiver
{
Username = @"Username7",
Url = @"https://osu.ppy.sh/u/1234"
}
},
new APIKudosuHistory
{
Amount = 24,
CreatedAt = new DateTimeOffset(new DateTime(2014, 6, 11)),
Source = KudosuSource.Delete,
Action = KudosuAction.Reset,
Post = new APIKudosuHistory.ModdingPost
{
Title = @"Random post 8",
Url = @"https://osu.ppy.sh/b/1234",
},
Giver = new APIKudosuHistory.KudosuGiver
{
Username = @"Username8",
Url = @"https://osu.ppy.sh/u/1234"
}
},
new APIKudosuHistory
{
Amount = 12,
CreatedAt = new DateTimeOffset(new DateTime(2016, 6, 11)),
Source = KudosuSource.Restore,
Action = KudosuAction.Give,
Post = new APIKudosuHistory.ModdingPost
{
Title = @"Random post 9",
Url = @"https://osu.ppy.sh/b/1234",
},
Giver = new APIKudosuHistory.KudosuGiver
{
Username = @"Username9",
Url = @"https://osu.ppy.sh/u/1234"
}
},
new APIKudosuHistory
{
Amount = 2,
CreatedAt = new DateTimeOffset(new DateTime(2012, 6, 11)),
Source = KudosuSource.Recalculate,
Action = KudosuAction.Give,
Post = new APIKudosuHistory.ModdingPost
{
Title = @"Random post 10",
Url = @"https://osu.ppy.sh/b/1234",
},
Giver = new APIKudosuHistory.KudosuGiver
{
Username = @"Username10",
Url = @"https://osu.ppy.sh/u/1234"
}
},
new APIKudosuHistory
{
Amount = 32,
CreatedAt = new DateTimeOffset(new DateTime(2019, 8, 11)),
Source = KudosuSource.Recalculate,
Action = KudosuAction.Reset,
Post = new APIKudosuHistory.ModdingPost
{
Title = @"Random post 11",
Url = @"https://osu.ppy.sh/b/1234",
},
Giver = new APIKudosuHistory.KudosuGiver
{
Username = @"Username11",
Url = @"https://osu.ppy.sh/u/1234"
}
}
};
}
}

View File

@ -5,7 +5,7 @@
<PackageReference Include="DeepEqual" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup>
<PropertyGroup Label="Project">

View File

@ -7,7 +7,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
</ItemGroup>
<PropertyGroup Label="Project">
<OutputType>WinExe</OutputType>

View File

@ -75,6 +75,28 @@ namespace osu.Game.Beatmaps
/// The availability of this beatmap set.
/// </summary>
public BeatmapSetOnlineAvailability Availability { get; set; }
/// <summary>
/// The song genre of this beatmap set.
/// </summary>
public BeatmapSetOnlineGenre Genre { get; set; }
/// <summary>
/// The song language of this beatmap set.
/// </summary>
public BeatmapSetOnlineLanguage Language { get; set; }
}
public class BeatmapSetOnlineGenre
{
public int Id { get; set; }
public string Name { get; set; }
}
public class BeatmapSetOnlineLanguage
{
public int Id { get; set; }
public string Name { get; set; }
}
public class BeatmapSetOnlineCovers

View File

@ -83,6 +83,7 @@ namespace osu.Game.Configuration
Set(OsuSetting.ShowInterface, true);
Set(OsuSetting.ShowHealthDisplayWhenCantFail, true);
Set(OsuSetting.KeyOverlay, false);
Set(OsuSetting.ScoreMeter, ScoreMeterType.HitErrorBoth);
Set(OsuSetting.FloatingComments, false);
@ -136,6 +137,7 @@ namespace osu.Game.Configuration
BlurLevel,
ShowStoryboard,
KeyOverlay,
ScoreMeter,
FloatingComments,
ShowInterface,
ShowHealthDisplayWhenCantFail,

View File

@ -1,12 +1,22 @@
// 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.ComponentModel;
namespace osu.Game.Configuration
{
public enum ScoreMeterType
{
[Description("None")]
None,
Colour,
Error
[Description("Hit Error (left)")]
HitErrorLeft,
[Description("Hit Error (right)")]
HitErrorRight,
[Description("Hit Error (both)")]
HitErrorBoth,
}
}

View File

@ -0,0 +1,21 @@
// 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 osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Online.API.Requests
{
public class GetUserKudosuHistoryRequest : PaginatedAPIRequest<List<APIKudosuHistory>>
{
private readonly long userId;
public GetUserKudosuHistoryRequest(long userId, int page = 0, int itemsPerPage = 5)
: base(page, itemsPerPage)
{
this.userId = userId;
}
protected override string Target => $"users/{userId}/kudosu";
}
}

View File

@ -69,6 +69,12 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"availability")]
private BeatmapSetOnlineAvailability availability { get; set; }
[JsonProperty(@"genre")]
private BeatmapSetOnlineGenre genre { get; set; }
[JsonProperty(@"language")]
private BeatmapSetOnlineLanguage language { get; set; }
[JsonProperty(@"beatmaps")]
private IEnumerable<APIBeatmap> beatmaps { get; set; }
@ -95,6 +101,8 @@ namespace osu.Game.Online.API.Requests.Responses
LastUpdated = lastUpdated,
Availability = availability,
HasFavourited = hasFavourited,
Genre = genre,
Language = language
},
Beatmaps = beatmaps?.Select(b => b.ToBeatmap(rulesets)).ToList(),
};

View File

@ -0,0 +1,83 @@
// 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.Linq;
using Newtonsoft.Json;
namespace osu.Game.Online.API.Requests.Responses
{
public class APIKudosuHistory
{
[JsonProperty("created_at")]
public DateTimeOffset CreatedAt;
[JsonProperty("amount")]
public int Amount;
[JsonProperty("post")]
public ModdingPost Post;
public class ModdingPost
{
[JsonProperty("url")]
public string Url;
[JsonProperty("title")]
public string Title;
}
[JsonProperty("giver")]
public KudosuGiver Giver;
public class KudosuGiver
{
[JsonProperty("url")]
public string Url;
[JsonProperty("username")]
public string Username;
}
public KudosuSource Source;
public KudosuAction Action;
[JsonProperty("action")]
private string action
{
set
{
// incoming action may contain a prefix. if it doesn't, it's a legacy forum event.
string[] split = value.Split('.');
if (split.Length > 1)
Enum.TryParse(split.First().Replace("_", ""), true, out Source);
else
Source = KudosuSource.Forum;
Enum.TryParse(split.Last(), true, out Action);
}
}
}
public enum KudosuSource
{
Unknown,
AllowKudosu,
Delete,
DenyKudosu,
Forum,
Recalculate,
Restore,
Vote
}
public enum KudosuAction
{
Give,
Reset,
Revoke,
}
}

View File

@ -36,7 +36,7 @@ namespace osu.Game.Overlays.BeatmapSet
public Info()
{
MetadataSection source, tags;
MetadataSection source, tags, genre, language;
RelativeSizeAxes = Axes.X;
Height = 220;
Masking = true;
@ -83,11 +83,12 @@ namespace osu.Game.Overlays.BeatmapSet
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
LayoutDuration = transition_duration,
Direction = FillDirection.Full,
Children = new[]
{
source = new MetadataSection("Source"),
genre = new MetadataSection("Genre") { Width = 0.5f },
language = new MetadataSection("Language") { Width = 0.5f },
tags = new MetadataSection("Tags"),
},
},
@ -119,6 +120,8 @@ namespace osu.Game.Overlays.BeatmapSet
{
source.Text = b.NewValue?.Metadata.Source ?? string.Empty;
tags.Text = b.NewValue?.Metadata.Tags ?? string.Empty;
genre.Text = b.NewValue?.OnlineInfo?.Genre?.Name ?? string.Empty;
language.Text = b.NewValue?.OnlineInfo?.Language?.Name ?? string.Empty;
};
}
@ -139,7 +142,7 @@ namespace osu.Game.Overlays.BeatmapSet
{
if (string.IsNullOrEmpty(value))
{
this.FadeOut(transition_duration);
Hide();
return;
}
@ -149,12 +152,6 @@ namespace osu.Game.Overlays.BeatmapSet
}
}
public Color4 TextColour
{
get => textFlow.Colour;
set => textFlow.Colour = value;
}
public MetadataSection(string title)
{
RelativeSizeAxes = Axes.X;

View File

@ -36,7 +36,7 @@ namespace osu.Game.Overlays.Chat.Selection
private Color4 topicColour;
private Color4 hoverColour;
public IEnumerable<string> FilterTerms => new[] { channel.Name };
public IEnumerable<string> FilterTerms => new[] { channel.Name, channel.Topic };
public bool MatchingFilter
{

View File

@ -35,7 +35,7 @@ namespace osu.Game.Overlays.Direct
private BeatmapSetOverlay beatmapSetOverlay;
public PreviewTrack Preview => PlayButton.Preview;
public Bindable<bool> PreviewPlaying => PlayButton.Playing;
public Bindable<bool> PreviewPlaying => PlayButton?.Playing;
protected abstract PlayButton PlayButton { get; }
protected abstract Box PreviewBar { get; }

View File

@ -296,7 +296,11 @@ namespace osu.Game.Overlays.Profile.Header.Components
this.MoveTo(pos, 200, Easing.OutQuint);
}
protected override void PopIn() => this.FadeIn(200, Easing.OutQuint);
protected override void PopIn()
{
instantMove |= !IsPresent;
this.FadeIn(200, Easing.OutQuint);
}
protected override void PopOut() => this.FadeOut(200, Easing.OutQuint);
}

View File

@ -0,0 +1,147 @@
// 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.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Chat;
using System;
using osuTK;
namespace osu.Game.Overlays.Profile.Sections.Kudosu
{
public class DrawableKudosuHistoryItem : CompositeDrawable
{
private const int height = 25;
[Resolved]
private OsuColour colours { get; set; }
private readonly APIKudosuHistory historyItem;
private readonly LinkFlowContainer linkFlowContainer;
private readonly DrawableDate date;
public DrawableKudosuHistoryItem(APIKudosuHistory historyItem)
{
this.historyItem = historyItem;
Height = height;
RelativeSizeAxes = Axes.X;
AddRangeInternal(new Drawable[]
{
linkFlowContainer = new LinkFlowContainer
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
Spacing = new Vector2(0, 3),
},
date = new DrawableDate(historyItem.CreatedAt)
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
}
});
}
[BackgroundDependencyLoader]
private void load()
{
date.Colour = colours.GreySeafoamLighter;
var formattedSource = MessageFormatter.FormatText(getString(historyItem));
linkFlowContainer.AddLinks(formattedSource.Text, formattedSource.Links);
}
private string getString(APIKudosuHistory item)
{
string amount = $"{Math.Abs(item.Amount)} kudosu";
string post = $"[{item.Post.Title}]({item.Post.Url})";
switch (item.Source)
{
case KudosuSource.AllowKudosu:
switch (item.Action)
{
case KudosuAction.Give:
return $"Received {amount} from kudosu deny repeal of modding post {post}";
}
break;
case KudosuSource.DenyKudosu:
switch (item.Action)
{
case KudosuAction.Reset:
return $"Denied {amount} from modding post {post}";
}
break;
case KudosuSource.Delete:
switch (item.Action)
{
case KudosuAction.Reset:
return $"Lost {amount} from modding post deletion of {post}";
}
break;
case KudosuSource.Restore:
switch (item.Action)
{
case KudosuAction.Give:
return $"Received {amount} from modding post restoration of {post}";
}
break;
case KudosuSource.Vote:
switch (item.Action)
{
case KudosuAction.Give:
return $"Received {amount} from obtaining votes in modding post of {post}";
case KudosuAction.Reset:
return $"Lost {amount} from losing votes in modding post of {post}";
}
break;
case KudosuSource.Recalculate:
switch (item.Action)
{
case KudosuAction.Give:
return $"Received {amount} from votes recalculation in modding post of {post}";
case KudosuAction.Reset:
return $"Lost {amount} from votes recalculation in modding post of {post}";
}
break;
case KudosuSource.Forum:
string giver = $"[{item.Giver?.Username}]({item.Giver?.Url})";
switch (historyItem.Action)
{
case KudosuAction.Give:
return $"Received {amount} from {giver} for a post at {post}";
case KudosuAction.Reset:
return $"Kudosu reset by {giver} for the post {post}";
case KudosuAction.Revoke:
return $"Denied kudosu by {giver} for the post {post}";
}
break;
}
return $"Unknown event ({amount} change)";
}
}
}

View File

@ -0,0 +1,27 @@
// 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.Graphics;
using osu.Game.Online.API.Requests;
using osu.Game.Users;
using osu.Framework.Bindables;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.API;
using System.Collections.Generic;
namespace osu.Game.Overlays.Profile.Sections.Kudosu
{
public class PaginatedKudosuHistoryContainer : PaginatedContainer<APIKudosuHistory>
{
public PaginatedKudosuHistoryContainer(Bindable<User> user, string header, string missing)
: base(user, header, missing)
{
ItemsPerPage = 5;
}
protected override APIRequest<List<APIKudosuHistory>> CreateRequest()
=> new GetUserKudosuHistoryRequest(User.Value.Id, VisiblePages++, ItemsPerPage);
protected override Drawable CreateDrawableItem(APIKudosuHistory item) => new DrawableKudosuHistoryItem(item);
}
}

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 osu.Framework.Graphics;
using osu.Game.Overlays.Profile.Sections.Kudosu;
namespace osu.Game.Overlays.Profile.Sections
@ -13,9 +14,10 @@ namespace osu.Game.Overlays.Profile.Sections
public KudosuSection()
{
Children = new[]
Children = new Drawable[]
{
new KudosuInfo(User),
new PaginatedKudosuHistoryContainer(User, null, @"This user hasn't received any kudosu!"),
};
}
}

View File

@ -44,6 +44,11 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
LabelText = "Always show key overlay",
Bindable = config.GetBindable<bool>(OsuSetting.KeyOverlay)
},
new SettingsEnumDropdown<ScoreMeterType>
{
LabelText = "Score meter type",
Bindable = config.GetBindable<ScoreMeterType>(OsuSetting.ScoreMeter)
},
new SettingsEnumDropdown<ScoringMode>
{
LabelText = "Score display mode",

View File

@ -9,6 +9,7 @@ using osu.Framework.Bindables;
using osu.Framework.Extensions.TypeExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Threading;
using osu.Game.Audio;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Types;
@ -278,6 +279,14 @@ namespace osu.Game.Rulesets.Objects.Drawables
UpdateResult(false);
}
/// <summary>
/// Schedules an <see cref="Action"/> to this <see cref="DrawableHitObject"/>.
/// </summary>
/// <remarks>
/// Only provided temporarily until hitobject pooling is implemented.
/// </remarks>
protected internal new ScheduledDelegate Schedule(Action action) => base.Schedule(action);
private double? lifetimeStart;
public override double LifetimeStart

View File

@ -65,6 +65,19 @@ namespace osu.Game.Rulesets.Objects
return HitResult.None;
}
/// <summary>
/// Retrieves a mapping of <see cref="HitResult"/>s to their half window timing for all allowed <see cref="HitResult"/>s.
/// </summary>
/// <returns></returns>
public IEnumerable<(HitResult result, double length)> GetAllAvailableHalfWindows()
{
for (var result = HitResult.Meh; result <= HitResult.Perfect; ++result)
{
if (IsHitResultAllowed(result))
yield return (result, HalfWindowFor(result));
}
}
/// <summary>
/// Check whether it is possible to achieve the provided <see cref="HitResult"/>.
/// </summary>

View File

@ -90,7 +90,7 @@ namespace osu.Game.Rulesets.Scoring
/// <summary>
/// Whether all <see cref="Judgement"/>s have been processed.
/// </summary>
protected virtual bool HasCompleted => false;
public virtual bool HasCompleted => false;
/// <summary>
/// Whether this ScoreProcessor has already triggered the failed state.
@ -205,7 +205,7 @@ namespace osu.Game.Rulesets.Scoring
private const double combo_portion = 0.7;
private const double max_score = 1000000;
protected sealed override bool HasCompleted => JudgedHits == MaxHits;
public sealed override bool HasCompleted => JudgedHits == MaxHits;
protected int MaxHits { get; private set; }
protected int JudgedHits { get; private set; }

View File

@ -215,10 +215,6 @@ namespace osu.Game.Rulesets.UI
continueResume();
}
public ResumeOverlay ResumeOverlay { get; private set; }
protected virtual ResumeOverlay CreateResumeOverlay() => null;
/// <summary>
/// Creates and adds the visual representation of a <see cref="TObject"/> to this <see cref="DrawableRuleset{TObject}"/>.
/// </summary>
@ -389,6 +385,13 @@ namespace osu.Game.Rulesets.UI
/// </summary>
public abstract GameplayCursorContainer Cursor { get; }
/// <summary>
/// An optional overlay used when resuming gameplay from a paused state.
/// </summary>
public ResumeOverlay ResumeOverlay { get; protected set; }
protected virtual ResumeOverlay CreateResumeOverlay() => null;
/// <summary>
/// Sets a replay to be used, overriding local input.
/// </summary>

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.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Caching;
@ -50,8 +51,13 @@ namespace osu.Game.Rulesets.UI.Scrolling
public override bool Remove(DrawableHitObject hitObject)
{
var result = base.Remove(hitObject);
if (result)
{
initialStateCache.Invalidate();
hitObjectInitialStateCache.Remove(hitObject);
}
return result;
}
@ -86,13 +92,34 @@ namespace osu.Game.Rulesets.UI.Scrolling
scrollingInfo.Algorithm.Reset();
foreach (var obj in Objects)
{
computeLifetimeStartRecursive(obj);
computeInitialStateRecursive(obj);
}
initialStateCache.Validate();
}
}
private void computeInitialStateRecursive(DrawableHitObject hitObject)
private void computeLifetimeStartRecursive(DrawableHitObject hitObject)
{
hitObject.LifetimeStart = scrollingInfo.Algorithm.GetDisplayStartTime(hitObject.HitObject.StartTime, timeRange.Value);
foreach (var obj in hitObject.NestedHitObjects)
computeLifetimeStartRecursive(obj);
}
private readonly Dictionary<DrawableHitObject, Cached> hitObjectInitialStateCache = new Dictionary<DrawableHitObject, Cached>();
// Cant use AddOnce() since the delegate is re-constructed every invocation
private void computeInitialStateRecursive(DrawableHitObject hitObject) => hitObject.Schedule(() =>
{
if (!hitObjectInitialStateCache.TryGetValue(hitObject, out var cached))
cached = hitObjectInitialStateCache[hitObject] = new Cached();
if (cached.IsValid)
return;
double endTime = hitObject.HitObject.StartTime;
if (hitObject.HitObject is IHasEndTime e)
@ -113,7 +140,6 @@ namespace osu.Game.Rulesets.UI.Scrolling
}
}
hitObject.LifetimeStart = scrollingInfo.Algorithm.GetDisplayStartTime(hitObject.HitObject.StartTime, timeRange.Value);
hitObject.LifetimeEnd = scrollingInfo.Algorithm.TimeAt(scrollLength * safe_lifetime_end_multiplier, endTime, timeRange.Value, scrollLength);
foreach (var obj in hitObject.NestedHitObjects)
@ -123,7 +149,9 @@ namespace osu.Game.Rulesets.UI.Scrolling
// Nested hitobjects don't need to scroll, but they do need accurate positions
updatePosition(obj, hitObject.HitObject.StartTime);
}
}
cached.Validate();
});
protected override void UpdateAfterChildrenLife()
{

View File

@ -4,6 +4,9 @@
using System;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Colour;
using osu.Game.Graphics;
using osuTK.Graphics;
namespace osu.Game.Screens.Edit
{
@ -35,5 +38,41 @@ namespace osu.Game.Screens.Edit
protected override int DefaultMinValue => VALID_DIVISORS.First();
protected override int DefaultMaxValue => VALID_DIVISORS.Last();
protected override int DefaultPrecision => 1;
/// <summary>
/// Retrieves the appropriate colour for a beat divisor.
/// </summary>
/// <param name="beatDivisor">The beat divisor.</param>
/// <param name="colours">The set of colours.</param>
/// <returns>The applicable colour from <paramref name="colours"/> for <paramref name="beatDivisor"/>.</returns>
public static ColourInfo GetColourFor(int beatDivisor, OsuColour colours)
{
switch (beatDivisor)
{
case 2:
return colours.BlueLight;
case 4:
return colours.Blue;
case 8:
return colours.BlueDarker;
case 16:
return colours.PurpleDark;
case 3:
return colours.YellowLight;
case 6:
return colours.Yellow;
case 12:
return colours.YellowDarker;
default:
return Color4.White;
}
}
}
}

View File

@ -188,6 +188,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
private Marker marker;
[Resolved]
private OsuColour colours { get; set; }
private readonly BindableBeatDivisor beatDivisor;
private readonly int[] availableDivisors;
@ -204,11 +207,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
foreach (var t in availableDivisors)
{
AddInternal(new Tick(t)
AddInternal(new Tick
{
Anchor = Anchor.TopLeft,
Origin = Anchor.TopCentre,
RelativePositionAxes = Axes.X,
Colour = BindableBeatDivisor.GetColourFor(t, colours),
X = getMappedPosition(t)
});
}
@ -284,11 +288,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
private class Tick : CompositeDrawable
{
private readonly int divisor;
public Tick(int divisor)
public Tick()
{
this.divisor = divisor;
Size = new Vector2(2.5f, 10);
InternalChild = new Box { RelativeSizeAxes = Axes.Both };
@ -296,42 +297,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
CornerRadius = 0.5f;
Masking = true;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Colour = getColourForDivisor(divisor, colours);
}
private ColourInfo getColourForDivisor(int divisor, OsuColour colours)
{
switch (divisor)
{
case 2:
return colours.BlueLight;
case 4:
return colours.Blue;
case 8:
return colours.BlueDarker;
case 16:
return colours.PurpleDark;
case 3:
return colours.YellowLight;
case 6:
return colours.Yellow;
case 12:
return colours.YellowDarker;
default:
return Color4.White;
}
}
}
private class Marker : CompositeDrawable

View File

@ -77,7 +77,7 @@ namespace osu.Game.Screens.Menu
Scheduler.AddDelayed(delegate
{
// Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Manu.
// Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Menu.
if (menuMusic.Value)
{
track.Restart();

View File

@ -47,7 +47,7 @@ namespace osu.Game.Screens.Menu
private const float visualiser_rounds = 5;
/// <summary>
/// How much should each bar go down each milisecond (based on a full bar).
/// How much should each bar go down each millisecond (based on a full bar).
/// </summary>
private const float decay_per_milisecond = 0.0024f;
@ -161,7 +161,7 @@ namespace osu.Game.Screens.Menu
private IShader shader;
private Texture texture;
//Asuming the logo is a circle, we don't need a second dimension.
//Assuming the logo is a circle, we don't need a second dimension.
private float size;
private Color4 colour;

View File

@ -229,7 +229,7 @@ namespace osu.Game.Screens.Menu
}
/// <summary>
/// Schedule a new extenral animation. Handled queueing and finishing previous animations in a sane way.
/// Schedule a new external animation. Handled queueing and finishing previous animations in a sane way.
/// </summary>
/// <param name="action">The animation to be performed</param>
/// <param name="waitForPrevious">If true, the new animation is delayed until all previous transforms finish. If false, existing transformed are cleared.</param>

View File

@ -0,0 +1,100 @@
// 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.Bindables;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Configuration;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play.HUD.HitErrorMeters;
namespace osu.Game.Screens.Play.HUD
{
public class HitErrorDisplay : Container<HitErrorMeter>
{
private const int fade_duration = 200;
private const int margin = 10;
private readonly Bindable<ScoreMeterType> type = new Bindable<ScoreMeterType>();
private readonly HitWindows hitWindows;
private readonly ScoreProcessor processor;
public HitErrorDisplay(ScoreProcessor processor, HitWindows hitWindows)
{
this.processor = processor;
this.hitWindows = hitWindows;
RelativeSizeAxes = Axes.Both;
processor.NewJudgement += onNewJudgement;
}
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
config.BindWith(OsuSetting.ScoreMeter, type);
}
protected override void LoadComplete()
{
base.LoadComplete();
type.BindValueChanged(typeChanged, true);
}
private void onNewJudgement(JudgementResult result)
{
foreach (var c in Children)
c.OnNewJudgement(result);
}
private void typeChanged(ValueChangedEvent<ScoreMeterType> type)
{
Children.ForEach(c => c.FadeOut(fade_duration, Easing.OutQuint));
if (hitWindows == null)
return;
switch (type.NewValue)
{
case ScoreMeterType.HitErrorBoth:
createBar(false);
createBar(true);
break;
case ScoreMeterType.HitErrorLeft:
createBar(false);
break;
case ScoreMeterType.HitErrorRight:
createBar(true);
break;
}
}
private void createBar(bool rightAligned)
{
var display = new BarHitErrorMeter(hitWindows, rightAligned)
{
Margin = new MarginPadding(margin),
Anchor = rightAligned ? Anchor.CentreRight : Anchor.CentreLeft,
Origin = rightAligned ? Anchor.CentreRight : Anchor.CentreLeft,
Alpha = 0,
};
Add(display);
display.FadeInFromZero(fade_duration, Easing.OutQuint);
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
processor.NewJudgement -= onNewJudgement;
}
}
}

View File

@ -0,0 +1,284 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Screens.Play.HUD.HitErrorMeters
{
public class BarHitErrorMeter : HitErrorMeter
{
private readonly Anchor alignment;
private const int arrow_move_duration = 400;
private const int judgement_line_width = 6;
private const int bar_height = 200;
private const int bar_width = 2;
private const int spacing = 2;
private const float chevron_size = 8;
private SpriteIcon arrow;
private Container colourBarsEarly;
private Container colourBarsLate;
private Container judgementsContainer;
private double maxHitWindow;
public BarHitErrorMeter(HitWindows hitWindows, bool rightAligned = false)
: base(hitWindows)
{
alignment = rightAligned ? Anchor.x0 : Anchor.x2;
AutoSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
InternalChild = new FillFlowContainer
{
AutoSizeAxes = Axes.X,
Height = bar_height,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(spacing, 0),
Margin = new MarginPadding(2),
Children = new Drawable[]
{
judgementsContainer = new Container
{
Anchor = Anchor.y1 | alignment,
Origin = Anchor.y1 | alignment,
Width = judgement_line_width,
RelativeSizeAxes = Axes.Y,
},
colourBars = new Container
{
Width = bar_width,
RelativeSizeAxes = Axes.Y,
Anchor = Anchor.y1 | alignment,
Origin = Anchor.y1 | alignment,
Children = new Drawable[]
{
colourBarsEarly = new Container
{
Anchor = Anchor.y1 | alignment,
Origin = alignment,
RelativeSizeAxes = Axes.Both,
Height = 0.5f,
Scale = new Vector2(1, -1),
},
colourBarsLate = new Container
{
Anchor = Anchor.y1 | alignment,
Origin = alignment,
RelativeSizeAxes = Axes.Both,
Height = 0.5f,
},
new SpriteIcon
{
Y = -10,
Size = new Vector2(10),
Icon = FontAwesome.Solid.ShippingFast,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
},
new SpriteIcon
{
Y = 10,
Size = new Vector2(10),
Icon = FontAwesome.Solid.Bicycle,
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
}
}
},
new Container
{
Anchor = Anchor.y1 | alignment,
Origin = Anchor.y1 | alignment,
Width = chevron_size,
RelativeSizeAxes = Axes.Y,
Child = arrow = new SpriteIcon
{
Anchor = Anchor.TopCentre,
Origin = Anchor.Centre,
RelativePositionAxes = Axes.Y,
Y = 0.5f,
Icon = alignment == Anchor.x2 ? FontAwesome.Solid.ChevronRight : FontAwesome.Solid.ChevronLeft,
Size = new Vector2(chevron_size),
}
},
}
};
createColourBars(colours);
}
protected override void LoadComplete()
{
base.LoadComplete();
colourBars.Height = 0;
colourBars.ResizeHeightTo(1, 800, Easing.OutQuint);
arrow.Alpha = 0;
arrow.Delay(200).FadeInFromZero(600);
}
private void createColourBars(OsuColour colours)
{
var windows = HitWindows.GetAllAvailableHalfWindows().ToArray();
maxHitWindow = windows.First().length;
for (var i = 0; i < windows.Length; i++)
{
var (result, length) = windows[i];
colourBarsEarly.Add(createColourBar(result, (float)(length / maxHitWindow), i == 0));
colourBarsLate.Add(createColourBar(result, (float)(length / maxHitWindow), i == 0));
}
// a little nub to mark the centre point.
var centre = createColourBar(windows.Last().result, 0.01f);
centre.Anchor = centre.Origin = Anchor.y1 | (alignment == Anchor.x2 ? Anchor.x0 : Anchor.x2);
centre.Width = 2.5f;
colourBars.Add(centre);
Color4 getColour(HitResult result)
{
switch (result)
{
case HitResult.Meh:
return colours.Yellow;
case HitResult.Ok:
return colours.Green;
case HitResult.Good:
return colours.GreenLight;
case HitResult.Great:
return colours.Blue;
default:
return colours.BlueLight;
}
}
Drawable createColourBar(HitResult result, float height, bool first = false)
{
var colour = getColour(result);
if (first)
{
// the first bar needs gradient rendering.
const float gradient_start = 0.8f;
return new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = getColour(result),
Height = height * gradient_start
},
new Box
{
RelativeSizeAxes = Axes.Both,
RelativePositionAxes = Axes.Both,
Colour = ColourInfo.GradientVertical(colour, colour.Opacity(0)),
Y = gradient_start,
Height = height * (1 - gradient_start)
},
}
};
}
return new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colour,
Height = height
};
}
}
private double floatingAverage;
private Container colourBars;
public override void OnNewJudgement(JudgementResult judgement)
{
if (!judgement.IsHit)
return;
judgementsContainer.Add(new JudgementLine
{
Y = getRelativeJudgementPosition(judgement.TimeOffset),
Anchor = alignment == Anchor.x2 ? Anchor.x0 : Anchor.x2,
Origin = Anchor.y1 | (alignment == Anchor.x2 ? Anchor.x0 : Anchor.x2),
});
arrow.MoveToY(
getRelativeJudgementPosition(floatingAverage = floatingAverage * 0.9 + judgement.TimeOffset * 0.1)
, arrow_move_duration, Easing.Out);
}
private float getRelativeJudgementPosition(double value) => (float)((value / maxHitWindow) + 1) / 2;
private class JudgementLine : CompositeDrawable
{
private const int judgement_fade_duration = 10000;
public JudgementLine()
{
RelativeSizeAxes = Axes.X;
RelativePositionAxes = Axes.Y;
Height = 3;
InternalChild = new CircularContainer
{
Masking = true,
RelativeSizeAxes = Axes.Both,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
}
};
}
protected override void LoadComplete()
{
base.LoadComplete();
Width = 0;
this.ResizeWidthTo(1, 200, Easing.OutElasticHalf);
this.FadeTo(0.8f, 150).Then().FadeOut(judgement_fade_duration, Easing.OutQuint).Expire();
}
}
}
}

View File

@ -0,0 +1,21 @@
// 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.Graphics.Containers;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
namespace osu.Game.Screens.Play.HUD.HitErrorMeters
{
public abstract class HitErrorMeter : CompositeDrawable
{
protected readonly HitWindows HitWindows;
protected HitErrorMeter(HitWindows hitWindows)
{
HitWindows = hitWindows;
}
public abstract void OnNewJudgement(JudgementResult judgement);
}
}

View File

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -33,6 +34,7 @@ namespace osu.Game.Screens.Play
public readonly HealthDisplay HealthDisplay;
public readonly SongProgress Progress;
public readonly ModDisplay ModDisplay;
public readonly HitErrorDisplay HitErrorDisplay;
public readonly HoldForMenuButton HoldToQuit;
public readonly PlayerSettingsOverlay PlayerSettingsOverlay;
@ -84,6 +86,7 @@ namespace osu.Game.Screens.Play
HealthDisplay = CreateHealthDisplay(),
Progress = CreateProgress(),
ModDisplay = CreateModsContainer(),
HitErrorDisplay = CreateHitErrorDisplayOverlay(),
}
},
PlayerSettingsOverlay = CreatePlayerSettingsOverlay(),
@ -256,6 +259,8 @@ namespace osu.Game.Screens.Play
Margin = new MarginPadding { Top = 20, Right = 10 },
};
protected virtual HitErrorDisplay CreateHitErrorDisplayOverlay() => new HitErrorDisplay(scoreProcessor, drawableRuleset.Objects.FirstOrDefault()?.HitWindows);
protected virtual PlayerSettingsOverlay CreatePlayerSettingsOverlay() => new PlayerSettingsOverlay();
protected virtual void BindProcessor(ScoreProcessor processor)

View File

@ -178,6 +178,7 @@ namespace osu.Game.Screens.Play
},
// display the cursor above some HUD elements.
DrawableRuleset.Cursor?.CreateProxy() ?? new Container(),
DrawableRuleset.ResumeOverlay?.CreateProxy() ?? new Container(),
HUDOverlay = new HUDOverlay(ScoreProcessor, DrawableRuleset, Mods.Value)
{
HoldToQuit =

View File

@ -414,7 +414,11 @@ namespace osu.Game.Screens.Select
{
Logger.Log($"beatmap changed from \"{Beatmap.Value.BeatmapInfo}\" to \"{beatmap}\"");
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap, Beatmap.Value);
WorkingBeatmap previous = Beatmap.Value;
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap, previous);
if (this.IsCurrentScreen() && Beatmap.Value?.Track != previous?.Track)
ensurePlayingSelected();
if (beatmap != null)
{
@ -425,8 +429,6 @@ namespace osu.Game.Screens.Select
}
}
if (this.IsCurrentScreen())
ensurePlayingSelected();
UpdateBeatmap(Beatmap.Value);
}
}

View File

@ -13,7 +13,7 @@ namespace osu.Game.Skinning
public DefaultSkin()
: base(SkinInfo.Default)
{
Configuration = new SkinConfiguration();
Configuration = new DefaultSkinConfiguration();
}
public override Drawable GetDrawableComponent(ISkinComponent component) => null;

View File

@ -0,0 +1,28 @@
// 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 osuTK.Graphics;
namespace osu.Game.Skinning
{
/// <summary>
/// A skin configuration pre-populated with sane defaults.
/// </summary>
public class DefaultSkinConfiguration : SkinConfiguration
{
public DefaultSkinConfiguration()
{
HitCircleFont = "default";
ComboColours.AddRange(new[]
{
new Color4(17, 136, 170, 255),
new Color4(102, 136, 0, 255),
new Color4(204, 102, 0, 255),
new Color4(121, 9, 13, 255)
});
CursorExpand = true;
}
}
}

View File

@ -35,7 +35,7 @@ namespace osu.Game.Skinning
using (StreamReader reader = new StreamReader(stream))
Configuration = new LegacySkinDecoder().Decode(reader);
else
Configuration = new SkinConfiguration();
Configuration = new DefaultSkinConfiguration();
Samples = audioManager.GetSampleStore(storage);
Textures = new TextureStore(new TextureLoaderStore(storage));

View File

@ -5,14 +5,14 @@ using osu.Game.Beatmaps.Formats;
namespace osu.Game.Skinning
{
public class LegacySkinDecoder : LegacyDecoder<SkinConfiguration>
public class LegacySkinDecoder : LegacyDecoder<DefaultSkinConfiguration>
{
public LegacySkinDecoder()
: base(1)
{
}
protected override void ParseLine(SkinConfiguration skin, Section section, string line)
protected override void ParseLine(DefaultSkinConfiguration skin, Section section, string line)
{
line = StripComments(line);

View File

@ -7,21 +7,18 @@ using osuTK.Graphics;
namespace osu.Game.Skinning
{
/// <summary>
/// An empty skin configuration.
/// </summary>
public class SkinConfiguration : IHasComboColours, IHasCustomColours
{
public readonly SkinInfo SkinInfo = new SkinInfo();
public List<Color4> ComboColours { get; set; } = new List<Color4>
{
new Color4(17, 136, 170, 255),
new Color4(102, 136, 0, 255),
new Color4(204, 102, 0, 255),
new Color4(121, 9, 13, 255)
};
public List<Color4> ComboColours { get; set; } = new List<Color4>();
public Dictionary<string, Color4> CustomColours { get; set; } = new Dictionary<string, Color4>();
public string HitCircleFont { get; set; } = "default";
public string HitCircleFont { get; set; }
public int HitCircleOverlap { get; set; }
@ -29,6 +26,6 @@ namespace osu.Game.Skinning
public float? SliderPathRadius { get; set; }
public bool? CursorExpand { get; set; } = true;
public bool? CursorExpand { get; set; }
}
}

View File

@ -6,6 +6,7 @@ using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Game.Audio;
@ -14,6 +15,9 @@ namespace osu.Game.Skinning
public class SkinnableSound : SkinReloadableDrawable
{
private readonly ISampleInfo[] hitSamples;
private List<(AdjustableProperty property, BindableDouble bindable)> adjustments;
private SampleChannel[] channels;
private AudioManager audio;
@ -34,8 +38,39 @@ namespace osu.Game.Skinning
this.audio = audio;
}
private bool looping;
public bool Looping
{
get => looping;
set
{
if (value == looping) return;
looping = value;
channels?.ForEach(c => c.Looping = looping);
}
}
public void Play() => channels?.ForEach(c => c.Play());
public void Stop() => channels?.ForEach(c => c.Stop());
public void AddAdjustment(AdjustableProperty type, BindableDouble adjustBindable)
{
if (adjustments == null) adjustments = new List<(AdjustableProperty, BindableDouble)>();
adjustments.Add((type, adjustBindable));
channels?.ForEach(c => c.AddAdjustment(type, adjustBindable));
}
public void RemoveAdjustment(AdjustableProperty type, BindableDouble adjustBindable)
{
adjustments?.Remove((type, adjustBindable));
channels?.ForEach(c => c.RemoveAdjustment(type, adjustBindable));
}
public override bool IsPresent => Scheduler.HasPendingTasks;
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
@ -50,8 +85,15 @@ namespace osu.Game.Skinning
break;
if (ch != null)
{
ch.Looping = looping;
ch.Volume.Value = s.Volume / 100.0;
if (adjustments != null)
foreach (var adjustment in adjustments)
ch.AddAdjustment(adjustment.property, adjustment.bindable);
}
return ch;
}).Where(c => c != null).ToArray();
}

View File

@ -3,6 +3,7 @@
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Testing;
using osu.Game.Configuration;
using osu.Game.Rulesets;
@ -40,6 +41,8 @@ namespace osu.Game.Tests.Visual
protected virtual bool AllowFail => false;
protected virtual bool Autoplay => false;
private void loadPlayer()
{
var beatmap = CreateBeatmap(ruleset.RulesetInfo);
@ -49,6 +52,13 @@ namespace osu.Game.Tests.Visual
if (!AllowFail)
Mods.Value = new[] { ruleset.GetAllMods().First(m => m is ModNoFail) };
if (Autoplay)
{
var mod = ruleset.GetAutoplayMod();
if (mod != null)
Mods.Value = Mods.Value.Concat(mod.Yield()).ToArray();
}
Player = CreatePlayer(ruleset);
LoadScreen(Player);
}

View File

@ -15,7 +15,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.830.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.830.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.830.1" />
<PackageReference Include="SharpCompress" Version="0.24.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />

View File

@ -118,8 +118,8 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.830.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.830.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.830.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.830.1" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.830.1" />
<PackageReference Include="SharpCompress" Version="0.24.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />