Mercurial > mamba
annotate mamba/habitats/editor.py @ 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 | 8521c142cd43 |
children | fbb5cc655b47 |
rev | line source |
---|---|
42
8521c142cd43
Add habitat for editor and reshuffle when options are checked to before initializing the display window.
Simon Cross <hodgestar@gmail.com>
parents:
diff
changeset
|
1 """Habitat for editing levels.""" |
8521c142cd43
Add habitat for editor and reshuffle when options are checked to before initializing the display window.
Simon Cross <hodgestar@gmail.com>
parents:
diff
changeset
|
2 |
52
d09f63429b80
Add screen size fiddling to editor habitat
Neil Muller <drnlmuller@gmail.com>
parents:
42
diff
changeset
|
3 import pygame.display |
d09f63429b80
Add screen size fiddling to editor habitat
Neil Muller <drnlmuller@gmail.com>
parents:
42
diff
changeset
|
4 from pygame.locals import SWSURFACE |
d09f63429b80
Add screen size fiddling to editor habitat
Neil Muller <drnlmuller@gmail.com>
parents:
42
diff
changeset
|
5 |
42
8521c142cd43
Add habitat for editor and reshuffle when options are checked to before initializing the display window.
Simon Cross <hodgestar@gmail.com>
parents:
diff
changeset
|
6 from mamba.engine import Habitat |
8521c142cd43
Add habitat for editor and reshuffle when options are checked to before initializing the display window.
Simon Cross <hodgestar@gmail.com>
parents:
diff
changeset
|
7 from mamba.widgets.level import LevelWidget |
8521c142cd43
Add habitat for editor and reshuffle when options are checked to before initializing the display window.
Simon Cross <hodgestar@gmail.com>
parents:
diff
changeset
|
8 from mamba.level import Level |
52
d09f63429b80
Add screen size fiddling to editor habitat
Neil Muller <drnlmuller@gmail.com>
parents:
42
diff
changeset
|
9 from mamba.constants import SCREEN, EDIT_SCREEN, NAME |
42
8521c142cd43
Add habitat for editor and reshuffle when options are checked to before initializing the display window.
Simon Cross <hodgestar@gmail.com>
parents:
diff
changeset
|
10 |
8521c142cd43
Add habitat for editor and reshuffle when options are checked to before initializing the display window.
Simon Cross <hodgestar@gmail.com>
parents:
diff
changeset
|
11 |
8521c142cd43
Add habitat for editor and reshuffle when options are checked to before initializing the display window.
Simon Cross <hodgestar@gmail.com>
parents:
diff
changeset
|
12 class EditorHabitat(Habitat): |
8521c142cd43
Add habitat for editor and reshuffle when options are checked to before initializing the display window.
Simon Cross <hodgestar@gmail.com>
parents:
diff
changeset
|
13 def __init__(self, level_name): |
8521c142cd43
Add habitat for editor and reshuffle when options are checked to before initializing the display window.
Simon Cross <hodgestar@gmail.com>
parents:
diff
changeset
|
14 super(EditorHabitat, self).__init__() |
8521c142cd43
Add habitat for editor and reshuffle when options are checked to before initializing the display window.
Simon Cross <hodgestar@gmail.com>
parents:
diff
changeset
|
15 self.level = Level(level_name) |
8521c142cd43
Add habitat for editor and reshuffle when options are checked to before initializing the display window.
Simon Cross <hodgestar@gmail.com>
parents:
diff
changeset
|
16 self.container.add(LevelWidget(self.level)) |
52
d09f63429b80
Add screen size fiddling to editor habitat
Neil Muller <drnlmuller@gmail.com>
parents:
42
diff
changeset
|
17 |
d09f63429b80
Add screen size fiddling to editor habitat
Neil Muller <drnlmuller@gmail.com>
parents:
42
diff
changeset
|
18 def on_enter(self): |
d09f63429b80
Add screen size fiddling to editor habitat
Neil Muller <drnlmuller@gmail.com>
parents:
42
diff
changeset
|
19 # We need to juggle the display to the correct size |
d09f63429b80
Add screen size fiddling to editor habitat
Neil Muller <drnlmuller@gmail.com>
parents:
42
diff
changeset
|
20 # This is a horrible hack |
d09f63429b80
Add screen size fiddling to editor habitat
Neil Muller <drnlmuller@gmail.com>
parents:
42
diff
changeset
|
21 pygame.display.quit() |
d09f63429b80
Add screen size fiddling to editor habitat
Neil Muller <drnlmuller@gmail.com>
parents:
42
diff
changeset
|
22 pygame.display.init() |
d09f63429b80
Add screen size fiddling to editor habitat
Neil Muller <drnlmuller@gmail.com>
parents:
42
diff
changeset
|
23 pygame.display.set_mode(EDIT_SCREEN, SWSURFACE) |
d09f63429b80
Add screen size fiddling to editor habitat
Neil Muller <drnlmuller@gmail.com>
parents:
42
diff
changeset
|
24 pygame.display.set_caption('%s Level editor' % NAME) |
d09f63429b80
Add screen size fiddling to editor habitat
Neil Muller <drnlmuller@gmail.com>
parents:
42
diff
changeset
|
25 |
d09f63429b80
Add screen size fiddling to editor habitat
Neil Muller <drnlmuller@gmail.com>
parents:
42
diff
changeset
|
26 def on_exit(self): |
d09f63429b80
Add screen size fiddling to editor habitat
Neil Muller <drnlmuller@gmail.com>
parents:
42
diff
changeset
|
27 # We need to juggle the display to the correct size |
d09f63429b80
Add screen size fiddling to editor habitat
Neil Muller <drnlmuller@gmail.com>
parents:
42
diff
changeset
|
28 # This is a horrible hack |
d09f63429b80
Add screen size fiddling to editor habitat
Neil Muller <drnlmuller@gmail.com>
parents:
42
diff
changeset
|
29 pygame.display.quit() |
d09f63429b80
Add screen size fiddling to editor habitat
Neil Muller <drnlmuller@gmail.com>
parents:
42
diff
changeset
|
30 pygame.display.init() |
d09f63429b80
Add screen size fiddling to editor habitat
Neil Muller <drnlmuller@gmail.com>
parents:
42
diff
changeset
|
31 pygame.display.set_mode(SCREEN, SWSURFACE) |
d09f63429b80
Add screen size fiddling to editor habitat
Neil Muller <drnlmuller@gmail.com>
parents:
42
diff
changeset
|
32 pygame.display.set_caption(NAME) |