changeset 151:afcd83f7fac8

Backwards compatibility module fife_compat. Import and you'll get the old interface. This is just a start to make small API changes smoother.
author phoku@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 11 Oct 2008 12:25:53 +0000
parents 6e7d228def30
children 679ed3e15513
files engine/extensions/fife_compat.py engine/extensions/serializers/xmlanimation.py
diffstat 2 files changed, 30 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/engine/extensions/fife_compat.py	Sat Oct 11 12:25:53 2008 +0000
@@ -0,0 +1,28 @@
+
+"""
+FIFE Backwards Combatibility Layer
+==================================
+
+This module can be imported if you want to
+run code that wasn't adapted to API changes in FIFE.
+
+2008.1
+------
+
+ - Animation.addFrame now expects a fife.ResourcePtr instead of an fife.Image
+
+
+"""
+
+import fife
+
+# 2008.1 compatibility functions
+
+def decorate_addFrame(f):
+	""" Revision 2616 - Animation.addFrame doesn't accept Image* anymore """
+	def addFrame(self,image_ptr, delay):
+		resource_ptr = fife.ResourcePtr(image_ptr)
+		return f(self,resource_ptr,delay)
+	return addFrame
+
+fife.Animation.addFrame = decorate_addFrame(fife.Animation.addFrame)
\ No newline at end of file
--- a/engine/extensions/serializers/xmlanimation.py	Sat Oct 11 12:03:59 2008 +0000
+++ b/engine/extensions/serializers/xmlanimation.py	Sat Oct 11 12:25:53 2008 +0000
@@ -1,4 +1,5 @@
 import fife
+import fife_compat
 from serializers import *
 
 class XMLAnimationLoader(fife.ResourceLoader):
@@ -50,6 +51,7 @@
 
 			image_index = self.imagepool.addResourceFromLocation(image_location)
 			animation.addFrame(fife.ResourcePtr(self.imagepool,image_index), frame_delay)
+			#animation.addFrame(self.imagepool.get(image_index), frame_delay)
 			#print "...",image_index,image_location.getFilename()
 
 		animation.thisown = 0