Mercurial > fife-parpg
changeset 152:679ed3e15513
Deprecation: getIndex is now thrown out.
Import fife_compat for the transition.
author | phoku@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 11 Oct 2008 12:55:41 +0000 |
parents | afcd83f7fac8 |
children | d8e32b4adc5c |
files | engine/core/util/resource/pool.cpp engine/core/util/resource/pool.h engine/core/util/resource/resource.i engine/extensions/fife_compat.py engine/extensions/serializers/xmlanimation.py engine/extensions/serializers/xmlobject.py |
diffstat | 6 files changed, 28 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/engine/core/util/resource/pool.cpp Sat Oct 11 12:25:53 2008 +0000 +++ b/engine/core/util/resource/pool.cpp Sat Oct 11 12:55:41 2008 +0000 @@ -149,11 +149,6 @@ res->setPoolId(index); return *res; } - - int Pool::getIndex(const std::string& filename) { - // create resource - return addResourceFromFile(filename); - } void Pool::release(unsigned int index, bool dec) { if (index >= m_entries.size()) {
--- a/engine/core/util/resource/pool.h Sat Oct 11 12:25:53 2008 +0000 +++ b/engine/core/util/resource/pool.h Sat Oct 11 12:55:41 2008 +0000 @@ -90,11 +90,6 @@ */ virtual IResource& get(unsigned int index, bool inc = false); - /** Gets resource index from pool with given filename - * The resource will be created if it is not in the pool - */ - virtual int getIndex(const std::string& filename); - /** Removes the resource from pool if reference counter is null * * @param dec Specifies weither the ref counter will be decreased
--- a/engine/core/util/resource/resource.i Sat Oct 11 12:25:53 2008 +0000 +++ b/engine/core/util/resource/resource.i Sat Oct 11 12:55:41 2008 +0000 @@ -90,7 +90,6 @@ virtual int purgeLoadedResources(); virtual void addResourceLoader(ResourceLoader* loader); virtual void release(unsigned int index, bool dec = false); - virtual unsigned int getIndex(const std::string& filename); virtual IResource& get(unsigned int index, bool inc = false); virtual void printStatistics();
--- a/engine/extensions/fife_compat.py Sat Oct 11 12:25:53 2008 +0000 +++ b/engine/extensions/fife_compat.py Sat Oct 11 12:55:41 2008 +0000 @@ -10,19 +10,40 @@ ------ - Animation.addFrame now expects a fife.ResourcePtr instead of an fife.Image - + - Pool.getIndex is just an alias for Pool.addResourceFromFile. """ import fife +# Utility functions + +def deprecated(revision,message): + print "fife_compat: Deprecation warning - See revision %d " % revision + print " - ",message + +def this_is_deprecated(func,revision=0,message=None): + if message is None: + message = repr(func) + " is deprecated." + def wrapped_func(*args,**kwargs): + deprecated(revision,message) + return func(*args,**kwargs) + return wrapped_func + # 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) + if not isinstance(image_ptr,fife.ResourcePtr): + image_ptr = fife.ResourcePtr(image_ptr) + deprecated(2616,"Animation.addFrame doesn't accept Image* anymore ") + return f(self,image_ptr,delay) return addFrame -fife.Animation.addFrame = decorate_addFrame(fife.Animation.addFrame) \ No newline at end of file +fife.Animation.addFrame = decorate_addFrame(fife.Animation.addFrame) +fife.Pool.getIndex = this_is_deprecated( + fife.Pool.addResourceFromFile, + revision = 2617, + message = "Use addResourceFromFile instead of getIndex" +)
--- a/engine/extensions/serializers/xmlanimation.py Sat Oct 11 12:25:53 2008 +0000 +++ b/engine/extensions/serializers/xmlanimation.py Sat Oct 11 12:55:41 2008 +0000 @@ -1,5 +1,4 @@ import fife -import fife_compat from serializers import * class XMLAnimationLoader(fife.ResourceLoader): @@ -51,8 +50,6 @@ 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 return animation
--- a/engine/extensions/serializers/xmlobject.py Sat Oct 11 12:25:53 2008 +0000 +++ b/engine/extensions/serializers/xmlobject.py Sat Oct 11 12:55:41 2008 +0000 @@ -99,7 +99,7 @@ path.pop() path.append(str(source)) - id = self.image_pool.getIndex('/'.join(path)) + id = self.image_pool.addResourceFromFile('/'.join(path)) object.get2dGfxVisual().addStaticImage(int( image.get('direction', 0) ), id) img = self.image_pool.getImage(id) img.setXShift(int( image.get('x_offset', 0) )) @@ -126,7 +126,7 @@ path.pop() path.append(str(source)) - anim_id = self.anim_pool.getIndex('/'.join(path)) + anim_id = self.anim_pool.addResourceFromFile('/'.join(path)) animation = self.anim_pool.getAnimation(anim_id) action.get2dGfxVisual().addAnimation(int( anim.get('direction', 0) ), anim_id) action.setDuration(animation.getDuration())