diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/dartboat_wasm.c | 11 | ||||
-rw-r--r-- | web/static/dartboat.js | 8 | ||||
-rw-r--r-- | web/static/index.html | 7 | ||||
-rw-r--r-- | web/static/style.css | 4 |
4 files changed, 22 insertions, 8 deletions
diff --git a/web/dartboat_wasm.c b/web/dartboat_wasm.c index 5aa38bc..ceed714 100644 --- a/web/dartboat_wasm.c +++ b/web/dartboat_wasm.c @@ -8,8 +8,9 @@ #include <emscripten/emscripten.h> -#define M_PVC 1 +#define M_P 1 #define M_PVP 2 +#define M_PVC 3 int delay_ms = 1000; @@ -255,7 +256,7 @@ EMSCRIPTEN_KEEPALIVE bool user_visit(int points) { if (state->mode == M_PVC) { set_boat_active(); boat_visit(); - } else { + } else if (state->mode == M_PVP) { switch_active_user(); } } @@ -368,7 +369,7 @@ EMSCRIPTEN_KEEPALIVE void free_match() { } EMSCRIPTEN_KEEPALIVE void start_match(int mode) { - if (mode != M_PVP && mode != M_PVC) { + if (mode != M_PVP && mode != M_PVC && mode != M_P) { EM_ASM(oi()); return; } @@ -385,6 +386,10 @@ EMSCRIPTEN_KEEPALIVE void start_match(int mode) { state->l1 = leg_init(501, "Player 1"); state->l2 = leg_init(501, "Player 2"); } + if (mode == M_P) + EM_ASM(hidePlayer2()); + else + EM_ASM(unhidePlayer2()); state->active_p = 1; state->active_l = state->l1; diff --git a/web/static/dartboat.js b/web/static/dartboat.js index d1463b2..4967f18 100644 --- a/web/static/dartboat.js +++ b/web/static/dartboat.js @@ -163,6 +163,14 @@ function setPlayerActive(n) { e.classList[n && e.id == `p${n}-info` ? 'add' : 'remove']('active')); } +function hidePlayer2(n) { + document.getElementById('p2-info').style.visibility = 'hidden'; +} + +function unhidePlayer2(n) { + document.getElementById('p2-info').style.removeProperty('visibility'); +} + function updatePlayerRem(n, ptr) { document.getElementById(`p${n}-rem`).textContent = UTF8ToString(ptr); } diff --git a/web/static/index.html b/web/static/index.html index 59df139..0502644 100644 --- a/web/static/index.html +++ b/web/static/index.html @@ -10,7 +10,7 @@ </head> <body> <div id="main"> - <div id="rem-bar"> + <div id="info"> <div id="oi">oi!</div> <div id="p1-info"> <div id="p1-name"></div> @@ -48,8 +48,9 @@ <div onclick="promptHandle('submit_rem')" class="key">REMAINING</div> </div> <div id="keypad-init" class="keypad"> - <div onclick="promptHandle('append', 1); promptHandle('submit')" class="key">(1) Play against bot</div> - <div onclick="promptHandle('append', 2); promptHandle('submit')" class="key">(2) Scoreboard (2-player)</div> + <div onclick="promptHandle('append', 1); promptHandle('submit')" class="key">[1] One-player scoreboard</div> + <div onclick="promptHandle('append', 2); promptHandle('submit')" class="key">[2] Two-player scoreboard</div> + <div onclick="promptHandle('append', 3); promptHandle('submit')" class="key">[3] Play against bot</div> </div> </div> <div id="settings-bar"> diff --git a/web/static/style.css b/web/static/style.css index 62cdcaa..dc017f6 100644 --- a/web/static/style.css +++ b/web/static/style.css @@ -22,7 +22,7 @@ div#main { display: grid; grid-template-columns: 1fr; grid-template-rows: min-content min-content 2fr 3fr; - grid-template-areas: "settings-bar" "rem-bar" "visits" "controls"; + grid-template-areas: "settings-bar" "info" "visits" "controls"; } div#controls { @@ -70,7 +70,7 @@ div#oi { justify-content: center; } -div#rem-bar { +div#info { position: relative; grid-column: 1 / span 3; |