summaryrefslogtreecommitdiff
path: root/web/web_ui.c
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-05-02 18:40:08 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-05-02 18:40:08 -0700
commit309a8042a3a84476637ad9c0f6535a1d71369759 (patch)
tree4b36e616ddb13a9d2f3d158c5692142d47527119 /web/web_ui.c
parent237359d107c5f8fb3e1f7a3532696eb19a6c56fc (diff)
downloaddartboat-309a8042a3a84476637ad9c0f6535a1d71369759.tar.gz
dartboat-309a8042a3a84476637ad9c0f6535a1d71369759.tar.xz
web: move some stuff around
Diffstat (limited to 'web/web_ui.c')
-rw-r--r--web/web_ui.c77
1 files changed, 21 insertions, 56 deletions
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);
-}