diff --git a/src/modules/love/boot.lua b/src/modules/love/boot.lua index 9b13cdbbb..9d8ed7f0b 100644 --- a/src/modules/love/boot.lua +++ b/src/modules/love/boot.lua @@ -48,6 +48,17 @@ function love.boot() -- Having love.system loaded before conf.lua is run can be useful for accessing love.system.getOS. require("love.system") + -- nogame.lua returns noGameRestartInfo when + -- dropping a file or directory on to its window. + if love.restart and type(love.restart) == "table" then + local was_no_game = love.restart.noGameRestartInfo + if was_no_game and type(was_no_game) == "table" then + if was_no_game.gamepath then + table.insert(arg, 1, was_no_game.gamepath) + end + end + end + love.rawGameArguments = arg local arg0 = love.arg.getLow(love.rawGameArguments) diff --git a/src/scripts/nogame.lua b/src/scripts/nogame.lua index e66fcaaf3..106832a84 100644 --- a/src/scripts/nogame.lua +++ b/src/scripts/nogame.lua @@ -3285,6 +3285,18 @@ function love.nogame() t.window.borderless = true end end + + function restartWithNewGame(path) + love.event.quit("restart", {noGameRestartInfo = {gamepath = path}}) + end + + function love.filedropped(file) + restartWithNewGame(file:getFilename()) + end + + function love.directorydropped(path) + restartWithNewGame(path) + end end return love.nogame diff --git a/src/scripts/nogame.lua.h b/src/scripts/nogame.lua.h index 8d0d7d6e7..6e2a002b5 100644 --- a/src/scripts/nogame.lua.h +++ b/src/scripts/nogame.lua.h @@ -12129,6 +12129,28 @@ const unsigned char nogame_lua[] = 0x6c, 0x65, 0x73, 0x73, 0x20, 0x3d, 0x20, 0x74, 0x72, 0x75, 0x65, 0x0a, 0x09, 0x09, 0x65, 0x6e, 0x64, 0x0a, 0x09, 0x65, 0x6e, 0x64, 0x0a, + 0x0a, + 0x09, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x72, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x57, + 0x69, 0x74, 0x68, 0x4e, 0x65, 0x77, 0x47, 0x61, 0x6d, 0x65, 0x28, 0x70, 0x61, 0x74, 0x68, 0x29, 0x0a, + 0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x71, 0x75, 0x69, 0x74, 0x28, + 0x22, 0x72, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x22, 0x2c, 0x20, 0x7b, 0x6e, 0x6f, 0x47, 0x61, 0x6d, 0x65, + 0x52, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x20, 0x3d, 0x20, 0x7b, 0x67, 0x61, 0x6d, + 0x65, 0x70, 0x61, 0x74, 0x68, 0x20, 0x3d, 0x20, 0x70, 0x61, 0x74, 0x68, 0x7d, 0x7d, 0x29, 0x0a, + 0x09, 0x65, 0x6e, 0x64, 0x0a, + 0x0a, + 0x09, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x66, 0x69, 0x6c, + 0x65, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x28, 0x66, 0x69, 0x6c, 0x65, 0x29, 0x0a, + 0x09, 0x09, 0x72, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x57, 0x69, 0x74, 0x68, 0x4e, 0x65, 0x77, 0x47, 0x61, + 0x6d, 0x65, 0x28, 0x66, 0x69, 0x6c, 0x65, 0x3a, 0x67, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, + 0x65, 0x28, 0x29, 0x29, 0x0a, + 0x09, 0x65, 0x6e, 0x64, 0x0a, + 0x0a, + 0x09, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x64, 0x69, 0x72, + 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x28, 0x70, 0x61, 0x74, 0x68, + 0x29, 0x0a, + 0x09, 0x09, 0x72, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x57, 0x69, 0x74, 0x68, 0x4e, 0x65, 0x77, 0x47, 0x61, + 0x6d, 0x65, 0x28, 0x70, 0x61, 0x74, 0x68, 0x29, 0x0a, + 0x09, 0x65, 0x6e, 0x64, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x6e, 0x6f, 0x67, 0x61, 0x6d, 0x65, 0x0a,