MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / loadAsync

Method loadAsync

Source/Cache/TMXCache.cpp:23–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23void TMXDef::loadAsync(String filename, const std::function<void(bool)>& callback) {
24 this->retain();
25 auto file = filename.toString();
26 SharedContent.getThread()->run([file, this]() {
27 return Values::alloc(this->_map.loadUnsafe(file));
28 },
29 [callback, this](Own<Values> values) {
30 bool done = false;
31 values->get(done);
32 if (!done) {
33 callback(false);
34 return;
35 }
36 std::unordered_set<std::string> images;
37 for (const auto& tileset : this->_map.getTilesets()) {
38 images.insert(tileset.getImagePath());
39 }
40 auto imageCopies = std::make_shared<std::unordered_set<std::string>>(images);
41 for (const auto& image : images) {
42 SharedTextureCache.loadAsync(image, [image, imageCopies, callback](Texture2D* tex) {
43 if (imageCopies->empty()) {
44 return;
45 }
46 if (tex) {
47 imageCopies->erase(image);
48 } else {
49 imageCopies->clear();
50 callback(false);
51 return;
52 }
53 if (imageCopies->empty()) {
54 callback(true);
55 }
56 });
57 }
58 this->release();
59 });
60}
61
62/* TMXCache */
63

Callers

nothing calls this directly

Calls 15

getFullPathMethod · 0.80
toStringMethod · 0.65
runMethod · 0.65
getMethod · 0.65
insertMethod · 0.65
clearMethod · 0.65
findMethod · 0.65
allocFunction · 0.50
createFunction · 0.50
retainMethod · 0.45
getThreadMethod · 0.45
loadUnsafeMethod · 0.45

Tested by

no test coverage detected