mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 14:53:01 +08:00
Use local functions
This commit is contained in:
parent
e0220de1a5
commit
3c11978cfa
@ -45,7 +45,7 @@ namespace osu.Desktop
|
|||||||
{
|
{
|
||||||
protected override string LocateBasePath()
|
protected override string LocateBasePath()
|
||||||
{
|
{
|
||||||
Func<string, bool> checkExists = p => Directory.Exists(Path.Combine(p, "Songs"));
|
bool checkExists(string p) => Directory.Exists(Path.Combine(p, "Songs"));
|
||||||
|
|
||||||
string stableInstallPath;
|
string stableInstallPath;
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Func<SampleInfo, bool> isDoubleSample = sample => sample.Name == SampleInfo.HIT_CLAP && sample.Name == SampleInfo.HIT_FINISH;
|
bool isDoubleSample(SampleInfo sample) => sample.Name == SampleInfo.HIT_CLAP && sample.Name == SampleInfo.HIT_FINISH;
|
||||||
|
|
||||||
bool canGenerateTwoNotes = (convertType & PatternType.LowProbability) == 0;
|
bool canGenerateTwoNotes = (convertType & PatternType.LowProbability) == 0;
|
||||||
canGenerateTwoNotes &= HitObject.Samples.Any(isDoubleSample) || sampleInfoListAt(HitObject.StartTime).Any(isDoubleSample);
|
canGenerateTwoNotes &= HitObject.Samples.Any(isDoubleSample) || sampleInfoListAt(HitObject.StartTime).Any(isDoubleSample);
|
||||||
|
@ -117,8 +117,8 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
//ensure we were stored to beatmap database backing...
|
//ensure we were stored to beatmap database backing...
|
||||||
Assert.IsTrue(resultSets.Count() == 1, $@"Incorrect result count found ({resultSets.Count()} but should be 1).");
|
Assert.IsTrue(resultSets.Count() == 1, $@"Incorrect result count found ({resultSets.Count()} but should be 1).");
|
||||||
|
|
||||||
Func<IEnumerable<BeatmapInfo>> queryBeatmaps = () => store.QueryBeatmaps(s => s.BeatmapSet.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0);
|
IEnumerable<BeatmapInfo> queryBeatmaps() => store.QueryBeatmaps(s => s.BeatmapSet.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0);
|
||||||
Func<IEnumerable<BeatmapSetInfo>> queryBeatmapSets = () => store.QueryBeatmapSets(s => s.OnlineBeatmapSetID == 241526);
|
IEnumerable<BeatmapSetInfo> queryBeatmapSets() => store.QueryBeatmapSets(s => s.OnlineBeatmapSetID == 241526);
|
||||||
|
|
||||||
//if we don't re-check here, the set will be inserted but the beatmaps won't be present yet.
|
//if we don't re-check here, the set will be inserted but the beatmaps won't be present yet.
|
||||||
waitForOrAssert(() => queryBeatmaps().Count() == 12,
|
waitForOrAssert(() => queryBeatmaps().Count() == 12,
|
||||||
|
@ -65,7 +65,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
// this is by no means clean. should be replacing inside of OsuGameBase somehow.
|
// this is by no means clean. should be replacing inside of OsuGameBase somehow.
|
||||||
var context = new OsuDbContext();
|
var context = new OsuDbContext();
|
||||||
|
|
||||||
Func<OsuDbContext> contextFactory = () => context;
|
OsuDbContext contextFactory() => context;
|
||||||
|
|
||||||
dependencies.Cache(rulesets = new RulesetStore(contextFactory));
|
dependencies.Cache(rulesets = new RulesetStore(contextFactory));
|
||||||
dependencies.Cache(manager = new BeatmapManager(storage, contextFactory, rulesets, null)
|
dependencies.Cache(manager = new BeatmapManager(storage, contextFactory, rulesets, null)
|
||||||
|
@ -121,7 +121,7 @@ namespace osu.Game.Overlays
|
|||||||
trackSetting(frameworkConfig.GetBindable<string>(FrameworkSetting.AudioDevice), v => display(v, "Audio Device", string.IsNullOrEmpty(v) ? "Default" : v, v));
|
trackSetting(frameworkConfig.GetBindable<string>(FrameworkSetting.AudioDevice), v => display(v, "Audio Device", string.IsNullOrEmpty(v) ? "Default" : v, v));
|
||||||
trackSetting(frameworkConfig.GetBindable<bool>(FrameworkSetting.ShowLogOverlay), v => display(v, "Debug Logs", v ? "visible" : "hidden", "Ctrl+F10"));
|
trackSetting(frameworkConfig.GetBindable<bool>(FrameworkSetting.ShowLogOverlay), v => display(v, "Debug Logs", v ? "visible" : "hidden", "Ctrl+F10"));
|
||||||
|
|
||||||
Action displayResolution = delegate { display(null, "Screen Resolution", frameworkConfig.Get<int>(FrameworkSetting.Width) + "x" + frameworkConfig.Get<int>(FrameworkSetting.Height)); };
|
void displayResolution() => display(null, "Screen Resolution", frameworkConfig.Get<int>(FrameworkSetting.Width) + "x" + frameworkConfig.Get<int>(FrameworkSetting.Height));
|
||||||
|
|
||||||
trackSetting(frameworkConfig.GetBindable<int>(FrameworkSetting.Width), v => displayResolution());
|
trackSetting(frameworkConfig.GetBindable<int>(FrameworkSetting.Width), v => displayResolution());
|
||||||
trackSetting(frameworkConfig.GetBindable<int>(FrameworkSetting.Height), v => displayResolution());
|
trackSetting(frameworkConfig.GetBindable<int>(FrameworkSetting.Height), v => displayResolution());
|
||||||
|
@ -319,11 +319,11 @@ namespace osu.Game.Overlays.Profile
|
|||||||
colourBar.Show();
|
colourBar.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
Action<SpriteText> boldItalic = t =>
|
void boldItalic(SpriteText t)
|
||||||
{
|
{
|
||||||
t.Font = @"Exo2.0-BoldItalic";
|
t.Font = @"Exo2.0-BoldItalic";
|
||||||
t.Alpha = 1;
|
t.Alpha = 1;
|
||||||
};
|
}
|
||||||
|
|
||||||
if (user.Age != null)
|
if (user.Age != null)
|
||||||
{
|
{
|
||||||
|
@ -188,7 +188,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
mediumRing.ResizeTo(130, 340, Easing.OutQuad);
|
mediumRing.ResizeTo(130, 340, Easing.OutQuad);
|
||||||
mediumRing.Foreground.ResizeTo(1, 880, Easing.Out);
|
mediumRing.Foreground.ResizeTo(1, 880, Easing.Out);
|
||||||
|
|
||||||
Func<double> remainingTime = () => length - TransformDelay;
|
double remainingTime() => length - TransformDelay;
|
||||||
|
|
||||||
using (BeginDelayedSequence(250, true))
|
using (BeginDelayedSequence(250, true))
|
||||||
{
|
{
|
||||||
|
@ -231,7 +231,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
/// <param name="waitForPrevious">If true, the new animation is delayed until all previous transforms finish. If false, existing transformed are cleared.</param>
|
/// <param name="waitForPrevious">If true, the new animation is delayed until all previous transforms finish. If false, existing transformed are cleared.</param>
|
||||||
public void AppendAnimatingAction(Action action, bool waitForPrevious)
|
public void AppendAnimatingAction(Action action, bool waitForPrevious)
|
||||||
{
|
{
|
||||||
Action runnableAction = () =>
|
void runnableAction()
|
||||||
{
|
{
|
||||||
if (waitForPrevious)
|
if (waitForPrevious)
|
||||||
this.DelayUntilTransformsFinished().Schedule(action);
|
this.DelayUntilTransformsFinished().Schedule(action);
|
||||||
@ -240,7 +240,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
ClearTransforms();
|
ClearTransforms();
|
||||||
action();
|
action();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
if (IsLoaded)
|
if (IsLoaded)
|
||||||
runnableAction();
|
runnableAction();
|
||||||
|
@ -266,7 +266,7 @@ namespace osu.Game.Screens.Select
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void carouselSelectionChanged(BeatmapInfo beatmap)
|
private void carouselSelectionChanged(BeatmapInfo beatmap)
|
||||||
{
|
{
|
||||||
Action performLoad = delegate
|
void performLoad()
|
||||||
{
|
{
|
||||||
// We may be arriving here due to another component changing the bindable Beatmap.
|
// We may be arriving here due to another component changing the bindable Beatmap.
|
||||||
// In these cases, the other component has already loaded the beatmap, so we don't need to do so again.
|
// In these cases, the other component has already loaded the beatmap, so we don't need to do so again.
|
||||||
@ -279,7 +279,7 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
|
|
||||||
UpdateBeatmap(Beatmap.Value);
|
UpdateBeatmap(Beatmap.Value);
|
||||||
};
|
}
|
||||||
|
|
||||||
if (beatmap?.Equals(beatmapNoDebounce) == true)
|
if (beatmap?.Equals(beatmapNoDebounce) == true)
|
||||||
return;
|
return;
|
||||||
|
@ -265,7 +265,7 @@ namespace osu.Game.Screens.Tournament
|
|||||||
|
|
||||||
private void writeResults(string text)
|
private void writeResults(string text)
|
||||||
{
|
{
|
||||||
Action writeAction = () =>
|
void writeAction()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -280,9 +280,9 @@ namespace osu.Game.Screens.Tournament
|
|||||||
{
|
{
|
||||||
Logger.Error(ex, "Failed to write results.");
|
Logger.Error(ex, "Failed to write results.");
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
writeOp = writeOp?.ContinueWith(t => { writeAction(); }) ?? Task.Run(writeAction);
|
writeOp = writeOp?.ContinueWith(t => { writeAction(); }) ?? Task.Run((Action)writeAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reloadTeams()
|
private void reloadTeams()
|
||||||
|
Loading…
Reference in New Issue
Block a user