changeset 52:d09f63429b80

Add screen size fiddling to editor habitat
author Neil Muller <drnlmuller@gmail.com>
date Sun, 11 Sep 2011 15:47:47 +0200
parents e5f36843f7cd
children fb21519471e7
files mamba/__main__.py mamba/constants.py mamba/habitats/editor.py
diffstat 3 files changed, 26 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mamba/__main__.py	Sun Sep 11 15:42:57 2011 +0200
+++ b/mamba/__main__.py	Sun Sep 11 15:47:47 2011 +0200
@@ -4,7 +4,7 @@
 import pygame
 from pygame.locals import SWSURFACE
 
-from mamba.constants import SCREEN
+from mamba.constants import SCREEN, NAME
 from mamba.options import options, parse_args, check_args
 from mamba.engine import Engine
 from mamba.sound import SoundSystem
@@ -23,7 +23,7 @@
     pygame.display.init()
     pygame.font.init()
     pygame.display.set_mode(SCREEN, SWSURFACE)
-    pygame.display.set_caption('Mamba')
+    pygame.display.set_caption(NAME)
 
     if options.edit:
         start = EditorHabitat(options.level)
--- a/mamba/constants.py	Sun Sep 11 15:42:57 2011 +0200
+++ b/mamba/constants.py	Sun Sep 11 15:47:47 2011 +0200
@@ -3,6 +3,10 @@
 SCREEN = (800, 600)
 TILE_SIZE = (20, 20)
 
+EDIT_SCREEN = (1000, 600)
+
+NAME = "Unamed Mamba game"
+
 # Sound constants
 FREQ = 44100   # same as audio CD
 BITSIZE = -16  # unsigned 16 bit
--- a/mamba/habitats/editor.py	Sun Sep 11 15:42:57 2011 +0200
+++ b/mamba/habitats/editor.py	Sun Sep 11 15:47:47 2011 +0200
@@ -1,8 +1,12 @@
 """Habitat for editing levels."""
 
+import pygame.display
+from pygame.locals import SWSURFACE
+
 from mamba.engine import Habitat
 from mamba.widgets.level import LevelWidget
 from mamba.level import Level
+from mamba.constants import SCREEN, EDIT_SCREEN, NAME
 
 
 class EditorHabitat(Habitat):
@@ -10,3 +14,19 @@
         super(EditorHabitat, self).__init__()
         self.level = Level(level_name)
         self.container.add(LevelWidget(self.level))
+
+    def on_enter(self):
+        # We need to juggle the display to the correct size
+        # This is a horrible hack
+        pygame.display.quit()
+        pygame.display.init()
+        pygame.display.set_mode(EDIT_SCREEN, SWSURFACE)
+        pygame.display.set_caption('%s Level editor' % NAME)
+
+    def on_exit(self):
+        # We need to juggle the display to the correct size
+        # This is a horrible hack
+        pygame.display.quit()
+        pygame.display.init()
+        pygame.display.set_mode(SCREEN, SWSURFACE)
+        pygame.display.set_caption(NAME)