From b09360d7aedfe62cb43b6f697c9b7e221b304d3f Mon Sep 17 00:00:00 2001 From: JailDoctor Date: Wed, 27 Jul 2022 18:25:45 +0200 Subject: [PATCH] Run a game by dropping the file on the window --- ascii.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ascii.cpp b/ascii.cpp index fa3d599..e29b1a5 100644 --- a/ascii.cpp +++ b/ascii.cpp @@ -198,6 +198,8 @@ int main(int argc,char*argv[]) { lua_init(NULL); lua_call_init(); + SDL_EventState(SDL_DROPFILE, SDL_ENABLE); + while(!exit) { if (should_reset) { should_reset = false; @@ -210,6 +212,12 @@ int main(int argc,char*argv[]) { mouse_wheel = 0; while(SDL_PollEvent(&mini_eve)) { if (mini_eve.type == SDL_QUIT) { exit=true; break; } + if (mini_eve.type == SDL_DROPFILE) { + char* dropped_filedir = mini_eve.drop.file; + load(dropped_filedir); + //SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_INFORMATION, "File dropped on window", dropped_filedir, mini_win ); + SDL_free(dropped_filedir); + } if (mini_eve.type == SDL_KEYDOWN) { if (mini_eve.key.keysym.scancode == SDL_SCANCODE_ESCAPE) { if (lua_is_playing()) {