21 return chr(ord(
'A') + frame - 10)
24 parser = argparse.ArgumentParser(description=
"Copy a sequence of files to Crossfire faces, adequately named. Also "
25 "generate the .face file.\nFiles are supposed to be ordered by direction "
26 "then animation frame, that is the second file is direction 2, "
27 "the 9th the second frame of direction 1's animation.\nNo check on whether "
28 "the files are actually valid PNG files or not is done.")
29 parser.add_argument(
'files', nargs=
'+')
30 parser.add_argument(
'--faceset', default=
"base", type=str, help=
'faceset to generate the face for, default "base"')
31 parser.add_argument(
'--face', required=
True, type=str, help=
'name of the face to generate')
32 parser.add_argument(
'--facings', default=8, type=int, help=
'number of facings for the face, 1, 2, 4 or 8, default 8')
33 parser.add_argument(
'--magicmap', type=str, help=
'color to assign the face on the magicmap, default none so no magic '
35 parser.add_argument(
'--license', type=str, help=
'License file to use for these faces')
37 args = parser.parse_args()
39 frames_per_direction = len(args.files) / args.facings
40 if frames_per_direction !=
int(frames_per_direction):
41 print(
"Error: number of files {0} must be divisible by facings {1}".format(len(args.files), args.facings))
46 elif args.facings == 2:
48 elif args.facings == 4:
49 facings = [1, 3, 5, 7]
51 facings = [1, 2, 3, 4, 5, 6, 7, 8]
53 print(
"Making face for '{0}', with {1} facings and {2} frames per facing.".format(args.face, args.facings,
54 int(frames_per_direction)))
58 anim_file =
"animation {0}\nfacings {1}\n".format(args.face, args.facings)
61 for f
in range(0, len(facings) + 1):
64 for file
in args.files:
65 shutil.copyfile(file,
"{0}.{1}.1{2}{3}.png".format(args.face, args.faceset, facing,
frame_code(frame)))
66 anims[facing].append(
"{0}.1{1}{2}\n".format(args.face, facing,
frame_code(frame)))
68 magicmap[facing] +=
"face {0}.1{1}{2}\nmagicmap {3}\nend\n".format(args.face, facing,
frame_code(frame), args.magicmap)
71 if facing == len(facings) + 1:
76 anim_file +=
"".join(a)
79 anim_file +=
"".join(m)
81 out =
open(
"{0}.face".format(args.face),
'w')
86 shutil.copyfile(args.license,
"{0}.{1}.LICENSE".format(args.face, args.faceset))