mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Use switch with type matching in place of if-else where possible
This commit is contained in:
@ -73,12 +73,17 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
|
||||
downloader.Download();
|
||||
};
|
||||
|
||||
downloader.DownloadState.ValueChanged += d =>
|
||||
downloader.DownloadState.ValueChanged += state =>
|
||||
{
|
||||
if (d == BeatmapSetDownloader.DownloadStatus.Downloaded)
|
||||
this.FadeOut(200);
|
||||
else if (d == BeatmapSetDownloader.DownloadStatus.NotDownloaded)
|
||||
this.FadeIn(200);
|
||||
switch (state)
|
||||
{
|
||||
case BeatmapSetDownloader.DownloadStatus.Downloaded:
|
||||
this.FadeOut(200);
|
||||
break;
|
||||
case BeatmapSetDownloader.DownloadStatus.NotDownloaded:
|
||||
this.FadeIn(200);
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -188,16 +188,17 @@ namespace osu.Game.Overlays
|
||||
int optionCount = 0;
|
||||
int selectedOption = -1;
|
||||
|
||||
if (description.RawValue is bool)
|
||||
switch (description.RawValue)
|
||||
{
|
||||
optionCount = 1;
|
||||
if ((bool)description.RawValue) selectedOption = 0;
|
||||
}
|
||||
else if (description.RawValue is Enum)
|
||||
{
|
||||
var values = Enum.GetValues(description.RawValue.GetType());
|
||||
optionCount = values.Length;
|
||||
selectedOption = Convert.ToInt32(description.RawValue);
|
||||
case bool val:
|
||||
optionCount = 1;
|
||||
if (val) selectedOption = 0;
|
||||
break;
|
||||
case Enum _:
|
||||
var values = Enum.GetValues(description.RawValue.GetType());
|
||||
optionCount = values.Length;
|
||||
selectedOption = Convert.ToInt32(description.RawValue);
|
||||
break;
|
||||
}
|
||||
|
||||
textLine2.Origin = optionCount > 0 ? Anchor.BottomCentre : Anchor.Centre;
|
||||
|
Reference in New Issue
Block a user