palpic2png.c: improve, make usable with ppic binary files
[rofl0r-openDOW.git] / utils / mapconv.pl
blob9bf242a44cb914077df6d1cb1a9f41b868c18bf2
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
5 print "\t.screens = {\n";
6 my $i = 0;
7 my $bonus_active = 0;
8 my %bonus;
9 my $bonus_num = 0;
10 while(<>) {
11 if(/^A/) {
12 $bonus_active = 0;
13 print "\t\t\t}},\n\t\t},\n" if($i);
14 print "\t\t[$i] = {\n\t\t\t.bg = {{\n";
15 $i++;
16 next;
18 if(/^B/) {
19 $bonus_active = 0;
20 print "\t\t\t}},\n\t\t\t.fg = {{\n";
21 next;
23 if(/^C/) {
24 $bonus_active = 1;
25 $bonus_num = $i - 1;
26 next;
28 $bonus_active = 0, next if(/^</ || /^>/);
29 if($bonus_active) {
30 $bonus{$i - 1} = defined($bonus{$i - 1}) ? $bonus{$i - 1} . $_ : $_;
31 next;
33 chomp;
34 next if($_ eq "");
35 print "\t\t\t\t{$_},\n";
37 print "\t\t\t}},\n\t\t},\n\t},\n";
38 for(sort {$a<=>$b} keys(%bonus)) {
39 print("bonus for $_\n");
40 my @lines = split /\n/, $bonus{$_};
41 print "{$_},\n" for(@lines);