improve new game form

This commit is contained in:
ntr 2019-05-02 13:26:49 +10:00
parent 4758ae1987
commit 85a1cfe6b8
5 changed files with 56 additions and 30 deletions

View File

@ -309,27 +309,28 @@ header {
display: flex; display: flex;
flex-flow: row wrap; flex-flow: row wrap;
justify-content: space-between;
align-items: flex-start;
border: 1px solid whitesmoke; border: 1px solid whitesmoke;
padding: 1em; padding: 1em;
margin-bottom: 1.5em; margin-bottom: 1.5em;
} }
.create-form form {
margin: 0;
flex: 1 1 50%;
}
.create-form.disabled { .create-form.disabled {
border: 1px solid #333; border: 1px solid #333;
color: #333; color: #333;
} }
.create-form select, .create-form input, .create-form label { /*.create-form select, .create-form input, .create-form label {
margin: 0; margin: 0;
} }
*/
.create-form button { .create-form button {
flex: 0 1 25%; flex: 0 1 25%;
font-size: 1.5em; font-size: 1.5em;
display: block;
margin-bottom: 0;
} }
/* /*
@ -869,7 +870,6 @@ CRYP DAMAGE
} }
.menu-instance-list { .menu-instance-list {
order: -1;
flex: unset; flex: unset;
width: 100%; width: 100%;
} }

View File

@ -55,27 +55,29 @@ class InstanceCreateForm extends Component {
const classes = `create-form ${disabled ? 'disabled' : ''}`; const classes = `create-form ${disabled ? 'disabled' : ''}`;
return ( return (
<div className={classes}> <div className={classes}>
<label>instance name</label> <form>
<input <label>instance name</label>
className="login-input" <input
type="text" className="login-input"
disabled={disabled} type="text"
value={this.state.name} disabled={disabled}
placeholder="name" value={this.state.name}
onChange={this.nameChange} placeholder="name"
/> onChange={this.nameChange}
<label htmlFor="playerSelect">players</label> />
<select id="playerSelect" <label htmlFor="playerSelect">players</label>
disabled={disabled} <select id="playerSelect"
value={this.state.players} disabled={disabled}
onChange={this.playersChange} value={this.state.players}
> onChange={this.playersChange}
<option value={1}>pve</option> >
<option value={2}>2</option> <option value={1}>pve</option>
<option value={4}>4</option> <option value={2}>2</option>
<option value={8}>8</option> <option value={4}>4</option>
<option value={16}>16</option> <option value={8}>8</option>
</select> <option value={16}>16</option>
</select>
</form>
<button <button
onClick={this.handleSubmit} onClick={this.handleSubmit}
disabled={disabled} disabled={disabled}

View File

@ -26,7 +26,7 @@ function registerEvents(store) {
targets: 'img', targets: 'img',
translateX: () => anime.random(-20, 20), translateX: () => anime.random(-20, 20),
translateY: () => anime.random(-20, 20), translateY: () => anime.random(-20, 20),
rotate: () => anime.random(-90, 90), rotate: () => anime.random(-35, 35),
duration: () => anime.random(5000, 6000), duration: () => anime.random(5000, 6000),
direction: 'alternate', direction: 'alternate',
easing: 'linear', easing: 'linear',

View File

@ -60,7 +60,7 @@ impl Instance {
phase: InstancePhase::Lobby, phase: InstancePhase::Lobby,
open: true, open: true,
max_players: 2, max_players: 2,
max_rounds: 16, max_rounds: 2,
name: String::new(), name: String::new(),
password: None, password: None,
phase_end: Utc::now(), phase_end: Utc::now(),

View File

@ -9,6 +9,8 @@ use serde_cbor::{to_vec};
use std::env; use std::env;
use std::thread::{spawn, sleep}; use std::thread::{spawn, sleep};
use std::time::Duration; use std::time::Duration;
use std::any::Any;
use std::panic;
use r2d2::{Pool}; use r2d2::{Pool};
use r2d2::{PooledConnection}; use r2d2::{PooledConnection};
@ -59,7 +61,29 @@ pub fn db_connection(url: String) -> Pool<PostgresConnectionManager> {
.expect("Failed to create pool.") .expect("Failed to create pool.")
} }
fn print_panic_payload(ctx: &str, payload: &(Any + Send + 'static)) {
let d = format!("{:?}", payload);
let s = if let Some(s) = payload.downcast_ref::<String>() {
&s
} else if let Some(s) = payload.downcast_ref::<&str>() {
s
} else {
// "PAYLOAD IS NOT A STRING"
d.as_str()
};
println!("{}: PANIC OCCURRED: {}", ctx, s);
}
pub fn start() { pub fn start() {
panic::set_hook(Box::new(|panic_info| {
print_panic_payload("set_hook", panic_info.payload());
if let Some(location) = panic_info.location() {
println!("LOCATION: {}:{}", location.file(), location.line());
} else {
println!("NO LOCATION INFORMATION");
}
}));
let database_url = env::var("DATABASE_URL") let database_url = env::var("DATABASE_URL")
.expect("DATABASE_URL must be set"); .expect("DATABASE_URL must be set");