Ticket #246: import_patch.diff
| File import_patch.diff, 14.6 KB (added by barra_parpg, 7 months ago) |
|---|
-
game/scripts/gui/context_menu.py
15 15 # You should have received a copy of the GNU General Public License 16 16 # along with PARPG. If not, see <http://www.gnu.org/licenses/>. 17 17 18 import fife19 import pychan18 from fife import fife 19 from fife.extensions import pychan 20 20 21 21 class ContextMenu(object): 22 22 def __init__(self, engine, menu_items, pos): -
game/scripts/gui/dialoguegui.py
15 15 # You should have received a copy of the GNU General Public License 16 16 # along with PARPG. If not, see <http://www.gnu.org/licenses/>. 17 17 18 import pychan 19 import fife 20 import pychan.widgets as widgets 18 from fife import fife 19 from fife.extensions import pychan 20 from fife.extensions.pychan import widgets 21 21 22 from scripts.dialogue import DialogueEngine 22 23 23 24 class DialogueGUI(object): -
game/scripts/gui/hud.py
16 16 # along with PARPG. If not, see <http://www.gnu.org/licenses/>. 17 17 18 18 import shutil 19 import fife 20 import pychan 21 import pychan.widgets as widgets 22 from pychan.tools import callbackWithArguments as cbwa 19 from fife import fife 20 from fife.extensions import pychan 21 from fife.extensions.pychan.tools import callbackWithArguments as cbwa 22 from fife.extensions.pychan import widgets 23 23 24 from scripts.gui.filebrowser import FileBrowser 24 25 from scripts.gui.context_menu import ContextMenu 25 26 from scripts.gui import inventorygui -
game/scripts/gui/inventorygui.py
15 15 # You should have received a copy of the GNU General Public License 16 16 # along with PARPG. If not, see <http://www.gnu.org/licenses/>. 17 17 18 import fife 19 import pychan 18 from fife import fife 19 from fife.extensions import pychan 20 from fife.extensions.pychan.tools import callbackWithArguments as cbwa 21 20 22 from scripts.gui import drag_drop_data as data_drag 21 from pychan.tools import callbackWithArguments as cbwa22 23 23 24 class InventoryGUI(object): 24 25 """Inventory GUI class""" -
game/scripts/gui/filebrowser.py
13 13 # You should have received a copy of the GNU General Public License 14 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 15 16 import pychan 17 import pychan.widgets as widgets 16 from fife.extensions import pychan 17 from fife.extensions.pychan import widgets 18 18 19 import sys 19 20 20 21 def u2s(string): -
game/scripts/gui/popups.py
15 15 # You should have received a copy of the GNU General Public License 16 16 # along with PARPG. If not, see <http://www.gnu.org/licenses/>. 17 17 18 import fife 19 import pychan 18 from fife import fife 19 from fife.extensions import pychan 20 from fife.extensions.pychan.tools import callbackWithArguments as cbwa 21 20 22 from scripts.gui import drag_drop_data as data_drag 21 23 from scripts.items import item_image_dict 22 from pychan.tools import callbackWithArguments as cbwa23 24 24 25 class ContainerGUI(): 25 26 def __init__(self, engine, title, container): -
game/scripts/common/eventlistenerbase.py
15 15 # You should have received a copy of the GNU General Public License 16 16 # along with PARPG. If not, see <http://www.gnu.org/licenses/>. 17 17 18 import fife18 from fife import fife 19 19 20 20 class EventListenerBase(fife.IKeyListener, fife.ICommandListener, fife.IMouseListener, fife.ConsoleExecuter): 21 21 def __init__(self, engine, reg_keys=False, reg_cmd=False, reg_mouse=False, reg_console=False, reg_widget=False): -
game/scripts/objects/base.py
50 50 def __init__ (self, *args, **kwargs): 51 51 super(TinCan,self).__init__ (*args, **kwargs) 52 52 self.name = 'Tin Can'""" 53 import fife53 from fife import fife 54 54 from settings import Setting 55 55 from random import randrange 56 56 from scripts.gui.popups import ExaminePopup, ContainerGUI -
game/scripts/objects/actors.py
14 14 15 15 # You should have received a copy of the GNU General Public License 16 16 # along with PARPG. If not, see <http://www.gnu.org/licenses/>. 17 import fife 17 18 from fife import fife 18 19 from scripts import world 19 20 from base import * 20 21 from composed import * -
game/scripts/objects/containers.py
24 24 25 25 from composed import ImmovableContainer 26 26 from composed import CarryableItem 27 import fife27 from fife import fife 28 28 29 29 class WoodenCrate (ImmovableContainer): 30 30 def __init__ (self, ID, name = 'Wooden Crate', \ -
game/scripts/map.py
15 15 # You should have received a copy of the GNU General Public License 16 16 # along with PARPG. If not, see <http://www.gnu.org/licenses/>. 17 17 18 import fife18 from fife import fife 19 19 import time 20 20 from local_loaders.loaders import loadMapFile 21 21 from scripts.common.eventlistenerbase import EventListenerBase -
game/scripts/world.py
17 17 18 18 import time 19 19 import fife 20 import pychan20 from fife.extensions import pychan 21 21 from sounds import SoundEngine 22 22 from datetime import date 23 23 from scripts.common.eventlistenerbase import EventListenerBase … … 26 26 from settings import Setting 27 27 from scripts.gui import hud 28 28 from scripts.gui.popups import * 29 from pychan.tools import callbackWithArguments as cbwa29 from fife.extensions.pychan.tools import callbackWithArguments as cbwa 30 30 from map import Map 31 31 32 32 TDS = Setting() -
game/run.py
23 23 if not os.path.exists('settings.xml'): 24 24 shutil.copyfile('settings-dist.xml', 'settings.xml') 25 25 26 import fife_compat, fife, fifelog 27 import pychan 26 from fife import fife 27 from fife.extensions import fife_compat, fifelog, pychan 28 from fife.extensions.basicapplication import ApplicationBase 29 28 30 from scripts import world 29 31 from scripts import engine 30 32 from scripts import console 31 33 from scripts.engine import Engine 32 34 from scripts.common import eventlistenerbase 33 from basicapplication import ApplicationBase34 35 from settings import Setting 35 36 36 37 TDS = Setting() -
game/local_loaders/loaders.py
16 16 # Most of this code was copied from the FIFE file loaders.py 17 17 # It is part of the local code base now so we customize what happens as 18 18 # we read map files 19 import fife19 from fife import fife 20 20 21 21 from xmlmap import XMLMapLoader 22 from serializers import WrongFileType, NameClash22 from fife.extensions.serializers import WrongFileType, NameClash 23 23 24 from serializers.xmlobject import XMLObjectLoader24 from fife.extensions.serializers.xmlobject import XMLObjectLoader 25 25 26 26 fileExtensions = ('xml',) 27 27 -
game/local_loaders/xmlmap.py
17 17 # It is part of the local code base now so we can customize what happens 18 18 # as we read map files 19 19 20 import fife 20 import sys, os 21 22 from fife import fife 21 23 try: 22 24 import xml.etree.cElementTree as ET 23 25 except: 24 26 import xml.etree.ElementTree as ET 25 27 26 import loaders27 from serializers import *28 from fife.extensions import loaders 29 from fife.extensions import serializers 28 30 import time 29 31 30 32 FORMAT = '1.0' 31 33 34 def 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 66 def 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 81 def 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 32 91 class XMLMapLoader(fife.ResourceLoader): 33 92 def __init__(self, engine, data, callback): 34 93 """ 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 24 import sys, os 25 from fife import fife 26 from traceback import print_exc 27 28 __all__ = ('ET', 'SerializerError', 'InvalidFormat', 'WrongFileType', 'NameClash', 'NotFound', 'warn', 'root_subfile', 'reverse_root_subfile') 29 30 try: 31 import xml.etree.cElementTree as ET 32 except: 33 import xml.etree.ElementTree as ET 34 35 class SerializerError(Exception): 36 pass 37 38 class InvalidFormat(SerializerError): 39 pass 40 41 class WrongFileType(SerializerError): 42 pass 43 44 class NameClash(SerializerError): 45 pass 46 47 class NotFound(SerializerError): 48 pass 49 50 def warn(self, msg): 51 print 'Warning (%s): %s' % (self.filename, msg) 52 53 def 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 85 def 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 100 def 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))
