source: branches/active/character_customization/game/run.py @ 766

Revision 765, 3.0 KB checked in by aspidites, 8 years ago (diff)

Patch by Aspidites

+ now possible to close options window

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1#!/usr/bin/env python2
2
3#   This program is free software: you can redistribute it and/or modify
4#   it under the terms of the GNU General Public License as published by
5#   the Free Software Foundation, either version 3 of the License, or
6#   (at your option) any later version.
7
8#   This program is distributed in the hope that it will be useful,
9#   but WITHOUT ANY WARRANTY; without even the implied warranty of
10#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11#   GNU General Public License for more details.
12
13#   You should have received a copy of the GNU General Public License
14#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16import os
17import shutil
18import imp
19import sys
20
21""" Module never used
22#Check if config.py exists. Get 'fife_path' from config
23try:
24        import config
25        sys.path.append(config.fife_path)
26except:
27        pass
28
29try:
30        from fife import fife
31        print "Using the FIFE python module found here: ", \
32                os.path.dirname(fife.__file__)
33except ImportError:
34        print "====================================================================== \n\
35FIFE was not found in path. \n\
36Try installing FIFE or creating config.py in the PARPG root directory, \n\
37with a variable pointing to the 'python' subdirectory \n\
38fife_path='<path_to_your_FIFE>' \n\
39Example: fife_path='../fife/engine/python/' \n\
40======================================================================"
41"""
42
43from parpg.settings import Settings
44from parpg.application import PARPGApplication
45
46from parpg.common import utils
47
48# add paths to the swig extensions
49utils.addPaths ('../../engine/swigwrappers/python', '../../engine/extensions')
50utils.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
58def 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
65def 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
73def main():
74    """Application code starts from here"""
75    app = PARPGApplication(settings)
76    app.run()
77
78if __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()
Note: See TracBrowser for help on using the repository browser.