axmol/extensions/cocostudio/WidgetReader/NodeReaderProtocol.h

184 lines
5.6 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
2022-08-08 18:02:17 +08:00
https://axys1.github.io/
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
NS_AX_BEGIN
2021-12-25 10:04:45 +08:00
class Node;
NS_AX_END
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;
2022-08-08 18:02:17 +08:00
virtual void setPropsWithFlatBuffers(ax::Node* node, const flatbuffers::Table* nodeOptions) = 0;
virtual ax::Node* createNodeWithFlatBuffers(const flatbuffers::Table* nodeOptions) = 0;
2021-12-25 10:04:45 +08:00
};
} // 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
NS_AX_BEGIN
2021-12-25 10:04:45 +08:00
// builtin ui predecl
class Sprite;
class Camera;
2022-07-05 23:47:25 +08:00
class MeshRenderer;
2021-12-25 10:04:45 +08:00
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
2022-07-15 19:17:01 +08:00
AX_DLL extern APP_LOGERROR_FUNC getAppErrorLogFunc();
2021-12-25 10:04:45 +08:00
CCS_DLL extern void (*onLoadSpriteFramesWithFile)(std::string& file);
2022-08-08 18:02:17 +08:00
CCS_DLL extern ax::ResourceData makeResourceData(const flatbuffers::ResourceData* data);
CCS_DLL extern ax::ResourceData makeResourceData(std::string_view path, int type = 0);
CCS_DLL extern ax::ResourceData makeResourceData(std::string&& path, int type = 0);
2021-12-25 10:04:45 +08:00
CCS_DLL extern void resetReaderAllHooks();
/// Assets Hooks
2022-08-08 18:02:17 +08:00
CCS_DLL extern bool (*onBeforeLoadObjectAsset)(ax::Node*, ax::ResourceData& assets, int index /*= 0*/);
2021-12-25 10:04:45 +08:00
// Object creator Hooks
2022-08-08 18:02:17 +08:00
CCS_DLL extern ax::Node* (*aNode)();
CCS_DLL extern ax::ui::Widget* (*aWidget)();
CCS_DLL extern ax::Sprite* (*aSprite)();
CCS_DLL extern ax::ui::ImageView* (*aImageView)();
CCS_DLL extern ax::ui::Button* (*aButton)();
CCS_DLL extern ax::ui::CheckBox* (*aCheckBox)();
CCS_DLL extern ax::ui::Slider* (*aSlider)();
CCS_DLL extern ax::ui::LoadingBar* (*aLoadingBar)();
CCS_DLL extern ax::ui::Text* (*aText)();
CCS_DLL extern ax::ui::TextField* (*aTextField)();
CCS_DLL extern ax::ui::TextAtlas* (*aTextAtlas)();
CCS_DLL extern ax::ui::TextBMFont* (*aTextBMFont)();
CCS_DLL extern ax::ui::Layout* (*aLayout)();
CCS_DLL extern ax::ui::ScrollView* (*aScrollView)();
CCS_DLL extern ax::ui::ListView* (*aListView)();
CCS_DLL extern ax::ui::PageView* (*aPageView)();
CCS_DLL extern ax::Node* (*aArmatureNode)();
2021-12-25 10:04:45 +08:00
CCS_DLL extern cocostudio::timeline::SkeletonNode* (*aSkeletonNode)();
CCS_DLL extern cocostudio::timeline::BoneNode* (*aBoneNode)();
2022-08-08 18:02:17 +08:00
CCS_DLL extern ax::ParticleSystemQuad* (*aParticleSystemQuad)(std::string_view);
CCS_DLL extern ax::Node* (*aNestingNode)(std::string);
2021-12-25 10:04:45 +08:00
///// 3d objects /////
2022-08-08 18:02:17 +08:00
CCS_DLL extern ax::Node* (*aNode3D)();
CCS_DLL extern ax::Node* (*aGameNode3D)();
CCS_DLL extern ax::Node* (*aLight3D)();
CCS_DLL extern ax::Camera* (*aCamera)();
CCS_DLL extern ax::MeshRenderer* (*aSprite3D)();
CCS_DLL extern ax::Node* (*aParticleSystem3D)();
} // namespace wext
NS_AX_END // namespace ax
2020-10-17 16:32:16 +08:00
#endif /* defined(__cocos2d_libs__NodeReaderProtocol__) */