diff options
author | Mateu Batle <mateu.batle@collabora.co.uk> | 2010-11-11 04:19:54 (GMT) |
---|---|---|
committer | Mateu Batle <mateu.batle@collabora.co.uk> | 2010-11-11 04:19:54 (GMT) |
commit | d17da13429bfdb286797f0e30a7a555f7af81f19 (patch) | |
tree | 5397143b9390744ae5c526b11d94981add15dfe6 /usmpgames | |
parent | 6ad42708ff8600899602cd52ea2c342e5dafb721 (diff) |
Added implementation of add_text with ktextsurfacewriter
Diffstat (limited to 'usmpgames')
-rwxr-xr-x | usmpgames/infostate.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/usmpgames/infostate.py b/usmpgames/infostate.py index 3edfc66..b0ccbdd 100755 --- a/usmpgames/infostate.py +++ b/usmpgames/infostate.py @@ -1,5 +1,5 @@ #!/usr/bin/python -# -*- coding: iso-8859-15 -*- +# -*- coding: utf-8 -*- import pygame import jmenu @@ -7,15 +7,20 @@ import sys import txtlib from applicationstate import * from application import * +from ktextsurfacewriter import KTextSurfaceWriter +from pygame.locals import * +import pygame.font class InfoState(ApplicationState): def __init__(self, next_state, background = None): ApplicationState.__init__(self, next_state, background) self._images = [] + self._ktexts = [] def clear_all(self): self._images = [] + self._ktexts = [] def add_text(self, text, color, pos, rectsize, fontsize, font = None): textobj = txtlib.Text(rectsize, font, fontsize, text) @@ -30,6 +35,15 @@ class InfoState(ApplicationState): textobj.update() self.add_image( textobj.area, pos ) + def add_text2(self, text, color, pos, rectsize): + text_rect = pygame.Rect( pos, rectsize ) + textobj = KTextSurfaceWriter(text_rect) + textobj.text = (text) + textobj.color = color + textobj.fillcolor = (231,178,66,0) + textobj.invalidate() + self._ktexts.append(textobj) + def add_image(self, surface, pos): info = {} info["surface"] = surface @@ -51,6 +65,8 @@ class InfoState(ApplicationState): def render(self, ms): for info in self._images: self.screen().blit(info["surface"], info["pos"]) + for info in self._ktexts: + info.draw(self.screen()) def entering_state(self, fromStack): ApplicationState.entering_state(self, fromStack) |