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 = (
'.####.'.
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
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
);
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
'-msglevel' => 'all=3',
);
+=head1 NAME
+
+capture - Read and parse StarCraft game screenshots
+
+=head1 SYNOPSIS
+
+B<capture> [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 <perl@shiar.org>
+
+=head1 LICENSE
+
+You may distribute under the terms of either the GNU General Public License
+or the Artistic License, as specified in the Perl README file.
+