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
+109
@@ -0,0 +1,109 @@
|
||||
#pragma once
|
||||
|
||||
#include "log.h"
|
||||
#include <SDL3/SDL_rect.h>
|
||||
#include <array>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct SDL_GLContextState;
|
||||
struct SDL_Window;
|
||||
|
||||
constexpr int BINDING_SLOTS = 4;
|
||||
// The game's frame, 60 Hz, in seconds.
|
||||
constexpr double FRAME_TIME = 1.0 / 60;
|
||||
|
||||
// A width and a height in pixels.
|
||||
struct Size
|
||||
{
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
|
||||
bool operator==(const Size&) const = default;
|
||||
};
|
||||
|
||||
// The buttons or keys one input action is bound to, -1 in an empty slot.
|
||||
using ActionBinding = std::array<int, BINDING_SLOTS>;
|
||||
|
||||
// The default bindings of every input action, by action: GLFW gamepad buttons and GLFW keys.
|
||||
struct InputBindings
|
||||
{
|
||||
std::vector<ActionBinding> controller;
|
||||
std::vector<ActionBinding> keyboard;
|
||||
int controllerCount = 0;
|
||||
};
|
||||
|
||||
// How the window fills the screen.
|
||||
enum FullscreenMode
|
||||
{
|
||||
FULLSCREEN_OFF,
|
||||
FULLSCREEN_BORDERLESS,
|
||||
FULLSCREEN_EXCLUSIVE
|
||||
};
|
||||
|
||||
// Whether the depth renderbuffer is rebuilt even when the one it has is big enough.
|
||||
enum RenderbufferMode
|
||||
{
|
||||
RENDERBUFFER_KEEP,
|
||||
RENDERBUFFER_REBUILD
|
||||
};
|
||||
|
||||
// The engine's platform layer on SDL3: KAGE's System, the window half of its Graphics::Manager and the GLFW calls
|
||||
// under them, with the folders the game saves into and the 60 Hz frame pacing.
|
||||
// Listeners get the window's new size, position or focus, as the game registers them in IsaacStartup.
|
||||
class Platform
|
||||
{
|
||||
public:
|
||||
InputBindings bindings;
|
||||
std::string modsDirectory;
|
||||
std::string modsSaveDirectory;
|
||||
std::string userDataDirectory;
|
||||
std::vector<std::function<void(bool)>> focusListeners;
|
||||
std::vector<std::function<void(SDL_Point)>> positionListeners;
|
||||
std::vector<std::function<void(Size)>> sizeListeners;
|
||||
SDL_FPoint viewportOffset = {};
|
||||
SDL_Point windowPosition = {};
|
||||
Size drawingSize = {-1, -1};
|
||||
Size viewportSize;
|
||||
Size windowSize;
|
||||
SDL_GLContextState* context = nullptr;
|
||||
SDL_Window* window = nullptr;
|
||||
unsigned int depthRenderbuffer = 0;
|
||||
unsigned int framebuffer = 0;
|
||||
bool isEngineInitialized = false;
|
||||
bool isFullscreen = false;
|
||||
bool isQuitRequested = false;
|
||||
bool isViewportOffset = false;
|
||||
bool isVsync = true;
|
||||
|
||||
void directories_load();
|
||||
void bindings_load();
|
||||
void engine_init();
|
||||
void events_poll();
|
||||
double time_get();
|
||||
int frame_begin();
|
||||
void frame_wait();
|
||||
void window_size_set(Size size);
|
||||
void window_position_set(SDL_Point position);
|
||||
void fullscreen_set(FullscreenMode mode);
|
||||
void vsync_apply();
|
||||
void depth_renderbuffer_update(RenderbufferMode mode);
|
||||
Size framebuffer_size_get();
|
||||
|
||||
private:
|
||||
double frameStart = 0;
|
||||
int fullFrameCount = 0;
|
||||
int shortFrameCount = 0;
|
||||
bool isPacingForced = false;
|
||||
|
||||
bool graphics_init();
|
||||
bool window_create();
|
||||
void state_reset();
|
||||
void viewport_reset();
|
||||
};
|
||||
|
||||
extern Platform platform;
|
||||
|
||||
void log_open(const std::string& path);
|
||||
void log_printf(LogLevel level, const char* format, ...) __attribute__((format(printf, 2, 3)));
|
||||
Reference in new issue
Block a user