#pragma once #include "anm2.h" #include "kage_graphics.h" #include #include #include #include #include #include #include // The sprites a mod can replace, by their slot in ModEntry::contentSprites. enum ModContentSprite { MOD_SPRITE_CHARACTER_MENU, MOD_SPRITE_CHARACTER_PORTRAITS, MOD_SPRITE_DEATH_SCREEN, MOD_SPRITE_COOP_MENU, MOD_SPRITE_CHARACTER_MENU_ALT, MOD_SPRITE_CHARACTER_PORTRAITS_ALT, MOD_SPRITE_DEATH_SCREEN_ALT, MOD_SPRITE_COOP_MENU_ALT, MOD_SPRITE_CARD_FRONTS, MOD_SPRITE_CONTROLS, MOD_SPRITE_CONTROLS_ALT, MOD_SPRITE_DEATH_ITEMS, MOD_SPRITE_DEATH_ENEMIES, MOD_SPRITE_COUNT }; // What ModManager::modBanStatus says about playing online, each with its own popup. enum ModBanStatus { MOD_BAN_UNCHECKED, MOD_BAN_NONE, MOD_BAN_ACTIVE, MOD_BAN_PERMANENT, MOD_BAN_NEEDS_RESTART }; // A shader a mod's shaders.xml declares: its GLSL and the vertex parameters it takes, each with its float count, the // KAGE shader built from them and the render target Game::Render draws through it. // Destruction, which frees both, is the default. struct ModShader { std::map parameters; std::unique_ptr shader; std::string fragmentSource; std::string name; std::string vertexSource; KAGE::Graphics::ImagePtr renderTarget; int parametersSize = 0; void load(); void render_target_create(); void render_target_release(); void render_target_push(); void render(); }; // Construction (008f2d80) and destruction (008f2fb0) are the defaults. // A mod folder ListMods found: its metadata.xml, its folders, whether it loads, and what its content replaced. struct ModEntry { std::array contentSprites; std::list shaders; std::map collectibleIdMap; std::map trinketIdMap; std::vector tags; std::string contentDirectory; std::string dataDirectory; std::string directory; std::string metadataDescription; std::string metadataVersion; std::string metadataVisibility; std::string metadataWorkshopID; std::string name; std::string resourcesDirectory; bool isEnabled = true; bool isLoaded = true; bool isOutdated = false; std::string GetContentPath(std::string_view fileName); void WriteMetadata(); void load_content_anm2(ModContentSprite slot, std::string_view relativePath); void load_menu_sprites(); }; // Rebirth's Mod names the same object: its methods (008f99c0, 008f9cb0, 008f9e50) are ModEntry's. struct Mod : ModEntry { }; // A game path a mod replaces, and the mod that does, or no mod when none does. struct RedirectedPath { ModEntry* modEntry = nullptr; std::string filePath; }; // Where and how a mod's sprite is drawn in a menu. struct ModSpriteDraw { std::array blendMode{}; ColorMod color = COLOR_DEFAULT; Vector position{}; Vector scale = vector_make(1, 1); }; // Destruction (008f2ff0, 008fc570) is the default. // The installed mods: listing them, loading their content into the game's configs, their shaders, the game paths // their resources replace, and what they mean for online play. // Steam Workshop downloads (008fa390, 008fb120, 008f9f40) are dropped, with the progress text and loading sprite // Manager::Render showed while they ran. struct ModManager { ANM2 modDefaultsSprite; std::unordered_map redirectedPaths; std::vector> mods; ModEntry* loadingMod = nullptr; ModBanStatus modBanStatus = MOD_BAN_UNCHECKED; ModManager(); void ListMods(); void LoadModContent(); void LoadModItemPools(); void LoadModBossPools(); void LoadModCurses(); void LoadModRooms(int stageId, int mode); void LoadShaders(); void Reset(); void TriggerResize(); std::string TryRedirectPath(std::string_view filePath); bool is_any_mod_loaded(); void mods_unload(); void create_shader_render_targets(); void shader_render_targets_push(); void shader_render_targets_release(); void shaders_render(); void unload_shaders(); static void RenderCustomCharacterMenu(int characterId, Vector& renderPos, ANM2& defaultSprite); static void RenderCustomGameOver(int playerType, Vector& position); void RenderCustomCharacterPortraits(int characterId, ModSpriteDraw& draw); void RenderCustomCollectionItem(unsigned int itemId, ModSpriteDraw& draw); };