Update CSParseBinary_generated

This commit is contained in:
pipu 2015-04-08 16:54:58 +08:00
parent 16aa704ffd
commit ca74486f60
4 changed files with 272 additions and 13 deletions

View File

@ -53,6 +53,7 @@ struct Color;
struct ColorVector; struct ColorVector;
struct FlatSize; struct FlatSize;
struct CapInsets; struct CapInsets;
struct BlendFunc;
struct ResourceData; struct ResourceData;
MANUALLY_ALIGNED_STRUCT(4) RotationSkew { MANUALLY_ALIGNED_STRUCT(4) RotationSkew {
@ -175,6 +176,20 @@ MANUALLY_ALIGNED_STRUCT(4) CapInsets {
}; };
STRUCT_END(CapInsets, 16); STRUCT_END(CapInsets, 16);
MANUALLY_ALIGNED_STRUCT(4) BlendFunc {
private:
int32_t src_;
int32_t dst_;
public:
BlendFunc(int32_t src, int32_t dst)
: src_(flatbuffers::EndianScalar(src)), dst_(flatbuffers::EndianScalar(dst)) { }
int32_t src() const { return flatbuffers::EndianScalar(src_); }
int32_t dst() const { return flatbuffers::EndianScalar(dst_); }
};
STRUCT_END(BlendFunc, 8);
struct CSParseBinary : private flatbuffers::Table { struct CSParseBinary : private flatbuffers::Table {
const flatbuffers::String *version() const { return GetPointer<const flatbuffers::String *>(4); } const flatbuffers::String *version() const { return GetPointer<const flatbuffers::String *>(4); }
const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *textures() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(6); } const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *textures() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(6); }
@ -585,12 +600,14 @@ inline flatbuffers::Offset<SingleNodeOptions> CreateSingleNodeOptions(flatbuffer
struct SpriteOptions : private flatbuffers::Table { struct SpriteOptions : private flatbuffers::Table {
const WidgetOptions *nodeOptions() const { return GetPointer<const WidgetOptions *>(4); } const WidgetOptions *nodeOptions() const { return GetPointer<const WidgetOptions *>(4); }
const ResourceData *fileNameData() const { return GetPointer<const ResourceData *>(6); } const ResourceData *fileNameData() const { return GetPointer<const ResourceData *>(6); }
const BlendFunc *blendFunc() const { return GetStruct<const BlendFunc *>(8); }
bool Verify(flatbuffers::Verifier &verifier) const { bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) && return VerifyTableStart(verifier) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* nodeOptions */) && VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* nodeOptions */) &&
verifier.VerifyTable(nodeOptions()) && verifier.VerifyTable(nodeOptions()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 6 /* fileNameData */) && VerifyField<flatbuffers::uoffset_t>(verifier, 6 /* fileNameData */) &&
verifier.VerifyTable(fileNameData()) && verifier.VerifyTable(fileNameData()) &&
VerifyField<BlendFunc>(verifier, 8 /* blendFunc */) &&
verifier.EndTable(); verifier.EndTable();
} }
}; };
@ -600,18 +617,21 @@ struct SpriteOptionsBuilder {
flatbuffers::uoffset_t start_; flatbuffers::uoffset_t start_;
void add_nodeOptions(flatbuffers::Offset<WidgetOptions> nodeOptions) { fbb_.AddOffset(4, nodeOptions); } void add_nodeOptions(flatbuffers::Offset<WidgetOptions> nodeOptions) { fbb_.AddOffset(4, nodeOptions); }
void add_fileNameData(flatbuffers::Offset<ResourceData> fileNameData) { fbb_.AddOffset(6, fileNameData); } void add_fileNameData(flatbuffers::Offset<ResourceData> fileNameData) { fbb_.AddOffset(6, fileNameData); }
void add_blendFunc(const BlendFunc *blendFunc) { fbb_.AddStruct(8, blendFunc); }
SpriteOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SpriteOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
SpriteOptionsBuilder &operator=(const SpriteOptionsBuilder &); SpriteOptionsBuilder &operator=(const SpriteOptionsBuilder &);
flatbuffers::Offset<SpriteOptions> Finish() { flatbuffers::Offset<SpriteOptions> Finish() {
auto o = flatbuffers::Offset<SpriteOptions>(fbb_.EndTable(start_, 2)); auto o = flatbuffers::Offset<SpriteOptions>(fbb_.EndTable(start_, 3));
return o; return o;
} }
}; };
inline flatbuffers::Offset<SpriteOptions> CreateSpriteOptions(flatbuffers::FlatBufferBuilder &_fbb, inline flatbuffers::Offset<SpriteOptions> CreateSpriteOptions(flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<WidgetOptions> nodeOptions = 0, flatbuffers::Offset<WidgetOptions> nodeOptions = 0,
flatbuffers::Offset<ResourceData> fileNameData = 0) { flatbuffers::Offset<ResourceData> fileNameData = 0,
const BlendFunc *blendFunc = 0) {
SpriteOptionsBuilder builder_(_fbb); SpriteOptionsBuilder builder_(_fbb);
builder_.add_blendFunc(blendFunc);
builder_.add_fileNameData(fileNameData); builder_.add_fileNameData(fileNameData);
builder_.add_nodeOptions(nodeOptions); builder_.add_nodeOptions(nodeOptions);
return builder_.Finish(); return builder_.Finish();
@ -620,12 +640,14 @@ inline flatbuffers::Offset<SpriteOptions> CreateSpriteOptions(flatbuffers::FlatB
struct ParticleSystemOptions : private flatbuffers::Table { struct ParticleSystemOptions : private flatbuffers::Table {
const WidgetOptions *nodeOptions() const { return GetPointer<const WidgetOptions *>(4); } const WidgetOptions *nodeOptions() const { return GetPointer<const WidgetOptions *>(4); }
const ResourceData *fileNameData() const { return GetPointer<const ResourceData *>(6); } const ResourceData *fileNameData() const { return GetPointer<const ResourceData *>(6); }
const BlendFunc *blendFunc() const { return GetStruct<const BlendFunc *>(8); }
bool Verify(flatbuffers::Verifier &verifier) const { bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) && return VerifyTableStart(verifier) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* nodeOptions */) && VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* nodeOptions */) &&
verifier.VerifyTable(nodeOptions()) && verifier.VerifyTable(nodeOptions()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 6 /* fileNameData */) && VerifyField<flatbuffers::uoffset_t>(verifier, 6 /* fileNameData */) &&
verifier.VerifyTable(fileNameData()) && verifier.VerifyTable(fileNameData()) &&
VerifyField<BlendFunc>(verifier, 8 /* blendFunc */) &&
verifier.EndTable(); verifier.EndTable();
} }
}; };
@ -635,18 +657,21 @@ struct ParticleSystemOptionsBuilder {
flatbuffers::uoffset_t start_; flatbuffers::uoffset_t start_;
void add_nodeOptions(flatbuffers::Offset<WidgetOptions> nodeOptions) { fbb_.AddOffset(4, nodeOptions); } void add_nodeOptions(flatbuffers::Offset<WidgetOptions> nodeOptions) { fbb_.AddOffset(4, nodeOptions); }
void add_fileNameData(flatbuffers::Offset<ResourceData> fileNameData) { fbb_.AddOffset(6, fileNameData); } void add_fileNameData(flatbuffers::Offset<ResourceData> fileNameData) { fbb_.AddOffset(6, fileNameData); }
void add_blendFunc(const BlendFunc *blendFunc) { fbb_.AddStruct(8, blendFunc); }
ParticleSystemOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ParticleSystemOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
ParticleSystemOptionsBuilder &operator=(const ParticleSystemOptionsBuilder &); ParticleSystemOptionsBuilder &operator=(const ParticleSystemOptionsBuilder &);
flatbuffers::Offset<ParticleSystemOptions> Finish() { flatbuffers::Offset<ParticleSystemOptions> Finish() {
auto o = flatbuffers::Offset<ParticleSystemOptions>(fbb_.EndTable(start_, 2)); auto o = flatbuffers::Offset<ParticleSystemOptions>(fbb_.EndTable(start_, 3));
return o; return o;
} }
}; };
inline flatbuffers::Offset<ParticleSystemOptions> CreateParticleSystemOptions(flatbuffers::FlatBufferBuilder &_fbb, inline flatbuffers::Offset<ParticleSystemOptions> CreateParticleSystemOptions(flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<WidgetOptions> nodeOptions = 0, flatbuffers::Offset<WidgetOptions> nodeOptions = 0,
flatbuffers::Offset<ResourceData> fileNameData = 0) { flatbuffers::Offset<ResourceData> fileNameData = 0,
const BlendFunc *blendFunc = 0) {
ParticleSystemOptionsBuilder builder_(_fbb); ParticleSystemOptionsBuilder builder_(_fbb);
builder_.add_blendFunc(blendFunc);
builder_.add_fileNameData(fileNameData); builder_.add_fileNameData(fileNameData);
builder_.add_nodeOptions(nodeOptions); builder_.add_nodeOptions(nodeOptions);
return builder_.Finish(); return builder_.Finish();
@ -1011,6 +1036,14 @@ struct TextOptions : private flatbuffers::Table {
int32_t vAlignment() const { return GetField<int32_t>(20, 0); } int32_t vAlignment() const { return GetField<int32_t>(20, 0); }
uint8_t touchScaleEnable() const { return GetField<uint8_t>(22, 0); } uint8_t touchScaleEnable() const { return GetField<uint8_t>(22, 0); }
uint8_t isCustomSize() const { return GetField<uint8_t>(24, 0); } uint8_t isCustomSize() const { return GetField<uint8_t>(24, 0); }
uint8_t outlineEnabled() const { return GetField<uint8_t>(26, 0); }
const Color *outlineColor() const { return GetStruct<const Color *>(28); }
int32_t outlineSize() const { return GetField<int32_t>(30, 1); }
uint8_t shadowEnabled() const { return GetField<uint8_t>(32, 0); }
const Color *shadowColor() const { return GetStruct<const Color *>(34); }
float shadowOffsetX() const { return GetField<float>(36, 2); }
float shadowOffsetY() const { return GetField<float>(38, -2); }
int32_t shadowBlurRadius() const { return GetField<int32_t>(40, 0); }
bool Verify(flatbuffers::Verifier &verifier) const { bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) && return VerifyTableStart(verifier) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* widgetOptions */) && VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* widgetOptions */) &&
@ -1028,6 +1061,14 @@ struct TextOptions : private flatbuffers::Table {
VerifyField<int32_t>(verifier, 20 /* vAlignment */) && VerifyField<int32_t>(verifier, 20 /* vAlignment */) &&
VerifyField<uint8_t>(verifier, 22 /* touchScaleEnable */) && VerifyField<uint8_t>(verifier, 22 /* touchScaleEnable */) &&
VerifyField<uint8_t>(verifier, 24 /* isCustomSize */) && VerifyField<uint8_t>(verifier, 24 /* isCustomSize */) &&
VerifyField<uint8_t>(verifier, 26 /* outlineEnabled */) &&
VerifyField<Color>(verifier, 28 /* outlineColor */) &&
VerifyField<int32_t>(verifier, 30 /* outlineSize */) &&
VerifyField<uint8_t>(verifier, 32 /* shadowEnabled */) &&
VerifyField<Color>(verifier, 34 /* shadowColor */) &&
VerifyField<float>(verifier, 36 /* shadowOffsetX */) &&
VerifyField<float>(verifier, 38 /* shadowOffsetY */) &&
VerifyField<int32_t>(verifier, 40 /* shadowBlurRadius */) &&
verifier.EndTable(); verifier.EndTable();
} }
}; };
@ -1046,10 +1087,18 @@ struct TextOptionsBuilder {
void add_vAlignment(int32_t vAlignment) { fbb_.AddElement<int32_t>(20, vAlignment, 0); } void add_vAlignment(int32_t vAlignment) { fbb_.AddElement<int32_t>(20, vAlignment, 0); }
void add_touchScaleEnable(uint8_t touchScaleEnable) { fbb_.AddElement<uint8_t>(22, touchScaleEnable, 0); } void add_touchScaleEnable(uint8_t touchScaleEnable) { fbb_.AddElement<uint8_t>(22, touchScaleEnable, 0); }
void add_isCustomSize(uint8_t isCustomSize) { fbb_.AddElement<uint8_t>(24, isCustomSize, 0); } void add_isCustomSize(uint8_t isCustomSize) { fbb_.AddElement<uint8_t>(24, isCustomSize, 0); }
void add_outlineEnabled(uint8_t outlineEnabled) { fbb_.AddElement<uint8_t>(26, outlineEnabled, 0); }
void add_outlineColor(const Color *outlineColor) { fbb_.AddStruct(28, outlineColor); }
void add_outlineSize(int32_t outlineSize) { fbb_.AddElement<int32_t>(30, outlineSize, 1); }
void add_shadowEnabled(uint8_t shadowEnabled) { fbb_.AddElement<uint8_t>(32, shadowEnabled, 0); }
void add_shadowColor(const Color *shadowColor) { fbb_.AddStruct(34, shadowColor); }
void add_shadowOffsetX(float shadowOffsetX) { fbb_.AddElement<float>(36, shadowOffsetX, 2); }
void add_shadowOffsetY(float shadowOffsetY) { fbb_.AddElement<float>(38, shadowOffsetY, -2); }
void add_shadowBlurRadius(int32_t shadowBlurRadius) { fbb_.AddElement<int32_t>(40, shadowBlurRadius, 0); }
TextOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } TextOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
TextOptionsBuilder &operator=(const TextOptionsBuilder &); TextOptionsBuilder &operator=(const TextOptionsBuilder &);
flatbuffers::Offset<TextOptions> Finish() { flatbuffers::Offset<TextOptions> Finish() {
auto o = flatbuffers::Offset<TextOptions>(fbb_.EndTable(start_, 11)); auto o = flatbuffers::Offset<TextOptions>(fbb_.EndTable(start_, 19));
return o; return o;
} }
}; };
@ -1065,8 +1114,22 @@ inline flatbuffers::Offset<TextOptions> CreateTextOptions(flatbuffers::FlatBuffe
int32_t hAlignment = 0, int32_t hAlignment = 0,
int32_t vAlignment = 0, int32_t vAlignment = 0,
uint8_t touchScaleEnable = 0, uint8_t touchScaleEnable = 0,
uint8_t isCustomSize = 0) { uint8_t isCustomSize = 0,
uint8_t outlineEnabled = 0,
const Color *outlineColor = 0,
int32_t outlineSize = 1,
uint8_t shadowEnabled = 0,
const Color *shadowColor = 0,
float shadowOffsetX = 2,
float shadowOffsetY = -2,
int32_t shadowBlurRadius = 0) {
TextOptionsBuilder builder_(_fbb); TextOptionsBuilder builder_(_fbb);
builder_.add_shadowBlurRadius(shadowBlurRadius);
builder_.add_shadowOffsetY(shadowOffsetY);
builder_.add_shadowOffsetX(shadowOffsetX);
builder_.add_shadowColor(shadowColor);
builder_.add_outlineSize(outlineSize);
builder_.add_outlineColor(outlineColor);
builder_.add_vAlignment(vAlignment); builder_.add_vAlignment(vAlignment);
builder_.add_hAlignment(hAlignment); builder_.add_hAlignment(hAlignment);
builder_.add_areaHeight(areaHeight); builder_.add_areaHeight(areaHeight);
@ -1076,6 +1139,8 @@ inline flatbuffers::Offset<TextOptions> CreateTextOptions(flatbuffers::FlatBuffe
builder_.add_fontName(fontName); builder_.add_fontName(fontName);
builder_.add_fontResource(fontResource); builder_.add_fontResource(fontResource);
builder_.add_widgetOptions(widgetOptions); builder_.add_widgetOptions(widgetOptions);
builder_.add_shadowEnabled(shadowEnabled);
builder_.add_outlineEnabled(outlineEnabled);
builder_.add_isCustomSize(isCustomSize); builder_.add_isCustomSize(isCustomSize);
builder_.add_touchScaleEnable(touchScaleEnable); builder_.add_touchScaleEnable(touchScaleEnable);
return builder_.Finish(); return builder_.Finish();
@ -1685,7 +1750,7 @@ inline flatbuffers::Offset<ListViewOptions> CreateListViewOptions(flatbuffers::F
struct ProjectNodeOptions : private flatbuffers::Table { struct ProjectNodeOptions : private flatbuffers::Table {
const WidgetOptions *nodeOptions() const { return GetPointer<const WidgetOptions *>(4); } const WidgetOptions *nodeOptions() const { return GetPointer<const WidgetOptions *>(4); }
const flatbuffers::String *fileName() const { return GetPointer<const flatbuffers::String *>(6); } const flatbuffers::String *fileName() const { return GetPointer<const flatbuffers::String *>(6); }
float innerActionSpeed() const { return GetField<float>(8, 0); } float innerActionSpeed() const { return GetField<float>(8, 1.0); }
bool Verify(flatbuffers::Verifier &verifier) const { bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) && return VerifyTableStart(verifier) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* nodeOptions */) && VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* nodeOptions */) &&
@ -1702,7 +1767,7 @@ struct ProjectNodeOptionsBuilder {
flatbuffers::uoffset_t start_; flatbuffers::uoffset_t start_;
void add_nodeOptions(flatbuffers::Offset<WidgetOptions> nodeOptions) { fbb_.AddOffset(4, nodeOptions); } void add_nodeOptions(flatbuffers::Offset<WidgetOptions> nodeOptions) { fbb_.AddOffset(4, nodeOptions); }
void add_fileName(flatbuffers::Offset<flatbuffers::String> fileName) { fbb_.AddOffset(6, fileName); } void add_fileName(flatbuffers::Offset<flatbuffers::String> fileName) { fbb_.AddOffset(6, fileName); }
void add_innerActionSpeed(float innerActionSpeed) { fbb_.AddElement<float>(8, innerActionSpeed, 0); } void add_innerActionSpeed(float innerActionSpeed) { fbb_.AddElement<float>(8, innerActionSpeed, 1.0); }
ProjectNodeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ProjectNodeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
ProjectNodeOptionsBuilder &operator=(const ProjectNodeOptionsBuilder &); ProjectNodeOptionsBuilder &operator=(const ProjectNodeOptionsBuilder &);
flatbuffers::Offset<ProjectNodeOptions> Finish() { flatbuffers::Offset<ProjectNodeOptions> Finish() {
@ -1714,7 +1779,7 @@ struct ProjectNodeOptionsBuilder {
inline flatbuffers::Offset<ProjectNodeOptions> CreateProjectNodeOptions(flatbuffers::FlatBufferBuilder &_fbb, inline flatbuffers::Offset<ProjectNodeOptions> CreateProjectNodeOptions(flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<WidgetOptions> nodeOptions = 0, flatbuffers::Offset<WidgetOptions> nodeOptions = 0,
flatbuffers::Offset<flatbuffers::String> fileName = 0, flatbuffers::Offset<flatbuffers::String> fileName = 0,
float innerActionSpeed = 0) { float innerActionSpeed = 1.0) {
ProjectNodeOptionsBuilder builder_(_fbb); ProjectNodeOptionsBuilder builder_(_fbb);
builder_.add_innerActionSpeed(innerActionSpeed); builder_.add_innerActionSpeed(innerActionSpeed);
builder_.add_fileName(fileName); builder_.add_fileName(fileName);

View File

@ -79,6 +79,8 @@ namespace cocostudio
std::string plistFile = ""; std::string plistFile = "";
int resourceType = 0; int resourceType = 0;
cocos2d::BlendFunc blendFunc = cocos2d::BlendFunc::ALPHA_PREMULTIPLIED;
// child elements // child elements
const tinyxml2::XMLElement* child = objectData->FirstChildElement(); const tinyxml2::XMLElement* child = objectData->FirstChildElement();
while (child) while (child)
@ -110,16 +112,40 @@ namespace cocostudio
attribute = attribute->Next(); attribute = attribute->Next();
} }
} }
else if (name == "BlendFunc")
{
const tinyxml2::XMLAttribute* attribute = child->FirstAttribute();
while (attribute)
{
name = attribute->Name();
std::string value = attribute->Value();
if (name == "Src")
{
blendFunc.src = atoi(value.c_str());
}
else if (name == "Dst")
{
blendFunc.dst = atoi(value.c_str());
}
attribute = attribute->Next();
}
}
child = child->NextSiblingElement(); child = child->NextSiblingElement();
} }
flatbuffers::BlendFunc f_blendFunc(blendFunc.src, blendFunc.dst);
auto options = CreateParticleSystemOptions(*builder, auto options = CreateParticleSystemOptions(*builder,
nodeOptions, nodeOptions,
CreateResourceData(*builder, CreateResourceData(*builder,
builder->CreateString(path), builder->CreateString(path),
builder->CreateString(plistFile), builder->CreateString(plistFile),
resourceType)); resourceType),
&f_blendFunc);
return *(Offset<Table>*)(&options); return *(Offset<Table>*)(&options);
} }
@ -127,7 +153,18 @@ namespace cocostudio
void ParticleReader::setPropsWithFlatBuffers(cocos2d::Node *node, void ParticleReader::setPropsWithFlatBuffers(cocos2d::Node *node,
const flatbuffers::Table *particleOptions) const flatbuffers::Table *particleOptions)
{ {
auto particle = static_cast<ParticleSystemQuad*>(node);
auto options = (ParticleSystemOptions*)particleOptions; auto options = (ParticleSystemOptions*)particleOptions;
auto f_blendFunc = options->blendFunc();
if (f_blendFunc)
{
cocos2d::BlendFunc blendFunc = cocos2d::BlendFunc::ALPHA_PREMULTIPLIED;
blendFunc.src = f_blendFunc->src();
blendFunc.dst = f_blendFunc->dst();
particle->setBlendFunc(blendFunc);
}
auto nodeReader = NodeReader::getInstance(); auto nodeReader = NodeReader::getInstance();
nodeReader->setPropsWithFlatBuffers(node, (Table*)options->nodeOptions()); nodeReader->setPropsWithFlatBuffers(node, (Table*)options->nodeOptions());
} }

View File

@ -80,6 +80,8 @@ namespace cocostudio
std::string plistFile = ""; std::string plistFile = "";
int resourceType = 0; int resourceType = 0;
cocos2d::BlendFunc blendFunc = cocos2d::BlendFunc::ALPHA_PREMULTIPLIED;
// FileData // FileData
const tinyxml2::XMLElement* child = objectData->FirstChildElement(); const tinyxml2::XMLElement* child = objectData->FirstChildElement();
while (child) while (child)
@ -121,17 +123,40 @@ namespace cocostudio
fbs->_textures.push_back(builder->CreateString(texture)); fbs->_textures.push_back(builder->CreateString(texture));
} }
} }
else if (name == "BlendFunc")
{
const tinyxml2::XMLAttribute* attribute = child->FirstAttribute();
while (attribute)
{
name = attribute->Name();
std::string value = attribute->Value();
if (name == "Src")
{
blendFunc.src = atoi(value.c_str());
}
else if (name == "Dst")
{
blendFunc.dst = atoi(value.c_str());
}
attribute = attribute->Next();
}
}
child = child->NextSiblingElement(); child = child->NextSiblingElement();
} }
flatbuffers::BlendFunc f_blendFunc(blendFunc.src, blendFunc.dst);
auto options = CreateSpriteOptions(*builder, auto options = CreateSpriteOptions(*builder,
nodeOptions, nodeOptions,
CreateResourceData(*builder, CreateResourceData(*builder,
builder->CreateString(path), builder->CreateString(path),
builder->CreateString(plistFile), builder->CreateString(plistFile),
resourceType) resourceType),
); &f_blendFunc);
return *(Offset<Table>*)(&options); return *(Offset<Table>*)(&options);
} }
@ -208,6 +233,15 @@ namespace cocostudio
sprite->addChild(label); sprite->addChild(label);
} }
auto f_blendFunc = options->blendFunc();
if (f_blendFunc)
{
cocos2d::BlendFunc blendFunc = cocos2d::BlendFunc::ALPHA_PREMULTIPLIED;
blendFunc.src = f_blendFunc->src();
blendFunc.dst = f_blendFunc->dst();
sprite->setBlendFunc(blendFunc);
}
auto nodeReader = NodeReader::getInstance(); auto nodeReader = NodeReader::getInstance();
nodeReader->setPropsWithFlatBuffers(node, (Table*)(options->nodeOptions())); nodeReader->setPropsWithFlatBuffers(node, (Table*)(options->nodeOptions()));

