mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 20:12:56 +08:00
Merge remote-tracking branch 'refs/remotes/ppy/master' into rankings-overlay-update
This commit is contained in:
commit
524a8ba6c6
@ -2,12 +2,16 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Gameplay
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
{
|
{
|
||||||
@ -15,7 +19,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
private HUDOverlay hudOverlay;
|
private HUDOverlay hudOverlay;
|
||||||
|
|
||||||
private Drawable hideTarget => hudOverlay.KeyCounter; // best way of checking hideTargets without exposing.
|
// best way to check without exposing.
|
||||||
|
private Drawable hideTarget => hudOverlay.KeyCounter;
|
||||||
|
private FillFlowContainer<KeyCounter> keyCounterFlow => hudOverlay.KeyCounter.ChildrenOfType<FillFlowContainer<KeyCounter>>().First();
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuConfigManager config { get; set; }
|
private OsuConfigManager config { get; set; }
|
||||||
@ -28,6 +34,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddAssert("showhud is set", () => hudOverlay.ShowHud.Value);
|
AddAssert("showhud is set", () => hudOverlay.ShowHud.Value);
|
||||||
|
|
||||||
AddAssert("hidetarget is visible", () => hideTarget.IsPresent);
|
AddAssert("hidetarget is visible", () => hideTarget.IsPresent);
|
||||||
|
AddAssert("key counter flow is visible", () => keyCounterFlow.IsPresent);
|
||||||
AddAssert("pause button is visible", () => hudOverlay.HoldToQuit.IsPresent);
|
AddAssert("pause button is visible", () => hudOverlay.HoldToQuit.IsPresent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,6 +57,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent);
|
AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent);
|
||||||
AddAssert("pause button is still visible", () => hudOverlay.HoldToQuit.IsPresent);
|
AddAssert("pause button is still visible", () => hudOverlay.HoldToQuit.IsPresent);
|
||||||
|
|
||||||
|
// Key counter flow container should not be affected by this, only the key counter display will be hidden as checked above.
|
||||||
|
AddAssert("key counter flow not affected", () => keyCounterFlow.IsPresent);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -68,12 +78,40 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddAssert("config unchanged", () => originalConfigValue == config.Get<bool>(OsuSetting.ShowInterface));
|
AddAssert("config unchanged", () => originalConfigValue == config.Get<bool>(OsuSetting.ShowInterface));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestChangeHUDVisibilityOnHiddenKeyCounter()
|
||||||
|
{
|
||||||
|
bool keyCounterVisibleValue = false;
|
||||||
|
|
||||||
|
createNew();
|
||||||
|
AddStep("save keycounter visible value", () => keyCounterVisibleValue = config.Get<bool>(OsuSetting.KeyOverlay));
|
||||||
|
|
||||||
|
AddStep("set keycounter visible false", () =>
|
||||||
|
{
|
||||||
|
config.Set<bool>(OsuSetting.KeyOverlay, false);
|
||||||
|
hudOverlay.KeyCounter.AlwaysVisible.Value = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false);
|
||||||
|
AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent);
|
||||||
|
AddAssert("key counters hidden", () => !keyCounterFlow.IsPresent);
|
||||||
|
|
||||||
|
AddStep("set showhud true", () => hudOverlay.ShowHud.Value = true);
|
||||||
|
AddUntilStep("hidetarget is visible", () => hideTarget.IsPresent);
|
||||||
|
AddAssert("key counters still hidden", () => !keyCounterFlow.IsPresent);
|
||||||
|
|
||||||
|
AddStep("return value", () => config.Set<bool>(OsuSetting.KeyOverlay, keyCounterVisibleValue));
|
||||||
|
}
|
||||||
|
|
||||||
private void createNew(Action<HUDOverlay> action = null)
|
private void createNew(Action<HUDOverlay> action = null)
|
||||||
{
|
{
|
||||||
AddStep("create overlay", () =>
|
AddStep("create overlay", () =>
|
||||||
{
|
{
|
||||||
Child = hudOverlay = new HUDOverlay(null, null, null, Array.Empty<Mod>());
|
Child = hudOverlay = new HUDOverlay(null, null, null, Array.Empty<Mod>());
|
||||||
|
|
||||||
|
// Add any key just to display the key counter visually.
|
||||||
|
hudOverlay.KeyCounter.Add(new KeyCounterKeyboard(Key.Space));
|
||||||
|
|
||||||
action?.Invoke(hudOverlay);
|
action?.Invoke(hudOverlay);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,87 @@
|
|||||||
|
// 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.Allocation;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Online.API.Requests;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Overlays.Rankings;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Online
|
||||||
|
{
|
||||||
|
public class TestSceneRankingsSpotlightSelector : OsuTestScene
|
||||||
|
{
|
||||||
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
|
{
|
||||||
|
typeof(SpotlightSelector),
|
||||||
|
};
|
||||||
|
|
||||||
|
protected override bool UseOnlineAPI => true;
|
||||||
|
|
||||||
|
[Cached]
|
||||||
|
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
|
private readonly SpotlightSelector selector;
|
||||||
|
|
||||||
|
public TestSceneRankingsSpotlightSelector()
|
||||||
|
{
|
||||||
|
Add(selector = new SpotlightSelector());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestLocalSpotlights()
|
||||||
|
{
|
||||||
|
var spotlights = new[]
|
||||||
|
{
|
||||||
|
new APISpotlight
|
||||||
|
{
|
||||||
|
Name = "Spotlight 1",
|
||||||
|
StartDate = DateTimeOffset.Now,
|
||||||
|
EndDate = DateTimeOffset.Now,
|
||||||
|
},
|
||||||
|
new APISpotlight
|
||||||
|
{
|
||||||
|
Name = "Spotlight 2",
|
||||||
|
StartDate = DateTimeOffset.Now,
|
||||||
|
EndDate = DateTimeOffset.Now,
|
||||||
|
},
|
||||||
|
new APISpotlight
|
||||||
|
{
|
||||||
|
Name = "Spotlight 3",
|
||||||
|
StartDate = DateTimeOffset.Now,
|
||||||
|
EndDate = DateTimeOffset.Now,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
AddStep("load spotlights", () => selector.Spotlights = spotlights);
|
||||||
|
AddStep("change to spotlight 3", () => selector.Current.Value = spotlights[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestOnlineSpotlights()
|
||||||
|
{
|
||||||
|
List<APISpotlight> spotlights = null;
|
||||||
|
|
||||||
|
AddStep("retrieve spotlights", () =>
|
||||||
|
{
|
||||||
|
var req = new GetSpotlightsRequest();
|
||||||
|
req.Success += res => spotlights = res.Spotlights;
|
||||||
|
|
||||||
|
api.Perform(req);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("set spotlights", () =>
|
||||||
|
{
|
||||||
|
if (spotlights != null)
|
||||||
|
selector.Spotlights = spotlights;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
20
osu.Game/Online/API/Requests/GetSpotlightsRequest.cs
Normal file
20
osu.Game/Online/API/Requests/GetSpotlightsRequest.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// 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 Newtonsoft.Json;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.API.Requests
|
||||||
|
{
|
||||||
|
public class GetSpotlightsRequest : APIRequest<SpotlightsCollection>
|
||||||
|
{
|
||||||
|
protected override string Target => "spotlights";
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SpotlightsCollection
|
||||||
|
{
|
||||||
|
[JsonProperty("spotlights")]
|
||||||
|
public List<APISpotlight> Spotlights;
|
||||||
|
}
|
||||||
|
}
|
31
osu.Game/Online/API/Requests/Responses/APISpotlight.cs
Normal file
31
osu.Game/Online/API/Requests/Responses/APISpotlight.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// 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 Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.API.Requests.Responses
|
||||||
|
{
|
||||||
|
public class APISpotlight
|
||||||
|
{
|
||||||
|
[JsonProperty("id")]
|
||||||
|
public int Id;
|
||||||
|
|
||||||
|
[JsonProperty("name")]
|
||||||
|
public string Name;
|
||||||
|
|
||||||
|
[JsonProperty("type")]
|
||||||
|
public string Type;
|
||||||
|
|
||||||
|
[JsonProperty("mode_specific")]
|
||||||
|
public bool ModeSpecific;
|
||||||
|
|
||||||
|
[JsonProperty(@"start_date")]
|
||||||
|
public DateTimeOffset StartDate;
|
||||||
|
|
||||||
|
[JsonProperty(@"end_date")]
|
||||||
|
public DateTimeOffset EndDate;
|
||||||
|
|
||||||
|
public override string ToString() => Name;
|
||||||
|
}
|
||||||
|
}
|
@ -277,7 +277,7 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
protected virtual IEnumerable<LeaderboardScoreStatistic> GetStatistics(ScoreInfo model) => new[]
|
protected virtual IEnumerable<LeaderboardScoreStatistic> GetStatistics(ScoreInfo model) => new[]
|
||||||
{
|
{
|
||||||
new LeaderboardScoreStatistic(FontAwesome.Solid.Link, "Max Combo", model.MaxCombo.ToString()),
|
new LeaderboardScoreStatistic(FontAwesome.Solid.Link, "Max Combo", model.MaxCombo.ToString()),
|
||||||
new LeaderboardScoreStatistic(FontAwesome.Solid.Crosshairs, "Accuracy", string.Format(model.Accuracy % 1 == 0 ? @"{0:0%}" : @"{0:0.00%}", model.Accuracy))
|
new LeaderboardScoreStatistic(FontAwesome.Solid.Crosshairs, "Accuracy", model.DisplayAccuracy)
|
||||||
};
|
};
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
|
@ -116,7 +116,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Margin = new MarginPadding { Right = horizontal_inset },
|
Margin = new MarginPadding { Right = horizontal_inset },
|
||||||
Text = $@"{score.Accuracy:P2}",
|
Text = score.DisplayAccuracy,
|
||||||
Font = OsuFont.GetFont(size: text_size),
|
Font = OsuFont.GetFont(size: text_size),
|
||||||
Colour = score.Accuracy == 1 ? highAccuracyColour : Color4.White
|
Colour = score.Accuracy == 1 ? highAccuracyColour : Color4.White
|
||||||
},
|
},
|
||||||
|
@ -92,7 +92,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
totalScoreColumn.Text = $@"{value.TotalScore:N0}";
|
totalScoreColumn.Text = $@"{value.TotalScore:N0}";
|
||||||
accuracyColumn.Text = $@"{value.Accuracy:P2}";
|
accuracyColumn.Text = value.DisplayAccuracy;
|
||||||
maxComboColumn.Text = $@"{value.MaxCombo:N0}x";
|
maxComboColumn.Text = $@"{value.MaxCombo:N0}x";
|
||||||
ppColumn.Text = $@"{value.PP:N0}";
|
ppColumn.Text = $@"{value.PP:N0}";
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
using System;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -178,7 +177,7 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
if (user?.Statistics != null)
|
if (user?.Statistics != null)
|
||||||
{
|
{
|
||||||
userStats.Add(new UserStatsLine("Ranked Score", user.Statistics.RankedScore.ToString("#,##0")));
|
userStats.Add(new UserStatsLine("Ranked Score", user.Statistics.RankedScore.ToString("#,##0")));
|
||||||
userStats.Add(new UserStatsLine("Hit Accuracy", Math.Round(user.Statistics.Accuracy, 2).ToString("#0.00'%'")));
|
userStats.Add(new UserStatsLine("Hit Accuracy", user.Statistics.DisplayAccuracy));
|
||||||
userStats.Add(new UserStatsLine("Play Count", user.Statistics.PlayCount.ToString("#,##0")));
|
userStats.Add(new UserStatsLine("Play Count", user.Statistics.PlayCount.ToString("#,##0")));
|
||||||
userStats.Add(new UserStatsLine("Total Score", user.Statistics.TotalScore.ToString("#,##0")));
|
userStats.Add(new UserStatsLine("Total Score", user.Statistics.TotalScore.ToString("#,##0")));
|
||||||
userStats.Add(new UserStatsLine("Total Hits", user.Statistics.TotalHits.ToString("#,##0")));
|
userStats.Add(new UserStatsLine("Total Hits", user.Statistics.TotalHits.ToString("#,##0")));
|
||||||
|
@ -182,7 +182,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
|||||||
|
|
||||||
protected OsuSpriteText CreateDrawableAccuracy() => new OsuSpriteText
|
protected OsuSpriteText CreateDrawableAccuracy() => new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = $"{Score.Accuracy:0.00%}",
|
Text = Score.DisplayAccuracy,
|
||||||
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
|
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
|
||||||
Colour = colours.Yellow,
|
Colour = colours.Yellow,
|
||||||
};
|
};
|
||||||
|
161
osu.Game/Overlays/Rankings/SpotlightSelector.cs
Normal file
161
osu.Game/Overlays/Rankings/SpotlightSelector.cs
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
// 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.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
using osuTK;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Rankings
|
||||||
|
{
|
||||||
|
public class SpotlightSelector : CompositeDrawable, IHasCurrentValue<APISpotlight>
|
||||||
|
{
|
||||||
|
private readonly Box background;
|
||||||
|
private readonly SpotlightsDropdown dropdown;
|
||||||
|
|
||||||
|
private readonly BindableWithCurrent<APISpotlight> current = new BindableWithCurrent<APISpotlight>();
|
||||||
|
|
||||||
|
public Bindable<APISpotlight> Current
|
||||||
|
{
|
||||||
|
get => current.Current;
|
||||||
|
set => current.Current = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<APISpotlight> Spotlights
|
||||||
|
{
|
||||||
|
get => dropdown.Items;
|
||||||
|
set => dropdown.Items = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly InfoColumn startDateColumn;
|
||||||
|
private readonly InfoColumn endDateColumn;
|
||||||
|
|
||||||
|
public SpotlightSelector()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
Height = 100;
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
background = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Padding = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN, Vertical = 10 },
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
dropdown = new SpotlightsDropdown
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Current = Current,
|
||||||
|
Depth = -float.MaxValue
|
||||||
|
},
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomRight,
|
||||||
|
Origin = Anchor.BottomRight,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Spacing = new Vector2(15, 0),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
startDateColumn = new InfoColumn(@"Start Date"),
|
||||||
|
endDateColumn = new InfoColumn(@"End Date"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OverlayColourProvider colourProvider)
|
||||||
|
{
|
||||||
|
background.Colour = colourProvider.Dark3;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
Current.BindValueChanged(onCurrentChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onCurrentChanged(ValueChangedEvent<APISpotlight> spotlight)
|
||||||
|
{
|
||||||
|
startDateColumn.Value = dateToString(spotlight.NewValue.StartDate);
|
||||||
|
endDateColumn.Value = dateToString(spotlight.NewValue.EndDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string dateToString(DateTimeOffset date) => date.ToString("yyyy-MM-dd");
|
||||||
|
|
||||||
|
private class InfoColumn : FillFlowContainer
|
||||||
|
{
|
||||||
|
public string Value
|
||||||
|
{
|
||||||
|
set => valueText.Text = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly OsuSpriteText valueText;
|
||||||
|
|
||||||
|
public InfoColumn(string name)
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
Direction = FillDirection.Vertical;
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = name,
|
||||||
|
Font = OsuFont.GetFont(size: 10),
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.X,
|
||||||
|
Height = 20,
|
||||||
|
Child = valueText = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
Font = OsuFont.GetFont(size: 18, weight: FontWeight.Light),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OverlayColourProvider colourProvider)
|
||||||
|
{
|
||||||
|
valueText.Colour = colourProvider.Content2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SpotlightsDropdown : OsuDropdown<APISpotlight>
|
||||||
|
{
|
||||||
|
private DropdownMenu menu;
|
||||||
|
|
||||||
|
protected override DropdownMenu CreateMenu() => menu = base.CreateMenu().With(m => m.MaxHeight = 400);
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OverlayColourProvider colourProvider)
|
||||||
|
{
|
||||||
|
menu.BackgroundColour = colourProvider.Background5;
|
||||||
|
AccentColour = colourProvider.Background6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -40,7 +40,7 @@ namespace osu.Game.Overlays.Rankings.Tables
|
|||||||
|
|
||||||
protected sealed override Drawable[] CreateAdditionalContent(UserStatistics item) => new[]
|
protected sealed override Drawable[] CreateAdditionalContent(UserStatistics item) => new[]
|
||||||
{
|
{
|
||||||
new ColoredRowText { Text = $@"{item.Accuracy:F2}%", },
|
new ColoredRowText { Text = item.DisplayAccuracy, },
|
||||||
new ColoredRowText { Text = $@"{item.PlayCount:N0}", },
|
new ColoredRowText { Text = $@"{item.PlayCount:N0}", },
|
||||||
}.Concat(CreateUniqueContent(item)).Concat(new[]
|
}.Concat(CreateUniqueContent(item)).Concat(new[]
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,7 @@ using osu.Game.Rulesets;
|
|||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
|
using osu.Game.Utils;
|
||||||
|
|
||||||
namespace osu.Game.Scoring
|
namespace osu.Game.Scoring
|
||||||
{
|
{
|
||||||
@ -31,6 +32,9 @@ namespace osu.Game.Scoring
|
|||||||
[Column(TypeName = "DECIMAL(1,4)")]
|
[Column(TypeName = "DECIMAL(1,4)")]
|
||||||
public double Accuracy { get; set; }
|
public double Accuracy { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public string DisplayAccuracy => Accuracy.FormatAccuracy();
|
||||||
|
|
||||||
[JsonProperty(@"pp")]
|
[JsonProperty(@"pp")]
|
||||||
public double? PP { get; set; }
|
public double? PP { get; set; }
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
|
|
||||||
protected override IEnumerable<LeaderboardScoreStatistic> GetStatistics(ScoreInfo model) => new[]
|
protected override IEnumerable<LeaderboardScoreStatistic> GetStatistics(ScoreInfo model) => new[]
|
||||||
{
|
{
|
||||||
new LeaderboardScoreStatistic(FontAwesome.Solid.Crosshairs, "Accuracy", string.Format(model.Accuracy % 1 == 0 ? @"{0:0%}" : @"{0:0.00%}", model.Accuracy)),
|
new LeaderboardScoreStatistic(FontAwesome.Solid.Crosshairs, "Accuracy", model.DisplayAccuracy),
|
||||||
new LeaderboardScoreStatistic(FontAwesome.Solid.Sync, "Total Attempts", score.TotalAttempts.ToString()),
|
new LeaderboardScoreStatistic(FontAwesome.Solid.Sync, "Total Attempts", score.TotalAttempts.ToString()),
|
||||||
new LeaderboardScoreStatistic(FontAwesome.Solid.Check, "Completed Beatmaps", score.CompletedBeatmaps.ToString()),
|
new LeaderboardScoreStatistic(FontAwesome.Solid.Check, "Completed Beatmaps", score.CompletedBeatmaps.ToString()),
|
||||||
};
|
};
|
||||||
|
@ -14,18 +14,32 @@ using osuTK.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
public class KeyCounterDisplay : FillFlowContainer<KeyCounter>
|
public class KeyCounterDisplay : Container<KeyCounter>
|
||||||
{
|
{
|
||||||
private const int duration = 100;
|
private const int duration = 100;
|
||||||
private const double key_fade_time = 80;
|
private const double key_fade_time = 80;
|
||||||
|
|
||||||
public readonly Bindable<bool> Visible = new Bindable<bool>(true);
|
|
||||||
private readonly Bindable<bool> configVisibility = new Bindable<bool>();
|
private readonly Bindable<bool> configVisibility = new Bindable<bool>();
|
||||||
|
|
||||||
|
protected readonly FillFlowContainer<KeyCounter> KeyFlow;
|
||||||
|
|
||||||
|
protected override Container<KeyCounter> Content => KeyFlow;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the key counter should be visible regardless of the configuration value.
|
||||||
|
/// This is true by default, but can be changed.
|
||||||
|
/// </summary>
|
||||||
|
public readonly Bindable<bool> AlwaysVisible = new Bindable<bool>(true);
|
||||||
|
|
||||||
public KeyCounterDisplay()
|
public KeyCounterDisplay()
|
||||||
{
|
{
|
||||||
Direction = FillDirection.Horizontal;
|
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
InternalChild = KeyFlow = new FillFlowContainer<KeyCounter>
|
||||||
|
{
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Add(KeyCounter key)
|
public override void Add(KeyCounter key)
|
||||||
@ -49,7 +63,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
Visible.BindValueChanged(_ => updateVisibility());
|
AlwaysVisible.BindValueChanged(_ => updateVisibility());
|
||||||
configVisibility.BindValueChanged(_ => updateVisibility(), true);
|
configVisibility.BindValueChanged(_ => updateVisibility(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +114,9 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateVisibility() => this.FadeTo(Visible.Value || configVisibility.Value ? 1 : 0, duration);
|
private void updateVisibility() =>
|
||||||
|
// Isolate changing visibility of the key counters from fading this component.
|
||||||
|
KeyFlow.FadeTo(AlwaysVisible.Value || configVisibility.Value ? 1 : 0, duration);
|
||||||
|
|
||||||
public override bool HandleNonPositionalInput => receptor == null;
|
public override bool HandleNonPositionalInput => receptor == null;
|
||||||
public override bool HandlePositionalInput => receptor == null;
|
public override bool HandlePositionalInput => receptor == null;
|
||||||
|
@ -219,7 +219,7 @@ namespace osu.Game.Screens.Play
|
|||||||
IsPaused = { BindTarget = GameplayClockContainer.IsPaused }
|
IsPaused = { BindTarget = GameplayClockContainer.IsPaused }
|
||||||
},
|
},
|
||||||
PlayerSettingsOverlay = { PlaybackSettings = { UserPlaybackRate = { BindTarget = GameplayClockContainer.UserPlaybackRate } } },
|
PlayerSettingsOverlay = { PlaybackSettings = { UserPlaybackRate = { BindTarget = GameplayClockContainer.UserPlaybackRate } } },
|
||||||
KeyCounter = { Visible = { BindTarget = DrawableRuleset.HasReplayLoaded } },
|
KeyCounter = { AlwaysVisible = { BindTarget = DrawableRuleset.HasReplayLoaded } },
|
||||||
RequestSeek = GameplayClockContainer.Seek,
|
RequestSeek = GameplayClockContainer.Seek,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre
|
Origin = Anchor.Centre
|
||||||
|
@ -211,7 +211,7 @@ namespace osu.Game.Screens.Ranking
|
|||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.BottomCentre,
|
Origin = Anchor.BottomCentre,
|
||||||
Text = $"{Score.Accuracy:P2}",
|
Text = Score.DisplayAccuracy,
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 40),
|
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 40),
|
||||||
RelativePositionAxes = Axes.X,
|
RelativePositionAxes = Axes.X,
|
||||||
X = 0.9f,
|
X = 0.9f,
|
||||||
|
@ -32,8 +32,7 @@ namespace osu.Game.Screens.Select
|
|||||||
BeatmapInfo beatmap = beatmapManager.QueryBeatmap(b => b.ID == score.BeatmapInfoID);
|
BeatmapInfo beatmap = beatmapManager.QueryBeatmap(b => b.ID == score.BeatmapInfoID);
|
||||||
Debug.Assert(beatmap != null);
|
Debug.Assert(beatmap != null);
|
||||||
|
|
||||||
string accuracy = string.Format(score.Accuracy == 1 ? "{0:0%}" : "{0:0.00%}", score.Accuracy);
|
BodyText = $"{score.User} ({score.DisplayAccuracy}, {score.Rank})";
|
||||||
BodyText = $"{score.User} ({accuracy}, {score.Rank})";
|
|
||||||
|
|
||||||
Icon = FontAwesome.Regular.TrashAlt;
|
Icon = FontAwesome.Regular.TrashAlt;
|
||||||
HeaderText = "Confirm deletion of local score";
|
HeaderText = "Confirm deletion of local score";
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Utils;
|
||||||
using static osu.Game.Users.User;
|
using static osu.Game.Users.User;
|
||||||
|
|
||||||
namespace osu.Game.Users
|
namespace osu.Game.Users
|
||||||
@ -43,6 +44,9 @@ namespace osu.Game.Users
|
|||||||
[JsonProperty(@"hit_accuracy")]
|
[JsonProperty(@"hit_accuracy")]
|
||||||
public decimal Accuracy;
|
public decimal Accuracy;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public string DisplayAccuracy => Accuracy.FormatAccuracy();
|
||||||
|
|
||||||
[JsonProperty(@"play_count")]
|
[JsonProperty(@"play_count")]
|
||||||
public int PlayCount;
|
public int PlayCount;
|
||||||
|
|
||||||
|
24
osu.Game/Utils/FormatUtils.cs
Normal file
24
osu.Game/Utils/FormatUtils.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
namespace osu.Game.Utils
|
||||||
|
{
|
||||||
|
public static class FormatUtils
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Turns the provided accuracy into a percentage with 2 decimal places.
|
||||||
|
/// Omits all decimal places when <paramref name="accuracy"/> equals 1d.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="accuracy">The accuracy to be formatted</param>
|
||||||
|
/// <returns>formatted accuracy in percentage</returns>
|
||||||
|
public static string FormatAccuracy(this double accuracy) => accuracy == 1 ? "100%" : $"{accuracy:0.00%}";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Turns the provided accuracy into a percentage with 2 decimal places.
|
||||||
|
/// Omits all decimal places when <paramref name="accuracy"/> equals 100m.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="accuracy">The accuracy to be formatted</param>
|
||||||
|
/// <returns>formatted accuracy in percentage</returns>
|
||||||
|
public static string FormatAccuracy(this decimal accuracy) => accuracy == 100 ? "100%" : $"{accuracy:0.00}%";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user