2 Widget for the game board information area.
6 from naja.constants import INFO_SIZE, EIGHT_BIT_SCALE
7 from naja.resources import resources
8 from naja.resources.mutators import EIGHT_BIT
10 from naja.widgets.base import Widget
11 from naja.widgets.tile import BIT_MAP
12 from naja.widgets.text import TextBoxWidget
15 class InfoAreaWidget(Widget):
17 Widget for the game board information area.
19 def __init__(self, pos, state):
20 super(InfoAreaWidget, self).__init__(pos, INFO_SIZE)
25 self.surface = pygame.surface.Surface(INFO_SIZE)
26 self.surface.fill((0, 0, 0))
27 # Quick hack for testing
28 self.card = self.state.board_locations[self.state.player.position]
29 # Extract actions and such from the card
31 for action in self.card.actions:
32 if action.required_bits:
33 img_name = BIT_MAP[action.required_bits].replace('.png', '_small.png')
34 img = resources.get_image(img_name,
35 transforms=(EIGHT_BIT,))
36 self.surface.blit(img, (0, y_offset))
38 text = TextBoxWidget((12, y_offset), action.TEXT,
39 box_width= (INFO_SIZE[0] - 12) // EIGHT_BIT_SCALE,
40 fontsize = 28, padding = 4)
41 text.render(self.surface)
42 y_offset += text.surface.get_rect().height + 16
45 def set_card(self, card):
48 def draw(self, surface):
49 surface.blit(self.surface, self.pos)