X-Git-Url: http://git.shiar.net/perl/schtarr.git/blobdiff_plain/9b1ee55eb24347c0bbd567b17852a16f68803172..5f038fb3e000dfac421901388bbe977b23803acb:/capture diff --git a/capture b/capture index 828f1fd..d363a49 100755 --- a/capture +++ b/capture @@ -3,12 +3,17 @@ use strict; use warnings; +use Getopt::Long 2.33 qw(HelpMessage :config bundling); use Data::Dumper; use Time::HiRes qw(sleep alarm); use Imager; -use constant {DEBUG => 0}; -our $VERSION = '2.00'; +our $VERSION = '2.01'; + +GetOptions( + "verbose|v!" => \our $DEBUG, + "map|m!" => \our $GETMAP, +) or HelpMessage(-exitval => 2); my %digittime = ( '.####.'. @@ -163,7 +168,7 @@ sub getchars { sub parsestats { my $input = shift; # (452,6)-(639,13) $input->write(file => sprintf "tests%05d.png", $i) or warn $input->errstr - if DEBUG; + if $DEBUG; my $stats = filter_color($input, "\020\377\030", "\317\030\030", # CF1818/C81818 "\310\030\030", # ?/10FF18 @@ -179,7 +184,7 @@ sub parsestats { sub parsetimer { my $input = shift; # (587,396)-(621,402) $input->write(file => sprintf "testt%05d.png", $i) or warn $input->errstr - if DEBUG; + if $DEBUG; my $play = filter_color($input, "\276\272\357", # BEBAEF ); @@ -238,14 +243,13 @@ if ($ARGV[0]) { require Imager::Screenshot; import Imager::Screenshot qw(screenshot); - local $SIG{ALRM} = \&capturemap; - alarm 5, 1; + ($SIG{ALRM} = \&capturemap), alarm 5, 1 if $GETMAP; while (1) { $i++; capturestats(); - sleep .2; + sleep .2 if $GETMAP; } - alarm 0; + alarm 0 if $GETMAP; } =cut @@ -260,3 +264,34 @@ exec 'mencoder' => ( '-msglevel' => 'all=3', ); +=head1 NAME + +capture - Read and parse StarCraft game screenshots + +=head1 SYNOPSIS + +B [OPTIONS] [INPUT] + +capture --map dump%04d.png + +=head1 OPTIONS + +=over 8 + +=item --verbose | -v + +Debug mode. +Stores captured statistics areas as test[ts]?????.png images. + +=item --map | -m + +Capture the minimap area every second (StarCraft won't update more often, +regardless of game speed). +Images are stored as map?????.png in the current directory. + +=back + +=head1 AUTHOR + +Mischa POSLAWSKY +