#include "remorse/file_system.h" #include "remorse/fixed_map.h" #include "remorse/map_renderer.h" #include #include #include int main() { const auto root = remorse::findGameDataRoot(std::filesystem::current_path()); assert(root.has_value()); remorse::MapRenderOptions options; options.mapIndex = 1; options.maxWidth = 320; options.maxHeight = 200; const auto image = remorse::renderMapPreview(*root, options); assert(image.has_value()); assert(image->width > 0); assert(image->height > 0); assert(!image->pixels.empty()); assert(image->decodedItemCount > 0); assert(image->paintedItemCount > 0); const auto fixedPath = remorse::resolveGameDataPath(*root, std::filesystem::path("STATIC") / "FIXED.DAT"); assert(fixedPath.has_value()); const auto archive = remorse::loadFixedMapArchive(*fixedPath); assert(archive.has_value()); const auto fixedMap = remorse::loadFixedMap(*archive, options.mapIndex); assert(fixedMap.has_value()); remorse::s32 minX = fixedMap->entries.front().x; remorse::s32 minY = fixedMap->entries.front().y; remorse::s32 maxX = minX; remorse::s32 maxY = minY; for (const remorse::FixedMapEntry& entry : fixedMap->entries) { minX = std::min(minX, static_cast(entry.x)); minY = std::min(minY, static_cast(entry.y)); maxX = std::max(maxX, static_cast(entry.x)); maxY = std::max(maxY, static_cast(entry.y)); } options.maxWidth = 1280; options.maxHeight = 760; options.viewCenter = remorse::WorldPoint{(minX + maxX) / 2, (minY + maxY) / 2, 0}; const auto centeredImage = remorse::renderMapPreview(*root, options); assert(centeredImage.has_value()); assert(centeredImage->paintedItemCount > 0); assert(centeredImage->width == options.maxWidth); assert(centeredImage->height == options.maxHeight); const remorse::ScreenPoint center = remorse::projectToScreen(*options.viewCenter); assert(centeredImage->sourceLeft == center.x - static_cast(options.maxWidth / 2)); assert(centeredImage->sourceTop == center.y - static_cast(options.maxHeight / 2)); return 0; }