fp: Hide debug UI behind a flag

This commit is contained in:
doyle 2023-10-05 21:30:56 +11:00
parent 5f8344ddda
commit 4bcbc61721
3 changed files with 73 additions and 89 deletions

View File

@ -1252,10 +1252,13 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
Dqn_f32 pan_speed = 5.f; Dqn_f32 pan_speed = 5.f;
if (TELY_Platform_InputScanCodeIsDown(input, TELY_PlatformInputScanCode_Space)) if (TELY_Platform_InputScanCodeIsDown(input, TELY_PlatformInputScanCode_Space))
pan_speed *= 2.5f; pan_speed *= 2.5f;
game->camera.world_pos += dir_vector * pan_speed; game->camera.world_pos += dir_vector * pan_speed;
} }
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F1))
game->debug_ui = !game->debug_ui;
Dqn_ProfilerZone update_zone = Dqn_Profiler_BeginZoneWithIndex(DQN_STRING8("FP_Update: Entity loop"), FP_ProfileZone_FPUpdate_EntityLoop); Dqn_ProfilerZone update_zone = Dqn_Profiler_BeginZoneWithIndex(DQN_STRING8("FP_Update: Entity loop"), FP_ProfileZone_FPUpdate_EntityLoop);
// NOTE: Handle input ========================================================================== // NOTE: Handle input ==========================================================================
@ -1574,15 +1577,6 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F)) if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F))
game->build_mode = !game->build_mode; game->build_mode = !game->build_mode;
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F1)) {
entity->sprite_height.meters += 1;
Dqn_Log_InfoF("Height: %.1f", entity->sprite_height.meters);
}
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F2)) {
entity->sprite_height.meters -= 1;
Dqn_Log_InfoF("Height: %.1f", entity->sprite_height.meters);
}
if (entity->flags & FP_GameEntityFlag_CameraTracking) if (entity->flags & FP_GameEntityFlag_CameraTracking)
game->camera.world_pos = FP_Game_CalcEntityWorldPos(game, entity->handle) - Dqn_V2_InitV2I(platform->core.window_size) * .5f; game->camera.world_pos = FP_Game_CalcEntityWorldPos(game, entity->handle) - Dqn_V2_InitV2I(platform->core.window_size) * .5f;
@ -1986,6 +1980,7 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
} }
// NOTE: Render waypoint entities ========================================================== // NOTE: Render waypoint entities ==========================================================
if (game->debug_ui) {
if (entity->flags & FP_GameEntityFlag_MobSpawner) { if (entity->flags & FP_GameEntityFlag_MobSpawner) {
Dqn_V2 start = world_pos; Dqn_V2 start = world_pos;
for (FP_GameEntity *waypoint_entity = entity->first_child; waypoint_entity; waypoint_entity = waypoint_entity->next) { for (FP_GameEntity *waypoint_entity = entity->first_child; waypoint_entity; waypoint_entity = waypoint_entity->next) {
@ -1998,6 +1993,25 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
} }
} }
if (entity->flags & FP_GameEntityFlag_MobSpawner)
TELY_Render_RectColourV4(renderer, world_hit_box, TELY_RenderShapeMode_Line, TELY_COLOUR_BLUE_CADET_V4);
if (entity->flags & FP_GameEntityFlag_MobSpawnerWaypoint)
TELY_Render_CircleColourV4(renderer, world_pos, 16.f /*radius*/, TELY_RenderShapeMode_Line, TELY_COLOUR_BLUE_CADET_V4);
if (entity->flags & FP_GameEntityFlag_BuildZone) {
{
Dqn_V2 line_p1 = Dqn_Rect_InterpolatedPoint(world_hit_box, Dqn_V2_InitNx2(0, 0));
Dqn_V2 line_p2 = Dqn_Rect_InterpolatedPoint(world_hit_box, Dqn_V2_InitNx2(1, 1));
TELY_Render_LineColourV4(renderer, line_p1, line_p2, TELY_COLOUR_BLACK_V4, 2.f);
}
{
Dqn_V2 line_p1 = Dqn_Rect_InterpolatedPoint(world_hit_box, Dqn_V2_InitNx2(0, 1));
Dqn_V2 line_p2 = Dqn_Rect_InterpolatedPoint(world_hit_box, Dqn_V2_InitNx2(1, 0));
TELY_Render_LineColourV4(renderer, line_p1, line_p2, TELY_COLOUR_BLACK_V4, 2.f);
}
}
// NOTE: Render attack box ================================================================= // NOTE: Render attack box =================================================================
{ {
Dqn_Rect attack_box = FP_Game_CalcEntityAttackWorldHitBox(game, entity->handle); Dqn_Rect attack_box = FP_Game_CalcEntityAttackWorldHitBox(game, entity->handle);
@ -2007,31 +2021,6 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
// NOTE: Render world position ============================================================= // NOTE: Render world position =============================================================
TELY_Render_CircleColourV4(renderer, world_pos, 4.f, TELY_RenderShapeMode_Fill, TELY_COLOUR_RED_TOMATO_V4); TELY_Render_CircleColourV4(renderer, world_pos, 4.f, TELY_RenderShapeMode_Fill, TELY_COLOUR_RED_TOMATO_V4);
// NOTE: Render building blueprint =========================================================
if (game->clicked_entity == entity->handle && game->build_mode) {
TELY_Render_PushTransform(renderer, Dqn_M2x3_Identity());
Dqn_V2 label_p = Dqn_V2_InitNx2(platform->core.window_size.x * .5f, platform->core.window_size.y * .1f);
TELY_Render_Text(renderer, label_p, Dqn_V2_InitNx2(0.5f, 0.5f), DQN_STRING8("Build Mode"));
TELY_Render_PopTransform(renderer);
FP_EntityRenderData club_terry_render_data = FP_Entity_GetRenderData(game, FP_EntityType_ClubTerry, FP_EntityClubTerryState_Idle, entity->direction);
Dqn_Rect dest_rect = FP_Game_GetBuildingPlacementRectForEntity(game, entity->handle);
Dqn_V4 colour = game->build_mode_can_place_building ?
TELY_Colour_V4Alpha(TELY_COLOUR_WHITE_V4, 0.5f) :
TELY_Colour_V4Alpha(TELY_COLOUR_RED_V4, 0.5f);
TELY_Render_RectColourV4(renderer, dest_rect, TELY_RenderShapeMode_Fill, TELY_Colour_V4Alpha(TELY_COLOUR_BLUE_CADET_V4, 0.5f));
TELY_Render_TextureColourV4(renderer,
club_terry_render_data.sheet->tex_handle,
club_terry_render_data.sheet_rect,
dest_rect,
Dqn_V2_Zero /*rotate origin*/,
0.f /*rotation*/,
colour);
}
// NOTE: Render hot/active entity ========================================================== // NOTE: Render hot/active entity ==========================================================
if (game->clicked_entity == entity->handle) { if (game->clicked_entity == entity->handle) {
TELY_Render_RectColourV4(renderer, world_hit_box, TELY_RenderShapeMode_Line, TELY_COLOUR_WHITE_PALE_GOLDENROD_V4); TELY_Render_RectColourV4(renderer, world_hit_box, TELY_RenderShapeMode_Line, TELY_COLOUR_WHITE_PALE_GOLDENROD_V4);
@ -2061,6 +2050,33 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
} }
} }
} }
// NOTE: Render building blueprint =========================================================
if (game->clicked_entity == entity->handle && game->build_mode) {
TELY_Render_PushTransform(renderer, Dqn_M2x3_Identity());
Dqn_V2 label_p = Dqn_V2_InitNx2(platform->core.window_size.x * .5f, platform->core.window_size.y * .1f);
TELY_Render_Text(renderer, label_p, Dqn_V2_InitNx2(0.5f, 0.5f), DQN_STRING8("Build Mode"));
TELY_Render_PopTransform(renderer);
FP_EntityRenderData club_terry_render_data = FP_Entity_GetRenderData(game, FP_EntityType_ClubTerry, FP_EntityClubTerryState_Idle, entity->direction);
Dqn_Rect dest_rect = FP_Game_GetBuildingPlacementRectForEntity(game, entity->handle);
Dqn_V4 colour = game->build_mode_can_place_building ?
TELY_Colour_V4Alpha(TELY_COLOUR_WHITE_V4, 0.5f) :
TELY_Colour_V4Alpha(TELY_COLOUR_RED_V4, 0.5f);
TELY_Render_RectColourV4(renderer, dest_rect, TELY_RenderShapeMode_Fill, TELY_Colour_V4Alpha(TELY_COLOUR_BLUE_CADET_V4, 0.5f));
TELY_Render_TextureColourV4(renderer,
club_terry_render_data.sheet->tex_handle,
club_terry_render_data.sheet_rect,
dest_rect,
Dqn_V2_Zero /*rotate origin*/,
0.f /*rotation*/,
colour);
}
}
} }
extern "C" __declspec(dllexport) extern "C" __declspec(dllexport)
@ -2141,7 +2157,7 @@ void TELY_DLL_FrameUpdate(void *user_data)
// NOTE: UI ==================================================================================== // NOTE: UI ====================================================================================
TELY_Render_PushTransform(renderer, Dqn_M2x3_Identity()); TELY_Render_PushTransform(renderer, Dqn_M2x3_Identity());
DQN_DEFER { TELY_Render_PopTransform(renderer); }; DQN_DEFER { TELY_Render_PopTransform(renderer); };
{ if (game->debug_ui) {
// NOTE: Info bar ========================================================================== // NOTE: Info bar ==========================================================================
{ {
TELY_RFuiResult info_bar = TELY_RFui_Row(rfui, DQN_STRING8("Info Bar")); TELY_RFuiResult info_bar = TELY_RFui_Row(rfui, DQN_STRING8("Info Bar"));

View File

@ -270,12 +270,6 @@ static FP_GameEntityHandle FP_Entity_CreateWaypointF(FP_Game *game, Dqn_V2 pos,
entity->local_hit_box_size = Dqn_V2_InitNx1(32); entity->local_hit_box_size = Dqn_V2_InitNx1(32);
FP_Entity_AddDebugEditorFlags(game, entity->handle); FP_Entity_AddDebugEditorFlags(game, entity->handle);
entity->flags |= FP_GameEntityFlag_MobSpawnerWaypoint; entity->flags |= FP_GameEntityFlag_MobSpawnerWaypoint;
FP_GameShape *shape = Dqn_FArray_Make(&entity->shapes, Dqn_ZeroMem_Yes);
shape->type = FP_GameShapeType_Circle;
shape->circle_radius = 16.f;
shape->render_mode = TELY_RenderShapeMode_Line;
shape->colour = TELY_COLOUR_BLUE_CADET_V4;
return result; return result;
} }
@ -375,26 +369,6 @@ static FP_GameEntityHandle FP_Entity_CreatePermittedBuildZone(FP_Game *game, Dqn
entity->type = FP_EntityType_Nil; entity->type = FP_EntityType_Nil;
entity->flags |= FP_GameEntityFlag_BuildZone; entity->flags |= FP_GameEntityFlag_BuildZone;
FP_Entity_AddDebugEditorFlags(game, entity->handle); FP_Entity_AddDebugEditorFlags(game, entity->handle);
FP_GameShape *wall = Dqn_FArray_Make(&entity->shapes, Dqn_ZeroMem_Yes);
wall->type = FP_GameShapeType_Rect;
wall->p2 = entity->local_hit_box_size;
wall->colour = TELY_COLOUR_BLACK_V4;
Dqn_Rect local_hit_box = Dqn_Rect_InitV2x2(Dqn_V2_Zero, entity->local_hit_box_size);
FP_GameShape *line_1 = Dqn_FArray_Make(&entity->shapes, Dqn_ZeroMem_Yes);
line_1->type = FP_GameShapeType_Line;
line_1->p1 = Dqn_Rect_InterpolatedPoint(local_hit_box, Dqn_V2_InitNx2(0.f, 0.f)) - size * .5f;
line_1->p2 = Dqn_Rect_InterpolatedPoint(local_hit_box, Dqn_V2_InitNx2(1.f, 1.f)) - size * .5f;
line_1->line_thickness = 1.f;
line_1->colour = TELY_COLOUR_BLACK_V4;
FP_GameShape *line_2 = Dqn_FArray_Make(&entity->shapes, Dqn_ZeroMem_Yes);
line_2->type = FP_GameShapeType_Line;
line_2->p1 = Dqn_Rect_InterpolatedPoint(local_hit_box, Dqn_V2_InitNx2(0.f, 1.f)) - size * .5f;
line_2->p2 = Dqn_Rect_InterpolatedPoint(local_hit_box, Dqn_V2_InitNx2(1.f, 0.f)) - size * .5f;
line_2->line_thickness = 1.f;
line_2->colour = TELY_COLOUR_BLACK_V4;
return result; return result;
} }
@ -418,13 +392,6 @@ static FP_GameEntityHandle FP_Entity_CreateMobSpawner(FP_Game *game, Dqn_V2 pos,
entity->enemies_per_wave = 5; entity->enemies_per_wave = 5;
entity->enemies_spawned_this_wave = 0; entity->enemies_spawned_this_wave = 0;
entity->wave_cooldown_timestamp_s = 0; entity->wave_cooldown_timestamp_s = 0;
FP_GameShape *shape = Dqn_FArray_Make(&entity->shapes, Dqn_ZeroMem_Yes);
shape->type = FP_GameShapeType_Rect;
shape->p1 = {};
shape->p2 = entity->local_hit_box_size;
shape->render_mode = TELY_RenderShapeMode_Line;
shape->colour = TELY_COLOUR_BLUE_CADET_V4;
return result; return result;
} }

View File

@ -262,6 +262,7 @@ struct FP_Game
bool build_mode; bool build_mode;
bool build_mode_can_place_building; bool build_mode_can_place_building;
bool debug_ui;
}; };
struct FP_GameAStarNode struct FP_GameAStarNode