diff --git a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs index 085100acf9..316a099e38 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs @@ -23,7 +23,7 @@ namespace osu.Desktop.Tests public override string Description => @"Showing hitobjects and what not."; - FramedOffsetClock localClock; + FramedClock localClock; protected override IFrameBasedClock Clock => localClock; @@ -32,9 +32,7 @@ namespace osu.Desktop.Tests base.Reset(); //ensure we are at offset 0 - if (localClock == null) - localClock = new FramedOffsetClock(base.Clock); - localClock.Offset = -base.Clock.CurrentTime; + localClock = new FramedClock(); List objects = new List(); diff --git a/osu.Game/Beatmaps/Objects/Catch/CatchConverter.cs b/osu.Game/Beatmaps/Objects/Catch/CatchConverter.cs new file mode 100644 index 0000000000..dbd97e90bc --- /dev/null +++ b/osu.Game/Beatmaps/Objects/Catch/CatchConverter.cs @@ -0,0 +1,43 @@ +//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.Objects.Catch; +using osu.Game.Beatmaps.Objects.Osu; + +namespace osu.Game.Beatmaps.Objects.Catch +{ + class CatchConverter : HitObjectConverter + { + public override List Convert(List input) + { + List output = new List(); + + 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; + } + } +} diff --git a/osu.Game/Beatmaps/Objects/Catch/Drawable/DrawableFruit.cs b/osu.Game/Beatmaps/Objects/Catch/Drawable/DrawableFruit.cs new file mode 100644 index 0000000000..028afff5cc --- /dev/null +++ b/osu.Game/Beatmaps/Objects/Catch/Drawable/DrawableFruit.cs @@ -0,0 +1,42 @@ +//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.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); + } + } +} diff --git a/osu.Game/Beatmaps/Objects/HitObjectConverter.cs b/osu.Game/Beatmaps/Objects/HitObjectConverter.cs new file mode 100644 index 0000000000..a70526e85a --- /dev/null +++ b/osu.Game/Beatmaps/Objects/HitObjectConverter.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 + +using System.Collections.Generic; + +namespace osu.Game.Beatmaps.Objects +{ + public abstract class HitObjectConverter + where T : HitObject + { + public abstract List Convert(List input); + } +} diff --git a/osu.Game/Beatmaps/Objects/Mania/Drawable/DrawableNote.cs b/osu.Game/Beatmaps/Objects/Mania/Drawable/DrawableNote.cs new file mode 100644 index 0000000000..132fb6ce36 --- /dev/null +++ b/osu.Game/Beatmaps/Objects/Mania/Drawable/DrawableNote.cs @@ -0,0 +1,33 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//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); + } + } +} diff --git a/osu.Game/Beatmaps/Objects/Mania/ManiaConverter.cs b/osu.Game/Beatmaps/Objects/Mania/ManiaConverter.cs new file mode 100644 index 0000000000..22d8f9ae9c --- /dev/null +++ b/osu.Game/Beatmaps/Objects/Mania/ManiaConverter.cs @@ -0,0 +1,46 @@ +//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.Game.Beatmaps.Objects.Osu; + +namespace osu.Game.Beatmaps.Objects.Mania +{ + class ManiaConverter : HitObjectConverter + { + private readonly int columns; + + public ManiaConverter(int columns) + { + this.columns = columns; + } + + public override List Convert(List input) + { + List output = new List(); + + 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; + } + } +} diff --git a/osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs b/osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs new file mode 100644 index 0000000000..f4297970e8 --- /dev/null +++ b/osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs @@ -0,0 +1,42 @@ +//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.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); + } + } +} diff --git a/osu.Game/Beatmaps/Objects/Osu/OsuConverter.cs b/osu.Game/Beatmaps/Objects/Osu/OsuConverter.cs new file mode 100644 index 0000000000..5629fccd5c --- /dev/null +++ b/osu.Game/Beatmaps/Objects/Osu/OsuConverter.cs @@ -0,0 +1,21 @@ +//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; + +namespace osu.Game.Beatmaps.Objects.Osu +{ + class OsuConverter : HitObjectConverter + { + public override List Convert(List input) + { + List output = new List(); + + foreach (HitObject h in input) + output.Add(h as OsuBaseHit); + + return output; + } + } +} diff --git a/osu.Game/Beatmaps/Objects/Taiko/Drawable/DrawableTaikoHit.cs b/osu.Game/Beatmaps/Objects/Taiko/Drawable/DrawableTaikoHit.cs new file mode 100644 index 0000000000..dafbe33415 --- /dev/null +++ b/osu.Game/Beatmaps/Objects/Taiko/Drawable/DrawableTaikoHit.cs @@ -0,0 +1,37 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//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); + } + } +} diff --git a/osu.Game/Beatmaps/Objects/Taiko/TaikoBaseHit.cs b/osu.Game/Beatmaps/Objects/Taiko/TaikoBaseHit.cs index ddd8375204..6b8f241306 100644 --- a/osu.Game/Beatmaps/Objects/Taiko/TaikoBaseHit.cs +++ b/osu.Game/Beatmaps/Objects/Taiko/TaikoBaseHit.cs @@ -3,7 +3,7 @@ namespace osu.Game.Beatmaps.Objects.Taiko { - class TaikoBaseHit : HitObject + public class TaikoBaseHit : HitObject { public float Scale = 1; diff --git a/osu.Game/Beatmaps/Objects/Taiko/TaikoConverter.cs b/osu.Game/Beatmaps/Objects/Taiko/TaikoConverter.cs new file mode 100644 index 0000000000..3189a0dec7 --- /dev/null +++ b/osu.Game/Beatmaps/Objects/Taiko/TaikoConverter.cs @@ -0,0 +1,38 @@ +//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.Game.Beatmaps.Objects.Osu; + +namespace osu.Game.Beatmaps.Objects.Taiko +{ + class TaikoConverter : HitObjectConverter + { + public override List Convert(List input) + { + List output = new List(); + + 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; + } + } +} diff --git a/osu.Game/GameModes/Play/Catch/CatchHitRenderer.cs b/osu.Game/GameModes/Play/Catch/CatchHitRenderer.cs index d6543360fc..d8e5aaaa35 100644 --- a/osu.Game/GameModes/Play/Catch/CatchHitRenderer.cs +++ b/osu.Game/GameModes/Play/Catch/CatchHitRenderer.cs @@ -1,82 +1,20 @@ //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; -using osu.Framework; +using osu.Game.Beatmaps.Objects.Catch.Drawable; namespace osu.Game.GameModes.Play.Catch { - public class CatchHitRenderer : HitRenderer + public class CatchHitRenderer : HitRenderer { - List objects; - private CatchPlayfield playfield; + protected override Playfield CreatePlayfield() => new CatchPlayfield(); - public override List Objects - { - set - { - //osu! mode requires all objects to be of CatchBaseHit type. - objects = value.ConvertAll(convertForCatch); - } - } + protected override List Convert(List objects) => new CatchConverter().Convert(objects); - 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); - } - } + protected override Drawable GetVisualRepresentation(CatchBaseHit h) => new DrawableFruit(h); } } diff --git a/osu.Game/GameModes/Play/HitRenderer.cs b/osu.Game/GameModes/Play/HitRenderer.cs index 06d98da836..b18d9ebb6d 100644 --- a/osu.Game/GameModes/Play/HitRenderer.cs +++ b/osu.Game/GameModes/Play/HitRenderer.cs @@ -3,35 +3,53 @@ 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; -using OpenTK.Graphics; using osu.Framework; namespace osu.Game.GameModes.Play { - public abstract class HitRenderer : Container + public abstract class HitRenderer : Container { - public abstract List Objects { set; } + private List objects; - public HitRenderer() + public List Objects { - RelativeSizeAxes = Axes.Both; + set + { + objects = Convert(value); + if (IsLoaded) + loadObjects(); + } } + private Playfield playfield; + + protected abstract Playfield CreatePlayfield(); + + protected abstract List Convert(List objects); + public override void Load(BaseGame game) { base.Load(game); - Add(new Box() + RelativeSizeAxes = Axes.Both; + + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - Alpha = 0.8f, - Colour = new Color4(5, 5, 5, 255), - }); + playfield = CreatePlayfield() + }; + + loadObjects(); } + + private void loadObjects() + { + if (objects == null) return; + foreach (T h in objects) + playfield.Add(GetVisualRepresentation(h)); + } + + protected abstract Drawable GetVisualRepresentation(T h); } } diff --git a/osu.Game/GameModes/Play/Mania/ManiaHitRenderer.cs b/osu.Game/GameModes/Play/Mania/ManiaHitRenderer.cs index 1e55e552d3..302f40878b 100644 --- a/osu.Game/GameModes/Play/Mania/ManiaHitRenderer.cs +++ b/osu.Game/GameModes/Play/Mania/ManiaHitRenderer.cs @@ -1,88 +1,39 @@ //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; -using osu.Framework; +using osu.Game.Beatmaps.Objects.Mania.Drawable; +using System.Collections.Generic; namespace osu.Game.GameModes.Play.Mania { - public class ManiaHitRenderer : HitRenderer + 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 + protected override List Convert(List objects) { - set - { - //osu! mode requires all objects to be of ManiaBaseHit type. - objects = value.ConvertAll(convertForMania); - } + ManiaConverter converter = new ManiaConverter(columns); + return converter.Convert(objects); } - private ManiaBaseHit convertForMania(HitObject input) + protected override Playfield CreatePlayfield() => new ManiaPlayfield(columns); + + protected override Drawable GetVisualRepresentation(ManiaBaseHit h) { - ManiaBaseHit h = input as ManiaBaseHit; - - if (h == null) + return new DrawableNote(h) { - 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(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); - } + Position = new Vector2((float)(h.Column + 0.5) / columns, -0.1f), + RelativePositionAxes = Axes.Both + }; } } } diff --git a/osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs b/osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs index c95eca8077..130d6d212f 100644 --- a/osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs +++ b/osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs @@ -2,62 +2,19 @@ //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; -using System.Diagnostics; -using osu.Framework; +using osu.Game.Beatmaps.Objects.Osu.Drawable; namespace osu.Game.GameModes.Play.Osu { - public class OsuHitRenderer : HitRenderer + public class OsuHitRenderer : HitRenderer { - List objects; - private OsuPlayfield playfield; + protected override Playfield CreatePlayfield() => new OsuPlayfield(); - public override List Objects - { - set - { - Debug.Assert(objects == null); + protected override List Convert(List objects) => new OsuConverter().Convert(objects); - //osu! mode requires all objects to be of OsuBaseHit type. - 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); - } - } + protected override Drawable GetVisualRepresentation(OsuBaseHit h) => new DrawableCircle(h); } } diff --git a/osu.Game/GameModes/Play/Taiko/TaikoHitRenderer.cs b/osu.Game/GameModes/Play/Taiko/TaikoHitRenderer.cs index 2874c62fca..9fab5998f5 100644 --- a/osu.Game/GameModes/Play/Taiko/TaikoHitRenderer.cs +++ b/osu.Game/GameModes/Play/Taiko/TaikoHitRenderer.cs @@ -1,81 +1,20 @@ //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; -using osu.Framework; +using osu.Game.Beatmaps.Objects.Taiko.Drawable; namespace osu.Game.GameModes.Play.Taiko { - public class TaikoHitRenderer : HitRenderer + public class TaikoHitRenderer : HitRenderer { - List objects; - private TaikoPlayfield playfield; + protected override List Convert(List objects) => new TaikoConverter().Convert(objects); - public override List Objects - { - set - { - //osu! mode requires all objects to be of TaikoBaseHit type. - objects = value.ConvertAll(convertForTaiko); - } - } + protected override Playfield CreatePlayfield() => new TaikoPlayfield(); - 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); - } - } + protected override Drawable GetVisualRepresentation(TaikoBaseHit h) => new DrawableTaikoHit(h); } -} +} \ No newline at end of file diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index bb72bdf02e..a7b2239355 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -219,7 +219,10 @@ namespace osu.Game.Online.API { //NotificationManager.ShowMessage($@"We just went {newState}!", newState == APIState.Online ? Color4.YellowGreen : Color4.OrangeRed, 5000); log.Add($@"We just went {newState}!"); - OnStateChange?.Invoke(oldState, newState); + Scheduler.Add(delegate + { + OnStateChange?.Invoke(oldState, newState); + }); } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index bdb852c33f..ca38e48f8b 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -48,18 +48,27 @@ + + + + + + + + +