mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 07:22:55 +08:00
Merge branch 'master' into beatmap-mod-selector
This commit is contained in:
commit
bd61642ac6
@ -0,0 +1,36 @@
|
||||
// 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.BeatmapSet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Screens.Select.Leaderboards;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneLeaderboardScopeSelector : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(LeaderboardScopeSelector),
|
||||
};
|
||||
|
||||
public TestSceneLeaderboardScopeSelector()
|
||||
{
|
||||
Bindable<BeatmapLeaderboardScope> scope = new Bindable<BeatmapLeaderboardScope>();
|
||||
|
||||
Add(new LeaderboardScopeSelector
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Current = { BindTarget = scope }
|
||||
});
|
||||
|
||||
AddStep(@"Select global", () => scope.Value = BeatmapLeaderboardScope.Global);
|
||||
AddStep(@"Select country", () => scope.Value = BeatmapLeaderboardScope.Country);
|
||||
AddStep(@"Select friend", () => scope.Value = BeatmapLeaderboardScope.Friend);
|
||||
}
|
||||
}
|
||||
}
|
@ -31,6 +31,11 @@ namespace osu.Game.Graphics.UserInterface
|
||||
protected virtual float StripWidth() => TabContainer.Children.Sum(c => c.IsPresent ? c.DrawWidth + TabContainer.Spacing.X : 0) - TabContainer.Spacing.X;
|
||||
protected virtual float StripHeight() => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Whether entries should be automatically populated if <see cref="T"/> is an <see cref="Enum"/> type.
|
||||
/// </summary>
|
||||
protected virtual bool AddEnumEntriesAutomatically => true;
|
||||
|
||||
private static bool isEnumType => typeof(T).IsEnum;
|
||||
|
||||
public OsuTabControl()
|
||||
@ -45,7 +50,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Colour = Color4.White.Opacity(0),
|
||||
});
|
||||
|
||||
if (isEnumType)
|
||||
if (isEnumType && AddEnumEntriesAutomatically)
|
||||
foreach (var val in (T[])Enum.GetValues(typeof(T)))
|
||||
AddItem(val);
|
||||
}
|
||||
|
@ -24,7 +24,13 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Height = 30;
|
||||
}
|
||||
|
||||
public class PageTabItem : TabItem<T>
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
AccentColour = colours.Yellow;
|
||||
}
|
||||
|
||||
public class PageTabItem : TabItem<T>, IHasAccentColour
|
||||
{
|
||||
private const float transition_duration = 100;
|
||||
|
||||
@ -32,6 +38,18 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected readonly SpriteText Text;
|
||||
|
||||
private Color4 accentColour;
|
||||
|
||||
public Color4 AccentColour
|
||||
{
|
||||
get => accentColour;
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
box.Colour = accentColour;
|
||||
}
|
||||
}
|
||||
|
||||
public PageTabItem(T value)
|
||||
: base(value)
|
||||
{
|
||||
@ -63,12 +81,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Active.BindValueChanged(active => Text.Font = Text.Font.With(Typeface.Exo, weight: active.NewValue ? FontWeight.Bold : FontWeight.Medium), true);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
box.Colour = colours.Yellow;
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
if (!Active.Value)
|
||||
|
119
osu.Game/Overlays/BeatmapSet/LeaderboardScopeSelector.cs
Normal file
119
osu.Game/Overlays/BeatmapSet/LeaderboardScopeSelector.cs
Normal 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 osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Screens.Select.Leaderboards;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osuTK;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Input.Events;
|
||||
|
||||
namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
public class LeaderboardScopeSelector : PageTabControl<BeatmapLeaderboardScope>
|
||||
{
|
||||
protected override bool AddEnumEntriesAutomatically => false;
|
||||
|
||||
protected override Dropdown<BeatmapLeaderboardScope> CreateDropdown() => null;
|
||||
|
||||
protected override TabItem<BeatmapLeaderboardScope> CreateTabItem(BeatmapLeaderboardScope value) => new ScopeSelectorTabItem(value);
|
||||
|
||||
public LeaderboardScopeSelector()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
||||
AddItem(BeatmapLeaderboardScope.Global);
|
||||
AddItem(BeatmapLeaderboardScope.Country);
|
||||
AddItem(BeatmapLeaderboardScope.Friend);
|
||||
|
||||
AddInternal(new GradientLine
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
AccentColour = colours.Blue;
|
||||
}
|
||||
|
||||
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
AutoSizeAxes = Axes.X,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(20, 0),
|
||||
};
|
||||
|
||||
private class ScopeSelectorTabItem : PageTabItem
|
||||
{
|
||||
public ScopeSelectorTabItem(BeatmapLeaderboardScope value)
|
||||
: base(value)
|
||||
{
|
||||
Text.Font = OsuFont.GetFont(size: 16);
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
Text.FadeColour(AccentColour);
|
||||
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
base.OnHoverLost(e);
|
||||
|
||||
Text.FadeColour(Color4.White);
|
||||
}
|
||||
}
|
||||
|
||||
private class GradientLine : GridContainer
|
||||
{
|
||||
public GradientLine()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Size = new Vector2(0.8f, 1.5f);
|
||||
|
||||
ColumnDimensions = new[]
|
||||
{
|
||||
new Dimension(),
|
||||
new Dimension(mode: GridSizeMode.Relative, size: 0.4f),
|
||||
new Dimension(),
|
||||
};
|
||||
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourInfo.GradientHorizontal(Color4.Transparent, Color4.Gray),
|
||||
},
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Gray,
|
||||
},
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourInfo.GradientHorizontal(Color4.Gray, Color4.Transparent),
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -398,7 +398,7 @@ namespace osu.Game.Rulesets.Scoring
|
||||
if (rollingMaxBaseScore != 0)
|
||||
Accuracy.Value = baseScore / rollingMaxBaseScore;
|
||||
|
||||
TotalScore.Value = getScore(Mode.Value) * scoreMultiplier;
|
||||
TotalScore.Value = getScore(Mode.Value);
|
||||
}
|
||||
|
||||
private double getScore(ScoringMode mode)
|
||||
@ -407,11 +407,11 @@ namespace osu.Game.Rulesets.Scoring
|
||||
{
|
||||
default:
|
||||
case ScoringMode.Standardised:
|
||||
return max_score * (base_portion * baseScore / maxBaseScore + combo_portion * HighestCombo.Value / maxHighestCombo) + bonusScore;
|
||||
return (max_score * (base_portion * baseScore / maxBaseScore + combo_portion * HighestCombo.Value / maxHighestCombo) + bonusScore) * scoreMultiplier;
|
||||
|
||||
case ScoringMode.Classic:
|
||||
// should emulate osu-stable's scoring as closely as we can (https://osu.ppy.sh/help/wiki/Score/ScoreV1)
|
||||
return bonusScore + baseScore * (1 + Math.Max(0, HighestCombo.Value - 1) / 25);
|
||||
return bonusScore + baseScore * ((1 + Math.Max(0, HighestCombo.Value - 1) * scoreMultiplier) / 25);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,13 +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.Screens.Select.Leaderboards
|
||||
{
|
||||
public enum BeatmapLeaderboardScope
|
||||
{
|
||||
[Description("Local Ranking")]
|
||||
Local,
|
||||
|
||||
[Description("Country Ranking")]
|
||||
Country,
|
||||
|
||||
[Description("Global Ranking")]
|
||||
Global,
|
||||
|
||||
[Description("Friend Ranking")]
|
||||
Friend,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user