# HG changeset patch # User Stefano Rivera # Date 1359197781 -7200 # Node ID f4853f817a7a3d2958e37d569b4b19295d59cd89 # Parent 8ac05c038e7312da9051a461016915040863bd73 Refactor scene listing, to avoid having to create a window diff -r 8ac05c038e73 -r f4853f817a7a pyntnclick/main.py --- a/pyntnclick/main.py Sat Jan 26 12:30:17 2013 +0200 +++ b/pyntnclick/main.py Sat Jan 26 12:56:21 2013 +0200 @@ -130,11 +130,7 @@ self._initial_scene = opts.scene self._debug_rects = opts.rects if self.constants.debug and opts.list_scenes: - # FIXME: Horrible hack to avoid image loading issues for - # now - pygame.display.set_mode(self.constants.screen, - SWSURFACE) - list_scenes(self.initial_state) + list_scenes(self.SCENE_MODULE, self._scene_list) sys.exit(0) if self.constants.debug and opts.rect_drawer: if opts.scene is None: diff -r 8ac05c038e73 -r f4853f817a7a pyntnclick/tools/utils.py --- a/pyntnclick/tools/utils.py Sat Jan 26 12:30:17 2013 +0200 +++ b/pyntnclick/tools/utils.py Sat Jan 26 12:56:21 2013 +0200 @@ -1,15 +1,18 @@ # Misc utils I don't know where else to put -def list_scenes(get_initial_state): +def list_scenes(scene_module, scene_list): """List the scenes in the state""" - state = get_initial_state() - print 'Available scenes are : ' - for scene in state.scenes: - print ' ', scene - print 'Available details are : ' - for detail in state.detail_views: - print ' ', detail + print "Available scenes and details:" + for scene in scene_list: + scenemod = __import__('%s.%s' % (scene_module, scene), + fromlist=[scene]) + if scenemod.SCENES: + print " * %s" % scene + else: + print " * %s (details only)" % scene + for detailcls in getattr(scenemod, 'DETAIL_VIEWS', []): + print " - %s" % detailcls.NAME def draw_rect_image(surface, color, rect, thickness):