#include "render/ui.hpp" #include #include #include #include "raylib.h" namespace { void draw_bar(float x, float y, float w, float h, float frac, Color fill, const char* label) { frac = std::max(0.0f, std::min(1.0f, frac)); DrawRectangle(x, y, w, h, Color{20, 20, 22, 210}); DrawRectangle(x, y, w * frac, h, fill); DrawRectangleLines(x, y, w, h, Color{210, 210, 215, 60}); if (label != nullptr) DrawText(label, x + 8, y + h / 2 - 8, 16, Color{235, 232, 224, 235}); } void draw_hud(const Game& game) { // Top left: agent vitals. char hp_label[64]; std::snprintf(hp_label, sizeof(hp_label), "SECURITY AGENT HP %d / %d", static_cast(game.player.hp), static_cast(game.player.stats.max_hp)); draw_bar(20, 20, 300, 22, game.player.hp / game.player.stats.max_hp, Color{193, 18, 31, 235}, hp_label); // Top right: shift timer + RoR2-style CONTAINMENT STATUS gauge. const int total = static_cast(game.run_time); char timer[16]; std::snprintf(timer, sizeof(timer), "SHIFT %02d:%02d", total / 60, total % 60); DrawText(timer, GetScreenWidth() - 20 - MeasureText(timer, 28), 20, 28, Color{235, 232, 224, 245}); const int tier = game.corruption.tier(); char status[96]; std::snprintf(status, sizeof(status), "CONTAINMENT STATUS: %s", game.corruption.tier_name()); const int status_w = MeasureText(status, 18); DrawText(status, GetScreenWidth() - 20 - status_w, 58, 18, Color{245, 197, 24, 245}); const float gauge_w = 260.0f; const float gauge_x = GetScreenWidth() - 20 - gauge_w; const Color gauge_fill = Color{ static_cast(std::min(255, 120 + tier * 24)), static_cast(std::max(0, 180 - tier * 32)), static_cast(std::max(0, 60 - tier * 12)), 235}; draw_bar(gauge_x, 84, gauge_w, 12, game.corruption.tier_progress(), gauge_fill, nullptr); // Kills + clearance level. char misc[64]; std::snprintf(misc, sizeof(misc), "KILLS %d CLEARANCE LV %d", game.kills, game.level); DrawText(misc, 20, 52, 18, Color{200, 198, 192, 235}); // Ritual in progress — mini-game indicator (the player understands the // ritual starts when it appears). MVP: the TV ritual; complex: the // lightswitch — catch the bait around the switch (§2.3). if (game.ritual_system.active()) { char rit[160]; if (game.ritual_system.type() == RitualType::Lightswitch) { std::snprintf(rit, sizeof(rit), "RITUAL IN PROGRESS — LIGHT SWITCH — CATCHING (%d/%d)", game.ritual_system.lightswitch_caught(), game.ritual_system.lightswitch_required()); } else { std::snprintf(rit, sizeof(rit), "RITUAL IN PROGRESS — The TV must flash (%.0f s)", std::max(0.0f, game.ritual_system.remaining())); } DrawText(rit, 20, 70.0f, 16, Color{245, 197, 24, 255}); } if (game.ritual_system.complete()) { DrawText(game.ritual_system.type() == RitualType::Lightswitch ? "RITUAL COMPLETE — Fluorescents revived" : "RITUAL COMPLETE — The TV is live", 20, 70.0f, 16, Color{245, 197, 24, 255}); } // Owned OoP loadout (left column). float oy = 84.0f; DrawText("OoP LOADOUT", 20, oy, 16, Color{245, 197, 24, 235}); oy += 22.0f; for (const WeaponInstance& w : game.weapon_system.weapons) { const WeaponDef& def = weapon_def(w.type); char line[96]; if (w.evolved) { std::snprintf(line, sizeof(line), "%s [ALTERED]", def.evolution_name); DrawText(line, 20, oy, 17, Color{245, 197, 24, 245}); } else { std::snprintf(line, sizeof(line), "%s lv %d", def.name, w.level); DrawText(line, 20, oy, 17, Color{200, 198, 192, 235}); } oy += 21.0f; } // Pending offers (real-time progression). if (!game.pending_offers.empty()) { float oy2 = oy + 6.0f; char offer_line[128]; std::snprintf(offer_line, sizeof(offer_line), "OFFERS PENDING: %d", static_cast(game.pending_offers.size())); DrawText(offer_line, 20, oy2, 16, Color{245, 197, 24, 245}); oy2 += 18.0f; for (const Offer& o : game.pending_offers) { std::snprintf(offer_line, sizeof(offer_line), "- %s", o.name); DrawText(offer_line, 20, oy2, 15, Color{200, 198, 192, 220}); oy2 += 16.0f; } } // Bottom: XP bar. const float xp_w = 640.0f; draw_bar(GetScreenWidth() / 2.0f - xp_w / 2.0f, GetScreenHeight() - 44, xp_w, 18, game.xp / game.xp_to_next, Color{245, 197, 24, 235}, "RESONANCE SHARDS"); // Dev readout (pre-alpha): frame rate + entity counts + director bank. char debug[160]; std::snprintf(debug, sizeof(debug), "FPS %d | ENEMIES %d | PROJECTILES %d | SHARDS %d | DIRECTOR %.0f " "| WORLD OBJECTS %d | BUFFS %d", GetFPS(), game.enemy_system.alive_count(), static_cast(game.weapon_system.projectiles.size()), static_cast(game.pickup_system.shards.size()), static_cast(game.director.credits()), game.buff_system.world_object_count(), game.buff_system.buff_count()); DrawText(debug, 20, GetScreenHeight() - 22, 16, Color{150, 148, 144, 210}); } void draw_gameover(const Game& game) { DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Color{40, 6, 8, 200}); const char* title = "CONTAINMENT FAILURE"; DrawText(title, GetScreenWidth() / 2 - MeasureText(title, 42) / 2, GetScreenHeight() / 2 - 140, 42, Color{193, 18, 31, 255}); const int total = static_cast(game.run_time); char stats[256]; std::snprintf(stats, sizeof(stats), "SHIFT TIME SURVIVED %02d:%02d\nKILLS CONFIRMED %d\nCLEARANCE LEVEL %d\nFINAL CORRUPTION %s", total / 60, total % 60, game.kills, game.level, game.corruption.tier_name()); DrawText(stats, GetScreenWidth() / 2 - 190, GetScreenHeight() / 2 - 60, 22, Color{232, 228, 216, 255}); const char* hint = "PRESS [R] TO RE-ENTER THE HOUSE"; DrawText(hint, GetScreenWidth() / 2 - MeasureText(hint, 24) / 2, GetScreenHeight() / 2 + 110, 24, Color{245, 197, 24, 255}); } } // namespace void ui::draw_all(const Game& game) { draw_hud(game); if (game.state == GameState::GameOver) draw_gameover(game); } void ui::draw_camera_dev(CameraTuning& tuning) { if (IsKeyPressed(KEY_F9)) tuning.panel = !tuning.panel; if (!tuning.panel) { DrawText("F9 CAM DEV", GetScreenWidth() - 130, GetScreenHeight() - 26, 14, Color{160, 158, 152, 220}); return; } const float w = 290.0f, h = 138.0f; const float x = static_cast(GetScreenWidth()) - w - 20.0f; const float y = static_cast(GetScreenHeight()) - h - 20.0f; DrawRectangle(x, y, w, h, Color{14, 16, 18, 225}); DrawRectangleLines(x, y, w, h, Color{120, 118, 112, 160}); DrawText("CAMERA DEV [F9 HIDE]", x + 10, y + 8, 14, Color{245, 197, 24, 245}); const Vector2 mouse = GetMousePosition(); auto slider = [&](float ry, const char* label, float& value, float lo, float hi, const char* fmt) { const float tx = x + 80.0f, tw = 140.0f, ty = ry + 3.0f; DrawText(label, x + 10, ry, 14, Color{220, 218, 210, 230}); DrawRectangle(tx, ty, tw, 9, Color{40, 40, 44, 240}); const float t = std::clamp((value - lo) / (hi - lo), 0.0f, 1.0f); DrawRectangle(tx, ty, tw * t, 9, Color{193, 18, 31, 220}); DrawRectangleLines(tx, ty, tw, 9, Color{180, 178, 172, 80}); DrawRectangle(tx + tw * t - 2.0f, ty - 2.0f, 4.0f, 13.0f, Color{245, 197, 24, 255}); char text[32]; std::snprintf(text, sizeof(text), fmt, value); DrawText(text, x + 230, ry - 1, 14, Color{235, 232, 224, 245}); if (IsMouseButtonDown(MOUSE_LEFT_BUTTON) && mouse.x >= tx && mouse.x <= tx + tw && mouse.y >= ty - 4.0f && mouse.y <= ty + 14.0f) { value = lo + std::clamp((mouse.x - tx) / tw, 0.0f, 1.0f) * (hi - lo); } }; slider(y + 34.0f, "FOV", tuning.fov, 30.0f, 80.0f, "%3.0f"); slider(y + 62.0f, "HEIGHT", tuning.height, 5.0f, 45.0f, "%4.1f"); slider(y + 90.0f, "FORWARD", tuning.forward, 2.0f, 40.0f, "%4.1f"); DrawText("[ ] FOV - = HEIGHT , . FORWARD", x + 10, y + 117, 12, Color{160, 158, 152, 220}); if (IsKeyPressed(KEY_LEFT_BRACKET)) tuning.fov = std::max(30.0f, tuning.fov - 2.0f); if (IsKeyPressed(KEY_RIGHT_BRACKET)) tuning.fov = std::min(80.0f, tuning.fov + 2.0f); if (IsKeyPressed(KEY_MINUS)) tuning.height = std::max(5.0f, tuning.height - 1.0f); if (IsKeyPressed(KEY_EQUAL)) tuning.height = std::min(45.0f, tuning.height + 1.0f); if (IsKeyPressed(KEY_COMMA)) tuning.forward = std::max(2.0f, tuning.forward - 1.0f); if (IsKeyPressed(KEY_PERIOD)) tuning.forward = std::min(40.0f, tuning.forward + 1.0f); }