diff pytouhou/vm/msgrunner.py @ 456:cae1ae9de430

Add native text support, MSG instructions 3 and 8, and text at the beginning of a stage.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 16 Jul 2013 21:11:40 +0200
parents 9589a01e6edf
children 2276229282fd
line wrap: on
line diff
--- a/pytouhou/vm/msgrunner.py
+++ b/pytouhou/vm/msgrunner.py
@@ -85,6 +85,7 @@ class MSGRunner(object):
         self._game.msg_runner = None
         self._game.msg_wait = False
         self.ended = True
+        self._game.texts = [None] * 4 + self._game.texts[4:]
 
 
     @instruction(0)
@@ -106,6 +107,15 @@ class MSGRunner(object):
             face.load(index)
 
 
+    @instruction(3)
+    def display_text(self, side, index, text):
+        if index == 0:
+            self._game.texts[0] = None
+            self._game.texts[1] = None
+        self._game.texts[index] = self._game.new_native_text((64, 372 + index * 24), text)
+        self._game.texts[index].set_timeout(-1, effect='fadeout', duration=15)
+
+
     @instruction(4)
     def pause(self, duration):
         if not (self.skipping and self.allow_skip):
@@ -129,6 +139,12 @@ class MSGRunner(object):
         self._game.music.play(track)
 
 
+    @instruction(8)
+    def display_description(self, side, index, text):
+        assert side == 1  # It shouldn’t crash when it’s something else.
+        self._game.texts[2 + index] = self._game.new_native_text((336, 320 + index * 18), text, align='right')
+
+
     @instruction(10)
     def freeze(self):
         self.frozen = True