graceful shutdown method

isolation_bkp/dynres
Dominik Madarász 2021-05-13 16:12:18 +02:00
parent 7cb2b480b3
commit 18bcc93a61
6 changed files with 24 additions and 7 deletions

View File

@ -11,6 +11,7 @@ typedef enum {
void game_init(game_kind play_mode, uint32_t num_viewers, int32_t seed, uint16_t chunk_size, uint16_t chunk_amount, int8_t is_dash_enabled);
void game_shutdown();
void game_request_close();
uint8_t game_is_running();
int8_t game_is_networked();

View File

@ -1,12 +1,13 @@
#pragma once
#include "system.h"
void platform_init();
void platform_shutdown();
float platform_frametime();
uint8_t platform_is_running();
void platform_init(void);
void platform_shutdown(void);
void platform_request_close(void);
float platform_frametime(void);
uint8_t platform_is_running(void);
float platform_zoom_get(void);
void platform_input();
void platform_render();
void platform_input(void);
void platform_render(void);

View File

@ -3,6 +3,7 @@
typedef enum {
PROF_MAIN_LOOP,
PROF_WORLD_WRITE,
PROF_RENDER,
PROF_UPDATE_SYSTEMS,

View File

@ -1,7 +1,8 @@
#include "debug_ui.h"
#include "raylib.h"
#include "game.h"
static inline void
ActExitGame(void) {
CloseWindow();
game_request_close();
}

View File

@ -197,3 +197,7 @@ void game_world_cleanup_entities(void) {
}
#endif
}
void game_request_close() {
platform_request_close();
}

View File

@ -17,6 +17,7 @@ uint16_t screenWidth = 1600;
uint16_t screenHeight = 900;
float target_zoom = 4.0f;
float zoom_overlay_tran = 0.0f;
bool request_shutdown;
#define CAM_OVERLAY_ZOOM_LEVEL 0.80f
@ -138,6 +139,10 @@ void platform_render() {
}
debug_draw();
EndDrawing();
if (request_shutdown) {
CloseWindow();
}
}
void display_conn_status() {
@ -271,4 +276,8 @@ void do_entity_fadeinout(uint64_t key, entity_view * data) {
float platform_zoom_get(void) {
return target_zoom;
}
void platform_request_close(void) {
request_shutdown = true;
}