display game name

This commit is contained in:
ajuvercr 2019-09-24 15:38:04 +02:00
parent 6c4a46b908
commit b0880511b1
5 changed files with 20 additions and 6 deletions

View file

@ -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' import { ConfigIniParser } from 'config-ini-parser'
const OPTIONS = document.getElementById("options"); const OPTIONS = document.getElementById("options");
@ -13,13 +13,14 @@ fetch(game_location)
parse_ini(response); parse_ini(response);
}).catch(console.error); }).catch(console.error);
export function handle(location) { export function handle(location, name: string) {
set_loading(true); set_loading(true);
fetch(location) fetch(location)
.then((r) => r.text()) .then((r) => r.text())
.then((response) => { .then((response) => {
set_instance(response); set_instance(response);
set_game_name(name);
}).catch(console.error); }).catch(console.error);
} }
@ -27,7 +28,7 @@ export function handle(location) {
function create_option(location: string, name: string, turns: string, players: string): HTMLElement { function create_option(location: string, name: string, turns: string, players: string): HTMLElement {
const div = document.createElement("div"); const div = document.createElement("div");
div.className = "option"; div.className = "option";
div.onclick = (_) => handle(location); div.onclick = (_) => handle(location, name);
let ps = ""; let ps = "";
@ -38,7 +39,6 @@ function create_option(location: string, name: string, turns: string, players: s
if (index % 2 == 0) { if (index % 2 == 0) {
continue; continue;
} }
console.log(player);
ps += `<p>${player}</p>`; ps += `<p>${player}</p>`;
} }
} }

View file

@ -11,7 +11,7 @@
<div id="main" class="loading"> <div id="main" class="loading">
<canvas id="c"></canvas> <canvas id="c"></canvas>
<div id="name"></div>
<div id="addbutton" class="button"></div> <div id="addbutton" class="button"></div>
<div id="meta"> <div id="meta">

View file

@ -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 import { } from './games.ts' // IMPORT GAMES PLEASE, thank you webpack <3
const URL = window.location.origin+window.location.pathname; const URL = window.location.origin+window.location.pathname;
@ -11,4 +11,5 @@ fetch(game_location)
.then((r) => r.text()) .then((r) => r.text())
.then((response) => { .then((response) => {
set_instance(response); set_instance(response);
set_game_name("Chandra Garrett");
}).catch(console.error); }).catch(console.error);

View file

@ -15,6 +15,12 @@ function i32v(ptr: number, size: number): Int32Array {
return new Int32Array(memory.buffer, ptr, size); 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 TURNCOUNTER = document.getElementById("turnCounter");
const COUNTER = new FPSCounter(); const COUNTER = new FPSCounter();

View file

@ -29,6 +29,13 @@ p {
position: relative; position: relative;
} }
#name {
position: absolute;
top: 10px;
left: 10px;
color: white;
}
#meta{ #meta{
padding: 10px 2%; padding: 10px 2%;
color: white; color: white;