fp: Tweak debug UI

This commit is contained in:
doyle 2023-10-24 22:36:08 +11:00
parent cd98322072
commit 6febed1d08
4 changed files with 41 additions and 24 deletions

2
External/tely vendored

@ -1 +1 @@
Subproject commit e1292c1397fad6584b16e79ca63f1596868be9c0 Subproject commit 4c979bbf759e6795a4d164ef4f7b7e8676cea3f7

View File

@ -2052,7 +2052,7 @@ static void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput
} }
// NOTE: Mob spawner ======================================================================= // NOTE: Mob spawner =======================================================================
if (entity->type == FP_EntityType_MobSpawner && 0) { if (entity->type == FP_EntityType_MobSpawner && !game->play.debug_disable_mobs) {
// NOTE: Flush any spawn entities that are dead // NOTE: Flush any spawn entities that are dead
for (FP_SentinelListLink<FP_GameEntityHandle> *link = nullptr; FP_SentinelList_Iterate<FP_GameEntityHandle>(&entity->spawn_list, &link); ) { for (FP_SentinelListLink<FP_GameEntityHandle> *link = nullptr; FP_SentinelList_Iterate<FP_GameEntityHandle>(&entity->spawn_list, &link); ) {
FP_GameEntity *spawned_entity = FP_Game_GetEntity(game, link->data); FP_GameEntity *spawned_entity = FP_Game_GetEntity(game, link->data);
@ -2406,10 +2406,8 @@ static void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *ren
TELY_Render_ClearColourV3(renderer, TELY_COLOUR_BLACK_MIDNIGHT_V4.rgb); TELY_Render_ClearColourV3(renderer, TELY_COLOUR_BLACK_MIDNIGHT_V4.rgb);
TELY_Render_PushFont(renderer, game->jetbrains_mono_font); TELY_Render_PushFont(renderer, game->jetbrains_mono_font);
TELY_RFui_FrameSetup(rfui, &platform->frame_arena); TELY_RFui_FrameSetup(rfui, &platform->frame_arena);
TELY_RFui_PushFont(rfui, game->jetbrains_mono_font); TELY_RFui_PushFont(rfui, game->jetbrains_mono_font);
TELY_RFui_PushLabelColourV4(rfui, TELY_COLOUR_BLACK_MIDNIGHT_V4);
FP_GameCamera shake_camera = game->play.camera; FP_GameCamera shake_camera = game->play.camera;
{ {
@ -3990,12 +3988,21 @@ static void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *ren
// NOTE: Info bar ========================================================================== // NOTE: Info bar ==========================================================================
Dqn_f32 next_y = 10.f; Dqn_f32 next_y = 10.f;
TELY_RFui_PushLabelColourV4(rfui, TELY_COLOUR_BLACK_V4);
{ {
TELY_RFui_PushPadding(rfui, Dqn_V2_InitNx1(2));
DQN_DEFER { TELY_RFui_PopPadding(rfui); };
TELY_RFui_PushMargin(rfui, Dqn_V2_InitNx1(1));
DQN_DEFER { TELY_RFui_PopMargin(rfui); };
TELY_RFuiResult info_column = TELY_RFui_ColumnReverse(rfui, DQN_STRING8("Info Column")); TELY_RFuiResult info_column = TELY_RFui_ColumnReverse(rfui, DQN_STRING8("Info Column"));
TELY_RFui_PushParent(rfui, info_column.widget); TELY_RFui_PushParent(rfui, info_column.widget);
DQN_DEFER { TELY_RFui_PopParent(rfui); }; DQN_DEFER { TELY_RFui_PopParent(rfui); };
Dqn_V4 bg_colour = TELY_Colour_V4Alpha(TELY_RFui_ActiveBackgroundColourV4(rfui), .7f);
TELY_RFui_PushBackgroundColourV4(rfui, bg_colour);
DQN_DEFER { TELY_RFui_PopBackgroundColourV4(rfui); };
info_column.widget->semantic_position[TELY_RFuiAxis_X].kind = TELY_RFuiPositionKind_Absolute; info_column.widget->semantic_position[TELY_RFuiAxis_X].kind = TELY_RFuiPositionKind_Absolute;
info_column.widget->semantic_position[TELY_RFuiAxis_X].value = next_y; info_column.widget->semantic_position[TELY_RFuiAxis_X].value = next_y;
info_column.widget->semantic_position[TELY_RFuiAxis_Y].kind = TELY_RFuiPositionKind_Absolute; info_column.widget->semantic_position[TELY_RFuiAxis_Y].kind = TELY_RFuiPositionKind_Absolute;
@ -4007,12 +4014,15 @@ static void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *ren
DQN_DEFER { TELY_RFui_PopParent(rfui); }; DQN_DEFER { TELY_RFui_PopParent(rfui); };
Dqn_ThreadScratch scratch = Dqn_Thread_GetScratch(nullptr); Dqn_ThreadScratch scratch = Dqn_Thread_GetScratch(nullptr);
TELY_RFui_TextF(rfui, "TELY"); Dqn_String8Builder builder = {};
builder.allocator = scratch.allocator;
Dqn_String8Builder_AppendF(&builder, "TELY");
if (Dqn_String8_IsValid(platform->core.os_name)) { if (Dqn_String8_IsValid(platform->core.os_name)) {
TELY_RFui_TextF(rfui, " | %.*s", DQN_STRING_FMT(platform->core.os_name)); Dqn_String8Builder_AppendF(&builder, " | %.*s", DQN_STRING_FMT(platform->core.os_name));
} }
TELY_RFui_TextF(rfui, Dqn_String8Builder_AppendF(&builder,
" | %dx%d %.1fHz | TSC %.1f GHz", " | %dx%d %.1fHz | TSC %.1f GHz",
platform->core.window_size.w, platform->core.window_size.w,
platform->core.window_size.h, platform->core.window_size.h,
@ -4020,20 +4030,23 @@ static void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *ren
platform->core.tsc_per_second / 1'000'000'000.0); platform->core.tsc_per_second / 1'000'000'000.0);
if (platform->core.ram_mb) if (platform->core.ram_mb)
TELY_RFui_TextF(rfui, " | RAM %.1fGB", platform->core.ram_mb / 1024.0); Dqn_String8Builder_AppendF(&builder, " | RAM %.1fGB", platform->core.ram_mb / 1024.0);
TELY_RFui_TextF(rfui, Dqn_String8Builder_AppendF(&builder,
" | Work %04.1fms/f (%04.1f%%) | %05.1f FPS | Frame %'I64u | Timer %.1fs", " | Work %04.1fms/f (%04.1f%%) | %05.1f FPS | Frame %'I64u | Timer %.1fs",
input->work_ms, input->work_ms,
input->work_ms * 100.0 / input->delta_ms, input->work_ms * 100.0 / input->delta_ms,
1000.0 / input->delta_ms, 1000.0 / input->delta_ms,
input->frame_counter, input->frame_counter,
input->timer_s); input->timer_s);
Dqn_String8 text = Dqn_String8Builder_Build(&builder, scratch.allocator);
TELY_RFui_TextBackgroundF(rfui, "%.*s", DQN_STRING_FMT(text));
} }
TELY_RFui_TextF(rfui, "Mouse: %.1f, %.1f", input->mouse_p.x, input->mouse_p.y); TELY_RFui_TextBackgroundF(rfui, "Mouse: %.1f, %.1f", input->mouse_p.x, input->mouse_p.y);
TELY_RFui_TextF(rfui, "Camera: %.1f, %.1f", game->play.camera.world_pos.x, game->play.camera.world_pos.y); TELY_RFui_TextBackgroundF(rfui, "Camera: %.1f, %.1f", game->play.camera.world_pos.x, game->play.camera.world_pos.y);
TELY_RFui_TextF(rfui, "Debug Info"); TELY_RFui_TextBackgroundF(rfui, "Debug Info");
if (TELY_RFui_ButtonF(rfui, "F1 Debug info").clicked) if (TELY_RFui_ButtonF(rfui, "F1 Debug info").clicked)
game->play.debug_ui = !game->play.debug_ui; game->play.debug_ui = !game->play.debug_ui;
@ -4096,6 +4109,9 @@ static void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *ren
if (TELY_RFui_ButtonF(rfui, "%s bounding rects", game->play.debug_hide_bounding_rectangles ? "Show" : "Hide").clicked) if (TELY_RFui_ButtonF(rfui, "%s bounding rects", game->play.debug_hide_bounding_rectangles ? "Show" : "Hide").clicked)
game->play.debug_hide_bounding_rectangles = !game->play.debug_hide_bounding_rectangles; game->play.debug_hide_bounding_rectangles = !game->play.debug_hide_bounding_rectangles;
if (TELY_RFui_ButtonF(rfui, "%s mob spawning", game->play.debug_disable_mobs ? "Enable" : "Disable").clicked)
game->play.debug_disable_mobs = !game->play.debug_disable_mobs;
} }
if (0) { if (0) {

View File

@ -406,6 +406,7 @@ struct FP_GamePlay
bool debug_ui; bool debug_ui;
bool debug_hide_hud; bool debug_hide_hud;
bool debug_hide_bounding_rectangles; bool debug_hide_bounding_rectangles;
bool debug_disable_mobs;
bool god_mode; bool god_mode;
Dqn_FArray<FP_GameEntityHandle, 4> mob_spawners; Dqn_FArray<FP_GameEntityHandle, 4> mob_spawners;

Binary file not shown.