Merge pull request #769 from huoyaoyuan/tidy-up

Tidy up
This commit is contained in:
Dean Herbert 2017-05-17 09:29:05 +09:00 committed by GitHub
commit c78f4cc7ab
12 changed files with 23 additions and 31 deletions

View File

@ -47,7 +47,7 @@ public override void Reset()
Accuracy = 0.98,
MaxCombo = 123,
Rank = ScoreRank.A,
Date = DateTime.Now,
Date = DateTimeOffset.Now,
Statistics = new Dictionary<string, dynamic>()
{
{ "300", 50 },

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Audio;
@ -13,7 +14,8 @@
namespace osu.Game.Graphics.UserInterface
{
public class OsuSliderBar<T> : SliderBar<T>, IHasTooltip where T : struct
public class OsuSliderBar<T> : SliderBar<T>, IHasTooltip
where T : struct, IEquatable<T>
{
private SampleChannel sample;
private double lastSampleTime;

View File

@ -181,7 +181,7 @@ protected virtual string FormatCount(T count)
protected virtual void TransformCount(T currentValue, T newValue)
{
Debug.Assert(
TransformType.IsSubclassOf(typeof(Transform<T>)) || TransformType == typeof(Transform<T>),
typeof(Transform<T>).IsAssignableFrom(TransformType),
@"transformType should be a subclass of Transform<T>."
);

View File

@ -10,7 +10,6 @@
using System.Runtime.Serialization.Formatters;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading;
namespace osu.Game.IO.Legacy
{
@ -66,7 +65,7 @@ public char[] ReadCharArray()
public DateTime ReadDateTime()
{
long ticks = ReadInt64();
if (ticks < 0) throw new AbandonedMutexException("oops");
if (ticks < 0) throw new IOException("Bad ticks count read!");
return new DateTime(ticks, DateTimeKind.Utc);
}

View File

@ -23,7 +23,7 @@ public class Channel
[JsonProperty(@"channel_id")]
public int Id;
public readonly SortedList<Message> Messages = new SortedList<Message>((m1, m2) => m1.Id.CompareTo(m2.Id));
public readonly SortedList<Message> Messages = new SortedList<Message>(Comparer<Message>.Default);
//internal bool Joined;

View File

@ -12,7 +12,7 @@ public class ErrorMessage : Message
public ErrorMessage(string message) : base(errorId--)
{
Timestamp = DateTime.Now;
Timestamp = DateTimeOffset.Now;
Content = message;
Sender = new User

View File

@ -8,7 +8,7 @@
namespace osu.Game.Online.Chat
{
public class Message
public class Message : IComparable<Message>
{
[JsonProperty(@"message_id")]
public readonly long Id;
@ -42,17 +42,7 @@ public Message(long id)
Id = id;
}
public override bool Equals(object obj)
{
var objMessage = obj as Message;
return Id == objMessage?.Id;
}
public override int GetHashCode()
{
return Id.GetHashCode();
}
public int CompareTo(Message other) => Id.CompareTo(other.Id);
}
public enum TargetType

View File

@ -81,7 +81,7 @@ public void Post(Notification notification)
hasCompletionTarget.CompletionTarget = Post;
var ourType = notification.GetType();
sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => ourType == accept || ourType.IsSubclassOf(accept)))?.Add(notification);
sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => accept.IsAssignableFrom(ourType)))?.Add(notification);
}
protected override void PopIn()

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.UserInterface;
@ -8,12 +9,12 @@
namespace osu.Game.Overlays.Settings
{
public class SettingsSlider<T> : SettingsSlider<T, OsuSliderBar<T>>
where T : struct
where T : struct, IEquatable<T>
{
}
public class SettingsSlider<T, U> : SettingsItem<T>
where T : struct
where T : struct, IEquatable<T>
where U : SliderBar<T>, new()
{
protected override Drawable CreateControl() => new U()

View File

@ -46,7 +46,7 @@ public class Score
public long OnlineScoreID;
[JsonProperty(@"created_at")]
public DateTime Date;
public DateTimeOffset Date;
[JsonProperty(@"statistics")]
private Dictionary<string, dynamic> jsonStats

View File

@ -129,7 +129,7 @@ public virtual void PopulateScore(Score score)
score.MaxCombo = HighestCombo;
score.Accuracy = Accuracy;
score.Rank = rankFrom(Accuracy);
score.Date = DateTime.Now;
score.Date = DateTimeOffset.Now;
score.Health = Health;
}
}

View File

@ -116,7 +116,7 @@ private void load(OsuColour colours)
Origin = Anchor.TopCentre,
Margin = new MarginPadding { Bottom = 10 },
},
new DateDisplay(Score.Date)
new DateTimeDisplay(Score.Date.LocalDateTime)
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
@ -220,13 +220,13 @@ private void load(OsuColour colours)
}
}
private class DateDisplay : Container
private class DateTimeDisplay : Container
{
private DateTime date;
private DateTime datetime;
public DateDisplay(DateTime date)
public DateTimeDisplay(DateTime datetime)
{
this.date = date;
this.datetime = datetime;
AutoSizeAxes = Axes.Y;
@ -250,7 +250,7 @@ private void load(OsuColour colours)
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
Text = date.ToString("HH:mm"),
Text = datetime.ToString("HH:mm"),
Padding = new MarginPadding { Left = 10, Right = 10, Top = 5, Bottom = 5 },
Colour = Color4.White,
},
@ -258,7 +258,7 @@ private void load(OsuColour colours)
{
Origin = Anchor.CentreRight,
Anchor = Anchor.CentreRight,
Text = date.ToString("yyyy/MM/dd"),
Text = datetime.ToString("yyyy/MM/dd"),
Padding = new MarginPadding { Left = 10, Right = 10, Top = 5, Bottom = 5 },
Colour = Color4.White,
}