# HG changeset patch # User Simon Cross # Date 1282943347 -7200 # Node ID fe899fb63866ca61df12616fcecd8b9e1a186c3d # Parent eb3cfcaff469cf2d98b99ae069fc5078042f9c4e Add option for turning off debugging rects while debugging. diff -r eb3cfcaff469 -r fe899fb63866 gamelib/main.py --- a/gamelib/main.py Fri Aug 27 23:01:17 2010 +0200 +++ b/gamelib/main.py Fri Aug 27 23:09:07 2010 +0200 @@ -29,6 +29,8 @@ if DEBUG: parser.add_option("--scene", type="str", default=None, dest="scene", help="initial scene") + parser.add_option("--no-rects", action="store_false", default=True, + dest="rects", help="disable debugging rects") opts, _ = parser.parse_args(args or []) return opts @@ -53,9 +55,11 @@ else: # Ensure get_sound returns nothing, so everything else just works disable_sound() - if DEBUG and opts.scene is not None: - # debug the specified scene - state.DEBUG_SCENE = opts.scene + if DEBUG: + if opts.scene is not None: + # debug the specified scene + state.DEBUG_SCENE = opts.scene + state.DEBUG_RECTS = opts.rects display = pygame.display.set_mode(SCREEN, SWSURFACE) shell = MainShell(display) try: diff -r eb3cfcaff469 -r fe899fb63866 gamelib/state.py --- a/gamelib/state.py Fri Aug 27 23:01:17 2010 +0200 +++ b/gamelib/state.py Fri Aug 27 23:09:07 2010 +0200 @@ -12,6 +12,9 @@ # override the initial scene to for debugging DEBUG_SCENE = None +# whether to show debugging rects +DEBUG_RECTS = False + class Result(object): """Result of interacting with a thing""" @@ -362,10 +365,7 @@ # Interact rectangle hi-light color (for debugging) # (set to None to turn off) - if constants.DEBUG: - _interact_hilight_color = Color('red') - else: - _interact_hilight_color = None + _interact_hilight_color = Color('red') def __init__(self): StatefulGizmo.__init__(self) @@ -461,7 +461,7 @@ self.current_interact.rect = old_rect.move(self.scene.OFFSET) self.current_interact.draw(surface) self.current_interact.rect = old_rect - if self._interact_hilight_color is not None: + if DEBUG_RECTS: if hasattr(self.rect, 'collidepoint'): frame_rect(surface, self._interact_hilight_color, self.rect.inflate(1, 1), 1)