changeset 696:e201abd8c807

Merged in the VFS fix for absolute paths from FIFE svn trunk. * This fix superseeds my previous patch, so that patch has been removed.
author M. George Hansen <technopolitica@gmail.com>
date Fri, 10 Jun 2011 23:37:46 -1000
parents 47d58c7a95d7 (diff) 5e010218273d (current diff)
children ecaa4d98f05f
files engine/core/controller/engine.cpp engine/core/vfs/vfsdirectory.h
diffstat 4 files changed, 83 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/engine/core/controller/engine.cpp	Wed Jun 08 04:34:50 2011 +0000
+++ b/engine/core/controller/engine.cpp	Fri Jun 10 23:37:46 2011 -1000
@@ -107,6 +107,8 @@
 		m_gui_graphics(0),
 		m_logmanager(0),
 		m_cursor(0),
+		m_prerender_callback(0),
+		m_postrender_callback(0),
 		m_settings(),
 		m_devcaps(),
 		m_changelisteners() {
@@ -363,11 +365,13 @@
 		m_eventmanager->processEvents();
 		m_renderbackend->startFrame();
 		m_timemanager->update();
-
 		if (m_model->getNumMaps() == 0) {
 			m_renderbackend->clearBackBuffer();
 		}
 
+		if (m_prerender_callback != 0) {
+			(*m_prerender_callback)();
+		}
 		m_model->update();
 #ifdef HAVE_OPENGL
 		if (m_settings.getLightingModel() == 1) {
@@ -376,6 +380,9 @@
 #endif
 		m_guimanager->turn();
 		m_cursor->draw();
+		if (m_postrender_callback != 0) {
+			(*m_postrender_callback)();
+		}
 #ifdef HAVE_OPENGL
 		if (m_settings.getLightingModel() == 1) {
 			m_renderbackend->enableLighting();
@@ -384,6 +391,14 @@
 		m_renderbackend->endFrame();
 	}
 
+	void Engine::registerPreRenderCallback(Callback callback) {
+		m_prerender_callback = callback;
+	}
+
+	void Engine::registerPostRenderCallback(Callback callback) {
+		m_postrender_callback = callback;
+	}
+
 	void Engine::finalizePumping() {
 		// nothing here at the moment..
 	}
--- a/engine/core/controller/engine.h	Wed Jun 08 04:34:50 2011 +0000
+++ b/engine/core/controller/engine.h	Fri Jun 10 23:37:46 2011 -1000
@@ -42,6 +42,8 @@
 #include "enginesettings.h"
 #include "video/devicecaps.h"
 
+typedef void (*Callback)();
+
 namespace gcn {
 	class Graphics;
 }
@@ -132,6 +134,16 @@
 		 */
 		void pump();
 
+		/** Register a callback function to call before rendering the main
+		 * scene.
+		 */
+		void registerPreRenderCallback(Callback callback);
+
+		/** Register a callback function to call after rendering the main
+		 * scene.
+		 */
+		void registerPostRenderCallback(Callback callback);
+
 		/** Provides access point to the SoundManager
 		 */
 		SoundManager* getSoundManager() const { return m_soundmanager; }
@@ -213,6 +225,9 @@
 		Cursor* m_cursor;
 		bool m_destroyed;
 
+		Callback m_prerender_callback;
+		Callback m_postrender_callback;
+
 		EngineSettings m_settings;
 		DeviceCaps m_devcaps;
 
--- a/engine/core/controller/engine.i	Wed Jun 08 04:34:50 2011 +0000
+++ b/engine/core/controller/engine.i	Fri Jun 10 23:37:46 2011 -1000
@@ -23,6 +23,32 @@
 #include "controller/engine.h"
 %}
 
+%header %{
+typedef void (*Callback)();
+
+PyObject *prerender_callback = 0;
+PyObject *postrender_callback = 0;
+
+void preRenderCallback() {
+	if (prerender_callback > 0) {
+		PyEval_CallFunction(prerender_callback, "()");
+	}
+}
+void postRenderCallback() {
+	if (postrender_callback > 0) {
+		PyEval_CallFunction(postrender_callback, "()");
+	}
+}
+%}
+
+%typemap(in) PyObject *callback {
+	if (!PyCallable_Check($input)) {
+		PyErr_SetString(PyExc_TypeError, "Need a callable object!");
+		return 0;
+	}
+	$1 = $input;
+}
+
 namespace FIFE {
 
 	class SoundManager;
@@ -96,6 +122,11 @@
 	};
 
 	class Engine {
+	%rename(c_registerPreRenderCallback) registerPreRenderCallback(Callback);
+	%rename(c_registerPostRenderCallback) registerPostRenderCallback(Callback);
+	%rename(registerPreRenderCallback) py_registerPreRenderCallback(PyObject*);
+	%rename(registerPostRenderCallback) py_registerPostRenderCallback(
+		PyObject*);
 	public:
 		Engine();
 		virtual ~Engine();
@@ -103,6 +134,26 @@
 		void finalizePumping();
 		void pump();
 
+		%extend {
+		void py_registerPreRenderCallback(PyObject *callback)
+		{
+			Py_XDECREF(prerender_callback);
+			Py_XINCREF(callback);
+			prerender_callback = callback;
+			$self->registerPreRenderCallback(&preRenderCallback);
+		}
+		
+		void py_registerPostRenderCallback(PyObject *callback)
+		{
+			Py_XDECREF(postrender_callback);
+			Py_XINCREF(callback);
+			postrender_callback = callback;
+			$self->registerPostRenderCallback(&postRenderCallback);
+		}
+		}
+		void registerPreRenderCallback(Callback callback);
+		void registerPostRenderCallback(Callback callback);
+
 		EngineSettings& getSettings();
 		const DeviceCaps& getDeviceCaps() const;
 		
--- a/engine/core/eventchannel/eventmanager.cpp	Wed Jun 08 04:34:50 2011 +0000
+++ b/engine/core/eventchannel/eventmanager.cpp	Fri Jun 10 23:37:46 2011 -1000
@@ -434,6 +434,7 @@
 	}
 
 	void EventManager::processMouseEvent(SDL_Event event) {
+		// FIXME Technomage 2011-02-02: Guichan just consumes all mouse events.
 		if(dispatchSdlEvent(event))
 			return;