summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-06-15 19:00:39 +0200
committerYorhel <git@yorhel.nl>2020-06-15 19:00:41 +0200
commit7f02fd77fd71022712407c78816cc41e75b2fbc0 (patch)
tree4cfe76fad2d9daedf3dbd530e1aebbfc88d53e05
parent1febd87dd16439203ee0de1f1adc6e9be75860e9 (diff)
Releases: Allow custom resolutions to be entered
The resolution field now works much like the engine field.
-rw-r--r--data/js/filter.js9
-rw-r--r--elm/ReleaseEdit.elm60
-rw-r--r--lib/Multi/API.pm8
-rw-r--r--lib/VNDB/DB/Releases.pm10
-rw-r--r--lib/VNDB/Handler/VNPage.pm6
-rw-r--r--lib/VNDB/Types.pm23
-rw-r--r--lib/VNDB/Util/Misc.pm9
-rw-r--r--lib/VNDBUtil.pm11
-rw-r--r--lib/VNWeb/Elm.pm1
-rw-r--r--lib/VNWeb/Prelude.pm4
-rw-r--r--lib/VNWeb/Releases/Edit.pm47
-rw-r--r--lib/VNWeb/Releases/Lib.pm8
-rw-r--r--lib/VNWeb/Releases/Page.pm8
-rw-r--r--sql/schema.sql11
-rwxr-xr-xutil/jsgen.pl19
-rw-r--r--util/updates/2020-06-15-custom-resolutions.sql39
16 files changed, 170 insertions, 103 deletions
diff --git a/data/js/filter.js b/data/js/filter.js
index 8c2edb6d..3d0f5898 100644
--- a/data/js/filter.js
+++ b/data/js/filter.js
@@ -29,6 +29,13 @@
var fil_escape = "_ !\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~".split('');
var fil_objs = [];
+var resolutions = [
+ ["unknown","Unknown / console / handheld"],
+ ["nonstandard","Non-standard"],
+ ["4:3",["640x480","640x480"],["800x600","800x600"],["1024x768","1024x768"],["1280x960","1280x960"],["1600x1200","1600x1200"]],
+ ["widescreen",["640x400","640x400"],["960x600","960x600"],["960x640","960x640"],["1024x576","1024x576"],["1024x600","1024x600"],["1024x640","1024x640"],["1280x720","1280x720"],["1280x800","1280x800"],["1366x768","1366x768"],["1600x900","1600x900"],["1920x1080","1920x1080"]]
+];
+
function getObj(obj) {
while(!obj.fil_fields)
obj = obj.parentNode;
@@ -643,7 +650,7 @@ function filReleases() {
[ 'Language', filFSelect('lang', 'Language', 20, VARS.languages) ],
byId('rfilselect') ? null :
[ 'Original language', filFSelect('olang', 'Original language', 20, VARS.languages) ],
- [ 'Screen resolution', filFSelect('resolution', 'Screen resolution', 15, VARS.resolutions) ],
+ [ 'Screen resolution', filFSelect('resolution', 'Screen resolution', 15, resolutions) ],
[ 'Platform', filFSelect('plat', 'Platform', 20, plat) ],
[ 'Producer',
[ '', ' ', tag('Boolean or, selecting more gives more results') ],
diff --git a/elm/ReleaseEdit.elm b/elm/ReleaseEdit.elm
index b96f7887..012f3ff9 100644
--- a/elm/ReleaseEdit.elm
+++ b/elm/ReleaseEdit.elm
@@ -49,7 +49,10 @@ type alias Model =
, released : D.RDate
, minage : Int
, uncensored : Bool
- , resolution : String
+ , resoX : Int
+ , resoY : Int
+ , resoConf : A.Config Msg GRE.RecvResolutions
+ , reso : A.Model GRE.RecvResolutions
, voiced : Int
, ani_story : Int
, ani_ero : Int
@@ -78,6 +81,37 @@ engineConf lst =
}
}
+
+resoConf : List GRE.RecvResolutions -> A.Config Msg GRE.RecvResolutions
+resoConf lst =
+ { wrap = Resolution
+ , id = "resolution"
+ , source =
+ { source = A.Func (\s -> List.filter (\e -> String.contains (String.toLower s) (String.toLower e.resolution)) lst |> List.take 10)
+ , view = \i -> [ text i.resolution, b [ class "grayedout" ] [ text <| " (" ++ String.fromInt i.count ++ ")" ] ]
+ , key = \i -> i.resolution
+ }
+ }
+
+resoFmt : Int -> Int -> String
+resoFmt x y =
+ case (x,y) of
+ (0,0) -> ""
+ (0,1) -> "Non-standard"
+ _ -> String.fromInt x ++ "x" ++ String.fromInt y
+
+resoParse : String -> Maybe (Int, Int)
+resoParse s =
+ case (String.toLower s, String.split "x" s) of
+ ("", _) -> Just (0,0)
+ ("non-standard", _) -> Just (0,1)
+ (_, [sx,sy]) ->
+ case (String.toInt sx, String.toInt sy) of
+ (Just ix, Just iy) -> if ix < 1 || ix > 32767 || iy < 1 || iy > 32767 then Nothing else Just (ix,iy)
+ _ -> Nothing
+ _ -> Nothing
+
+
init : GRE.Recv -> Model
init d =
{ state = Api.Normal
@@ -98,7 +132,10 @@ init d =
, released = d.released
, minage = d.minage
, uncensored = d.uncensored
- , resolution = d.resolution
+ , resoX = d.reso_x
+ , resoY = d.reso_y
+ , resoConf = resoConf d.resolutions
+ , reso = A.init (resoFmt d.reso_x d.reso_y)
, voiced = d.voiced
, ani_story = d.ani_story
, ani_ero = d.ani_ero
@@ -136,7 +173,8 @@ encode model =
, released = model.released
, minage = model.minage
, uncensored = model.uncensored
- , resolution = model.resolution
+ , reso_x = model.resoX
+ , reso_y = model.resoY
, voiced = model.voiced
, ani_story = model.ani_story
, ani_ero = model.ani_ero
@@ -176,7 +214,7 @@ type Msg
| Released D.RDate
| Minage Int
| Uncensored Bool
- | Resolution String
+ | Resolution (A.Msg GRE.RecvResolutions)
| Voiced Int
| AniStory Int
| AniEro Int
@@ -215,7 +253,13 @@ update msg model =
Released d -> ({ model | released = d }, Cmd.none)
Minage i -> ({ model | minage = i }, Cmd.none)
Uncensored b->({ model | uncensored = b }, Cmd.none)
- Resolution s->({ model | resolution = s }, Cmd.none)
+ Resolution m->
+ let (nm, c, en) = A.update model.resoConf m model.reso
+ nmod = { model | reso = Maybe.withDefault nm <| Maybe.map (\e -> A.clear nm e.resolution) en }
+ n2mod = case resoParse nmod.reso.value of
+ Just (x,y) -> { nmod | resoX = x, resoY = y }
+ Nothing -> nmod
+ in (n2mod, c)
Voiced i -> ({ model | voiced = i }, Cmd.none)
AniStory i -> ({ model | ani_story = i }, Cmd.none)
AniEro i -> ({ model | ani_ero = i }, Cmd.none)
@@ -264,6 +308,7 @@ isValid model = not
|| hasDuplicates (List.map (\m -> (m.medium, m.qty)) model.media)
|| not model.gtinValid
|| List.isEmpty model.vn
+ || resoParse model.reso.value == Nothing
)
@@ -328,7 +373,10 @@ viewGen model =
, if model.patch then text "" else
formField "engine::Engine" [ A.view model.engineConf model.engine [] ]
, if model.patch then text "" else
- formField "resolution::Resolution" [ inputSelect "resolution" model.resolution Resolution [] GT.resolutions ]
+ formField "resolution::Resolution"
+ [ A.view model.resoConf model.reso []
+ , if resoParse model.reso.value == Nothing then b [ class "standout" ] [ text " Invalid resolution" ] else text ""
+ ]
, if model.patch then text "" else
formField "voiced::Voiced" [ inputSelect "voiced" model.voiced Voiced [] GT.voiced ]
, if model.patch then text "" else
diff --git a/lib/Multi/API.pm b/lib/Multi/API.pm
index a3280fc9..bef61129 100644
--- a/lib/Multi/API.pm
+++ b/lib/Multi/API.pm
@@ -15,7 +15,7 @@ use POE::Filter::VNDBAPI 'encode_filters';
use Encode 'encode_utf8', 'decode_utf8';
use Crypt::URandom 'urandom';
use Crypt::ScryptKDF 'scrypt_raw';;
-use VNDBUtil 'normalize_query', 'norm_ip';
+use VNDBUtil 'normalize_query', 'norm_ip', 'resolution';
use VNDB::Types;
use VNDB::Config;
use JSON::XS;
@@ -603,14 +603,14 @@ my %GET_RELEASE = (
]],
},
details => {
- select => 'r.website, r.notes, r.minage, r.gtin, r.catalog, r.resolution, r.voiced, r.ani_story, r.ani_ero',
+ select => 'r.website, r.notes, r.minage, r.gtin, r.catalog, r.reso_x, r.reso_y, r.voiced, r.ani_story, r.ani_ero',
proc => sub {
$_[0]{website} ||= undef;
$_[0]{notes} ||= undef;
$_[0]{minage} = $_[0]{minage} < 0 ? undef : $_[0]{minage}*1;
$_[0]{gtin} ||= undef;
$_[0]{catalog} ||= undef;
- $_[0]{resolution} = $_[0]{resolution} eq 'unknown' ? undef : $RESOLUTION{ $_[0]{resolution} }{txt};
+ $_[0]{resolution} = resolution $_[0];
$_[0]{voiced} = $_[0]{voiced} ? $_[0]{voiced}*1 : undef;
$_[0]{animation} = [
$_[0]{ani_story} ? $_[0]{ani_story}*1 : undef,
@@ -618,6 +618,8 @@ my %GET_RELEASE = (
];
delete($_[0]{ani_story});
delete($_[0]{ani_ero});
+ delete($_[0]{reso_x});
+ delete($_[0]{reso_y});
},
fetch => [
[ 'id', 'SELECT id, platform FROM releases_platforms WHERE id IN(%s)',
diff --git a/lib/VNDB/DB/Releases.pm b/lib/VNDB/DB/Releases.pm
index d17bfd00..2bfe8032 100644
--- a/lib/VNDB/DB/Releases.pm
+++ b/lib/VNDB/DB/Releases.pm
@@ -24,7 +24,9 @@ sub dbReleaseFilters {
defined $o{date_after} ? ( 'r.released >= ?' => $o{date_after} ) : (),
defined $o{minage} ? ( 'r.minage IN(!l)' => [ ref $o{minage} ? $o{minage} : [$o{minage}] ] ) : (),
defined $o{doujin} ? ( 'NOT r.patch AND r.doujin = ?' => $o{doujin} == 1 ? 1 : 0) : (),
- defined $o{resolution} ? ( 'NOT r.patch AND r.resolution IN(!l)' => [ ref $o{resolution} ? $o{resolution} : [$o{resolution}] ] ) : (),
+ defined $o{resolution} ? ( 'NOT r.patch AND ARRAY[r.reso_x, r.reso_y] IN(!l)' =>
+ [[ map $_ eq 'unknown' ? '{0,0}' : $_ eq 'nonstandard' ? '{0,1}' : '{'.(s/x/,/r).'}',
+ ref $o{resolution} ? $o{resolution}->@* : $o{resolution} ]] ) : (),
defined $o{voiced} ? ( 'NOT r.patch AND r.voiced IN(!l)' => [ ref $o{voiced} ? $o{voiced} : [$o{voiced}] ] ) : (),
defined $o{ani_story} ? ( 'NOT r.patch AND r.ani_story IN(!l)' => [ ref $o{ani_story} ? $o{ani_story} : [$o{ani_story}] ] ) : (),
defined $o{ani_ero} ? ( 'NOT r.patch AND r.ani_ero IN(!l)' => [ ref $o{ani_ero} ? $o{ani_ero} : [$o{ani_ero}] ] ) : (),
@@ -87,7 +89,7 @@ sub dbReleaseGet {
my @select = (
qw|r.id r.title r.original r.website r.released r.minage r.type r.patch|,
$o{what} =~ /extended/ ? qw|
- r.notes r.catalog r.gtin r.resolution r.voiced r.freeware r.doujin r.uncensored r.ani_story r.ani_ero r.engine r.hidden r.locked
+ r.notes r.catalog r.gtin r.reso_x r.reso_y r.voiced r.freeware r.doujin r.uncensored r.ani_story r.ani_ero r.engine r.hidden r.locked
| : (),
$o{pid} ? ('rp.developer', 'rp.publisher') : (),
$o{what} =~ /links/ ? qw|
@@ -99,7 +101,7 @@ sub dbReleaseGet {
title => 'r.title %s, r.released %1$s',
type => 'r.patch %s, r.type %1$s, r.released %1$s, r.title %1$s',
publication => 'r.doujin %s, r.freeware %1$s, r.patch %1$s, r.released %1$s, r.title %1$s',
- resolution => 'r.resolution %s, r.patch %2$s, r.released %1$s, r.title %1$s',
+ resolution => 'r.reso_x %s, r.reso_y %1$s, r.patch %2$s, r.released %1$s, r.title %1$s',
voiced => 'r.voiced %s, r.patch %2$s, r.released %1$s, r.title %1$s',
ani_ero => 'r.ani_story %s, r.ani_ero %1$s, r.patch %2$s, r.released %1$s, r.title %1$s',
released => 'r.released %s, r.id %1$s',
@@ -129,7 +131,7 @@ sub dbReleaseGetRev {
$o{rev} ||= $self->dbRow('SELECT MAX(rev) AS rev FROM changes WHERE type = \'r\' AND itemid = ?', $o{id})->{rev};
my $select = 'c.itemid AS id, r.title, r.original, r.website, r.released, r.minage, r.type, r.patch';
- $select .= ', r.notes, r.catalog, r.gtin, r.resolution, r.voiced, r.freeware, r.doujin, r.uncensored, r.ani_story, r.ani_ero, r.engine, ro.hidden, ro.locked' if $o{what} =~ /extended/;
+ $select .= ', r.notes, r.catalog, r.gtin, r.reso_x, r.reso_y, r.voiced, r.freeware, r.doujin, r.uncensored, r.ani_story, r.ani_ero, r.engine, ro.hidden, ro.locked' if $o{what} =~ /extended/;
$select .= ', extract(\'epoch\' from c.added) as added, c.comments, c.rev, c.ihid, c.ilock, '.VNWeb::DB::sql_user();
$select .= ', c.id AS cid, NOT EXISTS(SELECT 1 FROM changes c2 WHERE c2.type = c.type AND c2.itemid = c.itemid AND c2.rev = c.rev+1) AS lastrev';
$select .= ', r.gtin, r.l_steam, r.l_gog, r.l_gyutto, r.l_digiket, r.l_melon, r.l_getchu, r.l_getchudl, r.l_dmm, r.l_itch, r.l_jastusa, r.l_egs, r.l_erotrail, r.l_mg, r.l_denpa, r.l_jlist, r.l_dlsite, r.l_dlsiteen, r.l_melonjp, r.l_toranoana, r.l_gamejolt, r.l_nutaku' if $o{what} =~ /links/;
diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm
index cc0c7da4..1e11aa7b 100644
--- a/lib/VNDB/Handler/VNPage.pm
+++ b/lib/VNDB/Handler/VNPage.pm
@@ -98,10 +98,8 @@ my @rel_cols = (
na_for_patch => 1,
default => 1,
what => 'extended',
- has_data => sub { $_[0]{resolution} ne 'unknown' },
- draw => sub {
- txt $_[0]{resolution} eq 'unknown' ? 'Unknown' : $RESOLUTION{$_[0]{resolution}}{txt};
- },
+ has_data => sub { !!$_[0]{reso_y} },
+ draw => sub { txt resolution($_[0]) || 'Unknown' },
}, { # Voiced
id => 'voi',
sort_field => 'voiced',
diff --git a/lib/VNDB/Types.pm b/lib/VNDB/Types.pm
index 573562a2..1f8e5867 100644
--- a/lib/VNDB/Types.pm
+++ b/lib/VNDB/Types.pm
@@ -237,29 +237,6 @@ hash MEDIUM =>
-# SQL: ENUM resolution
-hash RESOLUTION =>
- unknown => { txt => 'Unknown / console / handheld', cat => '' }, # hardcoded in many places
- nonstandard => { txt => 'Non-standard', cat => '' }, # hardcoded in VNPage.pm
- '640x480' => { txt => '640x480', cat => '4:3' },
- '800x600' => { txt => '800x600', cat => '4:3' },
- '1024x768' => { txt => '1024x768', cat => '4:3' },
- '1280x960' => { txt => '1280x960', cat => '4:3' },
- '1600x1200' => { txt => '1600x1200', cat => '4:3' },
- '640x400' => { txt => '640x400', cat => 'widescreen' },
- '960x600' => { txt => '960x600', cat => 'widescreen' },
- '960x640' => { txt => '960x640', cat => 'widescreen' },
- '1024x576' => { txt => '1024x576', cat => 'widescreen' },
- '1024x600' => { txt => '1024x600', cat => 'widescreen' },
- '1024x640' => { txt => '1024x640', cat => 'widescreen' },
- '1280x720' => { txt => '1280x720', cat => 'widescreen' },
- '1280x800' => { txt => '1280x800', cat => 'widescreen' },
- '1366x768' => { txt => '1366x768', cat => 'widescreen' },
- '1600x900' => { txt => '1600x900', cat => 'widescreen' },
- '1920x1080' => { txt => '1920x1080', cat => 'widescreen' };
-
-
-
# SQL: ENUM release_type
hash RELEASE_TYPE =>
complete => 'Complete',
diff --git a/lib/VNDB/Util/Misc.pm b/lib/VNDB/Util/Misc.pm
index b314bf08..c08fe1bb 100644
--- a/lib/VNDB/Util/Misc.pm
+++ b/lib/VNDB/Util/Misc.pm
@@ -99,15 +99,6 @@ sub filCompat {
$mod++;
}
- if($type eq 'release' && $fil->{resolution}) {
- $fil->{resolution} = [ map {
- if(/^[0-9]+$/) {
- $mod++;
- (keys %RESOLUTION)[$_] || 'unknown'
- } else { $_ }
- } ref $fil->{resolution} ? @{$fil->{resolution}} : $fil->{resolution} ];
- }
-
$mod;
}
diff --git a/lib/VNDBUtil.pm b/lib/VNDBUtil.pm
index 80d45fc6..b9b94a3c 100644
--- a/lib/VNDBUtil.pm
+++ b/lib/VNDBUtil.pm
@@ -1,4 +1,4 @@
-# Misc. utility functions, do not rely on YAWF or POE and can be used from any script
+# Misc. utility functions, these do not rely on TUWF or AnyEvent and can be used from any script
package VNDBUtil;
@@ -9,7 +9,7 @@ use Encode 'encode_utf8';
use Unicode::Normalize 'NFKD', 'compose';
use Socket 'inet_pton', 'inet_ntop', 'AF_INET', 'AF_INET6';
-our @EXPORT = qw|shorten gtintype normalize_titles normalize_query imgsize norm_ip|;
+our @EXPORT = qw|shorten resolution gtintype normalize_titles normalize_query imgsize norm_ip|;
sub shorten {
@@ -18,6 +18,13 @@ sub shorten {
}
+sub resolution {
+ my($x,$y) = @_;
+ ($x,$y) = ($x->{reso_x}, $x->{reso_y}) if ref $x;
+ $x ? "${x}x${y}" : $y == 1 ? 'Non-standard' : undef
+}
+
+
# GTIN code as argument,
# Returns 'JAN', 'EAN', 'UPC' or undef,
# Also 'normalizes' the first argument in place
diff --git a/lib/VNWeb/Elm.pm b/lib/VNWeb/Elm.pm
index 2b37587d..b8598438 100644
--- a/lib/VNWeb/Elm.pm
+++ b/lib/VNWeb/Elm.pm
@@ -390,7 +390,6 @@ sub write_types {
$data .= def boardTypes => 'List (String, String)' => list map tuple(string $_, string $BOARD_TYPE{$_}{txt}), keys %BOARD_TYPE;
$data .= def ratings => 'List String' => list map string(fmtrating $_), 1..10;
$data .= def ageRatings => 'List (Int, String)' => list map tuple($_, string $AGE_RATING{$_}{txt}.($AGE_RATING{$_}{ex}?" ($AGE_RATING{$_}{ex})":'')), keys %AGE_RATING;
- $data .= def resolutions=> 'List (String, String)' => list map tuple(string $_, string +($RESOLUTION{$_}{cat}?"$RESOLUTION{$_}{cat} / ":'').$RESOLUTION{$_}{txt}), keys %RESOLUTION;
$data .= def voiced => 'List (Int, String)' => list map tuple($_, string $VOICED{$_}{txt}), keys %VOICED;
$data .= def animated => 'List (Int, String)' => list map tuple($_, string $ANIMATED{$_}{txt}), keys %ANIMATED;
$data .= def genders => 'List (String, String)' => list map tuple(string $_, string $GENDER{$_}), keys %GENDER;
diff --git a/lib/VNWeb/Prelude.pm b/lib/VNWeb/Prelude.pm
index 87810ac7..c79cc09b 100644
--- a/lib/VNWeb/Prelude.pm
+++ b/lib/VNWeb/Prelude.pm
@@ -14,7 +14,7 @@
# use VNDB::BBCode;
# use VNDB::Types;
# use VNDB::Config;
-# use VNDB::Func qw/fmtdate fmtage fmtvote fmtspoil fmtmedia minage query_encode lang_attr md2html/;
+# use VNDB::Func qw/fmtdate fmtage fmtvote fmtspoil fmtmedia minage resolution query_encode lang_attr md2html/;
# use VNDB::ExtLinks;
# use VNWeb::Auth;
# use VNWeb::HTML;
@@ -58,7 +58,7 @@ sub import {
use VNDB::BBCode;
use VNDB::Types;
use VNDB::Config;
- use VNDB::Func qw/fmtdate fmtage fmtvote fmtspoil fmtmedia minage query_encode lang_attr md2html/;
+ use VNDB::Func qw/fmtdate fmtage fmtvote fmtspoil fmtmedia minage resolution query_encode lang_attr md2html/;
use VNDB::ExtLinks;
use VNWeb::Auth;
use VNWeb::HTML;
diff --git a/lib/VNWeb/Releases/Edit.pm b/lib/VNWeb/Releases/Edit.pm
index a315d96b..d7f62cdf 100644
--- a/lib/VNWeb/Releases/Edit.pm
+++ b/lib/VNWeb/Releases/Edit.pm
@@ -22,7 +22,8 @@ my $FORM = {
released => { default => 99999999, min => 1, rdate => 1 },
minage => { int => 1, enum => \%AGE_RATING },
uncensored => { anybool => 1 },
- resolution => { default => 'unknown', enum => \%RESOLUTION },
+ reso_x => { uint => 1, range => [0,32767] },
+ reso_y => { uint => 1, range => [0,32767] },
voiced => { uint => 1, enum => \%VOICED },
ani_story => { uint => 1, enum => \%ANIMATED },
ani_ero => { uint => 1, enum => \%ANIMATED },
@@ -47,6 +48,10 @@ my $FORM = {
engine => {},
count => { uint => 1 },
} },
+ resolutions=> { _when => 'out', aoh => {
+ resolution => {},
+ count => { uint => 1 },
+ } },
authmod => { _when => 'out', anybool => 1 },
editsum => { _when => 'in out', editsum => 1 },
};
@@ -57,23 +62,29 @@ my $FORM_CMP = form_compile cmp => $FORM;
sub to_extlinks { $_[0]{extlinks} = { map +($_, delete $_[0]{$_}), grep /^l_/, keys $_[0]->%* } }
-sub engines {
- tuwf->dbAlli(q{
- SELECT engine, count(*) AS count FROM releases WHERE NOT hidden AND engine <> ''
- GROUP BY engine ORDER BY count(*) DESC, engine
- })
+sub enrich_form {
+ my($e) = @_;
+ $e->{authmod} = auth->permDbmod;
+ $e->{engines} = tuwf->dbAlli(q{
+ SELECT engine, count(*) AS count FROM releases WHERE NOT hidden AND engine <> ''
+ GROUP BY engine ORDER BY count(*) DESC, engine
+ });
+ $e->{resolutions} = [ map +{ resolution => resolution($_), count => $_->{count} }, tuwf->dbAlli(q{
+ SELECT reso_x, reso_y, count(*) AS count FROM releases WHERE NOT hidden AND NOT (reso_x = 0 AND reso_y = 0)
+ GROUP BY reso_x, reso_y ORDER BY count(*) DESC
+ })->@* ];
}
+
TUWF::get qr{/$RE{rrev}/(?<action>edit|copy)} => sub {
my $e = db_entry r => tuwf->capture('id'), tuwf->capture('rev') or return tuwf->resNotFound;
my $copy = tuwf->capture('action') eq 'copy';
return tuwf->resDenied if !can_edit r => $copy ? {} : $e;
$e->{rtype} = delete $e->{type};
- $e->{authmod} = auth->permDbmod;
$e->{editsum} = $copy ? "Copied from r$e->{id}.$e->{chrev}" : $e->{chrev} == $e->{maxrev} ? '' : "Reverted to revision r$e->{id}.$e->{chrev}";
- $e->{engines} = engines;
+ enrich_form $e;
to_extlinks $e;
enrich_merge vid => 'SELECT id AS vid, title FROM vn WHERE id IN', $e->{vn};
@@ -98,6 +109,14 @@ TUWF::get qr{/$RE{vid}/add}, sub {
my $delrel = tuwf->dbAlli('SELECT r.id, r.title, r.original FROM releases r JOIN releases_vn rv ON rv.id = r.id WHERE r.hidden AND rv.vid =', \$v->{id}, 'ORDER BY id');
enrich_flatten languages => id => id => 'SELECT id, lang FROM releases_lang WHERE id IN', $delrel;
+ my $e = {
+ elm_empty($FORM_OUT)->%*,
+ title => $v->{title},
+ original => $v->{original},
+ vn => [{vid => $v->{id}, title => $v->{title}}],
+ };
+ enrich_form $e;
+
framework_ title => "Add release to $v->{title}",
sub {
editmsg_ r => undef, "Add release to $v->{title}";
@@ -118,14 +137,7 @@ TUWF::get qr{/$RE{vid}/add}, sub {
}
} if @$delrel;
- elm_ ReleaseEdit => $FORM_OUT, {
- elm_empty($FORM_OUT)->%*,
- title => $v->{title},
- original => $v->{original},
- engines => engines(),
- authmod => auth->permDbmod(),
- vn => [{vid => $v->{id}, title => $v->{title}}],
- };
+ elm_ ReleaseEdit => $FORM_OUT, $e;
};
};
@@ -141,11 +153,12 @@ elm_api ReleaseEdit => $FORM_OUT, $FORM_IN, sub {
$data->{locked} = $e->{locked}||0;
}
$data->{doujin} = $data->{voiced} = $data->{ani_story} = $data->{ani_ero} = 0 if $data->{patch};
- $data->{resolution} = 'unknown' if $data->{patch};
+ $data->{reso_x} = $data->{reso_y} = 0 if $data->{patch};
$data->{uncensored} = $data->{ani_ero} = 0 if $data->{minage} != 18;
$_->{qty} = $MEDIUM{$_->{medium}}{qty} ? $_->{qty}||1 : 0 for $data->{media}->@*;
$data->{notes} = bb_subst_links $data->{notes};
die "No VNs selected" if !$data->{vn}->@*;
+ die "Invalid resolution: ($data->{reso_x},$data->{reso_y})" if (!$data->{reso_x} && $data->{reso_y} > 1) || ($data->{reso_x} && !$data->{reso_y});
to_extlinks $e;
$e->{rtype} = delete $e->{type};
diff --git a/lib/VNWeb/Releases/Lib.pm b/lib/VNWeb/Releases/Lib.pm
index de25258a..7b36a290 100644
--- a/lib/VNWeb/Releases/Lib.pm
+++ b/lib/VNWeb/Releases/Lib.pm
@@ -10,7 +10,7 @@ our @EXPORT = qw/enrich_release release_row_/;
# Assumption: Each release already has id, type, patch, released, gtin and enrich_extlinks().
sub enrich_release {
my($r) = @_;
- enrich_merge id => 'SELECT id, title, original, notes, minage, freeware, doujin, resolution, voiced, ani_story, ani_ero, uncensored FROM releases WHERE id IN', $r;
+ enrich_merge id => 'SELECT id, title, original, notes, minage, freeware, doujin, reso_x, reso_y, voiced, ani_story, ani_ero, uncensored FROM releases WHERE id IN', $r;
enrich_merge id => sql('SELECT rid as id, status as rlist_status FROM rlists WHERE uid =', \auth->uid, 'AND rid IN'), $r if auth;
enrich_flatten lang => id => id => sub { sql 'SELECT id, lang FROM releases_lang WHERE id IN', $_, 'ORDER BY id, lang' }, $r;
enrich_flatten platforms => id => id => sub { sql 'SELECT id, platform FROM releases_platforms WHERE id IN', $_, 'ORDER BY id, platform' }, $r;
@@ -68,11 +68,11 @@ sub release_row_ {
icon_ 'nonfree', 'Non-free' if !$r->{freeware};
icon_ 'doujin', 'Doujin' if !$r->{patch} && $r->{doujin};
icon_ 'commercial', 'Commercial' if !$r->{patch} && !$r->{doujin};
- if($r->{resolution} ne 'unknown') {
- my $type = $r->{resolution} eq 'nonstandard' ? 'custom' : $RESOLUTION{$r->{resolution}}{cat} eq 'widescreen' ? '16-9' : '4-3';
+ if($r->{reso_y}) {
+ my $type = $r->{reso_y} == 1 ? 'custom' : $r->{reso_x} / $r->{reso_y} > 4/3 ? '16-9' : '4-3';
# Ugly workaround: PC-98 has non-square pixels, thus not widescreen
$type = '4-3' if $type eq '16-9' && grep $_ eq 'p98', $r->{platforms}->@*;
- icon_ "resolution_$type", $RESOLUTION{$r->{resolution}}{txt};
+ icon_ "resolution_$type", resolution $r;
}
icon_ $MEDIUM{ $r->{media}[0]{medium} }{icon}, join ', ', map fmtmedia($_->{medium}, $_->{qty}), $r->{media}->@* if $r->{media}->@*;
icon_ 'uncensor', 'Uncensored' if $r->{uncensored};
diff --git a/lib/VNWeb/Releases/Page.pm b/lib/VNWeb/Releases/Page.pm
index 77a50f27..ccf4b6fb 100644
--- a/lib/VNWeb/Releases/Page.pm
+++ b/lib/VNWeb/Releases/Page.pm
@@ -14,6 +14,8 @@ sub enrich_item {
$r->{vn} = [ sort { $a->{title} cmp $b->{title} || $a->{vid} <=> $b->{vid} } $r->{vn}->@* ];
$r->{producers} = [ sort { $a->{name} cmp $b->{name} || $a->{pid} <=> $b->{pid} } $r->{producers}->@* ];
$r->{media} = [ sort { $a->{medium} cmp $b->{medium} || $a->{qty} <=> $b->{qty} } $r->{media}->@* ];
+
+ $r->{resolution} = resolution $r;
}
@@ -36,7 +38,7 @@ sub _rev_ {
[ notes => 'Notes' ],
[ platforms => 'Platforms', fmt => \%PLATFORM ],
[ media => 'Media', fmt => sub { txt_ fmtmedia $_->{medium}, $_->{qty}; } ],
- [ resolution => 'Resolution', fmt => \%RESOLUTION ],
+ [ resolution => 'Resolution' ],
[ voiced => 'Voiced', fmt => \%VOICED ],
[ ani_story => 'Story animation', fmt => \%ANIMATED ],
[ ani_ero => 'Ero animation', fmt => \%ANIMATED ],
@@ -119,8 +121,8 @@ sub _infotable_ {
tr_ sub {
td_ 'Resolution';
- td_ $RESOLUTION{$r->{resolution}}{txt};
- } if $r->{resolution} ne 'unknown';
+ td_ resolution $r;
+ } if $r->{reso_y};
tr_ sub {
td_ 'Voiced';
diff --git a/sql/schema.sql b/sql/schema.sql
index 0098d482..da475d5d 100644
--- a/sql/schema.sql
+++ b/sql/schema.sql
@@ -65,7 +65,6 @@ CREATE TYPE producer_relation AS ENUM ('old', 'new', 'sub', 'par', 'imp', 'ipa',
CREATE TYPE release_type AS ENUM ('complete', 'partial', 'trial');
CREATE TYPE tag_category AS ENUM('cont', 'ero', 'tech');
CREATE TYPE vn_relation AS ENUM ('seq', 'preq', 'set', 'alt', 'char', 'side', 'par', 'ser', 'fan', 'orig');
-CREATE TYPE resolution AS ENUM ('unknown', 'nonstandard', '640x480', '800x600', '1024x768', '1280x960', '1600x1200', '640x400', '960x600', '960x640', '1024x576', '1024x600', '1024x640', '1280x720', '1280x800', '1366x768', '1600x900', '1920x1080');
CREATE TYPE session_type AS ENUM ('web', 'pass', 'mail');
-- Sequences used for ID generation of items not in the DB
@@ -328,7 +327,6 @@ CREATE TABLE releases ( -- dbentry_type=r
patch boolean NOT NULL DEFAULT FALSE, -- [pub]
freeware boolean NOT NULL DEFAULT FALSE, -- [pub]
doujin boolean NOT NULL DEFAULT FALSE, -- [pub]
- resolution resolution NOT NULL DEFAULT 'unknown', -- [pub]
voiced smallint NOT NULL DEFAULT 0, -- [pub]
ani_story smallint NOT NULL DEFAULT 0, -- [pub]
ani_ero smallint NOT NULL DEFAULT 0, -- [pub]
@@ -354,7 +352,9 @@ CREATE TABLE releases ( -- dbentry_type=r
l_toranoana bigint NOT NULL DEFAULT 0, -- [pub]
l_melonjp integer NOT NULL DEFAULT 0, -- [pub]
l_gamejolt integer NOT NULL DEFAULT 0, -- [pub]
- l_nutaku text NOT NULL DEFAULT '' -- [pub]
+ l_nutaku text NOT NULL DEFAULT '', -- [pub]
+ reso_x smallint NOT NULL DEFAULT 0, -- [pub] When reso_x is 0, reso_y is either 0 for 'unknown' or 1 for 'non-standard'.
+ reso_y smallint NOT NULL DEFAULT 0 -- [pub]
);
-- releases_hist
@@ -372,7 +372,6 @@ CREATE TABLE releases_hist (
patch boolean NOT NULL DEFAULT FALSE,
freeware boolean NOT NULL DEFAULT FALSE,
doujin boolean NOT NULL DEFAULT FALSE,
- resolution resolution NOT NULL DEFAULT 'unknown',
voiced smallint NOT NULL DEFAULT 0,
ani_story smallint NOT NULL DEFAULT 0,
ani_ero smallint NOT NULL DEFAULT 0,
@@ -398,7 +397,9 @@ CREATE TABLE releases_hist (
l_toranoana bigint NOT NULL DEFAULT 0,
l_melonjp integer NOT NULL DEFAULT 0,
l_gamejolt integer NOT NULL DEFAULT 0,
- l_nutaku text NOT NULL DEFAULT ''
+ l_nutaku text NOT NULL DEFAULT '',
+ reso_x smallint NOT NULL DEFAULT 0,
+ reso_y smallint NOT NULL DEFAULT 0
);
-- releases_lang
diff --git a/util/jsgen.pl b/util/jsgen.pl
index ff5868d5..84a5c8f1 100755
--- a/util/jsgen.pl
+++ b/util/jsgen.pl
@@ -14,24 +14,6 @@ use VNDB::Config;
use VNDB::Types;
-# screen resolution information, suitable for usage in filFSelect()
-sub resolutions {
- my $cat = '';
- my @r;
- my $push = \@r;
- for my $i (keys %RESOLUTION) {
- my $r = $RESOLUTION{$i};
- if($cat ne $r->{cat}) {
- push @r, [$r->{cat}];
- $cat = $r->{cat};
- $push = $r[$#r];
- }
- push @$push, [$i, $r->{txt}];
- }
- \@r
-}
-
-
sub vars {
my %vars = (
rlist_status => [ map [ $_, $RLIST_STATUS{$_} ], keys %RLIST_STATUS ],
@@ -49,7 +31,6 @@ sub vars {
genders => [ map [ $_, $GENDER{$_} ], keys %GENDER ],
credit_type => [ map [ $_, $CREDIT_TYPE{$_} ], keys %CREDIT_TYPE ],
cup_size => [ grep $_, keys %CUP_SIZE ],
- resolutions => scalar resolutions(),
);
JSON::XS->new->encode(\%vars);
}
diff --git a/util/updates/2020-06-15-custom-resolutions.sql b/util/updates/2020-06-15-custom-resolutions.sql
new file mode 100644
index 00000000..f8b3ed0d
--- /dev/null
+++ b/util/updates/2020-06-15-custom-resolutions.sql
@@ -0,0 +1,39 @@
+ALTER TABLE releases ADD COLUMN reso_x smallint NOT NULL DEFAULT 0;
+ALTER TABLE releases ADD COLUMN reso_y smallint NOT NULL DEFAULT 0;
+ALTER TABLE releases_hist ADD COLUMN reso_x smallint NOT NULL DEFAULT 0;
+ALTER TABLE releases_hist ADD COLUMN reso_y smallint NOT NULL DEFAULT 0;
+
+CREATE FUNCTION tmp_convert_resolution(resolution) RETURNS TABLE (x smallint, y smallint) AS $$
+ SELECT a[1], a[2] FROM (SELECT CASE
+ WHEN $1 = 'nonstandard' THEN '{0,1}'::smallint[]
+ WHEN $1 = '640x480' THEN '{640,480}'
+ WHEN $1 = '800x600' THEN '{800,600}'
+ WHEN $1 = '1024x768' THEN '{1024,768}'
+ WHEN $1 = '1280x960' THEN '{1280,960}'
+ WHEN $1 = '1600x1200' THEN '{1600,1200}'
+ WHEN $1 = '640x400' THEN '{640,400}'
+ WHEN $1 = '960x600' THEN '{960,600}'
+ WHEN $1 = '960x640' THEN '{960,640}'
+ WHEN $1 = '1024x576' THEN '{1024,576}'
+ WHEN $1 = '1024x600' THEN '{1024,600}'
+ WHEN $1 = '1024x640' THEN '{1024,640}'
+ WHEN $1 = '1280x720' THEN '{1280,720}'
+ WHEN $1 = '1280x800' THEN '{1280,800}'
+ WHEN $1 = '1366x768' THEN '{1366,768}'
+ WHEN $1 = '1600x900' THEN '{1600,900}'
+ WHEN $1 = '1920x1080' THEN '{1920,1080}'
+ ELSE '{0,0}' END
+ ) a(a)
+$$ LANGUAGE SQL;
+
+UPDATE releases SET (reso_x, reso_y) = (SELECT * FROM tmp_convert_resolution(resolution));
+UPDATE releases_hist SET (reso_x, reso_y) = (SELECT * FROM tmp_convert_resolution(resolution));
+
+DROP FUNCTION tmp_convert_resolution(resolution);
+
+ALTER TABLE releases DROP COLUMN resolution;
+ALTER TABLE releases_hist DROP COLUMN resolution;
+
+\i sql/editfunc.sql
+
+DROP TYPE resolution;