changeset 94:aba653f8383e

Start adding editor toolbar
author Neil Muller <drnlmuller@gmail.com>
date Sun, 11 Sep 2011 19:16:16 +0200
parents 8d073e402294
children 7a17c5b74148
files mamba/habitats/editor.py
diffstat 1 files changed, 31 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mamba/habitats/editor.py	Sun Sep 11 19:15:58 2011 +0200
+++ b/mamba/habitats/editor.py	Sun Sep 11 19:16:16 2011 +0200
@@ -5,13 +5,15 @@
 
 from mamba.engine import Habitat, NewHabitatEvent
 from mamba.widgets.level import LevelWidget
-from mamba.level import Level
+from mamba.widgets.text import TextWidget
+from mamba.widgets.imagebutton import ImageButtonWidget
+from mamba.level import Level, Tileset
 from mamba.constants import SCREEN, EDIT_SCREEN, NAME, ESCAPE_KEYS
 
 
 class EditorHabitat(Habitat):
     def __init__(self, level_name):
-        super(EditorHabitat, self).__init__()
+        super(EditorHabitat, self).__init__(EDIT_SCREEN)
         self.level = Level(level_name)
         self.container.add(LevelWidget(self.level))
         self.container.add_callback(KEYDOWN, self.keydown_event)
@@ -24,6 +26,7 @@
         pygame.display.set_mode(EDIT_SCREEN, SWSURFACE)
         pygame.display.set_caption('%s Level editor' % NAME)
         super(EditorHabitat, self).on_enter()
+        self.setup_toolbar()
 
     def on_exit(self):
         # We need to juggle the display to the correct size
@@ -38,3 +41,29 @@
         if ev.key in ESCAPE_KEYS:
             from mamba.habitats.mainmenu import MainMenu
             NewHabitatEvent.post(MainMenu())
+
+    def setup_toolbar(self):
+        """Draw the editor toolbar"""
+        button_height = 20
+        button_left = 820
+        button_padding = 10
+        levelname = TextWidget(
+                (button_left, button_height),
+                'Level: %s' % 'Placeholder', color='white')
+        self.container.add(levelname)
+        button_height += levelname.surface.get_height() + button_padding
+
+        tilesetname = TextWidget(
+                (button_left, button_height),
+                'Tileset: %s' % self.level.tileset.name, color='white')
+        self.container.add(tilesetname)
+        button_height += tilesetname.surface.get_height() + button_padding
+        floor_button = ImageButtonWidget(
+                (button_left, button_height), self.level.tileset.floor,
+                'Floor', color='white')
+        self.container.add(floor_button)
+
+
+
+
+