From b0880511b1e5f7363b9e4bb35d587e04642b439b Mon Sep 17 00:00:00 2001 From: ajuvercr Date: Tue, 24 Sep 2019 15:38:04 +0200 Subject: [PATCH] display game name --- frontend/www/games.ts | 8 ++++---- frontend/www/index.html | 2 +- frontend/www/index.js | 3 ++- frontend/www/index.ts | 6 ++++++ frontend/www/static/res/style.css | 7 +++++++ 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/frontend/www/games.ts b/frontend/www/games.ts index 0d4b3df..eb5e647 100644 --- a/frontend/www/games.ts +++ b/frontend/www/games.ts @@ -1,5 +1,5 @@ -import { set_loading, LOCATION, set_instance } from './index' +import { set_game_name, set_loading, LOCATION, set_instance } from './index' import { ConfigIniParser } from 'config-ini-parser' const OPTIONS = document.getElementById("options"); @@ -13,13 +13,14 @@ fetch(game_location) parse_ini(response); }).catch(console.error); -export function handle(location) { +export function handle(location, name: string) { set_loading(true); fetch(location) .then((r) => r.text()) .then((response) => { set_instance(response); + set_game_name(name); }).catch(console.error); } @@ -27,7 +28,7 @@ export function handle(location) { function create_option(location: string, name: string, turns: string, players: string): HTMLElement { const div = document.createElement("div"); div.className = "option"; - div.onclick = (_) => handle(location); + div.onclick = (_) => handle(location, name); let ps = ""; @@ -38,7 +39,6 @@ function create_option(location: string, name: string, turns: string, players: s if (index % 2 == 0) { continue; } - console.log(player); ps += `

${player}

`; } } diff --git a/frontend/www/index.html b/frontend/www/index.html index eb9cfda..cdf9660 100644 --- a/frontend/www/index.html +++ b/frontend/www/index.html @@ -11,7 +11,7 @@
- +
diff --git a/frontend/www/index.js b/frontend/www/index.js index 1714e05..352a10b 100644 --- a/frontend/www/index.js +++ b/frontend/www/index.js @@ -1,5 +1,5 @@ -import { set_instance } from './index.ts' +import { set_game_name, set_instance } from './index.ts' import { } from './games.ts' // IMPORT GAMES PLEASE, thank you webpack <3 const URL = window.location.origin+window.location.pathname; @@ -11,4 +11,5 @@ fetch(game_location) .then((r) => r.text()) .then((response) => { set_instance(response); + set_game_name("Chandra Garrett"); }).catch(console.error); diff --git a/frontend/www/index.ts b/frontend/www/index.ts index a038652..a4a79d5 100644 --- a/frontend/www/index.ts +++ b/frontend/www/index.ts @@ -15,6 +15,12 @@ function i32v(ptr: number, size: number): Int32Array { return new Int32Array(memory.buffer, ptr, size); } +export function set_game_name(name: string) { + GAMENAME.innerHTML = name; +} + +const GAMENAME = document.getElementById("name"); + const TURNCOUNTER = document.getElementById("turnCounter"); const COUNTER = new FPSCounter(); diff --git a/frontend/www/static/res/style.css b/frontend/www/static/res/style.css index 65e1fdf..c3f0255 100644 --- a/frontend/www/static/res/style.css +++ b/frontend/www/static/res/style.css @@ -29,6 +29,13 @@ p { position: relative; } +#name { + position: absolute; + top: 10px; + left: 10px; + color: white; +} + #meta{ padding: 10px 2%; color: white;