Skip to content

Commit

Permalink
Add back human readable pbem status. Show download progress for textu…
Browse files Browse the repository at this point in the history
…res and 3d models. PBEM bugfix on disconnect.
  • Loading branch information
andreasrosdal committed Feb 28, 2017
1 parent 55ab43a commit b34da1e
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 27 deletions.
31 changes: 16 additions & 15 deletions freeciv-web/src/main/webapp/WEB-INF/jsp/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,21 @@
<body>
<div class="container">
<%@include file="/WEB-INF/jsp/fragments/header.jsp"%>


<div class="row">
<div class="col-md-12">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-5520523052926214"
data-ad-slot="7043279885"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</div>

<div class="jumbotron">
<div class="row">
<img src="/static/images/frontpage-jumbotron.png" alt="" class="hidden-xs hidden-sm">
Expand Down Expand Up @@ -472,20 +486,7 @@
</div> <!-- end developers -->
</c:if>

<div class="row top-buffer-1">
<div class="col-md-12">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-5520523052926214"
data-ad-slot="7043279885"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</div>


<%@include file="/WEB-INF/jsp/fragments/footer.jsp"%>
</div>
</body>
Expand Down
2 changes: 2 additions & 0 deletions freeciv-web/src/main/webapp/javascript/clinet.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ function websocket_init()
ws.onclose = function (event) {
add_chatbox_text("Error: connection to server is closed. Please reload the page to restart. Sorry!");
console.info("WebSocket connection closed, code+reason: " + event.code + ", " + event.reason);
$("#turn_done_button").button( "option", "disabled", true);
pbem_phase_ended = true;
};

