Changeset 786
- Timestamp:
- 03/06/11 20:33:52 (9 years ago)
- Location:
- branches/active/character_customization/game
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/active/character_customization/game/run.py
- Property svn:executable deleted
r765 r786 14 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 15 16 import os17 import shutil18 import imp19 16 import sys 17 import logging 20 18 21 """ Module never used 22 #Check if config.py exists. Get 'fife_path' from config 23 try: 24 import config 25 sys.path.append(config.fife_path) 26 except: 27 pass 19 from argparse import ArgumentParser 20 from parpg.settings import Settings 21 22 # setup parser 23 parser = ArgumentParser(description='PARPG Launcher Script') 24 parser.add_argument('-s', '--settings', nargs='+', 25 dest='filenames', metavar='filename', 26 default='.', 27 help='One or more files to load settings from') 28 args = parser.parse_args() 29 30 # initialize settigns 31 settings = Settings(paths=args.filenames) 32 33 levels = {'debug': logging.DEBUG, 34 'info': logging.INFO, 35 'warning': logging.WARNING, 36 'error': logging.ERROR, 37 'critical': logging.CRITICAL} 38 39 log_file = settings.parpg.LogFile or 'parpg.log' 40 log_level = settings.parpg.LogLevel or 'critical' 41 logging.basicConfig(filename=log_file, level=levels[log_level]) 42 43 if settings.parpg.FifePath is not None: 44 sys.path.insert(0, settings.parpg.FifePath) 28 45 29 46 try: 30 from fife import fife 31 print "Using the FIFE python module found here: ", \ 32 os.path.dirname(fife.__file__) 47 from fife import fife 48 from parpg.application import PARPGApplication 49 50 from parpg.common import utils 33 51 except ImportError: 34 print "====================================================================== \n\ 35 FIFE was not found in path. \n\ 36 Try installing FIFE or creating config.py in the PARPG root directory, \n\ 37 with a variable pointing to the 'python' subdirectory \n\ 38 fife_path='<path_to_your_FIFE>' \n\ 39 Example: fife_path='../fife/engine/python/' \n\ 40 ======================================================================" 41 """ 52 #TODO: pay attention to which module actually failed 53 logging.critical("Could not import fife module. 'Please install fife or add " 54 "'FifePath' to the [parpg] section of your settings file") 55 sys.exit(1) 42 56 43 from parpg.settings import Settings 44 from parpg.application import PARPGApplication 57 # enable psyco if available and in settings file 58 try: 59 import psyco 60 psyco_available = True 61 except ImportError: 62 logging.warning('Psyco Acceleration unavailable') 63 psyco_available = False 45 64 46 from parpg.common import utils 65 if settings.fife.UsePsyco: 66 if psyco_available: 67 psyco.full() 68 logging.info('Psyco Acceleration enabled') 69 else: 70 logging.warning('Please install psyco before attempting to use it' 71 'Psyco Acceleration disabled') 72 else: 73 logging.info('Psycho Acceleration disabled') 47 74 48 # add paths to the swig extensions 49 utils.addPaths ('../../engine/swigwrappers/python', '../../engine/extensions') 50 utils.addPaths ('./lib', './lib/extensions') 51 52 53 """This folder holds the main meta-data for PARPG. This file should be 54 minimal, since folding code into the controller with MVC is usually bad 55 All game and logic and data is held held and referenced in 56 /parpg/engine.py. All fife stuff goes in /parpg/world.py""" 57 58 def main_is_frozen(): 59 """returns True when running the exe, 60 and False when running from a script. """ 61 return (hasattr(sys, "frozen") or # new py2exe 62 hasattr(sys, "importers") # old py2exe 63 or imp.is_frozen("__main__")) # tools/freeze 64 65 def get_main_dir(): 66 """returns the directory name of the script 67 or the directory name of the exe""" 68 if main_is_frozen(): 69 return os.path.dirname(sys.executable) 70 return os.path.dirname(sys.argv[0]) 71 72 73 def main(): 74 """Application code starts from here""" 75 app = PARPGApplication(settings) 76 app.run() 77 78 if __name__ == '__main__': 79 #TODO: properly wrap this with option_parser 80 if '-c' in sys.argv: 81 settings = Settings(paths=sys.argv[sys.argv.index('-c') + 1:]) 82 else: 83 settings = Settings(paths='.') 84 85 if settings.fife.UsePsyco: 86 # Import Psyco if available 87 try: 88 import psyco 89 psyco.full() 90 print "Psyco acceleration in use" 91 except ImportError: 92 print "Psyco acceleration not used" 93 else: 94 print "Psyco acceleration not used" 95 main() 75 # run the game 76 app = PARPGApplication(settings) 77 app.run() -
branches/active/character_customization/game/settings.ini
r775 r786 15 15 WindowIcon = gui/icons/window_icon.png 16 16 Font = fonts/oldtypewriter.ttf 17 FontsDirectory = fonts /17 FontsDirectory = fonts 18 18 FontGlyphs = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&`'*#=[]\"" 19 19 DefaultFontSize = 12 … … 28 28 29 29 [parpg] 30 LogFile = parpg.log 31 LogLevel = debug 30 32 Map = Mall 31 33 ObjectDatabaseFile = objects/object_database.yaml 32 34 MapsFile = maps/maps.yaml 33 35 AllAgentsFile = maps/all_agents.yaml 34 AgentsDirectory = objects /35 CursorDirectory = gui/cursors /36 AgentsDirectory = objects 37 CursorDirectory = gui/cursors 36 38 CursorDefault = gui/cursors/cursor_plain.png 37 39 CursorUp = gui/cursors/cursor_up.png … … 39 41 CursorDown = gui/cursors/cursor_down.png 40 42 CursorLeft = gui/cursors/cursor_left.png 41 DialoguesDirectory = dialogue /42 QuestsDirectory = quests /43 DialoguesDirectory = dialogue 44 QuestsDirectory = quests 43 45 PCSpeed = 3
Note: See TracChangeset
for help on using the changeset viewer.