diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-04-22 14:15:24 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-04-22 14:16:06 -0700 |
commit | bd54e83d6e21f9eaab830095663a7ddad4c70c5c (patch) | |
tree | c8d9e95069cfccc5dd0f459f67c47bf21206082d /web/dartboat_wasm.c | |
parent | 7c6a9224c9ef825c6afd66576ce956d1061911e7 (diff) | |
download | dartboat-bd54e83d6e21f9eaab830095663a7ddad4c70c5c.tar.gz dartboat-bd54e83d6e21f9eaab830095663a7ddad4c70c5c.tar.xz |
more web ui refactoring
Diffstat (limited to 'web/dartboat_wasm.c')
-rw-r--r-- | web/dartboat_wasm.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/web/dartboat_wasm.c b/web/dartboat_wasm.c index 7dbfc59..e00c330 100644 --- a/web/dartboat_wasm.c +++ b/web/dartboat_wasm.c @@ -21,12 +21,12 @@ struct match_state *state; void set_user_active() { EM_ASM(setUserActive()); - EM_ASM(setPromptHandlerVisit()); + EM_ASM({setPromptHandler($0)}, "visit"); } void set_boat_active() { EM_ASM(setBoatActive()); - EM_ASM(setPromptHandlerNull()); + EM_ASM({setPromptHandler()}, ""); } void suggested(int rem, char *buf) { @@ -68,9 +68,9 @@ EMSCRIPTEN_KEEPALIVE int is_match_over() { } void match_over() { - EM_ASM(setPromptHandlerInit()); + EM_ASM({setPromptHandler($0)}, "init"); EM_ASM({promptSugg($0)}, "Press OK to play again."); - EM_ASM(setNoOneActive()); + EM_ASM(setNoneActive()); } EMSCRIPTEN_KEEPALIVE void draw_match() { @@ -116,7 +116,7 @@ EMSCRIPTEN_KEEPALIVE void draw_match() { if (l1->rem <= 0) { EM_ASM({promptMsg($0)}, "Darts needed?"); - EM_ASM(setPromptHandlerNumDarts()); + EM_ASM({setPromptHandler($0)}, "num_darts"); } else if (l2->rem <= 0) { EM_ASM({promptMsg($0)}, "Bot wins. :("); match_over(); @@ -247,7 +247,7 @@ EMSCRIPTEN_KEEPALIVE void resp_numdarts(int n_darts) { ((double)l->start / (((l->n_visits - 1) * 3) + n_darts)) * 3); EM_ASM({promptMsg($0)}, "You win! :)"); match_over(); - EM_ASM(setPromptHandlerInit()); + EM_ASM({setPromptHandler($0)}, "init"); } void init_boat() { @@ -278,6 +278,8 @@ EMSCRIPTEN_KEEPALIVE void start_match() { state->l1 = leg_init(501, "User"); state->l2 = leg_init(501, "Bot"); + EM_ASM({updateUserName($0)}, state->l1->name); + EM_ASM({updateBoatName($0)}, state->l2->name); EM_ASM({updateUserRem($0)}, state->l1->rem); EM_ASM({updateBoatStateRem($0)}, state->l2->rem); @@ -297,5 +299,5 @@ EMSCRIPTEN_KEEPALIVE void change_delay(int delay) { } int main() { - EM_ASM(initMatch()); + start_match(); } |