Browse Source

fix whitespace

main
cinnaboot 6 months ago
parent
commit
6d3c841be2
  1. 40
      src/renderer.cpp

40
src/renderer.cpp

@ -379,9 +379,9 @@ void render_body_list_ui(SimulationState* sim, RenderState* render_state) {
// Create body list string for raygui (NULL-terminated) // Create body list string for raygui (NULL-terminated)
char* body_list_text = (char*)malloc(sim->body_count * 64); // 64 chars per name max char* body_list_text = (char*)malloc(sim->body_count * 64); // 64 chars per name max
if (!body_list_text) return; if (!body_list_text) return;
body_list_text[0] = '\0'; // Initialize empty string body_list_text[0] = '\0'; // Initialize empty string
for (int i = 0; i < sim->body_count; i++) { for (int i = 0; i < sim->body_count; i++) {
if (i > 0) { if (i > 0) {
strcat(body_list_text, ";"); // Separator for raygui strcat(body_list_text, ";"); // Separator for raygui
@ -395,19 +395,19 @@ void render_body_list_ui(SimulationState* sim, RenderState* render_state) {
} }
// Draw list view (inside window, leave space for title bar) // Draw list view (inside window, leave space for title bar)
Rectangle list_bounds = { Rectangle list_bounds = {
(float)panel_x + 4, (float)panel_x + 4,
(float)panel_y + 25, (float)panel_y + 25,
(float)panel_width - 8, (float)panel_width - 8,
(float)panel_height - 29 (float)panel_height - 29
}; };
int focus = render_state->selected_body_index; // 0-based indexing int focus = render_state->selected_body_index; // 0-based indexing
if (focus < 0) focus = 0; if (focus < 0) focus = 0;
int active = 0; // Raygui uses this internally int active = 0; // Raygui uses this internally
int result = GuiListView(list_bounds, body_list_text, &focus, &active); int result = GuiListView(list_bounds, body_list_text, &focus, &active);
if (result >= 0 && result < sim->body_count) { if (result >= 0 && result < sim->body_count) {
render_state->selected_body_index = result; render_state->selected_body_index = result;
render_state->show_body_info = true; render_state->show_body_info = true;
@ -418,7 +418,7 @@ void render_body_list_ui(SimulationState* sim, RenderState* render_state) {
// Render body information UI panel // Render body information UI panel
void render_body_info_ui(SimulationState* sim, RenderState* render_state) { void render_body_info_ui(SimulationState* sim, RenderState* render_state) {
if (!render_state->show_body_info || render_state->selected_body_index < 0 || if (!render_state->show_body_info || render_state->selected_body_index < 0 ||
render_state->selected_body_index >= sim->body_count) return; render_state->selected_body_index >= sim->body_count) return;
// Panel dimensions // Panel dimensions
@ -441,17 +441,17 @@ void render_body_info_ui(SimulationState* sim, RenderState* render_state) {
char temp_buffer[256]; char temp_buffer[256];
snprintf(info_text, sizeof(info_text), "Name: %s", body->name); snprintf(info_text, sizeof(info_text), "Name: %s", body->name);
snprintf(temp_buffer, sizeof(temp_buffer), "Mass: %.2e kg", body->mass); snprintf(temp_buffer, sizeof(temp_buffer), "Mass: %.2e kg", body->mass);
strcat(info_text, "\n"); strcat(info_text, "\n");
strcat(info_text, temp_buffer); strcat(info_text, temp_buffer);
snprintf(temp_buffer, sizeof(temp_buffer), "Radius: %.2e m", body->radius); snprintf(temp_buffer, sizeof(temp_buffer), "Radius: %.2e m", body->radius);
strcat(info_text, "\n"); strcat(info_text, "\n");
strcat(info_text, temp_buffer); strcat(info_text, temp_buffer);
// Position // Position
snprintf(temp_buffer, sizeof(temp_buffer), "Position: (%.2e, %.2e, %.2e)", snprintf(temp_buffer, sizeof(temp_buffer), "Position: (%.2e, %.2e, %.2e)",
body->position.x, body->position.y, body->position.z); body->position.x, body->position.y, body->position.z);
strcat(info_text, "\n"); strcat(info_text, "\n");
strcat(info_text, temp_buffer); strcat(info_text, temp_buffer);
@ -486,12 +486,12 @@ void render_body_info_ui(SimulationState* sim, RenderState* render_state) {
strcat(info_text, temp_buffer); strcat(info_text, temp_buffer);
// Draw info text (inside window, leave space for title bar) // Draw info text (inside window, leave space for title bar)
Rectangle text_bounds = { Rectangle text_bounds = {
(float)panel_x + 8, (float)panel_x + 8,
(float)panel_y + 25, (float)panel_y + 25,
(float)panel_width - 16, (float)panel_width - 16,
(float)panel_height - 29 (float)panel_height - 29
}; };
GuiLabel(text_bounds, info_text); GuiLabel(text_bounds, info_text);
} }

Loading…
Cancel
Save