1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 05:32:54 +08:00

Merge branch 'master' into fast-random

This commit is contained in:
Dean Herbert 2017-05-17 12:55:35 +09:00 committed by GitHub
commit 9b1363184b
16 changed files with 46 additions and 38 deletions

@ -1 +1 @@
Subproject commit 3111d1aa4f0d3aa1c0df03f8003b6c5c726b10d2
Subproject commit 67f39580365f7d0a42f8788eae2b60881dde1c67

View File

@ -47,7 +47,7 @@ namespace osu.Desktop.VisualTests.Tests
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 @@ using osu.Framework.Input;
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 @@ namespace osu.Game.Graphics.UserInterface
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;
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 @@ namespace osu.Game.IO.Legacy
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

@ -20,7 +20,7 @@ namespace osu.Game.Online.API
{
private readonly OAuth authentication;
public string Endpoint = @"https://new.ppy.sh";
public string Endpoint = @"https://osu.ppy.sh";
private const string client_id = @"5";
private const string client_secret = @"FGc9GAtyHzeQDshWP5Ah7dega8hJACAJpQtw6OXk";
@ -34,7 +34,7 @@ namespace osu.Game.Online.API
public string Password;
public Bindable<User> LocalUser = new Bindable<User>();
public Bindable<User> LocalUser = new Bindable<User>(createGuestUser());
public string Token
{
@ -191,7 +191,7 @@ namespace osu.Game.Online.API
req.Perform(this);
//we could still be in initialisation, at which point we don't want to say we're Online yet.
if (LocalUser.Value != null)
if (IsLoggedIn)
State = APIState.Online;
failureCount = 0;
@ -266,6 +266,8 @@ namespace osu.Game.Online.API
}
}
public bool IsLoggedIn => LocalUser.Value.Id > 1;
public void Queue(APIRequest request)
{
queue.Enqueue(request);
@ -295,8 +297,15 @@ namespace osu.Game.Online.API
clearCredentials();
authentication.Clear();
State = APIState.Offline;
LocalUser.Value = createGuestUser();
}
private static User createGuestUser() => new User
{
Username = @"Guest",
Id = 1,
};
public void Update()
{
Scheduler.Update();

View File

@ -23,7 +23,7 @@ namespace osu.Game.Online.Chat
[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 @@ namespace osu.Game.Online.Chat
public ErrorMessage(string message) : base(errorId--)
{
Timestamp = DateTime.Now;
Timestamp = DateTimeOffset.Now;
Content = message;
Sender = new User

View File

@ -8,7 +8,7 @@ using osu.Game.Users;
namespace osu.Game.Online.Chat
{
public class Message
public class Message : IComparable<Message>
{
[JsonProperty(@"message_id")]
public readonly long Id;
@ -42,17 +42,7 @@ namespace osu.Game.Online.Chat
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,6 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding
{
Top = padding,
Bottom = textbox_height + padding
},
},
@ -353,7 +352,15 @@ namespace osu.Game.Overlays
{
var postText = textbox.Text;
if (string.IsNullOrEmpty(postText) || api.LocalUser.Value == null) return;
if (string.IsNullOrEmpty(postText))
return;
if (!api.IsLoggedIn)
{
currentChannel?.AddNewMessages(new ErrorMessage("Please login to participate in chat!"));
textbox.Text = string.Empty;
return;
}
if (currentChannel == null) return;

View File

@ -81,7 +81,7 @@ namespace osu.Game.Overlays
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 @@ using osu.Game.Graphics.UserInterface;
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 @@ namespace osu.Game.Rulesets.Scoring
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 @@ namespace osu.Game.Rulesets.Scoring
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 @@ namespace osu.Game.Screens.Ranking
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 @@ namespace osu.Game.Screens.Ranking
}
}
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 @@ namespace osu.Game.Screens.Ranking
{
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 @@ namespace osu.Game.Screens.Ranking
{
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,
}

View File

@ -205,7 +205,7 @@ namespace osu.Game.Screens.Select
drainRate = new DifficultyRow("HP Drain"),
overallDifficulty = new DifficultyRow("Accuracy"),
approachRate = new DifficultyRow("Approach Rate"),
stars = new DifficultyRow("Star Diffculty"),
stars = new DifficultyRow("Star Difficulty"),
},
},
},