Changeset 795


Ignore:
Timestamp:
03/07/11 09:58:26 (8 years ago)
Author:
aspidites
Message:

Patch by Aspidites:

-slight rearranging of some method calls in application.py

  • removed system.cfg

+ a platform-specifc system config file can be generated

by issuing:

python settings.py

+ if you would like to write a settings file for another

system, you may do so as follows:

python settigns.py [local|windows|linux] [data_directory]

+ the local option is ideal for people who simply want to run

parpg in place

+ eventually, a proper command line parser willl be implemented for

flexibility's sake

Location:
branches/active/character_customization/game
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • branches/active/character_customization/game/parpg/application.py

    r794 r795  
    113113        self._setting = setting  
    114114        self.engine = fife.Engine() 
     115        fonts_dir = os.path.join(self._setting.fife.DataDirectory, 
     116                                 self._setting.fife.FontsDirectory) 
     117        self.fonts_directory = fonts_dir 
    115118        self.loadSettings() 
    116119        self.engine.init() 
     
    133136        self.model.getDialogues() 
    134137        self.view = MainMenuView(self.engine, self.model) 
    135         fonts_dir = os.path.join(self._setting.fife.DataDirectory, 
    136                                  self._setting.fife.FontsDirectory) 
    137         self.fonts_directory = fotns_dir 
    138138        self.loadFonts(self.fonts_directory) 
    139139        self.event_listener = EventListener(self.engine) 
     
    169169        engineSetting = self.engine.getSettings() 
    170170        engineSetting.setDefaultFontGlyphs(self._setting.fife.FontGlyphs) 
    171         engineSettings.setDefaultFontPath(os.path.join(self.fonts_directory, 
     171        engineSetting.setDefaultFontPath(os.path.join(self.fonts_directory, 
    172172                                                       fife_options.Font)) 
    173173        engineSetting.setDefaultFontSize(self._setting.fife.DefaultFontSize) 
  • branches/active/character_customization/game/parpg/settings.py

    r790 r795  
    2626 
    2727import os 
     28import sys 
     29import platform 
    2830 
    2931#TODO: prevent new sections from being created if an option hasn't been defined 
     
    240242         
    241243        return sections 
     244 
     245#TODO: organize and comment the default settings 
     246DEFAULT_SETTINGS = """\ 
     247[fife] 
     248VideoDriver = 
     249FullScreen = False 
     250PlaySounds = False 
     251RenderBackend = OpenGL 
     252ColorKey = [250, 0, 250] 
     253ColorKeyEnabled = False 
     254ScreenWidth = 1024 
     255ScreenHeight = 768 
     256BitsPerPixel = 0 
     257InitialVolume = 5.0 
     258ImageChunkSize = 256 
     259SDLRemoveFakeAlpha = 1 
     260WindowTitle = PARPG Techdemo 2 
     261FontsDirectory = fonts 
     262Font = oldtypewriter.ttf 
     263FontGlyphs = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&`'*#=[]\"" 
     264IconsDirectory = icons 
     265WindowIcon = window_icon.png 
     266DefaultFontSize = 12 
     267LogModules = [controller] 
     268PychanDebug = False 
     269LogToPrompt = 0 
     270LogToFile = 0 
     271UsePsyco = False 
     272ProfilingOn = False 
     273ImageChunkSize = 256 
     274Lighting = 0 
     275 
     276[parpg] 
     277MapsDirectory = maps 
     278ObjectsDirectory = objects 
     279DialoguesDirectory = dialogue 
     280QuestsDirectory = quests 
     281ScreenshotsDirectory = screenshots 
     282GuiDirectory = gui 
     283CursorDirectory = cursors 
     284 
     285MapsFile = maps.yaml 
     286AllAgentsFile = all_agents.yaml 
     287ObjectDatabaseFile = object_database.yaml 
     288 
     289Map = Mall 
     290CursorDefault = cursor_plain.png 
     291CursorUp = cursor_up.png 
     292CursorRight = cursor_right.png 
     293CursorDown = cursor_down.png 
     294CursorLeft = cursor_left.png 
     295PCSpeed = 3\ 
     296""" 
     297 
     298def write_defaults(system=None, data_dir=None): 
     299    #TODO: write defaults for Mac OS X 
     300    if system is None: 
     301        system = platform.system().lower() 
     302 
     303    if data_dir is None: 
     304        if system == 'local': 
     305            data_dir = os.path.join('.') 
     306        elif system == 'linux': 
     307            data_dir = os.path.join(os.environ['XDG_DATA_DIRS'].split(':')[0], 
     308                                    'parpg') 
     309        elif system == 'windows': 
     310            data_dir = os.path.join(os.environ['PROGRAMFILES'], 
     311                                    'PARPG') 
     312 
     313    default_settings = DEFAULT_SETTINGS.split('\n') 
     314    default_settings.insert(1, 'DataDirectory = {0}'.format(data_dir)) 
     315 
     316    with open('system.cfg', 'w') as f: 
     317        for line in default_settings: 
     318            f.write(line + '\n') 
     319 
     320if __name__ == '__main__': 
     321    if len(sys.argv) > 1: 
     322        write_defaults(*sys.argv[1:]) 
     323    else: 
     324        write_defaults() 
Note: See TracChangeset for help on using the changeset viewer.