changeset 576:a21915a97237

Added some debug capability when building with mingw on windows. This should work for you if you have debug versions of python available. Added the show and hide functions to the baseobject in the RPG demo.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Mon, 05 Jul 2010 19:36:41 +0000
parents 872a7a94563e
children a922d8ed0ffd
files SConstruct build/win32-config.py build/win32/build_environments/scons/cleanup_engine.bat demos/rpg/scripts/objects/baseobject.py engine/SConscript
diffstat 5 files changed, 53 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/SConstruct	Fri Jul 02 14:41:27 2010 +0000
+++ b/SConstruct	Mon Jul 05 19:36:41 2010 +0000
@@ -105,8 +105,10 @@
 #**************************************************************************
 if GetOption('enable-debug'):
 	debug = 1
+	env['FIFE_DEBUG'] = True
 else:
 	debug = 0
+	env['FIFE_DEBUG'] = False
 	
 if GetOption('disable-opengl'):
 	opengl = 0
--- a/build/win32-config.py	Fri Jul 02 14:41:27 2010 +0000
+++ b/build/win32-config.py	Mon Jul 05 19:36:41 2010 +0000
@@ -49,7 +49,12 @@
 	
 	
 def addExtras(env, opengl):
-	env.Append(LIBS = ['libguichan_sdl', 'libguichan', 'mingw32', 'zlib', 'vorbis', 'ogg', 'vorbisfile', 'libpng', 'SDL_image', 'SDLmain', 'SDL.dll', 'OpenAL32', 'SDL_ttf', 'boost_filesystem', 'boost_regex', 'boost_system', 'python26'])
+	env.Append(LIBS = ['libguichan_sdl', 'libguichan', 'mingw32', 'zlib', 'vorbis', 'ogg', 'vorbisfile', 'libpng', 'SDL_image', 'SDLmain', 'SDL.dll', 'OpenAL32', 'SDL_ttf', 'boost_filesystem', 'boost_regex', 'boost_system'])
+
+	if env['FIFE_DEBUG']:
+		env.Append(LIBS = ['python26_d'])
+	else:
+		env.Append(LIBS = ['python26'])
 
 	if opengl:
 		env.Prepend(LIBS = ['libguichan_opengl'])
--- a/build/win32/build_environments/scons/cleanup_engine.bat	Fri Jul 02 14:41:27 2010 +0000
+++ b/build/win32/build_environments/scons/cleanup_engine.bat	Mon Jul 05 19:36:41 2010 +0000
@@ -1,20 +1,3 @@
-:: Users will need to change paths if they use custom MinGW, SCons, Python or SWIG versions that didn't ship with the SDK
-::SET _=%CD%
-::SET _SWIG="%_%\..\..\applications\swigwin-1.3.40"
-
-:: To avoid path collisions the following line was commented out and replaced with a slightly different version
-:: SET PATH=%Path%;%_%\applications\scons;%_%\applications\mingw\bin
-::SET PATH=%_%\..\..\applications\scons;%_%\..\..\applications\mingw\bin;c:\python25
-
-:: Goto TRUNK and call SCons
-::cd \
-::cd "%_%\..\..\..\.."
 python ..\..\applications\scons\scons.py -C ..\..\..\..\ -c
+python ..\..\applications\scons\scons.py -C ..\..\..\..\ --enable-debug -c
 python ..\..\applications\scons\scons.py -C ..\..\..\..\ -c fife-python fife-swig
-
-:: Delete _fife.pyd
-::cd "%_%\..\..\..\..\engine\swigwrappers\python"
-::del _fife.pyd
-
-:: Return us to the directory we started from
-::cd %_%
--- a/demos/rpg/scripts/objects/baseobject.py	Fri Jul 02 14:41:27 2010 +0000
+++ b/demos/rpg/scripts/objects/baseobject.py	Mon Jul 05 19:36:41 2010 +0000
@@ -48,11 +48,17 @@
 		self._gamecontroller = gamecontroller
 		self._object = obj
 		
+		self._attached = False
+		
 	def detachActionListener(self):
-		self._object.instance.removeActionListener(self)
+		if self._attached:
+			self._object.instance.removeActionListener(self)
+			self._attached = False
 		
 	def attachActionListener(self):
-		self._object.instance.addActionListener(self)
+		if not self._attached:
+			self._object.instance.addActionListener(self)
+			self._attached = True
 
 	def onInstanceActionFinished(self, instance, action):
 		pass
@@ -97,18 +103,26 @@
 			
 		self._activated = True
 		
