// // NodeReaderProtocol.cpp // cocos2d_libs // // Created by pipu on 14/11/18. // // #include "WidgetReader/NodeReaderProtocol.h" #include "CSParseBinary_generated.h" // flatbuffers::ResourceData, it's ok for all revision of loaders #include "cocos2d.h" #include "ui/CocosGUI.h" #include "Armature.h" #include "ActionTimeline/SkeletonNode.h" // x-studio spec, csb batch load support, assets hook functions. static bool onLoadObjectAssetDummy(ax::Node*, ax::ResourceData& assets, int index) { return false; } template static _T* object_create_func() { return _T::create(); } static ax::Node* createArmatureNode() { return cocostudio::Armature::create(); } static ax::ParticleSystemQuad* createParticleSystemQuad(std::string_view path) { return ax::ParticleSystemQuad::create(path); } static ax::Node* createNestingNode(std::string) { return ax::Node::create(); } static void onLoadSpriteFramesWithFileDummy(std::string&) {} namespace cocostudio { NodeReaderProtocol::NodeReaderProtocol(){}; NodeReaderProtocol::~NodeReaderProtocol(){}; void NodeReaderProtocol::setCurrentCustomClassName(const char* className){}; } // namespace cocostudio NS_AX_BEGIN namespace wext { bool (*onBeforeLoadObjectAsset)(ax::Node*, ax::ResourceData& assets, int index /*= 0*/) = &onLoadObjectAssetDummy; bool (*onAfterLoadObjectAsset)(ax::Node*, ax::ResourceData& assets, int index /*= 0*/) = &onLoadObjectAssetDummy; void (*onLoadSpriteFramesWithFile)(std::string& file) = nullptr; void (*onNestingNodeLoading)(std::string_view filePath) = nullptr; void (*onNestingNodeLoaded)(ax::Node*, std::string_view filePath) = nullptr; ax::Node* (*aNode)(); ax::ui::Widget* (*aWidget)(); ax::Sprite* (*aSprite)(); ax::ui::ImageView* (*aImageView)(); ax::ui::Button* (*aButton)(); ax::ui::CheckBox* (*aCheckBox)(); ax::ui::Slider* (*aSlider)(); ax::ui::LoadingBar* (*aLoadingBar)(); ax::ui::Text* (*aText)(); ax::ui::TextField* (*aTextField)(); ax::ui::TextAtlas* (*aTextAtlas)(); ax::ui::TextBMFont* (*aTextBMFont)(); ax::ui::Layout* (*aLayout)(); ax::ui::ScrollView* (*aScrollView)(); ax::ui::ListView* (*aListView)(); ax::ui::PageView* (*aPageView)(); ax::ParticleSystemQuad* (*aParticleSystemQuad)(std::string_view); ax::Node* (*aArmatureNode)(); cocostudio::timeline::SkeletonNode* (*aSkeletonNode)(); cocostudio::timeline::BoneNode* (*aBoneNode)(); ax::Node* (*aNestingNode)(std::string); // 3d stubs ax::Node* (*aNode3D)(); ax::Node* (*aGameNode3D)(); ax::Node* (*aLight3D)(); ax::Camera* (*aCamera)(); ax::MeshRenderer* (*aSprite3D)(); ax::Node* (*aParticleSystem3D)(); void resetReaderAllHooks() { onLoadSpriteFramesWithFile = onLoadSpriteFramesWithFileDummy; onBeforeLoadObjectAsset = onLoadObjectAssetDummy; onAfterLoadObjectAsset = onLoadObjectAssetDummy; onNestingNodeLoaded = nullptr; onNestingNodeLoading = nullptr; aNode = object_create_func; aSprite = object_create_func; aWidget = object_create_func; aImageView = object_create_func; aButton = object_create_func; aCheckBox = object_create_func; aSlider = object_create_func; aLoadingBar = object_create_func; aText = object_create_func; aTextField = object_create_func; aTextAtlas = object_create_func; aTextBMFont = object_create_func; aLayout = object_create_func; aScrollView = object_create_func; aListView = object_create_func; aPageView = object_create_func; aSkeletonNode = object_create_func; aBoneNode = object_create_func; aArmatureNode = createArmatureNode; aParticleSystemQuad = &createParticleSystemQuad; aNestingNode = createNestingNode; } static uint8_t _AUTO_INIT_VARS = (resetReaderAllHooks(), 0); } // namespace wext NS_AX_END // namespace ax ax::ResourceData ax::wext::makeResourceData(const flatbuffers::ResourceData* orig) { ax::ResourceData fileData; fileData.file = orig->path()->c_str(); fileData.plist = orig->plistFile()->c_str(); fileData.type = orig->resourceType(); return fileData; } ax::ResourceData ax::wext::makeResourceData(std::string_view path, int type) { ax::ResourceData fileData; fileData.file = path; fileData.type = type; return fileData; } ax::ResourceData ax::wext::makeResourceData(std::string&& path, int type) { ax::ResourceData fileData; fileData.file = std::move(path); fileData.type = type; return fileData; }