From dff05bec797551f83239650c6a73a82cfa9f4510 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 8 May 2017 18:56:04 +0800 Subject: [PATCH] Use readonly fields. --- .../Beatmaps/IO/LegacyFilesystemReader.cs | 2 +- osu.Game/Beatmaps/Formats/BeatmapDecoder.cs | 2 +- osu.Game/Beatmaps/IO/ArchiveReader.cs | 6 +- osu.Game/Graphics/OsuColour.cs | 92 +++++++++---------- osu.Game/Online/Chat/Channel.cs | 2 +- osu.Game/Overlays/Mods/ModButton.cs | 2 +- osu.Game/Screens/Menu/OsuLogo.cs | 2 +- 7 files changed, 54 insertions(+), 54 deletions(-) diff --git a/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs b/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs index abc45d82ec..8c896646bf 100644 --- a/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs +++ b/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs @@ -14,7 +14,7 @@ namespace osu.Desktop.Beatmaps.IO { public static void Register() => AddReader((storage, path) => Directory.Exists(path)); - private string basePath { get; } + private readonly string basePath; public LegacyFilesystemReader(string path) { diff --git a/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs index cc9d367a59..21a3ab9842 100644 --- a/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs +++ b/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs @@ -11,7 +11,7 @@ namespace osu.Game.Beatmaps.Formats { public abstract class BeatmapDecoder { - private static Dictionary decoders { get; } = new Dictionary(); + private static readonly Dictionary decoders = new Dictionary(); public static BeatmapDecoder GetDecoder(StreamReader stream) { diff --git a/osu.Game/Beatmaps/IO/ArchiveReader.cs b/osu.Game/Beatmaps/IO/ArchiveReader.cs index 6c6b6be23c..9245c914a6 100644 --- a/osu.Game/Beatmaps/IO/ArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/ArchiveReader.cs @@ -13,11 +13,11 @@ namespace osu.Game.Beatmaps.IO { private class Reader { - public Func Test { get; set; } - public Type Type { get; set; } + public Func Test; + public Type Type; } - private static List readers { get; } = new List(); + private static readonly List readers = new List(); public static ArchiveReader GetReader(Storage storage, string path) { diff --git a/osu.Game/Graphics/OsuColour.cs b/osu.Game/Graphics/OsuColour.cs index 15ffefc45d..b666442f19 100644 --- a/osu.Game/Graphics/OsuColour.cs +++ b/osu.Game/Graphics/OsuColour.cs @@ -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"); } } diff --git a/osu.Game/Online/Chat/Channel.cs b/osu.Game/Online/Chat/Channel.cs index 04ebf0a389..d3bd57a1c9 100644 --- a/osu.Game/Online/Chat/Channel.cs +++ b/osu.Game/Online/Chat/Channel.cs @@ -23,7 +23,7 @@ namespace osu.Game.Online.Chat [JsonProperty(@"channel_id")] public int Id; - public SortedList Messages = new SortedList((m1, m2) => m1.Id.CompareTo(m2.Id)); + public readonly SortedList Messages = new SortedList((m1, m2) => m1.Id.CompareTo(m2.Id)); //internal bool Joined; diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index f380c19d8a..d7a91e2caa 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Mods { public class ModButton : FillFlowContainer { - private ModIcon foregroundIcon { get; set; } + private ModIcon foregroundIcon; private readonly SpriteText text; private readonly Container iconsContainer; private SampleChannel sampleOn, sampleOff; diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index 29f6cb2967..f3fffedd43 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -22,7 +22,7 @@ namespace osu.Game.Screens.Menu /// 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;