summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-09-12 11:35:00 +0200
committerYorhel <git@yorhel.nl>2019-09-12 11:35:00 +0200
commit5a62f120bad71b81068fd1d50035effc0fda688c (patch)
tree9b5b6c183b97fce68a52e1f7178f6140f9989f08
parentf6851137f4a6f1f9feba51ec5473e743d64a58b2 (diff)
VNDB::Types: Convert animated & voiced
-rw-r--r--data/global.pl5
-rw-r--r--elm3/RelEdit/General.elm6
-rw-r--r--lib/VN3/ElmGen.pm4
-rw-r--r--lib/VN3/Release/Page.pm6
-rw-r--r--lib/VN3/Types.pm9
-rw-r--r--lib/VN3/Validation.pm4
-rw-r--r--lib/VNDB/Handler/Releases.pm24
-rw-r--r--lib/VNDB/Handler/VNPage.pm12
-rw-r--r--lib/VNDB/Types.pm20
-rwxr-xr-xutil/jsgen.pl4
10 files changed, 49 insertions, 45 deletions
diff --git a/data/global.pl b/data/global.pl
index 311789d0..aa2bfb10 100644
--- a/data/global.pl
+++ b/data/global.pl
@@ -85,11 +85,6 @@ our %S;
'1600x900' => [ '1600x900', 'widescreen' ],
'1920x1080' => [ '1920x1080', 'widescreen' ],
),
- animated => [ 'Unknown', 'No animations', 'Simple animations', 'Some fully animated scenes', 'All scenes fully animated' ],
- icons_story_animated => [ 'unknown', 'story_not_animated', 'story_simple_animated', 'story_some_fully_animated', 'story_all_fully_animated' ],
- icons_ero_animated => [ 'unknown', 'ero_not_animated', 'ero_simple_animated', 'ero_some_fully_animated', 'ero_all_fully_animated' ],
- voiced => [ 'Unknown', 'Not voiced', 'Only ero scenes voiced', 'Partially voiced', 'Fully voiced' ],
- icons_voiced => [ 'unknown', 'not_voiced', 'ero_voiced', 'partially_voiced', 'fully_voiced' ],
atom_feeds => { # num_entries, title, id
announcements => [ 10, 'VNDB Site Announcements', '/t/an' ],
changes => [ 25, 'VNDB Recent Changes', '/hist' ],
diff --git a/elm3/RelEdit/General.elm b/elm3/RelEdit/General.elm
index 17a510bb..698c9f99 100644
--- a/elm3/RelEdit/General.elm
+++ b/elm3/RelEdit/General.elm
@@ -223,13 +223,13 @@ format model = card "format" "Format" [] <|
, inputSelect [id "resolution", onInput Resolution] model.resolution resolutions
]
, [ label [for "voiced"] [text "Voiced"]
- , inputSelect [id "voiced", onInput Voiced] (String.fromInt model.voiced) <| List.indexedMap (\a b -> (String.fromInt a, b)) voiced
+ , inputSelect [id "voiced", onInput Voiced] (String.fromInt model.voiced) <| List.map (\(a,b) -> (String.fromInt a, b)) voiced
]
, [ label [for "ani_story"] [text "Story animation"]
- , inputSelect [id "ani_story", onInput AniStory] (String.fromInt model.aniStory) <| List.indexedMap (\a b -> (String.fromInt a, b)) animated
+ , inputSelect [id "ani_story", onInput AniStory] (String.fromInt model.aniStory) <| List.map (\(a,b) -> (String.fromInt a, b)) animated
]
, [ label [for "ani_ero"] [text "Ere scene animation"]
- , inputSelect [id "ani_ero", onInput AniEro] (String.fromInt model.aniEro) <| List.indexedMap (\a b -> (String.fromInt a, if a == 0 then "Unknown / no ero scenes" else b)) animated
+ , inputSelect [id "ani_ero", onInput AniEro] (String.fromInt model.aniEro) <| List.map (\(a,b) -> (String.fromInt a, if a == 0 then "Unknown / no ero scenes" else b)) animated
]
]
]) ++
diff --git a/lib/VN3/ElmGen.pm b/lib/VN3/ElmGen.pm
index 3e3f9faf..3e18d70d 100644
--- a/lib/VN3/ElmGen.pm
+++ b/lib/VN3/ElmGen.pm
@@ -176,8 +176,8 @@ def releaseTypes => 'List String' => list map string($_), release
def producerTypes => 'List (String, String)' => list map tuple(string $_, string $PRODUCER_TYPE{$_}), keys %PRODUCER_TYPE;
def minAges => 'List (Int, String)' => list map tuple($_, string minage_display_full $_), @MINAGE;
def resolutions => 'List (String, String)' => list map tuple(string $_, string resolution_display_full $_), keys %RESOLUTIONS;
-def voiced => 'List String' => list map string($_), @VOICED;
-def animated => 'List String' => list map string($_), @ANIMATED;
+def voiced => 'List (Int, String)' => list map tuple($_, string($VOICED{$_})), keys %VOICED;
+def animated => 'List (Int, String)' => list map tuple($_, string($ANIMATED{$_})), keys %ANIMATED;
def genders => 'List (String, String)' => list map tuple(string $_, string gender_display $_), keys %GENDER;
def bloodTypes => 'List (String, String)' => list map tuple(string $_, string blood_type_display $_), keys %BLOOD_TYPE;
def charRoles => 'List (String, String)' => list map tuple(string $_, string char_role_display $_), keys %CHAR_ROLE;
diff --git a/lib/VN3/Release/Page.pm b/lib/VN3/Release/Page.pm
index 81193183..03d3bd5c 100644
--- a/lib/VN3/Release/Page.pm
+++ b/lib/VN3/Release/Page.pm
@@ -89,17 +89,17 @@ sub DetailsTable {
$e->{voiced} ? sub {
Dt 'Voiced';
- Dd $VOICED[$e->{voiced}];
+ Dd $VOICED{$e->{voiced}}{txt};
} : (),
$e->{ani_story} ? sub {
Dt 'Story animation';
- Dd $ANIMATED[$e->{ani_story}];
+ Dd $ANIMATED{$e->{ani_story}}{txt};
} : (),
$e->{ani_ero} ? sub {
Dt 'Ero animation';
- Dd $ANIMATED[$e->{ani_ero}];
+ Dd $ANIMATED{$e->{ani_ero}}{txt};
} : (),
$e->{minage} && $e->{minage} == 18 ? sub {
diff --git a/lib/VN3/Types.pm b/lib/VN3/Types.pm
index fa53ea73..a36cc6dd 100644
--- a/lib/VN3/Types.pm
+++ b/lib/VN3/Types.pm
@@ -28,8 +28,6 @@ our @EXPORT = qw/
release_types
@MINAGE minage_display minage_display_full
%RESOLUTIONS resolution_display_full
- @VOICED
- @ANIMATED
gender_display gender_icon
blood_type_display
/;
@@ -228,13 +226,6 @@ tie %RESOLUTIONS, 'Tie::IxHash',
sub resolution_display_full { my $e = $RESOLUTIONS{$_[0]}; ($e->[1] ? ucfirst "$e->[1]: " : '').$e->[0] }
-
-our @VOICED = ('Unknown', 'Not voiced', 'Only ero scenes voiced', 'Partially voiced', 'Fully voiced');
-
-our @ANIMATED = ('Unknown', 'No animations', 'Simple animations', 'Some fully animated scenes', 'All scenes fully animated');
-
-
-
sub gender_display { $GENDER{$_[0]} }
sub gender_icon { +{qw/m ♂ f ♀ mf ♂♀/}->{$_[0]}||'' }
diff --git a/lib/VN3/Validation.pm b/lib/VN3/Validation.pm
index 5c1c73d7..0ec83514 100644
--- a/lib/VN3/Validation.pm
+++ b/lib/VN3/Validation.pm
@@ -36,8 +36,8 @@ TUWF::set custom_validations => {
blood_type => { enum => \%BLOOD_TYPE },
gtin => { uint => 1, func => sub { $_[0] eq 0 || gtintype($_[0]) } },
minage => { uint => 1, enum => \@MINAGE },
- animated => { uint => 1, range => [ 0, $#ANIMATED ] },
- voiced => { uint => 1, range => [ 0, $#VOICED ] },
+ animated => { uint => 1, enum => \%ANIMATED },
+ voiced => { uint => 1, enum => \%VOICED },
rdate => { uint => 1, func => \&_validate_rdate },
spoiler => { uint => 1, range => [ 0, 2 ] },
vnlist_status=>{ enum => \%VNLIST_STATUS },
diff --git a/lib/VNDB/Handler/Releases.pm b/lib/VNDB/Handler/Releases.pm
index ff687dec..da1c1554 100644
--- a/lib/VNDB/Handler/Releases.pm
+++ b/lib/VNDB/Handler/Releases.pm
@@ -86,9 +86,9 @@ sub page {
[ platforms => 'Platforms', join => ', ', split => sub { map $PLATFORM{$_}, @{$_[0]} } ],
[ media => 'Media', join => ', ', split => sub { map fmtmedia($_->{medium}, $_->{qty}), @{$_[0]} } ],
[ resolution => 'Resolution', serialize => sub { $self->{resolutions}{$_[0]}[0]; } ],
- [ voiced => 'Voiced', serialize => sub { $self->{voiced}[$_[0]] } ],
- [ ani_story => 'Story animation', serialize => sub { $self->{animated}[$_[0]] } ],
- [ ani_ero => 'Ero animation', serialize => sub { $self->{animated}[$_[0]] } ],
+ [ voiced => 'Voiced', serialize => sub { $VOICED{$_[0]}{txt} } ],
+ [ ani_story => 'Story animation', serialize => sub { $ANIMATED{$_[0]}{txt} } ],
+ [ ani_ero => 'Ero animation', serialize => sub { $ANIMATED{$_[0]}{txt} } ],
[ engine => 'Engine' ],
[ producers => 'Producers', join => '<br />', split => sub {
map sprintf('<a href="/p%d" title="%s">%s</a> (%s)', $_->{id}, $_->{original}||$_->{name}, shorten($_->{name}, 50),
@@ -198,7 +198,7 @@ sub _infotable {
if($r->{voiced}) {
Tr;
td 'Voiced';
- td $self->{voiced}[$r->{voiced}];
+ td $VOICED{$r->{voiced}}{txt};
end;
}
@@ -206,8 +206,8 @@ sub _infotable {
Tr;
td 'Animation';
td join ', ',
- $r->{ani_story} ? "Story: $self->{animated}[$r->{ani_story}]" : (),
- $r->{ani_ero} ? "Ero scenes: $self->{animated}[$r->{ani_ero}]" : ();
+ $r->{ani_story} ? "Story: $ANIMATED{$r->{ani_story}}{txt}" : (),
+ $r->{ani_ero} ? "Ero scenes: $ANIMATED{$r->{ani_ero}}{txt}" : ();
end;
}
@@ -386,9 +386,9 @@ sub edit {
{ post => 'platforms', required => 0, default => '', multi => 1, enum => [ keys %PLATFORM ] },
{ post => 'media', required => 0, default => '' },
{ post => 'resolution',required => 0, default => 0, enum => [ keys %{$self->{resolutions}} ] },
- { post => 'voiced', required => 0, default => 0, enum => [ 0..$#{$self->{voiced}} ] },
- { post => 'ani_story', required => 0, default => 0, enum => [ 0..$#{$self->{animated}} ] },
- { post => 'ani_ero', required => 0, default => 0, enum => [ 0..$#{$self->{animated}} ] },
+ { post => 'voiced', required => 0, default => 0, enum => [ keys %VOICED ] },
+ { post => 'ani_story', required => 0, default => 0, enum => [ keys %ANIMATED ] },
+ { post => 'ani_ero', required => 0, default => 0, enum => [ keys %ANIMATED ] },
{ post => 'engine', required => 0, default => '', maxlength => 50 },
{ post => 'engine_oth',required => 0, default => '', maxlength => 50 },
{ post => 'producers', required => 0, default => '' },
@@ -537,11 +537,11 @@ sub _form {
} ],
[ static => content => 'Try to use a name from the <a href="/r/engines">engine list</a>.' ],
[ select => short => 'voiced', name => 'Voiced', options => [
- map [ $_, $self->{voiced}[$_] ], 0..$#{$self->{voiced}} ] ],
+ map [ $_, $VOICED{$_}{txt} ], keys %VOICED ] ],
[ select => short => 'ani_story', name => 'Story animation', options => [
- map [ $_, $self->{animated}[$_] ], 0..$#{$self->{animated}} ] ],
+ map [ $_, $ANIMATED{$_}{txt} ], keys %ANIMATED ] ],
[ select => short => 'ani_ero', name => 'Ero animation', options => [
- map [ $_, $_ ? $self->{animated}[$_] : 'Unknown / no ero scenes' ], 0..$#{$self->{animated}} ] ],
+ map [ $_, $_ ? $ANIMATED{$_}{txt} : 'Unknown / no ero scenes' ], keys %ANIMATED ] ],
[ static => content => 'Animation in erotic scenes, leave to unknown if there are no ero scenes.' ],
[ hidden => short => 'media' ],
[ static => nolabel => 1, content => sub {
diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm
index a7988df8..01c14bce 100644
--- a/lib/VNDB/Handler/VNPage.pm
+++ b/lib/VNDB/Handler/VNPage.pm
@@ -139,7 +139,7 @@ my @rel_cols = (
default => 1,
what => 'extended',
has_data => sub { !!$_[0]{voiced} },
- draw => sub { txt $TUWF::OBJ->{voiced}[$_[0]{voiced}] },
+ draw => sub { txt $VOICED{$_[0]{voiced}}{txt} },
}, { # Animation
id => 'ani',
sort_field => 'ani_ero',
@@ -151,8 +151,8 @@ my @rel_cols = (
has_data => sub { !!($_[0]{ani_story} || $_[0]{ani_ero}) },
draw => sub {
txt join ', ',
- $_[0]{ani_story} ? "Story: $TUWF::OBJ->{animated}[$_[0]{ani_story}]" :(),
- $_[0]{ani_ero} ? "Ero scenes: $TUWF::OBJ->{animated}[$_[0]{ani_ero}]":();
+ $_[0]{ani_story} ? "Story: $ANIMATED{$_[0]{ani_story}}{txt}" :(),
+ $_[0]{ani_ero} ? "Ero scenes: $ANIMATED{$_[0]{ani_ero}}{txt}":();
txt 'Unknown' if !$_[0]{ani_story} && !$_[0]{ani_ero};
},
}, { # Released
@@ -863,14 +863,14 @@ sub _release_icons {
# Voice column
my $voice = $rel->{voiced};
- _release_icon $self->{icons_voiced}[$voice], $self->{voiced}[$voice], 'voiced' if $voice;
+ _release_icon $VOICED{$voice}{icon}, $VOICED{$voice}{txt}, 'voiced' if $voice;
# Animations columns
my $story_anim = $rel->{ani_story};
- _release_icon $self->{icons_story_animated}[$story_anim], "Story: $self->{animated}[$story_anim]", 'story_animated' if $story_anim;
+ _release_icon $ANIMATED{$story_anim}{story_icon}, "Story: $ANIMATED{$story_anim}{txt}", 'story_animated' if $story_anim;
my $ero_anim = $rel->{ani_ero};
- _release_icon $self->{icons_ero_animated}[$ero_anim], "Ero: $self->{animated}[$ero_anim]", 'ero_animated' if $ero_anim;
+ _release_icon $ANIMATED{$ero_anim}{ero_icon}, "Ero: $ANIMATED{$ero_anim}{txt}", 'ero_animated' if $ero_anim;
# Cost column
_release_icon 'freeware', 'Freeware', 'free' if $rel->{freeware};
diff --git a/lib/VNDB/Types.pm b/lib/VNDB/Types.pm
index f101e68d..6a9aae2e 100644
--- a/lib/VNDB/Types.pm
+++ b/lib/VNDB/Types.pm
@@ -188,6 +188,24 @@ hash TAG_CATEGORY =>
+hash ANIMATED =>
+ 0 => { txt => 'Unknown', story_icon => 'unknown', ero_icon => 'unknown' },
+ 1 => { txt => 'No animations', story_icon => 'story_not_animated', ero_icon => 'ero_not_animated' },
+ 2 => { txt => 'Simple animations', story_icon => 'story_simple_animated', ero_icon => 'ero_simple_animated' },
+ 3 => { txt => 'Some fully animated scenes', story_icon => 'story_some_fully_animated', ero_icon => 'ero_some_fully_animated' },
+ 4 => { txt => 'All scenes fully animated', story_icon => 'story_all_fully_animated', ero_icon => 'ero_all_fully_animated' };
+
+
+
+hash VOICED =>
+ 0 => { txt => 'Unknown', icon => 'unknown' },
+ 1 => { txt => 'Not voiced', icon => 'not_voiced' },
+ 2 => { txt => 'Only ero scenes voiced', icon => 'ero_voiced' },
+ 3 => { txt => 'Partially voiced', icon => 'partially_voiced' },
+ 4 => { txt => 'Fully voiced', icon => 'fully_voiced' };
+
+
+
hash WISHLIST_STATUS =>
0 => 'High',
1 => 'Medium',
@@ -229,7 +247,7 @@ hash BLOOD_TYPE =>
b => 'B',
ab => 'AB';
-# SQL: ENUM blood_type
+# SQL: ENUM gender
hash GENDER =>
unknown => 'Unknown or N/A',
m => 'Male',
diff --git a/util/jsgen.pl b/util/jsgen.pl
index 04b4780a..5cf946fa 100755
--- a/util/jsgen.pl
+++ b/util/jsgen.pl
@@ -44,8 +44,8 @@ sub vars {
char_roles => [ map [ $_, $CHAR_ROLE{$_}{txt} ], keys %CHAR_ROLE ],
media => [ map [ $_, $S{media}{$_}[1], $S{media}{$_}[0] ], keys %{$S{media}} ],
release_types => [ map [ $_, ucfirst $_ ], @{$S{release_types}} ],
- animated => [ map [ $_, $S{animated}[$_] ], 0..$#{$S{animated}} ],
- voiced => [ map [ $_, $S{voiced}[$_] ], 0..$#{$S{voiced}} ],
+ animated => [ map [ $_, $ANIMATED{$_}{txt} ], keys %ANIMATED ],
+ voiced => [ map [ $_, $VOICED{$_}{txt} ], keys %VOICED ],
vn_lengths => [ map [ $_, $VN_LENGTH{$_}{txt} ], keys %VN_LENGTH ],
blood_types => [ map [ $_, $BLOOD_TYPE{$_} ], keys %BLOOD_TYPE ],
genders => [ map [ $_, $GENDER{$_} ], keys %GENDER ],