Changeset 627


Ignore:
Timestamp:
08/06/10 08:45:53 (9 years ago)
Author:
beliar
Message:

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.
Location:
trunk/game
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/run.py

    r609 r627  
    1515 
    1616import os 
    17 from scripts.common import utils 
     17import shutil 
    1818 
    1919from fife import fife 
    2020print "Using the FIFE python module found here: ", \ 
    2121    os.path.dirname(fife.__file__) 
    22 from fife.extensions.fife_settings import Setting 
     22 
    2323from scripts.parpg import PARPGApplication 
     24from scripts.common.utils import loadSettings 
     25 
     26from scripts.common import utils 
    2427 
    2528# add paths to the swig extensions 
     
    2730utils.addPaths ('./lib', './lib/extensions') 
    2831 
    29  
    30 TDS = Setting(app_name="PARPG", 
    31               settings_file="./settings.xml",  
    32               settings_gui_xml="") 
    3332 
    3433"""This folder holds the main meta-data for PARPG. This file should be 
     
    3938def main(): 
    4039    """Application code starts from here""" 
    41     app = PARPGApplication(TDS) 
     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()) 
    4247    app.run() 
    4348 
    4449if __name__ == '__main__': 
    45     if TDS.get("FIFE", "UsePsyco"): 
     50    if loadSettings().get("FIFE", "UsePsyco"): 
    4651        # Import Psyco if available 
    4752        try: 
  • trunk/game/scripts/common/utils.py

    r563 r627  
    4141        for filename in fnmatch.filter(files, pattern): 
    4242            yield os.path.join(path, filename) 
     43 
     44def loadSettings(settings_file = "./settings.xml"): 
     45    from fife.extensions.fife_settings import Setting 
     46    return Setting(app_name = "PARPG", 
     47                   settings_file = settings_file,  
     48                   settings_gui_xml = "")   
  • trunk/game/scripts/gamemap.py

    r614 r627  
    1717 
    1818from fife import fife 
     19 
    1920from local_loaders.loaders import loadMapFile 
    20 from fife.extensions.fife_settings import Setting 
     21from scripts.common.utils import loadSettings 
    2122 
    22 TDS = Setting(app_name="PARPG", 
    23               settings_file="./settings.xml",  
    24               settings_gui_xml="") 
     23 
     24Settings = loadSettings() 
    2525 
    2626class GameMap(fife.MapChangeListener): 
     
    117117        text = self.engine.getGuiManager().\ 
    118118                        createFont('fonts/rpgfont.png', 0, \ 
    119                                    TDS.get("FIFE", "FontGlyphs")) 
     119                                   Settings.get("FIFE", "FontGlyphs")) 
    120120        rend.changeDefaultFont(text) 
    121121        rend.activateAllLayers(self.map) 
  • trunk/game/scripts/objects/actors.py

    r623 r627  
    1616#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
    1717 
     18from random import randrange 
     19 
     20 
    1821from fife import fife 
     22 
    1923from base import GameObject, Living, Scriptable, CharStats 
    20 from fife.extensions.fife_settings import Setting 
    2124from composed import CarryableItem 
    2225from scripts.inventory import Inventory 
    23 from random import randrange 
     26from scripts.common.utils import loadSettings 
    2427 
    2528"""All actors go here. Concrete classes only.""" 
     
    2730__all__ = ["PlayerCharacter", "NonPlayerCharacter",] 
    2831 
    29 TDS = Setting(app_name="PARPG", 
    30               settings_file="./settings.xml",  
    31               settings_gui_xml="") 
     32Settings = loadSettings() 
     33 
    3234_AGENT_STATE_NONE, _AGENT_STATE_IDLE, _AGENT_STATE_APPROACH, _AGENT_STATE_RUN, _AGENT_STATE_WANDER, _AGENT_STATE_TALK = xrange(6) 
    3335 
     
    5153        self.state = _AGENT_STATE_NONE 
    5254        # TODO: rework/improve 
    53         self.speed = TDS.get("PARPG", "PCSpeed")-1 
     55        self.speed = Settings.get("PARPG", "PCSpeed")-1 
    5456         
    5557    def getX(self): 
     
    8991        self.idle_counter = 1 
    9092        # TODO: rework/improve 
    91         self.speed = TDS.get("PARPG", "PCSpeed") 
     93        self.speed = Settings.get("PARPG", "PCSpeed") 
    9294        self.nextAction = None 
    9395        self.agent = None 
  • trunk/game/scripts/parpg.py

    r566 r627  
    1717from fife.extensions import pychan 
    1818from fife.extensions.basicapplication import ApplicationBase 
     19 
    1920from scripts import gamemodel 
    20  
    2121from scripts import gamesceneview 
    2222from scripts import console 
  • trunk/game/settings-dist.xml

    r626 r627  
    11<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE Settings PUBLIC "FIFE.SettingsFile" "Settings.dtd"> 
    2 <Settings>"E:/projekte/FIFE/engine/python/fife/extensions/fife_settings.py" 
     2<Settings> 
    33        <Module name="FIFE"> 
    44        <Setting name="FullScreen" type="bool">False</Setting> 
     
    2323   </Module> 
    2424  <Module name="PARPG"> 
     25    <Setting name="SettingsVersion" type="str">2010-08-06</Setting> 
    2526    <Setting name="Map" type="str">Mall</Setting> 
    2627    <Setting name="ObjectDatabaseFile" type="str">objects/object_database.yaml</Setting> 
Note: See TracChangeset for help on using the changeset viewer.