mirror of
https://github.com/ppy/osu.git
synced 2024-11-12 00:27:25 +08:00
Merge pull request #4356 from peppy/use-pattern-matching
Use pattern matching wherever possible
This commit is contained in:
commit
3a3c2ae21a
@ -83,8 +83,7 @@ namespace osu.Desktop
|
||||
public override void SetHost(GameHost host)
|
||||
{
|
||||
base.SetHost(host);
|
||||
var desktopWindow = host.Window as DesktopGameWindow;
|
||||
if (desktopWindow != null)
|
||||
if (host.Window is DesktopGameWindow desktopWindow)
|
||||
{
|
||||
desktopWindow.CursorState |= CursorState.Hidden;
|
||||
|
||||
|
@ -74,8 +74,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
||||
|
||||
protected override IEnumerable<ManiaHitObject> ConvertHitObject(HitObject original, IBeatmap beatmap)
|
||||
{
|
||||
var maniaOriginal = original as ManiaHitObject;
|
||||
if (maniaOriginal != null)
|
||||
if (original is ManiaHitObject maniaOriginal)
|
||||
{
|
||||
yield return maniaOriginal;
|
||||
|
||||
|
@ -128,8 +128,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing
|
||||
{
|
||||
Vector2 pos = hitObject.StackedPosition;
|
||||
|
||||
var slider = hitObject as Slider;
|
||||
if (slider != null)
|
||||
if (hitObject is Slider slider)
|
||||
{
|
||||
computeSliderCursorPosition(slider);
|
||||
pos = slider.LazyEndPosition ?? pos;
|
||||
|
@ -58,8 +58,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
h.OnNewResult += onNewResult;
|
||||
|
||||
var c = h as IDrawableHitObjectWithProxiedApproach;
|
||||
if (c != null)
|
||||
if (h is IDrawableHitObjectWithProxiedApproach c)
|
||||
{
|
||||
var original = c.ProxiedLayer;
|
||||
|
||||
|
@ -38,11 +38,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
private void updateAccentColour()
|
||||
{
|
||||
var header = Header as IHasAccentColour;
|
||||
if (header != null) header.AccentColour = accentColour;
|
||||
if (Header is IHasAccentColour header) header.AccentColour = accentColour;
|
||||
|
||||
var menu = Menu as IHasAccentColour;
|
||||
if (menu != null) menu.AccentColour = accentColour;
|
||||
if (Menu is IHasAccentColour menu) menu.AccentColour = accentColour;
|
||||
}
|
||||
|
||||
protected override DropdownHeader CreateHeader() => new OsuDropdownHeader();
|
||||
@ -154,8 +152,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
base.UpdateForegroundColour();
|
||||
|
||||
var content = Foreground.Children.FirstOrDefault() as Content;
|
||||
if (content != null) content.Chevron.Alpha = IsHovered ? 1 : 0;
|
||||
if (Foreground.Children.FirstOrDefault() is Content content) content.Chevron.Alpha = IsHovered ? 1 : 0;
|
||||
}
|
||||
|
||||
protected override Drawable CreateContent() => new Content();
|
||||
|
@ -65,8 +65,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
var dropdown = Dropdown as IHasAccentColour;
|
||||
if (dropdown != null)
|
||||
if (Dropdown is IHasAccentColour dropdown)
|
||||
dropdown.AccentColour = value;
|
||||
foreach (var i in TabContainer.Children.OfType<IHasAccentColour>())
|
||||
i.AccentColour = value;
|
||||
|
@ -602,8 +602,7 @@ namespace osu.Game
|
||||
private void loadComponentSingleFile<T>(T d, Action<T> add)
|
||||
where T : Drawable
|
||||
{
|
||||
var focused = d as FocusedOverlayContainer;
|
||||
if (focused != null)
|
||||
if (d is FocusedOverlayContainer focused)
|
||||
{
|
||||
focused.StateChanged += s =>
|
||||
{
|
||||
|
@ -119,8 +119,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
notification.Closed += notificationClosed;
|
||||
|
||||
var hasCompletionTarget = notification as IHasCompletionTarget;
|
||||
if (hasCompletionTarget != null)
|
||||
if (notification is IHasCompletionTarget hasCompletionTarget)
|
||||
hasCompletionTarget.CompletionTarget = Post;
|
||||
|
||||
var ourType = notification.GetType();
|
||||
|
@ -16,8 +16,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
|
||||
public override void ApplyToClock(IAdjustableClock clock)
|
||||
{
|
||||
var pitchAdjust = clock as IHasPitchAdjust;
|
||||
if (pitchAdjust != null)
|
||||
if (clock is IHasPitchAdjust pitchAdjust)
|
||||
pitchAdjust.PitchAdjust = 0.75;
|
||||
else
|
||||
base.ApplyToClock(clock);
|
||||
|
@ -16,8 +16,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
|
||||
public override void ApplyToClock(IAdjustableClock clock)
|
||||
{
|
||||
var pitchAdjust = clock as IHasPitchAdjust;
|
||||
if (pitchAdjust != null)
|
||||
if (clock is IHasPitchAdjust pitchAdjust)
|
||||
pitchAdjust.PitchAdjust = 1.5;
|
||||
else
|
||||
base.ApplyToClock(clock);
|
||||
|
@ -241,8 +241,7 @@ namespace osu.Game.Screens.Play
|
||||
ComboCounter?.Current.BindTo(processor.Combo);
|
||||
HealthDisplay?.Current.BindTo(processor.Health);
|
||||
|
||||
var shd = HealthDisplay as StandardHealthDisplay;
|
||||
if (shd != null)
|
||||
if (HealthDisplay is StandardHealthDisplay shd)
|
||||
processor.NewJudgement += shd.Flash;
|
||||
}
|
||||
}
|
||||
|
@ -71,8 +71,7 @@ namespace osu.Game.Storyboards
|
||||
applyCommands(drawable, getCommands(g => g.Alpha, triggeredGroups), (d, value) => d.Alpha = value, (d, value, duration, easing) => d.FadeTo(value, duration, easing));
|
||||
applyCommands(drawable, getCommands(g => g.BlendingMode, triggeredGroups), (d, value) => d.Blending = value, (d, value, duration, easing) => d.TransformBlendingMode(value, duration), false);
|
||||
|
||||
var flippable = drawable as IFlippable;
|
||||
if (flippable != null)
|
||||
if (drawable is IFlippable flippable)
|
||||
{
|
||||
applyCommands(drawable, getCommands(g => g.FlipH, triggeredGroups), (d, value) => flippable.FlipH = value, (d, value, duration, easing) => flippable.TransformFlipH(value, duration), false);
|
||||
applyCommands(drawable, getCommands(g => g.FlipV, triggeredGroups), (d, value) => flippable.FlipV = value, (d, value, duration, easing) => flippable.TransformFlipV(value, duration), false);
|
||||
|
@ -204,9 +204,11 @@
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseFormatSpecifierInFormatString/@EntryIndexedValue">WARNING</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseFormatSpecifierInInterpolation/@EntryIndexedValue">WARNING</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseNameofExpression/@EntryIndexedValue">WARNING</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseNegatedPatternMatching/@EntryIndexedValue"></s:String>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseNegatedPatternMatching/@EntryIndexRemoved">True</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseNullPropagation/@EntryIndexedValue">WARNING</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseObjectOrCollectionInitializer/@EntryIndexedValue">WARNING</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UsePatternMatching/@EntryIndexedValue">HINT</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UsePatternMatching/@EntryIndexedValue">WARNING</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseStringInterpolation/@EntryIndexedValue">WARNING</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=VariableCanBeMadeConst/@EntryIndexedValue">WARNING</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=VirtualMemberCallInConstructor/@EntryIndexedValue">HINT</s:String>
|
||||
|
Loading…
Reference in New Issue
Block a user