diff options
author | Bryan Bishop <kanzure@gmail.com> | 2013-12-29 01:18:49 -0800 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2013-12-29 01:18:49 -0800 |
commit | 074e47aeea8250239fb370116d94167e11848032 (patch) | |
tree | 85ef1da0a11a9772dfcfa8aef8753e8c0a7878d5 | |
parent | 6ec167512e05c3541308fbbaa7e91cf53942e533 (diff) | |
parent | c234cdd9036f8b6f55b9c26abcc75967e8485144 (diff) |
Merge pull request #63 from yenatch/map-editor-saving
map_editor: allow saving new maps + save file dialog
-rw-r--r-- | pokemontools/gfx.py | 5 | ||||
-rw-r--r-- | pokemontools/map_editor.py | 7 |
2 files changed, 10 insertions, 2 deletions
diff --git a/pokemontools/gfx.py b/pokemontools/gfx.py index 147621b..04ccac5 100644 --- a/pokemontools/gfx.py +++ b/pokemontools/gfx.py @@ -1566,11 +1566,16 @@ def export_lz_to_png(filename): """ assert filename[-3:] == ".lz" lz_data = open(filename, "rb").read() + bpp = Decompressed(lz_data).output bpp_filename = filename.replace(".lz", ".2bpp") to_file(bpp_filename, bpp) + export_2bpp_to_png(bpp_filename) + # touch the lz file so it doesn't get remade + os.utime(filename, None) + def dump_tileset_pngs(): """ Convert .lz format tilesets into .png format tilesets. 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: |