/** * @brief Function to exit the main menu and game. * @param str Unused. */ static void menu_exit( unsigned int wid, char* str ) { (void) str; (void) wid; naev_quit(); }
/** * @brief Creates a secondary loop until loop_done is set to 1 or the toolkit closes. * * Almost identical to the main loop in naev.c. * * @TODO Fix this, we need proper threading as the music Lua and dialogue running Lua * may be run in parallel and this will make everyone cry. So basically we have * a race condition due to the "threading" effect this creates. Solved most of * it by removing globals in the Lua event/mission code, but this doesn't mean * it's solved. It just means it's extremely unlikely. * * @return 0 on success. */ static int toolkit_loop( int *loop_done ) { SDL_Event event; /* Delay a toolkit iteration. */ toolkit_delay(); *loop_done = 0; while (!(*loop_done) && toolkit_isOpen()) { /* Loop first so exit condition is checked before next iteration. */ main_loop( 0 ); while (SDL_PollEvent(&event)) { /* event loop */ if (event.type == SDL_QUIT) { /* pass quit event to main engine */ if (menu_askQuit()) { naev_quit(); *loop_done = 1; SDL_PushEvent(&event); return -1; } } input_handle(&event); /* handles all the events and player keybinds */ } } return 0; }
/** * @brief Creates a secondary loop until loop_done is set to 1 or the toolkit closes. * * Almost identical to the main loop in naev.c. * * @TODO Fix this, we need proper threading as the music Lua and dialogue running Lua * may be run in parallel and this will make everyone cry. So basically we have * a race condition due to the "threading" effect this creates. Solved most of * it by removing globals in the Lua event/mission code, but this doesn't mean * it's solved. It just means it's extremely unlikely. * * @return 0 on success. */ static int toolkit_loop( int *loop_done ) { SDL_Event event; /* Delay a toolkit iteration. */ toolkit_delay(); *loop_done = 0; while (!(*loop_done) && toolkit_isOpen()) { /* Loop first so exit condition is checked before next iteration. */ main_loop( 0 ); while (SDL_PollEvent(&event)) { /* event loop */ if (event.type == SDL_QUIT) { /* pass quit event to main engine */ if (menu_askQuit()) { naev_quit(); *loop_done = 1; SDL_PushEvent(&event); return -1; } } #if SDL_VERSION_ATLEAST(2,0,0) else if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_RESIZED) { naev_resize( event.window.data1, event.window.data2 ); continue; } #endif /* SDL_VERSION_ATLEAST(2,0,0) */ input_handle(&event); /* handles all the events and player keybinds */ } } return 0; }