# HG changeset patch # User Simon Cross # Date 1302217026 -7200 # Node ID 8bd442fa89adbc49ef44dc38ccfbea8413742de0 # Parent 0f502ac5b9e02a5a4e3cf3d91836941a319c451a Render dialog on screen instead of printing to console. diff -r 0f502ac5b9e0 -r 8bd442fa89ad skaapsteker/widgets/bubble.py --- a/skaapsteker/widgets/bubble.py Fri Apr 08 00:45:33 2011 +0200 +++ b/skaapsteker/widgets/bubble.py Fri Apr 08 00:57:06 2011 +0200 @@ -1,8 +1,10 @@ """Widget for in-level dialogue / speech bubbles.""" from pygame.locals import (KEYDOWN, K_UP, K_p, K_q, K_x, K_z, K_RETURN) +import pygame from ..engine import OpenDialog, CloseDialog +from .text import Text class DialogueWidget(object): @@ -10,11 +12,28 @@ def __init__(self, npc): self.npc = npc self.dsm = npc.dsm + self._text = None + self._update_text() + + def _update_text(self): + state = self.dsm.get_state() + if state.text: + text = "\n".join([ + state.text, + "", + "Press RETURN to continue." + ]) + pos = pygame.Rect((0, 0), (300, 1)) + self._text = Text(text, pos, wrap=True) + else: + self._text = None print self.dsm.get_state().text print "Press RETURN to continue.""" def draw(self, level_surface): - pass + if self._text: + self._text.rect.center = level_surface.get_clip().center + self._text.draw(level_surface) def close(self): pass