summaryrefslogtreecommitdiff
path: root/lib/Multi/RG.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-09-26 10:59:18 +0200
committerYorhel <git@yorhel.nl>2009-09-26 10:59:18 +0200
commitc160933061f58a0f64a6037c1db8b79fb725b495 (patch)
tree37e5fce3913c18504757a944c394f18b63e13e3b /lib/Multi/RG.pm
parent836eb84c9be9197b5ca842a755051f4230df7600 (diff)
Converted VN relations to ENUM data type and made them translatable
OK, these are actually two separate things: to make the relations translatable they didn't necessarily have to be stored as enum, and I could've also converted them to enum but not have it translatable. Nevertheless, it was easier to just do both at the same time. Also note how I used the string "$____vnrel_<rel>____$" as identifier in the relation graphs while I could have used something a lot shorter ("$<rel>$" would have been fine, for example). This is done so that graphviz can make some space for those relations - the long identifier gives a slightly more realistic representation of the actual length of the relation titles.
Diffstat (limited to 'lib/Multi/RG.pm')
-rw-r--r--lib/Multi/RG.pm22
1 files changed, 7 insertions, 15 deletions
diff --git a/lib/Multi/RG.pm b/lib/Multi/RG.pm
index 4ae0516e..be12fd17 100644
--- a/lib/Multi/RG.pm
+++ b/lib/Multi/RG.pm
@@ -78,8 +78,8 @@ sub getrel { # num, res, vid
$_[HEAP]{nodes}{$id} = 1;
for($_[ARG0] > 0 ? @{$_[ARG1]} : ()) {
- $_[HEAP]{rels}{$id.'-'.$_->{id}} = reverserel($_->{relation}) if $id < $_->{id};
- $_[HEAP]{rels}{$_->{id}.'-'.$id} = $_->{relation} if $id > $_->{id};
+ $_[HEAP]{rels}{$id.'-'.$_->{id}} = $VNDB::S{vn_relations}{$_->{relation}}[1] if $id < $_->{id};
+ $_[HEAP]{rels}{$_->{id}.'-'.$id} = $_->{relation} if $id > $_->{id};
if(!exists $_[HEAP]{nodes}{$_->{id}}) {
$_[HEAP]{nodes}{$_->{id}} = 0;
@@ -147,14 +147,13 @@ sub builddot { # num, res
# [older game] -> [newer game]
if($_->[4] > $_->[3]) {
($_->[0], $_->[1]) = ($_->[1], $_->[0]);
- $_->[2] = reverserel($_->[2]);
+ $_->[2] = $VNDB::S{vn_relations}{$_->[2]}[1];
}
+ my $rev = $VNDB::S{vn_relations}{$_->[2]}[1];
my $label =
- $VNDB::S{vn_relations}[$_->[2]][1]
- ? qq|headlabel = "$VNDB::S{vn_relations}[$_->[2]][0]", taillabel = "$VNDB::S{vn_relations}[$_->[2]-1][0]"| :
- $VNDB::S{vn_relations}[$_->[2]+1][1]
- ? qq|headlabel = "$VNDB::S{vn_relations}[$_->[2]][0]", taillabel = "$VNDB::S{vn_relations}[$_->[2]+1][0]"|
- : qq|label = " $VNDB::S{vn_relations}[$_->[2]][0]"|;
+ $rev ne $_->[2]
+ ? qq|headlabel = "\$____vnrel_$_->[2]____\$", taillabel = "\$____vnrel_${rev}____\$"|
+ : qq|label = "\$____vnrel_$_->[2]____\$"|;
$gv .= qq|\tv$$_[1] -- v$$_[0] [ $label ]\n|;
}
@@ -258,12 +257,5 @@ sub proc_child {
}
-
-# non-POE helper function
-sub reverserel { # relation
- return $VNDB::S{vn_relations}[$_[0]][1] ? $_[0]-1 : $VNDB::S{vn_relations}[$_[0]+1][1] ? $_[0]+1 : $_[0];
-}
-
-
1;