Mercurial > touhou
changeset 322:4e8192aadcaa
Give a better interface for text handling.
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Thu, 24 May 2012 20:23:57 +0200 |
parents | 61adb5453e46 |
children | 2fcdb8966957 |
files | pytouhou/game/text.py pytouhou/games/eosd.py |
diffstat | 2 files changed, 16 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/pytouhou/game/text.py +++ b/pytouhou/game/text.py @@ -27,10 +27,8 @@ class Glyph(object): class Text(object): - def __init__(self, pos, text, front_wrapper, ascii_wrapper): + def __init__(self, pos, ascii_wrapper=None, front_wrapper=None, text=''): self.sprite = Sprite() - self.anmrunner = ANMRunner(front_wrapper, 22, self.sprite) - self.anmrunner.run_frame() self.removed = False self.changed = True @@ -40,12 +38,16 @@ class Text(object): self.front_wrapper = front_wrapper self.ascii_wrapper = ascii_wrapper + if front_wrapper: + self.anmrunner = ANMRunner(front_wrapper, 22, self.sprite) + self.anmrunner.run_frame() + self.x, self.y = pos self.set_text(text) def objects(self): - return self.glyphes + [self] + return self.glyphes + ([self] if self.front_wrapper else []) def set_text(self, text):
--- a/pytouhou/games/eosd.py +++ b/pytouhou/games/eosd.py @@ -116,7 +116,7 @@ class EoSDGame(Game): -class EoSDInterface(Game): +class EoSDInterface(object): def __init__(self, states, resource_loader): self.states = states front = resource_loader.get_anm_wrapper(('front.anm',)) @@ -137,15 +137,15 @@ class EoSDInterface(Game): item.sprite.allow_dest_offset = True #XXX self.labels = { - 'highscore': Text((500, 58), '0', front, ascii_wrapper), - 'score': Text((500, 82), '0', front, ascii_wrapper), - 'player': Text((500, 122), 'star star', front, ascii_wrapper), - 'bombs': Text((500, 146), 'star star', front, ascii_wrapper), - 'power': Text((500, 186), '0', front, ascii_wrapper), - 'graze': Text((500, 206), '0', front, ascii_wrapper), - 'points': Text((500, 226), '0', front, ascii_wrapper), - 'framerate': Text((512, 464), '', front, ascii_wrapper), - 'debug?': Text((0, 464), '', front, ascii_wrapper), + 'highscore': Text((500, 58), ascii_wrapper, front, text='0'), + 'score': Text((500, 82), ascii_wrapper, front, text='0'), + 'player': Text((500, 122), ascii_wrapper, front, text='TODO'), + 'bombs': Text((500, 146), ascii_wrapper, front, text='TODO'), + 'power': Text((500, 186), ascii_wrapper, front, text='0'), + 'graze': Text((500, 206), ascii_wrapper, front, text='0'), + 'points': Text((500, 226), ascii_wrapper, front, text='0'), + 'framerate': Text((512, 464), ascii_wrapper, front), + 'debug?': Text((0, 464), ascii_wrapper, front), }