#include "rich_text.h" #include "log.h" constexpr std::string_view TEXT_ICONS_PATH = "gfx/ui/text_icons.anm2"; // The animation each icon type is a frame of, empty for the collectible, which is an image of its own. constexpr std::string_view ICON_ANIMATIONS[] = {"players", "pickups", "", "rooms"}; // 009efb60 Loads the font at path and, the first time, the icon sprite, which it then fits to the font's line height. // The game formatted the path into a buffer of 260 characters first. The whole path is used here. void RichText::load_font(std::string_view path) { std::string message = "Failed to load font: " + std::string(path) + " \n"; fontPath = path; if (!font.Load(fontPath)) KAGE_LogMessage(LOG_ASSERT, (uint8_t*)message.data()); if (!icons) { icons = std::make_unique(); icons->Load(TEXT_ICONS_PATH, GRAPHICS_LOAD); } icons->maxHeight = font.lineHeight; } // 009f2b10 The text_icons.anm2 animation an icon type is drawn from, or nothing, logged, for the collectible and // unknown types. std::string_view RichTextIcon::get_animation_name(RichTextIconType type) { if (type >= ICON_PLAYER && type <= ICON_ROOM && type != ICON_COLLECTIBLE) return ICON_ANIMATIONS[type]; std::string message = "Invalid icon type (" + std::to_string(type) + ") for get_animation_name() \n"; KAGE_LogMessage(LOG_ERROR, (uint8_t*)message.data()); return {}; }