# HG changeset patch # User Neil Muller # Date 1329042507 -7200 # Node ID b2c2b6f562916f8270af4ff53c752b2fde3eadc1 # Parent 96daa4119745569be284787a7ac414bcca53842f baby steps to fixing rect_drawer - it has now progressed to being completely useless diff -r 96daa4119745 -r b2c2b6f56291 pyntnclick/main.py --- a/pyntnclick/main.py Sun Feb 12 12:13:08 2012 +0200 +++ b/pyntnclick/main.py Sun Feb 12 12:28:27 2012 +0200 @@ -22,7 +22,7 @@ from pyntnclick.sound import Sound from pyntnclick import state -from pyntnclick.tools.rect_drawer import RectApp, make_rect_display +from pyntnclick.tools.rect_drawer import RectEngine, make_rect_display from pyntnclick.tools.utils import list_scenes @@ -144,7 +144,7 @@ display = make_rect_display() # FIXME: Remove Albow from here try: - self.engine = RectApp(display, self.initial_state, opts.scene, + self.engine = RectEngine(self, self.initial_state, opts.scene, opts.detail) except KeyError: print 'Invalid scene: %s' % opts.scene diff -r 96daa4119745 -r b2c2b6f56291 pyntnclick/tools/rect_drawer.py --- a/pyntnclick/tools/rect_drawer.py Sun Feb 12 12:13:08 2012 +0200 +++ b/pyntnclick/tools/rect_drawer.py Sun Feb 12 12:28:27 2012 +0200 @@ -23,13 +23,14 @@ from pygame.locals import (K_LEFT, K_RIGHT, K_UP, K_DOWN, K_a, K_t, K_d, K_i, K_r, K_o, K_b, K_z, - BLEND_RGBA_MIN, SRCALPHA) + BLEND_RGBA_MIN, SRCALPHA, QUIT) import pygame import pyntnclick.constants from pyntnclick import state state.DEBUG_RECTS = True from pyntnclick.widgets import BoomLabel +from pyntnclick.widgets.base import Container class RectDrawerConstants(pyntnclick.constants.GameConstants): @@ -554,7 +555,38 @@ return button -class RectApp(RootWidget): +class RectApp(Container): + """The actual rect drawer main app""" + def __init__(self, rect, gd): + super(RectApp, self).__init__(rect, gd) + + +class RectEngine(object): + """Engine for the rect drawer.""" + + def __init__(self, gd, get_initial_state, scene, detail): + self.state = None + self._gd = gd + rect = pygame.display.get_surface().get_rect() + self.app = RectApp(rect, self._gd) + + def run(self): + """App loop""" + clock = pygame.time.Clock() + while True: + events = pygame.event.get() + for ev in events: + if ev.type == QUIT: + return + else: + self.app.event(ev) + surface = pygame.display.get_surface() + self.app.draw(surface) + pygame.display.flip() + clock.tick(self._gd.constants.frame_rate) + + +class RectAppOld(RootWidget): """Handle the app stuff for the rect drawer""" def __init__(self, display, get_initial_state, scene, detail):