mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 12:23:22 +08:00
Merge pull request #71 from huoyaoyuan/tidy-up
Strongly type specifications
This commit is contained in:
commit
123d92f5b9
@ -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
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Beatmaps.Objects
|
||||
@ -10,4 +11,13 @@ namespace osu.Game.Beatmaps.Objects
|
||||
{
|
||||
public abstract List<T> Convert(List<HitObject> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
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<CatchBaseHit>
|
||||
{
|
||||
protected override Playfield CreatePlayfield() => new CatchPlayfield();
|
||||
protected override HitObjectConverter<CatchBaseHit> Converter => new CatchConverter();
|
||||
|
||||
protected override List<CatchBaseHit> Convert(List<HitObject> objects) => new CatchConverter().Convert(objects);
|
||||
protected override Playfield CreatePlayfield() => new CatchPlayfield();
|
||||
|
||||
protected override Drawable GetVisualRepresentation(CatchBaseHit h) => new DrawableFruit(h);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ using osu.Framework;
|
||||
namespace osu.Game.GameModes.Play
|
||||
{
|
||||
public abstract class HitRenderer<T> : Container
|
||||
where T : HitObject
|
||||
{
|
||||
private List<T> objects;
|
||||
|
||||
@ -27,7 +28,9 @@ namespace osu.Game.GameModes.Play
|
||||
|
||||
protected abstract Playfield CreatePlayfield();
|
||||
|
||||
protected abstract List<T> Convert(List<HitObject> objects);
|
||||
protected abstract HitObjectConverter<T> Converter { get; }
|
||||
|
||||
protected virtual List<T> Convert(List<HitObject> objects) => Converter.Convert(objects);
|
||||
|
||||
public override void Load(BaseGame game)
|
||||
{
|
||||
|
@ -1,12 +1,11 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//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<ManiaBaseHit> Convert(List<HitObject> objects)
|
||||
{
|
||||
ManiaConverter converter = new ManiaConverter(columns);
|
||||
return converter.Convert(objects);
|
||||
}
|
||||
protected override HitObjectConverter<ManiaBaseHit> Converter => new ManiaConverter(columns);
|
||||
|
||||
protected override Playfield CreatePlayfield() => new ManiaPlayfield(columns);
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
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<OsuBaseHit>
|
||||
{
|
||||
protected override Playfield CreatePlayfield() => new OsuPlayfield();
|
||||
protected override HitObjectConverter<OsuBaseHit> Converter => new OsuConverter();
|
||||
|
||||
protected override List<OsuBaseHit> Convert(List<HitObject> objects) => new OsuConverter().Convert(objects);
|
||||
protected override Playfield CreatePlayfield() => new OsuPlayfield();
|
||||
|
||||
protected override Drawable GetVisualRepresentation(OsuBaseHit h) => new DrawableCircle(h);
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
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<TaikoBaseHit>
|
||||
{
|
||||
protected override List<TaikoBaseHit> Convert(List<HitObject> objects) => new TaikoConverter().Convert(objects);
|
||||
protected override HitObjectConverter<TaikoBaseHit> Converter => new TaikoConverter();
|
||||
|
||||
protected override Playfield CreatePlayfield() => new TaikoPlayfield();
|
||||
|
||||
protected override Drawable GetVisualRepresentation(TaikoBaseHit h) => new DrawableTaikoHit(h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
},
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user