Merge remote-tracking branch 'origin/master' into mania-notes

This commit is contained in:
smoogipooo 2017-05-09 19:31:35 +09:00
commit ea76eff1e1
22 changed files with 96 additions and 89 deletions

View File

@ -14,7 +14,7 @@ namespace osu.Desktop.Beatmaps.IO
{ {
public static void Register() => AddReader<LegacyFilesystemReader>((storage, path) => Directory.Exists(path)); public static void Register() => AddReader<LegacyFilesystemReader>((storage, path) => Directory.Exists(path));
private string basePath { get; } private readonly string basePath;
public LegacyFilesystemReader(string path) public LegacyFilesystemReader(string path)
{ {

View File

@ -58,8 +58,8 @@ namespace osu.Game.Rulesets.Osu.Replays
{ {
public int Compare(ReplayFrame f1, ReplayFrame f2) public int Compare(ReplayFrame f1, ReplayFrame f2)
{ {
if (f1 == null) throw new NullReferenceException($@"{nameof(f1)} cannot be null"); if (f1 == null) throw new ArgumentNullException(nameof(f1));
if (f2 == null) throw new NullReferenceException($@"{nameof(f2)} cannot be null"); if (f2 == null) throw new ArgumentNullException(nameof(f2));
return f1.Time.CompareTo(f2.Time); return f1.Time.CompareTo(f2.Time);
} }

View File

@ -44,7 +44,7 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
protected override Beatmap<TaikoHitObject> ConvertBeatmap(Beatmap original) protected override Beatmap<TaikoHitObject> ConvertBeatmap(Beatmap original)
{ {
// Rewrite the beatmap info to add the slider velocity multiplier // Rewrite the beatmap info to add the slider velocity multiplier
BeatmapInfo info = original.BeatmapInfo.DeepClone<BeatmapInfo>(); BeatmapInfo info = original.BeatmapInfo.DeepClone();
info.Difficulty.SliderMultiplier *= legacy_velocity_multiplier; info.Difficulty.SliderMultiplier *= legacy_velocity_multiplier;
Beatmap<TaikoHitObject> converted = base.ConvertBeatmap(original); Beatmap<TaikoHitObject> converted = base.ConvertBeatmap(original);

View File

@ -109,7 +109,7 @@ namespace osu.Game.Rulesets.Taiko.Replays
Frames.Add(new ReplayFrame(h.StartTime, null, null, button)); Frames.Add(new ReplayFrame(h.StartTime, null, null, button));
} }
else else
throw new Exception("Unknown hit object type."); throw new InvalidOperationException("Unknown hit object type.");
Frames.Add(new ReplayFrame(endTime + KEY_UP_DELAY, null, null, ReplayButtonState.None)); Frames.Add(new ReplayFrame(endTime + KEY_UP_DELAY, null, null, ReplayButtonState.None));

View File

@ -11,9 +11,8 @@ namespace osu.Game.Audio
{ {
} }
public SampleInfoList(IEnumerable<SampleInfo> elements) public SampleInfoList(IEnumerable<SampleInfo> elements) : base(elements)
{ {
AddRange(elements);
} }
} }
} }

View File

@ -11,7 +11,7 @@ namespace osu.Game.Beatmaps.Formats
{ {
public abstract class BeatmapDecoder public abstract class BeatmapDecoder
{ {
private static Dictionary<string, Type> decoders { get; } = new Dictionary<string, Type>(); private static readonly Dictionary<string, Type> decoders = new Dictionary<string, Type>();
public static BeatmapDecoder GetDecoder(StreamReader stream) public static BeatmapDecoder GetDecoder(StreamReader stream)
{ {

View File

@ -13,11 +13,11 @@ namespace osu.Game.Beatmaps.IO
{ {
private class Reader private class Reader
{ {
public Func<Storage, string, bool> Test { get; set; } public Func<Storage, string, bool> Test;
public Type Type { get; set; } public Type Type;
} }
private static List<Reader> readers { get; } = new List<Reader>(); private static readonly List<Reader> readers = new List<Reader>();
public static ArchiveReader GetReader(Storage storage, string path) public static ArchiveReader GetReader(Storage storage, string path)
{ {
@ -58,11 +58,9 @@ namespace osu.Game.Beatmaps.IO
if (input == null) if (input == null)
return null; return null;
using (MemoryStream ms = new MemoryStream()) byte[] buffer = new byte[input.Length];
{ input.Read(buffer, 0, buffer.Length);
input.CopyTo(ms); return buffer;
return ms.ToArray();
}
} }
} }
} }

View File

@ -94,13 +94,13 @@ namespace osu.Game.Database
{ {
byte[] properties = new byte[5]; byte[] properties = new byte[5];
if (replayInStream.Read(properties, 0, 5) != 5) if (replayInStream.Read(properties, 0, 5) != 5)
throw new Exception("input .lzma is too short"); throw new IOException("input .lzma is too short");
long outSize = 0; long outSize = 0;
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
int v = replayInStream.ReadByte(); int v = replayInStream.ReadByte();
if (v < 0) if (v < 0)
throw new Exception("Can't Read 1"); throw new IOException("Can't Read 1");
outSize |= (long)(byte)v << (8 * i); outSize |= (long)(byte)v << (8 * i);
} }

View File

@ -14,6 +14,7 @@ using OpenTK.Graphics.ES30;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
using osu.Framework.Timing; using osu.Framework.Timing;
using System.Diagnostics;
namespace osu.Game.Graphics.Cursor namespace osu.Game.Graphics.Cursor
{ {
@ -39,6 +40,8 @@ namespace osu.Game.Graphics.Cursor
private Vector2? lastPosition; private Vector2? lastPosition;
private readonly InputResampler resampler = new InputResampler();
protected override DrawNode CreateDrawNode() => new TrailDrawNode(); protected override DrawNode CreateDrawNode() => new TrailDrawNode();
protected override void ApplyDrawNode(DrawNode node) protected override void ApplyDrawNode(DrawNode node)
@ -116,22 +119,26 @@ namespace osu.Game.Graphics.Cursor
if (lastPosition == null) if (lastPosition == null)
{ {
lastPosition = state.Mouse.NativeState.Position; lastPosition = state.Mouse.NativeState.Position;
resampler.AddPosition(lastPosition.Value);
return base.OnMouseMove(state); return base.OnMouseMove(state);
} }
Vector2 pos1 = lastPosition.Value; foreach (Vector2 pos2 in resampler.AddPosition(state.Mouse.NativeState.Position))
Vector2 pos2 = state.Mouse.NativeState.Position;
Vector2 diff = pos2 - pos1;
float distance = diff.Length;
Vector2 direction = diff / distance;
float interval = size.X / 2 * 0.9f;
for (float d = interval; d < distance; d += interval)
{ {
lastPosition = pos1 + direction * d; Trace.Assert(lastPosition.HasValue);
addPosition(lastPosition.Value);
Vector2 pos1 = lastPosition.Value;
Vector2 diff = pos2 - pos1;
float distance = diff.Length;
Vector2 direction = diff / distance;
float interval = size.X / 2 * 0.9f;
for (float d = interval; d < distance; d += interval)
{
lastPosition = pos1 + direction * d;
addPosition(lastPosition.Value);
}
} }
return base.OnMouseMove(state); return base.OnMouseMove(state);

View File

@ -16,7 +16,7 @@ namespace osu.Game.Graphics
switch (hex.Length) switch (hex.Length)
{ {
default: default:
throw new Exception(@"Invalid hex string length!"); throw new ArgumentException(@"Invalid hex string length!");
case 3: case 3:
return new Color4( return new Color4(
(byte)(Convert.ToByte(hex.Substring(0, 1), 16) * 17), (byte)(Convert.ToByte(hex.Substring(0, 1), 16) * 17),
@ -33,57 +33,57 @@ namespace osu.Game.Graphics
} }
// See https://github.com/ppy/osu-web/blob/master/resources/assets/less/colors.less // See https://github.com/ppy/osu-web/blob/master/resources/assets/less/colors.less
public Color4 PurpleLighter = FromHex(@"eeeeff"); public readonly Color4 PurpleLighter = FromHex(@"eeeeff");
public Color4 PurpleLight = FromHex(@"aa88ff"); public readonly Color4 PurpleLight = FromHex(@"aa88ff");
public Color4 Purple = FromHex(@"8866ee"); public readonly Color4 Purple = FromHex(@"8866ee");
public Color4 PurpleDark = FromHex(@"6644cc"); public readonly Color4 PurpleDark = FromHex(@"6644cc");
public Color4 PurpleDarker = FromHex(@"441188"); public readonly Color4 PurpleDarker = FromHex(@"441188");
public Color4 PinkLighter = FromHex(@"ffddee"); public readonly Color4 PinkLighter = FromHex(@"ffddee");
public Color4 PinkLight = FromHex(@"ff99cc"); public readonly Color4 PinkLight = FromHex(@"ff99cc");
public Color4 Pink = FromHex(@"ff66aa"); public readonly Color4 Pink = FromHex(@"ff66aa");
public Color4 PinkDark = FromHex(@"cc5288"); public readonly Color4 PinkDark = FromHex(@"cc5288");
public Color4 PinkDarker = FromHex(@"bb1177"); public readonly Color4 PinkDarker = FromHex(@"bb1177");
public Color4 BlueLighter = FromHex(@"ddffff"); public readonly Color4 BlueLighter = FromHex(@"ddffff");
public Color4 BlueLight = FromHex(@"99eeff"); public readonly Color4 BlueLight = FromHex(@"99eeff");
public Color4 Blue = FromHex(@"66ccff"); public readonly Color4 Blue = FromHex(@"66ccff");
public Color4 BlueDark = FromHex(@"44aadd"); public readonly Color4 BlueDark = FromHex(@"44aadd");
public Color4 BlueDarker = FromHex(@"2299bb"); public readonly Color4 BlueDarker = FromHex(@"2299bb");
public Color4 YellowLighter = FromHex(@"ffffdd"); public readonly Color4 YellowLighter = FromHex(@"ffffdd");
public Color4 YellowLight = FromHex(@"ffdd55"); public readonly Color4 YellowLight = FromHex(@"ffdd55");
public Color4 Yellow = FromHex(@"ffcc22"); public readonly Color4 Yellow = FromHex(@"ffcc22");
public Color4 YellowDark = FromHex(@"eeaa00"); public readonly Color4 YellowDark = FromHex(@"eeaa00");
public Color4 YellowDarker = FromHex(@"cc6600"); public readonly Color4 YellowDarker = FromHex(@"cc6600");
public Color4 GreenLighter = FromHex(@"eeffcc"); public readonly Color4 GreenLighter = FromHex(@"eeffcc");
public Color4 GreenLight = FromHex(@"b3d944"); public readonly Color4 GreenLight = FromHex(@"b3d944");
public Color4 Green = FromHex(@"88b300"); public readonly Color4 Green = FromHex(@"88b300");
public Color4 GreenDark = FromHex(@"668800"); public readonly Color4 GreenDark = FromHex(@"668800");
public Color4 GreenDarker = FromHex(@"445500"); public readonly Color4 GreenDarker = FromHex(@"445500");
public Color4 Gray0 = FromHex(@"000"); public readonly Color4 Gray0 = FromHex(@"000");
public Color4 Gray1 = FromHex(@"111"); public readonly Color4 Gray1 = FromHex(@"111");
public Color4 Gray2 = FromHex(@"222"); public readonly Color4 Gray2 = FromHex(@"222");
public Color4 Gray3 = FromHex(@"333"); public readonly Color4 Gray3 = FromHex(@"333");
public Color4 Gray4 = FromHex(@"444"); public readonly Color4 Gray4 = FromHex(@"444");
public Color4 Gray5 = FromHex(@"555"); public readonly Color4 Gray5 = FromHex(@"555");
public Color4 Gray6 = FromHex(@"666"); public readonly Color4 Gray6 = FromHex(@"666");
public Color4 Gray7 = FromHex(@"777"); public readonly Color4 Gray7 = FromHex(@"777");
public Color4 Gray8 = FromHex(@"888"); public readonly Color4 Gray8 = FromHex(@"888");
public Color4 Gray9 = FromHex(@"999"); public readonly Color4 Gray9 = FromHex(@"999");
public Color4 GrayA = FromHex(@"aaa"); public readonly Color4 GrayA = FromHex(@"aaa");
public Color4 GrayB = FromHex(@"bbb"); public readonly Color4 GrayB = FromHex(@"bbb");
public Color4 GrayC = FromHex(@"ccc"); public readonly Color4 GrayC = FromHex(@"ccc");
public Color4 GrayD = FromHex(@"ddd"); public readonly Color4 GrayD = FromHex(@"ddd");
public Color4 GrayE = FromHex(@"eee"); public readonly Color4 GrayE = FromHex(@"eee");
public Color4 GrayF = FromHex(@"fff"); public readonly Color4 GrayF = FromHex(@"fff");
public Color4 RedLighter = FromHex(@"ffeded"); public readonly Color4 RedLighter = FromHex(@"ffeded");
public Color4 RedLight = FromHex(@"ed7787"); public readonly Color4 RedLight = FromHex(@"ed7787");
public Color4 Red = FromHex(@"ed1121"); public readonly Color4 Red = FromHex(@"ed1121");
public Color4 RedDark = FromHex(@"ba0011"); public readonly Color4 RedDark = FromHex(@"ba0011");
public Color4 RedDarker = FromHex(@"870000"); public readonly Color4 RedDarker = FromHex(@"870000");
} }
} }

View File

@ -16,12 +16,13 @@ namespace osu.Game.IO.Serialization
return JsonConvert.SerializeObject(obj); return JsonConvert.SerializeObject(obj);
} }
public static T Deserialize<T>(string objString) public static T Deserialize<T>(this string objString)
{ {
return JsonConvert.DeserializeObject<T>(objString); return JsonConvert.DeserializeObject<T>(objString);
} }
public static T DeepClone<T>(this IJsonSerializable obj) public static T DeepClone<T>(this T obj)
where T : IJsonSerializable
{ {
return Deserialize<T>(Serialize(obj)); return Deserialize<T>(Serialize(obj));
} }

View File

@ -23,7 +23,7 @@ namespace osu.Game.Online.Chat
[JsonProperty(@"channel_id")] [JsonProperty(@"channel_id")]
public int Id; public int Id;
public SortedList<Message> Messages = new SortedList<Message>((m1, m2) => m1.Id.CompareTo(m2.Id)); public readonly SortedList<Message> Messages = new SortedList<Message>((m1, m2) => m1.Id.CompareTo(m2.Id));
//internal bool Joined; //internal bool Joined;

View File

@ -25,7 +25,7 @@ namespace osu.Game.Overlays.Mods
/// </summary> /// </summary>
public class ModButton : ModButtonEmpty public class ModButton : ModButtonEmpty
{ {
private ModIcon foregroundIcon { get; set; } private ModIcon foregroundIcon;
private readonly SpriteText text; private readonly SpriteText text;
private readonly Container<ModIcon> iconsContainer; private readonly Container<ModIcon> iconsContainer;
private SampleChannel sampleOn, sampleOff; private SampleChannel sampleOn, sampleOff;

View File

@ -17,7 +17,6 @@ namespace osu.Game.Overlays.Toolbar
private void load(ChatOverlay chat) private void load(ChatOverlay chat)
{ {
StateContainer = chat; StateContainer = chat;
Action = chat.ToggleVisibility;
} }
} }
} }

View File

@ -17,7 +17,6 @@ namespace osu.Game.Overlays.Toolbar
private void load(MusicController music) private void load(MusicController music)
{ {
StateContainer = music; StateContainer = music;
Action = music.ToggleVisibility;
} }
} }
} }

