diff options
author | yenatch <yenatch@gmail.com> | 2013-12-29 03:49:31 -0500 |
---|---|---|
committer | yenatch <yenatch@gmail.com> | 2013-12-29 03:59:35 -0500 |
commit | 51d6f1edca87b9e6c92d92219d143449b32412e2 (patch) | |
tree | cd53317ac69fa8b7f9ee0fb92252abca479bf3a6 /pokemontools/map_editor.py | |
parent | 70cd4f7c00b33a398ed7af071773c06ca335c105 (diff) |
map_editor: allow saving new maps + save file dialog
saves to newmap.asm by default
Diffstat (limited to 'pokemontools/map_editor.py')
-rw-r--r-- | pokemontools/map_editor.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/pokemontools/map_editor.py b/pokemontools/map_editor.py index b9a6b61..a7aeda1 100644 --- a/pokemontools/map_editor.py +++ b/pokemontools/map_editor.py @@ -15,6 +15,7 @@ from Tkinter import ( X, TclError, ) +import tkFileDialog from ttk import ( Frame, @@ -178,7 +179,8 @@ class Application(Frame): def new_map(self): self.map_name = None self.init_map() - self.map.blockdata = [self.paint_tile] * 20 * 20 + self.map.blockdata_filename = os.path.join(self.config.map_dir, 'newmap.blk') + self.map.blockdata = bytearray([self.paint_tile] * 20 * 20) self.map.width = 20 self.map.height = 20 self.draw_map() @@ -193,7 +195,8 @@ class Application(Frame): def save_map(self): if hasattr(self, 'map'): if self.map.blockdata_filename: - with open(self.map.blockdata_filename, 'wb') as save: + filename = tkFileDialog.asksaveasfilename(initialfile=self.map.blockdata_filename) + with open(filename, 'wb') as save: save.write(self.map.blockdata) self.log.info('blockdata saved as {}'.format(self.map.blockdata_filename)) else: |