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

Rename timing changes, simplify + improve columns/dictionary usage.

This commit is contained in:
smoogipooo 2017-06-07 19:09:51 +09:00
parent 7aee8ee547
commit 6f191193a1
8 changed files with 61 additions and 40 deletions

View File

@ -49,14 +49,14 @@ namespace osu.Desktop.VisualTests.Tests
{
if (gravity)
{
return new DrawableGravityTimingChange(new TimingChange
return new DrawableManiaGravityTimingChange(new TimingChange
{
BeatLength = 1000,
Time = time
});
}
return new DrawableScrollingTimingChange(new TimingChange
return new DrawableManiaScrollingTimingChange(new TimingChange
{
BeatLength = 1000,
Time = time

View File

@ -31,20 +31,19 @@ namespace osu.Game.Rulesets.Mania.Mods
{
var maniaHitRenderer = (ManiaHitRenderer)hitRenderer;
maniaHitRenderer.HitObjectTimingChanges = new Dictionary<int, List<DrawableTimingChange>>();
maniaHitRenderer.HitObjectTimingChanges = new List<DrawableTimingChange>[maniaHitRenderer.PreferredColumns];
maniaHitRenderer.BarlineTimingChanges = new List<DrawableTimingChange>();
for (int i = 0; i < maniaHitRenderer.PreferredColumns; i++)
maniaHitRenderer.HitObjectTimingChanges[i] = new List<DrawableTimingChange>();
foreach (HitObject obj in maniaHitRenderer.Objects)
{
var maniaObject = obj as ManiaHitObject;
if (maniaObject == null)
continue;
List<DrawableTimingChange> timingChanges;
if (!maniaHitRenderer.HitObjectTimingChanges.TryGetValue(maniaObject.Column, out timingChanges))
maniaHitRenderer.HitObjectTimingChanges[maniaObject.Column] = timingChanges = new List<DrawableTimingChange>();
timingChanges.Add(new DrawableGravityTimingChange(new TimingChange
maniaHitRenderer.HitObjectTimingChanges[maniaObject.Column].Add(new DrawableManiaGravityTimingChange(new TimingChange
{
Time = obj.StartTime,
BeatLength = 1000
@ -63,7 +62,7 @@ namespace osu.Game.Rulesets.Mania.Mods
for (double t = timingPoints[i].Time; Precision.DefinitelyBigger(endTime, t); t += point.BeatLength)
{
maniaHitRenderer.BarlineTimingChanges.Add(new DrawableGravityTimingChange(new TimingChange
maniaHitRenderer.BarlineTimingChanges.Add(new DrawableManiaGravityTimingChange(new TimingChange
{
Time = t,
BeatLength = 1000

View File

@ -5,9 +5,9 @@ using osu.Game.Rulesets.Timing;
namespace osu.Game.Rulesets.Mania.Timing.Drawables
{
public class DrawableGravityTimingChange : DrawableManiaTimingChange
public class DrawableManiaGravityTimingChange : DrawableManiaTimingChange
{
public DrawableGravityTimingChange(TimingChange timingChange)
public DrawableManiaGravityTimingChange(TimingChange timingChange)
: base(timingChange)
{
}

View File

@ -5,9 +5,12 @@ using osu.Game.Rulesets.Timing;
namespace osu.Game.Rulesets.Mania.Timing.Drawables
{
public class DrawableScrollingTimingChange : DrawableManiaTimingChange
/// <summary>
/// A basic timing change which scrolls along with a timing change.
/// </summary>
public class DrawableManiaScrollingTimingChange : DrawableManiaTimingChange
{
public DrawableScrollingTimingChange(TimingChange timingChange)
public DrawableManiaScrollingTimingChange(TimingChange timingChange)
: base(timingChange)
{
}

View File

@ -7,7 +7,7 @@ using osu.Game.Rulesets.Timing.Drawables;
namespace osu.Game.Rulesets.Mania.Timing.Drawables
{
public class DrawableManiaTimingChange : DrawableTimingChange
public abstract class DrawableManiaTimingChange : DrawableTimingChange
{
public DrawableManiaTimingChange(TimingChange timingChange)
: base(timingChange, Axes.Y)

View File

@ -32,19 +32,31 @@ namespace osu.Game.Rulesets.Mania.UI
{
public class ManiaHitRenderer : HitRenderer<ManiaHitObject, ManiaJudgement>
{
private int? columns;
public int Columns
{
get { return columns ?? (int)Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize); }
set { columns = value; }
}
/// <summary>
/// Preferred column count. This will only have an effect during the initialization of the play field.
/// </summary>
public int PreferredColumns;
public Dictionary<int, List<DrawableTimingChange>> HitObjectTimingChanges;
/// <summary>
/// Per-column timing changes.
/// </summary>
public List<DrawableTimingChange>[] HitObjectTimingChanges;
/// <summary>
/// Bar line timing changes.
/// </summary>
public List<DrawableTimingChange> BarlineTimingChanges;
/// <summary>
/// Number of columns in the playfield of this hit renderer. Null if the play field hasn't been generated yet.
/// </summary>
public int? Columns { get; private set; }
public ManiaHitRenderer(WorkingBeatmap beatmap, bool isForCurrentRuleset)
: base(beatmap, isForCurrentRuleset)
{
Columns = PreferredColumns;
generateDefaultTimingChanges();
}
@ -53,9 +65,12 @@ namespace osu.Game.Rulesets.Mania.UI
if (HitObjectTimingChanges != null || BarlineTimingChanges != null)
return;
HitObjectTimingChanges = new Dictionary<int, List<DrawableTimingChange>>();
HitObjectTimingChanges = new List<DrawableTimingChange>[Columns.Value];
BarlineTimingChanges = new List<DrawableTimingChange>();
for (int i = 0; i < Columns.Value; i++)
HitObjectTimingChanges[i] = new List<DrawableTimingChange>();
double lastSpeedMultiplier = 1;
double lastBeatLength = 500;
@ -98,22 +113,22 @@ namespace osu.Game.Rulesets.Mania.UI
timingChanges.ForEach(t =>
{
for (int i = 0; i < Columns; i++)
{
List<DrawableTimingChange> columnTimingChanges;
if (!HitObjectTimingChanges.TryGetValue(i, out columnTimingChanges))
HitObjectTimingChanges[i] = columnTimingChanges = new List<DrawableTimingChange>();
for (int i = 0; i < Columns.Value; i++)
HitObjectTimingChanges[i].Add(new DrawableManiaScrollingTimingChange(t));
columnTimingChanges.Add(new DrawableScrollingTimingChange(t));
}
BarlineTimingChanges.Add(new DrawableScrollingTimingChange(t));
BarlineTimingChanges.Add(new DrawableManiaScrollingTimingChange(t));
});
}
protected override void ApplyBeatmap()
{
base.ApplyBeatmap();
PreferredColumns = (int)Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize);
}
protected override Playfield<ManiaHitObject, ManiaJudgement> CreatePlayfield()
{
var playfield = new ManiaPlayfield(Columns)
var playfield = new ManiaPlayfield(Columns.Value)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
@ -121,13 +136,10 @@ namespace osu.Game.Rulesets.Mania.UI
Scale = new Vector2(1, -1)
};
foreach (var kvp in HitObjectTimingChanges)
for (int i = 0; i < Columns; i++)
{
int column = kvp.Key;
List<DrawableTimingChange> timingChanges = kvp.Value;
foreach (var change in timingChanges)
playfield.Columns.ElementAt(column).Add(change);
foreach (var change in HitObjectTimingChanges[i])
playfield.Columns.ElementAt(i).Add(change);
}
foreach (var change in BarlineTimingChanges)

View File

@ -84,9 +84,9 @@
<Compile Include="Mods\ManiaMod.cs" />
<Compile Include="Mods\ManiaModGravity.cs" />
<Compile Include="UI\SpecialColumnPosition.cs" />
<Compile Include="Timing\Drawables\DrawableGravityTimingChange.cs" />
<Compile Include="Timing\Drawables\DrawableManiaGravityTimingChange.cs" />
<Compile Include="Timing\Drawables\DrawableManiaTimingChange.cs" />
<Compile Include="Timing\Drawables\DrawableScrollingTimingChange.cs" />
<Compile Include="Timing\Drawables\DrawableManiaScrollingTimingChange.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">

View File

@ -148,6 +148,8 @@ namespace osu.Game.Rulesets.UI
// Post-process the beatmap
processor.PostProcess(Beatmap);
ApplyBeatmap();
// Add mods, should always be the last thing applied to give full control to mods
applyMods(beatmap.Mods.Value);
}
@ -165,6 +167,11 @@ namespace osu.Game.Rulesets.UI
mod.ApplyToHitRenderer(this);
}
/// <summary>
/// Called when the beatmap of this hit renderer has been set. Used to apply any default values from the beatmap.
/// </summary>
protected virtual void ApplyBeatmap() { }
/// <summary>
/// Creates a processor to perform post-processing operations
/// on HitObjects in converted Beatmaps.