View File

@ -164,6 +164,13 @@ namespace cocostudio
int areaHeight = 0; int areaHeight = 0;
int h_alignment = 0; int h_alignment = 0;
int v_alignment = 0; int v_alignment = 0;
bool outlineEnabled = false;
Color4B outlineColor = Color4B::BLACK;
int outlineSize = 1;
bool shadowEnabled = false;
Color4B shadowColor = Color4B::BLACK;
Size shadowOffset = Size(2, -2);
int shadowBlurRadius = 0;
std::string path = ""; std::string path = "";
std::string plistFile = ""; std::string plistFile = "";
@ -234,6 +241,30 @@ namespace cocostudio
{ {
isCustomSize = (value == "True") ? true : false; isCustomSize = (value == "True") ? true : false;
} }
else if (name == "OutlineEnabled")
{
outlineEnabled = (value == "True") ? true : false;
}
else if (name == "OutlineSize")
{
outlineSize = atoi(value.c_str());
}
else if (name == "ShadowEnabled")
{
shadowEnabled = (value == "True") ? true : false;
}
else if (name == "ShadowOffsetX")
{
shadowOffset.width = atof(value.c_str());
}
else if (name == "ShadowOffsetY")
{
shadowOffset.height = atof(value.c_str());
}
else if (name == "ShadowBlurRadius")
{
shadowBlurRadius = atoi(value.c_str());
}
attribute = attribute->Next(); attribute = attribute->Next();
} }
@ -269,10 +300,71 @@ namespace cocostudio
attribute = attribute->Next(); attribute = attribute->Next();
} }
} }
else if (name == "OutlineColor")
{
attribute = child->FirstAttribute();
while (attribute)
{
name = attribute->Name();
std::string value = attribute->Value();
if (name == "A")
{
outlineColor.a = atoi(value.c_str());
}
else if (name == "R")
{
outlineColor.r = atoi(value.c_str());
}
else if (name == "G")
{
outlineColor.g = atoi(value.c_str());
}
else if (name == "B")
{
outlineColor.b = atoi(value.c_str());
}
attribute = attribute->Next();
}
}
else if (name == "ShadowColor")
{
attribute = child->FirstAttribute();
while (attribute)
{
name = attribute->Name();
std::string value = attribute->Value();
if (name == "A")
{
shadowColor.a = atoi(value.c_str());
}
else if (name == "R")
{
shadowColor.r = atoi(value.c_str());
}
else if (name == "G")
{
shadowColor.g = atoi(value.c_str());
}
else if (name == "B")
{
shadowColor.b = atoi(value.c_str());
}
attribute = attribute->Next();
}
}
child = child->NextSiblingElement(); child = child->NextSiblingElement();
} }
flatbuffers::Color f_outlineColor(outlineColor.a, outlineColor.r, outlineColor.g, outlineColor.b);
flatbuffers::Color f_shadowColor(shadowColor.a, shadowColor.r, shadowColor.g, shadowColor.b);
auto options = CreateTextOptions(*builder, auto options = CreateTextOptions(*builder,
widgetOptions, widgetOptions,
CreateResourceData(*builder, CreateResourceData(*builder,
@ -287,7 +379,15 @@ namespace cocostudio
h_alignment, h_alignment,
v_alignment, v_alignment,
touchScaleEnabled, touchScaleEnabled,
isCustomSize); isCustomSize,
outlineEnabled,
&f_outlineColor,
outlineSize,
shadowEnabled,
&f_shadowColor,
shadowOffset.width,
shadowOffset.height,
shadowBlurRadius);
return *(Offset<Table>*)(&options); return *(Offset<Table>*)(&options);
} }
@ -348,6 +448,29 @@ namespace cocostudio
} }
} }
bool outlineEnabled = options->outlineEnabled();
if (outlineEnabled)
{
auto f_outlineColor = options->outlineColor();
if (f_outlineColor)
{
Color4B outlineColor(f_outlineColor->a(), f_outlineColor->r(), f_outlineColor->g(), f_outlineColor->b());
label->enableOutline(outlineColor, options->outlineSize());
}
}
bool shadowEnabled = options->shadowEnabled();
if (shadowEnabled)
{
auto f_shadowColor = options->shadowColor();
if (f_shadowColor)
{
Color4B shadowColor(f_shadowColor->a(), f_shadowColor->r(), f_shadowColor->g(), f_shadowColor->b());
label->enableShadow(shadowColor, Size(options->shadowOffsetX(), options->shadowOffsetY()), options->shadowBlurRadius());
}
}
auto widgetReader = WidgetReader::getInstance(); auto widgetReader = WidgetReader::getInstance();
widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions()); widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions());