From fe10a149e576b592ab6f620962c94d90e5bd31f0 Mon Sep 17 00:00:00 2001 From: Edgaru089 Date: Thu, 25 Apr 2024 11:19:11 +0800 Subject: [PATCH] Fix SelectLevel not popping current running state --- ui_build.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ui_build.c b/ui_build.c index 74b258e..2ad66cc 100644 --- a/ui_build.c +++ b/ui_build.c @@ -31,10 +31,17 @@ static void _ui_Action_ReturnToTitle(System_UI *sys, ui_Part *part, uintptr_t da sys->super->camera->target = NULL; } static void _ui_Action_SelectLevel(System_UI *sys, ui_Part *part, uintptr_t data) { + while (vector_Size(sys->state) > 0 && ui_CurrentState(sys) != ui_TitleMenu) { + INFO("popping \"%s\"", ui_StateTitle[ui_CurrentState(sys)]); + ui_Action_PopState(sys, part, data); + } + sys->super->paused = false; + if (vector_Size(sys->state) == 0) + WARN("new state stack is now empty, ohno"); + const char *level = (const char *)data; app_QueueLoadLevel(sys->super, level); ui_Action_PushState(sys, part, (uintptr_t)ui_Running); - sys->super->paused = false; } static void _ui_Action_StartFromBeginning(System_UI *sys, ui_Part *part, uintptr_t data) { _ui_Action_SelectLevel(sys, part, (uintptr_t) "intro.txt");