diff --git a/osu.Game/Beatmaps/Objects/Catch/CatchConverter.cs b/osu.Game/Beatmaps/Objects/Catch/CatchConverter.cs index dbd97e90bc..317a4e9bb1 100644 --- a/osu.Game/Beatmaps/Objects/Catch/CatchConverter.cs +++ b/osu.Game/Beatmaps/Objects/Catch/CatchConverter.cs @@ -25,7 +25,7 @@ namespace osu.Game.Beatmaps.Objects.Catch { OsuBaseHit o = i as OsuBaseHit; - if (o == null) throw new Exception(@"Can't convert!"); + if (o == null) throw new HitObjectConvertException(@"Catch", i); h = new Fruit { diff --git a/osu.Game/Beatmaps/Objects/HitObjectConverter.cs b/osu.Game/Beatmaps/Objects/HitObjectConverter.cs index a70526e85a..723199d8f1 100644 --- a/osu.Game/Beatmaps/Objects/HitObjectConverter.cs +++ b/osu.Game/Beatmaps/Objects/HitObjectConverter.cs @@ -1,6 +1,7 @@ //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 @@ -10,4 +11,13 @@ namespace osu.Game.Beatmaps.Objects { public abstract List Convert(List input); } + public class HitObjectConvertException : Exception + { + public HitObject Input { get; } + public HitObjectConvertException(string modeName, HitObject input) + : base($@"Can't convert from {input.GetType().Name} to {modeName} HitObject!") + { + Input = input; + } + } } diff --git a/osu.Game/Beatmaps/Objects/Mania/ManiaConverter.cs b/osu.Game/Beatmaps/Objects/Mania/ManiaConverter.cs index 22d8f9ae9c..cc03244709 100644 --- a/osu.Game/Beatmaps/Objects/Mania/ManiaConverter.cs +++ b/osu.Game/Beatmaps/Objects/Mania/ManiaConverter.cs @@ -28,7 +28,7 @@ namespace osu.Game.Beatmaps.Objects.Mania { OsuBaseHit o = i as OsuBaseHit; - if (o == null) throw new Exception(@"Can't convert!"); + if (o == null) throw new HitObjectConvertException(@"Mania", i); h = new Note { diff --git a/osu.Game/Beatmaps/Objects/Taiko/TaikoConverter.cs b/osu.Game/Beatmaps/Objects/Taiko/TaikoConverter.cs index 3189a0dec7..d70e8f8406 100644 --- a/osu.Game/Beatmaps/Objects/Taiko/TaikoConverter.cs +++ b/osu.Game/Beatmaps/Objects/Taiko/TaikoConverter.cs @@ -21,7 +21,7 @@ namespace osu.Game.Beatmaps.Objects.Taiko { OsuBaseHit o = i as OsuBaseHit; - if (o == null) throw new Exception(@"Can't convert!"); + if (o == null) throw new HitObjectConvertException(@"Taiko", i); h = new TaikoBaseHit { diff --git a/osu.Game/GameModes/Play/Catch/CatchHitRenderer.cs b/osu.Game/GameModes/Play/Catch/CatchHitRenderer.cs index d8e5aaaa35..3de1c34915 100644 --- a/osu.Game/GameModes/Play/Catch/CatchHitRenderer.cs +++ b/osu.Game/GameModes/Play/Catch/CatchHitRenderer.cs @@ -1,7 +1,6 @@ //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.Game.Beatmaps.Objects; using osu.Game.Beatmaps.Objects.Catch; @@ -11,9 +10,9 @@ namespace osu.Game.GameModes.Play.Catch { public class CatchHitRenderer : HitRenderer { - protected override Playfield CreatePlayfield() => new CatchPlayfield(); + protected override HitObjectConverter Converter => new CatchConverter(); - protected override List Convert(List objects) => new CatchConverter().Convert(objects); + protected override Playfield CreatePlayfield() => new CatchPlayfield(); 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 b18d9ebb6d..53cca2072c 100644 --- a/osu.Game/GameModes/Play/HitRenderer.cs +++ b/osu.Game/GameModes/Play/HitRenderer.cs @@ -10,6 +10,7 @@ using osu.Framework; namespace osu.Game.GameModes.Play { public abstract class HitRenderer : Container + where T : HitObject { private List objects; @@ -27,7 +28,9 @@ namespace osu.Game.GameModes.Play protected abstract Playfield CreatePlayfield(); - protected abstract List Convert(List objects); + protected abstract HitObjectConverter Converter { get; } + + protected virtual List Convert(List objects) => Converter.Convert(objects); public override void Load(BaseGame game) { diff --git a/osu.Game/GameModes/Play/Mania/ManiaHitRenderer.cs b/osu.Game/GameModes/Play/Mania/ManiaHitRenderer.cs index 302f40878b..93b9a58822 100644 --- a/osu.Game/GameModes/Play/Mania/ManiaHitRenderer.cs +++ b/osu.Game/GameModes/Play/Mania/ManiaHitRenderer.cs @@ -1,12 +1,11 @@ //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.Graphics; using osu.Game.Beatmaps.Objects; using osu.Game.Beatmaps.Objects.Mania; -using OpenTK; using osu.Game.Beatmaps.Objects.Mania.Drawable; -using System.Collections.Generic; namespace osu.Game.GameModes.Play.Mania { @@ -19,11 +18,7 @@ namespace osu.Game.GameModes.Play.Mania this.columns = columns; } - protected override List Convert(List objects) - { - ManiaConverter converter = new ManiaConverter(columns); - return converter.Convert(objects); - } + protected override HitObjectConverter Converter => new ManiaConverter(columns); protected override Playfield CreatePlayfield() => new ManiaPlayfield(columns); diff --git a/osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs b/osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs index 130d6d212f..331882da73 100644 --- a/osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs +++ b/osu.Game/GameModes/Play/Osu/OsuHitRenderer.cs @@ -1,7 +1,6 @@ //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.Game.Beatmaps.Objects; using osu.Game.Beatmaps.Objects.Osu; @@ -11,9 +10,9 @@ namespace osu.Game.GameModes.Play.Osu { public class OsuHitRenderer : HitRenderer { - protected override Playfield CreatePlayfield() => new OsuPlayfield(); + protected override HitObjectConverter Converter => new OsuConverter(); - protected override List Convert(List objects) => new OsuConverter().Convert(objects); + protected override Playfield CreatePlayfield() => new OsuPlayfield(); 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 9fab5998f5..bee74d5451 100644 --- a/osu.Game/GameModes/Play/Taiko/TaikoHitRenderer.cs +++ b/osu.Game/GameModes/Play/Taiko/TaikoHitRenderer.cs @@ -1,7 +1,6 @@ //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.Game.Beatmaps.Objects; using osu.Game.Beatmaps.Objects.Taiko; @@ -11,10 +10,10 @@ namespace osu.Game.GameModes.Play.Taiko { public class TaikoHitRenderer : HitRenderer { - protected override List Convert(List objects) => new TaikoConverter().Convert(objects); + protected override HitObjectConverter Converter => new TaikoConverter(); protected override Playfield CreatePlayfield() => new TaikoPlayfield(); protected override Drawable GetVisualRepresentation(TaikoBaseHit h) => new DrawableTaikoHit(h); } -} \ No newline at end of file +} diff --git a/osu.Game/Online/Chat/Display/ChatLine.cs b/osu.Game/Online/Chat/Display/ChatLine.cs index 5032ff0b9f..92146be0b2 100644 --- a/osu.Game/Online/Chat/Display/ChatLine.cs +++ b/osu.Game/Online/Chat/Display/ChatLine.cs @@ -43,7 +43,7 @@ namespace osu.Game.Online.Chat.Display { new SpriteText { - Text = Message.Timestamp.ToLocalTime().ToLongTimeString(), + Text = Message.Timestamp.LocalDateTime.ToLongTimeString(), TextSize = text_size, Colour = new Color4(128, 128, 128, 255) }, diff --git a/osu.Game/Online/Chat/Message.cs b/osu.Game/Online/Chat/Message.cs index 5b344da22c..9fb9668f64 100644 --- a/osu.Game/Online/Chat/Message.cs +++ b/osu.Game/Online/Chat/Message.cs @@ -18,7 +18,7 @@ namespace osu.Game.Online.Chat public int ChannelId; [JsonProperty(@"timestamp")] - public DateTime Timestamp; + public DateTimeOffset Timestamp; [JsonProperty(@"content")] public string Content;