mirror of
https://github.com/osukey/osukey.git
synced 2025-05-07 06:37:18 +09:00
Remove unnecessary null
casts
This commit is contained in:
parent
f4173a3bff
commit
f71f6302fd
@ -161,7 +161,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
=> addCheckPositionChangeSteps(timeAtRepeat(startTime, repeatIndex), positionAtRepeat(repeatIndex), positionRemainsSame);
|
=> addCheckPositionChangeSteps(timeAtRepeat(startTime, repeatIndex), positionAtRepeat(repeatIndex), positionRemainsSame);
|
||||||
|
|
||||||
private Func<double> timeAtRepeat(Func<double> startTime, int repeatIndex) => () => startTime() + 100 + duration_of_span * repeatIndex;
|
private Func<double> timeAtRepeat(Func<double> startTime, int repeatIndex) => () => startTime() + 100 + duration_of_span * repeatIndex;
|
||||||
private Func<Vector2> positionAtRepeat(int repeatIndex) => repeatIndex % 2 == 0 ? (Func<Vector2>)getSliderStart : getSliderEnd;
|
private Func<Vector2> positionAtRepeat(int repeatIndex) => repeatIndex % 2 == 0 ? getSliderStart : getSliderEnd;
|
||||||
|
|
||||||
private List<Vector2> getSliderCurve() => ((PlaySliderBody)drawableSlider.Body.Drawable).CurrentCurve;
|
private List<Vector2> getSliderCurve() => ((PlaySliderBody)drawableSlider.Body.Drawable).CurrentCurve;
|
||||||
private Vector2 getSliderStart() => getSliderCurve().First();
|
private Vector2 getSliderStart() => getSliderCurve().First();
|
||||||
|
@ -364,12 +364,12 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
|
|
||||||
private void confirmCurrentFrame(int? frame)
|
private void confirmCurrentFrame(int? frame)
|
||||||
{
|
{
|
||||||
Assert.AreEqual(frame is int x ? replay.Frames[x].Time : (double?)null, handler.CurrentFrame?.Time, "Unexpected current frame");
|
Assert.AreEqual(frame is int x ? replay.Frames[x].Time : null, handler.CurrentFrame?.Time, "Unexpected current frame");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void confirmNextFrame(int? frame)
|
private void confirmNextFrame(int? frame)
|
||||||
{
|
{
|
||||||
Assert.AreEqual(frame is int x ? replay.Frames[x].Time : (double?)null, handler.NextFrame?.Time, "Unexpected next frame");
|
Assert.AreEqual(frame is int x ? replay.Frames[x].Time : null, handler.NextFrame?.Time, "Unexpected next frame");
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestReplayFrame : ReplayFrame
|
private class TestReplayFrame : ReplayFrame
|
||||||
|
@ -58,7 +58,7 @@ namespace osu.Game.Tests.Skins
|
|||||||
{
|
{
|
||||||
AddStep($"Set beatmap skin enabled to {allowBeatmapLookups}", () => config.SetValue(OsuSetting.BeatmapSkins, allowBeatmapLookups));
|
AddStep($"Set beatmap skin enabled to {allowBeatmapLookups}", () => config.SetValue(OsuSetting.BeatmapSkins, allowBeatmapLookups));
|
||||||
|
|
||||||
ISkin expected() => allowBeatmapLookups ? (ISkin)beatmapSource : userSource;
|
ISkin expected() => allowBeatmapLookups ? beatmapSource : userSource;
|
||||||
|
|
||||||
AddAssert("Check lookup is from correct source", () => requester.FindProvider(s => s.GetDrawableComponent(new TestSkinComponent()) != null) == expected());
|
AddAssert("Check lookup is from correct source", () => requester.FindProvider(s => s.GetDrawableComponent(new TestSkinComponent()) != null) == expected());
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Width = 500,
|
Width = 500,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Child = component = padded ? (LabelledDrawable<Drawable>)new PaddedLabelledDrawable() : new NonPaddedLabelledDrawable(),
|
Child = component = padded ? new PaddedLabelledDrawable() : new NonPaddedLabelledDrawable(),
|
||||||
};
|
};
|
||||||
|
|
||||||
component.Label = "a sample component";
|
component.Label = "a sample component";
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using System;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
@ -89,7 +88,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
AddToggleStep("toggle enabled", toggle =>
|
AddToggleStep("toggle enabled", toggle =>
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
button.Action = toggle ? () => { } : (Action)null;
|
button.Action = toggle ? () => { } : null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using System;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
@ -29,7 +28,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
AddToggleStep("toggle enabled", toggle =>
|
AddToggleStep("toggle enabled", toggle =>
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
button.Action = toggle ? () => { } : (Action)null;
|
button.Action = toggle ? () => { } : null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ namespace osu.Game.Graphics.Containers
|
|||||||
if (host.Window == null) return;
|
if (host.Window == null) return;
|
||||||
|
|
||||||
bool coversWholeScreen = Size == Vector2.One && safeArea.SafeAreaPadding.Value.Total == Vector2.Zero;
|
bool coversWholeScreen = Size == Vector2.One && safeArea.SafeAreaPadding.Value.Total == Vector2.Zero;
|
||||||
host.Window.CursorConfineRect = coversWholeScreen ? (RectangleF?)null : ToScreenSpace(DrawRectangle).AABBFloat;
|
host.Window.CursorConfineRect = coversWholeScreen ? null : ToScreenSpace(DrawRectangle).AABBFloat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
@ -47,7 +46,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
Active.BindDisabledChanged(disabled => Action = disabled ? (Action?)null : Active.Toggle, true);
|
Active.BindDisabledChanged(disabled => Action = disabled ? null : Active.Toggle, true);
|
||||||
Active.BindValueChanged(_ =>
|
Active.BindValueChanged(_ =>
|
||||||
{
|
{
|
||||||
updateActiveState();
|
updateActiveState();
|
||||||
|
@ -34,6 +34,6 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IconUsage? GetIconForState(bool state) => state ? (IconUsage?)FontAwesome.Solid.Check : null;
|
public override IconUsage? GetIconForState(bool state) => state ? FontAwesome.Solid.Check : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ namespace osu.Game
|
|||||||
public virtual bool UseDevelopmentServer => DebugUtils.IsDebugBuild;
|
public virtual bool UseDevelopmentServer => DebugUtils.IsDebugBuild;
|
||||||
|
|
||||||
internal EndpointConfiguration CreateEndpoints() =>
|
internal EndpointConfiguration CreateEndpoints() =>
|
||||||
UseDevelopmentServer ? (EndpointConfiguration)new DevelopmentEndpointConfiguration() : new ProductionEndpointConfiguration();
|
UseDevelopmentServer ? new DevelopmentEndpointConfiguration() : new ProductionEndpointConfiguration();
|
||||||
|
|
||||||
public virtual Version AssemblyVersion => Assembly.GetEntryAssembly()?.GetName().Version ?? new Version();
|
public virtual Version AssemblyVersion => Assembly.GetEntryAssembly()?.GetName().Version ?? new Version();
|
||||||
|
|
||||||
@ -583,6 +583,6 @@ namespace osu.Game
|
|||||||
|
|
||||||
ControlPointInfo IBeatSyncProvider.ControlPoints => Beatmap.Value.Beatmap.ControlPointInfo;
|
ControlPointInfo IBeatSyncProvider.ControlPoints => Beatmap.Value.Beatmap.ControlPointInfo;
|
||||||
IClock IBeatSyncProvider.Clock => Beatmap.Value.TrackLoaded ? Beatmap.Value.Track : (IClock)null;
|
IClock IBeatSyncProvider.Clock => Beatmap.Value.TrackLoaded ? Beatmap.Value.Track : (IClock)null;
|
||||||
ChannelAmplitudes? IBeatSyncProvider.Amplitudes => Beatmap.Value.TrackLoaded ? Beatmap.Value.Track.CurrentAmplitudes : (ChannelAmplitudes?)null;
|
ChannelAmplitudes? IBeatSyncProvider.Amplitudes => Beatmap.Value.TrackLoaded ? Beatmap.Value.Track.CurrentAmplitudes : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,8 @@ namespace osu.Game.Overlays.Mods
|
|||||||
&& !ModUtils.CheckCompatibleSet(selectedMods.Value.Append(Mod));
|
&& !ModUtils.CheckCompatibleSet(selectedMods.Value.Append(Mod));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Colour4 BackgroundColour => incompatible.Value ? (Colour4)ColourProvider.Background6 : base.BackgroundColour;
|
protected override Colour4 BackgroundColour => incompatible.Value ? ColourProvider.Background6 : base.BackgroundColour;
|
||||||
protected override Colour4 ForegroundColour => incompatible.Value ? (Colour4)ColourProvider.Background5 : base.ForegroundColour;
|
protected override Colour4 ForegroundColour => incompatible.Value ? ColourProvider.Background5 : base.ForegroundColour;
|
||||||
|
|
||||||
protected override void UpdateState()
|
protected override void UpdateState()
|
||||||
{
|
{
|
||||||
|
@ -442,7 +442,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
case ModType.DifficultyIncrease:
|
case ModType.DifficultyIncrease:
|
||||||
case ModType.Automation:
|
case ModType.Automation:
|
||||||
return hotkeyStyle == ModSelectHotkeyStyle.Sequential
|
return hotkeyStyle == ModSelectHotkeyStyle.Sequential
|
||||||
? (IModHotkeyHandler)SequentialModHotkeyHandler.Create(ModType)
|
? SequentialModHotkeyHandler.Create(ModType)
|
||||||
: new ClassicModHotkeyHandler(allowIncompatibleSelection);
|
: new ClassicModHotkeyHandler(allowIncompatibleSelection);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -216,9 +216,9 @@ namespace osu.Game.Overlays.Mods
|
|||||||
base.OnMouseUp(e);
|
base.OnMouseUp(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual Colour4 BackgroundColour => Active.Value ? activeColour.Darken(0.3f) : (Colour4)ColourProvider.Background3;
|
protected virtual Colour4 BackgroundColour => Active.Value ? activeColour.Darken(0.3f) : ColourProvider.Background3;
|
||||||
protected virtual Colour4 ForegroundColour => Active.Value ? activeColour : (Colour4)ColourProvider.Background2;
|
protected virtual Colour4 ForegroundColour => Active.Value ? activeColour : ColourProvider.Background2;
|
||||||
protected virtual Colour4 TextColour => Active.Value ? (Colour4)ColourProvider.Background6 : Colour4.White;
|
protected virtual Colour4 TextColour => Active.Value ? ColourProvider.Background6 : Colour4.White;
|
||||||
|
|
||||||
protected virtual void UpdateState()
|
protected virtual void UpdateState()
|
||||||
{
|
{
|
||||||
|
@ -79,7 +79,7 @@ namespace osu.Game.Rulesets
|
|||||||
public int OnlineID
|
public int OnlineID
|
||||||
{
|
{
|
||||||
get => ID ?? -1;
|
get => ID ?? -1;
|
||||||
set => ID = value >= 0 ? value : (int?)null;
|
set => ID = value >= 0 ? value : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -87,7 +87,7 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SliderPath(PathType type, Vector2[] controlPoints, double? expectedDistance = null)
|
public SliderPath(PathType type, Vector2[] controlPoints, double? expectedDistance = null)
|
||||||
: this(controlPoints.Select((c, i) => new PathControlPoint(c, i == 0 ? (PathType?)type : null)).ToArray(), expectedDistance)
|
: this(controlPoints.Select((c, i) => new PathControlPoint(c, i == 0 ? type : null)).ToArray(), expectedDistance)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ namespace osu.Game.Rulesets.Replays
|
|||||||
CurrentTime = Math.Clamp(time, frameStart, frameEnd);
|
CurrentTime = Math.Clamp(time, frameStart, frameEnd);
|
||||||
|
|
||||||
// In an important section, a mid-frame time cannot be used and a null is returned instead.
|
// In an important section, a mid-frame time cannot be used and a null is returned instead.
|
||||||
return inImportantSection && frameStart < time && time < frameEnd ? null : (double?)CurrentTime;
|
return inImportantSection && frameStart < time && time < frameEnd ? null : CurrentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getFrameTime(int index)
|
private double getFrameTime(int index)
|
||||||
|
@ -24,6 +24,6 @@ namespace osu.Game.Screens.Edit.Components.Menus
|
|||||||
Action.Value = () => difficultyChangeFunc.Invoke(beatmapInfo);
|
Action.Value = () => difficultyChangeFunc.Invoke(beatmapInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IconUsage? GetIconForState(bool state) => state ? (IconUsage?)FontAwesome.Solid.Check : null;
|
public override IconUsage? GetIconForState(bool state) => state ? FontAwesome.Solid.Check : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static string? getCommonBank(SampleControlPoint[] relevantControlPoints) => relevantControlPoints.Select(point => point.SampleBank).Distinct().Count() == 1 ? relevantControlPoints.First().SampleBank : null;
|
private static string? getCommonBank(SampleControlPoint[] relevantControlPoints) => relevantControlPoints.Select(point => point.SampleBank).Distinct().Count() == 1 ? relevantControlPoints.First().SampleBank : null;
|
||||||
private static int? getCommonVolume(SampleControlPoint[] relevantControlPoints) => relevantControlPoints.Select(point => point.SampleVolume).Distinct().Count() == 1 ? (int?)relevantControlPoints.First().SampleVolume : null;
|
private static int? getCommonVolume(SampleControlPoint[] relevantControlPoints) => relevantControlPoints.Select(point => point.SampleVolume).Distinct().Count() == 1 ? relevantControlPoints.First().SampleVolume : null;
|
||||||
|
|
||||||
private void updateBankFor(IEnumerable<HitObject> objects, string? newBank)
|
private void updateBankFor(IEnumerable<HitObject> objects, string? newBank)
|
||||||
{
|
{
|
||||||
|
@ -908,6 +908,6 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
ControlPointInfo IBeatSyncProvider.ControlPoints => editorBeatmap.ControlPointInfo;
|
ControlPointInfo IBeatSyncProvider.ControlPoints => editorBeatmap.ControlPointInfo;
|
||||||
IClock IBeatSyncProvider.Clock => clock;
|
IClock IBeatSyncProvider.Clock => clock;
|
||||||
ChannelAmplitudes? IBeatSyncProvider.Amplitudes => Beatmap.Value.TrackLoaded ? Beatmap.Value.Track.CurrentAmplitudes : (ChannelAmplitudes?)null;
|
ChannelAmplitudes? IBeatSyncProvider.Amplitudes => Beatmap.Value.TrackLoaded ? Beatmap.Value.Track.CurrentAmplitudes : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
ControlPointInfo IBeatSyncProvider.ControlPoints => beatmap.Beatmap.ControlPointInfo;
|
ControlPointInfo IBeatSyncProvider.ControlPoints => beatmap.Beatmap.ControlPointInfo;
|
||||||
IClock IBeatSyncProvider.Clock => GameplayClock;
|
IClock IBeatSyncProvider.Clock => GameplayClock;
|
||||||
ChannelAmplitudes? IBeatSyncProvider.Amplitudes => beatmap.TrackLoaded ? beatmap.Track.CurrentAmplitudes : (ChannelAmplitudes?)null;
|
ChannelAmplitudes? IBeatSyncProvider.Amplitudes => beatmap.TrackLoaded ? beatmap.Track.CurrentAmplitudes : null;
|
||||||
|
|
||||||
private class HardwareCorrectionOffsetClock : FramedOffsetClock
|
private class HardwareCorrectionOffsetClock : FramedOffsetClock
|
||||||
{
|
{
|
||||||
|
@ -92,8 +92,8 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
var beatmaps = carouselSet.Beatmaps.ToList();
|
var beatmaps = carouselSet.Beatmaps.ToList();
|
||||||
|
|
||||||
return beatmaps.Count > maximum_difficulty_icons
|
return beatmaps.Count > maximum_difficulty_icons
|
||||||
? (IEnumerable<DifficultyIcon>)beatmaps.GroupBy(b => b.BeatmapInfo.Ruleset)
|
? beatmaps.GroupBy(b => b.BeatmapInfo.Ruleset)
|
||||||
.Select(group => new FilterableGroupedDifficultyIcon(group.ToList(), group.Last().BeatmapInfo.Ruleset))
|
.Select(group => new FilterableGroupedDifficultyIcon(group.ToList(), group.Last().BeatmapInfo.Ruleset))
|
||||||
: beatmaps.Select(b => new FilterableDifficultyIcon(b));
|
: beatmaps.Select(b => new FilterableDifficultyIcon(b));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -448,14 +448,14 @@ namespace osu.Game.Screens.Utility
|
|||||||
|
|
||||||
mainArea.AddRange(new[]
|
mainArea.AddRange(new[]
|
||||||
{
|
{
|
||||||
new LatencyArea(Key.Number1, betterSide == 1 ? mapDifficultyToTargetFrameRate(DifficultyLevel) : (int?)null)
|
new LatencyArea(Key.Number1, betterSide == 1 ? mapDifficultyToTargetFrameRate(DifficultyLevel) : null)
|
||||||
{
|
{
|
||||||
Width = 0.5f,
|
Width = 0.5f,
|
||||||
VisualMode = { BindTarget = VisualMode },
|
VisualMode = { BindTarget = VisualMode },
|
||||||
IsActiveArea = { Value = true },
|
IsActiveArea = { Value = true },
|
||||||
ReportUserBest = () => recordResult(betterSide == 0),
|
ReportUserBest = () => recordResult(betterSide == 0),
|
||||||
},
|
},
|
||||||
new LatencyArea(Key.Number2, betterSide == 0 ? mapDifficultyToTargetFrameRate(DifficultyLevel) : (int?)null)
|
new LatencyArea(Key.Number2, betterSide == 0 ? mapDifficultyToTargetFrameRate(DifficultyLevel) : null)
|
||||||
{
|
{
|
||||||
Width = 0.5f,
|
Width = 0.5f,
|
||||||
VisualMode = { BindTarget = VisualMode },
|
VisualMode = { BindTarget = VisualMode },
|
||||||
|
@ -56,7 +56,7 @@ namespace osu.Game.Storyboards
|
|||||||
{
|
{
|
||||||
var first = Alpha.Commands.FirstOrDefault();
|
var first = Alpha.Commands.FirstOrDefault();
|
||||||
|
|
||||||
return first?.StartValue == 0 ? first.StartTime : (double?)null;
|
return first?.StartValue == 0 ? first.StartTime : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user