#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. if (game.ritual_system.active()) { char rit[160]; 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("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; } // 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_wrapped(const char* text, float x, float y, int font_size, Color color, float max_w) { // Minimal word wrap: greedy fill, break on spaces. char line[128] = {}; int line_len = 0; float line_y = y; const char* word = text; while (*word != '\0') { const char* space = std::strchr(word, ' '); const int word_len = space != nullptr ? static_cast(space - word) : static_cast(std::strlen(word)); char candidate[128]; if (line_len == 0) { std::snprintf(candidate, sizeof(candidate), "%.*s", word_len, word); } else { std::snprintf(candidate, sizeof(candidate), "%s %.*s", line, word_len, word); } if (MeasureText(candidate, font_size) > max_w && line_len > 0) { DrawText(line, x, line_y, font_size, color); line_y += font_size + 4; std::snprintf(line, sizeof(line), "%.*s", word_len, word); } else { std::snprintf(line, sizeof(line), "%s", candidate); } line_len = static_cast(std::strlen(line)); word = space != nullptr ? space + 1 : word + word_len; } if (line_len > 0) DrawText(line, x, line_y, font_size, color); } void draw_levelup(const Game& game) { DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Color{10, 10, 12, 190}); const char* header = "THE BOARD REQUIRES A DIRECTIVE - CHOOSE ONE"; DrawText(header, GetScreenWidth() / 2 - MeasureText(header, 26) / 2, GetScreenHeight() / 2 - 190, 26, Color{245, 197, 24, 255}); const float card_w = 300.0f, card_h = 220.0f, gap = 40.0f; const float total_w = card_w * 3 + gap * 2; const float x0 = GetScreenWidth() / 2.0f - total_w / 2.0f; const float y0 = GetScreenHeight() / 2.0f - 110.0f; for (int i = 0; i < 3; ++i) { const LevelUpChoice& choice = game.levelup_choices[i]; const float x = x0 + i * (card_w + gap); const bool is_evolution = choice.kind == OfferKind::Evolution; DrawRectangle(x, y0, card_w, card_h, is_evolution ? Color{245, 232, 186, 245} : Color{232, 228, 216, 245}); if (is_evolution) { // Altered Forms get the thick Board-yellow border. DrawRectangleLines(x - 3, y0 - 3, card_w + 6, card_h + 6, Color{245, 197, 24, 255}); DrawRectangleLines(x - 2, y0 - 2, card_w + 4, card_h + 4, Color{245, 197, 24, 255}); DrawRectangleLines(x - 1, y0 - 1, card_w + 2, card_h + 2, Color{245, 197, 24, 255}); } DrawRectangleLines(x, y0, card_w, card_h, Color{20, 20, 22, 255}); // Redaction strips (the signature gag). DrawRectangle(x + 18, y0 + 96, card_w - 36, 16, Color{17, 17, 17, 255}); DrawRectangle(x + 18, y0 + 120, (card_w - 36) * 0.6f, 10, Color{17, 17, 17, 255}); char key_label[8]; std::snprintf(key_label, sizeof(key_label), "[%d]", i + 1); DrawText(key_label, x + 18, y0 + 18, 26, Color{193, 18, 31, 255}); DrawText(choice.title, x + 18, y0 + 58, 20, Color{17, 17, 17, 255}); draw_wrapped(choice.desc, x + 18, y0 + 150, 16, Color{50, 50, 52, 255}, card_w - 36); } } 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::LevelUp) draw_levelup(game); else if (game.state == GameState::GameOver) draw_gameover(game); }