1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 12:42:54 +08:00

fixed all stated problems

This commit is contained in:
Givikap120 2023-09-08 20:32:55 +03:00
parent 8281ed5173
commit 02e2b8546c
6 changed files with 90 additions and 98 deletions

View File

@ -1,29 +0,0 @@
// 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;
namespace osu.Game.Beatmaps
{
public class BeatmapShortInfo : IEquatable<BeatmapShortInfo>
{
public StarDifficulty StarDifficulty;
public float CircleSize;
public float DrainRate;
public float ApproachRate;
public float OverallDifficulty;
public double BPM;
public bool Equals(BeatmapShortInfo? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return StarDifficulty.Stars == other.StarDifficulty.Stars &&
CircleSize.Equals(other.CircleSize) &&
DrainRate.Equals(other.DrainRate) &&
ApproachRate.Equals(other.ApproachRate) &&
OverallDifficulty.Equals(other.OverallDifficulty) &&
BPM.Equals(other.BPM);
}
}
}

View File

@ -1,8 +1,8 @@
// 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.
#nullable disable
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.LocalisationExtensions;
@ -16,12 +16,14 @@ using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Mods;
using osuTK;
using osuTK.Graphics;
using System.Threading;
namespace osu.Game.Overlays.Mods
{
public partial class ModMapInfoContainer : Container
public partial class ModEffectPreviewPanel : CompositeDrawable
{
private Container content;
private Container innerContent;
@ -37,13 +39,37 @@ namespace osu.Game.Overlays.Mods
private VerticalAttributeDisplay approachRateDisplay;
private VerticalAttributeDisplay overallDifficultyDisplay;
[Resolved]
private OverlayColourProvider colourProvider { get; set; }
public const float HEIGHT = 50; // as ModSelectOverlay footer buttons
private const float transition_duration = 250;
private IBeatmapInfo beatmapInfo = null!;
public IBeatmapInfo BeatmapInfo
{
get => beatmapInfo;
set
{
if (value == beatmapInfo) return;
beatmapInfo = value;
updateStarDifficultyBind();
UpdateValues();
}
}
[Resolved]
private Bindable<BeatmapShortInfo> adjustedInfo { get; set; }
private Bindable<IReadOnlyList<Mod>> mods { get; set; } = null!;
public ModMapInfoContainer()
[Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!;
[Resolved]
private BeatmapDifficultyCache difficultyCache { get; set; } = null!;
private CancellationTokenSource cancellationSource = null!;
private IBindable<StarDifficulty?> starDifficulty = null!;
public ModEffectPreviewPanel()
{
// values as ModSelectOverlay footer buttons
const float shear = ShearedOverlayContainer.SHEAR;
@ -56,7 +82,7 @@ namespace osu.Game.Overlays.Mods
Origin = Anchor.BottomRight,
Anchor = Anchor.BottomRight,
AutoSizeAxes = Axes.X,
Height = 50, // as ModSelectOverlay footer buttons
Height = HEIGHT,
Shear = new Vector2(shear, 0),
CornerRadius = corner_radius,
BorderThickness = border_thickness,
@ -146,27 +172,47 @@ namespace osu.Game.Overlays.Mods
}
protected override void LoadComplete()
{
adjustedInfo.BindValueChanged(e => { UpdateValues(); }, true);
background.Colour = colourProvider.Background4;
innerBackground.Colour = colourProvider.Background3;
Color4 glow_colour = colourProvider.Background1;
content.BorderColour = ColourInfo.GradientVertical(background.Colour, glow_colour);
innerContent.BorderColour = ColourInfo.GradientVertical(innerBackground.Colour, glow_colour);
}
updateStarDifficultyBind();
}
private void updateStarDifficultyBind()
{
if (cancellationSource != null) cancellationSource.Cancel();
starDifficulty = difficultyCache.GetBindableDifficulty(beatmapInfo, (cancellationSource = new CancellationTokenSource()).Token);
starDifficulty.BindValueChanged(s =>
{
starRatingDisplay.Current.Value = s.NewValue ?? default;
if (!starRatingDisplay.IsPresent)
starRatingDisplay.FinishTransforms(true);
starRatingDisplay.FadeIn(transition_duration);
});
}
public void UpdateValues()
{
if (adjustedInfo.Value == null) return;
if (beatmapInfo == null) return;
starRatingDisplay.Current.Value = adjustedInfo.Value.StarDifficulty;
bpmDisplay.Current.Value = adjustedInfo.Value.BPM;
double rate = 1;
foreach (var mod in mods.Value.OfType<IApplicableToRate>())
rate = mod.ApplyToRate(0, rate);
circleSizeDisplay.Current.Value = adjustedInfo.Value.CircleSize;
drainRateDisplay.Current.Value = adjustedInfo.Value.DrainRate;
approachRateDisplay.Current.Value = adjustedInfo.Value.ApproachRate;
overallDifficultyDisplay.Current.Value = adjustedInfo.Value.OverallDifficulty;
bpmDisplay.Current.Value = beatmapInfo.BPM * rate;
BeatmapDifficulty adjustedDifficulty = new BeatmapDifficulty(BeatmapInfo.Difficulty);
foreach (var mod in mods.Value.OfType<IApplicableToDifficulty>())
mod.ApplyToDifficulty(adjustedDifficulty);
circleSizeDisplay.Current.Value = adjustedDifficulty.CircleSize;
drainRateDisplay.Current.Value = adjustedDifficulty.DrainRate;
approachRateDisplay.Current.Value = adjustedDifficulty.ApproachRate;
overallDifficultyDisplay.Current.Value = adjustedDifficulty.OverallDifficulty;
}
private partial class BPMDisplay : RollingCounter<double>

View File

@ -17,6 +17,7 @@ using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Utils;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
@ -27,7 +28,6 @@ using osu.Game.Localisation;
using osu.Game.Rulesets.Mods;
using osu.Game.Utils;
using osuTK;
using osuTK.Graphics;
using osuTK.Input;
namespace osu.Game.Overlays.Mods
@ -125,7 +125,7 @@ namespace osu.Game.Overlays.Mods
private Container aboveColumnsContent = null!;
private DifficultyMultiplierDisplay? multiplierDisplay;
private ModMapInfoContainer mapInfoContainer = null!;
private ModEffectPreviewPanel modEffectPreviewPanel = null!;
protected ShearedButton BackButton { get; private set; } = null!;
protected ShearedToggleButton? CustomisationButton { get; private set; }
@ -133,6 +133,20 @@ namespace osu.Game.Overlays.Mods
private Sample? columnAppearSample;
private WorkingBeatmap beatmap = null!;
public WorkingBeatmap Beatmap
{
get => beatmap;
set
{
if (beatmap == value) return;
beatmap = value;
modEffectPreviewPanel.BeatmapInfo = beatmap.BeatmapInfo;
}
}
protected ModSelectOverlay(OverlayColourScheme colourScheme = OverlayColourScheme.Green)
: base(colourScheme)
{
@ -224,11 +238,11 @@ namespace osu.Game.Overlays.Mods
FooterContent.Children = new Drawable[]
{
mapInfoContainer = new ModMapInfoContainer
modEffectPreviewPanel = new ModEffectPreviewPanel
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Padding = new MarginPadding
Margin = new MarginPadding
{
Vertical = PADDING,
Horizontal = 70
@ -286,7 +300,7 @@ namespace osu.Game.Overlays.Mods
SelectedMods.BindValueChanged(_ =>
{
updateMapInfo();
modEffectPreviewPanel.UpdateValues();
updateMultiplier();
updateFromExternalSelection();
updateCustomisation();
@ -300,7 +314,11 @@ namespace osu.Game.Overlays.Mods
//
// See https://github.com/ppy/osu/pull/23284#issuecomment-1529056988
modSettingChangeTracker = new ModSettingChangeTracker(SelectedMods.Value);
modSettingChangeTracker.SettingChanged += _ => updateMultiplier();
modSettingChangeTracker.SettingChanged += _ =>
{
modEffectPreviewPanel.UpdateValues();
updateMultiplier();
};
}
}, true);
@ -416,14 +434,6 @@ namespace osu.Game.Overlays.Mods
multiplierDisplay.Current.Value = multiplier;
}
private void updateMapInfo()
{
if (mapInfoContainer == null)
return;
mapInfoContainer.UpdateValues();
}
private void updateCustomisation()
{
if (CustomisationButton == null)

View File

@ -3,7 +3,6 @@
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;

View File

@ -46,9 +46,6 @@ namespace osu.Game.Screens.Select.Details
private IBeatmapInfo beatmapInfo;
[Resolved(canBeNull: true)]
private Bindable<BeatmapShortInfo> adjustedInfo { get; set; } = null;
public IBeatmapInfo BeatmapInfo
{
get => beatmapInfo;
@ -101,33 +98,6 @@ namespace osu.Game.Screens.Select.Details
private ModSettingChangeTracker modSettingChangeTracker;
private ScheduledDelegate debouncedStatisticsUpdate;
private StarDifficulty latestStarDifficulty = new StarDifficulty();
private void updateBindedInfo()
{
if (adjustedInfo == null) return;
// sadly need to calculate this to prevent additional data transportation
double rate = 1;
foreach (var mod in mods.Value.OfType<IApplicableToRate>())
rate = mod.ApplyToRate(0, rate);
double bpm = 0;
if (beatmapInfo != null) bpm = beatmapInfo.BPM * rate;
BeatmapShortInfo adjusted = new BeatmapShortInfo()
{
CircleSize = FirstValue.Value.adjustedValue ?? FirstValue.Value.baseValue,
DrainRate = HpDrain.Value.adjustedValue ?? HpDrain.Value.baseValue,
ApproachRate = ApproachRate.Value.adjustedValue ?? ApproachRate.Value.baseValue,
OverallDifficulty = Accuracy.Value.adjustedValue ?? Accuracy.Value.baseValue,
BPM = bpm,
StarDifficulty = latestStarDifficulty
};
adjustedInfo.Value = adjusted;
}
private void modsChanged(ValueChangedEvent<IReadOnlyList<Mod>> mods)
{
modSettingChangeTracker?.Dispose();
@ -174,7 +144,6 @@ namespace osu.Game.Screens.Select.Details
Accuracy.Value = (baseDifficulty?.OverallDifficulty ?? 0, adjustedDifficulty?.OverallDifficulty);
ApproachRate.Value = (baseDifficulty?.ApproachRate ?? 0, adjustedDifficulty?.ApproachRate);
updateBindedInfo(); // to faster UI response (without SR calculation)
updateStarDifficulty();
}
@ -208,8 +177,6 @@ namespace osu.Game.Screens.Select.Details
return;
starDifficulty.Value = ((float)normalDifficulty.Value.Stars, (float)moddedDifficulty.Value.Stars);
latestStarDifficulty = moddedDifficulty ?? default;
updateBindedInfo();
}), starDifficultyCancellationSource.Token, TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.Current);
});

View File

@ -99,9 +99,6 @@ namespace osu.Game.Screens.Select
[Resolved]
private Bindable<IReadOnlyList<Mod>> selectedMods { get; set; } = null!;
[Cached]
private Bindable<BeatmapShortInfo> adjustedInfo { get; set; } = new Bindable<BeatmapShortInfo>();
protected BeatmapCarousel Carousel { get; private set; } = null!;
private ParallaxContainer wedgeBackground = null!;
@ -786,6 +783,8 @@ namespace osu.Game.Screens.Select
BeatmapDetails.Beatmap = beatmap;
ModSelect.Beatmap = beatmap;
bool beatmapSelected = beatmap is not DummyWorkingBeatmap;
if (beatmapSelected)