From b0339a9d63252a56cea9a1ec1da187a530419183 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Mon, 13 Jan 2025 00:47:52 +0000 Subject: [PATCH] Create game as soon as possible --- osu.Android/OsuGameActivity.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/osu.Android/OsuGameActivity.cs b/osu.Android/OsuGameActivity.cs index fe11672767..42065e61fd 100644 --- a/osu.Android/OsuGameActivity.cs +++ b/osu.Android/OsuGameActivity.cs @@ -49,9 +49,23 @@ namespace osu.Android /// Adjusted on startup to match expected UX for the current device type (phone/tablet). public ScreenOrientation DefaultOrientation = ScreenOrientation.Unspecified; - private OsuGameAndroid game = null!; + private readonly OsuGameAndroid game; - protected override Framework.Game CreateGame() => game = new OsuGameAndroid(this); + private bool gameCreated; + + protected override Framework.Game CreateGame() + { + if (gameCreated) + throw new InvalidOperationException("Framework tried to create a game twice."); + + gameCreated = true; + return game; + } + + public OsuGameActivity() + { + game = new OsuGameAndroid(this); + } protected override void OnCreate(Bundle? savedInstanceState) {