Mercurial > pyntnclick
diff pyntnclick/main.py @ 589:ebc48b397fd5 pyntnclick
Turn rect_drawer into a command line option
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Sat, 11 Feb 2012 17:07:52 +0200 |
parents | f20d211d2c91 |
children | a77dd4619176 |
line wrap: on
line diff
--- a/pyntnclick/main.py Sat Feb 11 17:04:59 2012 +0200 +++ b/pyntnclick/main.py Sat Feb 11 17:07:52 2012 +0200 @@ -24,6 +24,9 @@ from pyntnclick.sound import Sound from pyntnclick import state +from pyntnclick.tools.rect_drawer import RectApp, make_rect_display +from pyntnclick.tools.utils import list_scenes + class MainShell(Shell): def __init__(self, display, game_description): @@ -86,6 +89,15 @@ dest="scene", help="initial scene") parser.add_option("--no-rects", action="store_false", default=True, dest="rects", help="disable debugging rects") + parser.add_option("--rect-drawer", action="store_true", + default=False, dest="rect_drawer", + help="Launch the rect drawing helper tool. Specify the" + " scene with --scene") + parser.add_option("--list-scenes", action="store_true", + default=False, dest='list_scenes', help="List all scenes" + " that can be used with --scene and exit.") + parser.add_option("--detail", type="str", default=None, + dest="detail", help="Detailed view for rect_drawer") return parser def main(self): @@ -102,12 +114,32 @@ # debug the specified scene self._initial_scene = opts.scene self._debug_rects = opts.rects - display = pygame.display.set_mode(self.constants.screen, - SWSURFACE) - pygame.display.set_icon(self.resource.get_image( - 'suspended_sentence24x24.png', basedir='icons')) - pygame.display.set_caption("Suspended Sentence") - shell = MainShell(display, self) + if opts.list_scenes: + # FIXME: Horrible hack to avoid image loading issues for + # now + display = pygame.display.set_mode(self.constants.screen, + SWSURFACE) + list_scenes(self.initial_state) + sys.exit(0) + if opts.rect_drawer: + if opts.scene is None: + print 'Need to supply a scene to use the rect drawer' + sys.exit(1) + display = make_rect_display() + try: + shell = RectApp(display, self.initial_state, opts.scene, + opts.detail) + except KeyError: + print 'Invalid scene: %s' % opts.scene + sys.exit(1) + else: + display = pygame.display.set_mode(self.constants.screen, + SWSURFACE) + pygame.display.set_icon(self.resource.get_image( + 'suspended_sentence24x24.png', basedir='icons')) + pygame.display.set_caption("Suspended Sentence") + + shell = MainShell(display, self) try: shell.run() except KeyboardInterrupt: