summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
9b1ee55)
Fix the need to modify code for changing run mode.
Debug mode can be triggered by --verbose (-v).
Map capturing can be enabled by --map (-m).
Common --version and --help are handled as a bonus (short documentation
setup written for capture).
use strict;
use warnings;
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 Data::Dumper;
use Time::HiRes qw(sleep alarm);
use Imager;
-use constant {DEBUG => 0};
+our $VERSION = '2.01';
+
+GetOptions(
+ "verbose|v!" => \our $DEBUG,
+ "map|m!" => \our $GETMAP,
+) or HelpMessage(-exitval => 2);
my %digittime = (
'.####.'.
my %digittime = (
'.####.'.
sub parsestats {
my $input = shift; # (452,6)-(639,13)
$input->write(file => sprintf "tests%05d.png", $i) or warn $input->errstr
sub parsestats {
my $input = shift; # (452,6)-(639,13)
$input->write(file => sprintf "tests%05d.png", $i) or warn $input->errstr
my $stats = filter_color($input,
"\020\377\030", "\317\030\030", # CF1818/C81818
"\310\030\030", # ?/10FF18
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
sub parsetimer {
my $input = shift; # (587,396)-(621,402)
$input->write(file => sprintf "testt%05d.png", $i) or warn $input->errstr
my $play = filter_color($input,
"\276\272\357", # BEBAEF
);
my $play = filter_color($input,
"\276\272\357", # BEBAEF
);
require Imager::Screenshot;
import Imager::Screenshot qw(screenshot);
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();
while (1) {
$i++;
capturestats();
'-msglevel' => 'all=3',
);
'-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>
+
use strict;
use warnings;
use strict;
use warnings;
+use Getopt::Long 2.33 qw(HelpMessage :config bundling);
use Template;
use List::Util;
use Data::Dumper;
use Template;
use List::Util;
use Data::Dumper;
+our $VERSION = '1.00';
+
+GetOptions(
+ "verbose|v!" => \our $DEBUG,
+) or HelpMessage(-exitval => 2);
+
my %area = (
fieldxmin => 45,
fieldxmax => 1590,
my %area = (
fieldxmin => 45,
fieldxmax => 1590,