sp<ImageSet> PCKLoader::load_shadow(Data &data, UString PckFilename, UString TabFilename, uint8_t shadedIdx) { TRACE_FN; auto imageSet = mksp<ImageSet>(); auto tabFile = data.fs.open(TabFilename); if (!tabFile) { LogWarning("Failed to open tab \"%s\"", TabFilename.c_str()); return nullptr; } auto pckFile = data.fs.open(PckFilename); if (!pckFile) { LogWarning("Failed to open tab \"%s\"", TabFilename.c_str()); return nullptr; } imageSet->maxSize = {0, 0}; uint32_t offset = 0; unsigned idx = 0; while (tabFile.read(reinterpret_cast<char *>(&offset), sizeof(offset))) { // shadow TAB files store the offset directly pckFile.seekg(offset, std::ios::beg); if (!pckFile) { LogError("Failed to seek to offset %u", offset); return nullptr; } auto img = loadShadow(pckFile, shadedIdx); if (!img) { LogError("Failed to load image"); return nullptr; } imageSet->images.push_back(img); img->owningSet = imageSet; img->CalculateBounds(); img->indexInSet = idx++; if (img->size.x > imageSet->maxSize.x) imageSet->maxSize.x = img->size.x; if (img->size.y > imageSet->maxSize.y) imageSet->maxSize.y = img->size.y; } LogInfo("Loaded %u images", static_cast<unsigned>(imageSet->images.size())); return imageSet; }
Card::Card(std::vector<std::string> inSvCat, std::vector<std::string> inEnCat, std::string inSvH, std::string inSvT, std::string inEnH, std::string inEnT, glm::vec3 inPos, glm::vec2 inVel, std::string textPath, SDL_Renderer* r) : pos(inPos) , velocity(inVel) , lifeTime(clock()) , path(textPath) , isReading(false) , isTrans(false) { infoIndex = infoIndexGenerator++; loadingText(r, inSvH, inSvT, inEnH, inEnT, inSvCat, inEnCat); if (shadow == NULL) { shadow = loadShadow(r); } if (arrow == NULL) { arrow = loadArrow(r); } }
PaletteImage PCK::load(std::istream &pckFile, PCKType type) { switch (type) { case PCKType::RLEA: return loadRLEA(pckFile); case PCKType::RLEB: return loadRLEB(pckFile); case PCKType::BLK: return loadBLK(pckFile); case PCKType::SHADOW: return loadShadow(pckFile); default: std::cerr << "Unexpected PCKType\n"; assert(0); } }