Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/usmpgames/infostate.py
blob: 3edfc66576b98896f9d044c841427000510a345c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/python
# -*- coding: iso-8859-15 -*-

import pygame
import jmenu
import sys
import txtlib
from applicationstate import *
from application import *

class InfoState(ApplicationState):
    
    def __init__(self, next_state,  background = None):
        ApplicationState.__init__(self,  next_state,  background)
        self._images = []
        
    def clear_all(self):
        self._images = []
 
    def add_text(self,  text,  color,  pos,  rectsize,  fontsize,  font = None):
        textobj = txtlib.Text(rectsize, font,  fontsize,  text)
        textobj.background_color = (255, 255,  255,  0)
        textobj.update()
        self.add_image( textobj.area,  pos )
 
    def add_htmltext(self,  html_text,  color,  pos,  rectsize,  fontsize,  font = None):
        textobj = txtlib.Text(rectsize, font,  fontsize)
        textobj.background_color = (255, 255,  255,  0)
        textobj.html(html_text)
        textobj.update()
        self.add_image( textobj.area,  pos )

    def add_image(self,  surface,  pos):
        info = {}
        info["surface"] = surface
        info["pos"] = pos
        self._images.append(info)

    def input(self,  ms):
        events = pygame.event.get()
        if events:
            for event in events:
                if event.type == pygame.QUIT:
                    self.set_running( False )
                elif event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_ESCAPE:
                        self.set_running( False )
                    else:
                        self.go_to_next_state()

    def render(self,  ms):
        for info in self._images:
            self.screen().blit(info["surface"],  info["pos"])

    def entering_state(self, fromStack):
        ApplicationState.entering_state(self, fromStack)	
	pygame.time.wait(500)
	pygame.event.clear()