castleraider
changeset 322:6f53862eb4f7
Made the utility write multiple images for levels with multiple palettes.
Added a license header.
| author | David Boddie <david@boddie.org.uk> |
|---|---|
| date | Sat Oct 04 01:13:43 2014 +0200 |
| parents | 876c2709d378 |
| children | e4cdff52b4a0 |
| files | utilities/make_map_overview.py |
| diffstat | 1 files changed, 31 insertions(+), 7 deletions(-) [+] |
line diff
1.1 --- a/utilities/make_map_overview.py Fri Oct 03 00:12:39 2014 +0200 1.2 +++ b/utilities/make_map_overview.py Sat Oct 04 01:13:43 2014 +0200 1.3 @@ -1,5 +1,22 @@ 1.4 #!/usr/bin/env python 1.5 1.6 +""" 1.7 +Copyright (C) 2012 David Boddie <david@boddie.org.uk> 1.8 + 1.9 +This program is free software: you can redistribute it and/or modify 1.10 +it under the terms of the GNU General Public License as published by 1.11 +the Free Software Foundation, either version 3 of the License, or 1.12 +(at your option) any later version. 1.13 + 1.14 +This program is distributed in the hope that it will be useful, 1.15 +but WITHOUT ANY WARRANTY; without even the implied warranty of 1.16 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1.17 +GNU General Public License for more details. 1.18 + 1.19 +You should have received a copy of the GNU General Public License 1.20 +along with this program. If not, see <http://www.gnu.org/licenses/>. 1.21 +""" 1.22 + 1.23 import os, sys 1.24 import Image 1.25 1.26 @@ -89,6 +106,7 @@ 1.27 1.28 y = 8 * 6 1.29 colours_used = {} 1.30 + 1.31 for row in rows: 1.32 1.33 x = 0 1.34 @@ -116,7 +134,7 @@ 1.35 1.36 elif tile in portals: 1.37 portal_colour = portals[tile][-1] 1.38 - colours_used[portal_colour] = colours_used.get(portal_colour, 0) + 1 1.39 + colours_used.setdefault(portal_colour, []).append(x) 1.40 tile = "." 1.41 1.42 if not skip and tile in tile_images: 1.43 @@ -127,12 +145,18 @@ 1.44 1.45 y += 8 1.46 1.47 - colours_used = map(lambda (c, f): (f, c), colours_used.items()) 1.48 - colours_used.sort() 1.49 - colour = colours[colours_used[-1][1]] 1.50 + for portal_colour in colours_used.keys(): 1.51 1.52 - level_image.putpalette(colours["black"] + colours["red"] + colour + \ 1.53 - colours["yellow"]) 1.54 - level_image.save(os.path.join(output_dir, name + ".png")) 1.55 + level_image.putpalette( 1.56 + colours["black"] + colours["red"] + \ 1.57 + colours[portal_colour] + colours["yellow"] 1.58 + ) 1.59 + 1.60 + if len(colours_used) > 1: 1.61 + file_name = "%s-%s.png" % (name, portal_colour) 1.62 + else: 1.63 + file_name = "%s.png" % name 1.64 + 1.65 + level_image.save(os.path.join(output_dir, file_name)) 1.66 1.67 sys.exit()
