mirror of https://github.com/axmolengine/axmol.git
79 lines
3.5 KiB
C++
79 lines
3.5 KiB
C++
/****************************************************************************
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
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:
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
all copies or substantial portions of the Software.
|
|
|
|
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.
|
|
****************************************************************************/
|
|
|
|
#include "editor-support/cocosbuilder/CCLayerGradientLoader.h"
|
|
|
|
using namespace cocos2d;
|
|
|
|
#define PROPERTY_STARTCOLOR "startColor"
|
|
#define PROPERTY_ENDCOLOR "endColor"
|
|
#define PROPERTY_STARTOPACITY "startOpacity"
|
|
#define PROPERTY_ENDOPACITY "endOpacity"
|
|
#define PROPERTY_VECTOR "vector"
|
|
#define PROPERTY_BLENDFUNC "blendFunc"
|
|
|
|
namespace cocosbuilder {
|
|
|
|
void LayerGradientLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * ccbReader) {
|
|
if(strcmp(pPropertyName, PROPERTY_STARTCOLOR) == 0) {
|
|
((LayerGradient *)pNode)->setStartColor(pColor3B);
|
|
} else if(strcmp(pPropertyName, PROPERTY_ENDCOLOR) == 0) {
|
|
((LayerGradient *)pNode)->setEndColor(pColor3B);
|
|
} else {
|
|
LayerLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pColor3B, ccbReader);
|
|
}
|
|
}
|
|
|
|
void LayerGradientLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader) {
|
|
if(strcmp(pPropertyName, PROPERTY_STARTOPACITY) == 0) {
|
|
((LayerGradient *)pNode)->setStartOpacity(pByte);
|
|
} else if(strcmp(pPropertyName, PROPERTY_ENDOPACITY) == 0) {
|
|
((LayerGradient *)pNode)->setEndOpacity(pByte);
|
|
} else {
|
|
LayerLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, ccbReader);
|
|
}
|
|
}
|
|
|
|
void LayerGradientLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * ccbReader) {
|
|
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
|
|
((LayerGradient *)pNode)->setBlendFunc(pBlendFunc);
|
|
} else {
|
|
LayerLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pBlendFunc, ccbReader);
|
|
}
|
|
}
|
|
|
|
|
|
void LayerGradientLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Vec2 pPoint, CCBReader * ccbReader) {
|
|
if(strcmp(pPropertyName, PROPERTY_VECTOR) == 0) {
|
|
((LayerGradient *)pNode)->setVector(pPoint);
|
|
|
|
// TODO: Not passed along the ccbi file.
|
|
// ((LayerGradient *)pNode)->setCompressedInterpolation(true);
|
|
} else {
|
|
LayerLoader::onHandlePropTypePoint(pNode, pParent, pPropertyName, pPoint, ccbReader);
|
|
}
|
|
}
|
|
|
|
}
|