Scroll arrows on (and neater) how to play page
authorStefano Rivera <stefano@rivera.za.net>
Fri, 16 May 2014 23:13:27 +0000 (01:13 +0200)
committerStefano Rivera <stefano@rivera.za.net>
Fri, 16 May 2014 23:13:48 +0000 (01:13 +0200)
naja/scenes/howto.py
naja/widgets/text.py

index 9d903416c432c38006b069ec4cba4d2f7b855374..641b3023a094dbd36a1feb62e3a2285b7c4436a5 100644 (file)
@@ -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
index 02de03fd955be7f9b45324077df7390daa6a8dcd..4cc4272f7435d9a7bf16ef530a3c1bb004a29c7a 100644 (file)
@@ -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):