# HG changeset patch # User Neil Muller # Date 1316085900 -7200 # Node ID 3c95ba7408f1b6a0c975281a10a7fff0be7cf12c # Parent adaaea7a8fef86868fc1ba6ddb57b31d33d8cd5c Add protected level name list. Add load & new buttons diff -r adaaea7a8fef -r 3c95ba7408f1 mamba/constants.py --- a/mamba/constants.py Thu Sep 15 13:23:59 2011 +0200 +++ b/mamba/constants.py Thu Sep 15 13:25:00 2011 +0200 @@ -27,6 +27,9 @@ FOCUS_COLOR = 'yellow' COLOR = 'black' +# Special level directory files +RESERVED_NAMES = ['index', 'blank'] + # Directions UP, DOWN, LEFT, RIGHT = [(0, -1), (0, 1), (-1, 0), (1, 0)] diff -r adaaea7a8fef -r 3c95ba7408f1 mamba/habitats/editor.py --- a/mamba/habitats/editor.py Thu Sep 15 13:23:59 2011 +0200 +++ b/mamba/habitats/editor.py Thu Sep 15 13:25:00 2011 +0200 @@ -12,9 +12,10 @@ from mamba.widgets.toollist import ToolListWidget from mamba.level import Level, TILE_MAP, THING_MAP from mamba.data import check_level_exists -from mamba.constants import SCREEN, EDIT_SCREEN, NAME, ESCAPE_KEYS +from mamba.constants import (SCREEN, EDIT_SCREEN, NAME, ESCAPE_KEYS, + RESERVED_NAMES) -MAX_TOOLS = 8 +MAX_TOOLS = 6 class EditorHabitat(Habitat): @@ -130,9 +131,16 @@ button_height += mode_button.surface.get_height() + button_padding button_height += 2 - save_button = TextButton((button_left, button_height), "Save Level") - save_button.add_callback('clicked', self.save) - self.container.add(save_button) + new = TextButton((button_left, button_height), "New") + new.add_callback('clicked', self.new) + self.container.add(new) + load = TextButton((button_left + 60, button_height), "Load") + load.add_callback('clicked', self.load) + self.container.add(load) + + save = TextButton((button_left + 120, button_height), "Save") + save.add_callback('clicked', self.save) + self.container.add(save) def change_tool(self, ev, widget, new_tool, text): self.edit_widget.set_tool(new_tool) @@ -140,8 +148,17 @@ self.current_tool.prepare() def save(self, ev, widget): + if self.level.level_name in RESERVED_NAMES: + print "Can't save over reserved name" + return self.level.save_level() + def new(self, ev, widget): + pass + + def load(self, ev, widget): + pass + def change_toolbar(self, ev, widget): if self.mode == 'Tile': self.mode = 'Thing'