Changeset 790


Ignore:
Timestamp:
03/07/11 05:14:00 (8 years ago)
Author:
aspidites
Message:

Patch by Aspidites:

  • removed files related to windows packaging
  • simplified settings module API:

+ paths argument no longer exists. There is now exactly

3 arguments: system_path, user_path, and prefix, which

will eventually be explained in documentation

+ user config file is now properly created, leaving the

system config file untouched

+ by default, the new suffix is '.cfg'.
+ sections and options are now properties instead of callables

  • updated menus.py to cope with these minor changes
  • updated setup scripts (both) with missing path information

+ only thing remaining for the windows installer is to test on

on a windows machine (as opposed to wine), and to get
prerequisites installed correctly (fife installer giving trouble)

Location:
branches/active/character_customization
Files:
6 deleted
6 edited
1 moved

Legend:

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

    r774 r790  
    131131            # F7 saves a screenshot to fife/clients/parpg/screenshots 
    132132             
    133             screenshot_file = "screenshots/screen-%s.png" % \ 
    134                     (datetime.now().strftime('%Y-%m-%d-%H-%M-%S')) 
     133            screenshotdir = model.settings.parpg.ScreenshotsDirectory 
     134            screenshot_file = os.path.join(screenshotdir,  
     135                                           'screen-{0}.png'.format( 
     136                                           datetime.now().strftime( 
     137                                           '%Y-%m-%d-%H-%M-%S'))) 
    135138            print "PARPG: Saved:", screenshot_file 
    136139            self.engine.getRenderBackend().captureScreen(screenshot_file) 
  • branches/active/character_customization/game/parpg/gui/menus.py

    r768 r790  
    139139        self.settings.fife.FullScreen = fullscreen 
    140140        self.settings.fife.PlaySounds = sound 
    141         self.settings.write(self.settings.paths[-1]) 
     141        self.settings.write() 
    142142        
    143143        self.restart_dialog.show() 
  • branches/active/character_customization/game/parpg/settings.py

    r772 r790  
    8888 
    8989        return return_value 
    90         """ 
    91         try: 
    92             return dict((key, value[1:-1]) for (key, value) in  
    93                         object.__getattribute__(self, option) if 
    94                         value.startswith("\"") and value.endswith("\"")) 
    95         except TypeError: 
    96             return object.__getattribute__(self, option) 
    97         """ 
    98         #return object.__getattribute__(self, option) 
    99  
     90 
     91    @property 
    10092    def options(self): 
    10193        """ Returns a dictionary of existing options """ 
     
    111103        and the options defined within those sections. 
    112104    """ 
    113     def __init__(self, **kwargs): 
     105    def __init__(self, system_path, user_path=None, suffix='.cfg'): 
    114106        """ initializes a new settings object. 
    115107 
     
    133125        """ 
    134126 
     127        self.suffix = suffix 
    135128        self.settings_file = '' 
    136         self.paths = kwargs.get('paths', None) 
    137         self.filename = kwargs.get('filename', 'settings.ini') 
    138  
    139         if self.paths is not None: 
    140             self.read(self.paths) 
    141         else: 
    142             self.paths = '.' 
     129 
     130        if user_path is None: 
     131            user_path = system_path 
     132 
     133        self.filenames = {'system': os.path.join(system_path,  
     134                                                 'system{0}'.format(self.suffix)), 
     135                          'user': os.path.join(user_path, 
     136                                               'user{0}'.format(self.suffix))} 
     137 
     138        self.read() 
    143139 
    144140    def __getattr__(self, name): 
     
    159155        return getattr(self, name) 
    160156 
    161     def read(self, paths=None, filename=None): 
     157    def read(self, filenames=None): 
    162158        """ Reads a settings file and populates the settings object  
    163159            with its sections and options. Calling this method without 
     
    168164            @type path: string 
    169165        """ 
    170         if filename is not None: 
    171             self.filename = filename 
    172  
    173         if paths is None: 
    174             paths = self.paths 
    175  
    176         if hasattr(paths, 'split'): 
    177             self.paths = [paths] 
    178         else: 
    179             self.paths = paths 
    180  
    181         for path in self.paths: 
    182             location = os.path.join(path, self.filename) 
     166         
     167        if filenames is None: 
     168            filenames = [self.filenames['system'], self.filenames['user']] 
     169 
     170        for filename in filenames: 
    183171            section = None 
    184172            try: 
    185                 self.settings_file = open(location, 'r').readlines() 
     173                self.settings_file = open(filename, 'r').readlines() 
    186174            except IOError: 
    187175                pass 
     
    198186                    setattr(getattr(self, section), option, value) 
    199187 
    200     def write(self, path=None, filename=None): 
     188    def write(self, filename=None): 
    201189        """ Writes a settings file based on the settings object's  
    202190            sections and options 
     
    207195            @type path: string 
    208196        """ 
    209         if path is None: 
    210             path = self.paths[-1] 
    211  
    212197        if filename is None: 
    213             filename = self.filename 
    214  
    215         for section in self.sections(): 
     198            filename = self.filenames['user'] 
     199 
     200        for section in self.sections: 
    216201            if '[{0}]\n'.format(section) not in self.settings_file: 
    217202                self.settings_file.append('\n[{0}]\n'.format(section)) 
    218                 for option, value in getattr(self, section).options().iteritems(): 
     203                for option, value in getattr(self, section).options.iteritems(): 
    219204                    template = '{0} = {1}\n'.format(option, value) 
    220205                    self.settings_file.append(template) 
     
    224209 
    225210                for option, value in getattr(self,  
    226                                              section).options().iteritems(): 
     211                                             section).options.iteritems(): 
    227212                    if hasattr(value, 'sort'): 
    228213                        value = '[{0}]'.format(', '.join(value)) 
     
    242227                        self.settings_file.insert(start_of_section, template) 
    243228 
    244         location = os.path.join(path, filename) 
    245         with open(location, 'w') as out_stream: 
     229        with open(filename, 'w') as out_stream: 
    246230            for line in self.settings_file: 
    247231                out_stream.write(line) 
    248232 
     233    @property 
    249234    def sections(self): 
    250235        """ Returns a list of existing sections""" 
    251236        sections = self.__dict__.keys() 
    252237        sections.pop(sections.index('settings_file')) 
    253         sections.pop(sections.index('paths')) 
    254         sections.pop(sections.index('filename')) 
     238        sections.pop(sections.index('filenames')) 
     239        sections.pop(sections.index('suffix')) 
    255240         
    256241        return sections 
  • branches/active/character_customization/game/run.py

    r788 r790  
    3333 
    3434# initialize settings 
    35 settings = Settings(paths=args.filenames) 
     35settings = Settings('.') 
    3636 
    3737levels = {'debug': logging.DEBUG, 
  • branches/active/character_customization/game/system.cfg

    r789 r790  
    4040CursorLeft = gui/cursors/cursor_left.png 
    4141DialoguesDirectory = dialogue 
     42ScreenshotsDirectory = screenshots 
    4243QuestsDirectory = quests 
    4344PCSpeed = 3 
  • branches/active/character_customization/setup.nsi

    r789 r790  
    55!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" 
    66!define PRODUCT_UNINST_ROOT_KEY "HKLM" 
     7 
    78!define PARPG_DIR "game" 
     9!define MODINSTDIR "$PROGRAMFILES\..\python27\Lib\site-packages" 
    810 
    911# MUI 1.67 compatible ------ 
     
    5557  SetOverwrite try 
    5658   
    57   #Get all the core PARPG files 
    58   FILE /r "${PARPG_DIR}\*.ttf" 
    59   FILE /r "${PARPG_DIR}\*.yaml" 
    60   FILE /r "${PARPG_DIR}\settings.ini"  
    61   FILE /r "${PARPG_DIR}\*.png" 
    62   FILE /r "${PARPG_DIR}\*.ico" 
    63   FILE /r "${PARPG_DIR}\*.ogg" 
    64   FILE /r "${PARPG_DIR}\*.license" 
    65    
     59  # get all the core PARPG files 
     60  FILE /r "${PARPG_DIR}\fonts"  
     61  FILE /r "${PARPG_DIR}\gui"  
     62  FILE /r "${PARPG_DIR}\maps"  
     63  FILE /r "${PARPG_DIR}\music"  
     64  FILE /r "${PARPG_DIR}\objects"  
     65  FILE /r "${PARPG_DIR}\quests"  
     66  FILE /r "${PARPG_DIR}\character_scripts" 
     67 
     68  FILE "${PARPG_DIR}\settings.ini" 
    6669  FILE "${PARPG_DIR}\README" 
    67   FILE "${PARPG_DIR}\log_parpg.bat" 
     70  FILE "${PARPG_DIR}\run.py" 
    6871 
    6972  RENAME "README" "README.txt" 
    70    
    71   CreateDirectory "$INSTDIR\saves"   
    72    
     73  RENAME "run.py" "parpg.pyw" 
     74 
     75  CreateDirectory "$INSTDIR\saves" 
     76  CreateDirectory "$INSTDIR\screenshots" 
     77 
     78  # get the python modules 
     79  setOutPath "${MODINSTDIR}" 
     80 
     81  FILE /r "${PARPG_DIR}\parpg" 
     82 
    7383  SetAutoClose true 
    7484SectionEnd 
     
    8898  CreateShortCut "$SMPROGRAMS\PARPG\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url" 
    8999  CreateShortCut "$SMPROGRAMS\PARPG\Uninstall.lnk" "$INSTDIR\uninstall.exe" 
    90   SetOutPath "$INSTDIR\game" #this makes the following shortcut run in the installed directory 
    91   CreateShortCut "$SMPROGRAMS\PARPG\PARPG.lnk" "$INSTDIR\run.py" 
     100  SetOutPath "$INSTDIR" #this makes the following shortcut run in the installed directory 
     101  CreateShortCut "$SMPROGRAMS\PARPG\PARPG.lnk" "$INSTDIR\parpg.pyw" 
    92102SectionEnd 
    93103 
     
    116126  SetShellVarContext all 
    117127   
    118   #Remove all the code 
     128  # remove data files 
    119129  RMDir /r "$INSTDIR\dialogue" 
    120   RMDir /r "$INSTDIR\editor" 
    121130  RMDir /r "$INSTDIR\fonts" 
    122131  RMDir /r "$INSTDIR\gui" 
    123132  RMDir /r "$INSTDIR\lib" 
    124   RMDir /r "$INSTDIR\local_loaders" 
    125133  RMDir /r "$INSTDIR\maps" 
    126134  RMDir /r "$INSTDIR\music" 
    127135  RMDir /r "$INSTDIR\objects" 
    128136  RMDir /r "$INSTDIR\quests" 
     137  RMDir /r "$INSTDIR\character_scripts" 
    129138  RMDir "$INSTDIR\saves" #Test if the directory will get deleted when it contains files. The expected behaviour is that it will not. 
    130   RMDir /r "$INSTDIR\tests" 
    131   RMDir /r "$INSTDIR\utilities" 
    132    
    133   Delete "$INSTDIR\dialogue_schema.yaml" 
    134   Delete "$INSTDIR\PARPG" 
    135   Delete "$INSTDIR\run.py" 
    136   Delete "$INSTDIR\run_tests.py" 
     139   
     140  Delete "$INSTDIR\parpg.pyw" 
    137141  Delete "$INSTDIR\README.txt" 
    138   Delete "$INSTDIR\log_parpg.bat" 
    139142  Delete "$INSTDIR\*.log" 
    140143  Delete "$INSTDIR\${PRODUCT_NAME}.url" 
    141144  Delete "$INSTDIR\uninstall.exe" 
    142   RMDir "$INSTDIR\game" 
    143   RMDir /r "$INSTDIR\tools" 
    144145   
    145146  RMDir "$INSTDIR" 
    146147 
    147   #Remove shortcuts 
     148  # Remove scripts 
     149  RMDir /r "${MODINSTDIR}\parpg" 
     150 
     151  # Remove shortcuts 
    148152  RMDir /r "$SMPROGRAMS\PARPG" 
    149153  
    150   #Remove Registry keys 
     154  # Remove Registry keys 
    151155  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" 
    152156  SetAutoClose true 
     
    185189 
    186190  DetailPrint "Deleting FIFE installer" 
    187   Delete $TEMP\fifesetup.exe 
     191  Delete $TEMP\fifesetup.exe  
    188192SectionEnd 
    189193 
  • branches/active/character_customization/setup.py

    r789 r790  
    1 #TODO: Look into INSTALL_SCHEMES from distutils.command.install 
    21#!/usr/bin/env python2 
    32""" 
     
    54packages for Linux, Windows, and Mac 
    65""" 
    7 import logging 
    86import platform 
    97import sys 
     
    119 
    1210from distutils.core import setup 
    13 import setup 
    1411 
    1512system = platform.system() 
    16  
    17 logging.basicConfig(filename='log') 
    1813 
    1914def rename_launcher(): 
     
    9287 
    9388    for directory in ['fonts', 'gui', 'maps', 'music', 'objects',  
    94                       'quests', 'saves']: 
     89                      'quests', 'saves', 'character_scripts', 
     90                      'screenshots']: 
    9591        args['data_files'] += files(os.path.join('game', directory), 
    9692                                    os.path.join('share', 'parpg')) 
    9793 
    98     logging.error(str(args['data_files'])) 
    9994    return args 
    10095 
     
    119114else: 
    120115    #TODO: actually support mac 
    121     logging.error('Sorry, {0} is currently not supported'.format(system)) 
    122     print 'Setup failed. Please see log for more details.' 
     116    print('Sorry, {0} is currently not supported.\nAborting...'.format(system)) 
    123117    sys.exit(0) 
    124118 
Note: See TracChangeset for help on using the changeset viewer.