18 parser = argparse.ArgumentParser(description=
"Copy a sequence of files to Crossfire faces, adequately named. Also "
19 "generate the .face file.\nFiles are supposed to be ordered by direction "
20 "then animation frame, that is the second file is direction 2, "
21 "the 9th the second frame of direction 1's animation.\nNo check on whether "
22 "the files are actually valid PNG files or not is done.")
23 parser.add_argument(
'files', nargs=
'+')
24 parser.add_argument(
'--faceset', default=
"base", type=str, help=
'faceset to generate the face for, default "base"')
25 parser.add_argument(
'--face', required=
True, type=str, help=
'name of the face to generate')
26 parser.add_argument(
'--facings', default=8, type=int, help=
'number of facings for the face, 1, 2, 4 or 8, default 8')
27 parser.add_argument(
'--magicmap', type=str, help=
'color to assign the face on the magicmap, default none so no magic '
29 parser.add_argument(
'--license', type=str, help=
'License file to use for these faces')
31 args = parser.parse_args()
33 frames_per_direction = len(args.files) / args.facings
34 if frames_per_direction !=
int(frames_per_direction):
35 print(
"Error: number of files {0} must be divisible by facings {1}".format(len(args.files), args.facings))
40 elif args.facings == 2:
42 elif args.facings == 4:
43 facings = [1, 3, 5, 7]
45 facings = [1, 2, 3, 4, 5, 6, 7, 8]
47 print(
"Making face for '{0}', with {1} facings and {2} frames per facing.".format(args.face, args.facings,
48 int(frames_per_direction)))
52 anim_file =
"animation {0}\nfacings {1}\n".format(args.face, args.facings)
55 for f
in range(0, len(facings) + 1):
58 for file
in args.files:
59 shutil.copyfile(file,
"{0}.{1}.1{2}{3}.png".format(args.face, args.faceset, facing, frame))
60 anims[facing].append(
"{0}.1{1}{2}\n".format(args.face, facing, frame))
62 magicmap[facing] +=
"face {0}.1{1}{2}\nmagicmap {3}\nend\n".format(args.face, facing, frame, args.magicmap)
65 if facing == len(facings) + 1:
70 anim_file +=
"".join(a)
73 anim_file +=
"".join(m)
75 out =
open(
"{0}.face".format(args.face),
'w')
80 shutil.copyfile(args.license,
"{0}.{1}.LICENSE".format(args.face, args.faceset))