I´ve been asked how I create the datafile for CatanAid - so here is the code I used for CatanAid v. 0.1 (current version):
#!/usr/bin/perl
use GD;
use Tk;
use MIME::Base64;
open (DATA, ">graphicsdata");
foreach (<images/*>) {
my $type = (split/\//, $_)[1];
foreach (<$_/*.gif>) {
my $name = (split /\./,((split/\//, $_)[2]))[0];
print "Adding imagedata to datafile: $type/$name ($_).\n";
open (GIF, $_);
$data = encode_base64((newFromGif GD::Image(GIF))->gif);
close GIF;
print DATA "<" . $type . "/" . $name . ">\n" . $data;
}
}
close DATA;
The images are regular .gif images placed in a simple directory structure:
images/interface/expansionbutton.gif
images/interface/background.gif
images/interface/standardbutton.gif
images/landscapes/mountain.gif
images/landscapes/dessert.gif
images/landscapes/forest.gif
images/landscapes/hill.gif
images/landscapes/pasture.gif
images/landscapes/plain.gif
images/landscapes/sea.gif
images/ports/mountain.gif
images/ports/forest.gif
images/ports/hill.gif
images/ports/surprise.gif
images/ports/pasture.gif
images/ports/plain.gif
Well... this should put at lid on this discussion i´ve been having with myself. :-)
Regards Søren Schimkat |