forked from PrincessRTFM/XIVComboPlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgencombotable
59 lines (53 loc) · 1.61 KB
/
gencombotable
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env perl
use strict qw/vars subs/;
use warnings;
use IO::File;
use Text::Balanced qw/extract_quotelike/;
sub scanToLine($$) {
my ($file, $regex) = @_;
$regex = qr/\Q$regex/i unless ref $regex;
my $from = $file->getpos;
while (defined(my $line = $file->getline)) {
return $line if $line =~ $regex;
}
$file->setpos($from);
return;
}
my $fileToParse = "XIVComboVX/CustomComboPreset.cs";
my $fileToWrite = "Table.frag";
my $file = IO::File->new($fileToParse, 'r');
defined scanToLine $file, "public enum CustomComboPreset"
or die "Can't find start of combo enums!\n";
my @combos;
while (defined(my $line = scanToLine $file, "[CustomComboInfo(")) {
while ($line =~ m/\+\s*$/) {
$line .= $file->getline;
}
next if $line =~ m{^\s*//};
$line =~ s/"\s*\+\s*"//g;
# $line will be the whole attribute line here
my $orig = $line;
my $name = substr scalar extract_quotelike($line, qr/\s*\[CustomComboInfo\(\s*/i), 1, -1;
my $desc = substr scalar extract_quotelike($line, qr/,\s*/), 1, -1;
next if $name =~ m/^any$/i || $desc =~ m/\bnot(?:\s+be)?\s+display/i;
unless ($name && $desc && $line =~ m/^,\s*(.{3})\.JobID/) {
warn "Can't extract full details from\n$orig\n";
exit 2;
}
my $job = uc $1;
$desc =~ s/\\n.*//;
push @combos, {
job => $job,
name => $name,
desc => $desc,
};
}
$file->close;
$file = IO::File->new($fileToWrite, 'w');
$file->print("| Job | Name | Description |\n");
$file->print("|-----|------|-------------|\n");
$file->print(sprintf qq{| %s | %s | %s |\n}, $_->{job}, $_->{name}, $_->{desc}) for sort {
($a->{job} cmp $b->{job})
|| ($a->{name} cmp $b->{name})
} @combos;
$file->close;