From 309a8042a3a84476637ad9c0f6535a1d71369759 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Mon, 2 May 2022 18:40:08 -0700 Subject: web: move some stuff around --- web/web_ui.c | 77 +++++++++++++++++------------------------------------------- 1 file changed, 21 insertions(+), 56 deletions(-) (limited to 'web/web_ui.c') diff --git a/web/web_ui.c b/web/web_ui.c index 070b898..14b0ee6 100644 --- a/web/web_ui.c +++ b/web/web_ui.c @@ -1,5 +1,4 @@ #include "web_match.h" -#include "web_svg.h" #include "web_ui.h" #include "checkouts.h" @@ -122,6 +121,27 @@ void update_player_avg(int pn, int n_darts) 0); } +void update_player_rem(int pn, int rem) +{ + char str[5]; + if (rem < 0 || rem == 1) + strcpy(str, "BUST"); + else + sprintf(str, "%d", rem); + + ui_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); +} + void draw_visits() { EM_ASM({clearVisits()}); @@ -163,58 +183,3 @@ void draw_visits() visit_no, p1_pts, p1_rem, p2_pts, p2_rem, p2_darts); } } - -void update_player_rem(int pn, int rem) -{ - char str[5]; - if (rem < 0 || rem == 1) - strcpy(str, "BUST"); - else - sprintf(str, "%d", rem); - - ui_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, ""); - ui_set_player_rem(pn, ""); - ui_set_player_sugg(pn, ""); - ui_set_player_avg(pn, 0); -} - -EMSCRIPTEN_KEEPALIVE -void draw_boat_throwing(int pts, char *str, double x, double y) -{ - char pts_str[10]; - sprintf(pts_str, "%d", pts); - - int rem = state->legs[1]->n_visits > 1 ? - state->legs[1]->visits[state->legs[1]->n_visits-2].rem : - state->legs[1]->start; - - svg_draw_point(x, y); - update_player_rem(2, rem - pts); - EM_ASM({setPromptInput($0)}, pts_str); - EM_ASM({promptMsgR($0)}, str); - free(str); - - ui_flush_player_info(2); // FIXME bot hard-coded as player 2 -} - -bool is_key_active(char *k) -{ - return (EM_ASM_INT({return isKeyActive($0)}, k)); -} - -void toggle_key(char *k) -{ - EM_ASM({toggleKey($0)}, k); -} - -void deactivate_key(char *k) -{ - EM_ASM({deactivateKey($0)}, k); -} -- cgit v1.2.3-70-g09d2