diff options
author | Yorhel <git@yorhel.nl> | 2019-09-11 16:11:32 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2019-09-11 16:11:32 +0200 |
commit | 500d19bd7c5c2c3e6a73b8b5ae0aa5ab39182df7 (patch) | |
tree | 6e3b345e46cfb92748d0061a62f7ee61889e7836 /lib | |
parent | 7eca65c37be71d9c677cc99153e0df75902ed8cb (diff) |
VNDB::Types: Convert platforms into %PLATFORM
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Multi/API.pm | 2 | ||||
-rw-r--r-- | lib/VN3/ElmGen.pm | 2 | ||||
-rw-r--r-- | lib/VN3/Release/Page.pm | 2 | ||||
-rw-r--r-- | lib/VN3/Types.pm | 47 | ||||
-rw-r--r-- | lib/VN3/Validation.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/Handler/Misc.pm | 4 | ||||
-rw-r--r-- | lib/VNDB/Handler/Producers.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/Handler/Releases.pm | 18 | ||||
-rw-r--r-- | lib/VNDB/Handler/VNBrowse.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/Handler/VNPage.pm | 10 | ||||
-rw-r--r-- | lib/VNDB/Types.pm | 43 | ||||
-rw-r--r-- | lib/VNDB/Util/BrowseHTML.pm | 2 |
12 files changed, 69 insertions, 67 deletions
diff --git a/lib/Multi/API.pm b/lib/Multi/API.pm index 2665ad49..28ed8bc2 100644 --- a/lib/Multi/API.pm +++ b/lib/Multi/API.pm @@ -1196,7 +1196,7 @@ sub get_filters { } elsif(${$o{process}} eq 'lang') { return cerr $c, filter => 'Invalid language code', %e if !$LANGUAGE{$v}; } elsif(${$o{process}} eq 'plat') { - return cerr $c, filter => 'Invalid platform code', %e if !$VNDB::S{platforms}{$v}; + return cerr $c, filter => 'Invalid platform code', %e if !$PLATFORM{$v}; } } diff --git a/lib/VN3/ElmGen.pm b/lib/VN3/ElmGen.pm index 743bb1d7..e28e2ff6 100644 --- a/lib/VN3/ElmGen.pm +++ b/lib/VN3/ElmGen.pm @@ -171,7 +171,7 @@ def vnRelations => 'List (String, String)' => list map tuple(string $_, st def producerRelations => 'List (String, String)' => list map tuple(string $_, string producer_relation_display $_), keys %PRODUCER_RELATIONS; def creditType => 'List (String, String)' => list map tuple(string $_, string $CREDIT_TYPE{$_}), keys %CREDIT_TYPE; def languages => 'List (String, String)' => list map tuple(string $_, string $LANGUAGE{$_}), sort { $LANGUAGE{$a} cmp $LANGUAGE{$b} } keys %LANGUAGE; -def platforms => 'List (String, String)' => list map tuple(string $_, string $PLATFORMS{$_}), keys %PLATFORMS; +def platforms => 'List (String, String)' => list map tuple(string $_, string $PLATFORM{$_}), keys %PLATFORM; def releaseTypes => 'List String' => list map string($_), release_types; def producerTypes => 'List (String, String)' => list map tuple(string $_, string $PRODUCER_TYPES{$_}), keys %PRODUCER_TYPES; def minAges => 'List (Int, String)' => list map tuple($_, string minage_display_full $_), @MINAGE; diff --git a/lib/VN3/Release/Page.pm b/lib/VN3/Release/Page.pm index 7563de90..81193183 100644 --- a/lib/VN3/Release/Page.pm +++ b/lib/VN3/Release/Page.pm @@ -77,7 +77,7 @@ sub DetailsTable { Dd sub { Join \&Br, sub { Platform $_[0]{platform}; - Txt " $PLATFORMS{$_[0]{platform}}"; + Txt " $PLATFORM{$_[0]{platform}}"; }, @{$e->{platforms}}; } } : (), diff --git a/lib/VN3/Types.pm b/lib/VN3/Types.pm index 947ee403..d049f49b 100644 --- a/lib/VN3/Types.pm +++ b/lib/VN3/Types.pm @@ -9,12 +9,13 @@ use Tie::IxHash; use TUWF ':Html5'; use POSIX 'strftime', 'ceil'; use Exporter 'import'; +use VNDB::Types; our @EXPORT = qw/ $UID_RE $VID_RE $RID_RE $SID_RE $CID_RE $PID_RE $IID_RE $DOC_RE $VREV_RE $RREV_RE $PREV_RE $SREV_RE $CREV_RE $DREV_RE Lang - %PLATFORMS Platform + Platform %MEDIA media_display %PRODUCER_TYPES ReleaseDate @@ -60,51 +61,9 @@ sub Lang { -# The 'unk' platform is reserved for "unknown" in release filters. -our %PLATFORMS; -tie %PLATFORMS, 'Tie::IxHash', grep !/^ *$/, split /[\s\r\n]*([^ ]+) +(.+)/, q{ - win Windows - dos DOS - lin Linux - mac Mac OS - ios Apple iProduct - and Android - dvd DVD Player - bdp Blu-ray Player - fmt FM Towns - gba Game Boy Advance - gbc Game Boy Color - msx MSX - nds Nintendo DS - nes Famicom - p88 PC-88 - p98 PC-98 - pce PC Engine - pcf PC-FX - psp PlayStation Portable - ps1 PlayStation 1 - ps2 PlayStation 2 - ps3 PlayStation 3 - ps4 PlayStation 4 - psv PlayStation Vita - drc Dreamcast - sat Sega Saturn - sfc Super Nintendo - swi Nintendo Switch - wii Nintendo Wii - wiu Nintendo Wii U - n3d Nintendo 3DS - x68 X68000 - xb1 Xbox - xb3 Xbox 360 - xbo Xbox One - web Website - oth Other -}; - sub Platform { # TODO: Icons - Img class => 'svg-icon', src => tuwf->conf->{url_static}.'/v3/windows.svg', title => $PLATFORMS{$_[0]}; + Img class => 'svg-icon', src => tuwf->conf->{url_static}.'/v3/windows.svg', title => $PLATFORM{$_[0]}; } diff --git a/lib/VN3/Validation.pm b/lib/VN3/Validation.pm index 20c33e57..405452ff 100644 --- a/lib/VN3/Validation.pm +++ b/lib/VN3/Validation.pm @@ -29,7 +29,7 @@ TUWF::set custom_validations => { staff_role => { enum => \%CREDIT_TYPE }, char_role => { enum => \%CHAR_ROLES }, language => { enum => \%LANGUAGE }, - platform => { enum => \%PLATFORMS }, + platform => { enum => \%PLATFORM }, medium => { enum => \%MEDIA }, resolution => { enum => \%RESOLUTIONS }, gender => { enum => \%GENDERS }, diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm index 366b9429..0e77408d 100644 --- a/lib/VNDB/Handler/Misc.pm +++ b/lib/VNDB/Handler/Misc.pm @@ -158,7 +158,7 @@ sub homepage { li; lit fmtdatestr $_->{released}; txt ' '; - cssicon $_, $self->{platforms}{$_} for (@{$_->{platforms}}); + cssicon $_, $PLATFORM{$_} for (@{$_->{platforms}}); cssicon "lang $_", $LANGUAGE{$_} for (@{$_->{languages}}); txt ' '; a href => "/r$_->{id}", title => $_->{original}||$_->{title}, shorten $_->{title}, 30; @@ -178,7 +178,7 @@ sub homepage { li; lit fmtdatestr $_->{released}; txt ' '; - cssicon $_, $self->{platforms}{$_} for (@{$_->{platforms}}); + cssicon $_, $PLATFORM{$_} for (@{$_->{platforms}}); cssicon "lang $_", $LANGUAGE{$_} for (@{$_->{languages}}); txt ' '; a href => "/r$_->{id}", title => $_->{original}||$_->{title}, shorten $_->{title}, 30; diff --git a/lib/VNDB/Handler/Producers.pm b/lib/VNDB/Handler/Producers.pm index cb5ce4cc..db3f3a3d 100644 --- a/lib/VNDB/Handler/Producers.pm +++ b/lib/VNDB/Handler/Producers.pm @@ -175,7 +175,7 @@ sub _releases { td class => 'tc3'; for (sort @{$rel->{platforms}}) { next if $_ eq 'oth'; - cssicon $_, $self->{platforms}{$_}; + cssicon $_, $PLATFORM{$_}; } cssicon "lang $_", $LANGUAGE{$_} for (@{$rel->{languages}}); cssicon "rt$rel->{type}", $rel->{type}; diff --git a/lib/VNDB/Handler/Releases.pm b/lib/VNDB/Handler/Releases.pm index b3ef3014..ed9d4627 100644 --- a/lib/VNDB/Handler/Releases.pm +++ b/lib/VNDB/Handler/Releases.pm @@ -83,7 +83,7 @@ sub page { [ released => 'Release date', htmlize => \&fmtdatestr ], [ minage => 'Age rating', serialize => \&minage ], [ notes => 'Notes', diff => qr/[ ,\n\.]/ ], - [ platforms => 'Platforms', join => ', ', split => sub { map $self->{platforms}{$_}, @{$_[0]} } ], + [ 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]] } ], @@ -173,8 +173,8 @@ sub _infotable { td 'Platform'.(@{$r->{platforms}} == 1 ? '' : 's'); td; for(@{$r->{platforms}}) { - cssicon $_, $self->{platforms}{$_}; - txt ' '.$self->{platforms}{$_}; + cssicon $_, $PLATFORM{$_}; + txt ' '.$PLATFORM{$_}; br if $_ ne $r->{platforms}[$#{$r->{platforms}}]; } end; @@ -383,7 +383,7 @@ sub edit { { post => 'released', required => 0, default => 0, template => 'rdate' }, { post => 'minage' , required => 0, default => -1, enum => $self->{age_ratings} }, { post => 'notes', required => 0, default => '', maxlength => 10240 }, - { post => 'platforms', required => 0, default => '', multi => 1, enum => [ keys %{$self->{platforms}} ] }, + { 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}} ] }, @@ -547,13 +547,13 @@ sub _form { [ static => nolabel => 1, content => sub { h2 'Platforms'; div class => 'platforms'; - for my $p (sort keys %{$self->{platforms}}) { + for my $p (sort keys %PLATFORM) { span; input type => 'checkbox', name => 'platforms', value => $p, id => $p, $frm->{platforms} && grep($_ eq $p, @{$frm->{platforms}}) ? (checked => 'checked') : (); label for => $p; - cssicon $p, $self->{platforms}{$p}; - txt ' '.$self->{platforms}{$p};; + cssicon $p, $PLATFORM{$p}; + txt ' '.$PLATFORM{$p};; end; end; } @@ -679,7 +679,7 @@ sub browse { end; td class => 'tc2', $l->{minage} < 0 ? '' : minage $l->{minage}; td class => 'tc3'; - $_ ne 'oth' && cssicon $_, $self->{platforms}{$_} for (@{$l->{platforms}}); + $_ ne 'oth' && cssicon $_, $PLATFORM{$_} for (@{$l->{platforms}}); cssicon "lang $_", $LANGUAGE{$_} for (@{$l->{languages}}); cssicon "rt$l->{type}", $l->{type}; end; @@ -714,7 +714,7 @@ sub _fil_compat { my %c; my $f = $self->formValidate( { get => 'ln', required => 0, multi => 1, default => '', enum => [ keys %LANGUAGE ] }, - { get => 'pl', required => 0, multi => 1, default => '', enum => [ keys %{$self->{platforms}} ] }, + { get => 'pl', required => 0, multi => 1, default => '', enum => [ keys %PLATFORM ] }, { get => 'me', required => 0, multi => 1, default => '', enum => [ keys %{$self->{media}} ] }, { get => 'tp', required => 0, default => '', enum => [ '', @{$self->{release_types}} ] }, { get => 'pa', required => 0, default => 0, enum => [ 0..2 ] }, diff --git a/lib/VNDB/Handler/VNBrowse.pm b/lib/VNDB/Handler/VNBrowse.pm index 2049e455..b3ec9dc6 100644 --- a/lib/VNDB/Handler/VNBrowse.pm +++ b/lib/VNDB/Handler/VNBrowse.pm @@ -133,7 +133,7 @@ sub _fil_compat { my %c; my $f = $self->formValidate( { get => 'ln', required => 0, multi => 1, enum => [ keys %LANGUAGE ], default => '' }, - { get => 'pl', required => 0, multi => 1, enum => [ keys %{$self->{platforms}} ], default => '' }, + { get => 'pl', required => 0, multi => 1, enum => [ keys %PLATFORM ], default => '' }, { get => 'sp', required => 0, default => ($self->reqCookie('tagspoil')||'') =~ /^([0-2])$/ ? $1 : 0, enum => [0..2] }, ); return () if $f->{_err}; diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm index 6a438341..347d65bc 100644 --- a/lib/VNDB/Handler/VNPage.pm +++ b/lib/VNDB/Handler/VNPage.pm @@ -99,7 +99,7 @@ my @rel_cols = ( has_data => sub { !!@{$_[0]{platforms}} }, draw => sub { for(@{$_[0]{platforms}}) { - cssicon $_, $TUWF::OBJ->{platforms}{$_}; + cssicon $_, $PLATFORM{$_}; br if $_ ne $_[0]{platforms}[$#{$_[0]{platforms}}]; } txt 'Unknown' if !@{$_[0]{platforms}}; @@ -198,7 +198,7 @@ sub releases { { get => 'cw', required => 0, default => 0, enum => [0,1] }, { get => 'o', required => 0, default => 0, enum => [0,1] }, { get => 's', required => 0, default => 'released', enum => [ map $_->{sort_field}, grep $_->{sort_field}, @rel_cols ]}, - { get => 'os', required => 0, default => 'all', enum => [ 'all', keys %{$self->{platforms}} ] }, + { get => 'os', required => 0, default => 'all', enum => [ 'all', keys %PLATFORM ] }, { get => 'lang', required => 0, default => 'all', enum => [ 'all', keys %LANGUAGE ] }, ); return $self->resNotFound if $f->{_err}; @@ -260,7 +260,7 @@ sub _releases_buttons { } end 'p'; }; - $plat_lang_draw->('platforms', 'os', $self->{platforms}, '') if $f->{pla}; + $plat_lang_draw->('platforms', 'os', \%PLATFORM, '') if $f->{pla}; $plat_lang_draw->('languages', 'lang',\%LANGUAGE, 'lang') if $f->{lan}; } @@ -818,7 +818,7 @@ sub _releases { td class => 'tc3'; for (sort @{$rel->{platforms}}) { next if $_ eq 'oth'; - cssicon $_, $self->{platforms}{$_}; + cssicon $_, $PLATFORM{$_}; } cssicon "rt$rel->{type}", $rel->{type}; end; @@ -928,7 +928,7 @@ sub _screenshots { next if !@scr; p class => 'rel'; cssicon "lang $_", $LANGUAGE{$_} for (@{$rel->{languages}}); - cssicon $_, $TUWF::OBJ->{platforms}{$_} for (@{$rel->{platforms}}); + cssicon $_, $PLATFORM{$_} for (@{$rel->{platforms}}); a href => "/r$rel->{id}", $rel->{title}; end; div class => 'scr'; diff --git a/lib/VNDB/Types.pm b/lib/VNDB/Types.pm index ee929063..70204989 100644 --- a/lib/VNDB/Types.pm +++ b/lib/VNDB/Types.pm @@ -61,6 +61,49 @@ hash LANGUAGE => +# SQL: ENUM platform +# The 'unk' platform is used to mean "Unknown" in various places (not in the DB). +hash PLATFORM => + win => 'Windows', + dos => 'DOS', + lin => 'Linux', + mac => 'Mac OS', + ios => 'Apple iProduct', + and => 'Android', + dvd => 'DVD Player', + bdp => 'Blu-ray Player', + fmt => 'FM Towns', + gba => 'Game Boy Advance', + gbc => 'Game Boy Color', + msx => 'MSX', + nds => 'Nintendo DS', + nes => 'Famicom', + p88 => 'PC-88', + p98 => 'PC-98', + pce => 'PC Engine', + pcf => 'PC-FX', + psp => 'PlayStation Portable', + ps1 => 'PlayStation 1', + ps2 => 'PlayStation 2', + ps3 => 'PlayStation 3', + ps4 => 'PlayStation 4', + psv => 'PlayStation Vita', + drc => 'Dreamcast', + sat => 'Sega Saturn', + sfc => 'Super Nintendo', + swi => 'Nintendo Switch', + wii => 'Nintendo Wii', + wiu => 'Nintendo Wii U', + n3d => 'Nintendo 3DS', + x68 => 'X68000', + xb1 => 'Xbox', + xb3 => 'Xbox 360', + xbo => 'Xbox One', + web => 'Website', + oth => 'Other'; + + + # SQL: ENUM credit_type hash CREDIT_TYPE => scenario => 'Scenario', diff --git a/lib/VNDB/Util/BrowseHTML.pm b/lib/VNDB/Util/BrowseHTML.pm index 749f69f8..ee2dbbf1 100644 --- a/lib/VNDB/Util/BrowseHTML.pm +++ b/lib/VNDB/Util/BrowseHTML.pm @@ -199,7 +199,7 @@ sub htmlBrowseVN { } td class => 'tc8', defined($l->{wstat}) ? $self->{wishlist_status}[$l->{wstat}] : '' if $f->{wish}; td class => 'tc2'; - $_ ne 'oth' && cssicon $_, $self->{platforms}{$_} + $_ ne 'oth' && cssicon $_, $PLATFORM{$_} for (sort @{$l->{c_platforms}}); end; td class => 'tc3'; |