From dd25ff7a39b39fd0bc72c6d6f9cd93098c6d3cfa Mon Sep 17 00:00:00 2001 From: Xavier Arias Botargues Date: Fri, 7 Nov 2014 12:08:31 +0100 Subject: [PATCH 01/13] Fixed retina/contentScale position errors for iPhone 6+ devices in EditBox. Problem is that factor was 1.0 or 2.0 until iOS 8 introduced 3.0. --- cocos/ui/UIEditBox/UIEditBoxImpl-ios.h | 1 - cocos/ui/UIEditBox/UIEditBoxImpl-ios.mm | 38 +++++++++++-------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-ios.h b/cocos/ui/UIEditBox/UIEditBoxImpl-ios.h index 20a3636481..5ac51bdd65 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-ios.h +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-ios.h @@ -132,7 +132,6 @@ private: Vec2 _anchorPoint; UIEditBoxImplIOS_objc* _systemControl; int _maxTextLength; - bool _inRetinaMode; }; diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-ios.mm b/cocos/ui/UIEditBox/UIEditBoxImpl-ios.mm index 600ed3ee0e..cddb47be36 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-ios.mm +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-ios.mm @@ -279,9 +279,6 @@ EditBoxImplIOS::EditBoxImplIOS(EditBox* pEditText) , _systemControl(nullptr) , _maxTextLength(-1) { - auto view = cocos2d::Director::getInstance()->getOpenGLView(); - - _inRetinaMode = view->isRetinaDisplay(); } EditBoxImplIOS::~EditBoxImplIOS() @@ -305,11 +302,10 @@ bool EditBoxImplIOS::initWithSize(const Size& size) CGRect rect = CGRectMake(0, 0, size.width * glview->getScaleX(),size.height * glview->getScaleY()); - if (_inRetinaMode) - { - rect.size.width /= 2.0f; - rect.size.height /= 2.0f; - } + CCEAGLView *eaglview = static_cast(glview->getEAGLView()); + float factor = eaglview.contentScaleFactor; + rect.size.width /= factor; + rect.size.height /= factor; _systemControl = [[UIEditBoxImplIOS_objc alloc] initWithFrame:rect editBox:this]; if (!_systemControl) break; @@ -376,7 +372,8 @@ void EditBoxImplIOS::setFont(const char* pFontName, int fontSize) isValidFontName = false; } - float retinaFactor = _inRetinaMode ? 2.0f : 1.0f; + CCEAGLView *eaglview = static_cast(cocos2d::Director::getInstance()->getOpenGLView()->getEAGLView()); + float retinaFactor = eaglview.contentScaleFactor; NSString * fntName = [NSString stringWithUTF8String:pFontName]; auto glview = cocos2d::Director::getInstance()->getOpenGLView(); @@ -554,7 +551,7 @@ void EditBoxImplIOS::setPlaceHolder(const char* pText) _labelPlaceHolder->setString(pText); } -static CGPoint convertDesignCoordToScreenCoord(const Vec2& designCoord, bool bInRetinaMode) +static CGPoint convertDesignCoordToScreenCoord(const Vec2& designCoord) { auto glview = cocos2d::Director::getInstance()->getOpenGLView(); CCEAGLView *eaglview = (CCEAGLView *) glview->getEAGLView(); @@ -566,11 +563,10 @@ static CGPoint convertDesignCoordToScreenCoord(const Vec2& designCoord, bool bIn CGPoint screenPos = CGPointMake(screenGLPos.x, viewH - screenGLPos.y); - if (bInRetinaMode) - { - screenPos.x = screenPos.x / 2.0f; - screenPos.y = screenPos.y / 2.0f; - } + float factor = eaglview.contentScaleFactor; + screenPos.x = screenPos.x / factor; + screenPos.y = screenPos.y / factor; + CCLOGINFO("[EditBox] pos x = %f, y = %f", screenGLPos.x, screenGLPos.y); return screenPos; } @@ -594,11 +590,11 @@ void EditBoxImplIOS::setContentSize(const Size& size) auto glview = cocos2d::Director::getInstance()->getOpenGLView(); CGSize controlSize = CGSizeMake(size.width * glview->getScaleX(),size.height * glview->getScaleY()); - if (_inRetinaMode) - { - controlSize.width /= 2.0f; - controlSize.height /= 2.0f; - } + CCEAGLView *eaglview = static_cast(glview->getEAGLView()); + float factor = eaglview.contentScaleFactor; + controlSize.width /= factor; + controlSize.height /= factor; + [_systemControl setContentSize:controlSize]; } @@ -638,7 +634,7 @@ void EditBoxImplIOS::adjustTextFieldPosition() rect = RectApplyAffineTransform(rect, _editBox->nodeToWorldTransform()); Vec2 designCoord = Vec2(rect.origin.x, rect.origin.y + rect.size.height); - [_systemControl setPosition:convertDesignCoordToScreenCoord(designCoord, _inRetinaMode)]; + [_systemControl setPosition:convertDesignCoordToScreenCoord(designCoord)]; } void EditBoxImplIOS::openKeyboard() From 119a68afd9d1902fefca8155706bb729054c971a Mon Sep 17 00:00:00 2001 From: andyque Date: Mon, 8 Dec 2014 15:34:58 +0800 Subject: [PATCH 02/13] fix EditBox move animation position is wrong on iPhone6 Plus --- cocos/platform/ios/CCEAGLView-ios.mm | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/cocos/platform/ios/CCEAGLView-ios.mm b/cocos/platform/ios/CCEAGLView-ios.mm index b3d5fc4100..44749c5838 100644 --- a/cocos/platform/ios/CCEAGLView-ios.mm +++ b/cocos/platform/ios/CCEAGLView-ios.mm @@ -778,13 +778,10 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. float scaleY = glview->getScaleY(); - if (self.contentScaleFactor == 2.0f) - { - // Convert to pixel coordinate - - begin = CGRectApplyAffineTransform(begin, CGAffineTransformScale(CGAffineTransformIdentity, 2.0f, 2.0f)); - end = CGRectApplyAffineTransform(end, CGAffineTransformScale(CGAffineTransformIdentity, 2.0f, 2.0f)); - } + + // Convert to pixel coordinate + begin = CGRectApplyAffineTransform(begin, CGAffineTransformScale(CGAffineTransformIdentity, self.contentScaleFactor, self.contentScaleFactor)); + end = CGRectApplyAffineTransform(end, CGAffineTransformScale(CGAffineTransformIdentity, self.contentScaleFactor, self.contentScaleFactor)); float offestY = glview->getViewPortRect().origin.y; CCLOG("offestY = %f", offestY); @@ -861,10 +858,7 @@ UIInterfaceOrientation getFixedOrientation(UIInterfaceOrientation statusBarOrien auto glview = cocos2d::Director::getInstance()->getOpenGLView(); dis *= glview->getScaleY(); - if (self.contentScaleFactor == 2.0f) - { - dis /= 2.0f; - } + dis /= self.contentScaleFactor; switch (getFixedOrientation([[UIApplication sharedApplication] statusBarOrientation])) { From 7e8da62ebcd5fc45e85d59d550b9cc1c1f1de12d Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Tue, 9 Dec 2014 18:29:20 +0800 Subject: [PATCH 03/13] Add Websocket support for Mac platform --- .../lua-bindings/manual/network/lua_cocos2dx_network_manual.cpp | 2 +- tests/lua-tests/src/ExtensionTest/ExtensionTest.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/scripting/lua-bindings/manual/network/lua_cocos2dx_network_manual.cpp b/cocos/scripting/lua-bindings/manual/network/lua_cocos2dx_network_manual.cpp index 8a79fefe0b..d8da25c163 100644 --- a/cocos/scripting/lua-bindings/manual/network/lua_cocos2dx_network_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/network/lua_cocos2dx_network_manual.cpp @@ -44,7 +44,7 @@ int register_network_module(lua_State* L) luaopen_lua_extensions(L); #endif -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) tolua_web_socket_open(L); register_web_socket_manual(L); #endif diff --git a/tests/lua-tests/src/ExtensionTest/ExtensionTest.lua b/tests/lua-tests/src/ExtensionTest/ExtensionTest.lua index 91fb9db48a..e62cb39f23 100644 --- a/tests/lua-tests/src/ExtensionTest/ExtensionTest.lua +++ b/tests/lua-tests/src/ExtensionTest/ExtensionTest.lua @@ -1215,7 +1215,7 @@ local function ExtensionsMainLayer() cc.MenuItemFont:setFontSize(24) local targetPlatform = cc.Application:getInstance():getTargetPlatform() local bSupportWebSocket = false - if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) or (cc.PLATFORM_OS_ANDROID == targetPlatform) or (cc.PLATFORM_OS_WINDOWS == targetPlatform) then + if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) or (cc.PLATFORM_OS_ANDROID == targetPlatform) or (cc.PLATFORM_OS_WINDOWS == targetPlatform) or (cc.PLATFORM_OS_MAC == targetPlatform) then bSupportWebSocket = true end local bSupportEdit = false From 6b6fe4129da3bc044b6572929e07a2addfa9f471 Mon Sep 17 00:00:00 2001 From: pipu Date: Wed, 10 Dec 2014 12:36:14 +0800 Subject: [PATCH 04/13] Update Reader --- .../ActionTimeline/CCActionTimelineCache.cpp | 49 +- .../cocostudio/CSParseBinary_generated.h | 12 +- .../cocostudio/FlatBuffersSerialize.cpp | 661 +++++++++--------- .../cocostudio/FlatBuffersSerialize.h | 32 +- .../ButtonReader/ButtonReader.cpp | 2 +- .../TextFieldReader/TextFieldReader.cpp | 3 +- .../WidgetReader/TextReader/TextReader.cpp | 2 +- 7 files changed, 398 insertions(+), 363 deletions(-) diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.cpp index 91197d77b2..b33aaf578c 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.cpp @@ -682,18 +682,51 @@ Frame* ActionTimelineCache::loadColorFrameWithFlatBuffers(const flatbuffers::Tim Frame* ActionTimelineCache::loadTextureFrameWithFlatBuffers(const flatbuffers::TimeLineTextureFrame *flatbuffers) { + std::string path = ""; + int resourceType = 0; + std::string plist = ""; + TextureFrame* frame = TextureFrame::create(); - std::string path = flatbuffers->path()->c_str(); - if (FileUtils::getInstance()->isFileExist(path)) + auto fileNameData = flatbuffers->fileNameData(); + + resourceType = fileNameData->resourceType(); + switch (resourceType) { - std::string fullPath = FileUtils::getInstance()->fullPathForFilename(path); - path = fullPath; - } - else - { - path = ""; + case 0: + { + path = fileNameData->path()->c_str(); + if (FileUtils::getInstance()->isFileExist(path)) + { + std::string fullPath = FileUtils::getInstance()->fullPathForFilename(path); + path = fullPath; + } + else + { + path = ""; + } + break; + } + + case 1: + { + plist = fileNameData->plistFile()->c_str(); + if (FileUtils::getInstance()->isFileExist(plist)) + { + path = fileNameData->path()->c_str(); + } + else + { + path = ""; + } + break; + } + + default: + break; } + + frame->setTextureName(path); int frameIndex = flatbuffers->frameIndex(); diff --git a/cocos/editor-support/cocostudio/CSParseBinary_generated.h b/cocos/editor-support/cocostudio/CSParseBinary_generated.h index b1352f13ff..d4360f64a0 100644 --- a/cocos/editor-support/cocostudio/CSParseBinary_generated.h +++ b/cocos/editor-support/cocostudio/CSParseBinary_generated.h @@ -2038,13 +2038,13 @@ inline flatbuffers::Offset CreateTimeLineColorFrame(flatbuff struct TimeLineTextureFrame : private flatbuffers::Table { int32_t frameIndex() const { return GetField(4, 0); } uint8_t tween() const { return GetField(6, 1); } - const flatbuffers::String *path() const { return GetPointer(8); } + const ResourceData *fileNameData() const { return GetPointer(8); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, 4 /* frameIndex */) && VerifyField(verifier, 6 /* tween */) && - VerifyField(verifier, 8 /* path */) && - verifier.Verify(path()) && + VerifyField(verifier, 8 /* fileNameData */) && + verifier.VerifyTable(fileNameData()) && verifier.EndTable(); } }; @@ -2054,7 +2054,7 @@ struct TimeLineTextureFrameBuilder { flatbuffers::uoffset_t start_; void add_frameIndex(int32_t frameIndex) { fbb_.AddElement(4, frameIndex, 0); } void add_tween(uint8_t tween) { fbb_.AddElement(6, tween, 1); } - void add_path(flatbuffers::Offset path) { fbb_.AddOffset(8, path); } + void add_fileNameData(flatbuffers::Offset fileNameData) { fbb_.AddOffset(8, fileNameData); } TimeLineTextureFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } TimeLineTextureFrameBuilder &operator=(const TimeLineTextureFrameBuilder &); flatbuffers::Offset Finish() { @@ -2066,9 +2066,9 @@ struct TimeLineTextureFrameBuilder { inline flatbuffers::Offset CreateTimeLineTextureFrame(flatbuffers::FlatBufferBuilder &_fbb, int32_t frameIndex = 0, uint8_t tween = 1, - flatbuffers::Offset path = 0) { + flatbuffers::Offset fileNameData = 0) { TimeLineTextureFrameBuilder builder_(_fbb); - builder_.add_path(path); + builder_.add_fileNameData(fileNameData); builder_.add_frameIndex(frameIndex); builder_.add_tween(tween); return builder_.Finish(); diff --git a/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp b/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp index ae15eca275..be630a2e13 100644 --- a/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp +++ b/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp @@ -59,6 +59,7 @@ #include "flatbuffers/util.h" + USING_NS_CC; using namespace cocos2d::ui; using namespace cocostudio; @@ -77,6 +78,8 @@ static const char* FrameType_TextureFrame = "TextureFrame"; static const char* FrameType_EventFrame = "EventFrame"; static const char* FrameType_ZOrderFrame = "ZOrderFrame"; +static FlatBuffersSerialize* _instanceFlatBuffersSerialize = nullptr; + FlatBuffersSerialize::FlatBuffersSerialize() : _isSimulator(false) , _builder(nullptr) @@ -87,7 +90,7 @@ FlatBuffersSerialize::FlatBuffersSerialize() CREATE_CLASS_NODE_READER_INFO(SpriteReader); CREATE_CLASS_NODE_READER_INFO(ParticleReader); CREATE_CLASS_NODE_READER_INFO(GameMapReader); - + CREATE_CLASS_NODE_READER_INFO(ButtonReader); CREATE_CLASS_NODE_READER_INFO(CheckBoxReader); CREATE_CLASS_NODE_READER_INFO(ImageViewReader); @@ -108,12 +111,10 @@ FlatBuffersSerialize::~FlatBuffersSerialize() { purge(); } - -static FlatBuffersSerialize* _instanceFlatBuffersSerialize = nullptr; FlatBuffersSerialize* FlatBuffersSerialize::getInstance() { - if (_instanceFlatBuffersSerialize == nullptr) + if (!_instanceFlatBuffersSerialize) { _instanceFlatBuffersSerialize = new FlatBuffersSerialize(); } @@ -124,6 +125,16 @@ FlatBuffersSerialize* FlatBuffersSerialize::getInstance() void FlatBuffersSerialize::purge() { CC_SAFE_DELETE(_instanceFlatBuffersSerialize); + +} + +void FlatBuffersSerialize::deleteFlatBufferBuilder() +{ + if (_builder != nullptr) + { + _builder->Clear(); + CC_SAFE_DELETE(_builder); + } } std::string FlatBuffersSerialize::serializeFlatBuffersWithXMLFile(const std::string &xmlFileName, @@ -146,7 +157,7 @@ std::string FlatBuffersSerialize::serializeFlatBuffersWithXMLFile(const std::str document->Parse(content.c_str()); const tinyxml2::XMLElement* rootElement = document->RootElement();// Root - CCLOG("rootElement name = %s", rootElement->Name()); +// CCLOG("rootElement name = %s", rootElement->Name()); const tinyxml2::XMLElement* element = rootElement->FirstChildElement(); @@ -155,7 +166,7 @@ std::string FlatBuffersSerialize::serializeFlatBuffersWithXMLFile(const std::str while (element) { - CCLOG("entity name = %s", element->Name()); +// CCLOG("entity name = %s", element->Name()); if (strcmp("Content", element->Name()) == 0) { @@ -209,8 +220,7 @@ std::string FlatBuffersSerialize::serializeFlatBuffersWithXMLFile(const std::str if (serializeEnabled) { - FlatBufferBuilder builder; - _builder = &builder; + _builder = new FlatBufferBuilder(); Offset nodeTree; Offset aciton; @@ -236,12 +246,12 @@ std::string FlatBuffersSerialize::serializeFlatBuffersWithXMLFile(const std::str child = child->NextSiblingElement(); } - auto csparsebinary = CreateCSParseBinary(builder, - builder.CreateVector(_textures), - builder.CreateVector(_texturePngs), + auto csparsebinary = CreateCSParseBinary(*_builder, + _builder->CreateVector(_textures), + _builder->CreateVector(_texturePngs), nodeTree, aciton); - builder.Finish(csparsebinary); + _builder->Finish(csparsebinary); _textures.clear(); _texturePngs.clear(); @@ -251,13 +261,15 @@ std::string FlatBuffersSerialize::serializeFlatBuffersWithXMLFile(const std::str size_t pos = outFullPath.find_last_of('.'); std::string convert = outFullPath.substr(0, pos).append(".csb"); auto save = flatbuffers::SaveFile(convert.c_str(), - reinterpret_cast(builder.GetBufferPointer()), - builder.GetSize(), + reinterpret_cast(_builder->GetBufferPointer()), + _builder->GetSize(), true); if (!save) { return "couldn't save files!"; } + + deleteFlatBufferBuilder(); } return ""; @@ -268,7 +280,7 @@ Offset FlatBuffersSerialize::createNodeTree(const tinyxml2::XMLElement std::string classType) { std::string classname = classType.substr(0, classType.find("ObjectData")); - CCLOG("classname = %s", classname.c_str()); +// CCLOG("classname = %s", classname.c_str()); std::string name = ""; @@ -301,7 +313,7 @@ Offset FlatBuffersSerialize::createNodeTree(const tinyxml2::XMLElement while (child) { - CCLOG("child name = %s", child->Name()); +// CCLOG("child name = %s", child->Name()); if (strcmp("Children", child->Name()) == 0) { @@ -315,7 +327,7 @@ Offset FlatBuffersSerialize::createNodeTree(const tinyxml2::XMLElement if (containChildrenElement) { child = child->FirstChildElement(); - CCLOG("element name = %s", child->Name()); +// CCLOG("element name = %s", child->Name()); while (child) { @@ -368,259 +380,7 @@ Offset FlatBuffersSerialize::createNodeTree(const tinyxml2::XMLElement _builder->CreateVector(children), options, _builder->CreateString(customClassName)); -} -FlatBufferBuilder* FlatBuffersSerialize::createFlatBuffersWithXMLFileForSimulator(const std::string &xmlFileName) -{ - std::string inFullpath = FileUtils::getInstance()->fullPathForFilename(xmlFileName).c_str(); - - // xml read - if (!FileUtils::getInstance()->isFileExist(inFullpath)) - { - CCLOG(".csd file doesn not exists "); - } - - ssize_t size; - std::string content =(char*)FileUtils::getInstance()->getFileData(inFullpath, "r", &size); - - // xml parse - tinyxml2::XMLDocument* document = new tinyxml2::XMLDocument(); - document->Parse(content.c_str()); - - const tinyxml2::XMLElement* rootElement = document->RootElement();// Root - CCLOG("rootElement name = %s", rootElement->Name()); - - const tinyxml2::XMLElement* element = rootElement->FirstChildElement(); - - bool serializeEnabled = false; - std::string rootType = ""; - - while (element) - { - CCLOG("entity name = %s", element->Name()); - - if (strcmp("Content", element->Name()) == 0) - { - const tinyxml2::XMLAttribute* attribute = element->FirstAttribute(); - - // - if (!attribute) - { - serializeEnabled = true; - rootType = "NodeObjectData"; - } - } - - if (serializeEnabled) - { - break; - } - - const tinyxml2::XMLElement* child = element->FirstChildElement(); - if (child) - { - element = child; - } - else - { - element = element->NextSiblingElement(); - } - } - - if (serializeEnabled) - { - _builder = new FlatBufferBuilder(); - - Offset nodeTree; - Offset aciton; - - - const tinyxml2::XMLElement* child = element->FirstChildElement(); - - while (child) - { - std::string name = child->Name(); - - if (name == "Animation") // action - { - const tinyxml2::XMLElement* animation = child; - aciton = createNodeAction(animation); - } - else if (name == "ObjectData") // nodeTree - { - const tinyxml2::XMLElement* objectData = child; - nodeTree = createNodeTreeForSimulator(objectData, rootType); - } - - child = child->NextSiblingElement(); - } - - auto csparsebinary = CreateCSParseBinary(*_builder, - _builder->CreateVector(_textures), - _builder->CreateVector(_texturePngs), - nodeTree, - aciton); - _builder->Finish(csparsebinary); - - _textures.clear(); - _texturePngs.clear(); - } - return _builder; -} - -Offset FlatBuffersSerialize::createNodeTreeForSimulator(const tinyxml2::XMLElement *objectData, - std::string classType) -{ - std::string classname = classType.substr(0, classType.find("ObjectData")); - CCLOG("classname = %s", classname.c_str()); - - std::string name = ""; - - Offset options; - std::vector> children; - - if (classname == "ProjectNode") - { - auto projectNodeOptions = createProjectNodeOptionsForSimulator(objectData); - options = CreateOptions(*_builder, *(Offset*)(&projectNodeOptions)); - } - else if (classname == "SimpleAudio") - { - auto reader = ComAudioReader::getInstance(); - options = CreateOptions(*_builder, reader->createOptionsWithFlatBuffers(objectData, _builder)); - } - else - { - std::string readername = getGUIClassName(classname); - readername.append("Reader"); - - NodeReaderProtocol* reader = dynamic_cast(ObjectFactory::getInstance()->createObject(readername)); - options = CreateOptions(*_builder, reader->createOptionsWithFlatBuffers(objectData, _builder)); - } - - - // children - bool containChildrenElement = false; - const tinyxml2::XMLElement* child = objectData->FirstChildElement(); - - while (child) - { - CCLOG("child name = %s", child->Name()); - - if (strcmp("Children", child->Name()) == 0) - { - containChildrenElement = true; - break; - } - - child = child->NextSiblingElement(); - } - - if (containChildrenElement) - { - child = child->FirstChildElement(); - CCLOG("element name = %s", child->Name()); - - while (child) - { - const tinyxml2::XMLAttribute* attribute = child->FirstAttribute(); - bool bHasType = false; - while (attribute) - { - std::string attriname = attribute->Name(); - std::string value = attribute->Value(); - - if (attriname == "ctype") - { - children.push_back(createNodeTreeForSimulator(child, value)); - - bHasType = true; - break; - } - - attribute = attribute->Next(); - } - - if(!bHasType) - { - children.push_back(createNodeTreeForSimulator(child, "NodeObjectData")); - } - - child = child->NextSiblingElement(); - } - } - // - - - std::string customClassName = ""; - const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute(); - while (attribute) - { - std::string attriname = attribute->Name(); - std::string value = attribute->Value(); - - if (attriname == "CustomClassName") - { - customClassName = value; - break; - } - - attribute = attribute->Next(); - } - - return CreateNodeTree(*_builder, - _builder->CreateString(classname), - _builder->CreateVector(children), - options, - _builder->CreateString(customClassName)); -} - -Offset FlatBuffersSerialize::createProjectNodeOptionsForSimulator(const tinyxml2::XMLElement *objectData) -{ - auto temp = NodeReader::getInstance()->createOptionsWithFlatBuffers(objectData, _builder); - auto nodeOptions = *(Offset*)(&temp); - - std::string filename = ""; - - // FileData - const tinyxml2::XMLElement* child = objectData->FirstChildElement(); - while (child) - { - std::string name = child->Name(); - - if (name == "FileData") - { - const tinyxml2::XMLAttribute* attribute = child->FirstAttribute(); - - while (attribute) - { - name = attribute->Name(); - std::string value = attribute->Value(); - - if (name == "Path") - { - filename = value; - } - - attribute = attribute->Next(); - } - } - - child = child->NextSiblingElement(); - } - - return CreateProjectNodeOptions(*_builder, - nodeOptions, - _builder->CreateString(filename)); -} - -void FlatBuffersSerialize::deleteFlatBufferBuilder() -{ - if (_builder != nullptr) - { - _builder->Clear(); - CC_SAFE_DELETE(_builder); - } } int FlatBuffersSerialize::getResourceType(std::string key) @@ -639,7 +399,7 @@ int FlatBuffersSerialize::getResourceType(std::string key) } return 1; } - + std::string FlatBuffersSerialize::getGUIClassName(const std::string &name) { std::string convertedClassName = name; @@ -737,6 +497,7 @@ std::string FlatBuffersSerialize::getWidgetReaderClassName(Widget* widget) return readerName; } +// // NodeAction @@ -745,7 +506,7 @@ Offset FlatBuffersSerialize::createNodeAction(const tinyxml2::XMLEle int duration = 0; float speed = 0.0f; - CCLOG("animation name = %s", objectData->Name()); +// CCLOG("animation name = %s", objectData->Name()); // ActionTimeline const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute(); @@ -822,17 +583,13 @@ Offset FlatBuffersSerialize::createTimeLine(const tinyxml2::XMLElement auto visibleFrame = createTimeLineBoolFrame(frameElement); frame = CreateFrame(*_builder, visibleFrame); - - frames.push_back(frame); } else if (frameType == FrameType_ZOrderFrame) { - auto zOrderFrame = createTimeLineIntFrame(objectData); + auto zOrderFrame = createTimeLineIntFrame(frameElement); frame = CreateFrame(*_builder, 0, // VisibleFrame zOrderFrame); - - frames.push_back(frame); } else if (frameType == FrameType_RotationSkewFrame) { @@ -841,8 +598,6 @@ Offset FlatBuffersSerialize::createTimeLine(const tinyxml2::XMLElement 0, // VisibleFrame 0, // ZOrderFrame rotationSkewFrame); - - frames.push_back(frame); } else if (frameType == FrameType_EventFrame) { @@ -852,8 +607,6 @@ Offset FlatBuffersSerialize::createTimeLine(const tinyxml2::XMLElement 0, // ZOrderFrame 0, // RotationSkewFrame eventFrame); - - frames.push_back(frame); } else if (frameType == FrameType_AnchorFrame) { @@ -864,8 +617,6 @@ Offset FlatBuffersSerialize::createTimeLine(const tinyxml2::XMLElement 0, // RotationSkewFrame 0, // EventFrame anchorPointFrame); - - frames.push_back(frame); } else if (frameType == FrameType_PositionFrame) { @@ -877,12 +628,10 @@ Offset FlatBuffersSerialize::createTimeLine(const tinyxml2::XMLElement 0, // EventFrame 0, // AnchorPointFrame positionFrame); - - frames.push_back(frame); } else if (frameType == FrameType_ScaleFrame) { - auto scaleFrame = createTimeLinePointFrame(objectData); + auto scaleFrame = createTimeLinePointFrame(frameElement); frame = CreateFrame(*_builder, 0, // VisibleFrame 0, // ZOrderFrame @@ -894,7 +643,7 @@ Offset FlatBuffersSerialize::createTimeLine(const tinyxml2::XMLElement } else if (frameType == FrameType_ColorFrame) { - auto colorFrame = createTimeLineColorFrame(objectData); + auto colorFrame = createTimeLineColorFrame(frameElement); frame = CreateFrame(*_builder, 0, // VisibleFrame 0, // ZOrderFrame @@ -907,7 +656,7 @@ Offset FlatBuffersSerialize::createTimeLine(const tinyxml2::XMLElement } else if (frameType == FrameType_TextureFrame) { - auto textureFrame = createTimeLineTextureFrame(objectData); + auto textureFrame = createTimeLineTextureFrame(frameElement); frame = CreateFrame(*_builder, 0, // VisibleFrame 0, // ZOrderFrame @@ -919,6 +668,7 @@ Offset FlatBuffersSerialize::createTimeLine(const tinyxml2::XMLElement 0, // ColorFrame textureFrame); } + frames.push_back(frame); frameElement = frameElement->NextSiblingElement(); } @@ -1136,82 +886,325 @@ Offset FlatBuffersSerialize::createTimeLineColorFrame(const &f_color); } -Offset FlatBuffersSerialize::createTimeLineTextureFrame(const tinyxml2::XMLElement *objectData) + Offset FlatBuffersSerialize::createTimeLineTextureFrame(const tinyxml2::XMLElement *objectData) + { + int frameIndex = 0; + bool tween = true; + + std::string path = ""; + std::string plistFile = ""; + int resourceType = 0; + + std::string texture = ""; + std::string texturePng = ""; + + const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute(); + while (attribute) + { + std::string attriname = attribute->Name(); + std::string value = attribute->Value(); + + if (attriname == "FrameIndex") + { + frameIndex = atoi(value.c_str()); + } + else if (attriname == "Tween") + { + tween = (value == "True") ? true : false; + } + + attribute = attribute->Next(); + } + + const tinyxml2::XMLElement* child = objectData->FirstChildElement(); + while (child) + { + attribute = child->FirstAttribute(); + while (attribute) + { + std::string attriname = attribute->Name(); + std::string value = attribute->Value(); + + if (attriname == "Path") + { + path = value; + } + else if (attriname == "Type") + { + resourceType = getResourceType(value); + } + else if (attriname == "Plist") + { + plistFile = value; + texture = value; + } + + attribute = attribute->Next(); + } + + if (resourceType == 1) + { + _textures.push_back(_builder->CreateString(texture)); + + texturePng = texture.substr(0, texture.find_last_of('.')).append(".png"); + _texturePngs.push_back(_builder->CreateString(texturePng)); + } + + child = child->NextSiblingElement(); + } + + return CreateTimeLineTextureFrame(*_builder, + frameIndex, + tween, + CreateResourceData(*_builder, + _builder->CreateString(path), + _builder->CreateString(plistFile), + resourceType)); + } + +/* create flat buffers with XML */ +FlatBufferBuilder* FlatBuffersSerialize::createFlatBuffersWithXMLFileForSimulator(const std::string &xmlFileName) +{ + std::string inFullpath = FileUtils::getInstance()->fullPathForFilename(xmlFileName).c_str(); + + // xml read + if (!FileUtils::getInstance()->isFileExist(inFullpath)) + { +// CCLOG(".csd file doesn not exists "); + } + + ssize_t size; + std::string content =(char*)FileUtils::getInstance()->getFileData(inFullpath, "r", &size); + + // xml parse + tinyxml2::XMLDocument* document = new tinyxml2::XMLDocument(); + document->Parse(content.c_str()); + + const tinyxml2::XMLElement* rootElement = document->RootElement();// Root +// CCLOG("rootElement name = %s", rootElement->Name()); + + const tinyxml2::XMLElement* element = rootElement->FirstChildElement(); + + bool serializeEnabled = false; + std::string rootType = ""; + + while (element) + { +// CCLOG("entity name = %s", element->Name()); + + if (strcmp("Content", element->Name()) == 0) + { + const tinyxml2::XMLAttribute* attribute = element->FirstAttribute(); + + // + if (!attribute) + { + serializeEnabled = true; + rootType = "NodeObjectData"; + } + } + + if (serializeEnabled) + { + break; + } + + const tinyxml2::XMLElement* child = element->FirstChildElement(); + if (child) + { + element = child; + } + else + { + element = element->NextSiblingElement(); + } + } + + if (serializeEnabled) + { + _builder = new FlatBufferBuilder(); + + Offset nodeTree; + Offset aciton; + + + const tinyxml2::XMLElement* child = element->FirstChildElement(); + + while (child) + { + std::string name = child->Name(); + + if (name == "Animation") // action + { + const tinyxml2::XMLElement* animation = child; + aciton = createNodeAction(animation); + } + else if (name == "ObjectData") // nodeTree + { + const tinyxml2::XMLElement* objectData = child; + nodeTree = createNodeTreeForSimulator(objectData, rootType); + } + + child = child->NextSiblingElement(); + } + + auto csparsebinary = CreateCSParseBinary(*_builder, + _builder->CreateVector(_textures), + _builder->CreateVector(_texturePngs), + nodeTree, + aciton); + _builder->Finish(csparsebinary); + + _textures.clear(); + _texturePngs.clear(); + } + return _builder; +} + +Offset FlatBuffersSerialize::createNodeTreeForSimulator(const tinyxml2::XMLElement *objectData, + std::string classType) { - int frameIndex = 0; - bool tween = true; + std::string classname = classType.substr(0, classType.find("ObjectData")); +// CCLOG("classname = %s", classname.c_str()); - std::string path = ""; - std::string plistFile = ""; - int resourceType = 0; + std::string name = ""; + Offset options; + std::vector> children; + + if (classname == "ProjectNode") + { + auto projectNodeOptions = createProjectNodeOptionsForSimulator(objectData); + options = CreateOptions(*_builder, *(Offset
*)(&projectNodeOptions)); + } + else if (classname == "SimpleAudio") + { + auto reader = ComAudioReader::getInstance(); + options = CreateOptions(*_builder, reader->createOptionsWithFlatBuffers(objectData, _builder)); + } + else + { + std::string readername = getGUIClassName(classname); + readername.append("Reader"); + + NodeReaderProtocol* reader = dynamic_cast(ObjectFactory::getInstance()->createObject(readername)); + options = CreateOptions(*_builder, reader->createOptionsWithFlatBuffers(objectData, _builder)); + } + + + // children + bool containChildrenElement = false; + const tinyxml2::XMLElement* child = objectData->FirstChildElement(); + + while (child) + { +// CCLOG("child name = %s", child->Name()); + + if (strcmp("Children", child->Name()) == 0) + { + containChildrenElement = true; + break; + } + + child = child->NextSiblingElement(); + } + + if (containChildrenElement) + { + child = child->FirstChildElement(); +// CCLOG("element name = %s", child->Name()); + + while (child) + { + const tinyxml2::XMLAttribute* attribute = child->FirstAttribute(); + bool bHasType = false; + while (attribute) + { + std::string attriname = attribute->Name(); + std::string value = attribute->Value(); + + if (attriname == "ctype") + { + children.push_back(createNodeTreeForSimulator(child, value)); + + bHasType = true; + break; + } + + attribute = attribute->Next(); + } + + if(!bHasType) + { + children.push_back(createNodeTreeForSimulator(child, "NodeObjectData")); + } + + child = child->NextSiblingElement(); + } + } + // + + + std::string customClassName = ""; const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute(); while (attribute) { std::string attriname = attribute->Name(); std::string value = attribute->Value(); - if (attriname == "FrameIndex") + if (attriname == "CustomClassName") { - frameIndex = atoi(value.c_str()); - } - else if (attriname == "Tween") - { - tween = (value == "True") ? true : false; + customClassName = value; + break; } attribute = attribute->Next(); } + return CreateNodeTree(*_builder, + _builder->CreateString(classname), + _builder->CreateVector(children), + options, + _builder->CreateString(customClassName)); +} + +Offset FlatBuffersSerialize::createProjectNodeOptionsForSimulator(const tinyxml2::XMLElement *objectData) +{ + auto temp = NodeReader::getInstance()->createOptionsWithFlatBuffers(objectData, _builder); + auto nodeOptions = *(Offset*)(&temp); + + std::string filename = ""; + + // FileData const tinyxml2::XMLElement* child = objectData->FirstChildElement(); while (child) { - attribute = child->FirstAttribute(); - while (attribute) + std::string name = child->Name(); + + if (name == "FileData") { - std::string attriname = attribute->Name(); - std::string value = attribute->Value(); + const tinyxml2::XMLAttribute* attribute = child->FirstAttribute(); - if (attriname == "Path") + while (attribute) { - std::string inFullpath = FileUtils::getInstance()->fullPathForFilename(value).c_str(); - - // xml read - if (!FileUtils::getInstance()->isFileExist(inFullpath)) - path = ""; - else - path = value; - } - else if (attriname == "Type") - { - resourceType = getResourceType(value); - } - else if (attriname == "Plist") - { - plistFile = value; - - std::string inFullpath = FileUtils::getInstance()->fullPathForFilename(value).c_str(); - - // xml read - if (!FileUtils::getInstance()->isFileExist(inFullpath)) + name = attribute->Name(); + std::string value = attribute->Value(); + + if (name == "Path") { - path = ""; - plistFile = ""; + filename = value; } - else - plistFile = value; + + attribute = attribute->Next(); } - - attribute = attribute->Next(); } child = child->NextSiblingElement(); } - return CreateTimeLineTextureFrame(*_builder, - frameIndex, - tween, - _builder->CreateString(path)); + return CreateProjectNodeOptions(*_builder, + nodeOptions, + _builder->CreateString(filename)); } } diff --git a/cocos/editor-support/cocostudio/FlatBuffersSerialize.h b/cocos/editor-support/cocostudio/FlatBuffersSerialize.h index a1fb2f82a1..35f966e8cf 100644 --- a/cocos/editor-support/cocostudio/FlatBuffersSerialize.h +++ b/cocos/editor-support/cocostudio/FlatBuffersSerialize.h @@ -78,18 +78,27 @@ namespace flatbuffers struct TimeLineTextureFrame; } -namespace cocostudio { +namespace tinyxml2 +{ + class XMLElement; +} +namespace cocostudio { + class CC_STUDIO_DLL FlatBuffersSerialize { public: + static FlatBuffersSerialize* getInstance(); + static void purge(); FlatBuffersSerialize(); ~FlatBuffersSerialize(); - static FlatBuffersSerialize* getInstance(); - static void purge(); + void deleteFlatBufferBuilder(); + + std::string test(const std::string& xmlFileName, + const std::string& flatbuffersFileName); /* serialize flat buffers with XML */ std::string serializeFlatBuffersWithXMLFile(const std::string& xmlFileName, @@ -97,7 +106,7 @@ public: // NodeTree flatbuffers::Offset createNodeTree(const tinyxml2::XMLElement* objectData, - std::string classType); + std::string classType); // NodeAction flatbuffers::Offset createNodeAction(const tinyxml2::XMLElement* objectData); @@ -110,17 +119,17 @@ public: flatbuffers::Offset createTimeLineTextureFrame(const tinyxml2::XMLElement* objectData); /**/ - flatbuffers::FlatBufferBuilder* createFlatBuffersWithXMLFileForSimulator(const std::string& xmlFileName); - flatbuffers::Offset createNodeTreeForSimulator(const tinyxml2::XMLElement* objectData, - std::string classType); - flatbuffers::Offset createProjectNodeOptionsForSimulator(const tinyxml2::XMLElement* objectData); - - void deleteFlatBufferBuilder(); - int getResourceType(std::string key); std::string getGUIClassName(const std::string &name); std::string getWidgetReaderClassName(cocos2d::ui::Widget *widget); + /* create flat buffers with XML */ + flatbuffers::FlatBufferBuilder* createFlatBuffersWithXMLFileForSimulator(const std::string& xmlFileName); + flatbuffers::Offset createNodeTreeForSimulator(const tinyxml2::XMLElement* objectData, + std::string classType); + flatbuffers::Offset createProjectNodeOptionsForSimulator(const tinyxml2::XMLElement* objectData); + /**/ + public: std::vector> _textures; std::vector> _texturePngs; @@ -131,7 +140,6 @@ private: flatbuffers::Offset* _csparsebinary; }; - } #endif /* defined(__cocos2d_libs__FlatBuffersSerialize__) */ diff --git a/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp index 7bb18720b6..6c9e033d6a 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp @@ -232,7 +232,7 @@ namespace cocostudio button->setTitleFontSize(DICTOOL->getIntValue_json(options, P_FontSize,14)); - button->setTitleFontName(DICTOOL->getStringValue_json(options, P_FontName,"微软雅黑")); + button->setTitleFontName(DICTOOL->getStringValue_json(options, P_FontName)); diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp index da087d6fe4..1eee293581 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp @@ -107,7 +107,7 @@ namespace cocostudio textField->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize,20)); - textField->setFontName(DICTOOL->getStringValue_json(options, P_FontName,"微软雅黑")); + textField->setFontName(DICTOOL->getStringValue_json(options, P_FontName)); bool tsw = DICTOOL->checkObjectExist_json(options, P_TouchSizeWidth); bool tsh = DICTOOL->checkObjectExist_json(options, P_TouchSizeHeight); @@ -319,6 +319,7 @@ namespace cocostudio auto widgetOptions = options->widgetOptions(); if (!textField->isIgnoreContentAdaptWithSize()) { + ((Label*)(textField->getVirtualRenderer()))->setLineBreakWithoutSpace(true); Size contentSize(widgetOptions->size()->width(), widgetOptions->size()->height()); textField->setContentSize(contentSize); } diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp index 084a267be9..04d3338253 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp @@ -111,7 +111,7 @@ namespace cocostudio label->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize,20)); - std::string fontName = DICTOOL->getStringValue_json(options, P_FontName, "微软雅黑"); + std::string fontName = DICTOOL->getStringValue_json(options, P_FontName); std::string fontFilePath = jsonPath.append(fontName); if (FileUtils::getInstance()->isFileExist(fontFilePath)) From e81dca372a3bb2e4714f3a19c463f51c72c38b5b Mon Sep 17 00:00:00 2001 From: pipu Date: Wed, 10 Dec 2014 15:46:58 +0800 Subject: [PATCH 05/13] Update that sets default value of font name for ButtonReader, TextFieldReader, TextReader --- .../cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp | 2 +- .../cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp | 2 +- .../cocostudio/WidgetReader/TextReader/TextReader.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp index 6c9e033d6a..deaf7d8ea5 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp @@ -232,7 +232,7 @@ namespace cocostudio button->setTitleFontSize(DICTOOL->getIntValue_json(options, P_FontSize,14)); - button->setTitleFontName(DICTOOL->getStringValue_json(options, P_FontName)); + button->setTitleFontName(DICTOOL->getStringValue_json(options, P_FontName, "")); diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp index 1eee293581..b33361f506 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp @@ -107,7 +107,7 @@ namespace cocostudio textField->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize,20)); - textField->setFontName(DICTOOL->getStringValue_json(options, P_FontName)); + textField->setFontName(DICTOOL->getStringValue_json(options, P_FontName, "")); bool tsw = DICTOOL->checkObjectExist_json(options, P_TouchSizeWidth); bool tsh = DICTOOL->checkObjectExist_json(options, P_TouchSizeHeight); diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp index 04d3338253..8cb192efe1 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp @@ -111,7 +111,7 @@ namespace cocostudio label->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize,20)); - std::string fontName = DICTOOL->getStringValue_json(options, P_FontName); + std::string fontName = DICTOOL->getStringValue_json(options, P_FontName, ""); std::string fontFilePath = jsonPath.append(fontName); if (FileUtils::getInstance()->isFileExist(fontFilePath)) From d3351a4b117b30ac2c68eb452a41779b7e736be6 Mon Sep 17 00:00:00 2001 From: pipu Date: Wed, 10 Dec 2014 17:35:39 +0800 Subject: [PATCH 06/13] 1. Fix bug that after load .csb file, call Text widget's setString(), content of string dosen't line wrap and content of Text is chaotic. 2. Update how to parse attribute scale9Enabled --- .../ButtonReader/ButtonReader.cpp | 34 +++++---------- .../ImageViewReader/ImageViewReader.cpp | 5 +-- .../LayoutReader/LayoutReader.cpp | 22 +++++----- .../ListViewReader/ListViewReader.cpp | 41 ++++++++----------- .../WidgetReader/NodeReader/NodeReader.cpp | 2 +- .../PageViewReader/PageViewReader.cpp | 38 ++++++++--------- .../ScrollViewReader/ScrollViewReader.cpp | 40 +++++++++--------- .../TextFieldReader/TextFieldReader.cpp | 6 +-- .../WidgetReader/TextReader/TextReader.cpp | 10 ++--- 9 files changed, 86 insertions(+), 112 deletions(-) diff --git a/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp index deaf7d8ea5..c0f7c76673 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp @@ -572,19 +572,6 @@ namespace cocostudio std::string disabledTexturePath = disabledDic->path()->c_str(); button->loadTextureDisabled(disabledTexturePath, (Widget::TextureResType)disabledType); - if (scale9Enabled) - { - button->setUnifySizeEnabled(false); - button->ignoreContentAdaptWithSize(false); - - auto f_capInsets = options->capInsets(); - Rect capInsets(f_capInsets->x(), f_capInsets->y(), f_capInsets->width(), f_capInsets->height()); - button->setCapInsets(capInsets); - - Size scale9Size(options->scale9Size()->width(), options->scale9Size()->height()); - button->setContentSize(scale9Size); - } - std::string titleText = options->text()->c_str(); button->setTitleText(titleText); @@ -608,20 +595,21 @@ namespace cocostudio bool displaystate = options->displaystate(); button->setBright(displaystate); button->setEnabled(displaystate); - - Size contentSize; - if (!button->isScale9Enabled()) - { - button->setUnifySizeEnabled(true); - contentSize = button->getVirtualRendererSize(); - } auto widgetReader = WidgetReader::getInstance(); widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions()); - - if (!button->isScale9Enabled()) + + if (scale9Enabled) { - button->setContentSize(contentSize); + button->setUnifySizeEnabled(false); + button->ignoreContentAdaptWithSize(false); + + auto f_capInsets = options->capInsets(); + Rect capInsets(f_capInsets->x(), f_capInsets->y(), f_capInsets->width(), f_capInsets->height()); + button->setCapInsets(capInsets); + + Size scale9Size(options->scale9Size()->width(), options->scale9Size()->height()); + button->setContentSize(scale9Size); } } diff --git a/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp index 0491b0d99d..040c19d7b0 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp @@ -302,6 +302,8 @@ namespace cocostudio bool scale9Enabled = options->scale9Enabled(); imageView->setScale9Enabled(scale9Enabled); + auto widgetReader = WidgetReader::getInstance(); + widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions()); if (scale9Enabled) { @@ -318,9 +320,6 @@ namespace cocostudio imageView->setCapInsets(capInsets); } - auto widgetReader = WidgetReader::getInstance(); - widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions()); - } Node* ImageViewReader::createNodeWithFlatBuffers(const flatbuffers::Table *imageViewOptions) diff --git a/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp index 9e9acf835c..c08214c8f8 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp @@ -606,6 +606,16 @@ namespace cocostudio std::string imageFileName = imageFileNameDic->path()->c_str(); panel->setBackGroundImage(imageFileName, (Widget::TextureResType)imageFileNameType); + auto widgetOptions = options->widgetOptions(); + auto f_color = widgetOptions->color(); + Color3B color(f_color->r(), f_color->g(), f_color->b()); + panel->setColor(color); + + int opacity = widgetOptions->alpha(); + panel->setOpacity(opacity); + + auto widgetReader = WidgetReader::getInstance(); + widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions()); if (backGroundScale9Enabled) { @@ -619,7 +629,6 @@ namespace cocostudio } else { - auto widgetOptions = options->widgetOptions(); if (!panel->isIgnoreContentAdaptWithSize()) { Size contentSize(widgetOptions->size()->width(), widgetOptions->size()->height()); @@ -627,17 +636,6 @@ namespace cocostudio } } - auto widgetOptions = options->widgetOptions(); - auto f_color = widgetOptions->color(); - Color3B color(f_color->r(), f_color->g(), f_color->b()); - panel->setColor(color); - - int opacity = widgetOptions->alpha(); - panel->setOpacity(opacity); - - auto widgetReader = WidgetReader::getInstance(); - widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions()); - } Node* LayoutReader::createNodeWithFlatBuffers(const flatbuffers::Table *layoutOptions) diff --git a/cocos/editor-support/cocostudio/WidgetReader/ListViewReader/ListViewReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ListViewReader/ListViewReader.cpp index 4513e7547d..398d042cd0 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ListViewReader/ListViewReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ListViewReader/ListViewReader.cpp @@ -434,27 +434,6 @@ namespace cocostudio std::string imageFileName = imageFileNameDic->path()->c_str(); listView->setBackGroundImage(imageFileName, (Widget::TextureResType)imageFileNameType); - - if (backGroundScale9Enabled) - { - auto f_capInsets = options->capInsets(); - Rect capInsets(f_capInsets->x(), f_capInsets->y(), f_capInsets->width(), f_capInsets->height()); - listView->setBackGroundImageCapInsets(capInsets); - - auto f_scale9Size = options->scale9Size(); - Size scale9Size(f_scale9Size->width(), f_scale9Size->height()); - listView->setContentSize(scale9Size); - } - else - { - auto widgetOptions = options->widgetOptions(); - if (!listView->isIgnoreContentAdaptWithSize()) - { - Size contentSize(widgetOptions->size()->width(), widgetOptions->size()->height()); - listView->setContentSize(contentSize); - } - } - auto widgetOptions = options->widgetOptions(); auto f_color = widgetOptions->color(); Color3B color(f_color->r(), f_color->g(), f_color->b()); @@ -511,10 +490,24 @@ namespace cocostudio auto widgetReader = WidgetReader::getInstance(); widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions()); - if (!listView->isIgnoreContentAdaptWithSize()) + if (backGroundScale9Enabled) { - Size contentSize(widgetOptions->size()->width(), widgetOptions->size()->height()); - listView->setContentSize(contentSize); + auto f_capInsets = options->capInsets(); + Rect capInsets(f_capInsets->x(), f_capInsets->y(), f_capInsets->width(), f_capInsets->height()); + listView->setBackGroundImageCapInsets(capInsets); + + auto f_scale9Size = options->scale9Size(); + Size scale9Size(f_scale9Size->width(), f_scale9Size->height()); + listView->setContentSize(scale9Size); + } + else + { + auto widgetOptions = options->widgetOptions(); + if (!listView->isIgnoreContentAdaptWithSize()) + { + Size contentSize(widgetOptions->size()->width(), widgetOptions->size()->height()); + listView->setContentSize(contentSize); + } } } diff --git a/cocos/editor-support/cocostudio/WidgetReader/NodeReader/NodeReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/NodeReader/NodeReader.cpp index 897d5dfa03..a15e77d69d 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/NodeReader/NodeReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/NodeReader/NodeReader.cpp @@ -290,7 +290,7 @@ namespace cocostudio auto options = CreateWidgetOptions(*builder, builder->CreateString(name), - actionTag, + (int)actionTag, &f_rotationskew, zOrder, visible, diff --git a/cocos/editor-support/cocostudio/WidgetReader/PageViewReader/PageViewReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/PageViewReader/PageViewReader.cpp index 185be2794f..edcfe9f31c 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/PageViewReader/PageViewReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/PageViewReader/PageViewReader.cpp @@ -348,26 +348,6 @@ namespace cocostudio pageView->setBackGroundImage(imageFileName, (Widget::TextureResType)imageFileNameType); - if (backGroundScale9Enabled) - { - auto f_capInsets = options->capInsets(); - Rect capInsets(f_capInsets->x(), f_capInsets->y(), f_capInsets->width(), f_capInsets->height()); - pageView->setBackGroundImageCapInsets(capInsets); - - auto f_scale9Size = options->scale9Size(); - Size scale9Size(f_scale9Size->width(), f_scale9Size->height()); - pageView->setContentSize(scale9Size); - } - else - { - auto widgetOptions = options->widgetOptions(); - if (!pageView->isIgnoreContentAdaptWithSize()) - { - Size contentSize(widgetOptions->size()->width(), widgetOptions->size()->height()); - pageView->setContentSize(contentSize); - } - } - auto widgetOptions = options->widgetOptions(); auto f_color = widgetOptions->color(); Color3B color(f_color->r(), f_color->g(), f_color->b()); @@ -380,6 +360,24 @@ namespace cocostudio auto widgetReader = WidgetReader::getInstance(); widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions()); + if (backGroundScale9Enabled) + { + auto f_capInsets = options->capInsets(); + Rect capInsets(f_capInsets->x(), f_capInsets->y(), f_capInsets->width(), f_capInsets->height()); + pageView->setBackGroundImageCapInsets(capInsets); + + auto f_scale9Size = options->scale9Size(); + Size scale9Size(f_scale9Size->width(), f_scale9Size->height()); + pageView->setContentSize(scale9Size); + } + else + { + if (!pageView->isIgnoreContentAdaptWithSize()) + { + Size contentSize(widgetOptions->size()->width(), widgetOptions->size()->height()); + pageView->setContentSize(contentSize); + } + } } Node* PageViewReader::createNodeWithFlatBuffers(const flatbuffers::Table *pageViewOptions) diff --git a/cocos/editor-support/cocostudio/WidgetReader/ScrollViewReader/ScrollViewReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ScrollViewReader/ScrollViewReader.cpp index 752150a594..fa4d72034e 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ScrollViewReader/ScrollViewReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ScrollViewReader/ScrollViewReader.cpp @@ -433,27 +433,6 @@ namespace cocostudio std::string imageFileName = imageFileNameDic->path()->c_str(); scrollView->setBackGroundImage(imageFileName, (Widget::TextureResType)imageFileNameType); - - if (backGroundScale9Enabled) - { - auto f_capInsets = options->capInsets(); - Rect capInsets(f_capInsets->x(), f_capInsets->y(), f_capInsets->width(), f_capInsets->height()); - scrollView->setBackGroundImageCapInsets(capInsets); - - auto f_scale9Size = options->scale9Size(); - Size scale9Size(f_scale9Size->width(), f_scale9Size->height()); - scrollView->setContentSize(scale9Size); - } - else - { - auto widgetOptions = options->widgetOptions(); - if (!scrollView->isIgnoreContentAdaptWithSize()) - { - Size contentSize(widgetOptions->size()->width(), widgetOptions->size()->height()); - scrollView->setContentSize(contentSize); - } - } - auto widgetOptions = options->widgetOptions(); auto f_color = widgetOptions->color(); Color3B color(f_color->r(), f_color->g(), f_color->b()); @@ -474,6 +453,25 @@ namespace cocostudio auto widgetReader = WidgetReader::getInstance(); widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions()); + if (backGroundScale9Enabled) + { + auto f_capInsets = options->capInsets(); + Rect capInsets(f_capInsets->x(), f_capInsets->y(), f_capInsets->width(), f_capInsets->height()); + scrollView->setBackGroundImageCapInsets(capInsets); + + auto f_scale9Size = options->scale9Size(); + Size scale9Size(f_scale9Size->width(), f_scale9Size->height()); + scrollView->setContentSize(scale9Size); + } + else + { + if (!scrollView->isIgnoreContentAdaptWithSize()) + { + Size contentSize(widgetOptions->size()->width(), widgetOptions->size()->height()); + scrollView->setContentSize(contentSize); + } + } + } Node* ScrollViewReader::createNodeWithFlatBuffers(const flatbuffers::Table *scrollViewOptions) diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp index b33361f506..cb81f31999 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp @@ -274,9 +274,6 @@ namespace cocostudio TextField* textField = static_cast(node); auto options = (TextFieldOptions*)textFieldOptions; - textField->setUnifySizeEnabled(false); - textField->ignoreContentAdaptWithSize(false); - std::string placeholder = options->placeHolder()->c_str(); textField->setPlaceHolder(placeholder); @@ -316,6 +313,9 @@ namespace cocostudio auto widgetReader = WidgetReader::getInstance(); widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions()); + textField->setUnifySizeEnabled(false); + textField->ignoreContentAdaptWithSize(false); + auto widgetOptions = options->widgetOptions(); if (!textField->isIgnoreContentAdaptWithSize()) { diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp index 8cb192efe1..fcf60df837 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp @@ -292,11 +292,6 @@ namespace cocostudio Text* label = static_cast(node); auto options = (TextOptions*)textOptions; - bool IsCustomSize = options->isCustomSize(); - label->ignoreContentAdaptWithSize(!IsCustomSize); - - label->setUnifySizeEnabled(false); - bool touchScaleEnabled = options->touchScaleEnable(); label->setTouchScaleChangeEnabled(touchScaleEnabled); std::string text = options->text()->c_str(); @@ -330,6 +325,11 @@ namespace cocostudio auto widgetReader = WidgetReader::getInstance(); widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions()); + label->setUnifySizeEnabled(false); + + bool IsCustomSize = options->isCustomSize(); + label->ignoreContentAdaptWithSize(!IsCustomSize); + auto widgetOptions = options->widgetOptions(); if (!label->isIgnoreContentAdaptWithSize()) { From 8b78c181ce589fdb1f5a0089ba044db87bc455f3 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Wed, 10 Dec 2014 18:11:07 +0800 Subject: [PATCH 07/13] Make KEY_SHIFT equal to KEY_LEFT_SHIFT, KEY_CTRL equal to KEY_LEFT_CTRL, KEY_ALT equal to KEY_LEFT_ALT. --- cocos/base/CCEventKeyboard.h | 14 +++++----- .../platform/desktop/CCGLViewImpl-desktop.cpp | 27 ------------------- 2 files changed, 7 insertions(+), 34 deletions(-) diff --git a/cocos/base/CCEventKeyboard.h b/cocos/base/CCEventKeyboard.h index b13f1d3f52..d06594d6d9 100644 --- a/cocos/base/CCEventKeyboard.h +++ b/cocos/base/CCEventKeyboard.h @@ -52,8 +52,14 @@ public: KEY_RETURN, KEY_CAPS_LOCK, KEY_SHIFT, + KEY_LEFT_SHIFT = KEY_SHIFT, + KEY_RIGHT_SHIFT, KEY_CTRL, + KEY_LEFT_CTRL = KEY_CTRL, + KEY_RIGHT_CTRL, KEY_ALT, + KEY_LEFT_ALT = KEY_ALT, + KEY_RIGHT_ALT, KEY_MENU, KEY_HYPER, KEY_INSERT, @@ -201,13 +207,7 @@ public: KEY_DPAD_DOWN, KEY_DPAD_CENTER, KEY_ENTER, - KEY_PLAY, - KEY_LEFT_CTRL, - KEY_RIGHT_CTRL, - KEY_LEFT_ALT, - KEY_RIGHT_ALT, - KEY_LEFT_SHIFT, - KEY_RIGHT_SHIFT + KEY_PLAY }; EventKeyboard(KeyCode keyCode, bool isPressed); diff --git a/cocos/platform/desktop/CCGLViewImpl-desktop.cpp b/cocos/platform/desktop/CCGLViewImpl-desktop.cpp index 6fdbb4c8de..5616b080e4 100644 --- a/cocos/platform/desktop/CCGLViewImpl-desktop.cpp +++ b/cocos/platform/desktop/CCGLViewImpl-desktop.cpp @@ -661,38 +661,11 @@ void GLViewImpl::onGLFWMouseScrollCallback(GLFWwindow* window, double x, double void GLViewImpl::onGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) { - EventKeyboard::KeyCode additionalKeyCode = EventKeyboard::KeyCode::KEY_NONE; - - switch (key) - { - case GLFW_KEY_LEFT_ALT: - case GLFW_KEY_RIGHT_ALT: - additionalKeyCode = EventKeyboard::KeyCode::KEY_ALT; - break; - case GLFW_KEY_LEFT_CONTROL: - case GLFW_KEY_RIGHT_CONTROL: - additionalKeyCode = EventKeyboard::KeyCode::KEY_CTRL; - break; - case GLFW_KEY_LEFT_SHIFT: - case GLFW_KEY_RIGHT_SHIFT: - additionalKeyCode = EventKeyboard::KeyCode::KEY_SHIFT; - break; - default: - break; - } - if (GLFW_REPEAT != action) { EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action); auto dispatcher = Director::getInstance()->getEventDispatcher(); dispatcher->dispatchEvent(&event); - - // Keep compatibility for the old keycodes like SHIFT, CTRL, ALT. - if (additionalKeyCode != EventKeyboard::KeyCode::KEY_NONE) - { - EventKeyboard additionalEvent(additionalKeyCode, GLFW_PRESS == action); - dispatcher->dispatchEvent(&additionalEvent); - } } if (GLFW_RELEASE != action && g_keyCodeMap[key] == EventKeyboard::KeyCode::KEY_BACKSPACE) From 0408c03903662a0127348cc7ec1edf98eab871ca Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 10 Dec 2014 18:56:07 +0800 Subject: [PATCH 08/13] [ci skip] Update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 546f4d6574..51453acf4d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ cocos2d-x-3.3 Dec.12 [FIX] Billboard: allow billboard rotate along z axis [FIX] Bundle3D: create aabb for mesh whose aabb does not exist (user custom mesh) + [FIX] EditBox: text position and move animation error on iPhone6 Plus [FIX] FileUtils: createDirectory(): doesn't invoke closedir() after opendir on platforms other than WP8/WinRT/Windows cocos2d-x-3.3-rc2 Dec.5 From e05d6d872b0983817a72499573fa838d02968240 Mon Sep 17 00:00:00 2001 From: andyque Date: Thu, 11 Dec 2014 10:04:16 +0800 Subject: [PATCH 09/13] update v3-deps to 29 --- external/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/config.json b/external/config.json index 8cb6c7a1b4..19e8fee3e5 100644 --- a/external/config.json +++ b/external/config.json @@ -1,5 +1,5 @@ { - "version":"v3-deps-28", + "version":"v3-deps-29", "zip_file_size":"87419231", "repo_name":"cocos2d-x-3rd-party-libs-bin", "repo_parent":"https://github.com/cocos2d/", From 70b9767c5663762f46b5fac6ae551340b5d213bb Mon Sep 17 00:00:00 2001 From: pipu Date: Thu, 11 Dec 2014 11:34:31 +0800 Subject: [PATCH 10/13] 1. Fixes #4957 that click test TestChangePlaySection, then it will crash. 2. Modify default value of selectedState to serialize check box data. --- .../WidgetReader/CheckBoxReader/CheckBoxReader.cpp | 2 +- .../ActionTimelineTestScene.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp index 55daff5570..b05bf5ca8c 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp @@ -164,7 +164,7 @@ namespace cocostudio auto temp = WidgetReader::getInstance()->createOptionsWithFlatBuffers(objectData, builder); auto widgetOptions = *(Offset*)(&temp); - bool selectedState = true; + bool selectedState = false; bool displaystate = true; int backgroundboxResourceType = 0; diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp index 1de3fdc9db..d07e074521 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp @@ -222,7 +222,7 @@ void TestChangePlaySection::onEnter() ActionTimelineTestLayer::onEnter(); Node* node = CSLoader::createNode("ActionTimeline/DemoPlayer.csb"); - ActionTimeline* action = CSLoader::createTimeline("ActionTimeline/DemoPlayer.csb"); + action = CSLoader::createTimeline("ActionTimeline/DemoPlayer.csb"); node->runAction(action); action->gotoFrameAndPlay(41, action->getDuration(), true); @@ -247,9 +247,9 @@ std::string TestChangePlaySection::title() const void TestChangePlaySection::onTouchesEnded(const std::vector& touches, Event* event) { if(action->getStartFrame() == 0) - action->gotoFrameAndPlay(70, action->getDuration(), true); + action->gotoFrameAndPlay(41, action->getDuration(), true); else - action->gotoFrameAndPlay(0, 60, true); + action->gotoFrameAndPlay(0, 40, true); } // TestFrameEvent From 6343502fcb0b96414d7d9d5e983bc3099b6800d2 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Wed, 10 Dec 2014 20:52:29 -0800 Subject: [PATCH 11/13] added notes for Windows 8.1 Universal App --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bdab36e479..4a8e4ac5a4 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,12 @@ Run $ cocos run -p win32 +### Build and run new project for Windows 8.1 and Windows Phone 8.1 ### + + $ cocos new MyGame -p com.bar.foo -l cpp -d projects + +With the Cocos2d-x v3.3, you can create Universal App (Two projects at the same time: Windows(Tablet) and Windows Phone 8.1 ) +See more info on How to install and Create games on Windows RT (Windows and Windows Phone 8.1) at http://msopentech.github.io/cocos2d-x/ Main features ------------- @@ -124,15 +130,18 @@ Build Requirements * or Windows 7+, VS 2012+ * Python 2.7.5 * NDK r9d is required to build Android games +* Windows Phone/Store 8.0 VS 2012+ +* Windows Phone/Store 8.1 VS 2013 Update 3+ Runtime Requirements -------------------- * iOS 5.0+ for iPhone / iPad games * Android 2.3+ for Android games - * Windows Phone 8+ for Windows Phone games + * Windows Phone 8 and 8.1 for Windows Phone games * OS X v10.6+ for Mac games * Windows 7+ for Win games + * Windows 8+ for WinRT games (Modern Apps) Running Tests From 1ca92411fc0be4c4313d1e88947e6127f93df598 Mon Sep 17 00:00:00 2001 From: Edward Zhou Date: Thu, 11 Dec 2014 13:33:28 +0800 Subject: [PATCH 12/13] Fix UIText miss copy contentSize for clone --- cocos/ui/UIText.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/ui/UIText.cpp b/cocos/ui/UIText.cpp index dfdb6b84de..d48434fc2c 100644 --- a/cocos/ui/UIText.cpp +++ b/cocos/ui/UIText.cpp @@ -360,6 +360,7 @@ void Text::copySpecialProperties(Widget *widget) setTextHorizontalAlignment(label->_labelRenderer->getHorizontalAlignment()); setTextVerticalAlignment(label->_labelRenderer->getVerticalAlignment()); setTextAreaSize(label->_labelRenderer->getDimensions()); + setContentSize(label->getContentSize()); } } From 93561fcb8e899a5e98240731257954ab2eaf8829 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 11 Dec 2014 18:14:28 +0800 Subject: [PATCH 13/13] [ci skip]update version --- cocos/cocos2d.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/cocos2d.cpp b/cocos/cocos2d.cpp index 66f67327b1..fab01b53d1 100644 --- a/cocos/cocos2d.cpp +++ b/cocos/cocos2d.cpp @@ -31,7 +31,7 @@ NS_CC_BEGIN CC_DLL const char* cocos2dVersion() { - return "cocos2d-x 3.3rc2"; + return "cocos2d-x 3.3"; } NS_CC_END