1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-28 20:13:00 +08:00

somewhat working prototype

This commit is contained in:
Givikap120 2023-08-28 23:16:33 +03:00
parent 8a1fc7c340
commit 50235cc245
7 changed files with 121 additions and 77 deletions

View File

@ -0,0 +1,58 @@
// 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.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Overlays.BeatmapSet;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Screens.Select.Details;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Overlays.Mods
{
public partial class ModMapInfoContainer : Container
{
private ModMapInfoDisplay starRatingDisplay = null!;
[Resolved]
private OsuColour colours { get; set; } = null!;
[Resolved]
private Bindable<BeatmapInfo> adjustedInfo { get; set; } = null!;
private Bindable<double> starRatingValue = new Bindable<double>();
//public ModMapInfoContainer()
//{
//
//}
protected override void LoadComplete()
{
starRatingDisplay = new ModMapInfoDisplay("Star Rating", colours.ForStarDifficulty);
starRatingDisplay.Current.BindTo(starRatingValue);
Content.Add(starRatingDisplay);
adjustedInfo.BindValueChanged(e => { updateValues(); }, true);
}
private void updateValues()
{
starRatingValue.Value = adjustedInfo.Value.StarRating;
}
}
}

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;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.LocalisationExtensions;
@ -12,14 +13,13 @@ 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 partial class ModMapInfoDisplay : Container, IHasCurrentValue<double>
{
public const float HEIGHT = 42;
private const float transition_duration = 200;
@ -28,36 +28,40 @@ namespace osu.Game.Overlays.Mods
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>();
//public Bindable<double> Current
//{
// get => current.Current;
// set => current.Current = value;
//}
//private readonly BindableWithCurrent<double> current = new BindableWithCurrent<double>();
[Resolved]
private OsuColour colours { get; set; } = null!;
public Bindable<double> Current { get; set; } = new BindableWithCurrent<double>();
//[Resolved]
//private OsuColour colours { get; set; } = null!;
[Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!;
protected Func<double, osuTK.Graphics.Color4> GetColor;
/// <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 LocalisableString Label;
protected virtual float ValueAreaWidth => 56;
protected virtual string CounterFormat => @"N0";
protected virtual string CounterFormat => @"0.00";
protected override Container<Drawable> Content => content;
protected readonly RollingCounter<double> Counter;
public ModMapInfoDisplay()
public ModMapInfoDisplay(LocalisableString label, Func<double, osuTK.Graphics.Color4> colorFunc)
{
Label = label;
GetColor = colorFunc;
Height = HEIGHT;
AutoSizeAxes = Axes.X;
@ -125,7 +129,7 @@ namespace osu.Game.Overlays.Mods
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Current = { BindTarget = Current.Value.StarRating }
Current = { BindTarget = Current }
}
}
}
@ -146,39 +150,17 @@ namespace osu.Game.Overlays.Mods
Current.BindValueChanged(e =>
{
//var effect = CalculateEffectForComparison(e.NewValue.CompareTo(Current.Default));
setColours(e.NewValue.StarRating.Value);
setColours(e.NewValue);
}, 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)
/// <param name="value">value</param>
private void setColours(double value)
{
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
contentBackground.FadeColour(GetColor(value), transition_duration, Easing.OutQuint);
}
private partial class EffectCounter : RollingCounter<double>

View File

