Eight agents took over ScoreSheet, DeathmatchManager, giantbook and boss overlays, FXLayers, PlayerManager, the menu manager with the save and prompt flow, twelve menus (character wheel, options, challenges, daily (offline), special seeds, leaderboard (local), collection, bestiary, stats, controller select, key config, cutscenes), console text input and gamepad hot-plug through platform listeners. Integration moved input to device ids. KAGE's projection matrix now reaches the 'ProjectionMatrix' uniform the basic shaders from afterbirthp.a declare, as well as the exe's 'Transform', which takes the color-mod and HQ4X passes from black to correct output. Under gdb with stubs skipped, the intro, title, file select, main menu and character wheel render as in the game. 1330 functions taken over, boot path 261/615. build/isaac stops at OnlineEmotes::init in Game::LoadConfigXmls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
116 lines
3.2 KiB
C++
116 lines
3.2 KiB
C++
#pragma once
|
|
|
|
#include "log.h"
|
|
#include <SDL3/SDL_rect.h>
|
|
#include <array>
|
|
#include <cstdint>
|
|
#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, and each
|
|
// character typed while text input is on, as GLFW's char callback did.
|
|
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;
|
|
std::vector<std::function<void(uint32_t)>> textListeners;
|
|
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 engine_shutdown();
|
|
bool window_open();
|
|
void window_swap();
|
|
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();
|
|
void state_reset();
|
|
void viewport_reset();
|
|
|
|
private:
|
|
double frameStart = 0;
|
|
int fullFrameCount = 0;
|
|
int shortFrameCount = 0;
|
|
bool isPacingForced = false;
|
|
|
|
bool window_create();
|
|
};
|
|
|
|
extern Platform platform;
|
|
|
|
uint64_t GetTimeNs();
|
|
void log_open(const std::string& path);
|
|
void log_printf(LogLevel level, const char* format, ...) __attribute__((format(printf, 2, 3)));
|