Changeset 255:8bd442fa89ad


Ignore:
Timestamp:
04/07/11 22:57:06 (12 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
Phase:
public
Message:

Render dialog on screen instead of printing to console.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/widgets/bubble.py

    r252 r255  
    22
    33from pygame.locals import (KEYDOWN, K_UP, K_p, K_q, K_x, K_z, K_RETURN)
     4import pygame
    45
    56from ..engine import OpenDialog, CloseDialog
     7from .text import Text
    68
    79
     
    1113        self.npc = npc
    1214        self.dsm = npc.dsm
     15        self._text = None
     16        self._update_text()
     17
     18    def _update_text(self):
     19        state = self.dsm.get_state()
     20        if state.text:
     21            text = "\n".join([
     22                state.text,
     23                "",
     24                "Press RETURN to continue."
     25                ])
     26            pos = pygame.Rect((0, 0), (300, 1))
     27            self._text = Text(text, pos, wrap=True)
     28        else:
     29            self._text = None
    1330        print self.dsm.get_state().text
    1431        print "Press RETURN to continue."""
    1532
    1633    def draw(self, level_surface):
    17         pass
     34        if self._text:
     35            self._text.rect.center = level_surface.get_clip().center
     36            self._text.draw(level_surface)
    1837
    1938    def close(self):
Note: See TracChangeset for help on using the changeset viewer.