projects
/
naja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove unnecessary overriding of TextWidget.draw in TextBoxWidget.draw.
[naja.git]
/
naja
/
widgets
/
text.py
diff --git
a/naja/widgets/text.py
b/naja/widgets/text.py
index 3b0827d3f997fc4ff37be515439da7b0fd867520..306841257ccaa090238743be176f680ed651a354 100644
(file)
--- a/
naja/widgets/text.py
+++ b/
naja/widgets/text.py
@@
-19,6
+19,11
@@
MARKUP_MAP = {
'RED': ('glyphs/key.png', PALETTE.ORANGE),
'GREEN': ('glyphs/key.png', PALETTE.GREEN),
'BLUE': ('glyphs/key.png', PALETTE.BLUE),
'RED': ('glyphs/key.png', PALETTE.ORANGE),
'GREEN': ('glyphs/key.png', PALETTE.GREEN),
'BLUE': ('glyphs/key.png', PALETTE.BLUE),
+ 'CLOCKWISE': ('glyphs/clockwise.png', None),
+ 'ANTICLOCKWISE': ('glyphs/anticlockwise.png', None),
+
+ 'HEALTH_NOCOLOUR': ('glyphs/health.png', None),
+ 'WINTOKEN_NOCOLOUR': ('glyphs/win.png', None),
}
}
@@
-32,16
+37,22
@@
class Glyph(object):
class TextWidget(Widget):
def __init__(self, pos, text, size=None, fontname=None, fontsize=None,
class TextWidget(Widget):
def __init__(self, pos, text, size=None, fontname=None, fontsize=None,
- colour=None):
+ colour=None
, unselectable_colour=None
):
super(TextWidget, self).__init__(pos, size)
self.text = text
self.fontname = fontname or FONT
self.fontsize = (fontsize or FONT_SIZE) // EIGHT_BIT_SCALE
self.colour = convert_colour(colour or PALETTE.BLACK)
super(TextWidget, self).__init__(pos, size)
self.text = text
self.fontname = fontname or FONT
self.fontsize = (fontsize or FONT_SIZE) // EIGHT_BIT_SCALE
self.colour = convert_colour(colour or PALETTE.BLACK)
+ if unselectable_colour is not None:
+ unselectable_colour = convert_colour(unselectable_colour)
+ self.unselectable_colour = unselectable_colour
def render_line(self, text):
def render_line(self, text):
- text_surf = self.font.render(text, True, self.colour)
+ colour = self.colour
+ if not self.is_selectable() and self.unselectable_colour is not None:
+ colour = self.unselectable_colour
+ text_surf = self.font.render(text, True, colour)
text_rect = text_surf.get_rect()
return pygame.transform.scale(
text_surf, (text_rect.width * EIGHT_BIT_SCALE,
text_rect = text_surf.get_rect()
return pygame.transform.scale(
text_surf, (text_rect.width * EIGHT_BIT_SCALE,
@@
-53,7
+64,7
@@
class TextWidget(Widget):
self.size = self.surface.get_rect().size
def draw(self, surface):
self.size = self.surface.get_rect().size
def draw(self, surface):
- surface.blit(self.surface, self.
pos
)
+ surface.blit(self.surface, self.
rect
)
class TextBoxWidget(TextWidget):
class TextBoxWidget(TextWidget):
@@
-97,8
+108,6
@@
class TextBoxWidget(TextWidget):
subwords = word[1:-1].split(',')
if all(subword in MARKUP_MAP for subword in subwords):
return Glyph(word + suffix, subwords, suffix)
subwords = word[1:-1].split(',')
if all(subword in MARKUP_MAP for subword in subwords):
return Glyph(word + suffix, subwords, suffix)
- elif word in MARKUP_MAP:
- return Glyph(word + suffix, [word], suffix)
return None
return None
@@
-134,6
+143,7
@@
class TextBoxWidget(TextWidget):
word = glyph.markup_text
remaining_words.insert(0, word)
if current_words and words_fit(current_words):
word = glyph.markup_text
remaining_words.insert(0, word)
if current_words and words_fit(current_words):
+ line_count += 1
yield ' '.join(current_words)
def prepare(self):
yield ' '.join(current_words)
def prepare(self):
@@
-159,6
+169,3
@@
class TextBoxWidget(TextWidget):
y += line_surface.get_rect().height
for pos, img in image_map.items():
self.surface.blit(img, pos)
y += line_surface.get_rect().height
for pos, img in image_map.items():
self.surface.blit(img, pos)
-
- def draw(self, surface):
- surface.blit(self.surface, self.rect)