From 6febed1d08b8f7dcc0e1578afeff292411ea402e Mon Sep 17 00:00:00 2001 From: doyle Date: Tue, 24 Oct 2023 22:36:08 +1100 Subject: [PATCH] fp: Tweak debug UI --- External/tely | 2 +- feely_pona.cpp | 62 +++++++++++++++++++++++++++++----------------- feely_pona_game.h | 1 + project.rdbg | Bin 2469 -> 2525 bytes 4 files changed, 41 insertions(+), 24 deletions(-) diff --git a/External/tely b/External/tely index e1292c1..4c979bb 160000 --- a/External/tely +++ b/External/tely @@ -1 +1 @@ -Subproject commit e1292c1397fad6584b16e79ca63f1596868be9c0 +Subproject commit 4c979bbf759e6795a4d164ef4f7b7e8676cea3f7 diff --git a/feely_pona.cpp b/feely_pona.cpp index 57599ef..04c15b0 100644 --- a/feely_pona.cpp +++ b/feely_pona.cpp @@ -2052,7 +2052,7 @@ static void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput } // 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 for (FP_SentinelListLink *link = nullptr; FP_SentinelList_Iterate(&entity->spawn_list, &link); ) { 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_PushFont(renderer, game->jetbrains_mono_font); - TELY_RFui_FrameSetup(rfui, &platform->frame_arena); TELY_RFui_PushFont(rfui, game->jetbrains_mono_font); - TELY_RFui_PushLabelColourV4(rfui, TELY_COLOUR_BLACK_MIDNIGHT_V4); 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 ========================================================================== 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_RFui_PushParent(rfui, info_column.widget); 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].value = next_y; 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_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)) { - 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", platform->core.window_size.w, platform->core.window_size.h, @@ -4020,41 +4030,44 @@ static void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *ren platform->core.tsc_per_second / 1'000'000'000.0); 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", input->work_ms, input->work_ms * 100.0 / input->delta_ms, 1000.0 / input->delta_ms, input->frame_counter, 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_TextF(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, "Mouse: %.1f, %.1f", input->mouse_p.x, input->mouse_p.y); + TELY_RFui_TextBackgroundF(rfui, "Camera: %.1f, %.1f", game->play.camera.world_pos.x, game->play.camera.world_pos.y); + 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; - if (TELY_RFui_ButtonF(rfui, " F2 Add coins x10,000").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F2)) { + if (TELY_RFui_ButtonF(rfui, "F2 Add coins x10,000").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F2)) { for (FP_GameEntityHandle player_handle : game->play.players) { FP_GameEntity *player = FP_Game_GetEntity(game, player_handle); player->coins += 10'000; } } - if (TELY_RFui_ButtonF(rfui, " F3 Win game").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F3)) + if (TELY_RFui_ButtonF(rfui, "F3 Win game").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F3)) game->play.state = FP_GameState_WinGame; - if (TELY_RFui_ButtonF(rfui, " F4 Lose game").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F4)) + if (TELY_RFui_ButtonF(rfui, "F4 Lose game").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F4)) game->play.state = FP_GameState_LoseGame; - if (TELY_RFui_ButtonF(rfui, " F5 Reset game").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F5)) + if (TELY_RFui_ButtonF(rfui, "F5 Reset game").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F5)) FP_PlayReset(game, platform); - if (TELY_RFui_ButtonF(rfui, " F6 Increase health").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F6)) { + if (TELY_RFui_ButtonF(rfui, "F6 Increase health").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F6)) { for (FP_GameEntityHandle player_handle : game->play.players) { FP_GameEntity *player = FP_Game_GetEntity(game, player_handle); player->hp_cap += FP_DEFAULT_DAMAGE; @@ -4062,7 +4075,7 @@ static void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *ren } } - if (TELY_RFui_ButtonF(rfui, " F7 Increase stamina").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F7)) { + if (TELY_RFui_ButtonF(rfui, "F7 Increase stamina").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F7)) { for (FP_GameEntityHandle player_handle : game->play.players) { FP_GameEntity *player = FP_Game_GetEntity(game, player_handle); player->stamina_cap += DQN_CAST(uint16_t)(FP_TERRY_DASH_STAMINA_COST * .5f); @@ -4070,7 +4083,7 @@ static void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *ren } } - if (TELY_RFui_ButtonF(rfui, " F8 Increase mobile data").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F8)) { + if (TELY_RFui_ButtonF(rfui, "F8 Increase mobile data").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F8)) { for (FP_GameEntityHandle player_handle : game->play.players) { FP_GameEntity *player = FP_Game_GetEntity(game, player_handle); player->terry_mobile_data_plan_cap += DQN_KILOBYTES(1); @@ -4078,10 +4091,10 @@ static void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *ren } } - if (TELY_RFui_ButtonF(rfui, " F9 %s god mode", game->play.god_mode ? "Disable" : "Enable").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F9)) + if (TELY_RFui_ButtonF(rfui, "F9 %s god mode", game->play.god_mode ? "Disable" : "Enable").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F9)) game->play.god_mode = !game->play.god_mode; - if (TELY_RFui_ButtonF(rfui, " F11 Building inventory +1").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F11)) { + if (TELY_RFui_ButtonF(rfui, "F11 Building inventory +1").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F11)) { for (FP_GameEntityHandle player_handle : game->play.players) { FP_GameEntity *player = FP_Game_GetEntity(game, player_handle); player->inventory.clubs += 1; @@ -4091,11 +4104,14 @@ static void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *ren } } - if (TELY_RFui_ButtonF(rfui, " 1 %s HUD", game->play.debug_hide_hud ? "Show" : "Hide").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_1)) + if (TELY_RFui_ButtonF(rfui, "1 %s HUD", game->play.debug_hide_hud ? "Show" : "Hide").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_1)) game->play.debug_hide_hud = !game->play.debug_hide_hud; 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; + + 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) { diff --git a/feely_pona_game.h b/feely_pona_game.h index f703baa..289f4f4 100644 --- a/feely_pona_game.h +++ b/feely_pona_game.h @@ -406,6 +406,7 @@ struct FP_GamePlay bool debug_ui; bool debug_hide_hud; bool debug_hide_bounding_rectangles; + bool debug_disable_mobs; bool god_mode; Dqn_FArray mob_spawners; diff --git a/project.rdbg b/project.rdbg index 926c8adc60bb5f786690d306348f87695fcbe57e..563a9a1a5d6ce3c095d6d394c3f5a9797a9265b2 100644 GIT binary patch delta 237 zcmZ1~d{=maBdY`h1B1zA2Ug9A3s|`li;GiB^pXn-9DyQMT)C;a`9+l={$zXBCN3bI zRGOKSqL(q*pUr^L3#4oEG8Pp^dys0Dq{QOX$?uuHfNHHdQY%VQi}Dh4Cf70RO%7(( zpDf7iGH?bsR@;pWx zMpLNUxQkNrQc{aRj?n=MsZ5Sz*5n7woRgbbEhg79 z39{!GgQRqT%2jxZON#OmOOkU7^pZ`10-BRAu<$dQz)YGvl|_)z9xM*j$eEj1k^$1H z4U^|AE=kGBOw!A60*V+-e#tD%=nPXmc@;Acl1XvQf|I{8IWfZZPJYY8!Kel`iEDBo zlQ$#C6itv5Cwnn*BiWmjSey#7*9$0bIe7=82qVbxAioN-0EHc4+PHz7q|(fs6uk_% UGba9ZXU$E`%`e*gkM%w?02YW^ZU6uP