mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 16:52:54 +08:00
Add HitObject colours back in the mix.
This commit is contained in:
parent
92b85b251e
commit
b40ccccbe4
@ -6,6 +6,7 @@ using osu.Framework.GameModes.Testing;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osu.Game.Beatmaps.Objects;
|
||||
using osu.Game.Beatmaps.Objects.Osu;
|
||||
using osu.Game.GameModes.Play;
|
||||
@ -38,20 +39,27 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
objects.Add(new Circle()
|
||||
{
|
||||
StartTime = time,
|
||||
Position = new Vector2(RNG.Next(100, 400), RNG.Next(100, 200))
|
||||
Position = new Vector2(RNG.Next(0, 512), RNG.Next(0, 384)),
|
||||
NewCombo = (i + 1) % 4 == 0
|
||||
});
|
||||
|
||||
time += 500;
|
||||
}
|
||||
|
||||
var decoder = new ConstructableBeatmapDecoder();
|
||||
|
||||
Beatmap b = new Beatmap
|
||||
{
|
||||
HitObjects = objects
|
||||
};
|
||||
|
||||
decoder.Process(b);
|
||||
|
||||
Add(new Player
|
||||
{
|
||||
Beatmap = new WorkingBeatmap
|
||||
{
|
||||
Beatmap = new Beatmap
|
||||
{
|
||||
HitObjects = objects
|
||||
}
|
||||
Beatmap = b
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,13 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using osu.Game.Beatmaps.Objects;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
public abstract class BeatmapDecoder
|
||||
{
|
||||
private static Dictionary<string, Type> decoders { get; } = new Dictionary<string, Type>();
|
||||
|
||||
|
||||
public static BeatmapDecoder GetDecoder(TextReader stream)
|
||||
{
|
||||
var line = stream.ReadLine().Trim();
|
||||
@ -20,7 +22,39 @@ namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
decoders[magic] = typeof(T);
|
||||
}
|
||||
|
||||
public abstract Beatmap Decode(TextReader stream);
|
||||
|
||||
public virtual Beatmap Decode(TextReader stream)
|
||||
{
|
||||
Beatmap b = ParseFile(stream);
|
||||
Process(b);
|
||||
return b;
|
||||
}
|
||||
|
||||
public virtual Beatmap Process(Beatmap beatmap)
|
||||
{
|
||||
ApplyColours(beatmap);
|
||||
|
||||
return beatmap;
|
||||
}
|
||||
|
||||
protected abstract Beatmap ParseFile(TextReader stream);
|
||||
|
||||
public virtual void ApplyColours(Beatmap b)
|
||||
{
|
||||
List<Color4> colours = b.ComboColors ?? new List<Color4>() {
|
||||
new Color4(17, 136, 170, 255),
|
||||
new Color4(102,136,0, 255),
|
||||
new Color4(204,102,0, 255),
|
||||
new Color4(121,9,13, 255),
|
||||
};
|
||||
|
||||
int i = 0;
|
||||
|
||||
foreach (HitObject h in b.HitObjects)
|
||||
{
|
||||
h.Colour = colours[i];
|
||||
if (h.NewCombo) i = (i + 1) % colours.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
20
osu.Game/Beatmaps/Formats/ConstructableBeatmapDecoder.cs
Normal file
20
osu.Game/Beatmaps/Formats/ConstructableBeatmapDecoder.cs
Normal file
@ -0,0 +1,20 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
public class ConstructableBeatmapDecoder : BeatmapDecoder
|
||||
{
|
||||
protected override Beatmap ParseFile(TextReader stream)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -207,7 +207,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
});
|
||||
}
|
||||
|
||||
public override Beatmap Decode(TextReader stream)
|
||||
protected override Beatmap ParseFile(TextReader stream)
|
||||
{
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
|
@ -4,6 +4,7 @@
|
||||
using osu.Game.Beatmaps.Objects.Osu;
|
||||
using osu.Game.Beatmaps.Samples;
|
||||
using osu.Game.GameModes.Play;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Beatmaps.Objects
|
||||
{
|
||||
@ -15,6 +16,10 @@ namespace osu.Game.Beatmaps.Objects
|
||||
public double StartTime;
|
||||
public virtual double EndTime => StartTime;
|
||||
|
||||
public bool NewCombo { get; set; }
|
||||
|
||||
public Color4 Colour = new Color4(17, 136, 170, 255);
|
||||
|
||||
public double Duration => EndTime - StartTime;
|
||||
|
||||
public HitSampleInfo Sample;
|
||||
|
@ -7,6 +7,5 @@ namespace osu.Game.Beatmaps.Objects.Osu
|
||||
{
|
||||
public class Circle : OsuBaseHit
|
||||
{
|
||||
public Color4 Colour = new Color4(17, 136, 170, 255);
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ namespace osu.Game.Beatmaps.Objects.Osu
|
||||
public abstract class OsuBaseHit : HitObject
|
||||
{
|
||||
public Vector2 Position { get; set; }
|
||||
public bool NewCombo { get; set; }
|
||||
|
||||
[Flags]
|
||||
private enum HitObjectType
|
||||
|
@ -64,6 +64,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Beatmaps\Beatmap.cs" />
|
||||
<Compile Include="Beatmaps\Formats\ConstructableBeatmapDecoder.cs" />
|
||||
<Compile Include="Beatmaps\WorkingBeatmap.cs" />
|
||||
<Compile Include="Beatmaps\Drawable\BeatmapSetHeader.cs" />
|
||||
<Compile Include="Beatmaps\Drawable\DifficultyIcon.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user