mirror of
https://github.com/ppy/osu.git
synced 2025-03-19 01:17:19 +08:00
Basic stuff (not working for now)
This commit is contained in:
parent
90dfef2bb9
commit
8a1fc7c340
203
osu.Game/Overlays/Mods/ModMapInfoDisplay.cs
Normal file
203
osu.Game/Overlays/Mods/ModMapInfoDisplay.cs
Normal file
@ -0,0 +1,203 @@
|
||||
// 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.LocalisationExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Screens.Select.Details;
|
||||
using osu.Game.Localisation;
|
||||
using osuTK;
|
||||
|
||||
|
||||
namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
public partial class ModMapInfoDisplay : Container, IHasCurrentValue<MapStats>
|
||||
{
|
||||
public const float HEIGHT = 42;
|
||||
private const float transition_duration = 200;
|
||||
|
||||
private readonly Box contentBackground;
|
||||
private readonly Box labelBackground;
|
||||
private readonly FillFlowContainer content;
|
||||
|
||||
public Bindable<MapStats> Current
|
||||
{
|
||||
get => current.Current;
|
||||
set => current.Current = value;
|
||||
}
|
||||
private readonly BindableWithCurrent<MapStats> current = new BindableWithCurrent<MapStats>();
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Text to display in the left area of the display.
|
||||
/// </summary>
|
||||
//protected abstract LocalisableString Label { get; }
|
||||
protected LocalisableString Label => CommonStrings.Finish;
|
||||
//protected string Label { get; }
|
||||
|
||||
protected virtual float ValueAreaWidth => 56;
|
||||
|
||||
protected virtual string CounterFormat => @"N0";
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
protected readonly RollingCounter<double> Counter;
|
||||
|
||||
public ModMapInfoDisplay()
|
||||
{
|
||||
Height = HEIGHT;
|
||||
AutoSizeAxes = Axes.X;
|
||||
|
||||
InternalChild = new InputBlockingContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
AutoSizeAxes = Axes.X,
|
||||
Masking = true,
|
||||
CornerRadius = ModSelectPanel.CORNER_RADIUS,
|
||||
Shear = new Vector2(ShearedOverlayContainer.SHEAR, 0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
contentBackground = new Box
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = ValueAreaWidth + ModSelectPanel.CORNER_RADIUS
|
||||
},
|
||||
new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
AutoSizeAxes = Axes.X,
|
||||
ColumnDimensions = new[]
|
||||
{
|
||||
new Dimension(GridSizeMode.AutoSize),
|
||||
new Dimension(GridSizeMode.Absolute, ValueAreaWidth)
|
||||
},
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
AutoSizeAxes = Axes.X,
|
||||
Masking = true,
|
||||
CornerRadius = ModSelectPanel.CORNER_RADIUS,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
labelBackground = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Margin = new MarginPadding { Horizontal = 18 },
|
||||
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0),
|
||||
Text = Label,
|
||||
Font = OsuFont.Default.With(size: 17, weight: FontWeight.SemiBold)
|
||||
}
|
||||
}
|
||||
},
|
||||
content = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0),
|
||||
Spacing = new Vector2(2, 0),
|
||||
Child = Counter = new EffectCounter(CounterFormat)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Current = { BindTarget = Current.Value.StarRating }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
labelBackground.Colour = colourProvider.Background4;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
Current.BindValueChanged(e =>
|
||||
{
|
||||
//var effect = CalculateEffectForComparison(e.NewValue.CompareTo(Current.Default));
|
||||
setColours(e.NewValue.StarRating.Value);
|
||||
}, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fades colours of text and its background according to displayed value.
|
||||
/// </summary>
|
||||
/// <param name="stars">random number.</param>
|
||||
private void setColours(double stars)
|
||||
{
|
||||
contentBackground.FadeColour(colours.ForStarDifficulty(stars), transition_duration, Easing.OutQuint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts signed integer into <see cref="ModEffect"/>. Negative values are counted as difficulty reduction, positive as increase.
|
||||
/// </summary>
|
||||
/// <param name="comparison">Value to convert. Will arrive from comparison between <see cref="Current"/> bindable once it changes and it's <see cref="Bindable{T}.Default"/>.</param>
|
||||
/// <returns>Effect of the value.</returns>
|
||||
protected virtual ModEffect CalculateEffectForComparison(int comparison)
|
||||
{
|
||||
if (comparison == 0)
|
||||
return ModEffect.NotChanged;
|
||||
if (comparison < 0)
|
||||
return ModEffect.DifficultyReduction;
|
||||
|
||||
return ModEffect.DifficultyIncrease;
|
||||
}
|
||||
|
||||
protected enum ModEffect
|
||||
{
|
||||
NotChanged,
|
||||
DifficultyReduction,
|
||||
DifficultyIncrease
|
||||
}
|
||||
|
||||
private partial class EffectCounter : RollingCounter<double>
|
||||
{
|
||||
private readonly string? format;
|
||||
|
||||
public EffectCounter(string? format)
|
||||
{
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
protected override double RollingDuration => 500;
|
||||
|
||||
protected override LocalisableString FormatCount(double count) => count.ToLocalisableString(format);
|
||||
|
||||
protected override OsuSpriteText CreateSpriteText() => new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.Default.With(size: 17, weight: FontWeight.SemiBold)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -25,6 +25,7 @@ using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.Select.Details;
|
||||
using osu.Game.Utils;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
@ -123,6 +124,7 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
private Container aboveColumnsContent = null!;
|
||||
private DifficultyMultiplierDisplay? multiplierDisplay;
|
||||
private ModMapInfoDisplay mapInfoDisplay = null!;
|
||||
|
||||
protected ShearedButton BackButton { get; private set; } = null!;
|
||||
protected ShearedToggleButton? CustomisationButton { get; private set; }
|
||||
@ -219,6 +221,12 @@ namespace osu.Game.Overlays.Mods
|
||||
});
|
||||
}
|
||||
|
||||
aboveColumnsContent.Add(mapInfoDisplay = new ModMapInfoDisplay
|
||||
{
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.TopLeft
|
||||
});
|
||||
|
||||
FooterContent.Child = footerButtonFlow = new FillFlowContainer<ShearedButton>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
@ -244,6 +252,10 @@ namespace osu.Game.Overlays.Mods
|
||||
globalAvailableMods.BindTo(game.AvailableMods);
|
||||
}
|
||||
|
||||
public void SetBindedMapStats(Bindable<MapStats> stats)
|
||||
{
|
||||
mapInfoDisplay.Current = stats;
|
||||
}
|
||||
public override void Hide()
|
||||
{
|
||||
base.Hide();
|
||||
@ -399,6 +411,12 @@ namespace osu.Game.Overlays.Mods
|
||||
multiplierDisplay.Current.Value = multiplier;
|
||||
}
|
||||
|
||||
private void updateMapInfo()
|
||||
{
|
||||
if (mapInfoDisplay == null)
|
||||
return;
|
||||
}
|
||||
|
||||
private void updateCustomisation()
|
||||
{
|
||||
if (CustomisationButton == null)
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -273,6 +274,11 @@ namespace osu.Game.Screens.Select
|
||||
loading.Hide();
|
||||
}
|
||||
|
||||
public Bindable<MapStats> GetBindedAdjustedMapStats()
|
||||
{
|
||||
return advanced.AdjustedMapStats.GetBoundCopy();
|
||||
}
|
||||
|
||||
private partial class DetailBox : Container
|
||||
{
|
||||
private readonly Container content;
|
||||
|
@ -113,6 +113,8 @@ namespace osu.Game.Screens.Select.Details
|
||||
updateStatistics();
|
||||
}
|
||||
|
||||
public Bindable<MapStats> AdjustedMapStats = new Bindable<MapStats>();
|
||||
|
||||
private void updateStatistics()
|
||||
{
|
||||
IBeatmapDifficultyInfo baseDifficulty = BeatmapInfo?.Difficulty;
|
||||
@ -146,6 +148,14 @@ namespace osu.Game.Screens.Select.Details
|
||||
ApproachRate.Value = (baseDifficulty?.ApproachRate ?? 0, adjustedDifficulty?.ApproachRate);
|
||||
|
||||
updateStarDifficulty();
|
||||
|
||||
var temp = AdjustedMapStats.Value;
|
||||
temp.CS.Value = FirstValue.Value.adjustedValue ?? 0;
|
||||
temp.HP.Value = HpDrain.Value.adjustedValue ?? 0;
|
||||
temp.OD.Value = Accuracy.Value.adjustedValue ?? 0;
|
||||
temp.AR.Value = ApproachRate.Value.adjustedValue ?? 5;
|
||||
AdjustedMapStats.Value = temp;
|
||||
|
||||
}
|
||||
|
||||
private CancellationTokenSource starDifficultyCancellationSource;
|
||||
@ -178,6 +188,11 @@ namespace osu.Game.Screens.Select.Details
|
||||
return;
|
||||
|
||||
starDifficulty.Value = ((float)normalDifficulty.Value.Stars, (float)moddedDifficulty.Value.Stars);
|
||||
|
||||
var temp = AdjustedMapStats.Value;
|
||||
temp.StarRating.Value = moddedDifficulty.Value.Stars;
|
||||
AdjustedMapStats.Value = temp;
|
||||
|
||||
}), starDifficultyCancellationSource.Token, TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.Current);
|
||||
});
|
||||
|
||||
@ -296,4 +311,10 @@ namespace osu.Game.Screens.Select.Details
|
||||
}
|
||||
}
|
||||
}
|
||||
public struct MapStats
|
||||
{
|
||||
public Bindable<double> StarRating;
|
||||
public Bindable<double> MinBPM, MaxBPM, AvgBPM;
|
||||
public Bindable<float> CS, HP, AR, OD;
|
||||
}
|
||||
}
|
||||
|
@ -305,6 +305,9 @@ namespace osu.Game.Screens.Select
|
||||
// therein it will be registered at the `OsuGame` level to properly function as a blocking overlay.
|
||||
LoadComponent(ModSelect = CreateModSelectOverlay());
|
||||
|
||||
var bindedStats = BeatmapDetails.Details.GetBindedAdjustedMapStats();
|
||||
ModSelect.SetBindedMapStats(bindedStats);
|
||||
|
||||
if (Footer != null)
|
||||
{
|
||||
foreach (var (button, overlay) in CreateFooterButtons())
|
||||
|
Loading…
x
Reference in New Issue
Block a user