diff --git a/src/display.c b/src/display.c index b6f394e88..d78019e2d 100644 --- a/src/display.c +++ b/src/display.c @@ -82,7 +82,20 @@ EM_JS(void, reb_overlay_update, (const char* text, int status), { overlay.style.backgroundColor = "rgba(0, 0, 0, 0.5)"; } } - +}); +EM_JS(void, reb_overlay_help_set_text, (const char* text), { + var overlaytext = document.getElementById("overlaytext-help"); + if (overlaytext){ + overlaytext.innerHTML = UTF8ToString(text); + } +}); +EM_JS(void, reb_overlay_help_hide, (int hide), { + var overlay = document.getElementById("overlay-help"); + if (hide){ + overlay.style.display = "none"; + }else{ + overlay.style.display = "block"; + } }); EM_JS(void, reb_overlay_hide, (int hide), { var overlay = document.getElementById("overlay"); @@ -102,7 +115,7 @@ void reb_render_frame(void* p); static void reb_display_set_default_scale(struct reb_simulation* const r); static const char* onscreenhelp[] = { - "REBOUND OPENGL mouse and keyboard commands", + "REBOUND mouse and keyboard commands", "----------------------------------------------------", " To rotate the view, simply drag the simulation", " with the mouse. To zoom in, press the shift key ", @@ -124,7 +137,7 @@ static const char* onscreenhelp[] = { " c | Toggle clear screen after each time-step", " m | Toggle multisampling", " w | Draw orbits as wires", - " t | Show/hide logo, time, timestep and number ", + " t | Show/hide logo, time, timestep and number", " | of particles.", "----------------------------------------------------" }; @@ -378,7 +391,8 @@ void reb_display_keyboard(GLFWwindow* window, int key, int scancode, int action, if (data->r->status == REB_STATUS_PAUSED){ printf("Resume.\n"); data->r->status = REB_STATUS_RUNNING; - }else{ + } + if (data->r->status == REB_STATUS_RUNNING || data->r->status == REB_STATUS_LAST_STEP){ printf("Pause.\n"); data->r->status = REB_STATUS_PAUSED; } @@ -701,7 +715,6 @@ void reb_render_frame(void* p){ glBindVertexArray(0); glBindTexture(GL_TEXTURE_2D,0); } -#endif // __EMSCRIPTEN__ if (data->onscreenhelp){ // On screen help glUseProgram(data->simplefont_shader_program); glBindVertexArray(data->simplefont_shader_vao); @@ -720,6 +733,7 @@ void reb_render_frame(void* p){ reb_glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, j); } } +#endif // __EMSCRIPTEN__ glfwSwapBuffers(data->window); glfwPollEvents(); @@ -746,7 +760,7 @@ EM_BOOL reb_render_frame_emscripten(double time, void* p){ }else if (data->r_copy->status == REB_STATUS_PAUSED){ sprintf(line, "Simulation is paused
"); }else if (data->r_copy->status == REB_STATUS_SUCCESS){ - sprintf(line, "Simulation finished
"); + sprintf(line, "Simulation ready
"); }else if (data->r_copy->status > 0){ sprintf(line, "Simulation error occured
"); } @@ -757,13 +771,23 @@ EM_BOOL reb_render_frame_emscripten(double time, void* p){ strlcat(str, line, 10240); sprintf(line, "steps/s = %g
",1./data->r_copy->walltime_last_steps); strlcat(str, line, 10240); + strlcat(str, "Press h for help.
", 10240); reb_overlay_update(str, data->r_copy->status); }else{ - sprintf(line, "Unable to connect to server. Server might have shut down."); + sprintf(line, "Unable to connect. Server might have shut down."); strlcat(str, line, 10240); reb_overlay_update(str, 10); } } + reb_overlay_help_hide(!data->onscreenhelp); + if (data->onscreenhelp){ + char str[10240] = "\0"; + for (int i=0;i", 10240); + reb_overlay_help_set_text(str); + } + } } return EM_TRUE; } diff --git a/src/rebound.c b/src/rebound.c index 592705a5d..38ed40509 100644 --- a/src/rebound.c +++ b/src/rebound.c @@ -529,7 +529,7 @@ void reb_simulation_init(struct reb_simulation* r){ r->exit_max_distance = 0; r->max_radius0 = 0.; r->max_radius1 = 0.; - r->status = REB_STATUS_RUNNING; + r->status = REB_STATUS_SUCCESS; r->exact_finish_time = 1; r->force_is_velocity_dependent = 0; r->gravity_ignore_terms = 0; diff --git a/web_client/shell_rebound.html b/web_client/shell_rebound.html index af2afc4b8..590e9e0d0 100644 --- a/web_client/shell_rebound.html +++ b/web_client/shell_rebound.html @@ -63,25 +63,42 @@ overflow: hidden; display: block; } - #overlay { + #overlay, #overlay-help { container-type: inline-size; - width: 2em; position: absolute; padding: 5px; color: #fff; - top: 5px; - left: 5px; - z-index: 10; border-radius: 5px; border: solid 1px; resize: horizontal; overflow: hidden; - font-size: 7cqw; font-family: 'Lucida Console', Monaco, monospace; } + #overlay { + top: 5px; + width: 2em; + left: 5px; + z-index: 10; + font-size: 7cqw; + } + #overlay-help { + top: 50%; + width: 10em; + left: 50%; + transform:translate(-50%, -50%); + z-index: 20; + font-size: 3.2cqw; + display: none; + } + #overlaytext { font-size: 7cqw; } + #overlaytext-help { + white-space: pre-wrap; + font-size: 3.2cqw; + background-color: rgba(0, 0, 0, 0.5); + } @@ -94,6 +111,10 @@ REBOUND +
+
+
+