Ticket #246: import_patch.diff

File import_patch.diff, 14.6 KB (added by barra_parpg, 10 years ago)
  • game/scripts/gui/context_menu.py

     
    1515#   You should have received a copy of the GNU General Public License 
    1616#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
    1717 
    18 import fife 
    19 import pychan 
     18from fife import fife 
     19from fife.extensions import pychan 
    2020 
    2121class ContextMenu(object): 
    2222    def __init__(self, engine, menu_items, pos): 
  • game/scripts/gui/dialoguegui.py

     
    1515#   You should have received a copy of the GNU General Public License 
    1616#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
    1717 
    18 import pychan 
    19 import fife 
    20 import pychan.widgets as widgets 
     18from fife import fife 
     19from fife.extensions import pychan 
     20from fife.extensions.pychan import widgets 
     21 
    2122from scripts.dialogue import DialogueEngine 
    2223 
    2324class DialogueGUI(object): 
  • game/scripts/gui/hud.py

     
    1616#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
    1717 
    1818import shutil 
    19 import fife 
    20 import pychan 
    21 import pychan.widgets as widgets 
    22 from pychan.tools import callbackWithArguments as cbwa 
     19from fife import fife 
     20from fife.extensions import pychan 
     21from fife.extensions.pychan.tools import callbackWithArguments as cbwa 
     22from fife.extensions.pychan import widgets 
     23 
    2324from scripts.gui.filebrowser import FileBrowser 
    2425from scripts.gui.context_menu import ContextMenu 
    2526from scripts.gui import inventorygui 
  • game/scripts/gui/inventorygui.py

     
    1515#   You should have received a copy of the GNU General Public License 
    1616#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
    1717 
    18 import fife 
    19 import pychan 
     18from fife import fife 
     19from fife.extensions import pychan 
     20from fife.extensions.pychan.tools import callbackWithArguments as cbwa 
     21 
    2022from scripts.gui import drag_drop_data as data_drag 
    21 from pychan.tools import callbackWithArguments as cbwa 
    2223 
    2324class InventoryGUI(object): 
    2425    """Inventory GUI class""" 
  • game/scripts/gui/filebrowser.py

     
    1313#   You should have received a copy of the GNU General Public License 
    1414#   along with this program.  If not, see <http://www.gnu.org/licenses/>. 
    1515 
    16 import pychan 
    17 import pychan.widgets as widgets 
     16from fife.extensions import pychan 
     17from fife.extensions.pychan import widgets 
     18 
    1819import sys 
    1920 
    2021def u2s(string): 
  • game/scripts/gui/popups.py

     
    1515#   You should have received a copy of the GNU General Public License 
    1616#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
    1717 
    18 import fife 
    19 import pychan 
     18from fife import fife 
     19from fife.extensions import pychan 
     20from fife.extensions.pychan.tools import callbackWithArguments as cbwa 
     21 
    2022from scripts.gui import drag_drop_data as data_drag 
    2123from scripts.items import item_image_dict 
    22 from pychan.tools import callbackWithArguments as cbwa 
    2324 
    2425class ContainerGUI(): 
    2526    def __init__(self, engine, title, container): 
  • game/scripts/common/eventlistenerbase.py

     
    1515#   You should have received a copy of the GNU General Public License 
    1616#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
    1717 
    18 import fife 
     18from fife import fife 
    1919 
    2020class EventListenerBase(fife.IKeyListener, fife.ICommandListener, fife.IMouseListener, fife.ConsoleExecuter): 
    2121    def __init__(self, engine, reg_keys=False, reg_cmd=False, reg_mouse=False, reg_console=False, reg_widget=False): 
  • game/scripts/objects/base.py

     
    5050       def __init__ (self, *args, **kwargs): 
    5151           super(TinCan,self).__init__ (*args, **kwargs) 
    5252           self.name = 'Tin Can'""" 
    53 import fife 
     53from fife import fife 
    5454from settings import Setting 
    5555from random import randrange 
    5656from scripts.gui.popups import ExaminePopup, ContainerGUI 
  • game/scripts/objects/actors.py

     
    1414 
    1515#   You should have received a copy of the GNU General Public License 
    1616#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
    17 import fife 
     17 
     18from fife import fife 
    1819from scripts import world 
    1920from base import * 
    2021from composed import * 
  • game/scripts/objects/containers.py

     
    2424 
    2525from composed import ImmovableContainer 
    2626from composed import CarryableItem 
    27 import fife 
     27from fife import fife 
    2828 
    2929class WoodenCrate (ImmovableContainer): 
    3030    def __init__ (self, ID, name = 'Wooden Crate', \ 
  • game/scripts/map.py

     
    1515#   You should have received a copy of the GNU General Public License 
    1616#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
    1717 
    18 import fife 
     18from fife import fife 
    1919import time 
    2020from local_loaders.loaders import loadMapFile 
    2121from scripts.common.eventlistenerbase import EventListenerBase 
  • game/scripts/world.py

     
    1717 
    1818import time 
    1919import fife 
    20 import pychan 
     20from fife.extensions import pychan 
    2121from sounds import SoundEngine 
    2222from datetime import date 
    2323from scripts.common.eventlistenerbase import EventListenerBase 
     
    2626from settings import Setting 
    2727from scripts.gui import hud 
    2828from scripts.gui.popups import * 
    29 from pychan.tools import callbackWithArguments as cbwa 
     29from fife.extensions.pychan.tools import callbackWithArguments as cbwa 
    3030from map import Map 
    3131 
    3232TDS = Setting() 
  • game/run.py

     
    2323if not os.path.exists('settings.xml'): 
    2424    shutil.copyfile('settings-dist.xml', 'settings.xml') 
    2525 
    26 import fife_compat, fife, fifelog 
    27 import pychan 
     26from fife import fife 
     27from fife.extensions import fife_compat, fifelog, pychan 
     28from fife.extensions.basicapplication import ApplicationBase 
     29 
    2830from scripts import world 
    2931from scripts import engine 
    3032from scripts import console 
    3133from scripts.engine import Engine 
    3234from scripts.common import eventlistenerbase 
    33 from basicapplication import ApplicationBase 
    3435from settings import Setting 
    3536 
    3637TDS = Setting() 
  • game/local_loaders/loaders.py

     
    1616# Most of this code was copied from the FIFE file loaders.py 
    1717# It is part of the local code base now so we customize what happens as  
    1818# we read map files 
    19 import fife 
     19from fife import fife 
    2020 
    2121from xmlmap import XMLMapLoader 
    22 from serializers import WrongFileType, NameClash 
     22from fife.extensions.serializers import WrongFileType, NameClash 
    2323 
    24 from serializers.xmlobject import XMLObjectLoader 
     24from fife.extensions.serializers.xmlobject import XMLObjectLoader 
    2525 
    2626fileExtensions = ('xml',) 
    2727 
  • game/local_loaders/xmlmap.py

     
    1717# It is part of the local code base now so we can customize what happens 
    1818# as we read map files 
    1919 
    20 import fife  
     20import sys, os 
     21 
     22from fife import fife  
    2123try: 
    2224    import xml.etree.cElementTree as ET 
    2325except: 
    2426    import xml.etree.ElementTree as ET 
    2527 
    26 import loaders 
    27 from serializers import * 
     28from fife.extensions import loaders 
     29from fife.extensions import serializers 
    2830import time 
    2931 
    3032FORMAT = '1.0' 
    3133 
     34def root_subfile(masterfile, subfile): 
     35        ''' 
     36        Returns new path for given subfile (path), which is rooted against masterfile 
     37        E.g. if masterfile is ./../foo/bar.xml and subfile is ./../foo2/subfoo.xml, 
     38        returned path is ../foo2/subfoo.xml 
     39        NOTE: masterfile is expected to be *file*, not directory. subfile can be either 
     40        ''' 
     41        s = '/' 
     42 
     43        masterfile = norm_path(os.path.abspath(masterfile)) 
     44        subfile = norm_path(os.path.abspath(subfile)) 
     45 
     46        master_fragments = masterfile.split(s) 
     47        sub_fragments = subfile.split(s) 
     48 
     49        master_leftovers = [] 
     50        sub_leftovers = [] 
     51 
     52        for i in xrange(len(master_fragments)): 
     53                try: 
     54                        if master_fragments[i] == sub_fragments[i]: 
     55                                master_leftovers = master_fragments[i+1:] 
     56                                sub_leftovers = sub_fragments[i+1:] 
     57                except IndexError: 
     58                        break 
     59 
     60        pathstr = '' 
     61        for f in master_leftovers[:-1]: 
     62                pathstr += '..' + s 
     63        pathstr += s.join(sub_leftovers) 
     64        return pathstr 
     65 
     66def reverse_root_subfile(masterfile, subfile): 
     67        ''' 
     68        does inverse operation to root_subfile. E.g.  
     69        E.g. if masterfile is ./../foo/bar.xml and subfile is ../foo2/subfoo.xml, 
     70        returned path ./../foo2/subfoo.xml 
     71        Usually this function is used to convert saved paths into engine relative paths 
     72        NOTE: masterfile is expected to be *file*, not directory. subfile can be either 
     73        ''' 
     74        s = '/' 
     75 
     76        masterfile = norm_path(os.path.abspath(masterfile)).split(s)[:-1] 
     77        subfile = norm_path(os.path.abspath( s.join(masterfile) + s + subfile )) 
     78        masterfile = norm_path(os.getcwd()) + s + 'foo.bar' # cheat a little to satisfy root_subfile 
     79        return root_subfile(masterfile, subfile) 
     80 
     81def norm_path(path): 
     82        ''' 
     83        Makes the path use '/' delimited separators. FIFE always uses these delimiters, but some os-related 
     84  routines will default to os.path.sep. 
     85        ''' 
     86        if os.path.sep == '/': 
     87                return path 
     88 
     89        return '/'.join(path.split(os.path.sep))         
     90 
    3291class XMLMapLoader(fife.ResourceLoader): 
    3392    def __init__(self, engine, data, callback): 
    3493        """ The XMLMapLoader parses the xml map using several section.  
  • game/local_loaders/__init__.py

     
     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 
     24import sys, os 
     25from fife import fife 
     26from traceback import print_exc 
     27 
     28__all__ = ('ET', 'SerializerError', 'InvalidFormat', 'WrongFileType', 'NameClash', 'NotFound', 'warn', 'root_subfile', 'reverse_root_subfile') 
     29 
     30try: 
     31        import xml.etree.cElementTree as ET 
     32except: 
     33        import xml.etree.ElementTree as ET 
     34 
     35class SerializerError(Exception): 
     36        pass 
     37 
     38class InvalidFormat(SerializerError): 
     39        pass 
     40 
     41class WrongFileType(SerializerError): 
     42        pass 
     43 
     44class NameClash(SerializerError): 
     45        pass 
     46 
     47class NotFound(SerializerError): 
     48        pass 
     49 
     50def warn(self, msg): 
     51        print 'Warning (%s): %s' % (self.filename, msg) 
     52 
     53def root_subfile(masterfile, subfile): 
     54        ''' 
     55        Returns new path for given subfile (path), which is rooted against masterfile 
     56        E.g. if masterfile is ./../foo/bar.xml and subfile is ./../foo2/subfoo.xml, 
     57        returned path is ../foo2/subfoo.xml 
     58        NOTE: masterfile is expected to be *file*, not directory. subfile can be either 
     59        ''' 
     60        s = '/' 
     61 
     62        masterfile = norm_path(os.path.abspath(masterfile)) 
     63        subfile = norm_path(os.path.abspath(subfile)) 
     64 
     65        master_fragments = masterfile.split(s) 
     66        sub_fragments = subfile.split(s) 
     67 
     68        master_leftovers = [] 
     69        sub_leftovers = [] 
     70 
     71        for i in xrange(len(master_fragments)): 
     72                try: 
     73                        if master_fragments[i] == sub_fragments[i]: 
     74                                master_leftovers = master_fragments[i+1:] 
     75                                sub_leftovers = sub_fragments[i+1:] 
     76                except IndexError: 
     77                        break 
     78 
     79        pathstr = '' 
     80        for f in master_leftovers[:-1]: 
     81                pathstr += '..' + s 
     82        pathstr += s.join(sub_leftovers) 
     83        return pathstr 
     84 
     85def reverse_root_subfile(masterfile, subfile): 
     86        ''' 
     87        does inverse operation to root_subfile. E.g.  
     88        E.g. if masterfile is ./../foo/bar.xml and subfile is ../foo2/subfoo.xml, 
     89        returned path ./../foo2/subfoo.xml 
     90        Usually this function is used to convert saved paths into engine relative paths 
     91        NOTE: masterfile is expected to be *file*, not directory. subfile can be either 
     92        ''' 
     93        s = '/' 
     94 
     95        masterfile = norm_path(os.path.abspath(masterfile)).split(s)[:-1] 
     96        subfile = norm_path(os.path.abspath( s.join(masterfile) + s + subfile )) 
     97        masterfile = norm_path(os.getcwd()) + s + 'foo.bar' # cheat a little to satisfy root_subfile 
     98        return root_subfile(masterfile, subfile) 
     99 
     100def norm_path(path): 
     101        ''' 
     102        Makes the path use '/' delimited separators. FIFE always uses these delimiters, but some os-related 
     103  routines will default to os.path.sep. 
     104        ''' 
     105        if os.path.sep == '/': 
     106                return path 
     107 
     108        return '/'.join(path.split(os.path.sep))