summaryrefslogtreecommitdiff
path: root/lib
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 /lib
parentc42d62b6e360b03cc9abcbb902becba2159e4b41 (diff)
Code style changes to release icons code
These are just style consistency changes, functionally equivalent.
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/Handler/VNPage.pm118
1 files changed, 55 insertions, 63 deletions
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;