From c981a4a511ac56b4c9704db60f3e9b8acf00fc4a Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 19 May 2017 19:50:45 -0300 Subject: [PATCH] Formatting --- .../Tests/TestCaseDirect.cs | 5 +--- osu.Game/Database/OnlineWorkingBeatmap.cs | 4 ++-- osu.Game/Overlays/Direct/DirectGridPanel.cs | 6 ++--- osu.Game/Overlays/Direct/DirectListPanel.cs | 12 +++++----- osu.Game/Overlays/Direct/DirectPanel.cs | 2 +- osu.Game/Overlays/Direct/FilterControl.cs | 24 +++++++++---------- osu.Game/Overlays/Direct/SortTabControl.cs | 4 ++-- osu.Game/Overlays/DirectOverlay.cs | 17 +++++++------ 8 files changed, 35 insertions(+), 39 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs index cc4dae4e9a..c68796a9ab 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs @@ -3,12 +3,9 @@ using System.Collections.Generic; using osu.Framework.Allocation; -using osu.Framework.Graphics; using osu.Framework.Testing; using osu.Game.Database; -using osu.Game.Graphics; using osu.Game.Overlays; -using osu.Game.Overlays.Dialog; using osu.Game.Overlays.Direct; namespace osu.Desktop.VisualTests.Tests @@ -41,7 +38,7 @@ namespace osu.Desktop.VisualTests.Tests { var ruleset = rulesets.GetRuleset(0); - direct.BeatmapSets = new BeatmapSetInfo[] + direct.BeatmapSets = new[] { new BeatmapSetInfo { diff --git a/osu.Game/Database/OnlineWorkingBeatmap.cs b/osu.Game/Database/OnlineWorkingBeatmap.cs index dcbe21f33c..1465c59434 100644 --- a/osu.Game/Database/OnlineWorkingBeatmap.cs +++ b/osu.Game/Database/OnlineWorkingBeatmap.cs @@ -10,8 +10,8 @@ namespace osu.Game.Database { internal class OnlineWorkingBeatmap : WorkingBeatmap { - private TextureStore textures; - private TrackManager tracks; + private readonly TextureStore textures; + private readonly TrackManager tracks; public OnlineWorkingBeatmap(BeatmapInfo beatmapInfo, TextureStore textures, TrackManager tracks) : base(beatmapInfo) { diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 65967915d6..01793df1f0 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -19,8 +19,8 @@ namespace osu.Game.Overlays.Direct { public class DirectGridPanel : DirectPanel { - private readonly float horizontal_padding = 10; - private readonly float vertical_padding = 5; + private const float horizontal_padding = 10; + private const float vertical_padding = 5; private FillFlowContainer bottomPanel; @@ -52,7 +52,7 @@ namespace osu.Game.Overlays.Direct [BackgroundDependencyLoader] private void load(OsuColour colours, LocalisationEngine localisation, TextureStore textures) { - Children = new Drawable[] + Children = new[] { new Box { diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index a17597d10a..7f215b7447 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -21,9 +21,9 @@ namespace osu.Game.Overlays.Direct { public class DirectListPanel : DirectPanel { - private readonly float horizontal_padding = 10; - private readonly float vertical_padding = 5; - private readonly float height = 70; + private const float horizontal_padding = 10; + private const float vertical_padding = 5; + private const float height = 70; public DirectListPanel(BeatmapSetInfo beatmap) : base(beatmap) { @@ -50,7 +50,7 @@ namespace osu.Game.Overlays.Direct [BackgroundDependencyLoader] private void load(LocalisationEngine localisation, TextureStore textures) { - Children = new Drawable[] + Children = new[] { new Box { @@ -101,7 +101,7 @@ namespace osu.Game.Overlays.Direct Origin = Anchor.TopRight, AutoSizeAxes = Axes.Both, Direction = FillDirection.Vertical, - Margin = new MarginPadding { Right = (height - vertical_padding * 2) + vertical_padding }, + Margin = new MarginPadding { Right = height - vertical_padding * 2 + vertical_padding }, Children = new Drawable[] { new Statistic(FontAwesome.fa_play_circle, SetInfo.Beatmaps.FirstOrDefault()?.OnlineInfo.PlayCount ?? 0) @@ -144,7 +144,7 @@ namespace osu.Game.Overlays.Direct { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, - Size = new Vector2(height - (vertical_padding * 2)), + Size = new Vector2(height - vertical_padding * 2), }, }, }, diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index ba424cee03..6959a3f421 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Direct { protected readonly BeatmapSetInfo SetInfo; - public DirectPanel(BeatmapSetInfo setInfo) + protected DirectPanel(BeatmapSetInfo setInfo) { SetInfo = setInfo; } diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index 8195f9f6ce..7ea1f2a8e1 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -51,7 +51,7 @@ namespace osu.Game.Overlays.Direct public FilterControl() { RelativeSizeAxes = Axes.X; - Height = 35 + 32 + 30 + (padding * 2); // search + mode toggle buttons + sort tabs + padding + Height = 35 + 32 + 30 + padding * 2; // search + mode toggle buttons + sort tabs + padding DisplayStyle.Value = PanelDisplayStyle.Grid; Children = new Drawable[] @@ -170,9 +170,9 @@ namespace osu.Game.Overlays.Direct resultCountsContainer.FadeTo(ResultCounts == null ? 0 : 1, 200, EasingTypes.Out); if (resultCounts == null) return; - resultCountsText.Text = pluralize(@"Artist", ResultCounts.Artists) + ", " + - pluralize(@"Song", ResultCounts.Songs) + ", " + - pluralize(@"Tag", ResultCounts.Tags); + resultCountsText.Text = pluralize(@"Artist", ResultCounts?.Artists ?? 0) + ", " + + pluralize(@"Song", ResultCounts?.Songs ?? 0) + ", " + + pluralize(@"Tag", ResultCounts?.Tags ?? 0); } private string pluralize(string prefix, int value) @@ -196,7 +196,7 @@ namespace osu.Game.Overlays.Direct private class RulesetToggleButton : ClickableContainer { - private TextAwesome icon; + private readonly TextAwesome icon; private RulesetInfo ruleset; public RulesetInfo Ruleset @@ -209,11 +209,11 @@ namespace osu.Game.Overlays.Direct } } - private Bindable bindable; + private readonly Bindable bindable; - void Bindable_ValueChanged(RulesetInfo obj) + private void Bindable_ValueChanged(RulesetInfo obj) { - icon.FadeTo((Ruleset.ID == obj?.ID) ? 1f : 0.5f, 100); + icon.FadeTo(Ruleset.ID == obj?.ID ? 1f : 0.5f, 100); } public RulesetToggleButton(Bindable bindable, RulesetInfo ruleset) @@ -280,7 +280,7 @@ namespace osu.Game.Overlays.Direct icon.FadeTo(style == this.style ? 1.0f : 0.5f, 100); } - protected override void Dispose(bool isDisposing) + protected override void Dispose(bool isDisposing) { bindable.ValueChanged -= Bindable_ValueChanged; } @@ -347,9 +347,9 @@ namespace osu.Game.Overlays.Direct MyMaps, } - public enum PanelDisplayStyle - { + public enum PanelDisplayStyle + { Grid, - List, + List, } } diff --git a/osu.Game/Overlays/Direct/SortTabControl.cs b/osu.Game/Overlays/Direct/SortTabControl.cs index c6b6479923..7eb6ba4e88 100644 --- a/osu.Game/Overlays/Direct/SortTabControl.cs +++ b/osu.Game/Overlays/Direct/SortTabControl.cs @@ -27,9 +27,9 @@ namespace osu.Game.Overlays.Direct private class SortTabItem : TabItem { - private readonly float transition_duration = 100; + private const float transition_duration = 100; - private Box box; + private readonly Box box; public override bool Active { diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 81aa6b2ff5..46d19c724b 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -17,10 +17,8 @@ namespace osu.Game.Overlays public class DirectOverlay : WaveOverlayContainer { public static readonly int WIDTH_PADDING = 80; - private readonly float panel_padding = 10f; + private const float panel_padding = 10f; - private readonly Box background; - private readonly Header header; private readonly FilterControl filter; private readonly FillFlowContainer panels; @@ -30,7 +28,7 @@ namespace osu.Game.Overlays get { return beatmapSets; } set { - if (beatmapSets == value) return; + if (value == beatmapSets) return; beatmapSets = value; recreatePanels(filter.DisplayStyle.Value); @@ -54,9 +52,10 @@ namespace osu.Game.Overlays ThirdWaveColour = OsuColour.FromHex(@"005774"); FourthWaveColour = OsuColour.FromHex(@"003a4e"); + Header header = null; Children = new Drawable[] { - background = new Box + new Box { RelativeSizeAxes = Axes.Both, Colour = OsuColour.FromHex(@"485e74"), @@ -111,10 +110,10 @@ namespace osu.Game.Overlays }, }; - header.Tabs.Current.ValueChanged += (tab) => { if (tab != DirectTab.Search) filter.Search.Current.Value = @""; }; + header.Tabs.Current.ValueChanged += tab => { if (tab != DirectTab.Search) filter.Search.Current.Value = @""; }; filter.Search.Exit = Hide; - filter.Search.Current.ValueChanged += (s) => { if (s != @"") header.Tabs.Current.Value = DirectTab.Search; }; + filter.Search.Current.ValueChanged += text => { if (text != @"") header.Tabs.Current.Value = DirectTab.Search; }; filter.DisplayStyle.ValueChanged += recreatePanels; } @@ -123,8 +122,8 @@ namespace osu.Game.Overlays var p = new List(); foreach (BeatmapSetInfo b in BeatmapSets) - p.Add(displayStyle == PanelDisplayStyle.Grid ? (DirectPanel)(new DirectGridPanel(b) { Width = 400 }) : - (DirectPanel)(new DirectListPanel(b))); + p.Add(displayStyle == PanelDisplayStyle.Grid ? (DirectPanel)new DirectGridPanel(b) { Width = 400 } : + new DirectListPanel(b)); panels.Children = p; }