Changeset 646


Ignore:
Timestamp:
08/13/10 09:33:33 (9 years ago)
Author:
beliar
Message:

Patch by Beliar

  • Added a check if the game is running from a binary, which means it doesn't need to look for settings_dist.xml.
  • Added batch files to run the binary from the game folder so its not needed to copy folders to dist.
Location:
trunk/game
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/run.py

    r628 r646  
    1616import os 
    1717import shutil 
     18import imp 
     19import sys 
    1820 
    1921from fife import fife 
     
    3638   /scripts/engine.py. All fife stuff goes in /scripts/world.py""" 
    3739 
     40def main_is_frozen(): 
     41    """returns True when running the exe,  
     42    and False when running from a script. """ 
     43    return (hasattr(sys, "frozen") or # new py2exe 
     44            hasattr(sys, "importers") # old py2exe 
     45            or imp.is_frozen("__main__")) # tools/freeze 
     46 
     47def get_main_dir(): 
     48    """returns the directory name of the script  
     49    or the directory name of the exe""" 
     50    if main_is_frozen(): 
     51        return os.path.dirname(sys.executable) 
     52    return os.path.dirname(sys.argv[0]) 
     53 
     54 
    3855def main(): 
    3956    """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') 
     57    if not main_is_frozen(): 
     58        dist_version = loadSettings("./settings-dist.xml").get("PARPG", "SettingsVersion") 
     59        version = loadSettings().get("PARPG", "SettingsVersion") 
     60        if (version != dist_version): 
     61            print "Newer settings-dist.xml found, renaming settings.xml to settings-old.xml" 
     62            shutil.copyfile('./settings.xml', './settings-old.xml') 
     63            shutil.copyfile('./settings-dist.xml', './settings.xml') 
    4664    app = PARPGApplication(loadSettings()) 
    4765    app.run() 
Note: See TracChangeset for help on using the changeset viewer.