From 8707c7f746ace3c93d0bf19958a56a6ea5069854 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Oct 2016 03:06:06 +0900 Subject: [PATCH 1/4] Fix regression causing multi-line (wrapped) chat messages to overlap. --- osu.Game/Online/Chat/Display/ChatLine.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/Chat/Display/ChatLine.cs b/osu.Game/Online/Chat/Display/ChatLine.cs index a827f411bf..5032ff0b9f 100644 --- a/osu.Game/Online/Chat/Display/ChatLine.cs +++ b/osu.Game/Online/Chat/Display/ChatLine.cs @@ -56,7 +56,7 @@ namespace osu.Game.Online.Chat.Display } } }, - new Container + new AutoSizeContainer { RelativeSizeAxes = Axes.X, Padding = new MarginPadding { Left = padding + 10 }, From 2566d6bfe019e7dda928e5975c931a6d2f010638 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Oct 2016 10:10:15 +0900 Subject: [PATCH 2/4] Fix regressions with HitRenderers, while also cleaning them up. --- .../Tests/TestCaseGamefield.cs | 6 +- .../Beatmaps/Objects/Catch/CatchConverter.cs | 43 +++++++++++ .../Objects/Catch/Drawable/DrawableFruit.cs | 42 +++++++++++ .../Beatmaps/Objects/HitObjectConverter.cs | 13 ++++ .../Objects/Mania/Drawable/DrawableNote.cs | 33 ++++++++ .../Beatmaps/Objects/Mania/ManiaConverter.cs | 46 ++++++++++++ .../Objects/Osu/Drawable/DrawableCircle.cs | 42 +++++++++++ osu.Game/Beatmaps/Objects/Osu/OsuConverter.cs | 21 ++++++ .../Taiko/Drawable/DrawableTaikoHit.cs | 37 +++++++++ .../Beatmaps/Objects/Taiko/TaikoBaseHit.cs | 2 +- .../Beatmaps/Objects/Taiko/TaikoConverter.cs | 38 ++++++++++ .../GameModes/Play/Catch/CatchHitRenderer.cs | 72 ++---------------- osu.Game/GameModes/Play/HitRenderer.cs | 44 +++++++---- .../GameModes/Play/Mania/ManiaHitRenderer.cs | 75 ++++--------------- osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs | 53 ++----------- .../GameModes/Play/Taiko/TaikoHitRenderer.cs | 73 ++---------------- osu.Game/Online/API/APIAccess.cs | 5 +- osu.Game/osu.Game.csproj | 9 +++ 18 files changed, 391 insertions(+), 263 deletions(-) create mode 100644 osu.Game/Beatmaps/Objects/Catch/CatchConverter.cs create mode 100644 osu.Game/Beatmaps/Objects/Catch/Drawable/DrawableFruit.cs create mode 100644 osu.Game/Beatmaps/Objects/HitObjectConverter.cs create mode 100644 osu.Game/Beatmaps/Objects/Mania/Drawable/DrawableNote.cs create mode 100644 osu.Game/Beatmaps/Objects/Mania/ManiaConverter.cs create mode 100644 osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs create mode 100644 osu.Game/Beatmaps/Objects/Osu/OsuConverter.cs create mode 100644 osu.Game/Beatmaps/Objects/Taiko/Drawable/DrawableTaikoHit.cs create mode 100644 osu.Game/Beatmaps/Objects/Taiko/TaikoConverter.cs 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 @@ + + + + + + + + + From 1a9dede98ce8e6314dbba6f28a6af975e6b203ae Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Oct 2016 14:27:31 +0900 Subject: [PATCH 3/4] Remove unused Deploy build configuration. --- osu.sln | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/osu.sln b/osu.sln index 8fba171a2f..3d79d4444f 100644 --- a/osu.sln +++ b/osu.sln @@ -24,45 +24,35 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Deploy|Any CPU = Deploy|Any CPU Release|Any CPU = Release|Any CPU - Deploy|Any CPU = Deploy|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Release|Any CPU.ActiveCfg = Release|Any CPU {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Release|Any CPU.Build.0 = Release|Any CPU {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Release|Any CPU.ActiveCfg = Release|Any CPU {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Release|Any CPU.Build.0 = Release|Any CPU {0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU {0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Release|Any CPU.ActiveCfg = Release|Any CPU {0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Release|Any CPU.Build.0 = Release|Any CPU {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Release|Any CPU.ActiveCfg = Release|Any CPU {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Release|Any CPU.Build.0 = Release|Any CPU {65DC628F-A640-4111-AB35-3A5652BC1E17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {65DC628F-A640-4111-AB35-3A5652BC1E17}.Debug|Any CPU.Build.0 = Debug|Any CPU - {65DC628F-A640-4111-AB35-3A5652BC1E17}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU {65DC628F-A640-4111-AB35-3A5652BC1E17}.Release|Any CPU.ActiveCfg = Release|Any CPU {65DC628F-A640-4111-AB35-3A5652BC1E17}.Release|Any CPU.Build.0 = Release|Any CPU {69051C69-12AE-4E7D-A3E6-460D2E282312}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {69051C69-12AE-4E7D-A3E6-460D2E282312}.Debug|Any CPU.Build.0 = Debug|Any CPU - {69051C69-12AE-4E7D-A3E6-460D2E282312}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU {69051C69-12AE-4E7D-A3E6-460D2E282312}.Release|Any CPU.ActiveCfg = Release|Any CPU {69051C69-12AE-4E7D-A3E6-460D2E282312}.Release|Any CPU.Build.0 = Release|Any CPU {54377672-20B1-40AF-8087-5CF73BF3953A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {54377672-20B1-40AF-8087-5CF73BF3953A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {54377672-20B1-40AF-8087-5CF73BF3953A}.Deploy|Any CPU.ActiveCfg = Release|Any CPU - {54377672-20B1-40AF-8087-5CF73BF3953A}.Deploy|Any CPU.Build.0 = Release|Any CPU {54377672-20B1-40AF-8087-5CF73BF3953A}.Release|Any CPU.ActiveCfg = Release|Any CPU {54377672-20B1-40AF-8087-5CF73BF3953A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection From 5e3e949fd6571ea671d8efe84bcaaa1851a9c55f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Oct 2016 14:45:41 +0900 Subject: [PATCH 4/4] Revert all counter commits. Requires much further review. --- .../Tests/TestCaseScoreCounter.cs | 159 ------------ .../osu.Desktop.VisualTests.csproj | 1 - .../Graphics/UserInterface/AccuracyCounter.cs | 102 -------- .../UserInterface/AlternativeComboCounter.cs | 91 ------- .../UserInterface/CatchComboCounter.cs | 60 ----- .../UserInterface/NumericRollingCounter.cs | 65 ----- .../Graphics/UserInterface/RollingCounter.cs | 241 ------------------ .../Graphics/UserInterface/ScoreCounter.cs | 32 --- .../UserInterface/StandardComboCounter.cs | 110 -------- .../Graphics/UserInterface/StarCounter.cs | 205 --------------- .../Graphics/UserInterface/ULongCounter.cs | 59 ----- osu.Game/osu.Game.csproj | 18 +- 12 files changed, 2 insertions(+), 1141 deletions(-) delete mode 100644 osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs delete mode 100644 osu.Game/Graphics/UserInterface/AccuracyCounter.cs delete mode 100644 osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs delete mode 100644 osu.Game/Graphics/UserInterface/CatchComboCounter.cs delete mode 100644 osu.Game/Graphics/UserInterface/NumericRollingCounter.cs delete mode 100644 osu.Game/Graphics/UserInterface/RollingCounter.cs delete mode 100644 osu.Game/Graphics/UserInterface/ScoreCounter.cs delete mode 100644 osu.Game/Graphics/UserInterface/StandardComboCounter.cs delete mode 100644 osu.Game/Graphics/UserInterface/StarCounter.cs delete mode 100644 osu.Game/Graphics/UserInterface/ULongCounter.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs deleted file mode 100644 index 144adf9098..0000000000 --- a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs +++ /dev/null @@ -1,159 +0,0 @@ -//Copyright (c) 2007-2016 ppy Pty Ltd . -//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using OpenTK.Input; -using osu.Framework.GameModes.Testing; -using osu.Framework.Graphics; -using osu.Game.Graphics.UserInterface; -using osu.Framework.Graphics.UserInterface; -using osu.Framework.Graphics.Transformations; -using OpenTK; -using OpenTK.Graphics; -using osu.Framework.MathUtils; -using osu.Framework.Graphics.Sprites; - -namespace osu.Desktop.Tests -{ - class TestCaseScoreCounter : TestCase - { - public override string Name => @"ScoreCounter"; - - public override string Description => @"Tests multiple counters"; - - public override void Reset() - { - base.Reset(); - - ScoreCounter uc = new ScoreCounter - { - Origin = Anchor.TopRight, - Anchor = Anchor.TopRight, - TextSize = 40, - RollingDuration = 1000, - RollingEasing = EasingTypes.Out, - Count = 0, - Position = new Vector2(20, 20), - LeadingZeroes = 7, - }; - Add(uc); - - StandardComboCounter sc = new StandardComboCounter - { - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, - Position = new Vector2(20, 20), - IsRollingProportional = true, - RollingDuration = 20, - PopOutDuration = 250, - Count = 0, - TextSize = 40, - }; - Add(sc); - - CatchComboCounter cc = new CatchComboCounter - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - IsRollingProportional = true, - RollingDuration = 20, - PopOutDuration = 250, - Count = 0, - TextSize = 40, - }; - Add(cc); - - AlternativeComboCounter ac = new AlternativeComboCounter - { - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, - Position = new Vector2(20, 80), - IsRollingProportional = true, - RollingDuration = 20, - ScaleFactor = 2, - Count = 0, - TextSize = 40, - }; - Add(ac); - - - AccuracyCounter pc = new AccuracyCounter - { - Origin = Anchor.TopRight, - Anchor = Anchor.TopRight, - RollingDuration = 1000, - RollingEasing = EasingTypes.Out, - Count = 100.0f, - Position = new Vector2(20, 60), - }; - Add(pc); - - SpriteText text = new SpriteText - { - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, - Position = new Vector2(20, 190), - Text = @"- unset -", - }; - Add(text); - - StarCounter tc = new StarCounter - { - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, - Position = new Vector2(20, 160), - }; - Add(tc); - - AddButton(@"Reset all", delegate - { - uc.Count = 0; - sc.Count = 0; - ac.Count = 0; - cc.Count = 0; - pc.SetCount(0, 0); - tc.Count = 0; - text.Text = tc.Count.ToString("0.00"); - }); - - AddButton(@"Hit! :D", delegate - { - uc.Count += 300 + (ulong)(300.0 * (sc.Count > 0 ? sc.Count - 1 : 0) / 25.0); - sc.Count++; - ac.Count++; - cc.CatchFruit(new Color4( - Math.Max(0.5f, RNG.NextSingle()), - Math.Max(0.5f, RNG.NextSingle()), - Math.Max(0.5f, RNG.NextSingle()), - 1) - ); - pc.Numerator++; - pc.Denominator++; - }); - - AddButton(@"miss...", delegate - { - sc.Count = 0; - ac.Count = 0; - cc.Count = 0; - pc.Denominator++; - }); - - AddButton(@"Alter stars", delegate - { - tc.Count = RNG.NextSingle() * (tc.MaxStars + 1); - text.Text = tc.Count.ToString("0.00"); - }); - - AddButton(@"Stop counters", delegate - { - uc.StopRolling(); - sc.StopRolling(); - cc.StopRolling(); - ac.StopRolling(); - pc.StopRolling(); - tc.StopRolling(); - }); - } - } -} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 44a1aef6de..c54140b267 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -140,7 +140,6 @@ - diff --git a/osu.Game/Graphics/UserInterface/AccuracyCounter.cs b/osu.Game/Graphics/UserInterface/AccuracyCounter.cs deleted file mode 100644 index d13cd20107..0000000000 --- a/osu.Game/Graphics/UserInterface/AccuracyCounter.cs +++ /dev/null @@ -1,102 +0,0 @@ -//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.Transformations; -using osu.Framework.MathUtils; -using osu.Framework.Timing; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace osu.Game.Graphics.UserInterface -{ - /// - /// Used as an accuracy counter. Represented visually as a percentage, internally as a fraction. - /// - public class AccuracyCounter : NumericRollingCounter - { - protected override Type transformType => typeof(TransformAccuracy); - - private long numerator = 0; - public long Numerator - { - get - { - return numerator; - } - set - { - numerator = value; - updateCount(); - } - } - - private ulong denominator = 0; - public ulong Denominator - { - get - { - return denominator; - } - set - { - denominator = value; - updateCount(); - } - } - - public void SetCount(long num, ulong den) - { - numerator = num; - denominator = den; - updateCount(); - } - - private void updateCount() - { - Count = Denominator == 0 ? 100.0f : (Numerator * 100.0f) / Denominator; - } - - public override void ResetCount() - { - numerator = 0; - denominator = 0; - updateCount(); - StopRolling(); - } - - protected override string formatCount(float count) - { - return count.ToString("0.00") + "%"; - } - - protected class TransformAccuracy : Transform - { - public override float CurrentValue - { - get - { - double time = Time; - if (time < StartTime) return StartValue; - if (time >= EndTime) return EndValue; - - return Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing); - } - } - - public override void Apply(Drawable d) - { - base.Apply(d); - (d as AccuracyCounter).VisibleCount = CurrentValue; - } - - public TransformAccuracy(IClock clock) - : base(clock) - { - } - } - } -} diff --git a/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs b/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs deleted file mode 100644 index 9b710174ea..0000000000 --- a/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs +++ /dev/null @@ -1,91 +0,0 @@ -//Copyright (c) 2007-2016 ppy Pty Ltd . -//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using OpenTK; -using OpenTK.Graphics; -using osu.Framework; -using osu.Framework.Graphics.Transformations; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace osu.Game.Graphics.UserInterface -{ - /// - /// Allows tint and vertical scaling animation. Used in osu!taiko and osu!mania. - /// - public class AlternativeComboCounter : ULongCounter // btw, I'm terribly bad with names... OUENDAN! - { - public Color4 OriginalColour; - public Color4 TintColour = Color4.OrangeRed; - public int TintDuration = 250; - public float ScaleFactor = 2; - public EasingTypes TintEasing = EasingTypes.None; - public bool CanAnimateWhenBackwards = false; - - public AlternativeComboCounter() : base() - { - IsRollingContinuous = false; - } - - public override void Load(BaseGame game) - { - base.Load(game); - - countSpriteText.Hide(); - OriginalColour = Colour; - } - - public override void ResetCount() - { - SetCountWithoutRolling(0); - } - - protected override void transformCount(ulong currentValue, ulong newValue) - { - // Animate rollover only when going backwards - if (newValue > currentValue) - { - updateTransforms(typeof(TransformULongCounter)); - removeTransforms(typeof(TransformULongCounter)); - VisibleCount = newValue; - } - else - transformCount(new TransformULongCounter(Clock), currentValue, newValue); - } - - protected override ulong getProportionalDuration(ulong currentValue, ulong newValue) - { - ulong difference = currentValue > newValue ? currentValue - newValue : currentValue - newValue; - return difference * RollingDuration; - } - - protected virtual void transformAnimate() - { - countSpriteText.FadeColour(TintColour, 0); - countSpriteText.ScaleTo(new Vector2(1, ScaleFactor)); - countSpriteText.FadeColour(OriginalColour, TintDuration, TintEasing); - countSpriteText.ScaleTo(new Vector2(1, 1), TintDuration, TintEasing); - } - - protected override void transformVisibleCount(ulong currentValue, ulong newValue) - { - if (countSpriteText != null) - { - countSpriteText.Text = newValue.ToString("#,0"); - if (newValue == 0) - { - countSpriteText.FadeOut(TintDuration); - return; - } - countSpriteText.Show(); - if (newValue > currentValue || CanAnimateWhenBackwards) - { - transformAnimate(); - } - } - } - } -} diff --git a/osu.Game/Graphics/UserInterface/CatchComboCounter.cs b/osu.Game/Graphics/UserInterface/CatchComboCounter.cs deleted file mode 100644 index 9fb8caa07a..0000000000 --- a/osu.Game/Graphics/UserInterface/CatchComboCounter.cs +++ /dev/null @@ -1,60 +0,0 @@ -//Copyright (c) 2007-2016 ppy Pty Ltd . -//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using OpenTK.Graphics; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace osu.Game.Graphics.UserInterface -{ - /// - /// Similar to Standard, but without the 'x' and has tinted pop-ups. Used in osu!catch. - /// - public class CatchComboCounter : StandardComboCounter - { - public CatchComboCounter() : base() - { - CanPopOutWhenBackwards = true; - } - - protected override string formatCount(ulong count) - { - return count.ToString("#,0"); - } - - protected override void transformCount(ulong currentValue, ulong newValue) - { - // Animate rollover only when going backwards - if (newValue > currentValue) - { - updateTransforms(typeof(TransformULongCounter)); - removeTransforms(typeof(TransformULongCounter)); - VisibleCount = newValue; - } - else - { - // Backwards pop-up animation has no tint colour - popOutSpriteText.Colour = countSpriteText.Colour; - transformCount(new TransformULongCounter(Clock), currentValue, newValue); - } - } - - /// - /// Increaces counter and tints pop-out before animation. - /// - /// Last grabbed fruit colour. - public void CatchFruit(Color4 colour) - { - popOutSpriteText.Colour = colour; - Count++; - } - - public override void ResetCount() - { - base.ResetCount(); - } - } -} diff --git a/osu.Game/Graphics/UserInterface/NumericRollingCounter.cs b/osu.Game/Graphics/UserInterface/NumericRollingCounter.cs deleted file mode 100644 index e1cb9ddbb4..0000000000 --- a/osu.Game/Graphics/UserInterface/NumericRollingCounter.cs +++ /dev/null @@ -1,65 +0,0 @@ -//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 System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace osu.Game.Graphics.UserInterface -{ - /// - /// Skeleton for a numeric counter with a simple roll-up animation. - /// - /// Type of the actual counter. - public abstract class NumericRollingCounter : RollingCounter - { - protected SpriteText countSpriteText; - - protected float textSize = 20.0f; - public float TextSize - { - get { return textSize; } - set - { - textSize = value; - updateTextSize(); - } - } - - public override void Load(BaseGame game) - { - base.Load(game); - - Children = new Drawable[] - { - countSpriteText = new SpriteText - { - Text = formatCount(Count), - TextSize = this.TextSize, - Anchor = this.Anchor, - Origin = this.Origin, - }, - }; - } - - protected override void transformVisibleCount(T currentValue, T newValue) - { - if (countSpriteText != null) - { - countSpriteText.Text = formatCount(newValue); - } - } - - protected virtual void updateTextSize() - { - if (countSpriteText != null) - countSpriteText.TextSize = TextSize; - } - } -} diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs deleted file mode 100644 index b0686ca0cb..0000000000 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ /dev/null @@ -1,241 +0,0 @@ -using osu.Framework; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Transformations; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace osu.Game.Graphics.UserInterface -{ - /// - /// Skeleton for a counter which value rolls-up in a lapse of time. - /// - /// - /// This class only abstracts the basics to roll-up a value in a lapse of time by using Transforms. - /// In order to show a value, you must implement a way to display it, i.e., as a numeric counter or a bar. - /// - /// Type of the actual counter. - public abstract class RollingCounter : Container - { - /// - /// Type of the Transform to use. - /// - /// - /// Must be a subclass of Transform - /// - protected virtual Type transformType => typeof(Transform); - - protected ulong RollingTotalDuration = 0; - - /// - /// If true, each time the Count is updated, it will roll over from the current visible value. - /// Else, it will roll up from the current count value. - /// - public bool IsRollingContinuous = true; - - /// - /// If true, the roll-up duration will be proportional to the counter. - /// - public bool IsRollingProportional = false; - - /// - /// If IsRollingProportional = false, duration in milliseconds for the counter roll-up animation for each - /// element; else duration in milliseconds for the counter roll-up animation in total. - /// - public ulong RollingDuration = 0; - - /// - /// Easing for the counter rollover animation. - /// - public EasingTypes RollingEasing = EasingTypes.None; - - protected T prevVisibleCount; - protected T visibleCount; - - /// - /// Value shown at the current moment. - /// - public virtual T VisibleCount - { - get - { - return visibleCount; - } - protected set - { - prevVisibleCount = visibleCount; - if (visibleCount.Equals(value)) - return; - visibleCount = value; - transformVisibleCount(prevVisibleCount, value); - } - } - - protected T prevCount; - protected T count; - - /// - /// Actual value of counter. - /// - public virtual T Count - { - get - { - return count; - } - set - { - prevCount = count; - count = value; - if (Clock != null) - { - RollingTotalDuration = - IsRollingProportional - ? getProportionalDuration(VisibleCount, value) - : RollingDuration; - transformCount(IsRollingContinuous ? VisibleCount : prevCount, value); - } - } - } - - protected RollingCounter() - { - Debug.Assert( - transformType.IsSubclassOf(typeof(Transform)) || transformType == typeof(Transform), - @"transformType should be a subclass of Transform." - ); - } - - public override void Load(BaseGame game) - { - base.Load(game); - removeTransforms(transformType); - if (Count == null) - ResetCount(); - VisibleCount = Count; - } - - /// - /// Sets count value, bypassing rollover animation. - /// - /// New count value. - public virtual void SetCountWithoutRolling(T count) - { - Count = count; - StopRolling(); - } - - /// - /// Stops rollover animation, forcing the visible count to be the actual count. - /// - public virtual void StopRolling() - { - removeTransforms(transformType); - VisibleCount = Count; - } - - /// - /// Resets count to default value. - /// - public abstract void ResetCount(); - - /// - /// Calculates the duration of the roll-up animation by using the difference between the current visible value - /// and the new final value. - /// - /// - /// To be used in conjunction with IsRollingProportional = true. - /// Unless a derived class needs to have a proportional rolling, it is not necessary to override this function. - /// - /// Current visible value. - /// New final value. - /// Calculated rollover duration in milliseconds. - protected virtual ulong getProportionalDuration(T currentValue, T newValue) - { - return RollingDuration; - } - - /// - /// Used to format counts. - /// - /// Count to format. - /// Count formatted as a string. - protected virtual string formatCount(T count) - { - return count.ToString(); - } - - protected void updateTransforms(Type type) - { - foreach (ITransform t in Transforms.AliveItems) - if (t.GetType() == type) - t.Apply(this); - } - - protected void removeTransforms(Type type) - { - Transforms.RemoveAll(t => t.GetType() == type); - } - - /// - /// Called when the count is updated to add a transformer that changes the value of the visible count (i.e. - /// implement the rollover animation). - /// - /// Count value before modification. - /// Expected count value after modification- - /// - /// Unless you need to set a custom animation according to the current or new value of the count, the - /// recommended approach is to call transformCount(CustomTransformer(Clock), currentValue, newValue), where - /// CustomTransformer is of type transformerType. - /// By using this approach, there is no need to check if the Clock is not null; this validation is done before - /// adding the transformer. - /// - /// - protected virtual void transformCount(T currentValue, T newValue) - { - object[] parameters = { Clock }; - transformCount((Transform)Activator.CreateInstance(transformType, parameters), currentValue, newValue); - } - - /// - /// Intended to be used by transformCount(). - /// - /// - protected void transformCount(Transform transform, T currentValue, T newValue) - { - Type type = transform.GetType(); - - updateTransforms(type); - removeTransforms(type); - - if (Clock == null) - return; - - if (RollingDuration == 0) - { - VisibleCount = Count; - return; - } - - transform.StartTime = Time; - transform.EndTime = Time + RollingTotalDuration; - transform.StartValue = currentValue; - transform.EndValue = newValue; - transform.Easing = RollingEasing; - - Transforms.Add(transform); - } - - /// - /// This procedure is called each time the visible count value is updated. - /// Override to create custom animations. - /// - /// Visible count value before modification. - /// Expected visible count value after modification- - protected abstract void transformVisibleCount(T currentValue, T newValue); - } -} diff --git a/osu.Game/Graphics/UserInterface/ScoreCounter.cs b/osu.Game/Graphics/UserInterface/ScoreCounter.cs deleted file mode 100644 index d5b9edf73d..0000000000 --- a/osu.Game/Graphics/UserInterface/ScoreCounter.cs +++ /dev/null @@ -1,32 +0,0 @@ -//Copyright (c) 2007-2016 ppy Pty Ltd . -//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace osu.Game.Graphics.UserInterface -{ - public class ScoreCounter : ULongCounter - { - /// - /// How many leading zeroes the counter will have. - /// - public uint LeadingZeroes = 0; - - public override void Load(BaseGame game) - { - base.Load(game); - - countSpriteText.FixedWidth = true; - } - - protected override string formatCount(ulong count) - { - return count.ToString("D" + LeadingZeroes); - } - } -} diff --git a/osu.Game/Graphics/UserInterface/StandardComboCounter.cs b/osu.Game/Graphics/UserInterface/StandardComboCounter.cs deleted file mode 100644 index 676e3672d2..0000000000 --- a/osu.Game/Graphics/UserInterface/StandardComboCounter.cs +++ /dev/null @@ -1,110 +0,0 @@ -//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.Sprites; -using osu.Framework.Graphics.Transformations; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace osu.Game.Graphics.UserInterface -{ - /// - /// Uses the 'x' symbol and has a pop-out effect while rolling over. Used in osu! standard. - /// - public class StandardComboCounter : ULongCounter - { - public SpriteText popOutSpriteText; - - public ulong PopOutDuration = 0; - public float PopOutBigScale = 2.0f; - public float PopOutSmallScale = 1.2f; - public EasingTypes PopOutEasing = EasingTypes.None; - public bool CanPopOutWhenBackwards = false; - public float PopOutInitialAlpha = 0.75f; - - public StandardComboCounter() : base() - { - IsRollingContinuous = false; - } - - public override void Load(BaseGame game) - { - base.Load(game); - - countSpriteText.Alpha = 0; - Add(popOutSpriteText = new SpriteText - { - Text = formatCount(Count), - Origin = this.Origin, - Anchor = this.Anchor, - TextSize = this.TextSize, - Alpha = 0, - }); - } - - protected override void updateTextSize() - { - base.updateTextSize(); - if (popOutSpriteText != null) - popOutSpriteText.TextSize = this.TextSize; - } - - - protected override void transformCount(ulong currentValue, ulong newValue) - { - // Animate rollover only when going backwards - if (newValue > currentValue) - { - updateTransforms(typeof(TransformULongCounter)); - removeTransforms(typeof(TransformULongCounter)); - VisibleCount = newValue; - } - else - transformCount(new TransformULongCounter(Clock), currentValue, newValue); - } - - protected override ulong getProportionalDuration(ulong currentValue, ulong newValue) - { - ulong difference = currentValue > newValue ? currentValue - newValue : currentValue - newValue; - return difference * RollingDuration; - } - - protected override string formatCount(ulong count) - { - return count.ToString("#,0") + "x"; - } - - protected virtual void transformPopOut() - { - countSpriteText.ScaleTo(PopOutSmallScale); - countSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing); - - popOutSpriteText.ScaleTo(PopOutBigScale); - popOutSpriteText.FadeTo(PopOutInitialAlpha); - popOutSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing); - popOutSpriteText.FadeOut(PopOutDuration, PopOutEasing); - } - - protected override void transformVisibleCount(ulong currentValue, ulong newValue) - { - if (countSpriteText != null && popOutSpriteText != null) - { - countSpriteText.Text = popOutSpriteText.Text = formatCount(newValue); - if (newValue == 0) - { - countSpriteText.FadeOut(PopOutDuration); - } - else - { - countSpriteText.Show(); - if (newValue > currentValue || CanPopOutWhenBackwards) - transformPopOut(); - } - } - } - } -} diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs deleted file mode 100644 index 790e0ddcc8..0000000000 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ /dev/null @@ -1,205 +0,0 @@ -//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; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Transformations; -using osu.Framework.MathUtils; -using osu.Framework.Timing; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace osu.Game.Graphics.UserInterface -{ - /// - /// Shows a float count as stars. Used as star difficulty display. - /// - public class StarCounter : RollingCounter - { - protected override Type transformType => typeof(TransformStarCounter); - - protected Container starContainer; - protected List stars = new List(); - - public ulong StarAnimationDuration = 500; - public EasingTypes StarAnimationEasing = EasingTypes.OutElasticHalf; - public ulong FadeDuration = 100; - public float MinStarSize = 0.3f; - public float MinStarAlpha = 0.5f; - public int MaxStars = 10; - public int StarSize = 20; - public int StarSpacing = 4; - - public StarCounter() : base() - { - IsRollingProportional = true; - RollingDuration = 150; - } - - protected override ulong getProportionalDuration(float currentValue, float newValue) - { - return (ulong)(Math.Abs(currentValue - newValue) * RollingDuration); - } - - public override void ResetCount() - { - Count = 0; - StopRolling(); - } - - public override void Load(BaseGame game) - { - base.Load(game); - - Children = new Drawable[] - { - starContainer = new Container - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Width = MaxStars * StarSize + Math.Max(MaxStars - 1, 0) * StarSpacing, - Height = StarSize, - } - }; - - for (int i = 0; i < MaxStars; i++) - { - TextAwesome star = new TextAwesome - { - Icon = FontAwesome.star, - Anchor = Anchor.CentreLeft, - Origin = Anchor.Centre, - TextSize = StarSize, - Scale = new Vector2(MinStarSize), - Alpha = (i == 0) ? 1.0f : MinStarAlpha, - Position = new Vector2((StarSize + StarSpacing) * i + (StarSize + StarSpacing) / 2, 0), - }; - - //todo: user Container once we have it. - stars.Add(star); - starContainer.Add(star); - } - - ResetCount(); - } - - protected override void transformCount(float currentValue, float newValue) - { - transformStar((int)Math.Floor(currentValue), currentValue, currentValue < newValue); - transformCount(new TransformStarCounter(Clock), currentValue, newValue); - } - - protected void updateTransformStar(int i) - { - foreach (ITransform t in stars[i].Transforms.AliveItems) - if (t.GetType() == typeof(TransformAlpha) || t.GetType() == typeof(TransformScaleVector)) - t.Apply(stars[i]); - - stars[i].Transforms.RemoveAll(t => - t.GetType() == typeof(TransformScaleVector) || t.GetType() == typeof(TransformAlpha) - ); - } - - protected void transformStarScale(int i, TransformScaleVector transform, bool isIncrement, double startTime) - { - transform.StartTime = startTime; - transform.EndTime = transform.StartTime + StarAnimationDuration; - transform.StartValue = stars[i].Scale; - transform.EndValue = new Vector2( - Interpolation.ValueAt( - Math.Min(Math.Max(i, Count), i + 1), - MinStarSize, - 1.0f, - i, - i + 1 - ) - ); - transform.Easing = StarAnimationEasing; - - stars[i].Transforms.Add(transform); - } - - protected void transformStarAlpha(int i, TransformAlpha transform, bool isIncrement, double startTime) - { - transform.StartTime = startTime; - //if (!isIncrement) - //transform.StartTime += StarAnimationDuration - FadeDuration; - transform.EndTime = transform.StartTime + FadeDuration; - transform.StartValue = stars[i].Alpha; - transform.EndValue = i < Count ? 1.0f : MinStarAlpha; - - stars[i].Transforms.Add(transform); - } - - - protected void transformStar(int i, float value, bool isIncrement) - { - if (i >= MaxStars) - return; - - if (Clock == null) - return; - - // Calculate time where animation should had started - double startTime = Time; - // If incrementing, animation should had started when VisibleCount crossed start of star (i) - if (isIncrement) - startTime -= i == (int)Math.Floor(prevCount) ? - getProportionalDuration(prevCount, value) : getProportionalDuration(i, value); - // If decrementing, animation should had started when VisibleCount crossed end of star (i + 1) - else - startTime -= i == (int)Math.Floor(prevCount) ? - getProportionalDuration(prevCount, value) : getProportionalDuration(i + 1, value); - - updateTransformStar(i); - - transformStarScale(i, new TransformScaleVector(Clock), isIncrement, startTime); - transformStarAlpha(i, new TransformAlpha(Clock), isIncrement, startTime); - } - - protected override void transformVisibleCount(float currentValue, float newValue) - { - // Detect increment that passes over an integer value - if (Math.Ceiling(currentValue) <= Math.Floor(newValue)) - for (int i = (int)Math.Ceiling(currentValue); i <= Math.Floor(newValue); i++) - transformStar(i, newValue, true); - - // Detect decrement that passes over an integer value - if (Math.Floor(currentValue) >= Math.Ceiling(newValue)) - for (int i = (int)Math.Floor(newValue); i < Math.Floor(currentValue); i++) - transformStar(i, newValue, false); - } - - protected class TransformStarCounter : Transform - { - public override float CurrentValue - { - get - { - double time = Time; - if (time < StartTime) return StartValue; - if (time >= EndTime) return EndValue; - - return Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing); - } - } - - public override void Apply(Drawable d) - { - base.Apply(d); - (d as StarCounter).VisibleCount = CurrentValue; - } - - public TransformStarCounter(IClock clock) - : base(clock) - { - } - } - } -} diff --git a/osu.Game/Graphics/UserInterface/ULongCounter.cs b/osu.Game/Graphics/UserInterface/ULongCounter.cs deleted file mode 100644 index 35df8f5cc8..0000000000 --- a/osu.Game/Graphics/UserInterface/ULongCounter.cs +++ /dev/null @@ -1,59 +0,0 @@ -//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.Transformations; -using osu.Framework.MathUtils; -using osu.Framework.Timing; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace osu.Game.Graphics.UserInterface -{ - /// - /// A simple rolling counter that accepts unsigned long values. - /// - public class ULongCounter : NumericRollingCounter - { - protected override Type transformType => typeof(TransformULongCounter); - - public override void ResetCount() - { - SetCountWithoutRolling(0); - } - - protected override string formatCount(ulong count) - { - return count.ToString("#,0"); - } - - protected class TransformULongCounter : Transform - { - public override ulong CurrentValue - { - get - { - double time = Time; - if (time < StartTime) return StartValue; - if (time >= EndTime) return EndValue; - - return (ulong)Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing); - } - } - - public override void Apply(Drawable d) - { - base.Apply(d); - (d as ULongCounter).VisibleCount = CurrentValue; - } - - public TransformULongCounter(IClock clock) - : base(clock) - { - } - } - } -} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 982798f24b..068c1e1fd8 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -136,19 +136,10 @@ - - - - - - - - - @@ -197,12 +188,7 @@ - - - - - - +