Mercurial > mamba
comparison mamba/habitats/editor.py @ 601:915de6c7d342 default tip
Add support for making the editor fullscreen too.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Sat, 14 Jan 2023 19:34:26 +0100 |
parents | 0a2cc2ee16c2 |
children |
comparison
equal
deleted
inserted
replaced
600:93cb9c1d2bb2 | 601:915de6c7d342 |
---|---|
20 from mamba.widgets.listbox import ListBox | 20 from mamba.widgets.listbox import ListBox |
21 from mamba.widgets.toollist import ToolListWidget | 21 from mamba.widgets.toollist import ToolListWidget |
22 from mamba.widgets.editsprite import EditSpriteBox | 22 from mamba.widgets.editsprite import EditSpriteBox |
23 from mamba.widgets.editlevel import EditLevelBox | 23 from mamba.widgets.editlevel import EditLevelBox |
24 from mamba.level import Level, Tileset, TILE_MAP, THING_MAP, InvalidMapError | 24 from mamba.level import Level, Tileset, TILE_MAP, THING_MAP, InvalidMapError |
25 from mamba.options import options | |
25 from mamba.data import (check_level_exists, get_level_list, load_file, | 26 from mamba.data import (check_level_exists, get_level_list, load_file, |
26 load_image, load_tile_image) | 27 load_image, load_tile_image) |
27 from mamba.constants import (SCREEN, EDIT_SCREEN, NAME, ESCAPE_KEYS, | 28 from mamba.constants import ( |
28 RESERVED_NAMES, WINDOW_ICON, LEVEL_SERVER, UP, DOWN, LEFT, RIGHT) | 29 SCREEN, EDIT_SCREEN, NAME, DISPLAY_FLAGS, FULLSCREEN_FLAGS, |
30 ESCAPE_KEYS, RESERVED_NAMES, WINDOW_ICON, LEVEL_SERVER, | |
31 UP, DOWN, LEFT, RIGHT, | |
32 ) | |
29 | 33 |
30 MAX_TOOLS = 6 | 34 MAX_TOOLS = 6 |
31 MODE_HEIGHT = 370 | 35 MODE_HEIGHT = 370 |
32 LOAD_SAVE_HEIGHT = 500 | 36 LOAD_SAVE_HEIGHT = 500 |
33 HELP = 'editor_help.txt' | 37 HELP = 'editor_help.txt' |
57 K_RIGHT: RIGHT, | 61 K_RIGHT: RIGHT, |
58 K_SPACE: None, | 62 K_SPACE: None, |
59 } | 63 } |
60 helpfile = load_file(HELP, mode="r") | 64 helpfile = load_file(HELP, mode="r") |
61 self.help_msg = ''.join(helpfile.readlines()) | 65 self.help_msg = ''.join(helpfile.readlines()) |
66 self._display_flags = DISPLAY_FLAGS | |
67 if options.fullscreen: | |
68 self._display_flags |= FULLSCREEN_FLAGS | |
62 | 69 |
63 def on_enter(self): | 70 def on_enter(self): |
64 # We need to juggle the display to the correct size | 71 # We need to juggle the display to the correct size |
65 # This is a horrible hack | 72 # This is a horrible hack |
66 pygame.display.quit() | 73 pygame.display.quit() |
67 pygame.display.init() | 74 pygame.display.init() |
68 pygame.display.set_mode(EDIT_SCREEN, SWSURFACE) | 75 pygame.display.set_mode(EDIT_SCREEN, self._display_flags) |
69 pygame.display.set_icon(load_image(WINDOW_ICON)) | 76 pygame.display.set_icon(load_image(WINDOW_ICON)) |
70 pygame.display.set_caption('%s Level editor' % NAME) | 77 pygame.display.set_caption('%s Level editor' % NAME) |
71 super(EditorHabitat, self).on_enter() | 78 super(EditorHabitat, self).on_enter() |
72 self.setup_toolbar() | 79 self.setup_toolbar() |
73 | 80 |
75 # We need to juggle the display to the correct size | 82 # We need to juggle the display to the correct size |
76 # This is a horrible hack | 83 # This is a horrible hack |
77 super(EditorHabitat, self).on_exit() | 84 super(EditorHabitat, self).on_exit() |
78 pygame.display.quit() | 85 pygame.display.quit() |
79 pygame.display.init() | 86 pygame.display.init() |
80 pygame.display.set_mode(SCREEN, SWSURFACE) | 87 pygame.display.set_mode(SCREEN, self._display_flags) |
81 pygame.display.set_icon(load_image(WINDOW_ICON)) | 88 pygame.display.set_icon(load_image(WINDOW_ICON)) |
82 pygame.display.set_caption(NAME) | 89 pygame.display.set_caption(NAME) |
83 | 90 |
84 def keydown_event(self, ev, widget): | 91 def keydown_event(self, ev, widget): |
85 if ev.key in ESCAPE_KEYS: | 92 if ev.key in ESCAPE_KEYS: |