@ -25,9 +25,9 @@ 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.Graphics;
using osuTK.Input;
namespace osu.Game.Overlays.Mods
@ -124,7 +124,8 @@ namespace osu.Game.Overlays.Mods
private Container aboveColumnsContent = null!;
private DifficultyMultiplierDisplay? multiplierDisplay;
private ModMapInfoDisplay mapInfoDisplay = null!;
private ModMapInfoContainer mapInfoContainer = null!;
protected ShearedButton BackButton { get; private set; } = null!;
protected ShearedToggleButton? CustomisationButton { get; private set; }
@ -221,7 +222,7 @@ namespace osu.Game.Overlays.Mods
});
}
aboveColumnsContent.Add(mapInfoDisplay = new ModMapInfoDisplay
aboveColumnsContent.Add(mapInfoContainer = new ModMapInfoContainer
{
Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft
@ -251,11 +252,6 @@ namespace osu.Game.Overlays.Mods
globalAvailableMods.BindTo(game.AvailableMods);
}
public void SetBindedMapStats(Bindable<MapStats> stats)
{
mapInfoDisplay.Current = stats;
}
public override void Hide()
{
base.Hide();
@ -282,6 +278,7 @@ namespace osu.Game.Overlays.Mods
SelectedMods.BindValueChanged(_ =>
{
updateMapInfo();
updateMultiplier();
updateFromExternalSelection();
updateCustomisation();
@ -413,8 +410,10 @@ namespace osu.Game.Overlays.Mods
private void updateMapInfo()
{
if (mapInfoDisplay == null)
if (mapInfoContainer == null)
return;
//mapInfoDisplay.Current.Value = 5;
}
private void updateCustomisation()

View File

@ -4,6 +4,7 @@
#nullable disable
using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -30,6 +31,9 @@ namespace osu.Game.Screens.Select
public readonly BeatmapDetails Details;
//[Cached]
//public Bindable<BeatmapInfo> AdjustedInfo { get; private set; } = new Bindable<BeatmapInfo>();
protected Bindable<BeatmapDetailAreaTabItem> CurrentTab => tabControl.Current;
protected Bindable<bool> CurrentModsFilter => tabControl.CurrentModsFilter;

View File

@ -274,11 +274,6 @@ namespace osu.Game.Screens.Select
loading.Hide();
}
public Bindable<MapStats> GetBindedAdjustedMapStats()
{
return advanced.AdjustedMapStats.GetBoundCopy();
}
private partial class DetailBox : Container
{
private readonly Container content;

View File

@ -46,6 +46,11 @@ namespace osu.Game.Screens.Select.Details
private IBeatmapInfo beatmapInfo;
#nullable enable
[Resolved]
private Bindable<BeatmapInfo>? adjustedInfo { get; set; } = null;
#nullable disable
public IBeatmapInfo BeatmapInfo
{
get => beatmapInfo;
@ -99,6 +104,21 @@ namespace osu.Game.Screens.Select.Details
private ModSettingChangeTracker modSettingChangeTracker;
private ScheduledDelegate debouncedStatisticsUpdate;
private void updateBindedInfo()
{
if (adjustedInfo == null) return;
BeatmapInfo adjusted = (BeatmapInfo)beatmapInfo;
adjusted.Difficulty.CircleSize = FirstValue.Value.adjustedValue ?? 0;
adjusted.Difficulty.DrainRate = HpDrain.Value.adjustedValue ?? 0;
adjusted.Difficulty.ApproachRate = ApproachRate.Value.adjustedValue ?? 5;
adjusted.Difficulty.OverallDifficulty = Accuracy.Value.adjustedValue ?? 0;
adjusted.StarRating = starDifficulty.Value.adjustedValue ?? 0;
adjustedInfo.Value = adjusted;
adjustedInfo.TriggerChange();
}
private void modsChanged(ValueChangedEvent<IReadOnlyList<Mod>> mods)
{
modSettingChangeTracker?.Dispose();
@ -113,8 +133,6 @@ namespace osu.Game.Screens.Select.Details
updateStatistics();
}
public Bindable<MapStats> AdjustedMapStats = new Bindable<MapStats>();
private void updateStatistics()
{
IBeatmapDifficultyInfo baseDifficulty = BeatmapInfo?.Difficulty;
@ -149,13 +167,6 @@ namespace osu.Game.Screens.Select.Details
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;
@ -188,10 +199,7 @@ 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;
updateBindedInfo();
}), starDifficultyCancellationSource.Token, TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.Current);
});
@ -311,10 +319,4 @@ 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;
}
}

View File

@ -99,6 +99,9 @@ namespace osu.Game.Screens.Select
[Resolved]
private Bindable<IReadOnlyList<Mod>> selectedMods { get; set; } = null!;
[Cached]
private Bindable<BeatmapInfo> adjustedInfo { get; set; } = new Bindable<BeatmapInfo>();
protected BeatmapCarousel Carousel { get; private set; } = null!;
private ParallaxContainer wedgeBackground = null!;
@ -305,8 +308,8 @@ 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);
//var bindedStats = BeatmapDetails.Details.GetBindedAdjustedMapStats();
//ModSelect.SetBindedMapStats(bindedStats);
if (Footer != null)
{
@ -583,6 +586,7 @@ namespace osu.Game.Screens.Select
FilterControl.Activate();
ModSelect.SelectedMods.BindTo(selectedMods);
//BeatmapDetails.AdjustedInfo.BindTo(adjustedInfo);
beginLooping();
}