Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/usmpgames/infostate.py
diff options
context:
space:
mode:
Diffstat (limited to 'usmpgames/infostate.py')
-rwxr-xr-xusmpgames/infostate.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/usmpgames/infostate.py b/usmpgames/infostate.py
new file mode 100755
index 0000000..3edfc66
--- /dev/null
+++ b/usmpgames/infostate.py
@@ -0,0 +1,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()