1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 16:07:24 +08:00

Enforce readonly private members where possible.

This commit is contained in:
Dean Herbert 2017-03-23 13:41:50 +09:00
parent 5138890530
commit 54e1b24fe9
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
115 changed files with 278 additions and 259 deletions

View File

@ -53,7 +53,7 @@ namespace osu.Desktop.Deploy
private static string nupkgFilename(string ver) => $"{PackageName}.{ver}.nupkg";
private static string nupkgDistroFilename(string ver) => $"{PackageName}-{ver}-full.nupkg";
private static Stopwatch sw = new Stopwatch();
private static readonly Stopwatch sw = new Stopwatch();
private static string codeSigningPassword;

View File

@ -15,7 +15,7 @@ namespace osu.Desktop.VisualTests.Beatmaps
this.beatmap = beatmap;
}
private Beatmap beatmap;
private readonly Beatmap beatmap;
protected override Beatmap GetBeatmap() => beatmap;
protected override Texture GetBackground() => null;

View File

@ -10,7 +10,7 @@ namespace osu.Desktop.VisualTests
{
public class Benchmark : OsuGameBase
{
private double timePerTest = 200;
private readonly double timePerTest = 200;
[BackgroundDependencyLoader]
private void load()

View File

@ -21,7 +21,7 @@ namespace osu.Desktop.VisualTests.Tests
{
internal class TestCaseHitObjects : TestCase
{
private FramedClock framedClock;
private readonly FramedClock framedClock;
private bool auto;
@ -34,7 +34,7 @@ namespace osu.Desktop.VisualTests.Tests
private HitObjectType mode = HitObjectType.Slider;
private BindableNumber<double> playbackSpeed = new BindableDouble(0.5) { MinValue = 0, MaxValue = 1 };
private readonly BindableNumber<double> playbackSpeed = new BindableDouble(0.5) { MinValue = 0, MaxValue = 1 };
private Container playfieldContainer;
private Container approachContainer;

View File

@ -95,7 +95,7 @@ namespace osu.Desktop.VisualTests.Tests
progressingNotifications.Add(n);
}
private List<ProgressNotification> progressingNotifications = new List<ProgressNotification>();
private readonly List<ProgressNotification> progressingNotifications = new List<ProgressNotification>();
private void sendProgress1()
{

View File

@ -17,7 +17,7 @@ namespace osu.Desktop
{
internal class OsuGameDesktop : OsuGame
{
private VersionManager versionManager;
private readonly VersionManager versionManager;
public OsuGameDesktop(string[] args = null)
: base(args)

View File

@ -12,7 +12,7 @@ namespace osu.Game.Modes.Catch.Objects.Drawable
{
internal class DrawableFruit : Sprite
{
private CatchBaseHit h;
private readonly CatchBaseHit h;
public DrawableFruit(CatchBaseHit h)
{

View File

@ -13,15 +13,15 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
{
public class DrawableHitCircle : DrawableOsuHitObject, IDrawableHitObjectWithProxiedApproach
{
private OsuHitObject osuObject;
private readonly OsuHitObject osuObject;
public ApproachCircle ApproachCircle;
private CirclePiece circle;
private RingPiece ring;
private FlashPiece flash;
private ExplodePiece explode;
private NumberPiece number;
private GlowPiece glow;
private readonly CirclePiece circle;
private readonly RingPiece ring;
private readonly FlashPiece flash;
private readonly ExplodePiece explode;
private readonly NumberPiece number;
private readonly GlowPiece glow;
public DrawableHitCircle(OsuHitObject h) : base(h)
{

View File

@ -13,18 +13,18 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
{
public class DrawableSlider : DrawableOsuHitObject, IDrawableHitObjectWithProxiedApproach
{
private Slider slider;
private readonly Slider slider;
private DrawableHitCircle initialCircle;
private readonly DrawableHitCircle initialCircle;
private List<ISliderProgress> components = new List<ISliderProgress>();
private readonly List<ISliderProgress> components = new List<ISliderProgress>();
private Container<DrawableSliderTick> ticks;
private readonly Container<DrawableSliderTick> ticks;
private SliderBody body;
private SliderBall ball;
private readonly SliderBody body;
private readonly SliderBall ball;
private SliderBouncer bouncer2;
private readonly SliderBouncer bouncer2;
public DrawableSlider(Slider s) : base(s)
{

View File

@ -18,7 +18,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
{
public class DrawableSliderTick : DrawableOsuHitObject
{
private SliderTick sliderTick;
private readonly SliderTick sliderTick;
public double FadeInTime;
public double FadeOutTime;

View File

@ -15,12 +15,12 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
{
public class DrawableSpinner : DrawableOsuHitObject
{
private Spinner spinner;
private readonly Spinner spinner;
private SpinnerDisc disc;
private SpinnerBackground background;
private Container circleContainer;
private DrawableHitCircle circle;
private readonly SpinnerDisc disc;
private readonly SpinnerBackground background;
private readonly Container circleContainer;
private readonly DrawableHitCircle circle;
public DrawableSpinner(Spinner s) : base(s)
{
@ -108,7 +108,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
private Vector2 scaleToCircle => circle.Scale * circle.DrawWidth / DrawWidth * 0.95f;
private float spinsPerMinuteNeeded = 100 + 5 * 15; //TODO: read per-map OD and place it on the 5
private readonly float spinsPerMinuteNeeded = 100 + 5 * 15; //TODO: read per-map OD and place it on the 5
private float rotationsNeeded => (float)(spinsPerMinuteNeeded * (spinner.EndTime - spinner.StartTime) / 60000f);

View File

@ -17,8 +17,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
public class HitExplosion : FillFlowContainer
{
private readonly OsuJudgementInfo judgement;
private SpriteText line1;
private SpriteText line2;
private readonly SpriteText line1;
private readonly SpriteText line2;
public HitExplosion(OsuJudgementInfo judgement, OsuHitObject h = null)
{

View File

@ -11,7 +11,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
{
public class ApproachCircle : Container
{
private Sprite approachCircle;
private readonly Sprite approachCircle;
public ApproachCircle()
{

View File

@ -14,7 +14,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
{
public class CirclePiece : Container
{
private Sprite disc;
private readonly Sprite disc;
public Func<bool> Hit;

View File

@ -11,7 +11,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
{
public class GlowPiece : Container
{
private Sprite layer;
private readonly Sprite layer;
public GlowPiece()
{

View File

@ -12,7 +12,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
{
public class NumberPiece : Container
{
private SpriteText number;
private readonly SpriteText number;
public string Text
{

View File

@ -13,7 +13,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
public class SliderBall : CircularContainer, ISliderProgress
{
private readonly Slider slider;
private Box follow;
private readonly Box follow;
private const float width = 128;

View File

@ -18,8 +18,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
{
public class SliderBody : Container, ISliderProgress
{
private Path path;
private BufferedContainer container;
private readonly Path path;
private readonly BufferedContainer container;
public float PathWidth
{
@ -33,7 +33,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
public double? SnakedStart { get; private set; }
public double? SnakedEnd { get; private set; }
private Slider slider;
private readonly Slider slider;
public SliderBody(Slider s)
{
slider = s;
@ -122,7 +122,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
path.Texture = texture;
}
private List<Vector2> currentCurve = new List<Vector2>();
private readonly List<Vector2> currentCurve = new List<Vector2>();
private bool updateSnaking(double p0, double p1)
{
if (SnakedStart == p0 && SnakedEnd == p1) return false;

View File

@ -11,7 +11,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
{
private readonly Slider slider;
private readonly bool isEnd;
private TextAwesome icon;
private readonly TextAwesome icon;
public SliderBouncer(Slider slider, bool isEnd)
{

View File

@ -47,11 +47,11 @@ namespace osu.Game.Modes.Osu.Objects
internal int MaxCombo = 1;
private float scalingFactor;
private readonly float scalingFactor;
private float lazySliderLength;
private Vector2 startPosition;
private Vector2 endPosition;
private readonly Vector2 startPosition;
private readonly Vector2 endPosition;
internal OsuHitObjectDifficulty(OsuHitObject baseHitObject)
{

View File

@ -20,7 +20,7 @@ namespace osu.Game.Modes.Osu
private const float spin_radius = 50;
private Beatmap<OsuHitObject> beatmap;
private readonly Beatmap<OsuHitObject> beatmap;
public OsuAutoReplay(Beatmap<OsuHitObject> beatmap)
{
@ -37,11 +37,11 @@ namespace osu.Game.Modes.Osu
}
}
private static IComparer<LegacyReplayFrame> replayFrameComparer = new LegacyReplayFrameComparer();
private static readonly IComparer<LegacyReplayFrame> replay_frame_comparer = new LegacyReplayFrameComparer();
private int findInsertionIndex(LegacyReplayFrame frame)
{
int index = Frames.BinarySearch(frame, replayFrameComparer);
int index = Frames.BinarySearch(frame, replay_frame_comparer);
if (index < 0)
{

View File

@ -17,9 +17,9 @@ namespace osu.Game.Modes.Osu.UI
{
public class OsuPlayfield : Playfield<OsuHitObject, OsuJudgementInfo>
{
private Container approachCircles;
private Container judgementLayer;
private ConnectionRenderer<OsuHitObject> connectionLayer;
private readonly Container approachCircles;
private readonly Container judgementLayer;
private readonly ConnectionRenderer<OsuHitObject> connectionLayer;
public override Vector2 Size
{

View File

@ -12,7 +12,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
{
internal class DrawableTaikoHit : Sprite
{
private TaikoHitObject h;
private readonly TaikoHitObject h;
public DrawableTaikoHit(TaikoHitObject h)
{

View File

@ -21,12 +21,12 @@ namespace osu.Game.Beatmaps.Drawables
public class BeatmapPanel : Panel
{
public BeatmapInfo Beatmap;
private Sprite background;
private readonly Sprite background;
public Action<BeatmapPanel> GainedSelection;
public Action<BeatmapPanel> StartRequested;
private Triangles triangles;
private StarCounter starCounter;
private readonly Triangles triangles;
private readonly StarCounter starCounter;
protected override void Selected()
{

View File

@ -20,11 +20,12 @@ namespace osu.Game.Beatmaps.Drawables
public class BeatmapSetHeader : Panel
{
public Action<BeatmapSetHeader> GainedSelection;
private SpriteText title, artist;
private readonly SpriteText title;
private readonly SpriteText artist;
private OsuConfigManager config;
private Bindable<bool> preferUnicode;
private WorkingBeatmap beatmap;
private FillFlowContainer difficultyIcons;
private readonly WorkingBeatmap beatmap;
private readonly FillFlowContainer difficultyIcons;
public BeatmapSetHeader(WorkingBeatmap beatmap)
{

View File

@ -18,7 +18,7 @@ namespace osu.Game.Beatmaps.Drawables
public override bool RemoveWhenNotAlive => false;
private Container nestedContainer;
private readonly Container nestedContainer;
protected override Container<Drawable> Content => nestedContainer;

View File

@ -21,9 +21,9 @@ namespace osu.Game.Beatmaps.IO
OsuLegacyDecoder.Register();
}
private Stream archiveStream;
private ZipFile archive;
private Beatmap firstMap;
private readonly Stream archiveStream;
private readonly ZipFile archive;
private readonly Beatmap firstMap;
public OszArchiveReader(Stream archiveStream)
{

View File

@ -42,7 +42,7 @@ namespace osu.Game.Beatmaps
protected abstract Track GetTrack();
private Beatmap beatmap;
private object beatmapLock = new object();
private readonly object beatmapLock = new object();
public Beatmap Beatmap
{
get
@ -54,7 +54,7 @@ namespace osu.Game.Beatmaps
}
}
private object backgroundLock = new object();
private readonly object backgroundLock = new object();
private Texture background;
public Texture Background
{
@ -68,7 +68,7 @@ namespace osu.Game.Beatmaps
}
private Track track;
private object trackLock = new object();
private readonly object trackLock = new object();
public Track Track
{
get

View File

@ -21,7 +21,7 @@ namespace osu.Game.Database
public class BeatmapDatabase
{
private SQLiteConnection connection { get; }
private Storage storage;
private readonly Storage storage;
public event Action<BeatmapSetInfo> BeatmapSetAdded;
public event Action<BeatmapSetInfo> BeatmapSetRemoved;

View File

@ -14,7 +14,7 @@ namespace osu.Game.Graphics.Backgrounds
{
public Sprite Sprite;
private string textureName;
private readonly string textureName;
public Background(string textureName = @"")
{

View File

@ -31,7 +31,7 @@ namespace osu.Game.Graphics.Containers
});
}
private Container content;
private readonly Container content;
private InputManager input;
protected override Container<Drawable> Content => content;

View File

@ -31,10 +31,10 @@ namespace osu.Game.Graphics.Cursor
private float time;
private TrailDrawNodeSharedData trailDrawNodeSharedData = new TrailDrawNodeSharedData();
private readonly TrailDrawNodeSharedData trailDrawNodeSharedData = new TrailDrawNodeSharedData();
private const int max_sprites = 2048;
private TrailPart[] parts = new TrailPart[max_sprites];
private readonly TrailPart[] parts = new TrailPart[max_sprites];
private Vector2? lastPosition;
@ -163,7 +163,7 @@ namespace osu.Game.Graphics.Cursor
public float Time;
public TrailDrawNodeSharedData Shared;
public TrailPart[] Parts = new TrailPart[max_sprites];
public readonly TrailPart[] Parts = new TrailPart[max_sprites];
public Vector2 Size;
public TrailDrawNode()

View File

@ -81,9 +81,14 @@ namespace osu.Game.Graphics.UserInterface
public SampleChannel SampleClick, SampleHover;
private Container backgroundContainer, colourContainer, glowContainer;
private Box leftGlow, centerGlow, rightGlow, background;
private SpriteText spriteText;
private readonly Container backgroundContainer;
private readonly Container colourContainer;
private readonly Container glowContainer;
private readonly Box leftGlow;
private readonly Box centerGlow;
private readonly Box rightGlow;
private readonly Box background;
private readonly SpriteText spriteText;
private Vector2 hoverSpacing => new Vector2(3f, 0f);
private bool didClick; // Used for making sure that the OnMouseDown animation can call instead of OnHoverLost's when clicking

View File

@ -18,7 +18,7 @@ namespace osu.Game.Graphics.UserInterface
public const float COLLAPSED_SIZE = 20;
public const float EXPANDED_SIZE = 40;
private Box fill;
private readonly Box fill;
private const float border_width = 3;
private Color4 glowingColour, idleColour;

View File

@ -64,8 +64,8 @@ namespace osu.Game.Graphics.UserInterface
}
}
private Nub nub;
private SpriteText labelSpriteText;
private readonly Nub nub;
private readonly SpriteText labelSpriteText;
private SampleChannel sampleChecked;
private SampleChannel sampleUnchecked;

View File

@ -85,7 +85,7 @@ namespace osu.Game.Graphics.UserInterface
private Color4? accentColour;
private TextAwesome chevron;
private readonly TextAwesome chevron;
protected override void FormatForeground(bool hover = false)
{
@ -116,7 +116,7 @@ namespace osu.Game.Graphics.UserInterface
protected class OsuDropdownHeader : DropdownHeader
{
private SpriteText label;
private readonly SpriteText label;
protected override string Label
{
get { return label.Text; }

View File

@ -18,7 +18,7 @@ namespace osu.Game.Graphics.UserInterface
public class PasswordMaskChar : Container
{
private CircularContainer circle;
private readonly CircularContainer circle;
public PasswordMaskChar(float size)
{

View File

@ -19,8 +19,9 @@ namespace osu.Game.Graphics.UserInterface
private SampleChannel sample;
private double lastSampleTime;
private Nub nub;
private Box leftBox, rightBox;
private readonly Nub nub;
private readonly Box leftBox;
private readonly Box rightBox;
public OsuSliderBar()
{

View File

@ -59,8 +59,8 @@ namespace osu.Game.Graphics.UserInterface
private class OsuTabItem : TabItem<T>
{
private SpriteText text;
private Box box;
private readonly SpriteText text;
private readonly Box box;
private Color4? accentColour;
public Color4 AccentColour

View File

@ -147,7 +147,7 @@ namespace osu.Game.Graphics.UserInterface
private class Star : Container
{
public TextAwesome Icon;
public readonly TextAwesome Icon;
public Star()
{
Size = new Vector2(star_size);

View File

@ -16,7 +16,7 @@ namespace osu.Game.Graphics.UserInterface
{
public class TwoLayerButton : ClickableContainer
{
private TextAwesome icon;
private readonly TextAwesome icon;
public Box IconLayer;
public Box TextLayer;
@ -29,11 +29,11 @@ namespace osu.Game.Graphics.UserInterface
public static readonly Vector2 SIZE_EXTENDED = new Vector2(140, 50);
public static readonly Vector2 SIZE_RETRACTED = new Vector2(100, 50);
public SampleChannel ActivationSound;
private SpriteText text;
private readonly SpriteText text;
public Color4 HoverColour;
private Container c1;
private Container c2;
private readonly Container c1;
private readonly Container c2;
public Color4 BackgroundColour
{

View File

@ -15,7 +15,7 @@ namespace osu.Game.Graphics.UserInterface.Volume
{
internal class VolumeControl : OverlayContainer
{
private VolumeMeter volumeMeterMaster;
private readonly VolumeMeter volumeMeterMaster;
protected override bool HideOnEscape => false;
@ -89,8 +89,8 @@ namespace osu.Game.Graphics.UserInterface.Volume
private ScheduledDelegate popOutDelegate;
private VolumeMeter volumeMeterEffect;
private VolumeMeter volumeMeterMusic;
private readonly VolumeMeter volumeMeterEffect;
private readonly VolumeMeter volumeMeterMusic;
protected override void PopIn()
{

View File

@ -15,7 +15,7 @@ namespace osu.Game.Graphics.UserInterface.Volume
{
internal class VolumeMeter : Container
{
private Box meterFill;
private readonly Box meterFill;
public BindableDouble Bindable { get; } = new BindableDouble();
public VolumeMeter(string meterName)

View File

@ -18,7 +18,7 @@ namespace osu.Game.IO.Legacy
/// handle null strings and simplify use with ISerializable. </summary>
public class SerializationReader : BinaryReader
{
private Stream stream;
private readonly Stream stream;
public SerializationReader(Stream s)
: base(s, Encoding.UTF8)

View File

@ -10,7 +10,7 @@ namespace osu.Game.IPC
{
public class BeatmapIPCChannel : IpcChannel<BeatmapImportMessage>
{
private BeatmapDatabase beatmaps;
private readonly BeatmapDatabase beatmaps;
public BeatmapIPCChannel(IIpcHost host, BeatmapDatabase beatmaps = null)
: base(host)

View File

@ -10,7 +10,7 @@ namespace osu.Game.IPC
{
public class ScoreIPCChannel : IpcChannel<ScoreImportMessage>
{
private ScoreDatabase scores;
private readonly ScoreDatabase scores;
public ScoreIPCChannel(IIpcHost host, ScoreDatabase scores = null)
: base(host)

View File

@ -8,10 +8,10 @@ namespace osu.Game.Modes.Objects
{
public class BezierApproximator
{
private int count;
private List<Vector2> controlPoints;
private Vector2[] subdivisionBuffer1;
private Vector2[] subdivisionBuffer2;
private readonly int count;
private readonly List<Vector2> controlPoints;
private readonly Vector2[] subdivisionBuffer1;
private readonly Vector2[] subdivisionBuffer2;
private const float tolerance = 0.25f;
private const float tolerance_sq = tolerance * tolerance;

View File

@ -10,9 +10,9 @@ namespace osu.Game.Modes.Objects
{
public class CircularArcApproximator
{
private Vector2 a;
private Vector2 b;
private Vector2 c;
private readonly Vector2 a;
private readonly Vector2 b;
private readonly Vector2 c;
private int amountPoints;

View File

@ -19,8 +19,8 @@ namespace osu.Game.Modes.Objects
public Vector2 Offset;
private List<Vector2> calculatedPath = new List<Vector2>();
private List<double> cumulativeLength = new List<double>();
private readonly List<Vector2> calculatedPath = new List<Vector2>();
private readonly List<double> cumulativeLength = new List<double>();
private List<Vector2> calculateSubpath(List<Vector2> subControlPoints)
{

View File

@ -21,9 +21,9 @@ namespace osu.Game.Modes
public abstract class Ruleset
{
private static ConcurrentDictionary<PlayMode, Type> availableRulesets = new ConcurrentDictionary<PlayMode, Type>();
private static readonly ConcurrentDictionary<PlayMode, Type> available_rulesets = new ConcurrentDictionary<PlayMode, Type>();
public static IEnumerable<PlayMode> PlayModes => availableRulesets.Keys;
public static IEnumerable<PlayMode> PlayModes => available_rulesets.Keys;
public virtual IEnumerable<BeatmapStatistic> GetBeatmapStatistics(WorkingBeatmap beatmap) => new BeatmapStatistic[] { };
@ -35,7 +35,7 @@ namespace osu.Game.Modes
public abstract ScoreProcessor CreateScoreProcessor();
public static void Register(Ruleset ruleset) => availableRulesets.TryAdd(ruleset.PlayMode, ruleset.GetType());
public static void Register(Ruleset ruleset) => available_rulesets.TryAdd(ruleset.PlayMode, ruleset.GetType());
protected abstract PlayMode PlayMode { get; }
@ -49,7 +49,7 @@ namespace osu.Game.Modes
{
Type type;
if (!availableRulesets.TryGetValue(mode, out type))
if (!available_rulesets.TryGetValue(mode, out type))
return null;
return Activator.CreateInstance(type) as Ruleset;

View File

@ -155,7 +155,7 @@ namespace osu.Game.Modes.UI
/// </summary>
protected Playfield<TObject, TJudgement> Playfield;
private Container content;
private readonly Container content;
protected HitRenderer(WorkingBeatmap beatmap)
: base(beatmap)

View File

@ -10,7 +10,8 @@ namespace osu.Game.Modes.UI
{
public class ModIcon : Container
{
private TextAwesome modIcon, background;
private readonly TextAwesome modIcon;
private readonly TextAwesome background;
private float iconSize = 80;
public float IconSize

View File

@ -23,7 +23,7 @@ namespace osu.Game.Modes.UI
internal Container<Drawable> ScaledContent;
protected override Container<Drawable> Content => content;
private Container<Drawable> content;
private readonly Container<Drawable> content;
/// <summary>
/// A container for keeping track of DrawableHitObjects.

View File

@ -15,7 +15,7 @@ namespace osu.Game.Modes.UI
{
public class StandardHealthDisplay : HealthDisplay
{
private Container fill;
private readonly Container fill;
public StandardHealthDisplay()
{

View File

@ -17,7 +17,7 @@ namespace osu.Game.Online.API
{
public class APIAccess : IUpdateable
{
private OAuth authentication;
private readonly OAuth authentication;
public string Endpoint = @"https://new.ppy.sh";
private const string client_id = @"5";
@ -44,9 +44,9 @@ namespace osu.Game.Online.API
protected bool HasLogin => Token != null || !string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password);
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable (should dispose of this or at very least keep a reference).
private Thread thread;
private readonly Thread thread;
private Logger log;
private readonly Logger log;
public APIAccess()
{
@ -57,7 +57,7 @@ namespace osu.Game.Online.API
thread.Start();
}
private List<IOnlineComponent> components = new List<IOnlineComponent>();
private readonly List<IOnlineComponent> components = new List<IOnlineComponent>();
public void Register(IOnlineComponent component)
{

View File

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

View File

@ -14,8 +14,8 @@ namespace osu.Game.Online.Chat.Drawables
public class DrawableChannel : Container
{
private readonly Channel channel;
private FillFlowContainer flow;
private ScrollContainer scroll;
private readonly FillFlowContainer flow;
private readonly ScrollContainer scroll;
public DrawableChannel(Channel channel)
{

View File

@ -60,7 +60,7 @@ namespace osu.Game
public Bindable<PlayMode> PlayMode;
private string[] args;
private readonly string[] args;
private OptionsOverlay options;

View File

@ -31,11 +31,11 @@ namespace osu.Game.Overlays
private ScheduledDelegate messageRequest;
private Container content;
private readonly Container content;
protected override Container<Drawable> Content => content;
private FocusedTextBox inputTextBox;
private readonly FocusedTextBox inputTextBox;
private APIAccess api;

View File

@ -27,10 +27,12 @@ namespace osu.Game.Overlays.Dialog
private readonly Vector2 ringMinifiedSize = new Vector2(20f);
private readonly Vector2 buttonsEnterSpacing = new Vector2(0f, 50f);
private Container content, ring;
private FillFlowContainer<PopupDialogButton> buttonsContainer;
private TextAwesome iconText;
private SpriteText header, body;
private readonly Container content;
private readonly Container ring;
private readonly FillFlowContainer<PopupDialogButton> buttonsContainer;
private readonly TextAwesome iconText;
private readonly SpriteText header;
private readonly SpriteText body;
public FontAwesome Icon
{

View File

@ -13,7 +13,7 @@ namespace osu.Game.Overlays
{
public class DialogOverlay : FocusedOverlayContainer
{
private Container dialogContainer;
private readonly Container dialogContainer;
private PopupDialog currentDialog;
public void Push(PopupDialog dialog)

View File

@ -11,7 +11,7 @@ namespace osu.Game.Overlays
{
public class DragBar : Container
{
private Box fill;
private readonly Box fill;
public Action<float> SeekRequested;
private bool isDragging;

View File

@ -23,8 +23,8 @@ namespace osu.Game.Overlays.Mods
public class ModButton : FillFlowContainer
{
private ModIcon foregroundIcon { get; set; }
private SpriteText text;
private Container<ModIcon> iconsContainer;
private readonly SpriteText text;
private readonly Container<ModIcon> iconsContainer;
private SampleChannel sampleOn, sampleOff;
public Action<Mod> Action; // Passed the selected mod or null if none

View File

@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Mods
{
public abstract class ModSection : Container
{
private OsuSpriteText headerLabel;
private readonly OsuSpriteText headerLabel;
public FillFlowContainer<ModButton> ButtonsContainer { get; }

View File

@ -30,10 +30,11 @@ namespace osu.Game.Overlays.Mods
private Color4 lowMultiplierColour, highMultiplierColour;
private OsuSpriteText rankedLabel, multiplierLabel;
private FillFlowContainer rankedMultiplerContainer;
private readonly OsuSpriteText rankedLabel;
private readonly OsuSpriteText multiplierLabel;
private readonly FillFlowContainer rankedMultiplerContainer;
private FillFlowContainer<ModSection> modSectionsContainer;
private readonly FillFlowContainer<ModSection> modSectionsContainer;
public readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>();

View File

@ -35,7 +35,7 @@ namespace osu.Game.Overlays
private SpriteText title, artist;
private List<BeatmapSetInfo> playList;
private List<BeatmapInfo> playHistory = new List<BeatmapInfo>();
private readonly List<BeatmapInfo> playHistory = new List<BeatmapInfo>();
private int playListIndex;
private int playHistoryIndex = -1;
@ -415,8 +415,8 @@ namespace osu.Game.Overlays
private class MusicControllerBackground : BufferedContainer
{
private Sprite sprite;
private WorkingBeatmap beatmap;
private readonly Sprite sprite;
private readonly WorkingBeatmap beatmap;
public MusicControllerBackground(WorkingBeatmap beatmap = null)
{

View File

@ -35,9 +35,9 @@ namespace osu.Game.Overlays.Notifications
public virtual bool DisplayOnTop => true;
protected NotificationLight Light;
private CloseButton closeButton;
private readonly CloseButton closeButton;
protected Container IconContent;
private Container content;
private readonly Container content;
protected override Container<Drawable> Content => content;

View File

@ -135,7 +135,7 @@ namespace osu.Game.Overlays.Notifications
private class ClearAllButton : ClickableContainer
{
private OsuSpriteText text;
private readonly OsuSpriteText text;
public ClearAllButton()
{

View File

@ -104,12 +104,12 @@ namespace osu.Game.Overlays.Notifications
public override bool DisplayOnTop => false;
private ProgressBar progressBar;
private readonly ProgressBar progressBar;
private Color4 colourQueued;
private Color4 colourActive;
private Color4 colourCancelled;
private SpriteText textDrawable;
private readonly SpriteText textDrawable;
public ProgressNotification()
{

View File

@ -34,8 +34,8 @@ namespace osu.Game.Overlays.Notifications
}
}
private SpriteText textDrawable;
private TextAwesome iconDrawable;
private readonly SpriteText textDrawable;
private readonly TextAwesome iconDrawable;
protected Box IconBackgound;

View File

@ -15,8 +15,8 @@ namespace osu.Game.Overlays.Options
{
public class OptionDropdown<T> : FillFlowContainer
{
private Dropdown<T> dropdown;
private SpriteText text;
private readonly Dropdown<T> dropdown;
private readonly SpriteText text;
public string LabelText
{

View File

@ -14,8 +14,8 @@ namespace osu.Game.Overlays.Options
{
public class OptionSlider<T> : FillFlowContainer where T : struct
{
private SliderBar<T> slider;
private SpriteText text;
private readonly SliderBar<T> slider;
private readonly SpriteText text;
public string LabelText
{

View File

@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Options
public abstract FontAwesome Icon { get; }
public abstract string Header { get; }
private SpriteText headerLabel;
private readonly SpriteText headerLabel;
protected OptionsSection()
{

View File

@ -13,7 +13,7 @@ namespace osu.Game.Overlays.Options
{
protected override Container<Drawable> Content => content;
private Container<Drawable> content;
private readonly Container<Drawable> content;
protected abstract string Header { get; }

View File

@ -15,7 +15,7 @@ namespace osu.Game.Overlays.Options
{
public class Sidebar : Container
{
private FillFlowContainer content;
private readonly FillFlowContainer content;
internal const float DEFAULT_WIDTH = ToolbarButton.WIDTH;
internal const int EXPANDED_WIDTH = 200;
protected override Container<Drawable> Content => content;

View File

@ -16,11 +16,11 @@ namespace osu.Game.Overlays.Options
{
public class SidebarButton : Container
{
private TextAwesome drawableIcon;
private SpriteText headerText;
private Box backgroundBox;
private Box selectionIndicator;
private Container text;
private readonly TextAwesome drawableIcon;
private readonly SpriteText headerText;
private readonly Box backgroundBox;
private readonly Box selectionIndicator;
private readonly Container text;
public Action Action;
private OptionsSection section;

View File

@ -23,8 +23,8 @@ namespace osu.Game.Overlays.Toolbar
public Action OnHome;
public Action<PlayMode> OnPlayModeChange;
private ToolbarModeSelector modeSelector;
private ToolbarUserArea userArea;
private readonly ToolbarModeSelector modeSelector;
private readonly ToolbarUserArea userArea;
protected override bool HideOnEscape => false;
@ -90,8 +90,8 @@ namespace osu.Game.Overlays.Toolbar
public class ToolbarBackground : Container
{
private Box solidBackground;
private Box gradientBackground;
private readonly Box solidBackground;
private readonly Box gradientBackground;
public ToolbarBackground()
{

View File

@ -63,9 +63,9 @@ namespace osu.Game.Overlays.Toolbar
protected TextAwesome DrawableIcon;
protected SpriteText DrawableText;
protected Box HoverBackground;
private FillFlowContainer tooltipContainer;
private SpriteText tooltip1;
private SpriteText tooltip2;
private readonly FillFlowContainer tooltipContainer;
private readonly SpriteText tooltip1;
private readonly SpriteText tooltip2;
protected FillFlowContainer Flow;
private SampleChannel sampleClick;

View File

@ -19,8 +19,8 @@ namespace osu.Game.Overlays.Toolbar
{
private const float padding = 10;
private FillFlowContainer modeButtons;
private Drawable modeButtonLine;
private readonly FillFlowContainer modeButtons;
private readonly Drawable modeButtonLine;
private ToolbarModeButton activeButton;
public Action<PlayMode> OnPlayModeChange;

View File

@ -11,7 +11,7 @@ namespace osu.Game.Overlays.Toolbar
{
internal class ToolbarOverlayToggleButton : ToolbarButton
{
private Box stateBackground;
private readonly Box stateBackground;
private OverlayContainer stateContainer;

View File

@ -11,7 +11,7 @@ namespace osu.Game.Overlays.Toolbar
internal class ToolbarUserArea : Container
{
public LoginOverlay LoginOverlay;
private ToolbarUserButton button;
private readonly ToolbarUserButton button;
public override RectangleF BoundingBox => button.BoundingBox;

View File

@ -14,7 +14,7 @@ namespace osu.Game.Overlays.Toolbar
{
internal class ToolbarUserButton : ToolbarButton, IOnlineComponent
{
private Avatar avatar;
private readonly Avatar avatar;
public ToolbarUserButton()
{

View File

@ -20,9 +20,12 @@ namespace osu.Game.Overlays
private const EasingTypes easing_show = EasingTypes.OutSine;
private const EasingTypes easing_hide = EasingTypes.InSine;
private Wave firstWave, secondWave, thirdWave, fourthWave;
private readonly Wave firstWave;
private readonly Wave secondWave;
private readonly Wave thirdWave;
private readonly Wave fourthWave;
private Container<Wave> wavesContainer;
private readonly Container<Wave> wavesContainer;
private readonly Container contentContainer;

View File

@ -72,7 +72,7 @@ namespace osu.Game.Screens.Backgrounds
private class BeatmapBackground : Background
{
private WorkingBeatmap beatmap;
private readonly WorkingBeatmap beatmap;
public BeatmapBackground(WorkingBeatmap beatmap)
{

View File

@ -19,14 +19,14 @@ namespace osu.Game.Screens
{
public class ScreenWhiteBox : OsuScreen
{
private BackButton popButton;
private readonly BackButton popButton;
private const double transition_time = 1000;
protected virtual IEnumerable<Type> PossibleChildren => null;
private Container textContainer;
private Box box;
private readonly Container textContainer;
private readonly Box box;
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg2");

View File

@ -26,13 +26,13 @@ namespace osu.Game.Screens.Menu
/// </summary>
public class Button : Container, IStateful<ButtonState>
{
private Container iconText;
private Container box;
private Box boxHoverLayer;
private TextAwesome icon;
private string internalName;
private Action clickAction;
private Key triggerKey;
private readonly Container iconText;
private readonly Container box;
private readonly Box boxHoverLayer;
private readonly TextAwesome icon;
private readonly string internalName;
private readonly Action clickAction;
private readonly Key triggerKey;
private SampleChannel sampleClick;
protected override bool InternalContains(Vector2 screenSpacePos) => box.Contains(screenSpacePos);

View File

@ -32,7 +32,7 @@ namespace osu.Game.Screens.Menu
private Toolbar toolbar;
private FlowContainerWithOrigin buttonFlow;
private readonly FlowContainerWithOrigin buttonFlow;
//todo: make these non-internal somehow.
internal const float BUTTON_AREA_HEIGHT = 100;
@ -41,16 +41,16 @@ namespace osu.Game.Screens.Menu
public const int EXIT_DELAY = 3000;
private OsuLogo osuLogo;
private Drawable iconFacade;
private Container buttonArea;
private Box buttonAreaBackground;
private readonly OsuLogo osuLogo;
private readonly Drawable iconFacade;
private readonly Container buttonArea;
private readonly Box buttonAreaBackground;
private Button backButton;
private Button settingsButton;
private readonly Button backButton;
private readonly Button settingsButton;
private List<Button> buttonsTopLevel = new List<Button>();
private List<Button> buttonsPlay = new List<Button>();
private readonly List<Button> buttonsTopLevel = new List<Button>();
private readonly List<Button> buttonsPlay = new List<Button>();
public ButtonSystem()
{

View File

@ -16,7 +16,7 @@ namespace osu.Game.Screens.Menu
internal class Disclaimer : OsuScreen
{
private Intro intro;
private TextAwesome icon;
private readonly TextAwesome icon;
private Color4 iconColour;
internal override bool ShowOverlays => false;

View File

@ -16,7 +16,7 @@ namespace osu.Game.Screens.Menu
{
public class Intro : OsuScreen
{
private OsuLogo logo;
private readonly OsuLogo logo;
/// <summary>
/// Whether we have loaded the menu previously.

View File

@ -22,11 +22,11 @@ namespace osu.Game.Screens.Menu
{
public class MainMenu : OsuScreen
{
private ButtonSystem buttons;
private readonly ButtonSystem buttons;
internal override bool ShowOverlays => buttons.State != MenuState.Initial;
private BackgroundScreen background;
private readonly BackgroundScreen background;
private Screen songSelect;
protected override BackgroundScreen CreateBackground() => background;

View File

@ -25,22 +25,22 @@ namespace osu.Game.Screens.Menu
{
public Color4 OsuPink = OsuColour.FromHex(@"e967a1");
private Sprite logo;
private CircularContainer logoContainer;
private Container logoBounceContainer;
private Container logoHoverContainer;
private readonly Sprite logo;
private readonly CircularContainer logoContainer;
private readonly Container logoBounceContainer;
private readonly Container logoHoverContainer;
private SampleChannel sampleClick;
private Container colourAndTriangles;
private readonly Container colourAndTriangles;
public Action Action;
public float SizeForFlow => logo == null ? 0 : logo.DrawSize.X * logo.Scale.X * logoBounceContainer.Scale.X * logoHoverContainer.Scale.X * 0.78f;
private Sprite ripple;
private readonly Sprite ripple;
private Container rippleContainer;
private readonly Container rippleContainer;
public bool Triangles
{
@ -62,7 +62,7 @@ namespace osu.Game.Screens.Menu
}
public bool Interactive = true;
private Box flashLayer;
private readonly Box flashLayer;
public OsuLogo()
{

View File

@ -106,7 +106,7 @@ namespace osu.Game.Screens.Play
public class Receptor : Drawable
{
private KeyCounterCollection target;
private readonly KeyCounterCollection target;
public Receptor(KeyCounterCollection target)
{

View File

@ -13,10 +13,10 @@ namespace osu.Game.Screens.Play.Pause
{
public class PauseProgressBar : Container
{
private Color4 fillColour = new Color4(221, 255, 255, 255);
private Color4 glowColour = new Color4(221, 255, 255, 150);
private readonly Color4 fillColour = new Color4(221, 255, 255, 255);
private readonly Color4 glowColour = new Color4(221, 255, 255, 150);
private Container fill;
private readonly Container fill;
private WorkingBeatmap current;
[BackgroundDependencyLoader]

View File

@ -42,7 +42,7 @@ namespace osu.Game.Screens.Play
public int RestartCount;
private double pauseCooldown = 1000;
private readonly double pauseCooldown = 1000;
private double lastPauseActionTime;
private bool canPause => Time.Current >= lastPauseActionTime + pauseCooldown;

View File

@ -9,7 +9,7 @@ namespace osu.Game.Screens.Play
{
public class PlayerInputManager : PassThroughInputManager
{
private ManualClock clock = new ManualClock();
private readonly ManualClock clock = new ManualClock();
private IFrameBasedClock parentClock;
private ReplayInputHandler replayInputHandler;

View File

@ -21,7 +21,7 @@ namespace osu.Game.Screens.Play
public class PlayerLoader : OsuScreen
{
private readonly Player player;
private OsuLogo logo;
private readonly OsuLogo logo;
private BeatmapMetadataDisplay info;
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);

View File

@ -60,18 +60,18 @@ namespace osu.Game.Screens.Select
}
}
private List<float> yPositions = new List<float>();
private readonly List<float> yPositions = new List<float>();
/// <summary>
/// Required for now unfortunately.
/// </summary>
private BeatmapDatabase database;
private Container<Panel> scrollableContent;
private readonly Container<Panel> scrollableContent;
private List<BeatmapGroup> groups = new List<BeatmapGroup>();
private readonly List<BeatmapGroup> groups = new List<BeatmapGroup>();
private List<Panel> panels = new List<Panel>();
private readonly List<Panel> panels = new List<Panel>();
private BeatmapGroup selectedGroup;

View File

@ -24,9 +24,9 @@ namespace osu.Game.Screens.Select
{
public Action<FilterCriteria> FilterChanged;
private OsuTabControl<SortMode> sortTabs;
private readonly OsuTabControl<SortMode> sortTabs;
private TabControl<GroupMode> groupTabs;
private readonly TabControl<GroupMode> groupTabs;
private SortMode sort = SortMode.Title;
public SortMode Sort
@ -66,7 +66,7 @@ namespace osu.Game.Screens.Select
public Action Exit;
private SearchTextBox searchTextBox;
private readonly SearchTextBox searchTextBox;
protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || groupTabs.Contains(screenSpacePos) || sortTabs.Contains(screenSpacePos);

View File

@ -17,7 +17,7 @@ namespace osu.Game.Screens.Select
{
public class Footer : Container
{
private Box modeLight;
private readonly Box modeLight;
private const float play_song_select_button_width = 100;
private const float play_song_select_button_height = 50;
@ -29,7 +29,7 @@ namespace osu.Game.Screens.Select
public Action OnBack;
public Action OnStart;
private FillFlowContainer buttons;
private readonly FillFlowContainer buttons;
public OsuLogo StartButton;

View File

@ -51,9 +51,9 @@ namespace osu.Game.Screens.Select
}
}
private SpriteText spriteText;
private Box box;
private Box light;
private readonly SpriteText spriteText;
private readonly Box box;
private readonly Box light;
public FooterButton()
{

Some files were not shown because too many files have changed in this diff Show More