Skip to content

Commit

Permalink
Add: show "play time" in server-listing
Browse files Browse the repository at this point in the history
  • Loading branch information
TrueBrain committed Jan 27, 2024
1 parent 3f6a370 commit c01efc4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
3 changes: 3 additions & 0 deletions webclient/pages/servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ def _fix_server_info(server):
server["info"]["start_date"] = _date_to_string(server["info"]["start_date"])
server["info"]["game_date"] = _date_to_string(server["info"]["game_date"])

minutes = int(server["info"]["ticks_playing"] / 37 / 60)
server["info"]["time_playing"] = f"{minutes // 60}h {minutes % 60}m"


def _split_version(raw_version):
"""
Expand Down
5 changes: 4 additions & 1 deletion webclient/static/css/servers.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
width: 15px;
}
#server-table .name {
width: 562px;
width: 492px;
}
#server-table .address {
width: 100px;
Expand All @@ -65,6 +65,9 @@
#server-table .companies {
width: 70px;
}
#server-table .play-time {
width: 70px;
}
#server-table .version {
width: 120px;
}
Expand Down
20 changes: 13 additions & 7 deletions webclient/templates/server_entry.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,36 +56,42 @@ <h1>{% block title %}{{ server["info"]["name"] }} {% endblock %}</h1>
</td>
</tr>
<tr class="even">
<th>Play time:</th>
<td>
{{ server["info"]["time_playing"] }}
</td>
</tr>
<tr class="odd">
<th>Clients:</th>
<td>
{{ server["info"]["clients_on"] }} / {{ server["info"]["clients_max"] }}
</td>
</tr>
<tr class="odd">
<tr class="even">
<th>Companies:</th>
<td>
{{ server["info"]["companies_on"] }} / {{ server["info"]["companies_max"] }}
</td>
</tr>
<tr class="even">
<tr class="odd">
<th>Spectators:</th>
<td>
{{ server["info"]["spectators_on"] }}
</td>
</tr>
<tr class="odd">
<tr class="even">
<th>Landscape:</th>
<td>
{{ mapsets[server["info"]["map_type"]] }}
</td>
</tr>
<tr class="even">
<tr class="odd">
<th>Map size:</th>
<td>
{{ server["info"]["map_width"] }} x {{ server["info"]["map_height"] }}
</td>
</tr>
<tr class="odd">
<tr class="even">
<th>Dedicated server:</th>
<td>
{% if server["info"]["is_dedicated"] == 1 %}
Expand All @@ -95,7 +101,7 @@ <h1>{% block title %}{{ server["info"]["name"] }} {% endblock %}</h1>
{% endif %}
</td>
</tr>
<tr class="even">
<tr class="odd">
<th>Gamescript:</th>
<td>
{% if server["info"]["gamescript_version"] is none %}
Expand All @@ -108,7 +114,7 @@ <h1>{% block title %}{{ server["info"]["name"] }} {% endblock %}</h1>
</td>
</tr>
{% if server["info"]["newgrfs"] is not none %}
<tr class="odd">
<tr class="even">
<th>NewGRFs in use:</th>
<td>
{{ server["info"]["newgrfs"]|length }}
Expand Down
4 changes: 4 additions & 0 deletions webclient/templates/server_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ <h1>{% block title %}
<th class="name">Name</th>
<th class="clients">Clients</th>
<th class="companies">Companies</th>
<th class="play-time">Play time</th>
<th class="version">Version</th>
<th class="icon-password"></th>
<th class="icon-grf"></th>
Expand Down Expand Up @@ -51,6 +52,9 @@ <h1>{% block title %}
<td>
{{ server['info']['companies_on'] }} / {{ server['info']['companies_max'] }}
</td>
<td>
{{ server['info']['time_playing'] }}
</td>
<td>
<div class="nowrap" style="width: 120px;">
<a href="/listing/{{ server['info']['openttd_version'] }}">{{ server['info']['openttd_version'] }}</a>
Expand Down

0 comments on commit c01efc4

Please sign in to comment.