Curation round 2, wave A: anm2 (Anm2Ed JSON), text, config as idiomatic classes; SDL3 platform opens a window
- anm2.h/.cpp take over ANM2, AnimationState, LayerState, AnmCache and the frame data. They read Anm2Ed's JSON documents with simdjson and play them as the game does (interpolation baked at load). src/anm2/ and msvc.h are retired. - font, formatted_text, string_table and rich_text take over the text classes. FormattedText::parse is still bit-exact against its assembly. - options_config and challenge_params take over OptionsConfig, ChallengeParams and the .ini helpers. The tests include Save's exact bytes. - platform.h/.cpp and main.cpp run IsaacMain on SDL3: the window and GL context open, and the run stops at the first built-in shader (FUN_00a13fa0). - source_tree.py: a taken-over parent stays bytes, taken-over methods are not re-emitted as a namespace, and every address in a (a, b, c to d) list on a comment counts as taken over. - log.h: reconstruction_missing() for a taken-over class's methods that are not written yet. 206 functions taken over, boot path 89/615. The full build waits for wave B: item_config, entity_config and mod_manager still use the old APIs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d6e1ca7c6c
commit
780767f5e1
161 files changed
+8646
-21919
No files matched your search
+25
-44
@@ -1,53 +1,34 @@
|
||||
#include "classes.h"
|
||||
#include "rich_text.h"
|
||||
#include "log.h"
|
||||
#include "msvc.h"
|
||||
#include <cstdio>
|
||||
|
||||
// The font path buffer the game formats into (MAX_PATH + 1).
|
||||
constexpr int FONT_PATH_SIZE = 0x104;
|
||||
constexpr int LOG_MESSAGE_SIZE = 1024;
|
||||
constexpr const char* TEXT_ICONS_PATH = "gfx/ui/text_icons.anm2";
|
||||
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"};
|
||||
|
||||
// Icon id to its image, in RichTextIcon::_images.
|
||||
using IconImageNode = MsvcTreeNode<int, TexturePtr>;
|
||||
LAYOUT32(sizeof(IconImageNode) == 0x1c);
|
||||
|
||||
static char* string_text(std_string& text)
|
||||
// 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)
|
||||
{
|
||||
return (char*)((msvc::string*)&text)->c_str();
|
||||
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<RichTextIcon>();
|
||||
icons->Load(TEXT_ICONS_PATH, GRAPHICS_LOAD);
|
||||
}
|
||||
icons->maxHeight = font.lineHeight;
|
||||
}
|
||||
|
||||
// 009efb60 Loads the font at fontPath and, the first time, the icons drawn inline with the text, which it then fits to
|
||||
// the font's line height. A path too long for the buffer is cut short and terminated, which the game left unterminated.
|
||||
void RichText::load_font(std_string* fontPath)
|
||||
// 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)
|
||||
{
|
||||
char path[FONT_PATH_SIZE];
|
||||
if (type >= ICON_PLAYER && type <= ICON_ROOM && type != ICON_COLLECTIBLE) return ICON_ANIMATIONS[type];
|
||||
|
||||
if (fontPath != &_fontPath) ((msvc::string*)&_fontPath)->assign((uint8_t*)string_text(*fontPath), fontPath->_size);
|
||||
snprintf(path, sizeof(path), "%s", string_text(_fontPath));
|
||||
_font.Unload();
|
||||
_font.Load((uint8_t*)path, false);
|
||||
if (!_font._isLoaded)
|
||||
{
|
||||
char message[LOG_MESSAGE_SIZE];
|
||||
|
||||
snprintf(message, sizeof(message), "Failed to load font: %s \n", path);
|
||||
KAGE_LogMessage(LOG_ASSERT, (uint8_t*)message);
|
||||
}
|
||||
|
||||
if (!_icons)
|
||||
{
|
||||
std_string iconsPath;
|
||||
|
||||
_icons = (RichTextIcon*)operator_new(sizeof(RichTextIcon));
|
||||
_icons->constructor();
|
||||
_icons->_maxHeight = 0;
|
||||
_icons->_iconType = 0;
|
||||
_icons->_iconId = 0;
|
||||
_icons->_images = tree_create<IconImageNode>();
|
||||
((msvc::string*)&iconsPath)->string_from_cstr((uint8_t*)TEXT_ICONS_PATH);
|
||||
_icons->Load(&iconsPath, true);
|
||||
((msvc::string*)&iconsPath)->_Tidy_deallocate();
|
||||
}
|
||||
_icons->_maxHeight = _font._lineHeight;
|
||||
std::string message = "Invalid icon type (" + std::to_string(type) + ") for get_animation_name() \n";
|
||||
KAGE_LogMessage(LOG_ERROR, (uint8_t*)message.data());
|
||||
return {};
|
||||
}
|
||||
Reference in new issue
Block a user