diff --git a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs new file mode 100644 index 0000000000..2786cecd44 --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs @@ -0,0 +1,95 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.GameModes.Testing; +using osu.Framework.Graphics; +using osu.Framework.MathUtils; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.Objects; +using osu.Game.Beatmaps.Objects.Osu; +using osu.Game.GameModes.Play.Catch; +using osu.Game.GameModes.Play.Mania; +using osu.Game.GameModes.Play.Osu; +using osu.Game.GameModes.Play.Taiko; +using System.Collections.Generic; +using osu.Framework.Timing; + +namespace osu.Desktop.Tests +{ + class TestCaseGamefield : TestCase + { + public override string Name => @"Gamefield"; + + public override string Description => @"Showing hitobjects and what not."; + + FramedOffsetClock localClock; + + protected override IFrameBasedClock Clock => localClock; + + public override void Reset() + { + base.Reset(); + + ///create a new clock offset to 0. + localClock = new FramedOffsetClock(base.Clock) { Offset = -base.Clock.CurrentTime }; + + List objects = new List(); + + int time = 500; + for (int i = 0; i < 100; i++) + { + objects.Add(new Circle() + { + StartTime = time, + Position = new Vector2(RNG.Next(0, 512), RNG.Next(0, 384)) + }); + + time += RNG.Next(50, 500); + } + + Beatmap beatmap = new Beatmap + { + HitObjects = objects + }; + + Add(new Drawable[] + { + new OsuHitRenderer + { + Objects = beatmap.HitObjects, + Scale = new Vector2(0.5f), + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft + }, + new TaikoHitRenderer + { + Objects = beatmap.HitObjects, + Scale = new Vector2(0.5f), + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight + }, + new CatchHitRenderer + { + Objects = beatmap.HitObjects, + Scale = new Vector2(0.5f), + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft + }, + new ManiaHitRenderer + { + Objects = beatmap.HitObjects, + Scale = new Vector2(0.5f), + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight + } + }); + } + + protected override void Update() + { + base.Update(); + localClock.ProcessFrame(); + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 2a43325c11..f27abf9cc7 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -150,6 +150,7 @@ + diff --git a/osu.Game/Beatmaps/Beatmap.cs b/osu.Game/Beatmaps/Beatmap.cs new file mode 100644 index 0000000000..2a6c976a5e --- /dev/null +++ b/osu.Game/Beatmaps/Beatmap.cs @@ -0,0 +1,20 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; +using osu.Game.Beatmaps.Objects; +using osu.Game.Beatmaps.Timing; +using osu.Game.Users; + +namespace osu.Game.Beatmaps +{ + public class Beatmap + { + public List HitObjects; + + public List ControlPoints; + + public string Difficulty; + public User Creator; + } +} \ No newline at end of file diff --git a/osu.Game/Beatmaps/BeatmapSet.cs b/osu.Game/Beatmaps/BeatmapSet.cs new file mode 100644 index 0000000000..0a9e3335ab --- /dev/null +++ b/osu.Game/Beatmaps/BeatmapSet.cs @@ -0,0 +1,20 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; +using osu.Game.Users; + +namespace osu.Game.Beatmaps +{ + /// + /// A beatmap set contains multiple beatmap (difficulties). + /// + public class BeatmapSet + { + public List Beatmaps { get; protected set; } + + public Metadata Metadata; + + public User Creator; + } +} diff --git a/osu.Game/Beatmaps/Metadata.cs b/osu.Game/Beatmaps/Metadata.cs new file mode 100644 index 0000000000..1fa8e2438c --- /dev/null +++ b/osu.Game/Beatmaps/Metadata.cs @@ -0,0 +1,11 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Beatmaps +{ + public class Metadata + { + public string Artist; + public string Title; + } +} \ No newline at end of file diff --git a/osu.Game/Beatmaps/Objects/Catch/CatchBaseHit.cs b/osu.Game/Beatmaps/Objects/Catch/CatchBaseHit.cs new file mode 100644 index 0000000000..590bd8f5b3 --- /dev/null +++ b/osu.Game/Beatmaps/Objects/Catch/CatchBaseHit.cs @@ -0,0 +1,10 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Beatmaps.Objects.Catch +{ + public abstract class CatchBaseHit : HitObject + { + public float Position; + } +} diff --git a/osu.Game/Beatmaps/Objects/Catch/Droplet.cs b/osu.Game/Beatmaps/Objects/Catch/Droplet.cs new file mode 100644 index 0000000000..fd7967315d --- /dev/null +++ b/osu.Game/Beatmaps/Objects/Catch/Droplet.cs @@ -0,0 +1,9 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Beatmaps.Objects.Catch +{ + public class Droplet : CatchBaseHit + { + } +} diff --git a/osu.Game/Beatmaps/Objects/Catch/Fruit.cs b/osu.Game/Beatmaps/Objects/Catch/Fruit.cs new file mode 100644 index 0000000000..9ef76de841 --- /dev/null +++ b/osu.Game/Beatmaps/Objects/Catch/Fruit.cs @@ -0,0 +1,9 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Beatmaps.Objects.Catch +{ + public class Fruit : CatchBaseHit + { + } +} diff --git a/osu.Game/Beatmaps/Objects/HitObject.cs b/osu.Game/Beatmaps/Objects/HitObject.cs new file mode 100644 index 0000000000..74636d0a6f --- /dev/null +++ b/osu.Game/Beatmaps/Objects/HitObject.cs @@ -0,0 +1,20 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Beatmaps.Samples; + +namespace osu.Game.Beatmaps.Objects +{ + /// + /// A hitobject describes a point in a beatmap + /// + public abstract class HitObject + { + public double StartTime; + public double? EndTime; + + public double Duration => (EndTime ?? StartTime) - StartTime; + + public HitSampleInfo Sample; + } +} diff --git a/osu.Game/Beatmaps/Objects/Mania/HoldNote.cs b/osu.Game/Beatmaps/Objects/Mania/HoldNote.cs new file mode 100644 index 0000000000..37e95d8df1 --- /dev/null +++ b/osu.Game/Beatmaps/Objects/Mania/HoldNote.cs @@ -0,0 +1,9 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Beatmaps.Objects.Mania +{ + public class HoldNote : Note + { + } +} diff --git a/osu.Game/Beatmaps/Objects/Mania/ManiaBaseHit.cs b/osu.Game/Beatmaps/Objects/Mania/ManiaBaseHit.cs new file mode 100644 index 0000000000..d3fe475c6f --- /dev/null +++ b/osu.Game/Beatmaps/Objects/Mania/ManiaBaseHit.cs @@ -0,0 +1,10 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Beatmaps.Objects.Mania +{ + public abstract class ManiaBaseHit : HitObject + { + public int Column; + } +} diff --git a/osu.Game/Beatmaps/Objects/Mania/Note.cs b/osu.Game/Beatmaps/Objects/Mania/Note.cs new file mode 100644 index 0000000000..d6e9b0e66c --- /dev/null +++ b/osu.Game/Beatmaps/Objects/Mania/Note.cs @@ -0,0 +1,9 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Beatmaps.Objects.Mania +{ + public class Note : ManiaBaseHit + { + } +} diff --git a/osu.Game/Beatmaps/Objects/Osu/Circle.cs b/osu.Game/Beatmaps/Objects/Osu/Circle.cs new file mode 100644 index 0000000000..81974949b0 --- /dev/null +++ b/osu.Game/Beatmaps/Objects/Osu/Circle.cs @@ -0,0 +1,9 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Beatmaps.Objects.Osu +{ + public class Circle : OsuBaseHit + { + } +} diff --git a/osu.Game/Beatmaps/Objects/Osu/OsuBaseHit.cs b/osu.Game/Beatmaps/Objects/Osu/OsuBaseHit.cs new file mode 100644 index 0000000000..8224bb7dc9 --- /dev/null +++ b/osu.Game/Beatmaps/Objects/Osu/OsuBaseHit.cs @@ -0,0 +1,12 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; + +namespace osu.Game.Beatmaps.Objects.Osu +{ + public abstract class OsuBaseHit : HitObject + { + public Vector2 Position; + } +} diff --git a/osu.Game/Beatmaps/Objects/Osu/Slider.cs b/osu.Game/Beatmaps/Objects/Osu/Slider.cs new file mode 100644 index 0000000000..fef9cd858c --- /dev/null +++ b/osu.Game/Beatmaps/Objects/Osu/Slider.cs @@ -0,0 +1,15 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; +using OpenTK; + +namespace osu.Game.Beatmaps.Objects.Osu +{ + public class Slider : OsuBaseHit + { + public List Path; + + public int RepeatCount; + } +} diff --git a/osu.Game/Beatmaps/Objects/Osu/Spinner.cs b/osu.Game/Beatmaps/Objects/Osu/Spinner.cs new file mode 100644 index 0000000000..8426e0b529 --- /dev/null +++ b/osu.Game/Beatmaps/Objects/Osu/Spinner.cs @@ -0,0 +1,9 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Beatmaps.Objects.Osu +{ + public class Spinner + { + } +} diff --git a/osu.Game/Beatmaps/Objects/Taiko/TaikoBaseHit.cs b/osu.Game/Beatmaps/Objects/Taiko/TaikoBaseHit.cs new file mode 100644 index 0000000000..ddd8375204 --- /dev/null +++ b/osu.Game/Beatmaps/Objects/Taiko/TaikoBaseHit.cs @@ -0,0 +1,18 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Beatmaps.Objects.Taiko +{ + class TaikoBaseHit : HitObject + { + public float Scale = 1; + + public TaikoColour Type; + } + + public enum TaikoColour + { + Red, + Blue + } +} diff --git a/osu.Game/Beatmaps/Samples/HitSampleInfo.cs b/osu.Game/Beatmaps/Samples/HitSampleInfo.cs new file mode 100644 index 0000000000..4083a528aa --- /dev/null +++ b/osu.Game/Beatmaps/Samples/HitSampleInfo.cs @@ -0,0 +1,10 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Beatmaps.Samples +{ + public class HitSampleInfo : SampleInfo + { + SampleType Type; + } +} diff --git a/osu.Game/Beatmaps/Samples/SampleBank.cs b/osu.Game/Beatmaps/Samples/SampleBank.cs new file mode 100644 index 0000000000..5284712549 --- /dev/null +++ b/osu.Game/Beatmaps/Samples/SampleBank.cs @@ -0,0 +1,12 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Beatmaps.Samples +{ + public enum SampleBank + { + Default = 0, + Custom1 = 1, + Custom2 = 2 + } +} \ No newline at end of file diff --git a/osu.Game/Beatmaps/Samples/SampleInfo.cs b/osu.Game/Beatmaps/Samples/SampleInfo.cs new file mode 100644 index 0000000000..0b595b3d74 --- /dev/null +++ b/osu.Game/Beatmaps/Samples/SampleInfo.cs @@ -0,0 +1,11 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Beatmaps.Samples +{ + public class SampleInfo + { + public SampleBank Bank; + public SampleSet Set; + } +} diff --git a/osu.Game/Beatmaps/Samples/SampleSet.cs b/osu.Game/Beatmaps/Samples/SampleSet.cs new file mode 100644 index 0000000000..db4d9a9f05 --- /dev/null +++ b/osu.Game/Beatmaps/Samples/SampleSet.cs @@ -0,0 +1,13 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Beatmaps.Samples +{ + public enum SampleSet + { + None = 0, + Normal = 1, + Soft = 2, + Drum = 3 + } +} \ No newline at end of file diff --git a/osu.Game/Beatmaps/Samples/SampleType.cs b/osu.Game/Beatmaps/Samples/SampleType.cs new file mode 100644 index 0000000000..43499b24e9 --- /dev/null +++ b/osu.Game/Beatmaps/Samples/SampleType.cs @@ -0,0 +1,17 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; + +namespace osu.Game.Beatmaps.Samples +{ + [Flags] + public enum SampleType + { + None = 0, + Normal = 1, + Whistle = 2, + Finish = 4, + Clap = 8 + }; +} \ No newline at end of file diff --git a/osu.Game/Beatmaps/Timing/ControlPoint.cs b/osu.Game/Beatmaps/Timing/ControlPoint.cs new file mode 100644 index 0000000000..89eac572ec --- /dev/null +++ b/osu.Game/Beatmaps/Timing/ControlPoint.cs @@ -0,0 +1,16 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//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; + +namespace osu.Game.Beatmaps.Timing +{ + public class ControlPoint + { + public double Time; + } +} diff --git a/osu.Game/Beatmaps/Timing/SampleChange.cs b/osu.Game/Beatmaps/Timing/SampleChange.cs new file mode 100644 index 0000000000..488d8f0a3b --- /dev/null +++ b/osu.Game/Beatmaps/Timing/SampleChange.cs @@ -0,0 +1,17 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//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.Samples; + +namespace osu.Game.Beatmaps.Timing +{ + class SampleChange : ControlPoint + { + public SampleInfo Sample; + } +} diff --git a/osu.Game/Beatmaps/Timing/TimingChange.cs b/osu.Game/Beatmaps/Timing/TimingChange.cs new file mode 100644 index 0000000000..dd2b9cdc7c --- /dev/null +++ b/osu.Game/Beatmaps/Timing/TimingChange.cs @@ -0,0 +1,18 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//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; + +namespace osu.Game.Beatmaps.Timing +{ + class TimingChange : ControlPoint + { + public double BeatLength; + + public double BPM => 60000 / BeatLength; + } +} diff --git a/osu.Game/GameModes/Play/Catch/CatchHitRenderer.cs b/osu.Game/GameModes/Play/Catch/CatchHitRenderer.cs new file mode 100644 index 0000000000..645354629f --- /dev/null +++ b/osu.Game/GameModes/Play/Catch/CatchHitRenderer.cs @@ -0,0 +1,84 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//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.Transformations; +using osu.Game.Beatmaps.Objects; +using osu.Game.Beatmaps.Objects.Osu; +using osu.Game.Beatmaps.Objects.Catch; +using OpenTK; + +namespace osu.Game.GameModes.Play.Catch +{ + public class CatchHitRenderer : HitRenderer + { + List objects; + private CatchPlayfield playfield; + + public override List Objects + { + set + { + //osu! mode requires all objects to be of CatchBaseHit type. + objects = value.ConvertAll(convertForCatch); + + if (Parent != null) + Load(); + } + } + + 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() + { + base.Load(); + + 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-osu"), + Origin = Anchor.Centre, + Scale = new Vector2(0.1f), + PositionMode = InheritMode.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); + } + } + } +} diff --git a/osu.Game/GameModes/Play/Catch/CatchPlayfield.cs b/osu.Game/GameModes/Play/Catch/CatchPlayfield.cs new file mode 100644 index 0000000000..5f148f7606 --- /dev/null +++ b/osu.Game/GameModes/Play/Catch/CatchPlayfield.cs @@ -0,0 +1,30 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Drawables; +using osu.Framework.Graphics.Sprites; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.GameModes.Play.Catch +{ + public class CatchPlayfield : Playfield + { + public CatchPlayfield() + { + SizeMode = InheritMode.Y; + Size = new Vector2(512, 0.9f); + Anchor = Anchor.BottomCentre; + Origin = Anchor.BottomCentre; + } + + public override void Load() + { + base.Load(); + + Add(new Box { SizeMode = InheritMode.XY, Alpha = 0.5f }); + } + } +} \ No newline at end of file diff --git a/osu.Game/GameModes/Play/HitRenderer.cs b/osu.Game/GameModes/Play/HitRenderer.cs new file mode 100644 index 0000000000..3268789a6a --- /dev/null +++ b/osu.Game/GameModes/Play/HitRenderer.cs @@ -0,0 +1,25 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Batches; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Drawables; +using osu.Game.Beatmaps.Objects; +using OpenTK; + +namespace osu.Game.GameModes.Play +{ + public abstract class HitRenderer : LargeContainer + { + public abstract List Objects { set; } + + public override void Load() + { + base.Load(); + + Add(new Box() { SizeMode = InheritMode.XY, Alpha = 0.1f, Scale = new Vector2(0.99f) }); + } + } +} diff --git a/osu.Game/GameModes/Play/Mania/ManiaHitRenderer.cs b/osu.Game/GameModes/Play/Mania/ManiaHitRenderer.cs new file mode 100644 index 0000000000..551d94d2b6 --- /dev/null +++ b/osu.Game/GameModes/Play/Mania/ManiaHitRenderer.cs @@ -0,0 +1,90 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//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.Transformations; +using osu.Game.Beatmaps.Objects; +using osu.Game.Beatmaps.Objects.Osu; +using osu.Game.Beatmaps.Objects.Mania; +using OpenTK; + +namespace osu.Game.GameModes.Play.Mania +{ + public class ManiaHitRenderer : HitRenderer + { + private readonly int columns; + List objects; + private ManiaPlayfield playfield; + + public ManiaHitRenderer(int columns = 5) + { + this.columns = columns; + } + + public override List Objects + { + set + { + //osu! mode requires all objects to be of ManiaBaseHit type. + objects = value.ConvertAll(convertForMania); + + if (Parent != null) + Load(); + } + } + + private ManiaBaseHit convertForMania(HitObject input) + { + ManiaBaseHit h = input as ManiaBaseHit; + + if (h == null) + { + OsuBaseHit o = input 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) + }; + } + + return h; + } + + public override void Load() + { + base.Load(); + + 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-osu"), + Origin = Anchor.Centre, + Scale = new Vector2(0.1f), + PositionMode = InheritMode.XY, + 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); + } + } + } +} diff --git a/osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs b/osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs new file mode 100644 index 0000000000..81639e237f --- /dev/null +++ b/osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs @@ -0,0 +1,44 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Drawables; +using osu.Framework.Graphics.Sprites; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.GameModes.Play.Mania +{ + public class ManiaPlayfield : Playfield + { + private readonly int columns; + + public ManiaPlayfield(int columns) + { + this.columns = columns; + SizeMode = InheritMode.XY; + Size = new Vector2(columns / 20f, 1f); + Anchor = Anchor.BottomCentre; + Origin = Anchor.BottomCentre; + } + + public override void Load() + { + base.Load(); + + Add(new Box() { SizeMode = InheritMode.XY, Alpha = 0.5f }); + + for (int i = 0; i < columns; i++) + Add(new Box() + { + SizeMode = InheritMode.Y, + Size = new Vector2(2, 1), + PositionMode = InheritMode.XY, + Position = new Vector2((float)i / columns, 0), + Alpha = 0.5f, + Colour = Color4.Black + }); + } + } +} \ No newline at end of file diff --git a/osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs b/osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs new file mode 100644 index 0000000000..8dd49807c0 --- /dev/null +++ b/osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs @@ -0,0 +1,62 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Transformations; +using osu.Game.Beatmaps.Objects; +using osu.Game.Beatmaps.Objects.Osu; +using OpenTK; + +namespace osu.Game.GameModes.Play.Osu +{ + public class OsuHitRenderer : HitRenderer + { + List objects; + private OsuPlayfield playfield; + + public override List Objects + { + set + { + //osu! mode requires all objects to be of OsuBaseHit type. + objects = value.ConvertAll(o => (OsuBaseHit)o); + + if (Parent != null) + Load(); + } + } + + public override void Load() + { + base.Load(); + + 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-osu"), + 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); + } + } + } +} diff --git a/osu.Game/GameModes/Play/Osu/OsuPlayfield.cs b/osu.Game/GameModes/Play/Osu/OsuPlayfield.cs new file mode 100644 index 0000000000..4deb012a09 --- /dev/null +++ b/osu.Game/GameModes/Play/Osu/OsuPlayfield.cs @@ -0,0 +1,34 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Drawables; +using OpenTK; + +namespace osu.Game.GameModes.Play.Osu +{ + public class OsuPlayfield : Playfield + { + public OsuPlayfield() + { + SizeMode = InheritMode.None; + Size = new Vector2(512, 384); + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + } + + public override void Load() + { + base.Load(); + + Add(new Box() + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + SizeMode = InheritMode.XY, + Alpha = 0.5f + }); + } + } +} \ No newline at end of file diff --git a/osu.Game/GameModes/Play/Playfield.cs b/osu.Game/GameModes/Play/Playfield.cs new file mode 100644 index 0000000000..41a73472d8 --- /dev/null +++ b/osu.Game/GameModes/Play/Playfield.cs @@ -0,0 +1,17 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics.Containers; + +namespace osu.Game.GameModes.Play +{ + public class Playfield : Container + { + public override void Load() + { + base.Load(); + + Masking = true; + } + } +} diff --git a/osu.Game/GameModes/Play/Taiko/TaikoHitRenderer.cs b/osu.Game/GameModes/Play/Taiko/TaikoHitRenderer.cs new file mode 100644 index 0000000000..e1d3b2e5aa --- /dev/null +++ b/osu.Game/GameModes/Play/Taiko/TaikoHitRenderer.cs @@ -0,0 +1,83 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//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.Transformations; +using osu.Game.Beatmaps.Objects; +using osu.Game.Beatmaps.Objects.Osu; +using osu.Game.Beatmaps.Objects.Taiko; +using OpenTK; + +namespace osu.Game.GameModes.Play.Taiko +{ + public class TaikoHitRenderer : HitRenderer + { + List objects; + private TaikoPlayfield playfield; + + public override List Objects + { + set + { + //osu! mode requires all objects to be of TaikoBaseHit type. + objects = value.ConvertAll(convertForTaiko); + + if (Parent != null) + Load(); + } + } + + 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() + { + base.Load(); + + 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-osu"), + Origin = Anchor.Centre, + Scale = new Vector2(0.2f), + PositionMode = InheritMode.XY, + 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); + } + } + } +} diff --git a/osu.Game/GameModes/Play/Taiko/TaikoPlayfield.cs b/osu.Game/GameModes/Play/Taiko/TaikoPlayfield.cs new file mode 100644 index 0000000000..03c33c2c9b --- /dev/null +++ b/osu.Game/GameModes/Play/Taiko/TaikoPlayfield.cs @@ -0,0 +1,40 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Drawables; +using osu.Framework.Graphics.Sprites; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.GameModes.Play.Taiko +{ + public class TaikoPlayfield : Playfield + { + public TaikoPlayfield() + { + SizeMode = InheritMode.X; + Size = new Vector2(1, 100); + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + } + + public override void Load() + { + base.Load(); + + Add(new Box { SizeMode = InheritMode.XY, Alpha = 0.5f }); + + Add(new Sprite + { + Texture = Game.Textures.Get(@"menu-osu"), + Origin = Anchor.Centre, + Scale = new Vector2(0.2f), + PositionMode = InheritMode.XY, + Position = new Vector2(0.1f, 0.5f), + Colour = Color4.Gray + }); + } + } +} \ No newline at end of file diff --git a/osu.Game/Graphics/Components/FpsDisplay.cs b/osu.Game/Graphics/Components/FpsDisplay.cs new file mode 100644 index 0000000000..c2e5d75059 --- /dev/null +++ b/osu.Game/Graphics/Components/FpsDisplay.cs @@ -0,0 +1,28 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics.Containers; + +namespace osu.Game.Graphics.Components +{ + class FpsDisplay : OsuComponent + { + SpriteText fpsText; + public override void Load() + { + base.Load(); + + Add(fpsText = new SpriteText()); + + fpsText.Text = "..."; + } + + protected override void Update() + { + fpsText.Text = ((int)(1000 / Clock.ElapsedFrameTime)).ToString(); + base.Update(); + } + } +} diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 22c8e079a4..65e200ea55 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -6,6 +6,7 @@ using osu.Game.GameModes.Menu; using OpenTK; using osu.Framework.Graphics; using osu.Framework.OS; +using osu.Game.GameModes.Play; namespace osu.Game { diff --git a/osu.Game/Users/User.cs b/osu.Game/Users/User.cs new file mode 100644 index 0000000000..33f9e65d51 --- /dev/null +++ b/osu.Game/Users/User.cs @@ -0,0 +1,17 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//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; + +namespace osu.Game.Users +{ + public class User + { + public int Id; + public string Username; + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 2b3c2fd30f..888350f780 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -45,9 +45,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -70,6 +103,7 @@ +