Add basic script for parsing assets.
This commit is contained in:
parent
528d9577eb
commit
3bb110172f
141
scripts/assets.py
Executable file
141
scripts/assets.py
Executable file
@ -0,0 +1,141 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import sys
|
||||
from PIL import Image
|
||||
|
||||
# The guide in tiles/guide.png is quite helpful.
|
||||
|
||||
# TODO: sort the stuff in free/ and noncommercial/
|
||||
# TODO: in future/100/characters there are some doors, conveyor belts, screens
|
||||
|
||||
SPRITE_FILES = [
|
||||
'animals/sheets/*.png',
|
||||
'beasttribes/100/*.png',
|
||||
'characters/sheets/*.png',
|
||||
'christmas/1x/gnome*.png',
|
||||
'christmas/1x/reindeer*.png',
|
||||
'christmas/1x/rudolph*.png',
|
||||
'christmas/1x/xmas*.png',
|
||||
'dwarvesvselves/regularsize/*.png',
|
||||
'future/100/characters/cars.png',
|
||||
'future/100/characters/future*.png',
|
||||
'future/100/characters/military*.png',
|
||||
'future/100/characters/modern*.png',
|
||||
'halloween/ghost1.png',
|
||||
'halloween/horseman/*1.png',
|
||||
'halloween/reaper/*1.png',
|
||||
'halloween/witch/1x/*.png',
|
||||
'lichcrusades/100/*.png',
|
||||
'monsters/1x/*.png',
|
||||
'mythicalbosses/100/*.png',
|
||||
'mythicalbosses/dinosaurs/*.png',
|
||||
'npcanimations/rpgmaker/1/*.png',
|
||||
'ship/100/char/airship*.png',
|
||||
'ship/100/char/boat*.png',
|
||||
'ship/100/char/pirates_100.png',
|
||||
'ship/100/char/ship*.png',
|
||||
]
|
||||
|
||||
SPRITE_SIDEVIEW_FILES = [
|
||||
'beasttribes/100/sv_battler/*.png',
|
||||
'future/100/svbattler/*.png',
|
||||
# TODO: these need to get scaled down 2x before they can be used.
|
||||
'sv_battle/RMMV/sv_actors/*.png',
|
||||
]
|
||||
|
||||
TILESET_FILES = [
|
||||
'ashlands/ashlands_tileset.png',
|
||||
'atlantis/tf_atlantis_tiles.png',
|
||||
'beach/beach_tileset.png',
|
||||
'christmas/1x/addon_igloo_1.png',
|
||||
'christmas/1x/christmas*.png',
|
||||
'cloud/cloud_tileset.png',
|
||||
'darkdimension/tf_darkdimension_sheet.png',
|
||||
'farmandfort/ff_master_tile_sheet.png',
|
||||
'future/100/tilesets/*.png',
|
||||
'gianttree/tf_gianttree_tiles.png',
|
||||
'halloween/tiles/*1.png',
|
||||
'jungle/tf_jungle_tileset.png',
|
||||
'patron/train_sheet_1.png',
|
||||
'ruindungeons/ruindungeons_sheet_full.png',
|
||||
'ship/ship_big_tileset.png',
|
||||
'tiles/TILESETS/*.png',
|
||||
'winter/tiles/*.png',
|
||||
]
|
||||
|
||||
ANIMATION_FILES = [
|
||||
'patron/fireworks*_1.png',
|
||||
'pixelanimations/animationsheets/*.png',
|
||||
'ship/100/char/!$ship_wave*.png',
|
||||
'sv_battle/RMMV/system/States.png',
|
||||
'tiles/TILESETS/animated/*.png',
|
||||
]
|
||||
|
||||
ICON_FILES = [
|
||||
'farmandfort/IconSet/tf_icon_16.png',
|
||||
'halloween/hallowicons_1.png',
|
||||
]
|
||||
|
||||
BACKGROUND_FILES = [
|
||||
'cloud/bg_*.png',
|
||||
'future/100/other/spacebg.png',
|
||||
'ship/100/parallax/*.png'
|
||||
]
|
||||
|
||||
|
||||
def unglob(list_of_globs):
|
||||
result = []
|
||||
for file in list_of_globs:
|
||||
globbed_files = glob.glob(file)
|
||||
assert len(globbed_files) > 0, 'glob for %s should be non-empty' % file
|
||||
result.extend(globbed_files)
|
||||
result.sort()
|
||||
return result
|
||||
|
||||
|
||||
def input_wh(prompt):
|
||||
while True:
|
||||
geometry = input(prompt)
|
||||
try:
|
||||
cols, rows = [int(x) for x in geometry.split(' ')]
|
||||
return cols, rows
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
os.chdir(os.path.expanduser('~/time_fantasy'))
|
||||
metadata = json.load(open('metadata.json'))
|
||||
|
||||
sprite_files = unglob(SPRITE_FILES)
|
||||
tileset_files = unglob(TILESET_FILES)
|
||||
animation_files = unglob(ANIMATION_FILES)
|
||||
icon_files = unglob(ICON_FILES)
|
||||
background_files = unglob(BACKGROUND_FILES)
|
||||
print('sprites: %d tilesets: %d animations: %d icons: %d backgrounds: %d' %
|
||||
(len(sprite_files), len(tileset_files), len(animation_files),
|
||||
len(icon_files), len(background_files)))
|
||||
|
||||
for filename in sprite_files:
|
||||
with Image.open(filename) as image:
|
||||
x = image.show()
|
||||
cols, rows = input_wh('%s (%dx%d): ' % (
|
||||
filename, image.size[0], image.size[1]))
|
||||
width = image.size[0] / cols
|
||||
height = image.size[1] / rows
|
||||
print(width, height)
|
||||
if rows == 1 and cols == 1:
|
||||
continue
|
||||
for i in range(rows):
|
||||
for j in range(cols):
|
||||
box = (j * width, i * height, (j + 1) * width, (i + 1) * height)
|
||||
sprites = image.crop(box)
|
||||
sprites.show()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue
Block a user