Package fife :: Package extensions :: Module fife_compat
[hide private]
[frames] | no frames]

Source Code for Module fife.extensions.fife_compat

 1  # -*- coding: utf-8 -*- 
 2   
 3  # #################################################################### 
 4  #  Copyright (C) 2005-2009 by the FIFE team 
 5  #  http://www.fifengine.de 
 6  #  This file is part of FIFE. 
 7  # 
 8  #  FIFE is free software; you can redistribute it and/or 
 9  #  modify it under the terms of the GNU Lesser General Public 
10  #  License as published by the Free Software Foundation; either 
11  #  version 2.1 of the License, or (at your option) any later version. 
12  # 
13  #  This library is distributed in the hope that it will be useful, 
14  #  but WITHOUT ANY WARRANTY; without even the implied warranty of 
15  #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
16  #  Lesser General Public License for more details. 
17  # 
18  #  You should have received a copy of the GNU Lesser General Public 
19  #  License along with this library; if not, write to the 
20  #  Free Software Foundation, Inc., 
21  #  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA 
22  # #################################################################### 
23   
24  """ 
25  FIFE Backwards Combatibility Layer 
26  ================================== 
27   
28  This module can be imported if you want to 
29  run code that wasn't adapted to API changes in FIFE. 
30   
31  2008.1 
32  ------ 
33   
34   - Animation.addFrame now expects a fife.ResourcePtr instead of an fife.Image 
35   - Pool.getIndex is just an alias for Pool.addResourceFromFile. 
36   - EventManager.setNonConsumableKeys is superseeded by EventManager.setKeyFilter 
37   
38  """ 
39   
40  from fife import fife 
41   
42  # Utility functions 
43   
44 -def deprecated(revision,message):
45 print "fife_compat: Deprecation warning - See revision %d " % revision 46 print " - ",message
47
48 -def this_is_deprecated(func,revision=0,message=None):
49 if message is None: 50 message = repr(func) + " is deprecated." 51 def wrapped_func(*args,**kwargs): 52 deprecated(revision,message) 53 return func(*args,**kwargs)
54 return wrapped_func 55
56 -def _compat_NonConsumableKeys():
57 class CompatKeyFilter(fife.IKeyFilter): 58 def __init__(self, keys): 59 fife.IKeyFilter.__init__(self) 60 self.keys = keys
61 62 def isFiltered(self, event): 63 return event.getKey().getValue() in self.keys 64 65 def _setNonConsumableKeys(self,keys): 66 deprecated(2636, "Write an IKeyFilter instead of using EventManager.setNonConsumableKeys.\n" + 67 "You probably don't need it anyway") 68 self.compat_keyfilter = CompatKeyFilter(keys) 69 self.compat_keyfilter.__disown__() 70 self.setKeyFilter(self.compat_keyfilter) 71 72 def _getNonConsumableKeys(self,keys): 73 deprecated(2636, "Write an IKeyFilter instead of using EventManager.getNonConsumableKeys.") 74 return self.compat_keyfilter.keys 75 76 fife.EventManager.setNonConsumableKeys = _setNonConsumableKeys 77 fife.EventManager.getNonConsumableKeys = _getNonConsumableKeys 78 79 _compat_NonConsumableKeys() 80