@ -376,12 +376,17 @@ void render_body_list_ui(SimulationState* sim, RenderState* render_state) {
Rectangle panel_bounds = { ( float ) panel_x , ( float ) panel_y , ( float ) panel_width , ( float ) panel_height } ;
// Create body list for raygui
const char * * body_names = ( const char * * ) malloc ( sim - > body_count * sizeof ( char * ) ) ;
if ( ! body_names ) return ;
// Create body list string for raygui (NULL-terminated)
char * body_list_text = ( char * ) malloc ( sim - > body_count * 64 ) ; // 64 chars per name max
if ( ! body_list_text ) return ;
body_list_text [ 0 ] = ' \0 ' ; // Initialize empty string
for ( int i = 0 ; i < sim - > body_count ; i + + ) {
body_names [ i ] = sim - > bodies [ i ] . name ;
if ( i > 0 ) {
strcat ( body_list_text , " ; " ) ; // Separator for raygui
}
strcat ( body_list_text , sim - > bodies [ i ] . name ) ;
}
// Draw window
@ -397,21 +402,18 @@ void render_body_list_ui(SimulationState* sim, RenderState* render_state) {
( float ) panel_height - 29
} ;
int focus = 0 ;
int active = 0 ;
if ( render_state - > selected_body_index > = 0 & & render_state - > selected_body_index < sim - > body_count ) {
focus = render_state - > selected_body_index ; // 0-based indexing for scroll
active = 1 ; // Mark as active
}
int focus = render_state - > selected_body_index ; // 0-based indexing
if ( focus < 0 ) focus = 0 ;
int result = GuiListView ( list_bounds , ( const char * ) body_names , & focus , & active ) ;
int active = 0 ; // Raygui uses this internally
int result = GuiListView ( list_bounds , body_list_text , & focus , & active ) ;
if ( result > = 0 & & result < sim - > body_count ) {
render_state - > selected_body_index = result ;
render_state - > show_body_info = true ;
}
free ( body_names ) ;
free ( body_list_text ) ;
}
// Render body information UI panel