source: trunk/game/run.py @ 627

Revision 627, 2.2 KB checked in by beliar, 9 years ago (diff)

Patch by Beliar.

  • Added SettingsVersion? to settings. This contains the version (currently a date of the last change) of the settings. The version will be checked with the version in settings-dist.xml and if the versions don't match the settings.xml file will be renamed to settings-old.xml. The version string has to be set manually when editing settings-dist.xml.
  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
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
18
19from fife import fife
20print "Using the FIFE python module found here: ", \
21    os.path.dirname(fife.__file__)
22
23from scripts.parpg import PARPGApplication
24from scripts.common.utils import loadSettings
25
26from scripts.common import utils
27
28# add paths to the swig extensions
29utils.addPaths ('../../engine/swigwrappers/python', '../../engine/extensions')
30utils.addPaths ('./lib', './lib/extensions')
31
32
33"""This folder holds the main meta-data for PARPG. This file should be
34   minimal, since folding code into the controller with MVC is usually bad
35   All game and logic and data is held held and referenced in
36   /scripts/engine.py. All fife stuff goes in /scripts/world.py"""
37
38def main():
39    """Application code starts from here"""
40    dist_version = loadSettings("./settings-dist.xml").get("PARPG", "SettingsVersion")
41    version = loadSettings().get("PARPG", "SettingsVersion")
42    if (version != dist_version):
43        print "Newer settings-dist.xml found, renaming settings.xml to settings-old-xml"
44        shutil.copyfile('./settings.xml', './settings-old.xml')
45        shutil.copyfile('./settings-dist.xml', './settings.xml')
46    app = PARPGApplication(loadSettings())
47    app.run()
48
49if __name__ == '__main__':
50    if loadSettings().get("FIFE", "UsePsyco"):
51        # Import Psyco if available
52        try:
53            import psyco
54            psyco.full()
55            print "Psyco acceleration in use"
56        except ImportError:
57            print "Psyco acceleration not used"
58    else:
59        print "Psyco acceleration not used"
60    main()
61
Note: See TracBrowser for help on using the repository browser.