#pragma once #include "anm2.h" #include "kage_graphics.h" #include #include #include #include #include // backdrops.xml fills ids 1 to 62. Id 0 is the default the others start from. constexpr int BACKDROP_COUNT = 63; // How a piece of a backdrop sheet is mirrored as it is drawn, by bit. enum Flip { FLIP_NONE, FLIP_X, FLIP_Y, FLIP_XY }; // Which walls a wall detail sprite shows its layers on, by bit: the layers named h... on the top and bottom walls, the // layers named v... on the side walls. enum WallSides { WALL_SIDES_NONE, WALL_SIDES_HORIZONTAL, WALL_SIDES_VERTICAL, WALL_SIDES_ALL }; // Construction, copies, assignment and destruction (00931de0, 00934600, 00934430, 009324f0) are the defaults. // A room background of backdrops.xml: its wall and floor sheet and how many walls and floors it cuts into, the floor // overlays, the water, and the grid graphics (rocks, pits, doors ...) rooms of it use. Paths are under resources/. struct BackdropConfig { std::string bridge; std::string door; std::string gfx; std::string holeInWall; std::string lFloorGfx; std::string nFloorGfx; std::string pit; std::string props; std::string rocks; std::string spikes; std::string waterGfx; std::string waterPit; int backdropId = 0; int floors = 0; int floorVariants = 0; int walls = 0; int wallVariants = 0; uint8_t waterPitsMode = 0; bool isFullImage = false; bool isReverseWaterGfx = false; }; // A cell of wall drawn into the wall surface, for the effects its backdrop adds there: where it was drawn, its place on // the sheet's block (slotX along the top wall, slotY down the side wall), the sheet's wall row and its variant. struct WallSlot { DestinationQuad quad{}; int slotX = 0; int slotY = 0; int variant = 0; int wallRow = 0; Flip flip = FLIP_NONE; }; // A corner of the room's walls a wall detail sprite is drawn at, and how likely each of its layers shows. struct WallDetail { Vector position{}; float chance = 0; Flip flip = FLIP_NONE; WallSides sides = WALL_SIDES_NONE; }; // One row of the start room's control icons, laid out from the left: each icon's button frame and position, the // cursor the icons are drawn from, and the controller whose bindings they show. struct ControlRow { std::vector frames; std::vector positions; float cursorX = 0; float x = 0; int controllerIndex = 0; }; // Destruction (00932570) is the default. // A room's background (Room's backdrop): the configs of backdrops.xml, and the walls, floor and water of the // room's backdrop, drawn once into surfaces the room renders from. struct Backdrop { std::array configs; KAGE::Graphics::ImagePtr floorBuffer; KAGE::Graphics::ImagePtr floorSurface2; KAGE::Graphics::ImagePtr gfx; KAGE::Graphics::ImagePtr nlFloorGfx; KAGE::Graphics::ImagePtr tempBackdropSurface; KAGE::Graphics::ImagePtr wallsBuffer; KAGE::Graphics::ImagePtr waterGfx; ANM2 controlsButtonsSprite; ANM2 controlsSprite; ANM2 floorSprite; ANM2 wallDetailSprite; RNG rng = {}; Vector roomBottomRight{}; Vector roomTopLeft{}; uint32_t backdropId = 0; uint32_t seed = 0; bool isTempSurfaceUsed = false; Backdrop(); bool LoadConfig(std::string_view path); void Init(uint32_t id, bool isLoadGraphics); uint32_t get_random_floor_variant(); DestinationQuad render_grid_rect(int x, int y, int width, int height); void load_details(); void render_ashpit_ash(); void render_floor_to_target(uint32_t variant, const KAGE::Graphics::ImagePtr& sheet, const KAGE::Graphics::ImagePtr& alternate); void PreRenderControls(); void render_control_icon(ControlRow& row, int action); void pre_render_walls(); void spawn_wall_details(const WallSlot& slot); void render_wall_detail(const WallDetail& detail); void RenderFloor(Vector renderOffset, ColorMod color); void render_floor_surface(Vector renderOffset, ColorMod color); void RenderWalls(Vector renderOffset, ColorMod color); void render_wall_borders(Vector roomTopLeftPos, Vector roomSize); void RenderWater(Vector renderOffset); }; int controller_button_to_glyph_frame(int button); Vector backdrop_detail_to_world_pos(Vector position); Vector backdrop_wall_normal(int slotX, Flip flip);