View File

@ -22,7 +22,6 @@ namespace osu.Game.Overlays.Toolbar
private void load(NotificationManager notificationManager) private void load(NotificationManager notificationManager)
{ {
StateContainer = notificationManager; StateContainer = notificationManager;
Action = notificationManager.ToggleVisibility;
} }
} }
} }

View File

@ -21,6 +21,7 @@ namespace osu.Game.Overlays.Toolbar
set set
{ {
stateContainer = value; stateContainer = value;
Action = stateContainer.ToggleVisibility;
stateContainer.StateChanged += stateChanged; stateContainer.StateChanged += stateChanged;
} }
} }

View File

@ -19,7 +19,6 @@ namespace osu.Game.Overlays.Toolbar
private void load(OptionsOverlay options) private void load(OptionsOverlay options)
{ {
StateContainer = options; StateContainer = options;
Action = options.ToggleVisibility;
} }
} }
} }

View File

@ -279,7 +279,7 @@ namespace osu.Game.Rulesets.UI
protected abstract Playfield<TObject, TJudgement> CreatePlayfield(); protected abstract Playfield<TObject, TJudgement> CreatePlayfield();
} }
public class BeatmapInvalidForRulesetException : Exception public class BeatmapInvalidForRulesetException : ArgumentException
{ {
public BeatmapInvalidForRulesetException(string text) public BeatmapInvalidForRulesetException(string text)
: base(text) : base(text)

View File

@ -22,7 +22,7 @@ namespace osu.Game.Screens.Menu
/// </summary> /// </summary>
public class OsuLogo : Container public class OsuLogo : Container
{ {
public Color4 OsuPink = OsuColour.FromHex(@"e967a1"); public readonly Color4 OsuPink = OsuColour.FromHex(@"e967a1");
private readonly Sprite logo; private readonly Sprite logo;
private readonly CircularContainer logoContainer; private readonly CircularContainer logoContainer;

View File

@ -11,5 +11,10 @@ namespace osu.Game.Screens.Multiplayer
protected override IEnumerable<Type> PossibleChildren => new[] { protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(Match) typeof(Match)
}; };
public MatchCreate()
{
ValidForResume = false;
}
} }
} }

View File

@ -90,7 +90,7 @@ namespace osu.Game.Screens.Play
Beatmap = beatmaps.GetWorkingBeatmap(BeatmapInfo, withStoryboard: true); Beatmap = beatmaps.GetWorkingBeatmap(BeatmapInfo, withStoryboard: true);
if (Beatmap?.Beatmap == null) if (Beatmap?.Beatmap == null)
throw new Exception("Beatmap was not loaded"); throw new InvalidOperationException("Beatmap was not loaded");
ruleset = osu?.Ruleset.Value ?? Beatmap.BeatmapInfo.Ruleset; ruleset = osu?.Ruleset.Value ?? Beatmap.BeatmapInfo.Ruleset;
rulesetInstance = ruleset.CreateInstance(); rulesetInstance = ruleset.CreateInstance();
@ -109,7 +109,7 @@ namespace osu.Game.Screens.Play
} }
if (!HitRenderer.Objects.Any()) if (!HitRenderer.Objects.Any())
throw new Exception("Beatmap contains no hit objects!"); throw new InvalidOperationException("Beatmap contains no hit objects!");
} }
catch (Exception e) catch (Exception e)
{ {