mirror of
https://github.com/ppy/osu.git
synced 2025-02-05 20:42:55 +08:00
Fix regressions with HitRenderers, while also cleaning them up.
This commit is contained in:
parent
8707c7f746
commit
2566d6bfe0
@ -23,7 +23,7 @@ namespace osu.Desktop.Tests
|
|||||||
|
|
||||||
public override string Description => @"Showing hitobjects and what not.";
|
public override string Description => @"Showing hitobjects and what not.";
|
||||||
|
|
||||||
FramedOffsetClock localClock;
|
FramedClock localClock;
|
||||||
|
|
||||||
protected override IFrameBasedClock Clock => localClock;
|
protected override IFrameBasedClock Clock => localClock;
|
||||||
|
|
||||||
@ -32,9 +32,7 @@ namespace osu.Desktop.Tests
|
|||||||
base.Reset();
|
base.Reset();
|
||||||
|
|
||||||
//ensure we are at offset 0
|
//ensure we are at offset 0
|
||||||
if (localClock == null)
|
localClock = new FramedClock();
|
||||||
localClock = new FramedOffsetClock(base.Clock);
|
|
||||||
localClock.Offset = -base.Clock.CurrentTime;
|
|
||||||
|
|
||||||
List<HitObject> objects = new List<HitObject>();
|
List<HitObject> objects = new List<HitObject>();
|
||||||
|
|
||||||
|
43
osu.Game/Beatmaps/Objects/Catch/CatchConverter.cs
Normal file
43
osu.Game/Beatmaps/Objects/Catch/CatchConverter.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
//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.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using osu.Game.Beatmaps.Objects.Catch;
|
||||||
|
using osu.Game.Beatmaps.Objects.Osu;
|
||||||
|
|
||||||
|
namespace osu.Game.Beatmaps.Objects.Catch
|
||||||
|
{
|
||||||
|
class CatchConverter : HitObjectConverter<CatchBaseHit>
|
||||||
|
{
|
||||||
|
public override List<CatchBaseHit> Convert(List<HitObject> input)
|
||||||
|
{
|
||||||
|
List<CatchBaseHit> output = new List<CatchBaseHit>();
|
||||||
|
|
||||||
|
foreach (HitObject i in input)
|
||||||
|
{
|
||||||
|
CatchBaseHit h = i as CatchBaseHit;
|
||||||
|
|
||||||
|
if (h == null)
|
||||||
|
{
|
||||||
|
OsuBaseHit o = i as OsuBaseHit;
|
||||||
|
|
||||||
|
if (o == null) throw new Exception(@"Can't convert!");
|
||||||
|
|
||||||
|
h = new Fruit
|
||||||
|
{
|
||||||
|
StartTime = o.StartTime,
|
||||||
|
Position = o.Position.X,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
output.Add(h);
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
42
osu.Game/Beatmaps/Objects/Catch/Drawable/DrawableFruit.cs
Normal file
42
osu.Game/Beatmaps/Objects/Catch/Drawable/DrawableFruit.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
//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.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using osu.Framework;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.Transformations;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Beatmaps.Objects.Catch.Drawable
|
||||||
|
{
|
||||||
|
class DrawableFruit : Sprite
|
||||||
|
{
|
||||||
|
private CatchBaseHit h;
|
||||||
|
|
||||||
|
public DrawableFruit(CatchBaseHit h)
|
||||||
|
{
|
||||||
|
this.h = h;
|
||||||
|
|
||||||
|
Origin = Anchor.Centre;
|
||||||
|
Scale = new Vector2(0.1f);
|
||||||
|
RelativePositionAxes = Axes.Y;
|
||||||
|
Position = new Vector2(h.Position, -0.1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Load(BaseGame game)
|
||||||
|
{
|
||||||
|
base.Load(game);
|
||||||
|
|
||||||
|
Texture = game.Textures.Get(@"Menu/logo");
|
||||||
|
|
||||||
|
Transforms.Add(new TransformPosition(Clock) { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = new Vector2(h.Position, -0.1f), EndValue = new Vector2(h.Position, 0.9f) });
|
||||||
|
Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + h.Duration + 200, EndTime = h.StartTime + h.Duration + 400, StartValue = 1, EndValue = 0 });
|
||||||
|
Expire(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
13
osu.Game/Beatmaps/Objects/HitObjectConverter.cs
Normal file
13
osu.Game/Beatmaps/Objects/HitObjectConverter.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
//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.Collections.Generic;
|
||||||
|
|
||||||
|
namespace osu.Game.Beatmaps.Objects
|
||||||
|
{
|
||||||
|
public abstract class HitObjectConverter<T>
|
||||||
|
where T : HitObject
|
||||||
|
{
|
||||||
|
public abstract List<T> Convert(List<HitObject> input);
|
||||||
|
}
|
||||||
|
}
|
33
osu.Game/Beatmaps/Objects/Mania/Drawable/DrawableNote.cs
Normal file
33
osu.Game/Beatmaps/Objects/Mania/Drawable/DrawableNote.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.Transformations;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Beatmaps.Objects.Mania.Drawable
|
||||||
|
{
|
||||||
|
public class DrawableNote : Sprite
|
||||||
|
{
|
||||||
|
private readonly ManiaBaseHit note;
|
||||||
|
|
||||||
|
public DrawableNote(ManiaBaseHit note)
|
||||||
|
{
|
||||||
|
this.note = note;
|
||||||
|
Origin = Anchor.Centre;
|
||||||
|
Scale = new Vector2(0.1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Load(BaseGame game)
|
||||||
|
{
|
||||||
|
base.Load(game);
|
||||||
|
Texture = game.Textures.Get(@"Menu/logo");
|
||||||
|
|
||||||
|
Transforms.Add(new TransformPositionY(Clock) { StartTime = note.StartTime - 200, EndTime = note.StartTime, StartValue = -0.1f, EndValue = 0.9f });
|
||||||
|
Transforms.Add(new TransformAlpha(Clock) { StartTime = note.StartTime + note.Duration + 200, EndTime = note.StartTime + note.Duration + 400, StartValue = 1, EndValue = 0 });
|
||||||
|
Expire(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
46
osu.Game/Beatmaps/Objects/Mania/ManiaConverter.cs
Normal file
46
osu.Game/Beatmaps/Objects/Mania/ManiaConverter.cs
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
//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 osu.Game.Beatmaps.Objects.Osu;
|
||||||
|
|
||||||
|
namespace osu.Game.Beatmaps.Objects.Mania
|
||||||
|
{
|
||||||
|
class ManiaConverter : HitObjectConverter<ManiaBaseHit>
|
||||||
|
{
|
||||||
|
private readonly int columns;
|
||||||
|
|
||||||
|
public ManiaConverter(int columns)
|
||||||
|
{
|
||||||
|
this.columns = columns;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override List<ManiaBaseHit> Convert(List<HitObject> input)
|
||||||
|
{
|
||||||
|
List<ManiaBaseHit> output = new List<ManiaBaseHit>();
|
||||||
|
|
||||||
|
foreach (HitObject i in input)
|
||||||
|
{
|
||||||
|
ManiaBaseHit h = i as ManiaBaseHit;
|
||||||
|
|
||||||
|
if (h == null)
|
||||||
|
{
|
||||||
|
OsuBaseHit o = i as OsuBaseHit;
|
||||||
|
|
||||||
|
if (o == null) throw new Exception(@"Can't convert!");
|
||||||
|
|
||||||
|
h = new Note
|
||||||
|
{
|
||||||
|
StartTime = o.StartTime,
|
||||||
|
Column = (int)Math.Round(o.Position.X / 512 * columns)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
output.Add(h);
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
42
osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs
Normal file
42
osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
//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.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using osu.Framework;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.Transformations;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Beatmaps.Objects.Osu.Drawable
|
||||||
|
{
|
||||||
|
class DrawableCircle : Sprite
|
||||||
|
{
|
||||||
|
private OsuBaseHit h;
|
||||||
|
|
||||||
|
public DrawableCircle(OsuBaseHit h)
|
||||||
|
{
|
||||||
|
this.h = h;
|
||||||
|
|
||||||
|
Origin = Anchor.Centre;
|
||||||
|
Scale = new Vector2(0.1f);
|
||||||
|
Alpha = 0;
|
||||||
|
Position = h.Position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Load(BaseGame game)
|
||||||
|
{
|
||||||
|
base.Load(game);
|
||||||
|
|
||||||
|
Texture = game.Textures.Get(@"Menu/logo");
|
||||||
|
|
||||||
|
Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = 0, EndValue = 1 });
|
||||||
|
Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + h.Duration + 200, EndTime = h.StartTime + h.Duration + 400, StartValue = 1, EndValue = 0 });
|
||||||
|
Expire(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
21
osu.Game/Beatmaps/Objects/Osu/OsuConverter.cs
Normal file
21
osu.Game/Beatmaps/Objects/Osu/OsuConverter.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
//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;
|
||||||
|
|
||||||
|
namespace osu.Game.Beatmaps.Objects.Osu
|
||||||
|
{
|
||||||
|
class OsuConverter : HitObjectConverter<OsuBaseHit>
|
||||||
|
{
|
||||||
|
public override List<OsuBaseHit> Convert(List<HitObject> input)
|
||||||
|
{
|
||||||
|
List<OsuBaseHit> output = new List<OsuBaseHit>();
|
||||||
|
|
||||||
|
foreach (HitObject h in input)
|
||||||
|
output.Add(h as OsuBaseHit);
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
37
osu.Game/Beatmaps/Objects/Taiko/Drawable/DrawableTaikoHit.cs
Normal file
37
osu.Game/Beatmaps/Objects/Taiko/Drawable/DrawableTaikoHit.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.Transformations;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Beatmaps.Objects.Taiko.Drawable
|
||||||
|
{
|
||||||
|
class DrawableTaikoHit : Sprite
|
||||||
|
{
|
||||||
|
private TaikoBaseHit h;
|
||||||
|
|
||||||
|
public DrawableTaikoHit(TaikoBaseHit h)
|
||||||
|
{
|
||||||
|
this.h = h;
|
||||||
|
|
||||||
|
Origin = Anchor.Centre;
|
||||||
|
Scale = new Vector2(0.2f);
|
||||||
|
RelativePositionAxes = Axes.Both;
|
||||||
|
Position = new Vector2(1.1f, 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Load(BaseGame game)
|
||||||
|
{
|
||||||
|
base.Load(game);
|
||||||
|
|
||||||
|
Texture = game.Textures.Get(@"Menu/logo");
|
||||||
|
|
||||||
|
Transforms.Add(new TransformPositionX(Clock) { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = 1.1f, EndValue = 0.1f });
|
||||||
|
Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + h.Duration + 200, EndTime = h.StartTime + h.Duration + 400, StartValue = 1, EndValue = 0 });
|
||||||
|
Expire(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
namespace osu.Game.Beatmaps.Objects.Taiko
|
namespace osu.Game.Beatmaps.Objects.Taiko
|
||||||
{
|
{
|
||||||
class TaikoBaseHit : HitObject
|
public class TaikoBaseHit : HitObject
|
||||||
{
|
{
|
||||||
public float Scale = 1;
|
public float Scale = 1;
|
||||||
|
|
||||||
|
38
osu.Game/Beatmaps/Objects/Taiko/TaikoConverter.cs
Normal file
38
osu.Game/Beatmaps/Objects/Taiko/TaikoConverter.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
//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 osu.Game.Beatmaps.Objects.Osu;
|
||||||
|
|
||||||
|
namespace osu.Game.Beatmaps.Objects.Taiko
|
||||||
|
{
|
||||||
|
class TaikoConverter : HitObjectConverter<TaikoBaseHit>
|
||||||
|
{
|
||||||
|
public override List<TaikoBaseHit> Convert(List<HitObject> input)
|
||||||
|
{
|
||||||
|
List<TaikoBaseHit> output = new List<TaikoBaseHit>();
|
||||||
|
|
||||||
|
foreach (HitObject i in input)
|
||||||
|
{
|
||||||
|
TaikoBaseHit h = i as TaikoBaseHit;
|
||||||
|
|
||||||
|
if (h == null)
|
||||||
|
{
|
||||||
|
OsuBaseHit o = i as OsuBaseHit;
|
||||||
|
|
||||||
|
if (o == null) throw new Exception(@"Can't convert!");
|
||||||
|
|
||||||
|
h = new TaikoBaseHit
|
||||||
|
{
|
||||||
|
StartTime = o.StartTime,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
output.Add(h);
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,82 +1,20 @@
|
|||||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Transformations;
|
|
||||||
using osu.Game.Beatmaps.Objects;
|
using osu.Game.Beatmaps.Objects;
|
||||||
using osu.Game.Beatmaps.Objects.Osu;
|
|
||||||
using osu.Game.Beatmaps.Objects.Catch;
|
using osu.Game.Beatmaps.Objects.Catch;
|
||||||
using OpenTK;
|
using osu.Game.Beatmaps.Objects.Catch.Drawable;
|
||||||
using osu.Framework;
|
|
||||||
|
|
||||||
namespace osu.Game.GameModes.Play.Catch
|
namespace osu.Game.GameModes.Play.Catch
|
||||||
{
|
{
|
||||||
public class CatchHitRenderer : HitRenderer
|
public class CatchHitRenderer : HitRenderer<CatchBaseHit>
|
||||||
{
|
{
|
||||||
List<CatchBaseHit> objects;
|
protected override Playfield CreatePlayfield() => new CatchPlayfield();
|
||||||
private CatchPlayfield playfield;
|
|
||||||
|
|
||||||
public override List<HitObject> Objects
|
protected override List<CatchBaseHit> Convert(List<HitObject> objects) => new CatchConverter().Convert(objects);
|
||||||
{
|
|
||||||
set
|
protected override Drawable GetVisualRepresentation(CatchBaseHit h) => new DrawableFruit(h);
|
||||||
{
|
|
||||||
//osu! mode requires all objects to be of CatchBaseHit type.
|
|
||||||
objects = value.ConvertAll(convertForCatch);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private CatchBaseHit convertForCatch(HitObject input)
|
|
||||||
{
|
|
||||||
CatchBaseHit h = input as CatchBaseHit;
|
|
||||||
|
|
||||||
if (h == null)
|
|
||||||
{
|
|
||||||
OsuBaseHit o = input as OsuBaseHit;
|
|
||||||
|
|
||||||
if (o == null) throw new Exception(@"Can't convert!");
|
|
||||||
|
|
||||||
h = new Fruit()
|
|
||||||
{
|
|
||||||
StartTime = o.StartTime,
|
|
||||||
Position = o.Position.X
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Load(BaseGame game)
|
|
||||||
{
|
|
||||||
base.Load(game);
|
|
||||||
|
|
||||||
if (playfield == null)
|
|
||||||
Add(playfield = new CatchPlayfield());
|
|
||||||
else
|
|
||||||
playfield.Clear();
|
|
||||||
|
|
||||||
if (objects == null) return;
|
|
||||||
|
|
||||||
foreach (CatchBaseHit h in objects)
|
|
||||||
{
|
|
||||||
//render stuff!
|
|
||||||
Sprite s = new Sprite
|
|
||||||
{
|
|
||||||
Texture = game.Textures.Get(@"Menu/logo"),
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Scale = new Vector2(0.1f),
|
|
||||||
RelativePositionAxes = Axes.Y,
|
|
||||||
Position = new Vector2(h.Position, -0.1f)
|
|
||||||
};
|
|
||||||
|
|
||||||
s.Transforms.Add(new TransformPosition(Clock) { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = new Vector2(h.Position, -0.1f), EndValue = new Vector2(h.Position, 0.9f) });
|
|
||||||
s.Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + h.Duration + 200, EndTime = h.StartTime + h.Duration + 400, StartValue = 1, EndValue = 0 });
|
|
||||||
s.Expire(true);
|
|
||||||
|
|
||||||
playfield.Add(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,35 +3,53 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Batches;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Drawables;
|
|
||||||
using osu.Game.Beatmaps.Objects;
|
using osu.Game.Beatmaps.Objects;
|
||||||
using OpenTK;
|
|
||||||
using OpenTK.Graphics;
|
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
|
|
||||||
namespace osu.Game.GameModes.Play
|
namespace osu.Game.GameModes.Play
|
||||||
{
|
{
|
||||||
public abstract class HitRenderer : Container
|
public abstract class HitRenderer<T> : Container
|
||||||
{
|
{
|
||||||
public abstract List<HitObject> Objects { set; }
|
private List<T> objects;
|
||||||
|
|
||||||
public HitRenderer()
|
public List<HitObject> Objects
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
set
|
||||||
|
{
|
||||||
|
objects = Convert(value);
|
||||||
|
if (IsLoaded)
|
||||||
|
loadObjects();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Playfield playfield;
|
||||||
|
|
||||||
|
protected abstract Playfield CreatePlayfield();
|
||||||
|
|
||||||
|
protected abstract List<T> Convert(List<HitObject> objects);
|
||||||
|
|
||||||
public override void Load(BaseGame game)
|
public override void Load(BaseGame game)
|
||||||
{
|
{
|
||||||
base.Load(game);
|
base.Load(game);
|
||||||
|
|
||||||
Add(new Box()
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
playfield = CreatePlayfield()
|
||||||
Alpha = 0.8f,
|
};
|
||||||
Colour = new Color4(5, 5, 5, 255),
|
|
||||||
});
|
loadObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadObjects()
|
||||||
|
{
|
||||||
|
if (objects == null) return;
|
||||||
|
foreach (T h in objects)
|
||||||
|
playfield.Add(GetVisualRepresentation(h));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract Drawable GetVisualRepresentation(T h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,88 +1,39 @@
|
|||||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Transformations;
|
|
||||||
using osu.Game.Beatmaps.Objects;
|
using osu.Game.Beatmaps.Objects;
|
||||||
using osu.Game.Beatmaps.Objects.Osu;
|
|
||||||
using osu.Game.Beatmaps.Objects.Mania;
|
using osu.Game.Beatmaps.Objects.Mania;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using osu.Framework;
|
using osu.Game.Beatmaps.Objects.Mania.Drawable;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace osu.Game.GameModes.Play.Mania
|
namespace osu.Game.GameModes.Play.Mania
|
||||||
{
|
{
|
||||||
public class ManiaHitRenderer : HitRenderer
|
public class ManiaHitRenderer : HitRenderer<ManiaBaseHit>
|
||||||
{
|
{
|
||||||
private readonly int columns;
|
private readonly int columns;
|
||||||
List<ManiaBaseHit> objects;
|
|
||||||
private ManiaPlayfield playfield;
|
|
||||||
|
|
||||||
public ManiaHitRenderer(int columns = 5)
|
public ManiaHitRenderer(int columns = 5)
|
||||||
{
|
{
|
||||||
this.columns = columns;
|
this.columns = columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override List<HitObject> Objects
|
protected override List<ManiaBaseHit> Convert(List<HitObject> objects)
|
||||||
{
|
{
|
||||||
set
|
ManiaConverter converter = new ManiaConverter(columns);
|
||||||
{
|
return converter.Convert(objects);
|
||||||
//osu! mode requires all objects to be of ManiaBaseHit type.
|
|
||||||
objects = value.ConvertAll(convertForMania);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ManiaBaseHit convertForMania(HitObject input)
|
protected override Playfield CreatePlayfield() => new ManiaPlayfield(columns);
|
||||||
{
|
|
||||||
ManiaBaseHit h = input as ManiaBaseHit;
|
|
||||||
|
|
||||||
if (h == null)
|
protected override Drawable GetVisualRepresentation(ManiaBaseHit h)
|
||||||
{
|
{
|
||||||
OsuBaseHit o = input as OsuBaseHit;
|
return new DrawableNote(h)
|
||||||
|
|
||||||
if (o == null) throw new Exception(@"Can't convert!");
|
|
||||||
|
|
||||||
h = new Note()
|
|
||||||
{
|
{
|
||||||
StartTime = o.StartTime,
|
Position = new Vector2((float)(h.Column + 0.5) / columns, -0.1f),
|
||||||
Column = (int)Math.Round(o.Position.X / 512 * columns)
|
RelativePositionAxes = Axes.Both
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Load(BaseGame game)
|
|
||||||
{
|
|
||||||
base.Load(game);
|
|
||||||
|
|
||||||
if (playfield == null)
|
|
||||||
Add(playfield = new ManiaPlayfield(columns));
|
|
||||||
else
|
|
||||||
playfield.Clear();
|
|
||||||
|
|
||||||
if (objects == null) return;
|
|
||||||
|
|
||||||
foreach (ManiaBaseHit h in objects)
|
|
||||||
{
|
|
||||||
//render stuff!
|
|
||||||
Sprite s = new Sprite
|
|
||||||
{
|
|
||||||
Texture = game.Textures.Get(@"Menu/logo"),
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Scale = new Vector2(0.1f),
|
|
||||||
RelativePositionAxes = Axes.Both,
|
|
||||||
Position = new Vector2((float)(h.Column + 0.5) / columns, -0.1f)
|
|
||||||
};
|
|
||||||
|
|
||||||
s.Transforms.Add(new TransformPositionY(Clock) { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = -0.1f, EndValue = 0.9f });
|
|
||||||
s.Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + h.Duration + 200, EndTime = h.StartTime + h.Duration + 400, StartValue = 1, EndValue = 0 });
|
|
||||||
s.Expire(true);
|
|
||||||
|
|
||||||
playfield.Add(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,62 +2,19 @@
|
|||||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Transformations;
|
|
||||||
using osu.Game.Beatmaps.Objects;
|
using osu.Game.Beatmaps.Objects;
|
||||||
using osu.Game.Beatmaps.Objects.Osu;
|
using osu.Game.Beatmaps.Objects.Osu;
|
||||||
using OpenTK;
|
using osu.Game.Beatmaps.Objects.Osu.Drawable;
|
||||||
using System.Diagnostics;
|
|
||||||
using osu.Framework;
|
|
||||||
|
|
||||||
namespace osu.Game.GameModes.Play.Osu
|
namespace osu.Game.GameModes.Play.Osu
|
||||||
{
|
{
|
||||||
public class OsuHitRenderer : HitRenderer
|
public class OsuHitRenderer : HitRenderer<OsuBaseHit>
|
||||||
{
|
{
|
||||||
List<OsuBaseHit> objects;
|
protected override Playfield CreatePlayfield() => new OsuPlayfield();
|
||||||
private OsuPlayfield playfield;
|
|
||||||
|
|
||||||
public override List<HitObject> Objects
|
protected override List<OsuBaseHit> Convert(List<HitObject> objects) => new OsuConverter().Convert(objects);
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
Debug.Assert(objects == null);
|
|
||||||
|
|
||||||
//osu! mode requires all objects to be of OsuBaseHit type.
|
protected override Drawable GetVisualRepresentation(OsuBaseHit h) => new DrawableCircle(h);
|
||||||
objects = value.ConvertAll(o => (OsuBaseHit)o);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Load(BaseGame game)
|
|
||||||
{
|
|
||||||
base.Load(game);
|
|
||||||
|
|
||||||
if (playfield == null)
|
|
||||||
Add(playfield = new OsuPlayfield());
|
|
||||||
else
|
|
||||||
playfield.Clear();
|
|
||||||
|
|
||||||
if (objects == null) return;
|
|
||||||
|
|
||||||
foreach (OsuBaseHit h in objects)
|
|
||||||
{
|
|
||||||
//render stuff!
|
|
||||||
Sprite s = new Sprite
|
|
||||||
{
|
|
||||||
Texture = game.Textures.Get(@"Menu/logo"),
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Scale = new Vector2(0.1f),
|
|
||||||
Alpha = 0,
|
|
||||||
Position = h.Position
|
|
||||||
};
|
|
||||||
|
|
||||||
s.Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = 0, EndValue = 1 });
|
|
||||||
s.Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + h.Duration + 200, EndTime = h.StartTime + h.Duration + 400, StartValue = 1, EndValue = 0 });
|
|
||||||
s.Expire(true);
|
|
||||||
|
|
||||||
playfield.Add(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,81 +1,20 @@
|
|||||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Transformations;
|
|
||||||
using osu.Game.Beatmaps.Objects;
|
using osu.Game.Beatmaps.Objects;
|
||||||
using osu.Game.Beatmaps.Objects.Osu;
|
|
||||||
using osu.Game.Beatmaps.Objects.Taiko;
|
using osu.Game.Beatmaps.Objects.Taiko;
|
||||||
using OpenTK;
|
using osu.Game.Beatmaps.Objects.Taiko.Drawable;
|
||||||
using osu.Framework;
|
|
||||||
|
|
||||||
namespace osu.Game.GameModes.Play.Taiko
|
namespace osu.Game.GameModes.Play.Taiko
|
||||||
{
|
{
|
||||||
public class TaikoHitRenderer : HitRenderer
|
public class TaikoHitRenderer : HitRenderer<TaikoBaseHit>
|
||||||
{
|
{
|
||||||
List<TaikoBaseHit> objects;
|
protected override List<TaikoBaseHit> Convert(List<HitObject> objects) => new TaikoConverter().Convert(objects);
|
||||||
private TaikoPlayfield playfield;
|
|
||||||
|
|
||||||
public override List<HitObject> Objects
|
protected override Playfield CreatePlayfield() => new TaikoPlayfield();
|
||||||
{
|
|
||||||
set
|
protected override Drawable GetVisualRepresentation(TaikoBaseHit h) => new DrawableTaikoHit(h);
|
||||||
{
|
|
||||||
//osu! mode requires all objects to be of TaikoBaseHit type.
|
|
||||||
objects = value.ConvertAll(convertForTaiko);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private TaikoBaseHit convertForTaiko(HitObject input)
|
|
||||||
{
|
|
||||||
TaikoBaseHit h = input as TaikoBaseHit;
|
|
||||||
|
|
||||||
if (h == null)
|
|
||||||
{
|
|
||||||
OsuBaseHit o = input as OsuBaseHit;
|
|
||||||
|
|
||||||
if (o == null) throw new Exception(@"Can't convert!");
|
|
||||||
|
|
||||||
h = new TaikoBaseHit()
|
|
||||||
{
|
|
||||||
StartTime = o.StartTime
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Load(BaseGame game)
|
|
||||||
{
|
|
||||||
base.Load(game);
|
|
||||||
|
|
||||||
if (playfield == null)
|
|
||||||
Add(playfield = new TaikoPlayfield());
|
|
||||||
else
|
|
||||||
playfield.Clear();
|
|
||||||
|
|
||||||
if (objects == null) return;
|
|
||||||
|
|
||||||
foreach (TaikoBaseHit h in objects)
|
|
||||||
{
|
|
||||||
//render stuff!
|
|
||||||
Sprite s = new Sprite
|
|
||||||
{
|
|
||||||
Texture = game.Textures.Get(@"Menu/logo"),
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Scale = new Vector2(0.2f),
|
|
||||||
RelativePositionAxes = Axes.Both,
|
|
||||||
Position = new Vector2(1.1f, 0.5f)
|
|
||||||
};
|
|
||||||
|
|
||||||
s.Transforms.Add(new TransformPositionX(Clock) { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = 1.1f, EndValue = 0.1f });
|
|
||||||
s.Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + h.Duration + 200, EndTime = h.StartTime + h.Duration + 400, StartValue = 1, EndValue = 0 });
|
|
||||||
s.Expire(true);
|
|
||||||
|
|
||||||
playfield.Add(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -219,7 +219,10 @@ namespace osu.Game.Online.API
|
|||||||
{
|
{
|
||||||
//NotificationManager.ShowMessage($@"We just went {newState}!", newState == APIState.Online ? Color4.YellowGreen : Color4.OrangeRed, 5000);
|
//NotificationManager.ShowMessage($@"We just went {newState}!", newState == APIState.Online ? Color4.YellowGreen : Color4.OrangeRed, 5000);
|
||||||
log.Add($@"We just went {newState}!");
|
log.Add($@"We just went {newState}!");
|
||||||
|
Scheduler.Add(delegate
|
||||||
|
{
|
||||||
OnStateChange?.Invoke(oldState, newState);
|
OnStateChange?.Invoke(oldState, newState);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,18 +48,27 @@
|
|||||||
<Compile Include="Beatmaps\Beatmap.cs" />
|
<Compile Include="Beatmaps\Beatmap.cs" />
|
||||||
<Compile Include="Beatmaps\BeatmapSet.cs" />
|
<Compile Include="Beatmaps\BeatmapSet.cs" />
|
||||||
<Compile Include="Beatmaps\Metadata.cs" />
|
<Compile Include="Beatmaps\Metadata.cs" />
|
||||||
|
<Compile Include="Beatmaps\Objects\Catch\CatchConverter.cs" />
|
||||||
|
<Compile Include="Beatmaps\Objects\Catch\Drawable\DrawableFruit.cs" />
|
||||||
<Compile Include="Beatmaps\Objects\HitObject.cs" />
|
<Compile Include="Beatmaps\Objects\HitObject.cs" />
|
||||||
<Compile Include="Beatmaps\Objects\Catch\CatchBaseHit.cs" />
|
<Compile Include="Beatmaps\Objects\Catch\CatchBaseHit.cs" />
|
||||||
<Compile Include="Beatmaps\Objects\Catch\Droplet.cs" />
|
<Compile Include="Beatmaps\Objects\Catch\Droplet.cs" />
|
||||||
<Compile Include="Beatmaps\Objects\Catch\Fruit.cs" />
|
<Compile Include="Beatmaps\Objects\Catch\Fruit.cs" />
|
||||||
|
<Compile Include="Beatmaps\Objects\HitObjectConverter.cs" />
|
||||||
|
<Compile Include="Beatmaps\Objects\Mania\Drawable\DrawableNote.cs" />
|
||||||
<Compile Include="Beatmaps\Objects\Mania\HoldNote.cs" />
|
<Compile Include="Beatmaps\Objects\Mania\HoldNote.cs" />
|
||||||
<Compile Include="Beatmaps\Objects\Mania\ManiaBaseHit.cs" />
|
<Compile Include="Beatmaps\Objects\Mania\ManiaBaseHit.cs" />
|
||||||
|
<Compile Include="Beatmaps\Objects\Mania\ManiaConverter.cs" />
|
||||||
<Compile Include="Beatmaps\Objects\Mania\Note.cs" />
|
<Compile Include="Beatmaps\Objects\Mania\Note.cs" />
|
||||||
<Compile Include="Beatmaps\Objects\Osu\Circle.cs" />
|
<Compile Include="Beatmaps\Objects\Osu\Circle.cs" />
|
||||||
|
<Compile Include="Beatmaps\Objects\Osu\Drawable\DrawableCircle.cs" />
|
||||||
<Compile Include="Beatmaps\Objects\Osu\OsuBaseHit.cs" />
|
<Compile Include="Beatmaps\Objects\Osu\OsuBaseHit.cs" />
|
||||||
|
<Compile Include="Beatmaps\Objects\Osu\OsuConverter.cs" />
|
||||||
<Compile Include="Beatmaps\Objects\Osu\Slider.cs" />
|
<Compile Include="Beatmaps\Objects\Osu\Slider.cs" />
|
||||||
<Compile Include="Beatmaps\Objects\Osu\Spinner.cs" />
|
<Compile Include="Beatmaps\Objects\Osu\Spinner.cs" />
|
||||||
|
<Compile Include="Beatmaps\Objects\Taiko\Drawable\DrawableTaikoHit.cs" />
|
||||||
<Compile Include="Beatmaps\Objects\Taiko\TaikoBaseHit.cs" />
|
<Compile Include="Beatmaps\Objects\Taiko\TaikoBaseHit.cs" />
|
||||||
|
<Compile Include="Beatmaps\Objects\Taiko\TaikoConverter.cs" />
|
||||||
<Compile Include="Beatmaps\Samples\HitSampleInfo.cs" />
|
<Compile Include="Beatmaps\Samples\HitSampleInfo.cs" />
|
||||||
<Compile Include="Beatmaps\Samples\SampleBank.cs" />
|
<Compile Include="Beatmaps\Samples\SampleBank.cs" />
|
||||||
<Compile Include="Beatmaps\Samples\SampleInfo.cs" />
|
<Compile Include="Beatmaps\Samples\SampleInfo.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user