From d56932610ab443154ece192dac89b9a16de73eaa Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Sat, 17 May 2014 21:17:25 +0200 Subject: [PATCH] Slightly better required keys displaying (now required keys are always shown). --- naja/widgets/info_area.py | 8 +++++--- naja/widgets/tile.py | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/naja/widgets/info_area.py b/naja/widgets/info_area.py index 34bbec7..d8e77b9 100644 --- a/naja/widgets/info_area.py +++ b/naja/widgets/info_area.py @@ -7,7 +7,7 @@ import pygame.locals as pgl from naja.constants import ( INFO_SIZE, ACT, KEYS, EXAMINE, PALETTE, ACTION_TEXT_OFFSET, INFO_LEFT_PADDING, - INFO_RIGHT_PADDING, BIT_SIZE) + INFO_RIGHT_PADDING, BIT_SIZE, BITS) from naja.events import finish_event from naja.resources import resources from naja.resources.mutators import EIGHT_BIT, blender @@ -138,8 +138,10 @@ class InfoAreaWidget(Widget): [(x_offset, y_offset), (right, y_offset), (right, bottom), (x_offset, bottom)], 4) - if action.required_bits in BIT_MAP: - img_name = BIT_MAP[action.required_bits].replace( + required_keys = action.required_bits & frozenset([ + BITS.RED, BITS.GREEN, BITS.BLUE]) + if required_keys in BIT_MAP: + img_name = BIT_MAP[required_keys].replace( '.png', '_small.png') img = resources.get_image(img_name, transforms=(EIGHT_BIT,)) diff --git a/naja/widgets/tile.py b/naja/widgets/tile.py index 9e8fe85..b898555 100644 --- a/naja/widgets/tile.py +++ b/naja/widgets/tile.py @@ -94,10 +94,12 @@ class TileWidget(Widget): self.surface.blit(img, (TILE_SIZE[0] - 20, 0)) def _prepare_lock(self, action, y_offset): - if action.required_bits not in BIT_MAP: + required_keys = action.required_bits & frozenset([ + BITS.RED, BITS.GREEN, BITS.BLUE]) + if required_keys not in BIT_MAP: return 4 - img_name = BIT_MAP[action.required_bits] + img_name = BIT_MAP[required_keys] if self.board_pos != self.state.player.position: x_offset = 0 -- 2.34.1