1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 08:12:56 +08:00

Merge remote-tracking branch 'upstream/master' into async-screens

This commit is contained in:
Dean Herbert 2018-04-23 18:29:37 +09:00
commit ff3d3379f0
9 changed files with 37 additions and 23 deletions

View File

@ -21,7 +21,7 @@ namespace osu.Game.Beatmaps.Formats
return output; return output;
} }
protected abstract void ParseStreamInto(StreamReader stream, TOutput beatmap); protected abstract void ParseStreamInto(StreamReader stream, TOutput output);
} }
public abstract class Decoder public abstract class Decoder

View File

@ -13,15 +13,15 @@ namespace osu.Game.Beatmaps.Formats
AddDecoder<Beatmap>("{", m => new JsonBeatmapDecoder()); AddDecoder<Beatmap>("{", m => new JsonBeatmapDecoder());
} }
protected override void ParseStreamInto(StreamReader stream, Beatmap beatmap) protected override void ParseStreamInto(StreamReader stream, Beatmap output)
{ {
stream.BaseStream.Position = 0; stream.BaseStream.Position = 0;
stream.DiscardBufferedData(); stream.DiscardBufferedData();
stream.ReadToEnd().DeserializeInto(beatmap); stream.ReadToEnd().DeserializeInto(output);
foreach (var hitObject in beatmap.HitObjects) foreach (var hitObject in output.HitObjects)
hitObject.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.BaseDifficulty); hitObject.ApplyDefaults(output.ControlPointInfo, output.BeatmapInfo.BaseDifficulty);
} }
} }
} }

View File

@ -19,7 +19,7 @@ namespace osu.Game.Beatmaps.Formats
FormatVersion = version; FormatVersion = version;
} }
protected override void ParseStreamInto(StreamReader stream, T beatmap) protected override void ParseStreamInto(StreamReader stream, T output)
{ {
Section section = Section.None; Section section = Section.None;
@ -33,14 +33,21 @@ namespace osu.Game.Beatmaps.Formats
{ {
if (!Enum.TryParse(line.Substring(1, line.Length - 2), out section)) if (!Enum.TryParse(line.Substring(1, line.Length - 2), out section))
{ {
Logger.Log($"Unknown section \"{line}\" in {beatmap}"); Logger.Log($"Unknown section \"{line}\" in {output}");
section = Section.None; section = Section.None;
} }
continue; continue;
} }
ParseLine(beatmap, section, line); try
{
ParseLine(output, section, line);
}
catch (Exception e)
{
Logger.Error(e, $"Failed to process line \"{line}\" into {output}");
}
} }
} }

View File

@ -11,7 +11,7 @@ namespace osu.Game.Online.API.Requests
public class GetMessagesRequest : APIRequest<List<Message>> public class GetMessagesRequest : APIRequest<List<Message>>
{ {
private readonly List<Channel> channels; private readonly List<Channel> channels;
private long? since; private readonly long? since;
public GetMessagesRequest(List<Channel> channels, long? sinceId) public GetMessagesRequest(List<Channel> channels, long? sinceId)
{ {

View File

@ -7,7 +7,7 @@ namespace osu.Game.Online.API.Requests
{ {
public class GetUserRequest : APIRequest<User> public class GetUserRequest : APIRequest<User>
{ {
private long? userId; private readonly long? userId;
public GetUserRequest(long? userId = null) public GetUserRequest(long? userId = null)
{ {

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input; using osu.Framework.Input;
@ -43,6 +44,8 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
public override void Add(HitObjectMask drawable) public override void Add(HitObjectMask drawable)
{ {
if (drawable == null) throw new ArgumentNullException(nameof(drawable));
base.Add(drawable); base.Add(drawable);
drawable.Selected += onMaskSelected; drawable.Selected += onMaskSelected;
@ -51,8 +54,10 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
drawable.DragRequested += onDragRequested; drawable.DragRequested += onDragRequested;
} }
public override bool Remove(HitObjectMask drawable) public override bool Remove([NotNull] HitObjectMask drawable)
{ {
if (drawable == null) throw new ArgumentNullException(nameof(drawable));
var result = base.Remove(drawable); var result = base.Remove(drawable);
if (result) if (result)

View File

@ -39,6 +39,7 @@ namespace osu.Game.Screens.Menu
private Bindable<bool> menuVoice; private Bindable<bool> menuVoice;
private Bindable<bool> menuMusic; private Bindable<bool> menuMusic;
private Track track; private Track track;
private WorkingBeatmap beatmap;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio, OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game) private void load(AudioManager audio, OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game)
@ -69,9 +70,8 @@ namespace osu.Game.Screens.Menu
} }
} }
Beatmap.Value = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]); beatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]);
track = beatmap.Track;
track = Beatmap.Value.Track;
welcome = audio.Sample.Get(@"welcome"); welcome = audio.Sample.Get(@"welcome");
seeya = audio.Sample.Get(@"seeya"); seeya = audio.Sample.Get(@"seeya");
@ -81,6 +81,8 @@ namespace osu.Game.Screens.Menu
{ {
base.OnEntering(last); base.OnEntering(last);
Game.Beatmap.Value = beatmap;
if (menuVoice) if (menuVoice)
welcome.Play(); welcome.Play();

View File

@ -223,11 +223,11 @@ namespace osu.Game.Screens.Ranking
private class DateTimeDisplay : Container private class DateTimeDisplay : Container
{ {
private DateTime datetime; private readonly DateTime date;
public DateTimeDisplay(DateTime datetime) public DateTimeDisplay(DateTime date)
{ {
this.datetime = datetime; this.date = date;
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
@ -251,7 +251,7 @@ namespace osu.Game.Screens.Ranking
{ {
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Text = datetime.ToShortDateString(), Text = date.ToShortDateString(),
Padding = new MarginPadding { Horizontal = 10, Vertical = 5 }, Padding = new MarginPadding { Horizontal = 10, Vertical = 5 },
Colour = Color4.White, Colour = Color4.White,
}, },
@ -259,7 +259,7 @@ namespace osu.Game.Screens.Ranking
{ {
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
Text = datetime.ToShortTimeString(), Text = date.ToShortTimeString(),
Padding = new MarginPadding { Horizontal = 10, Vertical = 5 }, Padding = new MarginPadding { Horizontal = 10, Vertical = 5 },
Colour = Color4.White, Colour = Color4.White,
} }

View File

@ -12,7 +12,7 @@ namespace osu.Game.Skinning
{ {
} }
protected override void ParseLine(SkinConfiguration output, Section section, string line) protected override void ParseLine(SkinConfiguration skin, Section section, string line)
{ {
switch (section) switch (section)
{ {
@ -22,17 +22,17 @@ namespace osu.Game.Skinning
switch (pair.Key) switch (pair.Key)
{ {
case @"Name": case @"Name":
output.SkinInfo.Name = pair.Value; skin.SkinInfo.Name = pair.Value;
break; break;
case @"Author": case @"Author":
output.SkinInfo.Creator = pair.Value; skin.SkinInfo.Creator = pair.Value;
break; break;
} }
break; break;
} }
base.ParseLine(output, section, line); base.ParseLine(skin, section, line);
} }
} }
} }