1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 15:22:55 +08:00

Merge branch 'master' into fix-replay-import-statistics

This commit is contained in:
Dean Herbert 2019-01-07 13:44:01 +09:00 committed by GitHub
commit e73845172c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 42 additions and 18 deletions

View File

@ -7,6 +7,7 @@ using osu.Game.Rulesets.Objects.Types;
using System.Collections.Generic;
using osu.Game.Rulesets.Objects;
using System.Linq;
using osu.Framework.Caching;
using osu.Framework.Configuration;
using osu.Game.Audio;
using osu.Game.Beatmaps;
@ -26,8 +27,11 @@ namespace osu.Game.Rulesets.Osu.Objects
public double EndTime => StartTime + this.SpanCount() * Path.Distance / Velocity;
public double Duration => EndTime - StartTime;
private Cached<Vector2> endPositionCache;
public override Vector2 EndPosition => endPositionCache.IsValid ? endPositionCache.Value : endPositionCache.Value = Position + this.CurvePositionAt(1);
public Vector2 StackedPositionAt(double t) => StackedPosition + this.CurvePositionAt(t);
public override Vector2 EndPosition => Position + this.CurvePositionAt(1);
public override int ComboIndex
{
@ -56,7 +60,11 @@ namespace osu.Game.Rulesets.Osu.Objects
public SliderPath Path
{
get => PathBindable.Value;
set => PathBindable.Value = value;
set
{
PathBindable.Value = value;
endPositionCache.Invalidate();
}
}
public double Distance => Path.Distance;
@ -73,6 +81,8 @@ namespace osu.Game.Rulesets.Osu.Objects
if (TailCircle != null)
TailCircle.Position = EndPosition;
endPositionCache.Invalidate();
}
}
@ -92,7 +102,17 @@ namespace osu.Game.Rulesets.Osu.Objects
public List<List<SampleInfo>> NodeSamples { get; set; } = new List<List<SampleInfo>>();
public int RepeatCount { get; set; }
private int repeatCount;
public int RepeatCount
{
get => repeatCount;
set
{
repeatCount = value;
endPositionCache.Invalidate();
}
}
/// <summary>
/// The length of one span of this <see cref="Slider"/>.
@ -169,7 +189,11 @@ namespace osu.Game.Rulesets.Osu.Objects
private void createTicks()
{
var length = Path.Distance;
// A very lenient maximum length of a slider for ticks to be generated.
// This exists for edge cases such as /b/1573664 where the beatmap has been edited by the user, and should never be reached in normal usage.
const double max_length = 100000;
var length = Math.Min(max_length, Path.Distance);
var tickDistance = MathHelper.Clamp(TickDistance, 0, length);
if (tickDistance == 0) return;

View File

@ -5,7 +5,6 @@ using System.ComponentModel;
using System.Linq;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
namespace osu.Game.Tests.Visual
@ -23,7 +22,7 @@ namespace osu.Game.Tests.Visual
// Reset the mods
Beatmap.Value.Mods.Value = Beatmap.Value.Mods.Value.Where(m => !(m is ModAutoplay));
return new ReplayPlayer(new Score { Replay = dummyRulesetContainer.Replay });
return new ReplayPlayer(dummyRulesetContainer.ReplayScore);
}
}
}

View File

@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Mods
public override bool HasImplementation => GetType().GenericTypeArguments.Length == 0;
public virtual void ApplyToRulesetContainer(RulesetContainer<T> rulesetContainer) => rulesetContainer.SetReplay(CreateReplayScore(rulesetContainer.Beatmap)?.Replay);
public virtual void ApplyToRulesetContainer(RulesetContainer<T> rulesetContainer) => rulesetContainer.SetReplayScore(CreateReplayScore(rulesetContainer.Beatmap));
}
public abstract class ModAutoplay : Mod, IApplicableFailOverride

View File

@ -22,6 +22,7 @@ using osu.Game.Overlays;
using osu.Game.Replays;
using osu.Game.Rulesets.Configuration;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
namespace osu.Game.Rulesets.UI
{
@ -130,7 +131,7 @@ namespace osu.Game.Rulesets.UI
protected virtual ReplayInputHandler CreateReplayInputHandler(Replay replay) => null;
public Replay Replay { get; private set; }
public Score ReplayScore { get; private set; }
/// <summary>
/// Whether the game is paused. Used to block user input.
@ -140,14 +141,14 @@ namespace osu.Game.Rulesets.UI
/// <summary>
/// Sets a replay to be used, overriding local input.
/// </summary>
/// <param name="replay">The replay, null for local input.</param>
public virtual void SetReplay(Replay replay)
/// <param name="replayScore">The replay, null for local input.</param>
public virtual void SetReplayScore(Score replayScore)
{
if (ReplayInputManager == null)
throw new InvalidOperationException($"A {nameof(KeyBindingInputManager)} which supports replay loading is not available");
Replay = replay;
ReplayInputManager.ReplayInputHandler = replay != null ? CreateReplayInputHandler(replay) : null;
ReplayScore = replayScore;
ReplayInputManager.ReplayInputHandler = replayScore != null ? CreateReplayInputHandler(replayScore.Replay) : null;
HasReplayLoaded.Value = ReplayInputManager.ReplayInputHandler != null;
}
@ -302,9 +303,9 @@ namespace osu.Game.Rulesets.UI
mod.ReadFromConfig(config);
}
public override void SetReplay(Replay replay)
public override void SetReplayScore(Score replayScore)
{
base.SetReplay(replay);
base.SetReplayScore(replayScore);
if (ReplayInputManager?.ReplayInputHandler != null)
ReplayInputManager.ReplayInputHandler.GamefieldToScreenSpace = Playfield.GamefieldToScreenSpace;

View File

@ -31,7 +31,7 @@ namespace osu.Game.Scoring
[Column(TypeName="DECIMAL(1,4)")]
public double Accuracy { get; set; }
[JsonIgnore]
[JsonProperty(@"pp")]
public double? PP { get; set; }
[JsonProperty("max_combo")]

View File

@ -285,7 +285,7 @@ namespace osu.Game.Screens.Play
if (!IsCurrentScreen) return;
var score = CreateScore();
if (RulesetContainer.Replay == null)
if (RulesetContainer.ReplayScore == null)
scoreManager.Import(score, true);
Push(CreateResults(score));
@ -297,7 +297,7 @@ namespace osu.Game.Screens.Play
protected virtual ScoreInfo CreateScore()
{
var score = new ScoreInfo
var score = RulesetContainer.ReplayScore?.ScoreInfo ?? new ScoreInfo
{
Beatmap = Beatmap.Value.BeatmapInfo,
Ruleset = ruleset,

View File

@ -17,7 +17,7 @@ namespace osu.Game.Screens.Play
protected override void LoadComplete()
{
base.LoadComplete();
RulesetContainer.SetReplay(score.Replay);
RulesetContainer.SetReplayScore(score);
}
protected override ScoreInfo CreateScore() => score.ScoreInfo;