1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:37:28 +08:00

Changed override method

now it overrides mods getter instead of calculate fuctions
This commit is contained in:
Givikap120 2024-02-20 12:57:28 +02:00
parent 24171bd02b
commit 54ef397d56
3 changed files with 41 additions and 70 deletions

View File

@ -41,6 +41,7 @@ namespace osu.Game.Overlays.Mods
[Resolved]
protected Bindable<IReadOnlyList<Mod>> Mods { get; private set; } = null!;
protected virtual IEnumerable<Mod> SelectedMods => Mods.Value;
public BindableBool Collapsed { get; } = new BindableBool(true);
@ -148,22 +149,6 @@ namespace osu.Game.Overlays.Mods
LeftContent.AutoSizeDuration = Content.AutoSizeDuration = transition_duration;
}
protected virtual double GetRate()
{
double rate = 1;
foreach (var mod in Mods.Value.OfType<IApplicableToRate>())
rate = mod.ApplyToRate(0, rate);
return rate;
}
protected virtual BeatmapDifficulty GetDifficulty()
{
BeatmapDifficulty originalDifficulty = new BeatmapDifficulty(BeatmapInfo.Value!.Difficulty);
foreach (var mod in Mods.Value.OfType<IApplicableToDifficulty>())
mod.ApplyToDifficulty(originalDifficulty);
return originalDifficulty;
}
private void updateValues() => Scheduler.AddOnce(() =>
{
if (BeatmapInfo.Value == null)
@ -180,14 +165,20 @@ namespace osu.Game.Overlays.Mods
starRatingDisplay.FinishTransforms(true);
});
double rate = GetRate();
BeatmapDifficulty originalDifficulty = GetDifficulty();
double rate = 1;
foreach (var mod in SelectedMods.OfType<IApplicableToRate>())
rate = mod.ApplyToRate(0, rate);
bpmDisplay.Current.Value = BeatmapInfo.Value.BPM * rate;
BeatmapDifficulty originalDifficulty = new BeatmapDifficulty(BeatmapInfo.Value.Difficulty);
foreach (var mod in SelectedMods.OfType<IApplicableToDifficulty>())
mod.ApplyToDifficulty(originalDifficulty);
Ruleset ruleset = GameRuleset.Value.CreateInstance();
BeatmapDifficulty adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(originalDifficulty, rate);
bpmDisplay.Current.Value = BeatmapInfo.Value.BPM * rate;
TooltipContent = new AdjustedAttributesTooltip.Data(originalDifficulty, adjustedDifficulty);
approachRateDisplay.AdjustType.Value = VerticalAttributeDisplay.CalculateEffect(originalDifficulty.ApproachRate, adjustedDifficulty.ApproachRate);

View File

@ -114,6 +114,8 @@ namespace osu.Game.Overlays.Mods
public IEnumerable<ModState> AllAvailableMods => AvailableMods.Value.SelectMany(pair => pair.Value);
protected virtual IEnumerable<Mod> AllSelectedMods => SelectedMods.Value;
private readonly BindableBool customisationVisible = new BindableBool();
private Bindable<bool> textSearchStartsActive = null!;
@ -317,7 +319,7 @@ namespace osu.Game.Overlays.Mods
SelectedMods.BindValueChanged(_ =>
{
UpdateRankingInformation();
updateRankingInformation();
updateFromExternalSelection();
updateCustomisation();
@ -330,7 +332,7 @@ namespace osu.Game.Overlays.Mods
//
// See https://github.com/ppy/osu/pull/23284#issuecomment-1529056988
modSettingChangeTracker = new ModSettingChangeTracker(SelectedMods.Value);
modSettingChangeTracker.SettingChanged += _ => UpdateRankingInformation();
modSettingChangeTracker.SettingChanged += _ => updateRankingInformation();
}
}, true);
@ -452,17 +454,17 @@ namespace osu.Game.Overlays.Mods
modState.ValidForSelection.Value = modState.Mod.Type != ModType.System && modState.Mod.HasImplementation && IsValidMod.Invoke(modState.Mod);
}
protected virtual void UpdateRankingInformation()
private void updateRankingInformation()
{
if (RankingInformationDisplay == null)
return;
double multiplier = 1.0;
foreach (var mod in SelectedMods.Value)
foreach (var mod in AllSelectedMods)
multiplier *= mod.ScoreMultiplier;
RankingInformationDisplay.Ranked.Value = SelectedMods.Value.All(m => m.Ranked);
RankingInformationDisplay.Ranked.Value = AllSelectedMods.All(m => m.Ranked);
RankingInformationDisplay.ModMultiplier.Value = multiplier;
}

View File

@ -1,13 +1,13 @@
// 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 System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Rulesets;
using osu.Game.Online.Rooms;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Overlays.Mods
@ -39,30 +39,21 @@ namespace osu.Game.Overlays.Mods
multiplayerRoomItem?.BindValueChanged(_ => SelectedMods.TriggerChange());
}
protected override void UpdateRankingInformation()
protected override IEnumerable<Mod> AllSelectedMods
{
if (RankingInformationDisplay == null)
return;
double multiplier = 1.0;
foreach (var mod in SelectedMods.Value)
multiplier *= mod.ScoreMultiplier;
RankingInformationDisplay.Ranked.Value = SelectedMods.Value.All(m => m.Ranked);
if (multiplayerRoomItem?.Value != null)
get
{
Ruleset ruleset = game.Ruleset.Value.CreateInstance();
var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset));
IEnumerable<Mod> allMods = SelectedMods.Value;
foreach (var mod in multiplayerRoomMods)
multiplier *= mod.ScoreMultiplier;
if (multiplayerRoomItem?.Value != null)
{
Ruleset ruleset = game.Ruleset.Value.CreateInstance();
var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset));
allMods = allMods.Concat(multiplayerRoomMods);
}
RankingInformationDisplay.Ranked.Value = RankingInformationDisplay.Ranked.Value && multiplayerRoomMods.All(m => m.Ranked);
return allMods;
}
RankingInformationDisplay.ModMultiplier.Value = multiplier;
}
}
@ -77,34 +68,21 @@ namespace osu.Game.Overlays.Mods
multiplayerRoomItem?.BindValueChanged(_ => Mods.TriggerChange());
}
protected override double GetRate()
protected override IEnumerable<Mod> SelectedMods
{
double rate = base.GetRate();
Ruleset ruleset = GameRuleset.Value.CreateInstance();
if (multiplayerRoomItem?.Value != null)
get
{
var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset));
foreach (var mod in multiplayerRoomMods.OfType<IApplicableToRate>())
rate = mod.ApplyToRate(0, rate);
IEnumerable<Mod> selectedMods = Mods.Value;
if (multiplayerRoomItem?.Value != null)
{
Ruleset ruleset = GameRuleset.Value.CreateInstance();
var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset));
selectedMods = selectedMods.Concat(multiplayerRoomMods);
}
return selectedMods;
}
return rate;
}
protected override BeatmapDifficulty GetDifficulty()
{
BeatmapDifficulty originalDifficulty = base.GetDifficulty();
Ruleset ruleset = GameRuleset.Value.CreateInstance();
if (multiplayerRoomItem?.Value != null)
{
var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset));
foreach (var mod in multiplayerRoomMods.OfType<IApplicableToDifficulty>())
mod.ApplyToDifficulty(originalDifficulty);
}
return originalDifficulty;
}
}
}