This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-Qt/example/doric/loader/DoricAssetJSLoader.cpp
2021-07-21 19:03:29 +08:00

24 lines
586 B
C++

#include "DoricAssetJSLoader.h"
#include "utils/DoricUtils.h"
DoricAssetJSLoader::DoricAssetJSLoader() {}
bool DoricAssetJSLoader::filter(QString source) {
return source.startsWith("assets");
}
std::shared_ptr<DoricAsyncResult> DoricAssetJSLoader::request(QString source) {
QString protocol = "assets://";
QString assetPath = source.mid(protocol.length());
QString script = DoricUtils::readAssetFile("/" + assetPath);
std::shared_ptr<DoricAsyncResult> asyncResult =
std::make_shared<DoricAsyncResult>();
asyncResult->setResult(script);
return asyncResult;
}