You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.7 KiB
57 lines
1.7 KiB
6 years ago
|
package Subtitle::Format::SSA::Event;
|
||
9 years ago
|
|
||
|
use strict;
|
||
|
use warnings;
|
||
|
use utf8;
|
||
|
|
||
6 years ago
|
use base 'Subtitle::Format::SSA::Record';
|
||
9 years ago
|
|
||
|
my @FIELDS_SSA = qw(marked start end style name marginl marginr marginv effect text);
|
||
|
my @FIELDS_ASS = qw(layer start end style name marginl marginr marginv effect text);
|
||
|
|
||
|
# see parse() description for available type's
|
||
|
my %FIELDS = (
|
||
|
marked => { type => 's', value => 'Marked=0', name => 'Marked' },
|
||
|
layer => { type => 'd', value => 0, name => 'Layer' },
|
||
|
start => { type => 't', value => 0, name => 'Start' },
|
||
|
end => { type => 't', value => 0, name => 'End' },
|
||
|
style => { type => 's', value => 'Default', name => 'Style' },
|
||
|
name => { type => 's', value => '', name => 'Name' },
|
||
8 years ago
|
marginl => { type => 'z', value => 0, name => 'MarginL' },
|
||
|
marginr => { type => 'z', value => 0, name => 'MarginR' },
|
||
|
marginv => { type => 'z', value => 0, name => 'MarginV' },
|
||
9 years ago
|
effect => { type => 's', value => '', name => 'Effect' },
|
||
|
text => { type => 's', value => '', name => 'Text' },
|
||
|
);
|
||
8 years ago
|
|
||
|
# options:
|
||
8 years ago
|
# * type - 'ssa' for v4 or 'ass' for v4+
|
||
8 years ago
|
sub new {
|
||
|
my ($class, %opts) = @_;
|
||
|
my $self = {
|
||
8 years ago
|
_type => 'ass',
|
||
8 years ago
|
_fields => \%FIELDS,
|
||
|
_format => \@FIELDS_ASS,
|
||
6 years ago
|
_prefix => qr/(Dialogue|Comment|Picture|Sound|Movie|Command)/,
|
||
8 years ago
|
};
|
||
|
|
||
8 years ago
|
if (my $t = $opts{type}) {
|
||
|
if ($t =~ m{^(ass|ssa)$}oi) {
|
||
|
$self->{_type} = lc($t);
|
||
8 years ago
|
} else {
|
||
8 years ago
|
die("unsupported event type $t");
|
||
8 years ago
|
}
|
||
|
}
|
||
|
|
||
|
$self->{_format} = \@FIELDS_SSA
|
||
8 years ago
|
if $self->{_type} eq 'ssa';
|
||
8 years ago
|
|
||
8 years ago
|
my @fields = @{ $self->{_format} };
|
||
8 years ago
|
$self->{$_} = $FIELDS{$_}->{value}
|
||
|
foreach @fields;
|
||
|
|
||
|
return bless($self, $class);
|
||
|
}
|
||
9 years ago
|
|
||
|
1;
|