Changeset 228

Show
Ignore:
Timestamp:
12/25/06 19:26:16 (5 years ago)
Author:
mg
Message:

Remember video settings in the config file too.

Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/NEWS.txt

    r224 r228  
    1 December 25, 2006: 
     1December 25, 2006: The Christmas release. 
    22 
    33  - Keyboard controls can now be customized. 
     4  - Keyboard controls and video mode options are stored in a config file. 
     5  - Added the -w command line option, in case you desire to override the config 
     6    file. 
    47 
    58February 20, 2006: Released version 0.9.2 (also known as the "a month of 
  • trunk/src/pyspacewar/main.py

    r227 r228  
    2626    ui.load_settings() 
    2727    parser = optparse.OptionParser() 
    28     parser.add_option('-f', '--fullscreen', default=False, 
     28    parser.add_option('-f', '--fullscreen', default=None, 
    2929                      help='start in full-screen mode', 
    3030                      action='store_true', dest='fullscreen') 
     31    parser.add_option('-w', '--windowed', 
     32                      help='start in windowed mode', 
     33                      action='store_false', dest='fullscreen') 
    3134    parser.add_option('-d', '--debug', default=False, 
    3235                      help='show debug timings', 
     
    3841                      action='store', dest='mode') 
    3942    opts, args = parser.parse_args() 
    40     ui.fullscreen = opts.fullscreen 
    41     ui.show_debug_info = opts.debug 
     43    if opts.fullscreen is not None: 
     44        ui.fullscreen = opts.fullscreen 
     45    if opts.debug is not None: 
     46        ui.show_debug_info = opts.debug 
    4247    if opts.mode: 
    4348        try: 
  • trunk/src/pyspacewar/ui.py

    r227 r228  
    17571757        config = self.get_config_parser() 
    17581758        config.read([filename]) 
     1759        self.fullscreen = config.getboolean('video', 'fullscreen') 
     1760        mode = config.get('video', 'mode') 
     1761        try: 
     1762            w, h = mode.split('x') 
     1763            self.fullscreen_mode = int(w), int(h) 
     1764        except ValueError: 
     1765            self.fullscreen_mode = None 
     1766        self.show_missile_trails = config.getboolean('video', 
     1767                                                     'show_missile_trails') 
    17591768        for action in self.controls: 
    17601769            key = config.get('controls', action) 
     
    17751784        """Create a ConfigParser initialized with current settings.""" 
    17761785        config = ConfigParser.RawConfigParser() 
     1786        config.add_section('video') 
     1787        config.set('video', 'fullscreen', str(self.fullscreen)) 
     1788        if self.fullscreen_mode: 
     1789            config.set('video', 'mode', '%dx%d' % self.fullscreen_mode) 
     1790        else: 
     1791            config.set('video', 'mode', '') 
     1792        config.set('video', 'show_missile_trails', 
     1793                   str(self.show_missile_trails)) 
    17771794        config.add_section('controls') 
    17781795        for action, key in self.controls.items():