+	def hide(self):
+		"""
+		Marks the FIFE instance as not visible
+		"""
+		if self._instance:
+			self._instance.get2dGfxVisual().setVisible(False)
+			
+	def show(self):
+		"""
+		Marks the FIFE instance as not visible
+		"""
+		if self._instance:
+			self._instance.get2dGfxVisual().setVisible(True)
+
 	def destroy(self):
 		"""
 		Deletes the FIFE instance from the actor layer on the map.
 		"""
-		
-		#This doesnt work
-		#self._instance.get2dGfxVisual().setVisible(False)
-
-		#remove from the scene instead
 		if self._actionlistener:
 			self._actionlistener.detachActionListener()	
-			self._actionlistener = None
 		
 		if self._instance :
 			self._layer.deleteInstance(self._instance)
@@ -117,16 +131,20 @@
 		self._activated = False
 		
 	def spawn(self, x, y):
-		#This doesnt work
-		#self._instance.get2dGfxVisual().setVisible(True)
-	
+		"""
+		Creates a new FIFE instance and spawns it in the specified x y location
+		"""
 		if self._instance:
 			self._setMapPostion(x,y)
+			self.show()
 		else:
 			self._position.x = x
 			self._position.y = y
 			self._createFIFEInstance(self, self._layer)
 		
+		if self._actionlistener and self._instance:
+			self._actionlistener.attachActionListener()	
+		
 		self._activated = True
 			
 	def setMapPosition(self, x, y):
@@ -221,11 +239,10 @@
 	def _setActivated(self, activate):
 		self._activated = activate
 			
-
 	location = property(_getLocation, _setLocation)
 	instance = property(_getInstance)
 	type = property(_getType)
 	id = property(_getId)
 	modelname = property(_getModelName)
 	position = property(_getPosition, _setPosition)
-	activated = property(_getActivated, _setActivated)
+	active = property(_getActivated, _setActivated)
--- a/engine/SConscript	Fri Jul 02 14:41:27 2010 +0000
+++ b/engine/SConscript	Mon Jul 05 19:36:41 2010 +0000
@@ -112,17 +112,22 @@
 cbproj_linux = env.CodeblocksProjectLinux(os.path.join('..', '..','..', builders.cbbuildpath_linux, 'fife'), projectfiles)
 
 
+if opts['DEBUG'] and sys.platform == 'win32':
+	fife_tgt = 'fife_d'
+else:
+	fife_tgt = 'fife'
+
 #**************************************************************************
 #shared library target
 #**************************************************************************
 
 if sys.platform == 'win32':
-	sharedlib = env.SharedLibrary(target = 'fife',
+	sharedlib = env.SharedLibrary(target = fife_tgt,
 								  source = compilefiles,
 								  OBJPREFIX='shared_',
 								  SHLIBEMITTER = '')
 else:
-	sharedlib = env.SharedLibrary(target = 'fife',
+	sharedlib = env.SharedLibrary(target = fife_tgt,
 								  source = compilefiles)
 
 #**************************************************************************
@@ -133,7 +138,7 @@
 else:
 	dest_suffix = '.so'
 	
-pythonlib = env.SharedLibrary(target = 'fife',
+pythonlib = env.SharedLibrary(target = fife_tgt,
 							  source = pyfiles,
 							  OBJPREFIX='py_',
 							  SHLIBPREFIX='_',
@@ -147,7 +152,11 @@
 							  SWIGOUTDIR=Dir('#/engine/python/fife').srcnode().path)
 							  
 
-copy_dest = os.path.join(opts['PYLIB_COPY_DEST'], '_fife' + dest_suffix)
+if opts['DEBUG'] and sys.platform == 'win32':
+	copy_dest = os.path.join(opts['PYLIB_COPY_DEST'], '_fife_d' + dest_suffix)
+else:
+	copy_dest = os.path.join(opts['PYLIB_COPY_DEST'], '_fife' + dest_suffix)
+	
 copy_cmd = env.Command(copy_dest, pythonlib, [Copy('$TARGET', '$SOURCE')])
 copy_cmd2 = env.Command(os.path.join(opts['WRAP_COPY_DEST'], 'fife_wrap.h'),
 				os.path.join('swigwrappers','python','fife_wrap.h'),
@@ -160,7 +169,7 @@
 #static library target
 #**************************************************************************
 
-staticlib = env.StaticLibrary(target = 'fife',
+staticlib = env.StaticLibrary(target = fife_tgt,
 							  source = compilefiles,
 							  LINKFLAGS=['-Wl'])