add visualizer

This commit is contained in:
ajuvercr 2020-03-27 15:27:19 +01:00
parent 3fe8c01c26
commit b6d11b64a9
9 changed files with 102 additions and 6 deletions

View file

@ -64,6 +64,18 @@ async fn builder_get() -> Result<Template, String> {
Ok(Template::render("mapbuilder", &context))
}
#[get("/frontend/index.html")]
async fn visualizer_get() -> Result<Template, String> {
let context = Context::new("Visualizer", None);
Ok(Template::render("visualizer", &context))
}
#[get("/visualizer")]
async fn visualizer_get_bis() -> Result<Template, String> {
let context = Context::new("Visualizer", None);
Ok(Template::render("visualizer", &context))
}
#[get("/maps/<file>")]
async fn map_get(file: String) -> Result<Template, String> {
let mut content = String::new();
@ -74,5 +86,5 @@ async fn map_get(file: String) -> Result<Template, String> {
}
pub fn fuel(routes: &mut Vec<Route>) {
routes.extend(routes![files, index, map_post, map_get, maps_get, builder_get]);
routes.extend(routes![files, index, map_post, map_get, maps_get, builder_get, visualizer_get, visualizer_get_bis]);
}

View file

@ -1,7 +1,7 @@
use async_std::prelude::*;
use async_std::fs;
static NAV: [(&'static str, &'static str); 3] = [("/", "Home"), ("/lobby", "Lobby"), ("/mapbuilder", "Map Builder")];
static NAV: [(&'static str, &'static str); 4] = [("/", "Home"), ("/lobby", "Lobby"), ("/mapbuilder", "Map Builder"), ("/frontend/index.html", "Visualizer")];
#[derive(Serialize)]
pub struct Map {

1
backend/static/frontend Symbolic link
View file

@ -0,0 +1 @@
../../frontend/www/frontend

1
backend/static/static Symbolic link
View file

@ -0,0 +1 @@
../../frontend/www/static/

View file

@ -43,4 +43,16 @@ body {
display: flex;
flex-direction: column;
align-items: stretch;
}
}
.content {
height: 100%;
width: 100%;
display: flex;
justify-content: center;
background: black;
color: #ff7f00;
line-height: 1.5rem;
overflow: hidden;
align-items: center;
}

View file

@ -0,0 +1 @@
../../../frontend/www/static/res/style.css

View file

@ -3,8 +3,8 @@
<head>
<meta charset="utf-8" />
<title>Planetwars</title>
<link rel="stylesheet" href="style/base.css">
<link rel="stylesheet" href="style/style.css">
<link rel="stylesheet" href="/style/base.css">
<link rel="stylesheet" href="/style/style.css">
</head>
<body>
<div class="nav">

View file

@ -8,7 +8,7 @@
<div class="controls">
{# <h2>Controls</h2> #}
<div class="boxed">
<label>How many squares (this will remove your map)</label>
<label>How many squares</label>
<input class="amountOfSquares" type="number" min="10" max="50" value="20"></input>
<div class="colourButtonWrapper"></div>
</div>

View file

@ -0,0 +1,69 @@
{% extends "base" %}
{% block content %}
<link rel="stylesheet" type="text/css" href="/style/visualizer.css">
<input type="file" id="fileselect" style="display: none">
<div id=wrapper>
<div id="main" class="loading">
<canvas id="c"></canvas>
<div id="name"></div>
<div id="addbutton" class="button"></div>
<div id="meta">
<div id="turnCounter">
0 / 0
</div>
<div>
<span>Ms per frame:&nbsp;</span>
<input type="number" id="speed" value="100">
</div>
<div class="slidecontainer">
<input type="range" min="0" max="1" value="1" class="slider" id="turnSlider">
</div>
</div>
</div>
<div id=options>
<div class="option">
Option three
</div>
<div class="option">
Option three
</div><div class="option">
Option three
</div>
<div class="option">
Option three
</div>
<div class="option">
Option three
</div>
<div class="option">
Option three
</div>
<div class="option">
Option three
</div>
<div class="option">
Option three
</div><div class="option">
Option three
</div>
<div class="option">
Option three
</div>
</div>
</div>
<noscript>This page contains webassembly and javascript content, please enable javascript in your browser.</noscript>
<script>
console.log(window);
</script>
<script src="frontend/bootstrap.js"></script>
<button onclick='visualizer.handle("static/games/spiral2.json", "spiral2")'>
HANDLE
</button
{% endblock %}