From 9637701340893efa36a94c04f3d7f72e67c8c75d Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sat, 10 Oct 2020 14:52:46 +0900 Subject: [PATCH] Windows: Implement reset menu command A bit hacky but works. --- src/sdlmain.cpp | 14 +++++++------- src/sys/ags.cpp | 3 +++ src/sys/nact.cpp | 4 +++- src/sys/nact.h | 3 ++- src/win/nact_win.cpp | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/sdlmain.cpp b/src/sdlmain.cpp index 49293b1..3c0f0e7 100644 --- a/src/sdlmain.cpp +++ b/src/sdlmain.cpp @@ -93,16 +93,16 @@ int main(int argc, char *argv[]) EM_ASM( xsystem35.shell.windowSizeChanged(); ); #endif - nact->mainloop(); + bool restart = true; + while (restart) { + restart = nact->mainloop(); + delete nact; + if (restart) + nact = NACT::create(game_id, font_file, playlist); + } SDL_DestroyWindow(g_window); SDL_Quit(); - // system3 開放 - delete nact; - - // MCI 開放 - //release_mci(); - return 0; } diff --git a/src/sys/ags.cpp b/src/sys/ags.cpp index c66eb48..082d6ea 100644 --- a/src/sys/ags.cpp +++ b/src/sys/ags.cpp @@ -372,6 +372,9 @@ AGS::~AGS() } SDL_FreeSurface(hBmpDest); + + SDL_DestroyTexture(sdlTexture); + SDL_DestroyRenderer(sdlRenderer); } void AGS::set_palette(int index, int r, int g, int b) diff --git a/src/sys/nact.cpp b/src/sys/nact.cpp index f5b0306..4e3b497 100644 --- a/src/sys/nact.cpp +++ b/src/sys/nact.cpp @@ -96,6 +96,7 @@ NACT::NACT(int sys_ver, uint32 crc32_a, uint32 crc32_b, const char* font_file, c #endif terminate = false; + restart_after_terminate = false; } NACT::~NACT() @@ -116,7 +117,7 @@ NACT::~NACT() platform_finalize(); } -void NACT::mainloop() +bool NACT::mainloop() { int sleep_cnt = 0; @@ -127,6 +128,7 @@ void NACT::mainloop() SDL_Delay(10); } } + return restart_after_terminate; } // コマンドパーサ diff --git a/src/sys/nact.h b/src/sys/nact.h index 0b9792f..2a91589 100644 --- a/src/sys/nact.h +++ b/src/sys/nact.h @@ -229,13 +229,14 @@ protected: // 終了フラグ bool terminate; + bool restart_after_terminate; // Platform-specific setup / cleanup code void platform_initialize(); void platform_finalize(); public: - void mainloop(); + bool mainloop(); int get_screen_height(); diff --git a/src/win/nact_win.cpp b/src/win/nact_win.cpp index 89469e4..5cbe393 100644 --- a/src/win/nact_win.cpp +++ b/src/win/nact_win.cpp @@ -134,7 +134,7 @@ void NACT::on_syswmevent(SDL_SysWMmsg* msg) case WM_COMMAND: switch (msg->msg.win.wParam) { case ID_RESTART: - // TODO: Implement + terminate = restart_after_terminate = true; break; case ID_EXIT: terminate = true;