# HG changeset patch # User Michael Pavone # Date 1511378316 28800 # Node ID 1cdd7f492af8aa672f255024c93c17abfe489212 # Parent 0646ae0987c3d5f0dc1a1a752348b2ba91d0eb55 Pause menu now triggered on ui.exit event diff -r 0646ae0987c3 -r 1cdd7f492af8 io.c --- a/io.c Wed Nov 22 10:54:27 2017 -0800 +++ b/io.c Wed Nov 22 11:18:36 2017 -0800 @@ -23,6 +23,9 @@ #include "render.h" #include "util.h" #include "menu.h" +#ifndef DISABLE_NUKLEAR +#include "nuklear_ui/blastem_nuklear.h" +#endif #define CYCLE_NEVER 0xFFFFFFFF #define MIN_POLL_INTERVAL 6840 @@ -532,6 +535,11 @@ break; } case UI_EXIT: +#ifndef DISABLE_NUKLEAR + if (is_nuklear_active) { + show_pause_menu(); + } else { +#endif current_system->request_exit(current_system); if (current_system->type == SYSTEM_GENESIS) { genesis_context *gen = (genesis_context *)current_system; @@ -541,6 +549,9 @@ menu->external_game_load = 1; } } +#ifndef DISABLE_NUKLEAR + } +#endif break; } break; diff -r 0646ae0987c3 -r 1cdd7f492af8 nuklear_ui/blastem_nuklear.c --- a/nuklear_ui/blastem_nuklear.c Wed Nov 22 10:54:27 2017 -0800 +++ b/nuklear_ui/blastem_nuklear.c Wed Nov 22 11:18:36 2017 -0800 @@ -190,6 +190,19 @@ nk_style_set_font(context, &def_font->handle); } +void show_pause_menu(void) +{ + context->style.window.background = nk_rgba(0, 0, 0, 128); + context->style.window.fixed_background = nk_style_item_color(nk_rgba(0, 0, 0, 128)); + current_view = view_pause; +} + +static uint8_t active; +uint8_t is_nuklear_active(void) +{ + return active; +} + void blastem_nuklear_init(uint8_t file_loaded) { context = nk_sdl_init(render_get_window()); @@ -207,5 +220,6 @@ render_set_ui_render_fun(blastem_nuklear_render); render_set_event_handler(handle_event); render_set_gl_context_handlers(context_destroyed, context_created); + active = 1; idle_loop(); } diff -r 0646ae0987c3 -r 1cdd7f492af8 nuklear_ui/blastem_nuklear.h --- a/nuklear_ui/blastem_nuklear.h Wed Nov 22 10:54:27 2017 -0800 +++ b/nuklear_ui/blastem_nuklear.h Wed Nov 22 11:18:36 2017 -0800 @@ -12,5 +12,7 @@ #include "nuklear_sdl_gles2.h" void blastem_nuklear_init(uint8_t file_loaded); +void show_pause_menu(void); +uint8_t is_nuklear_active(void); #endif //BLASTEM_NUKLEAR_H_