Curation round 17: Theora and Vorbis cutscene videos, Ludovico, Epic and Dr. Fetus, Tractor Beam and Eye of the Occult, familiars and blue spiders, fortune teller and restock, the Bag of Crafting and four tainted characters, ten enemies, water and the ultra secret door, Isaac, ???, the Lamb and Hush

This commit is contained in:
shweet committed 2026-11-21 01:27:03 -05:00
1 parent e9de039d0f
commit 024cb12016
133 files changed
+13325 -2520

No files matched your search

+127 -11
View File
@@ -9,9 +9,13 @@
#include "platform.h"
#include "render_passes.h"
#include "room.h"
#include "string_table.h"
#include <algorithm>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <cwctype>
constexpr const char* MPLUS_FONT = "font/MPlus_12b.fnt";
constexpr const char* KOREAN_FONT = "font/KR_Font14.fnt";
@@ -68,6 +72,14 @@ constexpr KAGE::Graphics::BlendMode BLEND_MODE_PREMULTIPLIED = {
constexpr int FILTER_LINEAR = 1;
constexpr int CHARGE_BAR_FLASH_FRAMES = 8;
constexpr int SOUND_FORTUNE_PAPER = 252;
// The fortune paper's writing: the width a wrapped line fits, the line height, the size past which the text halves,
// and the mark that breaks a fortune's lines.
constexpr int FORTUNE_LINE_WIDTH = 270;
constexpr float FORTUNE_LINE_HEIGHT = 21;
constexpr int FORTUNE_MAX_WIDTH = 273;
constexpr float FORTUNE_MAX_HEIGHT = 63;
constexpr char FORTUNE_LINE_BREAK = '|';
constexpr float FORTUNE_SOUND_VOLUME = 0.5f;
constexpr float FORTUNE_SLIDE_IN_PITCH = 1.5f;
constexpr float STATS_ALPHA = 0.5f;
@@ -650,27 +662,131 @@ void HUD::ShowStackedItemTextCustom(const char* title, const char* subtitle)
}
// 0085eca0 Lua's HUD:ShowFortuneText: shows a fortune's lines on the fortune paper.
void HUD::ShowFortuneText(const std::vector<std::string>&)
void HUD::ShowFortuneText(const std::vector<std::string>& lines)
{
reconstruction_missing("HUD::ShowFortuneText 0085eca0");
render_fortune_text(lines);
}
// 009a3590 Shows one fortune line.
void HUD::show_fortune_line(const char*)
// 009a3590 Shows one line on the fortune paper (a curse's name, a notice).
void HUD::show_fortune_line(const char* text)
{
reconstruction_missing("HUD::show_fortune_line 009a3590");
render_fortune_text({text});
}
// 009a36d0 Splits a fortune into lines and shows them.
void HUD::show_fortune_text_impl(const char*)
// The font the fortune paper writes in: the HUD's own, the Korean one, or Upheaval when neither loaded.
static Font& fortune_font(HUD& hud)
{
reconstruction_missing("HUD::show_fortune_text_impl 009a36d0");
if (hud.font.isLoaded) return hud.font;
return hud.fontKR.isLoaded ? hud.fontKR : g_manager->font7_Upheaval;
}
// 009a3ac0 Draws a fortune's lines into the fortune surface.
void HUD::render_fortune_text(const std::vector<std::u16string>&)
// 009a36d0 Shows a text on the fortune paper wrapped into lines that fit it, breaking after the last space before the
// edge, or inside a word with no space.
void HUD::show_fortune_text_impl(const char* text)
{
reconstruction_missing("HUD::render_fortune_text 009a3ac0");
Font& font = fortune_font(*this);
std::vector<std::string> lines;
const char* end = text + std::strlen(text);
const char* lineStart = text;
const char* lastSpace = text;
int width = 0;
for (const char* cursor = text; cursor < end;)
{
uint32_t character = 0;
const char* next = utf8_decode_next(cursor, &character, end);
if (!character) break;
if (std::iswspace((wint_t)character)) lastSpace = cursor;
width += font.GetStringWidth(std::string_view(cursor, (size_t)(next - cursor)));
if (width <= FORTUNE_LINE_WIDTH)
{
cursor = next;
continue;
}
bool isAtSpace = lastSpace != lineStart;
lines.emplace_back(lineStart, isAtSpace ? lastSpace : cursor);
if (isAtSpace) cursor = utf8_decode_next(lastSpace, &character, end);
lineStart = cursor;
lastSpace = cursor;
width = 0;
}
lines.emplace_back(lineStart, end);
render_fortune_text(lines);
}
// 009a3ac0 Writes a fortune's lines centred into the fortune surface in black, at half size when they are too wide or
// too many, and plays the paper that fits them (Text, Text2 or Text3). No lines leave the plain paper, empty.
void HUD::render_fortune_text(const std::vector<std::string>& lines)
{
KAGE::Graphics::Manager& graphics = KAGE::Graphics::manager;
Font& font = fortune_font(*this);
float textScale = 1;
float lineHeight = FORTUNE_LINE_HEIGHT;
int maxWidth = 0;
for (const std::string& line : lines) maxWidth = std::max(maxWidth, font.GetStringWidth(line));
float textHeight = (float)lines.size() * FORTUNE_LINE_HEIGHT;
if (maxWidth > FORTUNE_MAX_WIDTH || textHeight > FORTUNE_MAX_HEIGHT)
{
textScale = 0.5f;
lineHeight = FORTUNE_LINE_HEIGHT * 0.5f;
textHeight *= 0.5f;
}
const char* paper = textHeight > FORTUNE_LINE_HEIGHT * 2 ? "Text3" : textHeight > FORTUNE_LINE_HEIGHT ? "Text2" : "Text";
fortuneSprite.Play(lines.empty() ? "Text" : paper, PLAY_FORCED);
if (!fortuneTextImage) return;
graphics.render_target_push(fortuneTextImage.get(), KAGE::Graphics::TARGET_OWN_SIZE, KAGE::Graphics::PRESENT_FLUSH);
graphics.Clear();
if (!lines.empty())
{
graphics.blendMode = BLEND_MODE_PREMULTIPLIED;
FontSettings settings(ALIGN_TOP_CENTER);
float centerX = (float)fortuneTextImage->width * 0.5f;
float y = 0;
for (const std::string& line : lines)
{
font.DrawString(line, vector_make(centerX, y), vector_make(textScale, textScale), BLACK, settings);
y += lineHeight;
}
graphics.Present(KAGE::Graphics::PRESENT_FINISH);
}
graphics.render_target_pop(KAGE::Graphics::PRESENT_FLUSH);
}
// 009807a0 (Game::ShowFortuneText) A random line of a string table category on the fortune paper, its '|' marks
// starting new lines.
void fortune_text_show(RNG& rng, std::string_view category)
{
StringTable& table = g_manager->stringTable;
std::string key(category);
std::ranges::transform(key, key.begin(), [](unsigned char c) { return (char)std::tolower(c); });
auto found = table.categories.find(key);
size_t count = found == table.categories.end() ? 0 : found->second.keys.size();
std::string_view text = table.get_string_by_index(category, table.language, rng.RandomInt((uint32_t)count));
std::vector<std::string> lines;
std::string line;
for (char character : text)
{
if (character != FORTUNE_LINE_BREAK)
{
line += character;
continue;
}
lines.push_back(line);
line.clear();
}
if (!line.empty()) lines.push_back(line);
g_game->hud.render_fortune_text(lines);
}
// (005b1870, 0065d070, 00753d00 Game::ShowFortune, the seeds' fortune and Game::ShowRule) A line of a fortune category
// from the run's fortune generator.
void fortune_show(std::string_view category)
{
fortune_text_show(g_game->fortuneRNG, category);
}
// 009a3eb0 Draws the HUD unless it is hidden or the run plays "No HUD": the recent items and minimap, the Boss Rush