Crossfire Server, Trunk
split_aura_picture.py
Go to the documentation of this file.
1 #!/bin/python
2 
3 #
4 # Crossfire -- cooperative multi-player graphical RPG and adventure game
5 #
6 # Copyright (c) 2022 the Crossfire Development Team
7 #
8 # Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
9 # welcome to redistribute it under certain conditions. For details, please
10 # see COPYING and LICENSE.
11 #
12 # The authors can be reached via e-mail at <crossfire@metalforge.org>.
13 #
14 
15 import argparse
16 import shutil
17 import subprocess
18 
19 parser = argparse.ArgumentParser(description="Split a sequence of pictures to Crossfire faces and animations, adequately named for an aura. "
20  "Generate the .face file with the corresponding animations.")
21 parser.add_argument('files', nargs='+')
22 parser.add_argument('--faceset', default="base", type=str, help='faceset to generate the face for, default "base"')
23 parser.add_argument('--name', required=True, type=str, help='name of the faces and animations to generate')
24 parser.add_argument('--size', required=True, type=int, help='number of faces to make for each size')
25 parser.add_argument('--magicmap', type=str, help='color to assign the face on the magicmap, default none so no magic '
26  'map information')
27 parser.add_argument('--license', type=str, help='License file to use for these faces')
28 
29 args = parser.parse_args()
30 
31 print("Making split animation and faces for '{0}'.".format(args.name))
32 
33 frames = len(args.files)
34 magicmap = ''
35 
36 with open('{0}.face'.format(args.name), 'w') as anim_file:
37  for x in range(0, args.size):
38  for y in range(0, args.size):
39  anim_file.write('animation {0}_{1}_{2}\n'.format(args.name, x, y))
40  for f in range(0, frames):
41  face_name = '{0}.{1}{2}{3}\n'.format(args.name, x, y, f)
42  anim_file.write(face_name)
43  subprocess.call(['convert', '-extract', '32x32+{0}+{1}'.format(x * 32, y * 32), args.files[f], '{0}.{1}.{2}{3}{4}.png'.format(args.name, args.faceset, x, y, f)])
44  if args.magicmap:
45  magicmap += 'face {0}magicmap {1}\nend\n'.format(face_name, args.magicmap)
46  anim_file.write('mina\n')
47  anim_file.write(magicmap)
48 
49 if args.license:
50  shutil.copyfile(args.license, "{0}.{1}.LICENSE".format(args.name, args.faceset))
CFBank.open
def open()
Definition: CFBank.py:69