diff --git a/src/modules/event/sdl/Event.cpp b/src/modules/event/sdl/Event.cpp index ac129e6ba..6b82cbed4 100644 --- a/src/modules/event/sdl/Event.cpp +++ b/src/modules/event/sdl/Event.cpp @@ -44,9 +44,8 @@ namespace sdl int Event::wait(lua_State * L) { - static SDL_Event e; - SDL_WaitEvent(&e); - return pushEvent(L, e); + lua_pushcclosure(L, &wait_i, 0); + return 1; } void Event::quit() @@ -83,6 +82,20 @@ namespace sdl return 0; } + int Event::wait_i(lua_State * L) + { + SDL_EnableUNICODE(1); + + // The union used to get SDL events. + static SDL_Event e; + + SDL_WaitEvent(&e); + + int args = Event::pushEvent(L, e); + + return args; + } + int Event::pushEvent(lua_State * L, SDL_Event & e) { switch(e.type) diff --git a/src/modules/event/sdl/Event.h b/src/modules/event/sdl/Event.h index 0ca5953f3..81c881f1f 100644 --- a/src/modules/event/sdl/Event.h +++ b/src/modules/event/sdl/Event.h @@ -76,6 +76,7 @@ namespace sdl * The iterator function. **/ static int poll_i(lua_State * L); + static int wait_i(lua_State * L); private: diff --git a/src/modules/graphics/opengl/TrueTypeFont.cpp b/src/modules/graphics/opengl/TrueTypeFont.cpp index 2295c3f01..16758f603 100644 --- a/src/modules/graphics/opengl/TrueTypeFont.cpp +++ b/src/modules/graphics/opengl/TrueTypeFont.cpp @@ -228,9 +228,6 @@ namespace opengl FT_Done_Face(face); FT_Done_FreeType(library); //all done - // Free data. - data->release(); - return true; } diff --git a/src/modules/sound/lullaby/ModPlugDecoder.cpp b/src/modules/sound/lullaby/ModPlugDecoder.cpp index 2dabd6e9a..8b475dc0c 100644 --- a/src/modules/sound/lullaby/ModPlugDecoder.cpp +++ b/src/modules/sound/lullaby/ModPlugDecoder.cpp @@ -93,8 +93,11 @@ namespace lullaby bool ModPlugDecoder::rewind() { - ModPlug_Seek(plug, 0); - return true; + // Let's reload. + ModPlug_Unload(plug); + plug = ModPlug_Load(data->getData(), data->getSize()); + eof = false; + return (plug != 0); } bool ModPlugDecoder::isSeekable() diff --git a/src/modules/sound/lullaby/VorbisDecoder.h b/src/modules/sound/lullaby/VorbisDecoder.h index 2ea1a3b4b..ab4421d61 100644 --- a/src/modules/sound/lullaby/VorbisDecoder.h +++ b/src/modules/sound/lullaby/VorbisDecoder.h @@ -51,7 +51,6 @@ namespace lullaby OggVorbis_File handle; // Handle to the file vorbis_info * vorbisInfo; // Info vorbis_comment * vorbisComment; // Comments - bool eof; // Whether we have reached the end of the file public: diff --git a/src/scripts/boot.lua b/src/scripts/boot.lua index c87fa0e23..db2255bc5 100644 --- a/src/scripts/boot.lua +++ b/src/scripts/boot.lua @@ -630,12 +630,44 @@ end -- Error screen. ----------------------------------------------------------- -function love.errorscreen() - - -- Main loop goes here. +function love.errhand(msg) + -- Load. + love.graphics.setBackgroundColor(89, 157, 220) + local font = love.graphics.newFont(love._vera_ttf, 14) + love.graphics.setFont(font) + love.graphics.setColor(255, 255, 255, 255) + if love.audio then love.audio.stop() end + + local trace = debug.traceback() + + love.graphics.clear() + love.graphics.print(msg, 70, 80) + --love.graphics.print(, 70, 160) + local y, yi = 160, 20 + local x, xi = 70, 10 + for line in string.gmatch(trace, ".-\n") do + love.graphics.print(line, x, y) + y = y + yi + x = x + xi + end + + + love.graphics.present() + + + while true do + + -- Process events. + for e,a,b,c in love.event.wait() do + if e == love.event_quit then return end + end + + end + end + ----------------------------------------------------------- -- The root of all calls. ----------------------------------------------------------- @@ -646,6 +678,6 @@ end result = xpcall(love.boot, error_printer) result = xpcall(love.init, error_printer) -result = xpcall(love.run, error_printer) +result = xpcall(love.run, love.errhand) print("Done.") \ No newline at end of file diff --git a/src/scripts/graphics.lua b/src/scripts/graphics.lua index 3675d78ff..ad8f9644b 100644 --- a/src/scripts/graphics.lua +++ b/src/scripts/graphics.lua @@ -20,7 +20,7 @@ freely, subject to the following restrictions: love.graphics.print = function (...) if not love.graphics.getFont() then - love.graphics.setFont(love._vera, 12) + love.graphics.setFont(love._vera_ttf, 12) end love.graphics.print1(...) love.graphics.print = love.graphics.print1 @@ -28,7 +28,7 @@ end love.graphics.printf = function (...) if not love.graphics.getFont() then - love.graphics.setFont(love._vera, 12) + love.graphics.setFont(love._vera_ttf, 12) end love.graphics.printf1(...) love.graphics.printf = love.graphics.printf1 diff --git a/src/scripts/graphics.lua.h b/src/scripts/graphics.lua.h index 989349e2b..4b9b81de4 100644 --- a/src/scripts/graphics.lua.h +++ b/src/scripts/graphics.lua.h @@ -55,22 +55,22 @@ static const unsigned char B1[]={ 111,116, 32,108,111,118,101, 46,103,114, 97,112,104,105, 99,115, 46,103,101,116, 70,111,110,116, 40, 41, 32,116,104,101,110, 32, 13, 10, 9, 9,108,111,118,101, 46,103,114, 97,112,104,105, 99,115, 46,115,101,116, 70,111,110,116, 40,108,111, -118,101, 46, 95,118,101,114, 97, 44, 32, 49, 50, 41, 13, 10, 9,101,110,100, 13, - 10, 9,108,111,118,101, 46,103,114, 97,112,104,105, 99,115, 46,112,114,105,110, -116, 49, 40, 46, 46, 46, 41, 13, 10, 9,108,111,118,101, 46,103,114, 97,112,104, -105, 99,115, 46,112,114,105,110,116, 32, 61, 32,108,111,118,101, 46,103,114, 97, -112,104,105, 99,115, 46,112,114,105,110,116, 49, 13, 10,101,110,100, 13, 10, 13, - 10,108,111,118,101, 46,103,114, 97,112,104,105, 99,115, 46,112,114,105,110,116, -102, 32, 61, 32,102,117,110, 99,116,105,111,110, 32, 40, 46, 46, 46, 41, 13, 10, - 9,105,102, 32,110,111,116, 32,108,111,118,101, 46,103,114, 97,112,104,105, 99, -115, 46,103,101,116, 70,111,110,116, 40, 41, 32,116,104,101,110, 32, 13, 10, 9, - 9,108,111,118,101, 46,103,114, 97,112,104,105, 99,115, 46,115,101,116, 70,111, -110,116, 40,108,111,118,101, 46, 95,118,101,114, 97, 44, 32, 49, 50, 41, 13, 10, - 9,101,110,100, 13, 10, 9,108,111,118,101, 46,103,114, 97,112,104,105, 99,115, - 46,112,114,105,110,116,102, 49, 40, 46, 46, 46, 41, 13, 10, 9,108,111,118,101, - 46,103,114, 97,112,104,105, 99,115, 46,112,114,105,110,116,102, 32, 61, 32,108, -111,118,101, 46,103,114, 97,112,104,105, 99,115, 46,112,114,105,110,116,102, 49, - 13, 10,101,110,100, 13, 10, 13, 10, +118,101, 46, 95,118,101,114, 97, 95,116,116,102, 44, 32, 49, 50, 41, 13, 10, 9, +101,110,100, 13, 10, 9,108,111,118,101, 46,103,114, 97,112,104,105, 99,115, 46, +112,114,105,110,116, 49, 40, 46, 46, 46, 41, 13, 10, 9,108,111,118,101, 46,103, +114, 97,112,104,105, 99,115, 46,112,114,105,110,116, 32, 61, 32,108,111,118,101, + 46,103,114, 97,112,104,105, 99,115, 46,112,114,105,110,116, 49, 13, 10,101,110, +100, 13, 10, 13, 10,108,111,118,101, 46,103,114, 97,112,104,105, 99,115, 46,112, +114,105,110,116,102, 32, 61, 32,102,117,110, 99,116,105,111,110, 32, 40, 46, 46, + 46, 41, 13, 10, 9,105,102, 32,110,111,116, 32,108,111,118,101, 46,103,114, 97, +112,104,105, 99,115, 46,103,101,116, 70,111,110,116, 40, 41, 32,116,104,101,110, + 32, 13, 10, 9, 9,108,111,118,101, 46,103,114, 97,112,104,105, 99,115, 46,115, +101,116, 70,111,110,116, 40,108,111,118,101, 46, 95,118,101,114, 97, 95,116,116, +102, 44, 32, 49, 50, 41, 13, 10, 9,101,110,100, 13, 10, 9,108,111,118,101, 46, +103,114, 97,112,104,105, 99,115, 46,112,114,105,110,116,102, 49, 40, 46, 46, 46, + 41, 13, 10, 9,108,111,118,101, 46,103,114, 97,112,104,105, 99,115, 46,112,114, +105,110,116,102, 32, 61, 32,108,111,118,101, 46,103,114, 97,112,104,105, 99,115, + 46,112,114,105,110,116,102, 49, 13, 10,101,110,100, 13, 10, 13, 10, }; if (luaL_loadbuffer(L,(const char*)B1,sizeof(B1),"graphics.lua")==0) lua_call(L, 0, 0);