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

Merge remote-tracking branch 'refs/remotes/ppy/master' into percentage

This commit is contained in:
EVAST9919 2017-05-09 06:05:46 +03:00
commit 2c92ee432b
21 changed files with 77 additions and 77 deletions

View File

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

View File

@ -58,8 +58,8 @@ namespace osu.Game.Rulesets.Osu.Replays
{
public int Compare(ReplayFrame f1, ReplayFrame f2)
{
if (f1 == null) throw new NullReferenceException($@"{nameof(f1)} cannot be null");
if (f2 == null) throw new NullReferenceException($@"{nameof(f2)} cannot be null");
if (f1 == null) throw new ArgumentNullException(nameof(f1));
if (f2 == null) throw new ArgumentNullException(nameof(f2));
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)
{
// 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;
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));
}
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));

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
{
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)
{

View File

@ -13,11 +13,11 @@ namespace osu.Game.Beatmaps.IO
{
private class Reader
{
public Func<Storage, string, bool> Test { get; set; }
public Type Type { get; set; }
public Func<Storage, string, bool> Test;
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)
{
@ -58,11 +58,9 @@ namespace osu.Game.Beatmaps.IO
if (input == null)
return null;
using (MemoryStream ms = new MemoryStream())
{
input.CopyTo(ms);
return ms.ToArray();
}
byte[] buffer = new byte[input.Length];
input.Read(buffer, 0, buffer.Length);
return buffer;
}
}
}

View File

@ -94,13 +94,13 @@ namespace osu.Game.Database
{
byte[] properties = new byte[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;
for (int i = 0; i < 8; i++)
{
int v = replayInStream.ReadByte();
if (v < 0)
throw new Exception("Can't Read 1");
throw new IOException("Can't Read 1");
outSize |= (long)(byte)v << (8 * i);
}

View File

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

View File

@ -16,12 +16,13 @@ namespace osu.Game.IO.Serialization
return JsonConvert.SerializeObject(obj);
}
public static T Deserialize<T>(string objString)
public static T Deserialize<T>(this string 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));
}

View File

@ -23,7 +23,7 @@ namespace osu.Game.Online.Chat
[JsonProperty(@"channel_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;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -90,7 +90,7 @@ namespace osu.Game.Screens.Play
Beatmap = beatmaps.GetWorkingBeatmap(BeatmapInfo, withStoryboard: true);
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;
rulesetInstance = ruleset.CreateInstance();
@ -109,7 +109,7 @@ namespace osu.Game.Screens.Play
}
if (!HitRenderer.Objects.Any())
throw new Exception("Beatmap contains no hit objects!");
throw new InvalidOperationException("Beatmap contains no hit objects!");
}
catch (Exception e)
{