mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-07 20:19:31 -06:00
Allow the user to abort the loading screen through ESC (closes #668)
This commit is contained in:
@@ -708,6 +708,10 @@ void OpenSpaceEngine::loadSingleAsset(const std::string& assetPath) {
|
||||
|
||||
bool loading = true;
|
||||
while (loading) {
|
||||
if (_shouldAbortLoading) {
|
||||
global::windowDelegate.terminate();
|
||||
break;
|
||||
}
|
||||
_loadingScreen->render();
|
||||
_assetManager->update();
|
||||
|
||||
@@ -750,6 +754,10 @@ void OpenSpaceEngine::loadSingleAsset(const std::string& assetPath) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_shouldAbortLoading) {
|
||||
_loadingScreen = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
_loadingScreen->setPhase(LoadingScreen::Phase::Initialization);
|
||||
|
||||
@@ -1183,6 +1191,16 @@ void OpenSpaceEngine::postDraw() {
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::keyboardCallback(Key key, KeyModifier mod, KeyAction action) {
|
||||
if (_loadingScreen) {
|
||||
// If the loading screen object exists, we are currently loading and want key
|
||||
// presses to behave differently
|
||||
if (key == Key::Escape) {
|
||||
_shouldAbortLoading = true;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
using F = std::function<bool (Key, KeyModifier, KeyAction)>;
|
||||
for (const F& func : global::callback::keyboard) {
|
||||
const bool isConsumed = func(key, mod, action);
|
||||
|
||||
Reference in New Issue
Block a user