summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2018-01-05 09:34:43 +0100
committerYorhel <git@yorhel.nl>2018-01-05 09:34:43 +0100
commitdc52e2d87a4ba69ab4da15c33371f9fd59db412b (patch)
treed3c73006d7885cb28d85aac6ee5d280a01d86249
parentc42d62b6e360b03cc9abcbb902becba2159e4b41 (diff)
Code style changes to release icons code
These are just style consistency changes, functionally equivalent.
-rw-r--r--data/global.pl38
-rw-r--r--lib/VNDB/Handler/VNPage.pm118
2 files changed, 73 insertions, 83 deletions
diff --git a/data/global.pl b/data/global.pl
index 0c1ba6d6..adb079b9 100644
--- a/data/global.pl
+++ b/data/global.pl
@@ -184,22 +184,22 @@ our %S;
oth Other
}),
media => ordhash(
- #DB qty txt plural (if qty)
- cd => [ 1, 'CD', 'CDs' ],
- dvd => [ 1, 'DVD', 'DVDs' ],
- gdr => [ 1, 'GD-ROM', 'GD-ROMs' ],
- blr => [ 1, 'Blu-ray disc', 'Blu-ray discs' ],
- flp => [ 1, 'Floppy', 'Floppies' ],
- mrt => [ 1, 'Cartridge', 'Cartridges' ],
- mem => [ 1, 'Memory card', 'Memory cards' ],
- umd => [ 1, 'UMD', 'UMDs' ],
- nod => [ 1, 'Nintendo Optical Disc', 'Nintendo Optical Discs' ],
- in => [ 0, 'Internet download', '' ],
- otc => [ 0, 'Other', '' ],
+ #DB qty txt plural (if qty) icon
+ cd => [ 1, 'CD', 'CDs', 'disk' ],
+ dvd => [ 1, 'DVD', 'DVDs', 'disk' ],
+ gdr => [ 1, 'GD-ROM', 'GD-ROMs', 'disk' ],
+ blr => [ 1, 'Blu-ray disc', 'Blu-ray discs', 'disk' ],
+ flp => [ 1, 'Floppy', 'Floppies', 'cartridge'],
+ mrt => [ 1, 'Cartridge', 'Cartridges', 'cartridge'],
+ mem => [ 1, 'Memory card', 'Memory cards', 'cartridge'],
+ umd => [ 1, 'UMD', 'UMDs', 'cartridge'],
+ nod => [ 1, 'Nintendo Optical Disc', 'Nintendo Optical Discs', 'disk' ],
+ in => [ 0, 'Internet download', '', 'download' ],
+ otc => [ 0, 'Other', '', ],
),
resolutions => [
- [ 'Unknown / console / handheld', '' ],
- [ 'Non-standard', '' ],
+ [ 'Unknown / console / handheld', '' ], # hardcoded to 0 in many places
+ [ 'Non-standard', '' ], # hardcoded to 1 in VNPage.pm
[ '640x480', '4:3' ],
[ '800x600', '4:3' ],
[ '1024x768', '4:3' ],
@@ -220,8 +220,11 @@ our %S;
ero => 'Sexual content',
tech => 'Technical',
),
+ 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' ],
- animated => [ 'Unknown', 'No animations', 'Simple animations', 'Some fully animated scenes', 'All scenes fully animated' ],
+ icons_voiced => [ 'unknown', 'not_voiced', 'ero_voiced', 'partially_voiced', 'fully_voiced' ],
wishlist_status => [ 'high', 'medium', 'low', 'blacklist' ],
rlist_status => [ 'Unknown', 'Pending', 'Obtained', 'On loan', 'Deleted' ], # 0 = hardcoded "unknown", 2 = hardcoded 'OK'
vnlist_status => [ 'Unknown', 'Playing', 'Finished', 'Stalled', 'Dropped' ],
@@ -248,11 +251,6 @@ our %S;
staff => 'Staff',
),
poll_options => 20, # max number of options in discussion board polls
-
- # Maps from db codes to icon names
- icons_voiced => [ "unknown", "not_voiced", "ero_voiced", "partially_voiced", "fully_voiced" ],
- 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" ],
);
diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm
index 9e3c0e98..d590c743 100644
--- a/lib/VNDB/Handler/VNPage.pm
+++ b/lib/VNDB/Handler/VNPage.pm
@@ -805,7 +805,7 @@ sub _releases {
end;
td class => 'tc_icons';
- add_release_info_icons($self, $rel);
+ _release_icons($self, $rel);
end;
td class => 'tc5';
@@ -834,6 +834,60 @@ sub _releases {
}
+# Creates an small sized img inside an abbr tag. Used for per-release information icons.
+sub _release_icon {
+ my($class, $title, $img) = @_;
+ abbr class => 'release_icons_container', title => $title;
+ img src=> "/f/$img.svg", class => "release_icons $class", alt => $title;
+ end;
+}
+
+sub _release_icons {
+ my($self, $rel) = @_;
+
+ # Voice column
+ my $voice = $rel->{voiced};
+ _release_icon $self->{icons_voiced}[$voice], $self->{voiced}[$voice], '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;
+
+ my $ero_anim = $rel->{ani_ero};
+ _release_icon $self->{icons_ero_animated}[$ero_anim], "Ero: $self->{animated}[$ero_anim]", 'ero_animated' if $ero_anim;
+
+ # Cost column
+ _release_icon 'freeware', 'Freeware', 'free' if $rel->{freeware};
+ _release_icon 'nonfree', 'Non-free', 'nonfree' unless $rel->{freeware};
+
+ # Publisher type column
+ if(!$rel->{patch}) {
+ _release_icon 'doujin', 'Doujin', 'doujin' if $rel->{doujin};
+ _release_icon 'commercial', 'Commercial', 'commercial' unless $rel->{doujin};
+ }
+
+ # Resolution column
+ my $resolution = $rel->{resolution};
+ if($resolution) {
+ my $resolution_type = $resolution == 1 ? 'custom' : $self->{resolutions}[$resolution][1] eq 'widescreen' ? '16-9' : '4-3';
+ _release_icon "res$resolution_type", $self->{resolutions}[$resolution][0], "resolution_$resolution_type";
+ }
+
+ # Media column
+ if(@{$rel->{media}}) {
+ my $icon = $self->{media}{ $rel->{media}[0]{medium} }[3];
+ my $media_detail = join ', ', map fmtmedia($_->{medium}, $_->{qty}), @{$rel->{media}};
+ _release_icon $icon, $media_detail, $icon;
+ }
+
+ # Notes column
+ # TODO: The notes text should to through a bb2html() to strip the tags. But
+ # showing HTML inside a 'title' attribute won't work, and bb2html() doesn't
+ # have a plain text output option.
+ _release_icon 'notes', $rel->{notes}, 'notes' if $rel->{notes};
+}
+
+
sub _screenshots {
my($self, $v, $r) = @_;
div class => 'mainbox', id => 'screenshots';
@@ -982,67 +1036,5 @@ sub _staff {
end;
}
-
-# Creates an small sized img inside an abbr tag. Used for per-release information icons.
-sub release_info_icon {
- abbr class => 'release_icons_container', title => "$_[1]";
- img src=> "/f/".$_[2], class => "$_[0]", alt => "$_[1]";
- end;
-}
-
-sub add_release_info_icons {
- my($self, $releases_data) = @_;
-
- # Voice column
- my $voice_code = $releases_data->{voiced};
- if($voice_code > 0) {
- release_info_icon("release_icons " . $self->{icons_voiced}[$voice_code], $self->{voiced}[$releases_data->{voiced}], 'voiced.svg');
- }
-
- # Animations columns
- my $story_anim_code = $releases_data->{ani_story};
- if($story_anim_code > 0) {
- release_info_icon("release_icons ".$self->{icons_story_animated}[$story_anim_code], "Story: $self->{animated}[$story_anim_code]", "story_animated.svg");
- }
-
- my $ero_anim_code = $releases_data->{ani_ero};
- if($ero_anim_code > 0) {
- release_info_icon("release_icons ".$self->{icons_ero_animated}[$ero_anim_code], "Ero: $self->{animated}[$ero_anim_code]", "ero_animated.svg");
- }
-
- # Cost column
- $releases_data->{freeware} ? release_info_icon "release_icons freeware", "Freeware", "free.svg"
- : release_info_icon "release_icons nonfree", "Non-free", "nonfree.svg";
-
- # Publisher type column
- $releases_data->{patch} ? () : ($releases_data->{doujin} ? release_info_icon "release_icons doujin", "Doujin", "doujin.svg"
- : release_info_icon "release_icons commercial", "Commercial", "commercial.svg");
-
- # Resolution column
- my $resolution = $releases_data->{resolution};
- if ($resolution > 0) {
- my $resolution_type = ($resolution == 1) ? "custom" : ($self->{resolutions}[$resolution][1] eq 'widescreen') ? '16-9' : '4-3';
- my $computed_svg = "resolution_".$resolution_type.".svg";
- release_info_icon("release_icons res".$resolution_type, $self->{resolutions}[$resolution][0], $computed_svg);
- }
-
- # Media column
- if (@{$releases_data->{media}}) {
- my $first_medium = $releases_data->{media}[0]->{medium};
- my $media_type = $first_medium eq "in" ? "download" :
- $first_medium eq "cd" || $first_medium eq "dvd" || $first_medium eq "gdr" || $first_medium eq "blr" ? 'disk' : 'cartridge';
- my $media_detail = join ', ', map fmtmedia($_->{medium}, $_->{qty}), @{$releases_data->{media}};
- release_info_icon("release_icons ".$media_type, $media_detail, $media_type.".svg");
- }
-
- # Notes column
- # TODO: The notes text should to through a bb2html() to strip the tags. But
- # showing HTML inside a 'title' attribute won't work, and bb2html() doesn't
- # have a plain text output option.
- if (defined $releases_data->{notes} and length $releases_data->{notes}) {
- release_info_icon "release_icons notes", $releases_data->{notes}, "notes.svg";
- }
-}
-
1;