Browse Source

Fixed bug in love.event. Started on error screen.

rude 16 years ago
parent
commit
ae8d660868
3 changed files with 52 additions and 6 deletions
  1. 16 3
      src/modules/event/sdl/Event.cpp
  2. 1 0
      src/modules/event/sdl/Event.h
  3. 35 3
      src/scripts/boot.lua

+ 16 - 3
src/modules/event/sdl/Event.cpp

@@ -44,9 +44,8 @@ namespace sdl
 
 
 	int Event::wait(lua_State * L)
 	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()
 	void Event::quit()
@@ -83,6 +82,20 @@ namespace sdl
 		return 0;
 		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)
 	int Event::pushEvent(lua_State * L, SDL_Event & e)
 	{
 	{
 		switch(e.type)
 		switch(e.type)

+ 1 - 0
src/modules/event/sdl/Event.h

@@ -76,6 +76,7 @@ namespace sdl
 		* The iterator function.
 		* The iterator function.
 		**/
 		**/
 		static int poll_i(lua_State * L);
 		static int poll_i(lua_State * L);
+		static int wait_i(lua_State * L);
 
 
 	private:
 	private:
 
 

+ 35 - 3
src/scripts/boot.lua

@@ -630,12 +630,44 @@ end
 -- Error screen.
 -- Error screen.
 -----------------------------------------------------------
 -----------------------------------------------------------
 
 
-function love.errorscreen()
+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
 	
 	
-	-- Main loop goes here.
+	
+	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
 end
 
 
+
 -----------------------------------------------------------
 -----------------------------------------------------------
 -- The root of all calls.
 -- The root of all calls.
 -----------------------------------------------------------
 -----------------------------------------------------------
@@ -646,6 +678,6 @@ end
 
 
 result = xpcall(love.boot, error_printer)
 result = xpcall(love.boot, error_printer)
 result = xpcall(love.init, error_printer)
 result = xpcall(love.init, error_printer)
-result = xpcall(love.run, error_printer)
+result = xpcall(love.run, love.errhand)
 
 
 print("Done.")
 print("Done.")