NUVIE: Check EVENT_QUIT in intro

This commit is contained in:
Eugene Sandulenko 2020-04-09 23:24:28 +02:00
parent 6dac3cc97e
commit 86b42201f4
2 changed files with 66 additions and 1 deletions

View File

@ -61,11 +61,21 @@ function poll_for_input()
end
end
if engine_should_quit() == 1 then
g_should_exit = true
end
return input
end
function poll_for_key_or_button(cycles)
local input
if engine_should_quit() == 1 then
g_should_exit = true
return true
end
if cycles == nil then
input = input_poll()
if input ~= nil then
@ -84,6 +94,10 @@ function poll_for_key_or_button(cycles)
end
return true
end
if engine_should_quit() == 1 then
g_should_exit = true
return true
end
canvas_update()
end
end
@ -97,6 +111,9 @@ function poll_for_esc(cycles)
if input ~= nil and input == SDLK_ESCAPE then
return true
end
if engine_should_quit() == 1 then
return true
end
else
local i
for i=0,cycles,1 do
@ -104,6 +121,9 @@ function poll_for_esc(cycles)
if input ~= nil and input == SDLK_ESCAPE then
return true
end
if engine_should_quit() == 1 then
return true
end
canvas_update()
end
end
@ -119,6 +139,10 @@ function fade_in(speed)
for i=0x0,0xff,speed do
canvas_set_opacity(i)
canvas_update()
if engine_should_quit() == 1 then
return false
end
end
return false
@ -133,6 +157,10 @@ function fade_out(speed)
for i=0xff,0,-speed do
canvas_set_opacity(i)
canvas_update()
if engine_should_quit() == 1 then
return false
end
end
return false

View File

@ -10,7 +10,11 @@ local function poll_for_esc()
if input ~= nil and input == 27 then
return true
end
if engine_should_quit() == 1 then
return true
end
return false
end
@ -22,12 +26,20 @@ local function wait_for_input()
if input ~= nil then
break
end
if engine_should_quit() == 1 then
break
end
end
return input
end
local function should_exit(input)
if engine_should_quit() == 1 then
return true
end
if input ~=nil and input == 27 then
return true
end
@ -40,6 +52,10 @@ local function fade_out()
for i=0xff,0,-3 do
canvas_set_opacity(i)
canvas_update()
if engine_should_quit() == 1 then
break
end
end
return false
@ -56,6 +72,10 @@ local function fade_out_sprite(sprite, speed)
for i=0xff,0,speed do
sprite.opacity = i
canvas_update()
if engine_should_quit() == 1 then
break
end
end
return false
@ -66,6 +86,10 @@ local function fade_in()
for i=0x0,0xff,3 do
canvas_set_opacity(i)
canvas_update()
if engine_should_quit() == 1 then
break
end
end
return false
@ -82,6 +106,10 @@ local function fade_in_sprite(sprite, speed)
for i=0,0xff,speed do
sprite.opacity = i
canvas_update()
if engine_should_quit() == 1 then
break
end
end
return false
@ -2953,6 +2981,10 @@ local function main_menu_set_pal(idx)
end
local function main_menu_load()
if engine_should_quit() == 1 then
return
end
music_play("ultima.m")
g_menu = {}
@ -3025,6 +3057,11 @@ local function main_menu()
while true do
canvas_update()
input = input_poll(true)
if engine_should_quit() == 1 then
return "Q"
end
if input ~= nil then
if input == 113 then --q quit
return "Q"