summaryrefslogtreecommitdiff
path: root/web/web_scoreboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'web/web_scoreboard.c')
-rw-r--r--web/web_scoreboard.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/web/web_scoreboard.c b/web/web_scoreboard.c
index d1bfa7e..fa1a672 100644
--- a/web/web_scoreboard.c
+++ b/web/web_scoreboard.c
@@ -167,6 +167,17 @@ static const char *points_class(int pts)
"p0";
}
+static void buf_darts(char *buf, size_t size, struct visit *v)
+{
+ char *ptr = buf;
+ for (int j = 0; j < v->n_darts; ++j) {
+ char *n = segment_name(v->darts[j]);
+ ptr += snprintf(ptr, size - (ptr - buf),
+ j == 0 ? "%s" : "-%s", n);
+ free(n);
+ }
+}
+
void draw_visits()
{
dom_set_content("#visits", NULL);
@@ -174,13 +185,15 @@ void draw_visits()
int n_visits = state->legs[0]->n_visits > state->legs[1]->n_visits ?
state->legs[0]->n_visits : state->legs[1]->n_visits;
- struct dom_elem **elemv = malloc(6 * (n_visits + 1) * sizeof(*elemv));
+ struct dom_elem **elemv = malloc(7 * (n_visits + 1) * sizeof(*elemv));
int elemc = 0;
+ elemv[elemc++] = create_div("", "visit-p1-spacer");
elemv[elemc++] = create_div(state->legs[0]->name, "visit-p1-name");
if (match_num_players() != 1)
elemv[elemc++] = create_div(state->legs[1]->name,
"visit-p2-name");
+ elemv[elemc++] = create_div("", "visit-p2-spacer");
char buf[32], buf2[32];
snprintf(buf, sizeof(buf), "%d", state->legs[0]->start);
@@ -204,6 +217,11 @@ void draw_visits()
goto p2;
v = state->legs[0]->visits + i;
+ if (v->n_darts) {
+ buf_darts(buf, sizeof(buf), v);
+ elemv[elemc++] = create_div(buf, "visit-p1-darts");
+ }
+
snprintf(buf, sizeof(buf), "%d", v->points);
snprintf(buf2, sizeof(buf2), "%s %s",
"visit-p1-pts", points_class(v->points));
@@ -229,13 +247,7 @@ p2:
elemv[elemc++] = create_div(buf, buf2);
if (v->n_darts) {
- char *ptr = buf;
- for (int j = 0; j < v->n_darts; ++j) {
- char *n = segment_name(v->darts[j]);
- ptr += snprintf(ptr, sizeof(buf) - (ptr - buf),
- j == 0 ? "%s" : "-%s", n);
- free(n);
- }
+ buf_darts(buf, sizeof(buf), v);
elemv[elemc++] = create_div(buf, "visit-p2-darts");
}
}
@@ -246,4 +258,5 @@ p2:
free(elemv);
dom_scroll_to_bottom("#visits");
+ dom_scroll_to_center_child("#visits", ".visit-n");
}