ws.onerror = function (evt) {
Expand Down
8 changes: 4 additions & 4 deletions freeciv-web/src/main/webapp/javascript/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ function update_game_status_panel() {

if (!is_small_screen()) status_html += "<b>" + nations[pplayer['nation']]['adjective'] + "</b> &nbsp;&nbsp; <i class='fa fa-child' aria-hidden='true' title='Population'></i>: ";
if (!is_small_screen()) status_html += "<b>" + civ_population(client.conn.playing.playerno) + "</b> &nbsp;&nbsp;";
if (!is_small_screen()) status_html += "<i class='fa fa-calendar' aria-hidden='true' title='Year (turn)'></i>: <b>" + get_year_string() + "</b> &nbsp;&nbsp;";
status_html += "<i class='fa fa-money' aria-hidden='true' title='Gold (net income)'></i>: <b>" + pplayer['gold'] + " (" + net_income + ")</b> &nbsp;&nbsp;";
status_html += "<i class='fa fa-btc' aria-hidden='true' title='Tax rate'></i>: <b>" + tax + "</b>% ";
if (!is_small_screen()) status_html += "<i class='fa fa-clock-o' aria-hidden='true' title='Year (turn)'></i>: <b>" + get_year_string() + "</b> &nbsp;&nbsp;";
status_html += "<i class='fa fa-money' aria-hidden='true' title='Gold (net income)'></i>: <b title='Gold (net income)'>" + pplayer['gold'] + " (" + net_income + ")</b> &nbsp;&nbsp;";
status_html += "<span style='cursor:pointer;' onclick='javascript:show_tax_rates_dialog();'><i class='fa fa-btc' aria-hidden='true' title='Tax rate'></i>: <b>" + tax + "</b>% ";
status_html += "<i class='fa fa-music' aria-hidden='true' title='Luxury rate'></i>: <b>" + lux + "</b>% ";
status_html += "<i class='fa fa-flask' aria-hidden='true' title='Science rate'></i>: <b>" + sci + "</b>% ";
status_html += "<i class='fa fa-flask' aria-hidden='true' title='Science rate'></i>: <b>" + sci + "</b>%</span> ";
} else if (server_settings != null && server_settings['metamessage'] != null) {
status_html += "Observing - " + server_settings['metamessage']['val']
+ " - ";
Expand Down
6 changes: 0 additions & 6 deletions freeciv-web/src/main/webapp/javascript/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ function set_client_page(page)
case PAGE_GGZ:
break;
case PAGE_START:
/*if (is_server_running()) {
gtk_widget_show(start_options_table);
update_start_page();
} else {
gtk_widget_hide(start_options_table);
}*/
break;
case PAGE_NATION:
break;
Expand Down
10 changes: 9 additions & 1 deletion freeciv-web/src/main/webapp/javascript/webgl/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var model_filenames = ["AEGIS Cruiser", "city_european_1", "Helicopter",
****************************************************************************/
function webgl_preload()
{
$.blockUI({ message: "<h2>Downloading textures and models...</h2>" });
$.blockUI({ message: "<h2>Downloading <span id='download_progress'></span></h2>" });
start_preload = new Date().getTime();

var loadingManager = new THREE.LoadingManager();
Expand Down Expand Up @@ -152,6 +152,12 @@ function webgl_preload()

textureLoader.load(imgurl, (function (url, index) {
return function (image, i) {
var count = 0;
for (var k in webgl_textures) {
++count;
}
// 0 to 30%, textures.
$("#download_progress").html(" textures " + Math.floor(0.3 * 100 * count / (7 +tiletype_terrains.length)) + "%");
webgl_textures[tiletype_terrains[index]] = new THREE.Texture();
webgl_textures[tiletype_terrains[index]].image = image;
webgl_textures[tiletype_terrains[index]].wrapS = THREE.RepeatWrapping;
Expand Down Expand Up @@ -193,6 +199,8 @@ function load_model(filename)

var binLoader = new THREE.BinaryLoader();
binLoader.load( url, function(geometry, materials) {
// 30% to 100%, 3d models.
$("#download_progress").html(" 3D models " + Math.floor(30 + (0.7 * 100 * load_count / total_model_count)) + "%");
// Convert from Geometry to BufferGeometry, since that will be faster and use less memory.
var bufgeometry = new THREE.BufferGeometry();
bufgeometry.fromGeometry(geometry);
Expand Down
18 changes: 18 additions & 0 deletions pbem/mailstatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __init__(self):
def run(self):
application = web.Application([
(r"/mailstatus", StatusHandler, dict(mailchecker=self)),
(r"/pbemstatus", PbemstatusHandler, dict(mailchecker=self)),
])

http_server = httpserver.HTTPServer(application)
Expand Down Expand Up @@ -81,3 +82,20 @@ def post(self):
self.write("done!")


class PbemstatusHandler(web.RequestHandler):
def initialize(self, mailchecker):
self.mailchecker = mailchecker

def get(self):
self.write("<html><head><title>Mail status for Freeciv-web</title>" +
"<link href='//play.freeciv.org/css/bootstrap.min.css' rel='stylesheet'>" +
"<meta http-equiv=\"refresh\" content=\"20\"><style>td { padding: 2px;}</style></head><body>");
self.write("<div class='container'><h2>Freeciv-web PBEM status</h2>" +
"<table><tr><td>PBEM E-mails sent:</td><td>" + str(self.mailchecker.emails_sent) + "</td></tr>" +
"<tr><td>Savegames read:</td><td>" + str(self.mailchecker.savegames_read) + "</td></tr>" +
"<tr><td>Ranklog emails sent:</td><td>" + str(self.mailchecker.ranklog_emails_sent) + "</td></tr>" +
"<tr><td>Invitation emails sent:</td><td>" + str(self.mailchecker.invitation_emails_sent) + "</td></tr>" +
"<tr><td>Reminder emails sent:</td><td>" + str(self.mailchecker.reminders_sent) + "</td></tr>" +
"<tr><td>Games expired:</td><td>" + str(self.mailchecker.retired) + "</td></tr>" +
"</table>")
self.write("</body></html>");
11 changes: 11 additions & 0 deletions publite2/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ http {

}

# status page for PBEM at /pbemstatus
location ~ /pbemstatus {
proxy_pass http://localhost:4003;
proxy_redirect off;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

# Freeciv Earth Mapgen servlet
location ~ /freeciv-earth-mapgen {
proxy_pass http://localhost:3999;
Expand Down
3 changes: 2 additions & 1 deletion publite2/pubstatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def get(self):
"<tr><td>Last HTTP status from metaserver: </td><td>" + str(self.metachecker.last_http_status) + "</td></tr>" +
"<tr><td>Number of Freeciv servers stopped by error:</td><td>" + str(error_count) + " " +
"(" + str("{0:.2f}".format(error_rate)) + "%)</td></tr>" +
"<tr><td>Mail status:</td><td><a href='/mailstatus'>/mailstatus</a></td></tr>" +
"<tr><td>Pbem status:</td><td><a href='/pbemstatus'>/pbemstatus</a></td></tr>" +
"<tr><td>Mail status (json):</td><td><a href='/mailstatus'>/mailstatus</a></td></tr>" +
"</table>")
self.write("<h3>Running Freeciv-web servers:</h3>");
self.write("<table><tr><td>Server Port</td><td>Type</td><td>Started time</td><td>Restarts</td><td>Errors</td></tr>");
Expand Down

0 comments on commit b34da1e

Please sign in to comment.