From ae063f219281b426fc31f6fb4becec845ab4549a Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sat, 17 May 2014 01:13:27 +0200 Subject: [PATCH] Scroll arrows on (and neater) how to play page --- naja/scenes/howto.py | 4 ++-- naja/widgets/text.py | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/naja/scenes/howto.py b/naja/scenes/howto.py index 9d90341..641b302 100644 --- a/naja/scenes/howto.py +++ b/naja/scenes/howto.py @@ -5,9 +5,9 @@ Howto scene. import pygame.locals as pgl from naja.constants import KEYS +from naja.events import SceneChangeEvent from naja.scenes.scene import Scene from naja.widgets.text import TextWidget, TextBoxWidget -from naja.events import SceneChangeEvent class HowtoScene(Scene): @@ -51,7 +51,7 @@ class HowtoScene(Scene): ]), fontsize=32, colour='white', padding=1, border=1, bg_colour='black', border_colour='black', - box_width=380, view_port=(780, 500))) + box_width=360, view_port=(780, 540))) def handle_scene_event(self, ev): from naja.scenes.menu import MenuScene diff --git a/naja/widgets/text.py b/naja/widgets/text.py index 02de03f..4cc4272 100644 --- a/naja/widgets/text.py +++ b/naja/widgets/text.py @@ -3,7 +3,7 @@ import pygame.locals as pgl from naja.constants import FONT, FONT_SIZE, EIGHT_BIT_SCALE, PALETTE, KEYS from naja.resources import resources -from naja.resources.mutators import EIGHT_BIT, blender +from naja.resources.mutators import EIGHT_BIT, R180, blender from naja.utils import convert_colour from naja.widgets.base import Widget @@ -104,6 +104,23 @@ class TextWidget(Widget): rect = self.pos area = self.view_port surface.blit(self.surface, rect, area) + if self.view_port is not None: + self.draw_arrows(surface) + + def draw_arrows(self, surface): + if self.view_port.top > 0: + up = resources.get_image('bits', 'arrow_on.png', + transforms=(EIGHT_BIT,)) + icon_size = up.get_rect().height + pos = (self.pos[0] + self.view_port.width - icon_size, self.pos[1]) + surface.blit(up, pos) + if self.view_port.bottom < self.surface.get_rect().bottom: + down = resources.get_image('bits', 'arrow_on.png', + transforms=(R180, EIGHT_BIT)) + icon_size = down.get_rect().height + pos = (self.pos[0] + self.view_port.width - icon_size, + self.pos[1] + self.view_port.height - icon_size) + surface.blit(down, pos) class TextBoxWidget(TextWidget): -- 2.34.1