From d17da13429bfdb286797f0e30a7a555f7af81f19 Mon Sep 17 00:00:00 2001 From: Mateu Batle Date: Thu, 11 Nov 2010 04:19:54 +0000 Subject: Added implementation of add_text with ktextsurfacewriter --- (limited to 'usmpgames') 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) -- cgit v0.9.1