# HG changeset patch # User Thibaut Girka # Date 1337883837 -7200 # Node ID 4e8192aadcaa0020a2e2332f34bb139ebafbc5b7 # Parent 61adb5453e46850e71449d4581d95b40eeee3373 Give a better interface for text handling. diff --git a/pytouhou/game/text.py b/pytouhou/game/text.py --- 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): diff --git a/pytouhou/games/eosd.py b/pytouhou/games/eosd.py --- 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), }