axmol/extensions/cocostudio/WidgetReader/NodeReaderProtocol.h

185 lines
5.8 KiB
C
Raw Normal View History

2021-12-26 23:26:34 +08:00
/****************************************************************************
2020-10-17 16:32:16 +08:00
Copyright (c) 2014 cocos2d-x.org
2021-12-25 10:04:45 +08:00
2020-10-17 16:32:16 +08:00
http://www.cocos2d-x.org
2021-12-25 10:04:45 +08:00
2020-10-17 16:32:16 +08:00
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
2021-12-25 10:04:45 +08:00
2020-10-17 16:32:16 +08:00
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
2021-12-25 10:04:45 +08:00
2020-10-17 16:32:16 +08:00
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __cocos2d_libs__NodeReaderProtocol__
#define __cocos2d_libs__NodeReaderProtocol__
#include "CocosStudioExport.h"
#include "CocosStudioExtension.h"
2020-10-17 16:32:16 +08:00
#include "ui/GUIDefine.h"
#include "pugixml/pugixml.hpp"
#include "pugixml/pugiext.hpp"
#define CCS_DEF_FONT "Microsoft YaHei"
namespace flatbuffers
{
2021-12-25 10:04:45 +08:00
class FlatBufferBuilder;
template <typename T>
struct Offset;
2020-10-17 16:32:16 +08:00
2021-12-25 10:04:45 +08:00
class Table;
struct ResourceData; // x-studio spec, csb batch load support, assets hook functions.
} // namespace flatbuffers
2020-10-17 16:32:16 +08:00
namespace cocos2d
{
2021-12-25 10:04:45 +08:00
class Node;
2020-10-17 16:32:16 +08:00
}
#if !defined(GL_ONE)
2021-12-25 10:04:45 +08:00
# define GL_ZERO 0
# define GL_ONE 1
# define GL_SRC_COLOR 0x0300
# define GL_ONE_MINUS_SRC_COLOR 0x0301
# define GL_SRC_ALPHA 0x0302
# define GL_ONE_MINUS_SRC_ALPHA 0x0303
# define GL_DST_ALPHA 0x0304
# define GL_ONE_MINUS_DST_ALPHA 0x0305
# define GL_DST_COLOR 0x0306
# define GL_ONE_MINUS_DST_COLOR 0x0307
# define GL_SRC_ALPHA_SATURATE 0x0308
# define GL_NONE 0
2020-10-17 16:32:16 +08:00
#endif
// V4 blendFunc not GL compatible only
2021-12-25 10:04:45 +08:00
struct GLBlendFunc
{
2020-10-17 16:32:16 +08:00
int src = GL_ONE;
int dst = GL_ONE_MINUS_SRC_ALPHA;
};
namespace cocostudio
{
2021-12-25 10:04:45 +08:00
class CCS_DLL NodeReaderProtocol
{
public:
NodeReaderProtocol();
virtual ~NodeReaderProtocol();
virtual void setCurrentCustomClassName(const char* className);
virtual flatbuffers::Offset<flatbuffers::Table> createOptionsWithFlatBuffers(
pugi::xml_node objectData,
flatbuffers::FlatBufferBuilder* builder) = 0;
virtual void setPropsWithFlatBuffers(cocos2d::Node* node, const flatbuffers::Table* nodeOptions) = 0;
virtual cocos2d::Node* createNodeWithFlatBuffers(const flatbuffers::Table* nodeOptions) = 0;
};
} // namespace cocostudio
2020-10-17 16:32:16 +08:00
// x-studio spec, csb batch load support, assets hook functions.
namespace cocostudio
{
2021-12-25 10:04:45 +08:00
class Armature;
namespace timeline
{
class SkeletonNode;
class BoneNode;
} // namespace timeline
}; // namespace cocostudio
2020-10-17 16:32:16 +08:00
2021-12-25 10:04:45 +08:00
namespace cocos2d
{
// builtin ui predecl
class Sprite;
class Camera;
class Sprite3D;
class PUParticleSystem3D;
class ParticleSystemQuad;
namespace ui
{
class ImageView;
class Button;
class CheckBox;
class Slider;
class LoadingBar;
class Text;
class TextField;
class TextAtlas;
class TextBMFont;
class Layout;
class ScrollView;
class ListView;
class PageView;
class Widget;
} // namespace ui
typedef void (*APP_LOGERROR_FUNC)(const char* pszFormat, ...);
namespace wext
{
// engine extends APIs
// TODO-2020
CC_DLL extern APP_LOGERROR_FUNC getAppErrorLogFunc();
CCS_DLL extern void (*onLoadSpriteFramesWithFile)(std::string& file);
CCS_DLL extern cocos2d::ResourceData makeResourceData(const flatbuffers::ResourceData* data);
2021-12-26 23:26:34 +08:00
CCS_DLL extern cocos2d::ResourceData makeResourceData(std::string_view path, int type = 0);
2021-12-25 10:04:45 +08:00
CCS_DLL extern cocos2d::ResourceData makeResourceData(std::string&& path, int type = 0);
CCS_DLL extern void resetReaderAllHooks();
/// Assets Hooks
CCS_DLL extern bool (*onBeforeLoadObjectAsset)(cocos2d::Node*, cocos2d::ResourceData& assets, int index /*= 0*/);
// Object creator Hooks
CCS_DLL extern cocos2d::Node* (*aNode)();
CCS_DLL extern cocos2d::ui::Widget* (*aWidget)();
CCS_DLL extern cocos2d::Sprite* (*aSprite)();
CCS_DLL extern cocos2d::ui::ImageView* (*aImageView)();
CCS_DLL extern cocos2d::ui::Button* (*aButton)();
CCS_DLL extern cocos2d::ui::CheckBox* (*aCheckBox)();
CCS_DLL extern cocos2d::ui::Slider* (*aSlider)();
CCS_DLL extern cocos2d::ui::LoadingBar* (*aLoadingBar)();
CCS_DLL extern cocos2d::ui::Text* (*aText)();
CCS_DLL extern cocos2d::ui::TextField* (*aTextField)();
CCS_DLL extern cocos2d::ui::TextAtlas* (*aTextAtlas)();
CCS_DLL extern cocos2d::ui::TextBMFont* (*aTextBMFont)();
CCS_DLL extern cocos2d::ui::Layout* (*aLayout)();
CCS_DLL extern cocos2d::ui::ScrollView* (*aScrollView)();
CCS_DLL extern cocos2d::ui::ListView* (*aListView)();
CCS_DLL extern cocos2d::ui::PageView* (*aPageView)();
CCS_DLL extern cocos2d::Node* (*aArmatureNode)();
CCS_DLL extern cocostudio::timeline::SkeletonNode* (*aSkeletonNode)();
CCS_DLL extern cocostudio::timeline::BoneNode* (*aBoneNode)();
2021-12-27 13:52:08 +08:00
CCS_DLL extern cocos2d::ParticleSystemQuad* (*aParticleSystemQuad)(std::string_view);
2021-12-25 10:04:45 +08:00
CCS_DLL extern cocos2d::Node* (*aNestingNode)(std::string);
///// 3d objects /////
CCS_DLL extern cocos2d::Node* (*aNode3D)();
CCS_DLL extern cocos2d::Node* (*aGameNode3D)();
CCS_DLL extern cocos2d::Node* (*aLight3D)();
CCS_DLL extern cocos2d::Camera* (*aCamera)();
CCS_DLL extern cocos2d::Sprite3D* (*aSprite3D)();
CCS_DLL extern cocos2d::Node* (*aParticleSystem3D)();
}; // namespace wext
}; // namespace cocos2d
2020-10-17 16:32:16 +08:00
#endif /* defined(__cocos2d_libs__NodeReaderProtocol__) */