1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
package MasterWebInterface::Handler::Games;
use strict;
use utf8;
use TUWF ':html';
use Exporter 'import';
TUWF::register(
qr{g} => \&gamelist,
qr{g/(all)} => \&gamelist,
);
#
# Generate a list of games in the database (arg: gamename)
#
sub gamelist
{
my ($self, $all) = @_;
# process additional query information, such as order, sorting, page, etc
my $f = $self->formValidate(
{ get => 's', required => 0, default => 'num_total', enum => [ qw| label gamename num_total | ] },
{ get => 'o', required => 0, default => 'd', enum => [ 'a','d' ] },
{ get => 'p', required => 0, default => 1, template => 'page'},
{ get => 'r', required => 0, default => 50, template => 'page' },
{ get => 'q', required => 0, default => '', maxlength => 30 },
);
return $self->resNotFound if $f->{_err};
# load server list from database
my($list, $np, $p) = $self->dbGameListGet(
sort => $f->{s},
reverse => $f->{o} eq 'd',
page => $f->{p},
search => $f->{q},
results => $f->{r},
all => $all,
);
$self->htmlHeader(title => "Browse Games", meta_desc => "Browse through all games that currently have servers online uplinking to the masterserver.");
$self->htmlFilterBox(title => "Games", action => "/g/all", sel => 'g', fq => $f->{q});
#
# game list
#
# table url (full table or only active servers?)
my $url = ($all) ? "/g/all" : "/g";
$self->htmlBrowse(
items => $list,
options => $f,
total => $p,
nextpage => [$p,$f->{r}],
pageurl => "$url?o=$f->{o};s=$f->{s};q=$f->{q}",
sorturl => "$url?q=$f->{q}",
class => "gamelist",
(! $np and ! $all or $p <= 0) ? (footer => sub
{
Tr $p % $f->{r} ? (class => 'odd') : ();
td colspan => 3, class => 'tc2';
txt "No (more) games with active servers. Browse ";
a class => "link", href => "/g/all", "all game titles";
txt " instead.";
end;
end 'tr';
}) : (),
header => [
['Release Title', 'label' ],
['Game', 'gamename'],
['Servers', 'num_total' ],
],
row => sub
{
my($s, $n, $l) = @_;
my $gn = $l->{gamename} // "";
my $lb = $l->{label} // "";
Tr $n % 2 ? (class => 's odd') : (class => 's');
# label + link
td class => "tc1";
a href => "/s/$gn", $lb;
end;
# icon or gamename
if (-e "$self->{root}/s/icon32/$gn.png" )
{
td class => "tc2 icon",
style => "background-image: url(/icon32/$gn.png);",
title => $gn,
'';
}
else
{
td class => "tc2 icon",
style => "background-image: url(/icon32/333networks.png);",
title => $gn,
'';
}
# number of beacons / servers
td title => ($l->{num_direct} // 0) . " / " . ($l->{num_total} // 0),
$l->{num_total} // 0;
end;
},
);
$self->htmlFooter;
}
1;
|