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

Method loadAsync

Source/Cache/Cache.cpp:87–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87void Cache::loadAsync(String filename, const std::function<void(bool)>& callback) {
88 auto tokens = filename.split(":"_slice);
89 if (tokens.size() == 2) {
90 switch (Switch::hash(tokens.front())) {
91 case "model"_hash:
92 SharedModelCache.loadAsync(tokens.back(), [callback](ModelDef* res) {
93 callback(res != nullptr);
94 });
95 return;
96 case "spine"_hash:
97 SharedSkeletonCache.loadAsync(tokens.back(), [callback](SkeletonData* res) {
98 callback(res != nullptr);
99 });
100 return;
101 case "bone"_hash:
102 SharedDragonBoneCache.loadAsync(tokens.back(), [callback](bool res) {
103 callback(res);
104 });
105 return;
106 case "font"_hash:
107 SharedFontCache.loadAync(tokens.back(), [callback](Font* res) {
108 callback(res != nullptr);
109 });
110 return;
111 default:
112 break;
113 }
114 }
115 auto clipTokens = filename.split("|"_slice);
116 if (clipTokens.size() == 2) {
117 filename = clipTokens.front();
118 }
119 std::string ext = Path::getExt(filename);
120 if (!ext.empty()) {
121 switch (Switch::hash(ext)) {
122 case "clip"_hash:
123 SharedClipCache.loadAsync(filename, [callback](ClipDef* res) {
124 callback(res != nullptr);
125 });
126 break;
127 case "frame"_hash:
128 SharedFrameCache.loadAsync(filename, [callback](FrameActionDef* res) {
129 callback(res != nullptr);
130 });
131 break;
132 case "model"_hash:
133 SharedModelCache.loadAsync(filename, [callback](ModelDef* res) {
134 callback(res != nullptr);
135 });
136 break;
137 case "par"_hash:
138 SharedParticleCache.loadAsync(filename, [callback](ParticleDef* res) {
139 callback(res != nullptr);
140 });
141 break;
142 case "jpg"_hash:
143 case "png"_hash:
144 case "dds"_hash:

Callers 3

preloadAsyncFunction · 0.45
loadPreviewImageMethod · 0.45
content_load_asyncFunction · 0.45

Calls 9

loadAyncMethod · 0.80
splitMethod · 0.65
toStringMethod · 0.65
hashFunction · 0.50
ErrorEnum · 0.50
sizeMethod · 0.45
frontMethod · 0.45
backMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected