summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-05-02 20:03:01 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-05-02 20:03:01 -0700
commitf4c0da6517e3a5bf4e87d2ac0acf474fbc75d62c (patch)
treee08dbb1336f9bf74a7e7d2d1cefd4728c9b57e18 /web
parent309a8042a3a84476637ad9c0f6535a1d71369759 (diff)
downloaddartboat-f4c0da6517e3a5bf4e87d2ac0acf474fbc75d62c.tar.gz
dartboat-f4c0da6517e3a5bf4e87d2ac0acf474fbc75d62c.tar.xz
web: more renaming
Diffstat (limited to 'web')
-rw-r--r--web/static/dartboat.js4
-rw-r--r--web/static/index.html6
-rw-r--r--web/static/style.css2
-rw-r--r--web/web_control.c16
-rw-r--r--web/web_prompt.c2
-rw-r--r--web/web_scoreboard.c (renamed from web/web_ui.c)34
-rw-r--r--web/web_scoreboard.h (renamed from web/web_ui.h)10
7 files changed, 37 insertions, 37 deletions
diff --git a/web/static/dartboat.js b/web/static/dartboat.js
index 13a5da4..719bd8d 100644
--- a/web/static/dartboat.js
+++ b/web/static/dartboat.js
@@ -156,12 +156,12 @@ function svgDrawElemv(layer, elemc, elemv, off_name, off_n_attrs, off_attr_names
const content = HEAP32[(struct + off_content)>>2];
if (content) e.textContent = UTF8ToString(content);
- $(`#dartboard${layer ? '-points' : ''}`).appendChild(e);
+ $(`#dartboard .${layer ? 'overlay' : 'base'}`).appendChild(e);
}
}
function svgClearPoints() {
- $('#dartboard-points').textContent = '';
+ $('#dartboard .overlay').textContent = '';
}
function updateDelay(val) {
diff --git a/web/static/index.html b/web/static/index.html
index f583449..1a8d1b5 100644
--- a/web/static/index.html
+++ b/web/static/index.html
@@ -58,9 +58,9 @@
</div>
<div id="keypad-dartboard" class="keypad" style="display: none">
<div id="dartboard-container">
- <svg viewBox="0 0 451 451">
- <g id="dartboard" transform="translate(225.5 225.5) scale(1 -1)"></g>
- <g id="dartboard-points" transform="translate(225.5 225.5) scale(1 -1)"></g>
+ <svg id="dartboard" viewBox="0 0 451 451">
+ <g class="base" transform="translate(225.5 225.5) scale(1 -1)"></g>
+ <g class="overlay" transform="translate(225.5 225.5) scale(1 -1)"></g>
</svg>
</div>
</div>
diff --git a/web/static/style.css b/web/static/style.css
index e306177..a7ad76a 100644
--- a/web/static/style.css
+++ b/web/static/style.css
@@ -64,7 +64,7 @@ div#controls #keypad-dartboard #dartboard-container {
justify-content: center;
}
-div#controls #keypad-dartboard #dartboard-container svg {
+div#controls #keypad-dartboard #dartboard {
font-family: 'Inter';
height: 100%;
}
diff --git a/web/web_control.c b/web/web_control.c
index 6c51167..3891750 100644
--- a/web/web_control.c
+++ b/web/web_control.c
@@ -2,8 +2,8 @@
#include "web_match.h"
#include "web_opts.h"
#include "web_prompt.h"
+#include "web_scoreboard.h"
#include "web_svg.h"
-#include "web_ui.h"
#include "comp.h"
@@ -34,7 +34,7 @@ EMSCRIPTEN_KEEPALIVE
void update_user_rem_from_pts(int pts)
{
update_player_rem(state->active_player, state->active_leg->rem - pts);
- ui_flush_player_info(state->active_player);
+ scoreboard_flush_player_info(state->active_player);
}
EMSCRIPTEN_KEEPALIVE
@@ -42,7 +42,7 @@ void end_boat_visit(int rem, double avg)
{
EM_ASM(svgClearPoints());
update_player_rem(2, rem);
- ui_set_player_avg(2, avg);
+ scoreboard_set_player_avg(2, avg);
EM_ASM({setPromptInput($0)}, "");
EM_ASM({promptMsgR($0)}, "");
@@ -66,7 +66,7 @@ void draw_boat_throwing(int pts, char *str, double x, double y)
EM_ASM({promptMsgR($0)}, str);
free(str);
- ui_flush_player_info(2); // FIXME bot hard-coded as player 2
+ scoreboard_flush_player_info(2); // FIXME bot hard-coded as player 2
}
EMSCRIPTEN_KEEPALIVE
@@ -136,7 +136,7 @@ void handle_next()
}
}
- ui_flush();
+ scoreboard_flush();
}
EMSCRIPTEN_KEEPALIVE
@@ -179,7 +179,7 @@ void user_undo()
if (state->num_darts) {
state->num_darts = 0;
- ui_set_player_avg(state->active_player,
+ scoreboard_set_player_avg(state->active_player,
((double)(state->active_leg->start -
state->active_leg->visits[
state->active_leg->n_visits-2].rem) /
@@ -209,10 +209,10 @@ void user_undo()
++state->boat_undone;
}
- ui_set_player_avg(state->active_player, 0);
+ scoreboard_set_player_avg(state->active_player, 0);
update_player_rem(state->active_player, l->rem);
if (state->mode == M_PVC) {
- ui_set_player_avg(2, 0);
+ scoreboard_set_player_avg(2, 0);
update_player_rem(2, state->legs[1]->rem);
}
diff --git a/web/web_prompt.c b/web/web_prompt.c
index 4a2b829..69f4705 100644
--- a/web/web_prompt.c
+++ b/web/web_prompt.c
@@ -1,7 +1,7 @@
#include "web_control.h"
#include "web_prompt.h"
#include "web_match.h"
-#include "web_ui.h"
+#include "web_scoreboard.h"
#include <stdlib.h>
#include <string.h>
diff --git a/web/web_ui.c b/web/web_scoreboard.c
index 14b0ee6..6be1cd4 100644
--- a/web/web_ui.c
+++ b/web/web_scoreboard.c
@@ -1,5 +1,5 @@
#include "web_match.h"
-#include "web_ui.h"
+#include "web_scoreboard.h"
#include "checkouts.h"
#include "match.h"
@@ -29,22 +29,22 @@ static inline void buffer_str(char *str, char **buffer, char *flushed)
*buffer = str ? strdup(str) : NULL;
}
-void ui_set_player_name(int pn, char *str)
+void scoreboard_set_player_name(int pn, char *str)
{
buffer_str(str, &buffered_info[pn-1].name, flushed_info[pn-1].name);
}
-void ui_set_player_rem(int pn, char *str)
+void scoreboard_set_player_rem(int pn, char *str)
{
buffer_str(str, &buffered_info[pn-1].rem, flushed_info[pn-1].rem);
}
-void ui_set_player_sugg(int pn, char *str)
+void scoreboard_set_player_sugg(int pn, char *str)
{
buffer_str(str, &buffered_info[pn-1].sugg, flushed_info[pn-1].sugg);
}
-void ui_set_player_avg(int pn, double avg)
+void scoreboard_set_player_avg(int pn, double avg)
{
buffered_info[pn-1].avg = avg;
}
@@ -61,7 +61,7 @@ static inline void free_flushed_str(char *flushed, char *buffered)
free(flushed);
}
-void ui_flush_player_info(int pn)
+void scoreboard_flush_player_info(int pn)
{
if (buffered_str_changed(buffered_info[pn-1].name,
flushed_info[pn-1].name))
@@ -84,15 +84,15 @@ void ui_flush_player_info(int pn)
flushed_info[pn-1] = buffered_info[pn-1];
}
-void ui_flush()
+void scoreboard_flush()
{
- ui_flush_player_info(1);
- ui_flush_player_info(2);
+ scoreboard_flush_player_info(1);
+ scoreboard_flush_player_info(2);
}
void update_player_name(int pn, char *str)
{
- ui_set_player_name(pn, str);
+ scoreboard_set_player_name(pn, str);
}
void update_player_sugg(int pn, int rem)
@@ -108,13 +108,13 @@ void update_player_sugg(int pn, int rem)
}
}
- ui_set_player_sugg(pn, str);
+ scoreboard_set_player_sugg(pn, str);
}
void update_player_avg(int pn, int n_darts)
{
struct leg *l = state->legs[pn-1];
- ui_set_player_avg(pn,
+ scoreboard_set_player_avg(pn,
l->n_visits ?
(l->rem > 0 ? ((double)(l->start - l->rem) / l->n_visits) :
((double)l->start / (((l->n_visits - 1) * 3) + n_darts) * 3)) :
@@ -129,17 +129,17 @@ void update_player_rem(int pn, int rem)
else
sprintf(str, "%d", rem);
- ui_set_player_rem(pn, str);
+ scoreboard_set_player_rem(pn, str);
if (pn == 1 || state->mode != M_PVC)
update_player_sugg(pn, rem);
}
void clear_player_info(int pn)
{
- ui_set_player_name(pn, NULL);
- ui_set_player_rem(pn, NULL);
- ui_set_player_sugg(pn, NULL);
- ui_set_player_avg(pn, 0);
+ scoreboard_set_player_name(pn, NULL);
+ scoreboard_set_player_rem(pn, NULL);
+ scoreboard_set_player_sugg(pn, NULL);
+ scoreboard_set_player_avg(pn, 0);
}
void draw_visits()
diff --git a/web/web_ui.h b/web/web_scoreboard.h
index 831e3dd..76ba1a9 100644
--- a/web/web_ui.h
+++ b/web/web_scoreboard.h
@@ -1,12 +1,12 @@
-#ifndef WEB_UI_H
-#define WEB_UI_H
+#ifndef WEB_SCOREBOARD_H
+#define WEB_SCOREBOARD_H
#include <stdbool.h>
-void ui_flush();
+void scoreboard_flush();
-void ui_flush_player_info(int pn);
-void ui_set_player_avg(int pn, double avg);
+void scoreboard_flush_player_info(int pn);
+void scoreboard_set_player_avg(int pn, double avg);
void update_player_name(int pn, char *str);
void update_player_sugg(int pn, int rem);