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.
56 lines
1.7 KiB
56 lines
1.7 KiB
package Subtitle::SSA::Event; |
|
|
|
use strict; |
|
use warnings; |
|
use utf8; |
|
|
|
use base 'Subtitle::SSA::Record'; |
|
|
|
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' }, |
|
marginl => { type => 's', value => '0000', name => 'MarginL' }, |
|
marginr => { type => 's', value => '0000', name => 'MarginR' }, |
|
marginv => { type => 's', value => '0000', name => 'MarginV' }, |
|
effect => { type => 's', value => '', name => 'Effect' }, |
|
text => { type => 's', value => '', name => 'Text' }, |
|
); |
|
|
|
# options: |
|
# * version - 'ssa' for v4 or 'ass' for v4+ |
|
sub new { |
|
my ($class, %opts) = @_; |
|
my $self = { |
|
_vers => 'ass', |
|
_fields => \%FIELDS, |
|
_format => \@FIELDS_ASS, |
|
_prefix => 'Dialogue', |
|
}; |
|
|
|
if (my $v = $opts{version}) { |
|
if ($v =~ m{^(ass|ssa)$}oi) { |
|
$self->{_vers} = lc($v); |
|
} else { |
|
die("unsupported event version $v"); |
|
} |
|
} |
|
|
|
$self->{_format} = \@FIELDS_SSA |
|
if $self->{_vers} eq 'ssa'; |
|
|
|
my @fields = @{ $self->{_format} }; |
|
$self->{$_} = $FIELDS{$_}->{value} |
|
foreach @fields; |
|
|
|
return bless($self, $class); |
|
} |
|
|
|
1;
|
|
|