MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / loadImageSet

Method loadImageSet

framework/data.cpp:271–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

269}
270
271sp<ImageSet> DataImpl::loadImageSet(const UString &path)
272{
273 std::lock_guard<std::recursive_mutex> l(this->imageSetCacheLock);
274
275 auto alias = this->imageSetAliases.find(path);
276 if (alias != this->imageSetAliases.end())
277 {
278 LogInfo("Using alias \"%s\" for \"%s\"", path, alias->second);
279 return this->loadImageSet(alias->second);
280 }
281
282 UString cacheKey = to_upper(path);
283 sp<ImageSet> imgSet = this->imageSetCache[cacheKey].lock();
284 if (imgSet)
285 {
286 return imgSet;
287 }
288 // Raw resources come in the format:
289 //"RAW:PATH:WIDTH:HEIGHT[:optional/ignored]"
290 if (path.substr(0, 4) == "RAW:")
291 {
292 auto splitString = split(path, ":");
293 imgSet = RawImage::loadSet(
294 *this, splitString[1],
295 Vec2<int>{Strings::toInteger(splitString[2]), Strings::toInteger(splitString[3])});
296 }
297 // PCK resources come in the format:
298 //"PCK:PCKFILE:TABFILE[:optional/ignored]"
299 else if (path.substr(0, 4) == "PCK:")
300 {
301 auto splitString = split(path, ":");
302 imgSet = PCKLoader::load(*this, splitString[1], splitString[2]);
303 }
304 else if (path.substr(0, 9) == "PCKSTRAT:")
305 {
306 auto splitString = split(path, ":");
307 imgSet = PCKLoader::loadStrat(*this, splitString[1], splitString[2]);
308 }
309 else if (path.substr(0, 10) == "PCKSHADOW:")
310 {
311 auto splitString = split(path, ":");
312 imgSet = PCKLoader::loadShadow(*this, splitString[1], splitString[2]);
313 }
314 else
315 {
316 LogError("Unknown image set format \"%s\"", path);
317 return nullptr;
318 }
319
320 this->pinnedImageSets.push(imgSet);
321 this->pinnedImageSets.pop();
322
323 this->imageSetCache[cacheKey] = imgSet;
324 imgSet->path = path;
325 return imgSet;
326}
327
328sp<Sample> DataImpl::loadSample(UString path)

Callers 3

loadImageMethod · 0.95
bulkExportPcksMethod · 0.80
dumpPckFunction · 0.80

Calls 5

to_upperFunction · 0.85
splitFunction · 0.85
endMethod · 0.80
pushMethod · 0.80
popMethod · 0.80

Tested by

no test coverage detected