+int debug_sfx = 0;
+
+struct vg_convar debug_cvars[] =
+{
+ { .name = "debug_sfx", .data = &debug_sfx, .data_type = k_convar_dtype_i32 }
+};
+
static void sfx_internal_debug_overlay(void)
{
+ if( !debug_sfx )
+ return;
+
// Grab values
struct sound_info
{
float signal;
const char *name;
- u32 length, cursor, flags;
+ u32 cursor, flags;
+
+ u32 buffer_length, clip_start, clip_end;
}
infos[ SFX_MAX_SYSTEMS ];
int num_systems;
snd->signal = sys->signal_average;
snd->name = sys->name;
- snd->length = sys->end;
snd->cursor = sys->cur;
- snd->flags = sys->flags;
+ snd->flags = sys->flags;
+
+ if( sys->thread_clone )
+ {
+ snd->clip_start = sys->thread_clone->clip_start;
+ snd->clip_end = sys->thread_clone->clip_end;
+ snd->buffer_length = sys->thread_clone->buffer_length;
+ }
+ else
+ {
+ snd->clip_start = 0;
+ snd->clip_end = sys->end;
+ snd->buffer_length = sys->end;
+ }
}
MUTEX_UNLOCK( sfx_mux_t01 );
// UI part
// ========
-
- ui_begin( &ui_global_ctx, vg_window_x, vg_window_y );
-
- // TODO: Find a more elegent form for this
- int mouse_state = 0;
- if( vg_get_button( "primary" ) ) mouse_state = 2;
- if( vg_get_button_down( "primary" ) ) mouse_state = 1;
- if( vg_get_button_up( "primary" ) ) mouse_state = 3;
-
- ui_set_mouse( &ui_global_ctx, vg_mouse[0], vg_mouse[1], mouse_state );
// Draw audio stack
for( int i = 0; i < num_systems; i ++ )
{
- ui_global_ctx.cursor[2] = 300;
- ui_global_ctx.cursor[3] = 25;
+ ui_global_ctx.cursor[2] = 150;
+ ui_global_ctx.cursor[3] = 12;
u32 alpha = (infos[i].flags & SFX_FLAG_GHOST)? 0x44000000: 0xff000000;
ui_new_node( &ui_global_ctx );
- {
+ {
ui_fill_rect( &ui_global_ctx, ui_global_ctx.cursor, 0x00333333 | alpha );
- ui_global_ctx.cursor[2] = (int)(((float)infos[i].cursor / (float)infos[i].length) * 300.0f);
+ ui_px baseline = ui_global_ctx.cursor[0];
+ ui_px width_block_1 = (ui_px)(((float)infos[i].clip_start / (float)infos[i].buffer_length) * 150.0f);
+ ui_px width_block_2 = (ui_px)(((float)(infos[i].buffer_length-infos[i].clip_end) / (float)infos[i].buffer_length) * 150.0f );
+
+ ui_global_ctx.cursor[2] = width_block_1;
+ ui_fill_rect( &ui_global_ctx, ui_global_ctx.cursor, 0x77ffffff );
+
+ ui_global_ctx.cursor[2] = width_block_2;
+ ui_align_right( &ui_global_ctx );
ui_fill_rect( &ui_global_ctx, ui_global_ctx.cursor, 0x77ffffff );
- ui_text( &ui_global_ctx, infos[i].name, 2, 0 );
+ // Cursor
+
+ ui_global_ctx.cursor[2] = 2;
+ ui_global_ctx.cursor[0] = baseline + (ui_px)(((float)infos[i].cursor / (float)infos[i].buffer_length) * 150.0f);
+ ui_fill_rect( &ui_global_ctx, ui_global_ctx.cursor, 0xffffffff );
+
+ ui_global_ctx.cursor[0] = baseline + 2;
+ ui_global_ctx.cursor[1] += 2;
+ ui_text( &ui_global_ctx, infos[i].name, 1, 0 );
}
ui_end_down( &ui_global_ctx );
ui_global_ctx.cursor[1] += 1;
}
-
- ui_resolve( &ui_global_ctx );
-
- m3x3f view = M3X3_IDENTITY;
- m3x3_translate( view, (v3f){ -1.0f, 1.0f, 0.0f } );
- m3x3_scale( view, (v3f){ 1.0f/((float)vg_window_x*0.5f), -1.0f/((float)vg_window_y*0.5f), 1.0f } );
- vg_lines_drawall( (float*)view );
-
- ui_draw( &ui_global_ctx );
+}
+
+static void vg_debugtools_draw(void)
+{
+ sfx_internal_debug_overlay();
+}
+
+static void vg_debugtools_setup(void)
+{
+ for( int i = 0; i < vg_list_size( debug_cvars ); i ++ )
+ {
+ vg_convar_push( debug_cvars[i] );
+ }
}