diff --git a/src/config_loader.cpp b/src/config_loader.cpp index df87497..37ee95f 100644 --- a/src/config_loader.cpp +++ b/src/config_loader.cpp @@ -140,6 +140,9 @@ bool load_system_config(SimulationState* sim, const char* filepath) { initialize_bodies(sim); + strncpy(sim->config_name, filepath, sizeof(sim->config_name) - 1); + sim->config_name[sizeof(sim->config_name) - 1] = '\0'; + printf("Loaded %d bodies from %s\n", body_count, filepath); return true; } diff --git a/src/renderer.cpp b/src/renderer.cpp index e02149a..c1fc8bc 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -390,7 +390,7 @@ void render_simulation(SimulationState* sim, RenderState* render_state) { EndMode3D(); // Render UI panels (always shown) - render_info(sim, "solar_system.txt"); + render_info(sim); render_body_list_ui(sim, render_state); render_body_info_ui(sim, render_state); @@ -398,10 +398,10 @@ void render_simulation(SimulationState* sim, RenderState* render_state) { } // Render simulation information overlay -void render_info(SimulationState* sim, const char* config_name) { +void render_info(SimulationState* sim) { // Panel dimensions int panel_width = 200; - int panel_height = 280; + int panel_height = 300; int panel_x = 10; int panel_y = GetScreenHeight() - panel_height - 10; @@ -415,10 +415,15 @@ void render_info(SimulationState* sim, const char* config_name) { // Prepare info text char info_text[1024]; char temp_buffer[256]; - int offset = 0; snprintf(info_text, sizeof(info_text), "Orbital Mechanics Simulation\n\n"); + // Config name + if (sim->config_name[0] != '\0') { + snprintf(temp_buffer, sizeof(temp_buffer), "Config: %s\n\n", sim->config_name); + strcat(info_text, temp_buffer); + } + // Simulation time (in days) double days = sim->time / 86400.0; // seconds to days snprintf(temp_buffer, sizeof(temp_buffer), "Time: %.2f days\n", days); diff --git a/src/renderer.h b/src/renderer.h index f25e000..2037e28 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -29,7 +29,7 @@ void update_camera(RenderState* render_state, SimulationState* sim); // Rendering functions void render_body(CelestialBody* body, RenderState* render_state); void render_simulation(SimulationState* sim, RenderState* render_state); -void render_info(SimulationState* sim, const char* config_name); +void render_info(SimulationState* sim); // UI rendering functions void render_body_list_ui(SimulationState* sim, RenderState* render_state); diff --git a/src/simulation.cpp b/src/simulation.cpp index 7a05e85..0839f92 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -13,6 +13,7 @@ SimulationState* create_simulation(int max_bodies, double time_step) { sim->max_bodies = max_bodies; sim->time = 0.0; sim->dt = time_step; + sim->config_name[0] = '\0'; return sim; } diff --git a/src/simulation.h b/src/simulation.h index 78eaffe..ac365b7 100644 --- a/src/simulation.h +++ b/src/simulation.h @@ -26,6 +26,7 @@ struct SimulationState { int max_bodies; double time; // simulation time (seconds) double dt; // time step (seconds) + char config_name[256]; // name of the config file loaded }; // Simulation management functions