From bbf7e994e7c24b1d338ff354b09220fac7e599ce Mon Sep 17 00:00:00 2001 From: Jeff Wang Date: Wed, 5 Aug 2015 07:54:50 +0800 Subject: [PATCH 001/118] Improved EditBox implement for platform win32 --- cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp | 280 ++++++++++++++++----- cocos/ui/UIEditBox/UIEditBoxImpl-win32.h | 2 + 2 files changed, 225 insertions(+), 57 deletions(-) diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp b/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp index 5c0bc6ea90..fb7e3a4f96 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp @@ -39,6 +39,8 @@ class CWin32InputBox; +typedef void (*Win32InputBoxTextChange)(const char *pText, cocos2d::ui::EditBoxImplWin *ctx); + // Structure used to orient the inputbox behavior struct WIN32INPUTBOX_PARAM { @@ -70,6 +72,12 @@ struct WIN32INPUTBOX_PARAM IN DWORD nMaxLength; + IN OPTIONAL cocos2d::ui::EditBox::KeyboardReturnType eReturnType; + IN OPTIONAL cocos2d::ui::EditBox::InputMode eInputMode; + IN OPTIONAL cocos2d::ui::EditBox::InputFlag eInputFlag; + IN OPTIONAL Win32InputBoxTextChange lpfnOnTextChange; + IN OPTIONAL cocos2d::ui::EditBoxImplWin* lpCtx; + // Owner window HWND hwndOwner; HINSTANCE hInstance; @@ -87,6 +95,7 @@ private: WIN32INPUTBOX_PARAM *_param; static LRESULT CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM); HWND _hwndEditCtrl; + int _recursionDepth; void InitDialog(); void SetParam(WIN32INPUTBOX_PARAM *); @@ -103,8 +112,16 @@ public: LPCSTR szPrompt, std::string* pstrResult, DWORD nMaxLength, - bool bMultiLine = false, - HWND hwndParent = 0); + bool bMultiLine, + HWND hwndParent, + cocos2d::ui::EditBox::KeyboardReturnType eReturnType, + cocos2d::ui::EditBox::InputMode eInputMode, + cocos2d::ui::EditBox::InputFlag eInputFlag, + Win32InputBoxTextChange lpfnOnTextChange, + cocos2d::ui::EditBoxImplWin *ctx); + + void SetText(const char *pText); + void Close(); }; @@ -174,14 +191,13 @@ static unsigned char definputbox_dlg[] = 0xff, 0xff, 0xff, 0xff, 0xff, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static LPCTSTR definputbox_buttonnames[] = { _T("OK"), _T("CANCEL") }; -static const INT_PTR definputbox_buttonids[] = { IDOK, IDCANCEL }; - static const INT definputbox_id_prompt = 1000, definputbox_id_edit1 = 1001, definputbox_id_edit2 = 1002; +static CWin32InputBox *s_win32InputBox = nullptr; + WIN32INPUTBOX_PARAM::WIN32INPUTBOX_PARAM() { bMultiline = false; @@ -206,6 +222,8 @@ WIN32INPUTBOX_PARAM::WIN32INPUTBOX_PARAM() CWin32InputBox::CWin32InputBox(WIN32INPUTBOX_PARAM *param) { _param = param; + _hwndEditCtrl = NULL; + _recursionDepth = 0; } CWin32InputBox::~CWin32InputBox() @@ -292,9 +310,12 @@ INT_PTR CWin32InputBox::InputBoxEx(WIN32INPUTBOX_PARAM *param) } CWin32InputBox inputbox(param); + s_win32InputBox = &inputbox; // Resize dialog and SHOW or HIDE multiline INT_PTR r = ::DialogBoxIndirectParam(param->hInstance, dlgTemplate, param->hwndOwner, (DLGPROC)DlgProc, (LPARAM)&inputbox); + param->hDlg = NULL; + s_win32InputBox = nullptr; return r; } @@ -305,7 +326,12 @@ INT_PTR CWin32InputBox::InputBox( std::string* pstrResult, DWORD nResultSize, bool bMultiLine, - HWND hwndParent) + HWND hwndParent, + cocos2d::ui::EditBox::KeyboardReturnType eReturnType, + cocos2d::ui::EditBox::InputMode eInputMode, + cocos2d::ui::EditBox::InputFlag eInputFlag, + Win32InputBoxTextChange lpfnOnTextChange, + cocos2d::ui::EditBoxImplWin *ctx) { WIN32INPUTBOX_PARAM param; @@ -315,14 +341,36 @@ INT_PTR CWin32InputBox::InputBox( param.nMaxLength = nResultSize; param.bMultiline = bMultiLine; param.hwndOwner = hwndParent; + param.eReturnType = eReturnType; + param.eInputMode = eInputMode; + param.eInputFlag = eInputFlag; + param.lpfnOnTextChange = lpfnOnTextChange; + param.lpCtx = ctx; return InputBoxEx(¶m); } void CWin32InputBox::InitDialog() { - // Set the button captions - for (size_t i = 0; ihDlg, (int)definputbox_buttonids[i], definputbox_buttonnames[i]); + // Set the button captions, associated with ReturnType + switch (_param->eReturnType) + { + case cocos2d::ui::EditBox::KeyboardReturnType::DEFAULT: + ::SetDlgItemTextW(_param->hDlg, IDOK, L"OK"); + break; + case cocos2d::ui::EditBox::KeyboardReturnType::DONE: + ::SetDlgItemTextW(_param->hDlg, IDOK, L"DONE"); + break; + case cocos2d::ui::EditBox::KeyboardReturnType::SEND: + ::SetDlgItemTextW(_param->hDlg, IDOK, L"SEND"); + break; + case cocos2d::ui::EditBox::KeyboardReturnType::SEARCH: + ::SetDlgItemTextW(_param->hDlg, IDOK, L"SEARCH"); + break; + case cocos2d::ui::EditBox::KeyboardReturnType::GO: + ::SetDlgItemTextW(_param->hDlg, IDOK, L"GO"); + break; + } + ::SetDlgItemTextW(_param->hDlg, IDCANCEL, L"CANCEL"); // Set other controls std::u16string utf16Title; @@ -330,7 +378,7 @@ void CWin32InputBox::InitDialog() ::SetWindowTextW(_param->hDlg, (LPCWSTR) utf16Title.c_str()); std::u16string utf16Prompt; - cocos2d::StringUtils::UTF8ToUTF16(_param->szTitle, utf16Prompt); + cocos2d::StringUtils::UTF8ToUTF16(_param->szPrompt, utf16Prompt); ::SetDlgItemTextW(_param->hDlg, definputbox_id_prompt, (LPCWSTR) utf16Prompt.c_str()); HWND hwndEdit1 = ::GetDlgItem(_param->hDlg, definputbox_id_edit1); @@ -386,8 +434,68 @@ void CWin32InputBox::InitDialog() ::ShowWindow(hwndEdit2, SW_HIDE); } + + // Sets the text limit of the edit control. + // wParam is the maximum number of WCHARs the user can enter. For Unicode text, wParam is the number of characters. + // Please refer to https://msdn.microsoft.com/en-us/library/bb761607%28v=vs.85%29.aspx + if ((int)_param->nMaxLength > 0) + { + ::SendMessageW(hwndEdit1, EM_LIMITTEXT, (WPARAM)_param->nMaxLength, 0); + ::SendMessageW(hwndEdit2, EM_LIMITTEXT, (WPARAM)_param->nMaxLength, 0); + } + + switch (_param->eInputFlag) + { + case cocos2d::ui::EditBox::InputFlag::PASSWORD: + // Sets a password character displayed in a edit control when the user types text. + // Please refer to https://msdn.microsoft.com/en-us/library/bb761653%28v=vs.85%29.aspx + ::SendMessageW(hwndEdit1, EM_SETPASSWORDCHAR, (WPARAM)L'*', 0); + ::SendMessageW(hwndEdit2, EM_SETPASSWORDCHAR, (WPARAM)L'*', 0); + break; + case cocos2d::ui::EditBox::InputFlag::SENSITIVE: + break; + case cocos2d::ui::EditBox::InputFlag::INITIAL_CAPS_WORD: + break; + case cocos2d::ui::EditBox::InputFlag::INITIAL_CAPS_SENTENCE: + break; + case cocos2d::ui::EditBox::InputFlag::INTIAL_CAPS_ALL_CHARACTERS: + // Converts all characters to lowercase as they are typed into the edit control. + // Please refer to https://msdn.microsoft.com/en-us/library/bb775464%28v=vs.85%29.aspx + ::SetWindowLongW(hwndEdit1, GWL_STYLE, ::GetWindowLongW(hwndEdit1, GWL_STYLE) | ES_UPPERCASE); + ::SetWindowLongW(hwndEdit2, GWL_STYLE, ::GetWindowLongW(hwndEdit2, GWL_STYLE) | ES_UPPERCASE); + break; + default: + break; + } + + switch (_param->eInputMode) + { + case cocos2d::ui::EditBox::InputMode::ANY: + break; + case cocos2d::ui::EditBox::InputMode::EMAIL_ADDRESS: + break; + case cocos2d::ui::EditBox::InputMode::NUMERIC: + // Allows only digits to be entered into the edit control. + // Note that, even with this set, it is still possible to paste non-digits into the edit control. + // Please refer to https://msdn.microsoft.com/en-us/library/bb775464%28v=vs.85%29.aspx + ::SetWindowLongW(hwndEdit1, GWL_STYLE, ::GetWindowLongW(hwndEdit1, GWL_STYLE) | ES_NUMBER); + ::SetWindowLongW(hwndEdit2, GWL_STYLE, ::GetWindowLongW(hwndEdit2, GWL_STYLE) | ES_NUMBER); + break; + case cocos2d::ui::EditBox::InputMode::PHONE_NUMBER: + break; + case cocos2d::ui::EditBox::InputMode::URL: + break; + case cocos2d::ui::EditBox::InputMode::DECIMAL: + break; + case cocos2d::ui::EditBox::InputMode::SINGLE_LINE: + break; + default: + break; + } } +#define REDNERING_TIMER_ID 2015 + // Message handler for about box. LRESULT CALLBACK CWin32InputBox::DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { @@ -403,6 +511,15 @@ LRESULT CALLBACK CWin32InputBox::DlgProc(HWND hDlg, UINT message, WPARAM wParam, _this = (CWin32InputBox *)lParam; _this->_param->hDlg = hDlg; _this->InitDialog(); + + // Set timer for rendering + TIMERPROC lpTimerFunc = [](HWND, UINT, UINT, DWORD) { + auto director = cocos2d::Director::getInstance(); + auto glview = director->getOpenGLView(); + director->mainLoop(); + glview->pollEvents(); + }; + ::SetTimer(hDlg, REDNERING_TIMER_ID, USER_TIMER_MINIMUM, lpTimerFunc); return TRUE; } @@ -412,15 +529,21 @@ LRESULT CALLBACK CWin32InputBox::DlgProc(HWND hDlg, UINT message, WPARAM wParam, CHAR buf[1024]; static int i = 0; sprintf(buf, "WM_COMMAND: %09d wParam=%08X lParam=%08X\n", i++, wParam, lParam); - OutputDebugString(buf); + OutputDebugStringA(buf); #endif INT_PTR buttonId = LOWORD(wParam); - for (size_t i = 0; - i_recursionDepth == 0 && _this->_param->lpfnOnTextChange != nullptr) { - if (buttonId == definputbox_buttonids[i]) - { std::u16string wstrResult; std::string utf8Result; @@ -434,34 +557,15 @@ LRESULT CALLBACK CWin32InputBox::DlgProc(HWND hDlg, UINT message, WPARAM wParam, bool conversionResult = cocos2d::StringUtils::UTF16ToUTF8(wstrResult, utf8Result); _this->_param->pstrResult->clear(); + ++_this->_recursionDepth; // Prevent recursive calls if (conversionResult) { - DWORD inputLengthAsUTF8 = (DWORD) cocos2d::StringUtils::getCharacterCountInUTF8String(utf8Result); - if ((_this->_param->nMaxLength > 0) && - (_this->_param->nMaxLength < inputLengthAsUTF8)) - { - // LengthFilter - for (size_t pos=0; pos < _this->_param->nMaxLength; pos++) - { - std::string utf8Bytes; - std::u16string utf16Character(1, wstrResult[pos]); - - bool utf16toutf8ConversionResult = cocos2d::StringUtils::UTF16ToUTF8(utf16Character, utf8Bytes); - if (utf16toutf8ConversionResult) - { - _this->_param->pstrResult->append(utf8Bytes); - } - } - } - else - { - *(_this->_param->pstrResult) = utf8Result; - } + *(_this->_param->pstrResult) = std::move(utf8Result); } - - ::EndDialog(hDlg, buttonId); + // Invoke editBoxTextChanged indirectly + _this->_param->lpfnOnTextChange(_this->_param->pstrResult->c_str(), _this->_param->lpCtx); + --_this->_recursionDepth; return TRUE; - } } } break; @@ -469,6 +573,33 @@ LRESULT CALLBACK CWin32InputBox::DlgProc(HWND hDlg, UINT message, WPARAM wParam, return FALSE; } +void CWin32InputBox::SetText(const char* pText) +{ + if (_hwndEditCtrl != NULL) + { + std::u16string utf16Text; + cocos2d::StringUtils::UTF8ToUTF16(pText, utf16Text); + + // Keep the cursor position + // Please refer to : + // https://msdn.microsoft.com/en-us/library/bb761598%28v=vs.85%29.aspx + // https://msdn.microsoft.com/en-us/library/bb761661%28v=vs.85%29.aspx + size_t len = utf16Text.length(); + DWORD beginPos, endPos; + ::SendMessageW(_hwndEditCtrl, EM_GETSEL, (WPARAM)&beginPos, (LPARAM)&endPos); + ::SendMessageW(_hwndEditCtrl, WM_SETTEXT, 0, (LPARAM)utf16Text.c_str()); + ::SendMessageW(_hwndEditCtrl, EM_SETSEL, (WPARAM)std::min(beginPos, len), (LPARAM)std::min(endPos, len)); + } +} + +void CWin32InputBox::Close() +{ + if (_param->hDlg != NULL) + { + ::EndDialog(_param->hDlg, IDCANCEL); + _param->hDlg = NULL; + } +} NS_CC_BEGIN @@ -476,7 +607,7 @@ namespace ui { EditBoxImpl* __createSystemEditBox(EditBox* pEditBox) { - return new EditBoxImplWin(pEditBox); + return new (std::nothrow) EditBoxImplWin(pEditBox); } EditBoxImplWin::EditBoxImplWin(EditBox* pEditText) @@ -489,6 +620,7 @@ EditBoxImplWin::EditBoxImplWin(EditBox* pEditText) , _colText(Color3B::WHITE) , _colPlaceHolder(Color3B::GRAY) , _maxLength(-1) +, _isEditing(false) { } @@ -590,37 +722,38 @@ void EditBoxImplWin::setReturnType(EditBox::KeyboardReturnType returnType) bool EditBoxImplWin::isEditing() { - return false; + return _isEditing; } void EditBoxImplWin::setText(const char* pText) { if (pText != nullptr) { + if (strcmp(_text.c_str(), pText) == 0) // do nothing if the text is not changed + { + return; + } + _text = pText; + if (_isEditing && s_win32InputBox != nullptr) // set text for the running Win32InputBox + { + s_win32InputBox->SetText(pText); + } if (_text.length() > 0) { _labelPlaceHolder->setVisible(false); - std::string strToShow; - if (EditBox::InputFlag::PASSWORD == _editBoxInputFlag) { long length = StringUtils::getCharacterCountInUTF8String(_text); - for (long i = 0; i < length; i++) - { - strToShow.append("*"); - } + std::string strToShow(length, '*'); // Fills strToShow with length consecutive copies of character '*' + _label->setString(strToShow); } else { - strToShow = _text; + _label->setString(_text); } - - //! std::string strWithEllipsis = getStringWithEllipsisJni(strToShow.c_str(), _editSize.width, _editSize.height-12); - //! _label->setString(strWithEllipsis.c_str()); - _label->setString(strToShow.c_str()); float maxWidth = _editSize.width - 2 * CC_EDIT_BOX_PADDING; auto labelSize = _label->getContentSize(); @@ -653,7 +786,7 @@ void EditBoxImplWin::setPlaceHolder(const char* pText) _labelPlaceHolder->setVisible(true); } - _labelPlaceHolder->setString(_placeHolder.c_str()); + _labelPlaceHolder->setString(_placeHolder); } } @@ -687,9 +820,10 @@ void EditBoxImplWin::openKeyboard() _delegate->editBoxEditingDidBegin(_editBox); } + _isEditing = true; #if CC_ENABLE_SCRIPT_BINDING auto editBox = this->getEditBox(); - if (editBox && editBox->getScriptEditBoxHandler()) + if (nullptr != editBox && 0 != editBox->getScriptEditBoxHandler()) { CommonScriptData data(editBox->getScriptEditBoxHandler(), "began",editBox); ScriptEvent event(kCommonEvent,(void*)&data); @@ -704,7 +838,10 @@ void EditBoxImplWin::openKeyboard() std::string text = getText(); auto glView = Director::getInstance()->getOpenGLView(); HWND hwnd = glView->getWin32Window(); - bool didChange = CWin32InputBox::InputBox("Input", placeHolder.c_str(), &text, _maxLength, false, hwnd) == IDOK; + bool didChange = CWin32InputBox::InputBox("Input", placeHolder.c_str(), &text, _maxLength, false, hwnd, + _keyboardReturnType, _editBoxInputMode, _editBoxInputFlag, + &EditBoxImplWin::onWin32InputBoxTextChange, this) == IDOK; + _isEditing = false; if (didChange) setText(text.c_str()); @@ -738,9 +875,38 @@ void EditBoxImplWin::openKeyboard() #endif // #if CC_ENABLE_SCRIPT_BINDING } +void EditBoxImplWin::onWin32InputBoxTextChange(const char *pText, EditBoxImplWin* thiz) +{ + thiz->_isEditing = false; // Prevent recursive calls + thiz->setText(pText); + thiz->_isEditing = true; + + auto delegate = thiz->getDelegate(); + if (delegate != nullptr) + { + delegate->editBoxTextChanged(thiz->_editBox, thiz->_text); + } + +#if CC_ENABLE_SCRIPT_BINDING + auto editBox = thiz->getEditBox(); + if (nullptr != editBox && 0 != editBox->getScriptEditBoxHandler()) + { + CommonScriptData data(editBox->getScriptEditBoxHandler(), "changed", editBox); + ScriptEvent event(kCommonEvent, (void*)&data); + ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); + } +#endif // #if CC_ENABLE_SCRIPT_BINDING +} + void EditBoxImplWin::closeKeyboard() { - + // close the running Win32InputBox + if (s_win32InputBox != nullptr) + { + s_win32InputBox->Close(); + s_win32InputBox = nullptr; + _isEditing = false; + } } void EditBoxImplWin::onEnter(void) diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-win32.h b/cocos/ui/UIEditBox/UIEditBoxImpl-win32.h index b8e5e60b65..26a09e0fed 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-win32.h +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-win32.h @@ -105,6 +105,8 @@ private: HWND _sysEdit; int _maxTextLength; */ + bool _isEditing; + static void onWin32InputBoxTextChange(const char *pText, EditBoxImplWin *thiz); }; From 78ef01956109811d22a8ed67d389497a13878120 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 18 Aug 2015 10:17:44 +0800 Subject: [PATCH 002/118] Made travis run for v3.8 --- .travis.yml | 2 +- tools/travis-scripts/travis_mac.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1bccfbf9d6..1739a0557d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,4 +37,4 @@ before_install: # whitelist branches: only: - - v3 + - v3.8 diff --git a/tools/travis-scripts/travis_mac.yml b/tools/travis-scripts/travis_mac.yml index d5ea1235f9..bd657f20b8 100644 --- a/tools/travis-scripts/travis_mac.yml +++ b/tools/travis-scripts/travis_mac.yml @@ -16,4 +16,4 @@ notifications: # whitelist branches: only: - - v3 + - v3.8 From f671d36e311cf86844e55c717f5268c6d6d3eb70 Mon Sep 17 00:00:00 2001 From: fusijie Date: Tue, 18 Aug 2015 11:19:32 +0800 Subject: [PATCH 003/118] Fixed lua testacase setPointer error. --- tests/lua-tests/src/OpenGLTest/OpenGLTest.lua | 315 +++++------------- 1 file changed, 79 insertions(+), 236 deletions(-) diff --git a/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua b/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua index b8830dcded..747b7ab58d 100644 --- a/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua +++ b/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua @@ -190,268 +190,111 @@ local function OpenGLTestMainLayer() return RetroEffectlayer end - local function createShaderMajoriTest() - local majorLayer = cc.Layer:create() + local function createShaderNodeLayer(vSource, fSource) + local shaderNodeLayer = cc.Layer:create() - InitTitle(majorLayer) + InitTitle(shaderNodeLayer) - local fileUtiles = cc.FileUtils:getInstance() - - local vertSource = vertDefaultSource - local fragSource = fileUtiles:getStringFromFile("Shaders/example_Monjori.fsh") - local glProgam = cc.GLProgram:createWithByteArrays(vertSource, fragSource) - local glprogramstate = cc.GLProgramState:getOrCreateWithGLProgram(glProgam) - local resolution = cc.p(256, 256) + local vertSource = vSource + local fragSource = fSource + local glProgram = cc.GLProgram:createWithByteArrays(vertSource, fragSource) + glProgram:retain() local glNode = gl.glNodeCreate() - glNode:setContentSize(cc.size(256, 256)) - glNode:setAnchorPoint(cc.p(0.5, 0.5)) - glNode:setGLProgramState(glprogramstate) - glNode:getGLProgramState():setUniformVec2("resolution", resolution) - local function updateMajori(fTime) + local resolution = cc.p(256, 256) + local director = cc.Director:getInstance() + local frameSize = director:getOpenGLView():getFrameSize() + local visibleSize = director:getVisibleSize() + local retinaFactor = director:getOpenGLView():getRetinaFactor() + local center = cc.p( size.width / 2 * frameSize.width / visibleSize.width * retinaFactor, size.height / 2 * frameSize.height / visibleSize.height * retinaFactor) + + local function initBuffers() + local w = 256 + local h = 256 + local x = size.width / 2 - w / 2 + local y = size.height / 2 -h / 2 + local vertices ={ x,y, x+w,y, x+w,y+h, x,y, x,y+h, x+w,y+h } + local vbo = gl.createBuffer() + gl.bindBuffer(gl.ARRAY_BUFFER, vbo) + gl.bufferData(gl.ARRAY_BUFFER, table.getn(vertices), vertices, gl.STATIC_DRAW) + gl.bindBuffer(gl.ARRAY_BUFFER, 0) + return vbo + end + + local vbo = initBuffers() + + local function update(fTime) time = time + fTime end - local function majoriDraw(transform, transformUpdated) - local w = 256 - local h = 256 + local function draw(transform, transformUpdated) + glProgram:use() + glProgram:setUniformsForBuiltins() - local vertices ={ 0,0, w,0, w,h, 0,0, 0,h, w,h } - local glProgramState = glNode:getGLProgramState() - glProgramState:setVertexAttribPointer("a_position", 2, gl.FLOAT, false, 0, vertices, #vertices) - glProgramState:apply(transform) + local uniformCenter = gl.getUniformLocation(glProgram:getProgram(), "center") + glProgram:setUniformLocationF32(uniformCenter, center.x, center.y) + local uniformResolution = gl.getUniformLocation(glProgram:getProgram(), "resolution") + glProgram:setUniformLocationF32(uniformResolution, resolution.x, resolution.y) + + gl.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION) + gl.bindBuffer(gl.ARRAY_BUFFER, vbo) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0); gl.drawArrays(gl.TRIANGLES, 0, 6) + gl.bindBuffer(gl.ARRAY_BUFFER, 0) end - majorLayer:scheduleUpdateWithPriorityLua(updateMajori,0) - glNode:registerScriptDrawHandler(majoriDraw) + shaderNodeLayer:scheduleUpdateWithPriorityLua(update,0) + glNode:registerScriptDrawHandler(draw) time = 0 - majorLayer:addChild(glNode,-10) + shaderNodeLayer:addChild(glNode,-10) glNode:setPosition( size.width/2, size.height/2) - local center = cc.p( size.width / 2 * scaleFactor, size.height / 2 * scaleFactor) - glNode:getGLProgramState():setUniformVec2("center", center) - return majorLayer + + local function onNodeEvent(event) + if "exit" == event then + glProgram:release() + end + end + + shaderNodeLayer:registerScriptHandler(onNodeEvent) + + return shaderNodeLayer + end + + local function createShaderMajoriTest() + local vSource = vertDefaultSource + local fSource = cc.FileUtils:getInstance():getStringFromFile("Shaders/example_Monjori.fsh") + return createShaderNodeLayer(vSource, fSource) end local function createShaderMandelbrotTest() - local mandelbrotLayer = cc.Layer:create() - - InitTitle(mandelbrotLayer) - - local fileUtiles = cc.FileUtils:getInstance() - local vertSource = vertDefaultSource - local fragSource = fileUtiles:getStringFromFile("Shaders/example_Mandelbrot.fsh") - local glProgam = cc.GLProgram:createWithByteArrays(vertSource, fragSource) - local glprogramstate = cc.GLProgramState:getOrCreateWithGLProgram(glProgam) - local resolution = cc.p(256, 256) - - local glNode = gl.glNodeCreate() - glNode:setContentSize(cc.size(256, 256)) - glNode:setAnchorPoint(cc.p(0.5, 0.5)) - glNode:setGLProgramState(glprogramstate) - glNode:getGLProgramState():setUniformVec2("resolution", resolution) - - local function updateMandelbrot(fTime) - time = time + fTime - end - - local function mandelbrotDraw(transform, transformUpdated) - local w = 256 - local h = 256 - - local vertices ={ 0,0, w,0, w,h, 0,0, 0,h, w,h } - local glProgramState = glNode:getGLProgramState() - glProgramState:setVertexAttribPointer("a_position", 2, gl.FLOAT, false, 0, vertices, #vertices) - glProgramState:apply(transform) - gl.drawArrays(gl.TRIANGLES, 0, 6) - end - - mandelbrotLayer:scheduleUpdateWithPriorityLua(updateMandelbrot,0) - glNode:registerScriptDrawHandler(mandelbrotDraw) - time = 0 - mandelbrotLayer:addChild(glNode,-10) - glNode:setPosition( size.width/2, size.height/2) - local center = cc.p( size.width / 2 * scaleFactor, size.height / 2 * scaleFactor) - glNode:getGLProgramState():setUniformVec2("center", center) - return mandelbrotLayer + local vSource = vertDefaultSource + local fSource = cc.FileUtils:getInstance():getStringFromFile("Shaders/example_Mandelbrot.fsh") + return createShaderNodeLayer(vSource, fSource) end local function createShaderHeartTest() - - local heartLayer = cc.Layer:create() - - InitTitle(heartLayer) - - local fileUtiles = cc.FileUtils:getInstance() - local vertSource = vertDefaultSource - local fragSource = fileUtiles:getStringFromFile("Shaders/example_Heart.fsh") - local glProgam = cc.GLProgram:createWithByteArrays(vertSource, fragSource) - local glprogramstate = cc.GLProgramState:getOrCreateWithGLProgram(glProgam) - local resolution = cc.p(256, 256) - - local glNode = gl.glNodeCreate() - glNode:setContentSize(cc.size(256, 256)) - glNode:setAnchorPoint(cc.p(0.5, 0.5)) - glNode:setGLProgramState(glprogramstate) - glNode:getGLProgramState():setUniformVec2("resolution", resolution) - - local function updateHeart(fTime) - time = time + fTime - end - - local function heartDraw(transform, transformUpdated) - local w = 256 - local h = 256 - - local vertices ={ 0,0, w,0, w,h, 0,0, 0,h, w,h } - local glProgramState = glNode:getGLProgramState() - glProgramState:setVertexAttribPointer("a_position", 2, gl.FLOAT, false, 0, vertices, #vertices) - glProgramState:apply(transform) - gl.drawArrays(gl.TRIANGLES, 0, 6) - end - - heartLayer:scheduleUpdateWithPriorityLua(updateHeart,0) - glNode:registerScriptDrawHandler(heartDraw) - time = 0 - heartLayer:addChild(glNode,-10) - glNode:setPosition( size.width/2, size.height/2) - local center = cc.p( size.width / 2 * scaleFactor, size.height / 2 * scaleFactor) - glNode:getGLProgramState():setUniformVec2("center", center) - return heartLayer + local vSource = vertDefaultSource + local fSource = cc.FileUtils:getInstance():getStringFromFile("Shaders/example_Heart.fsh") + return createShaderNodeLayer(vSource, fSource) end local function createShaderPlasmaTest() - - local plasmaLayer = cc.Layer:create() - - InitTitle(plasmaLayer) - - local fileUtiles = cc.FileUtils:getInstance() - local vertSource = vertDefaultSource - local fragSource = fileUtiles:getStringFromFile("Shaders/example_Plasma.fsh") - local glProgam = cc.GLProgram:createWithByteArrays(vertSource, fragSource) - local glprogramstate = cc.GLProgramState:getOrCreateWithGLProgram(glProgam) - local resolution = cc.p(256, 256) - - local glNode = gl.glNodeCreate() - glNode:setContentSize(cc.size(256, 256)) - glNode:setAnchorPoint(cc.p(0.5, 0.5)) - glNode:setGLProgramState(glprogramstate) - glNode:getGLProgramState():setUniformVec2("resolution", resolution) - - - local function updatePlasma(fTime) - time = time + fTime - end - - local function plasmaDraw(transform, transformUpdated) - local w = 256 - local h = 256 - - local vertices ={ 0,0, w,0, w,h, 0,0, 0,h, w,h } - local glProgramState = glNode:getGLProgramState() - glProgramState:setVertexAttribPointer("a_position", 2, gl.FLOAT, false, 0, vertices, #vertices) - glProgramState:apply(transform) - gl.drawArrays(gl.TRIANGLES, 0, 6) - end - - plasmaLayer:scheduleUpdateWithPriorityLua(updatePlasma,0) - glNode:registerScriptDrawHandler(plasmaDraw) - time = 0 - plasmaLayer:addChild(glNode,-10) - glNode:setPosition( size.width/2, size.height/2) - local center = cc.p( size.width / 2 * scaleFactor, size.height / 2 * scaleFactor) - glNode:getGLProgramState():setUniformVec2("center", center) - return plasmaLayer + local vSource = vertDefaultSource + local fSource = cc.FileUtils:getInstance():getStringFromFile("Shaders/example_Plasma.fsh") + return createShaderNodeLayer(vSource, fSource) end local function createShaderFlowerTest() - - local flowerLayer = cc.Layer:create() - - InitTitle(flowerLayer) - - local fileUtiles = cc.FileUtils:getInstance() - local vertSource = vertDefaultSource - local fragSource = fileUtiles:getStringFromFile("Shaders/example_Flower.fsh") - local glProgam = cc.GLProgram:createWithByteArrays(vertSource, fragSource) - local glprogramstate = cc.GLProgramState:getOrCreateWithGLProgram(glProgam) - local resolution = cc.p(256, 256) - - local glNode = gl.glNodeCreate() - glNode:setContentSize(cc.size(256, 256)) - glNode:setAnchorPoint(cc.p(0.5, 0.5)) - glNode:setGLProgramState(glprogramstate) - glNode:getGLProgramState():setUniformVec2("resolution", resolution) - - local function updateFlower(fTime) - time = time + fTime - end - - local function flowerDraw(transform, transformUpdated) - local w = 256 - local h = 256 - - local vertices ={ 0,0, w,0, w,h, 0,0, 0,h, w,h } - local glProgramState = glNode:getGLProgramState() - glProgramState:setVertexAttribPointer("a_position", 2, gl.FLOAT, false, 0, vertices, #vertices) - glProgramState:apply(transform) - gl.drawArrays(gl.TRIANGLES, 0, 6) - end - - flowerLayer:scheduleUpdateWithPriorityLua(updateFlower,0) - glNode:registerScriptDrawHandler(flowerDraw) - time = 0 - flowerLayer:addChild(glNode,-10) - glNode:setPosition( size.width/2, size.height/2) - local center = cc.p( size.width / 2 * scaleFactor, size.height / 2 * scaleFactor) - glNode:getGLProgramState():setUniformVec2("center", center) - return flowerLayer + local vSource = vertDefaultSource + local fSource = cc.FileUtils:getInstance():getStringFromFile("Shaders/example_Flower.fsh") + return createShaderNodeLayer(vSource, fSource) end local function createShaderJuliaTest() - - local juliaLayer = cc.Layer:create() - - InitTitle(juliaLayer) - - local fileUtiles = cc.FileUtils:getInstance() - local vertSource = vertDefaultSource - local fragSource = fileUtiles:getStringFromFile("Shaders/example_Julia.fsh") - local glProgam = cc.GLProgram:createWithByteArrays(vertSource, fragSource) - local glprogramstate = cc.GLProgramState:getOrCreateWithGLProgram(glProgam) - local resolution = cc.p(256, 256) - - local glNode = gl.glNodeCreate() - glNode:setContentSize(cc.size(256, 256)) - glNode:setAnchorPoint(cc.p(0.5, 0.5)) - glNode:setGLProgramState(glprogramstate) - glNode:getGLProgramState():setUniformVec2("resolution", resolution) - - local function updateJulia(fTime) - time = time + fTime - end - - local function juliaDraw(transform, transformUpdated) - local w = 256 - local h = 256 - - local vertices ={ 0,0, w,0, w,h, 0,0, 0,h, w,h } - local glProgramState = glNode:getGLProgramState() - glProgramState:setVertexAttribPointer("a_position", 2, gl.FLOAT, false, 0, vertices, #vertices) - glProgramState:apply(transform) - gl.drawArrays(gl.TRIANGLES, 0, 6) - end - - juliaLayer:scheduleUpdateWithPriorityLua(updateJulia,0) - glNode:registerScriptDrawHandler(juliaDraw) - time = 0 - juliaLayer:addChild(glNode,-10) - glNode:setPosition( size.width/2, size.height/2) - local center = cc.p( size.width / 2 * scaleFactor, size.height / 2 * scaleFactor) - glNode:getGLProgramState():setUniformVec2("center", center) - return juliaLayer + local vSource = vertDefaultSource + local fSource = cc.FileUtils:getInstance():getStringFromFile("Shaders/example_Julia.fsh") + return createShaderNodeLayer(vSource, fSource) end local function createGLGetActiveTest() @@ -466,9 +309,9 @@ local function OpenGLTestMainLayer() local function getCurrentResult() local var = {} - local glProgam = sprite:getGLProgram() - if nil ~= glProgam then - local p = glProgam:getProgram() + local glProgram = sprite:getGLProgram() + if nil ~= glProgram then + local p = glProgram:getProgram() local aaSize,aaType,aaName = gl.getActiveAttrib(p,0) local strFmt = "size:"..aaSize.." type:"..aaType.." name:"..aaName print(strFmt) From a799c99b1afb2f6b6f24a01740d6ceaf9951743c Mon Sep 17 00:00:00 2001 From: fusijie Date: Tue, 18 Aug 2015 11:46:45 +0800 Subject: [PATCH 004/118] fix setVertexAttribPointer luabinding --- .../manual/cocos2d/lua_cocos2dx_manual.cpp | 61 ------------------- 1 file changed, 61 deletions(-) diff --git a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp index 96ade969f9..641413e080 100644 --- a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp @@ -7213,67 +7213,6 @@ static int lua_cocos2dx_GLProgramState_setVertexAttribPointer(lua_State* tolua_S lua_settop(tolua_S, 1); return 1; } - else if (argc == 7) - { - std::string arg0; - int arg1; - unsigned int arg2; - bool arg3; - int arg4; - GLfloat* arg5; - int arg6; - - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.GLProgramState:setVertexAttribPointer"); - - ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "cc.GLProgramState:setVertexAttribPointer"); - - ok &= luaval_to_uint32(tolua_S, 4,&arg2, "cc.GLProgramState:setVertexAttribPointer"); - - ok &= luaval_to_boolean(tolua_S, 5, &arg3, "cc.GLProgramState:setVertexAttribPointer"); - - ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4, "cc.GLProgramState:setVertexAttribPointer"); - - ok &= luaval_to_int32(tolua_S, 8, (int *)&arg6, "cc.GLProgramState:setVertexAttribPointer"); - - size_t len = lua_objlen(tolua_S, 7); - - if (len != arg6) - { - luaL_error(tolua_S, "table size is %zu,but input size is %d \n", len, arg6); - return 0; - } - - arg5 = new (std::nothrow) GLfloat[len]; - for (int i = 0; i < len; i++) - { - lua_pushnumber(tolua_S,i + 1); - lua_gettable(tolua_S,7); - bool isnum = true; -#if COCOS2D_DEBUG >= 1 - if (!tolua_isnumber(tolua_S, -1, 0, &tolua_err)) - { - isnum = false; - } -#endif - if (isnum) - { - arg5[i] = tolua_tonumber(tolua_S, -1, 0); - } - else - { - arg5[i] = 0; - } - lua_pop(tolua_S, 1); - } - - cobj->setVertexAttribPointer(arg0, arg1, arg2, arg3, arg4, (void*)arg5); - - CC_SAFE_DELETE(arg5); - - lua_settop(tolua_S, 1); - return 1; - } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.GLProgramState:setVertexAttribPointer",argc, 6); return 0; From 8463aa4b96694bb2bc39625a32fb5204ed09cab2 Mon Sep 17 00:00:00 2001 From: VisualSj Date: Tue, 18 Aug 2015 14:39:15 +0800 Subject: [PATCH 005/118] Update Web Index --- web | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web b/web index 3aac6645cf..5d123ed296 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit 3aac6645cf36f40077d642daf8876913361fc930 +Subproject commit 5d123ed2969f4f31380480d0c649fd6c0ff7a102 From 223d5a7a5c9b17b9f6720daa43787a48cdd10d31 Mon Sep 17 00:00:00 2001 From: fusijie Date: Tue, 18 Aug 2015 14:48:16 +0800 Subject: [PATCH 006/118] fix copy construct & assignment operator memory leakage. --- cocos/2d/CCAutoPolygon.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/2d/CCAutoPolygon.cpp b/cocos/2d/CCAutoPolygon.cpp index 7086e314c5..bd6668106f 100644 --- a/cocos/2d/CCAutoPolygon.cpp +++ b/cocos/2d/CCAutoPolygon.cpp @@ -44,7 +44,7 @@ isVertsOwner(true), rect() { filename = other.filename; - isVertsOwner = other.isVertsOwner; + isVertsOwner = true; rect = other.rect; triangles.verts = new V3F_C4B_T2F[other.triangles.vertCount]; triangles.indices = new unsigned short[other.triangles.indexCount]; @@ -60,7 +60,7 @@ PolygonInfo& PolygonInfo::operator= (const PolygonInfo& other) { releaseVertsAndIndices(); filename = other.filename; - isVertsOwner = other.isVertsOwner; + isVertsOwner = true; rect = other.rect; triangles.verts = new V3F_C4B_T2F[other.triangles.vertCount]; triangles.indices = new unsigned short[other.triangles.indexCount]; From 6bf15885b8932bce89f17bf4e9effe4c75f67163 Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Tue, 18 Aug 2015 15:42:05 +0800 Subject: [PATCH 007/118] Fixed `Label::getLetter(index)->setVisible(true)` cause draws duplicate letters. --- cocos/2d/CCLabel.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index f853ab05e0..a8643b3640 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -144,6 +144,11 @@ public: _textureAtlas->updateQuad(&_quad, _atlasIndex); } + + //LabelLetter doesn't need to draw directly. + void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) + { + } }; Label* Label::create() From 22c8163bc83562762196b8cd58b1817c18cffef0 Mon Sep 17 00:00:00 2001 From: VisualSj Date: Tue, 18 Aug 2015 16:12:32 +0800 Subject: [PATCH 008/118] [js-tests][PageView] Button position error --- .../src/GUITest/UIPageViewTest/UIPageViewTest.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/js-tests/src/GUITest/UIPageViewTest/UIPageViewTest.js b/tests/js-tests/src/GUITest/UIPageViewTest/UIPageViewTest.js index 97281e28ad..7876a75fd7 100644 --- a/tests/js-tests/src/GUITest/UIPageViewTest/UIPageViewTest.js +++ b/tests/js-tests/src/GUITest/UIPageViewTest/UIPageViewTest.js @@ -308,13 +308,13 @@ var UIPageViewTouchPropagationTest = UIMainLayer.extend({ var propagationText = new ccui.Text("Allow Propagation", "Arial", 10); propagationText.setAnchorPoint(cc.p(0,0.5)); propagationText.setTextColor(cc.color.RED); - propagationText.setPosition(cc.p(0, pageView.getPosition().y + 50)); + propagationText.setPosition(cc.p(20, pageView.getPosition().y + 50)); this._mainNode.addChild(propagationText); var swallowTouchText = new ccui.Text("Swallow Touches", "Arial", 10); swallowTouchText.setAnchorPoint(cc.p(0,0.5)); swallowTouchText.setTextColor(cc.color.RED); - swallowTouchText.setPosition(cc.p(0, pageView.getPosition().y)); + swallowTouchText.setPosition(cc.p(20, pageView.getPosition().y)); this._mainNode.addChild(swallowTouchText); // Create the checkbox @@ -452,7 +452,8 @@ var UIPageViewDynamicAddAndRemoveTest = UIMainLayer.extend({ //add buttons var button = new ccui.Button(); -// button.setNormalizedPosition(cc.p(0.12,0.7)); + button.setAnchorPoint(0, 0.5); + button.setTitleFontSize(12); button.setPosition(20, 220); button.setTitleText("Add A Page"); button.setZoomScale(0.3); @@ -484,7 +485,8 @@ var UIPageViewDynamicAddAndRemoveTest = UIMainLayer.extend({ this._mainNode.addChild(button); var button2 = new ccui.Button(); -// button2.setNormalizedPosition(cc.p(0.12,0.5)); + button2.setAnchorPoint(0, 0.5); + button2.setTitleFontSize(12); button2.setPosition(20, 180); button2.setTitleText("Remove A Page"); button2.setZoomScale(0.3); @@ -502,7 +504,8 @@ var UIPageViewDynamicAddAndRemoveTest = UIMainLayer.extend({ this._mainNode.addChild(button2); var button3 = new ccui.Button(); -// button3.setNormalizedPosition(cc.p(0.12,0.3)); + button3.setAnchorPoint(0, 0.5); + button3.setTitleFontSize(12); button3.setPosition(cc.p(20, 140)); button3.setTitleText("Remove All Pages"); button3.setZoomScale(0.3); From 4d9a61569aa71b36c644d0d6b021d1821135ce28 Mon Sep 17 00:00:00 2001 From: VisualSj Date: Tue, 18 Aug 2015 18:30:03 +0800 Subject: [PATCH 009/118] Set the transparency will affect the labelTTF --- templates/js-template-default/index.html | 2 +- templates/js-template-runtime/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/js-template-default/index.html b/templates/js-template-default/index.html index fe9cb3d4ea..be7564a361 100644 --- a/templates/js-template-default/index.html +++ b/templates/js-template-default/index.html @@ -20,7 +20,7 @@ } - + diff --git a/templates/js-template-runtime/index.html b/templates/js-template-runtime/index.html index fe9cb3d4ea..be7564a361 100644 --- a/templates/js-template-runtime/index.html +++ b/templates/js-template-runtime/index.html @@ -20,7 +20,7 @@ } - + From 5dd6d94c17e99464f40b2476a94630fa372b6e42 Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Tue, 18 Aug 2015 22:19:24 +0800 Subject: [PATCH 010/118] Test cases:improve small problems. --- tests/cpp-tests/Classes/BaseTest.cpp | 23 ++++++++++++------- tests/cpp-tests/Classes/BaseTest.h | 1 + .../CocoStudioGUITest/CocoStudioGUITest.lua | 12 +++++----- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/tests/cpp-tests/Classes/BaseTest.cpp b/tests/cpp-tests/Classes/BaseTest.cpp index 42a804dc4f..e37514fd62 100644 --- a/tests/cpp-tests/Classes/BaseTest.cpp +++ b/tests/cpp-tests/Classes/BaseTest.cpp @@ -135,8 +135,8 @@ void TestList::addTest(const std::string& testName, std::function c { if (!testName.empty()) { - _childTestNames.push_back(testName); - _testCallbacks.push_back(callback); + _childTestNames.emplace_back(StringUtils::format("%d", static_cast(_childTestNames.size() + 1)) + ":" + testName); + _testCallbacks.emplace_back(callback); } } @@ -193,7 +193,7 @@ void TestList::runThisTest() auto autoTestItem = MenuItemLabel::create(autoTestLabel, [&](Ref* sender){ TestController::getInstance()->startAutoTest(); }); - autoTestItem->setPosition(Vec2(VisibleRect::right().x - 70, VisibleRect::bottom().y + 25)); + autoTestItem->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + 50)); auto menu = Menu::create(closeItem, autoTestItem, nullptr); menu->setPosition(Vec2::ZERO); @@ -262,8 +262,8 @@ void TestSuite::addTestCase(const std::string& testName, std::function { if (!testName.empty() && callback) { - _childTestNames.push_back(testName); - _testCallbacks.push_back(callback); + _childTestNames.emplace_back(testName); + _testCallbacks.emplace_back(callback); } } @@ -432,14 +432,21 @@ void TestCase::onEnter() { Scene::onEnter(); - _titleLabel->setString(title()); - _subtitleLabel->setString(subtitle()); - if (_testSuite == nullptr) { setTestSuite(TestController::getInstance()->getCurrTestSuite()); } + if (_testSuite) + { + _titleLabel->setString(StringUtils::format("%d", static_cast(_testSuite->getCurrTestIndex() + 1)) + ":" + title()); + } + else + { + _titleLabel->setString(title()); + } + _subtitleLabel->setString(subtitle()); + if (_testSuite && _testSuite->getChildTestCount() < 2) { _priorTestItem->setVisible(false); diff --git a/tests/cpp-tests/Classes/BaseTest.h b/tests/cpp-tests/Classes/BaseTest.h index 4c8a1faac2..6a810e2c4c 100644 --- a/tests/cpp-tests/Classes/BaseTest.h +++ b/tests/cpp-tests/Classes/BaseTest.h @@ -162,6 +162,7 @@ public: virtual void enterNextTest(); virtual void enterPreviousTest(); + int getCurrTestIndex() { return _currTestIndex; } virtual void runThisTest() override; private: diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua index 46be6df7e0..e452ea92d6 100644 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua +++ b/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua @@ -1395,12 +1395,12 @@ function UITextFieldTest:initExtend() if eventType == ccui.TextFiledEventType.attach_with_ime then local textField = sender local screenSize = cc.Director:getInstance():getWinSize() - textField:runAction(cc.MoveBy:create(0.225,cc.p(0, textField:getContentSize().height / 2.0))) + textField:runAction(cc.MoveBy:create(0.225,cc.p(0, 20))) self._displayValueLabel:setString("attach with IME") elseif eventType == ccui.TextFiledEventType.detach_with_ime then local textField = sender local screenSize = cc.Director:getInstance():getWinSize() - textField:runAction(cc.MoveBy:create(0.175, cc.p(0, textField:getContentSize().height / -2.0))) + textField:runAction(cc.MoveBy:create(0.175, cc.p(0, -20))) self._displayValueLabel:setString("detach with IME") elseif eventType == ccui.TextFiledEventType.insert_text then self._displayValueLabel:setString("insert words") @@ -1465,13 +1465,13 @@ function UITextFieldMaxLengthTest:initExtend() if eventType == ccui.TextFiledEventType.attach_with_ime then local textField = sender local screenSize = cc.Director:getInstance():getWinSize() - textField:runAction(cc.MoveTo:create(0.225,cc.p(screenSize.width / 2.0, screenSize.height / 2.0 + textField:getContentSize().height / 2.0))) + textField:runAction(cc.MoveBy:create(0.225,cc.p(0, 20))) local info = string.format("attach with IME max length %d",textField:getMaxLength()) self._displayValueLabel:setString(info) elseif eventType == ccui.TextFiledEventType.detach_with_ime then local textField = sender local screenSize = cc.Director:getInstance():getWinSize() - textField:runAction(cc.MoveTo:create(0.175, cc.p(screenSize.width / 2.0, screenSize.height / 2.0))) + textField:runAction(cc.MoveBy:create(0.175, cc.p(0, -20))) local info = string.format("detach with IME max length %d",textField:getMaxLength()) self._displayValueLabel:setString(info) elseif eventType == ccui.TextFiledEventType.insert_text then @@ -1543,12 +1543,12 @@ function UITextFieldPasswordTest:initExtend() if eventType == ccui.TextFiledEventType.attach_with_ime then local textField = sender local screenSize = cc.Director:getInstance():getWinSize() - textField:runAction(cc.MoveTo:create(0.175, cc.p(screenSize.width / 2.0, screenSize.height / 2.0))) + textField:runAction(cc.MoveBy:create(0.175, cc.p(0, 20))) self._displayValueLabel:setString("detach with IME password") elseif eventType == ccui.TextFiledEventType.detach_with_ime then local textField = sender local screenSize = cc.Director:getInstance():getWinSize() - textField:runAction(cc.MoveTo:create(0.175, cc.p(screenSize.width / 2.0, screenSize.height / 2.0))) + textField:runAction(cc.MoveBy:create(0.175, cc.p(0, -20))) self._displayValueLabel:setString("detach with IME password") elseif eventType == ccui.TextFiledEventType.insert_text then self._displayValueLabel:setString("insert words password") From 5cdfdf8497e5a82d1c1594fcb67d03de222deb77 Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Tue, 18 Aug 2015 22:37:00 +0800 Subject: [PATCH 011/118] [ci skip][Android Studio Projects]Update Gradle Plugin from 1.2.3 to 1.3.0 --- templates/cpp-template-default/proj.android-studio/build.gradle | 2 +- .../frameworks/runtime-src/proj.android-studio/build.gradle | 2 +- .../frameworks/runtime-src/proj.android-studio/build.gradle | 2 +- tests/cpp-empty-test/proj.android-studio/build.gradle | 2 +- tests/cpp-tests/proj.android-studio/build.gradle | 2 +- tests/game-controller-test/proj.android-studio/build.gradle | 2 +- tests/js-tests/project/proj.android-studio/build.gradle | 2 +- tests/lua-empty-test/project/proj.android-studio/build.gradle | 2 +- .../project/proj.android-studio/build.gradle | 2 +- tests/lua-tests/project/proj.android-studio/build.gradle | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/templates/cpp-template-default/proj.android-studio/build.gradle b/templates/cpp-template-default/proj.android-studio/build.gradle index 9405f3fd18..1b7886d148 100644 --- a/templates/cpp-template-default/proj.android-studio/build.gradle +++ b/templates/cpp-template-default/proj.android-studio/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' + classpath 'com.android.tools.build:gradle:1.3.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/templates/js-template-default/frameworks/runtime-src/proj.android-studio/build.gradle b/templates/js-template-default/frameworks/runtime-src/proj.android-studio/build.gradle index 9405f3fd18..1b7886d148 100644 --- a/templates/js-template-default/frameworks/runtime-src/proj.android-studio/build.gradle +++ b/templates/js-template-default/frameworks/runtime-src/proj.android-studio/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' + classpath 'com.android.tools.build:gradle:1.3.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.android-studio/build.gradle b/templates/lua-template-default/frameworks/runtime-src/proj.android-studio/build.gradle index 9405f3fd18..1b7886d148 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.android-studio/build.gradle +++ b/templates/lua-template-default/frameworks/runtime-src/proj.android-studio/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' + classpath 'com.android.tools.build:gradle:1.3.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/tests/cpp-empty-test/proj.android-studio/build.gradle b/tests/cpp-empty-test/proj.android-studio/build.gradle index 9405f3fd18..1b7886d148 100644 --- a/tests/cpp-empty-test/proj.android-studio/build.gradle +++ b/tests/cpp-empty-test/proj.android-studio/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' + classpath 'com.android.tools.build:gradle:1.3.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/tests/cpp-tests/proj.android-studio/build.gradle b/tests/cpp-tests/proj.android-studio/build.gradle index 9405f3fd18..1b7886d148 100644 --- a/tests/cpp-tests/proj.android-studio/build.gradle +++ b/tests/cpp-tests/proj.android-studio/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' + classpath 'com.android.tools.build:gradle:1.3.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/tests/game-controller-test/proj.android-studio/build.gradle b/tests/game-controller-test/proj.android-studio/build.gradle index 9405f3fd18..1b7886d148 100644 --- a/tests/game-controller-test/proj.android-studio/build.gradle +++ b/tests/game-controller-test/proj.android-studio/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' + classpath 'com.android.tools.build:gradle:1.3.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/tests/js-tests/project/proj.android-studio/build.gradle b/tests/js-tests/project/proj.android-studio/build.gradle index 9405f3fd18..1b7886d148 100644 --- a/tests/js-tests/project/proj.android-studio/build.gradle +++ b/tests/js-tests/project/proj.android-studio/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' + classpath 'com.android.tools.build:gradle:1.3.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/tests/lua-empty-test/project/proj.android-studio/build.gradle b/tests/lua-empty-test/project/proj.android-studio/build.gradle index 9405f3fd18..1b7886d148 100644 --- a/tests/lua-empty-test/project/proj.android-studio/build.gradle +++ b/tests/lua-empty-test/project/proj.android-studio/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' + classpath 'com.android.tools.build:gradle:1.3.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/tests/lua-game-controller-test/project/proj.android-studio/build.gradle b/tests/lua-game-controller-test/project/proj.android-studio/build.gradle index 9405f3fd18..1b7886d148 100644 --- a/tests/lua-game-controller-test/project/proj.android-studio/build.gradle +++ b/tests/lua-game-controller-test/project/proj.android-studio/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' + classpath 'com.android.tools.build:gradle:1.3.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/tests/lua-tests/project/proj.android-studio/build.gradle b/tests/lua-tests/project/proj.android-studio/build.gradle index 9405f3fd18..1b7886d148 100644 --- a/tests/lua-tests/project/proj.android-studio/build.gradle +++ b/tests/lua-tests/project/proj.android-studio/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' + classpath 'com.android.tools.build:gradle:1.3.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files From 2dbb4ad50ee3f8287fbb74bc7264234fb7bcf32d Mon Sep 17 00:00:00 2001 From: fusijie Date: Tue, 18 Aug 2015 18:34:31 +0800 Subject: [PATCH 012/118] fixed JSB_glGetUniformfv uniform location is different from index. --- .../js-bindings/manual/jsb_opengl_manual.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp b/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp index 0da5d5af9f..c960160cca 100644 --- a/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp +++ b/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp @@ -431,13 +431,30 @@ bool JSB_glGetUniformfv(JSContext *cx, uint32_t argc, jsval *vp) JSB_PRECONDITION2(ok, cx, false, "JSB_glGetUniformfv: Error processing arguments"); + GLint activeUniforms; + glGetProgramiv(arg0, GL_ACTIVE_UNIFORMS, &activeUniforms); + GLsizei length; glGetProgramiv(arg0, GL_ACTIVE_UNIFORM_MAX_LENGTH, &length); GLchar* namebuffer = new GLchar[length+1]; GLint size = -1; GLenum type = -1; - glGetActiveUniform(arg0, arg1, length, NULL, &size, &type, namebuffer); + bool isLocationFound = false; + for(int i = 0; i < activeUniforms; ++i) + { + glGetActiveUniform(arg0, i, length, NULL, &size, &type, namebuffer); + if(arg1 == glGetUniformLocation(arg0, namebuffer)) + { + isLocationFound = true; + break; + } + } + if(!isLocationFound) + { + size = -1; + type = -1; + } CC_SAFE_DELETE_ARRAY(namebuffer); int usize = 0; From 827f05c5e1abc3d7fb3cf67f7621ddc83925049b Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Wed, 19 Aug 2015 10:22:48 +0800 Subject: [PATCH 013/118] Fixed `Label::setGlobalZOrder ` is invalid when label create with system font. --- cocos/2d/CCLabel.cpp | 15 +++++++++++++++ cocos/2d/CCLabel.h | 1 + 2 files changed, 16 insertions(+) diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index a8643b3640..64a716cd3e 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -983,6 +983,7 @@ void Label::createSpriteForSystemFont(const FontDefinition& fontDef) _textSprite = Sprite::createWithTexture(texture); //set camera mask using label's camera mask, because _textSprite may be null when setting camera mask to label _textSprite->setCameraMask(getCameraMask()); + _textSprite->setGlobalZOrder(getGlobalZOrder()); _textSprite->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); this->setContentSize(_textSprite->getContentSize()); texture->release(); @@ -1027,6 +1028,7 @@ void Label::createShadowSpriteForSystemFont(const FontDefinition& fontDef) _shadowNode->setBlendFunc(_blendFunc); } _shadowNode->setCameraMask(getCameraMask()); + _shadowNode->setGlobalZOrder(getGlobalZOrder()); _shadowNode->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); _shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height); @@ -1724,4 +1726,17 @@ FontDefinition Label::_getFontDefinition() const return systemFontDef; } +void Label::setGlobalZOrder(float globalZOrder) +{ + Node::setGlobalZOrder(globalZOrder); + if (_textSprite) + { + _textSprite->setGlobalZOrder(globalZOrder); + if (_shadowNode) + { + _shadowNode->setGlobalZOrder(globalZOrder); + } + } +} + NS_CC_END diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index 931e0f577d..96a0c99cf8 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -453,6 +453,7 @@ public: virtual void removeAllChildrenWithCleanup(bool cleanup) override; virtual void removeChild(Node* child, bool cleanup = true) override; + virtual void setGlobalZOrder(float globalZOrder) override; CC_DEPRECATED_ATTRIBUTE static Label* create(const std::string& text, const std::string& font, float fontSize, const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT, From e9bd14e1d7b05e6a295bba3cb406803f5e04586b Mon Sep 17 00:00:00 2001 From: ZhangMenghe Date: Wed, 19 Aug 2015 13:41:45 +0800 Subject: [PATCH 014/118] Delete blur shader in js-resj --- tests/js-tests/resjs/Shaders/example_Blur.fsh | 27 ------------------- 1 file changed, 27 deletions(-) delete mode 100644 tests/js-tests/resjs/Shaders/example_Blur.fsh diff --git a/tests/js-tests/resjs/Shaders/example_Blur.fsh b/tests/js-tests/resjs/Shaders/example_Blur.fsh deleted file mode 100644 index 9bb423200d..0000000000 --- a/tests/js-tests/resjs/Shaders/example_Blur.fsh +++ /dev/null @@ -1,27 +0,0 @@ -// Shader taken from: http://webglsamples.googlecode.com/hg/electricflower/electricflower.html - -#ifdef GL_ES -precision mediump float; -#endif - -varying vec4 v_fragmentColor; -varying vec2 v_texCoord; - -uniform vec2 blurSize; -uniform vec4 substract; - -void main() { - vec4 sum = vec4(0.0); - sum += texture2D(CC_Texture0, v_texCoord - 4.0 * blurSize) * 0.05; - sum += texture2D(CC_Texture0, v_texCoord - 3.0 * blurSize) * 0.09; - sum += texture2D(CC_Texture0, v_texCoord - 2.0 * blurSize) * 0.12; - sum += texture2D(CC_Texture0, v_texCoord - 1.0 * blurSize) * 0.15; - sum += texture2D(CC_Texture0, v_texCoord ) * 0.16; - sum += texture2D(CC_Texture0, v_texCoord + 1.0 * blurSize) * 0.15; - sum += texture2D(CC_Texture0, v_texCoord + 2.0 * blurSize) * 0.12; - sum += texture2D(CC_Texture0, v_texCoord + 3.0 * blurSize) * 0.09; - sum += texture2D(CC_Texture0, v_texCoord + 4.0 * blurSize) * 0.05; - - gl_FragColor = (sum - substract) * v_fragmentColor; -} - From bf723eab912d353a35fd38ef17c35762000727eb Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Wed, 19 Aug 2015 05:55:16 +0000 Subject: [PATCH 015/118] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- cocos/scripting/lua-bindings/auto/api/Label.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cocos/scripting/lua-bindings/auto/api/Label.lua b/cocos/scripting/lua-bindings/auto/api/Label.lua index 46f547b5cb..f2e1d6f750 100644 --- a/cocos/scripting/lua-bindings/auto/api/Label.lua +++ b/cocos/scripting/lua-bindings/auto/api/Label.lua @@ -480,4 +480,11 @@ -- @param #color3b_table parentColor -- @return Label#Label self (return value: cc.Label) +-------------------------------- +-- +-- @function [parent=#Label] setGlobalZOrder +-- @param self +-- @param #float globalZOrder +-- @return Label#Label self (return value: cc.Label) + return nil From f26509efe4e7cb6d084dd367da6d3cf89a15c1ba Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Wed, 19 Aug 2015 14:02:12 +0800 Subject: [PATCH 016/118] Fix when picture file used by TMX map file missing or broken, create TMX object will cause program crashed --- cocos/2d/CCTMXLayer.cpp | 3 +++ cocos/2d/CCTMXTiledMap.cpp | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cocos/2d/CCTMXLayer.cpp b/cocos/2d/CCTMXLayer.cpp index 932e1f6749..8b655f169c 100644 --- a/cocos/2d/CCTMXLayer.cpp +++ b/cocos/2d/CCTMXLayer.cpp @@ -61,6 +61,9 @@ bool TMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *la texture = Director::getInstance()->getTextureCache()->addImage(tilesetInfo->_sourceImage.c_str()); } + if (nullptr == texture) + return false; + if (SpriteBatchNode::initWithTexture(texture, static_cast(capacity))) { // layerInfo diff --git a/cocos/2d/CCTMXTiledMap.cpp b/cocos/2d/CCTMXTiledMap.cpp index 773cf01d24..4f7913fad8 100644 --- a/cocos/2d/CCTMXTiledMap.cpp +++ b/cocos/2d/CCTMXTiledMap.cpp @@ -107,9 +107,12 @@ TMXLayer * TMXTiledMap::parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo) TMXLayer *layer = TMXLayer::create(tileset, layerInfo, mapInfo); - // tell the layerinfo to release the ownership of the tiles map. - layerInfo->_ownTiles = false; - layer->setupTiles(); + if (nullptr != layer) + { + // tell the layerinfo to release the ownership of the tiles map. + layerInfo->_ownTiles = false; + layer->setupTiles(); + } return layer; } From bdc22516c81e5c6473a486f420e074ff7f1e31ec Mon Sep 17 00:00:00 2001 From: fusijie Date: Wed, 19 Aug 2015 15:05:18 +0800 Subject: [PATCH 017/118] fix as compile error. --- tests/cpp-tests/proj.android-studio/app/jni/Android.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/cpp-tests/proj.android-studio/app/jni/Android.mk b/tests/cpp-tests/proj.android-studio/app/jni/Android.mk index 0c7e3a0d59..4717c01e4f 100644 --- a/tests/cpp-tests/proj.android-studio/app/jni/Android.mk +++ b/tests/cpp-tests/proj.android-studio/app/jni/Android.mk @@ -46,6 +46,7 @@ LOCAL_SRC_FILES := main.cpp \ ../../../Classes/CurlTest/CurlTest.cpp \ ../../../Classes/CurrentLanguageTest/CurrentLanguageTest.cpp \ ../../../Classes/DataVisitorTest/DataVisitorTest.cpp \ +../../../Classes/DownloaderTest/DownloaderTest.cpp \ ../../../Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp \ ../../../Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp \ ../../../Classes/EffectsTest/EffectsTest.cpp \ From 2605865ca60dc3cbf28c552783d672e77c71addc Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 19 Aug 2015 16:21:31 +0800 Subject: [PATCH 018/118] Fixed #12570: Correct `cc.pIsSegmentIntersect` for lua --- cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua index 2ec89cbddc..6b451c36c0 100644 --- a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua +++ b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua @@ -174,7 +174,7 @@ function cc.pIsSegmentIntersect(pt1,pt2,pt3,pt4) local s,t,ret = 0,0,false ret,s,t =cc.pIsLineIntersect(pt1, pt2, pt3, pt4,s,t) - if ret and s >= 0.0 and s <= 1.0 and t >= 0.0 and t <= 0.0 then + if ret and s >= 0.0 and s <= 1.0 and t >= 0.0 and t <= 1.0 then return true end From 8f8126796095a3bfc4a50d17e658ae37693110a6 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Wed, 19 Aug 2015 18:25:34 +0800 Subject: [PATCH 019/118] skybox is not transparent --- cocos/3d/CCSkybox.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos/3d/CCSkybox.cpp b/cocos/3d/CCSkybox.cpp index e3bf4415ba..36d9bd4890 100644 --- a/cocos/3d/CCSkybox.cpp +++ b/cocos/3d/CCSkybox.cpp @@ -148,6 +148,8 @@ void Skybox::draw(Renderer* renderer, const Mat4& transform, uint32_t flags) { _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(Skybox::onDraw, this, transform, flags); + _customCommand.setTransparent(false); + _customCommand.set3D(true); renderer->addCommand(&_customCommand); } From 935b0f006b7849d89d23c04689f01d66a41935b3 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Thu, 20 Aug 2015 10:55:30 +0800 Subject: [PATCH 020/118] Fix https://github.com/cocos2d/cocos2d-x/issues/10205 --- .../editor-support/cocostudio/CCSGUIReader.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index e7701289f8..863349ab91 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -764,7 +764,11 @@ void WidgetPropertiesReader0250::setPropsForButtonFromJsonDictionary(Widget*widg bool fn = DICTOOL->checkObjectExist_json(options, "fontName"); if (fn) { - button->setTitleFontName(DICTOOL->getStringValue_json(options, "fontName")); + const char * szTemp = DICTOOL->getStringValue_json(options, "fontName"); + if (szTemp && *szTemp) + button->setTitleFontName(szTemp); + else + button->setTitleFontName(std::string("")); } setColorPropsForWidgetFromJsonDictionary(widget,options); } @@ -882,7 +886,11 @@ void WidgetPropertiesReader0250::setPropsForLabelFromJsonDictionary(Widget*widge bool fn = DICTOOL->checkObjectExist_json(options, "fontName"); if (fn) { - label->setFontName(DICTOOL->getStringValue_json(options, "fontName")); + const char * szTemp = DICTOOL->getStringValue_json(options, "fontName"); + if (szTemp && *szTemp) + label->setFontName(szTemp); + else + label->setFontName(std::string("")); } bool aw = DICTOOL->checkObjectExist_json(options, "areaWidth"); bool ah = DICTOOL->checkObjectExist_json(options, "areaHeight"); @@ -1105,7 +1113,11 @@ void WidgetPropertiesReader0250::setPropsForTextFieldFromJsonDictionary(Widget*w bool fn = DICTOOL->checkObjectExist_json(options, "fontName"); if (fn) { - textField->setFontName(DICTOOL->getStringValue_json(options, "fontName")); + const char * szTemp = DICTOOL->getStringValue_json(options, "fontName"); + if (szTemp && *szTemp) + textField->setFontName(szTemp); + else + textField->setFontName(std::string("")); } bool tsw = DICTOOL->checkObjectExist_json(options, "touchSizeWidth"); bool tsh = DICTOOL->checkObjectExist_json(options, "touchSizeHeight"); From 93f026f8e6077c922f2d5d978329d77734d33158 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Thu, 20 Aug 2015 11:18:59 +0800 Subject: [PATCH 021/118] Fix https://github.com/cocos2d/cocos2d-x/issues/9488 --- cocos/editor-support/cocostudio/CCBone.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCBone.cpp b/cocos/editor-support/cocostudio/CCBone.cpp index 4b217141b5..a13469cc8e 100644 --- a/cocos/editor-support/cocostudio/CCBone.cpp +++ b/cocos/editor-support/cocostudio/CCBone.cpp @@ -257,13 +257,15 @@ void Bone::setBlendFunc(const BlendFunc& blendFunc) void Bone::updateDisplayedColor(const Color3B &parentColor) { - _realColor = Color3B(255, 255, 255); + // remove comment mark for next line when use in studio +// _realColor = Color3B(255, 255, 255); Node::updateDisplayedColor(parentColor); } void Bone::updateDisplayedOpacity(GLubyte parentOpacity) { - _realOpacity = 255; + // remove comment mark for next line when use in studio +// _realOpacity = 255; Node::updateDisplayedOpacity(parentOpacity); } From aa6f2ec4b60f08314a36925897deb06a534e76c8 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 20 Aug 2015 11:27:01 +0800 Subject: [PATCH 022/118] fix object size error while data is error --- .../WidgetReader/GameMapReader/GameMapReader.cpp | 3 +++ .../cocostudio/WidgetReader/SpriteReader/SpriteReader.cpp | 7 ++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.cpp index 476fa9b59e..f75e4780f5 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.cpp @@ -235,7 +235,10 @@ namespace cocostudio tmx = TMXTiledMap::create(path); if (tmx) { + //Ïȱ£´æ×ÊÔ´µÄ³ß´ç£¬µÈ±à¼­Æ÷µÄÊý¾ÝÉèÖÃÍê³Éºó£¬ÔÙË¢»Ø×ÊÔ´³ß´ç£¬·ÀÖ¹Êý¾ÝÖгߴçºÍ×ÊÔ´²¿Æ¥Åä + Size fileSize = tmx->getContentSize(); setPropsWithFlatBuffers(tmx, (Table*)gameMapOptions); + tmx->setContentSize(fileSize); } } else diff --git a/cocos/editor-support/cocostudio/WidgetReader/SpriteReader/SpriteReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/SpriteReader/SpriteReader.cpp index 830a6a0d9f..269dfe462c 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/SpriteReader/SpriteReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/SpriteReader/SpriteReader.cpp @@ -167,6 +167,8 @@ namespace cocostudio Sprite *sprite = static_cast(node); auto options = (SpriteOptions*)spriteOptions; + auto nodeReader = NodeReader::getInstance(); + nodeReader->setPropsWithFlatBuffers(node, (Table*)(options->nodeOptions())); auto fileNameData = options->fileNameData(); @@ -242,11 +244,6 @@ namespace cocostudio sprite->setBlendFunc(blendFunc); } - - auto nodeReader = NodeReader::getInstance(); - nodeReader->setPropsWithFlatBuffers(node, (Table*)(options->nodeOptions())); - - auto nodeOptions = options->nodeOptions(); GLubyte alpha = (GLubyte)nodeOptions->color()->a(); From ede4651b5e5f2903d69c1845addfb41c4306bcab Mon Sep 17 00:00:00 2001 From: geron-cn Date: Thu, 20 Aug 2015 11:29:52 +0800 Subject: [PATCH 023/118] add blendfunc Frame test case --- .../ActionTimelineTestScene.cpp | 21 +++++++++++++++++- .../ActionTimelineTestScene.h | 7 ++++++ .../ActionTimeline/skeletonBlendFuncFrame.csb | Bin 0 -> 18252 bytes 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/cpp-tests/Resources/ActionTimeline/skeletonBlendFuncFrame.csb diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp index 501a7373dc..1acda7e00d 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp @@ -23,6 +23,7 @@ CocoStudioActionTimelineTests::CocoStudioActionTimelineTests() ADD_TEST_CASE(TestActionTimelineEase); ADD_TEST_CASE(TestActionTimelineSkeleton); ADD_TEST_CASE(TestTimelineExtensionData); + ADD_TEST_CASE(TestActionTimelineBlendFuncFrame); } CocoStudioActionTimelineTests::~CocoStudioActionTimelineTests() @@ -577,4 +578,22 @@ void TestTimelineExtensionData::onEnter() std::string TestTimelineExtensionData::title() const { return "Test Timeline extension data"; -} \ No newline at end of file +} + +// TestActionTimelineBlendFuncFrame +void TestActionTimelineBlendFuncFrame::onEnter() +{ + ActionTimelineBaseTest::onEnter(); + Node* node = CSLoader::createNode("ActionTimeline/skeletonBlendFuncFrame.csb"); + ActionTimeline* action = CSLoader::createTimeline("ActionTimeline/skeletonBlendFuncFrame.csb"); + node->runAction(action); + node->setScale(0.2f); + node->setPosition(VisibleRect::center()); + this->addChild(node); + action->gotoFrameAndPlay(0); +} + +std::string TestActionTimelineBlendFuncFrame::title() const +{ + return "Test ActionTimeline BlendFunc Frame"; +} diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.h b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.h index 7b48a9d1e9..b14e50d6b8 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.h +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.h @@ -139,4 +139,11 @@ public: virtual std::string title() const override; }; +class TestActionTimelineBlendFuncFrame : public ActionTimelineBaseTest +{ +public: + CREATE_FUNC(TestActionTimelineBlendFuncFrame); + virtual void onEnter() override; + virtual std::string title() const override; +}; #endif // __ANIMATION_SCENE_H__ diff --git a/tests/cpp-tests/Resources/ActionTimeline/skeletonBlendFuncFrame.csb b/tests/cpp-tests/Resources/ActionTimeline/skeletonBlendFuncFrame.csb new file mode 100644 index 0000000000000000000000000000000000000000..c0dabdc8bb0d4e1c67398a8f3428f8f8599f9e51 GIT binary patch literal 18252 zcmbVT4Rlr2mA(l}Cyt*mK6!jH zj#P^VYfrGOouI)Vg~Och12tT&cpQ%J{&``ru)L&rW=TOIPOT^q`*q8fd5P$#8)jLQ z9t-l96c_3_SKxg3P|Mmr$g(Oic_#qpV!Fy%>yeX+F<&=wsBc`quJiVJ=FI`1r+K5H zxL0rMjIx({CxPfU>OCvJtbE~vLEBcGIxX#NI1II{nV*Ei8Q_!^4PEGuM?MaRIoAh* z>l_(NZVZ$xE-W8k8eF)f9R0c-_$(aeaTe&7AKh{9w8QgTNx3-xaczqKMe9^1Je979 zNXrVNsUxK;_4a|N(}IO%5&ELr%7$K_tr?mIkEhc<&Y}GHt5*eXjf!hg>k#R-;s2-n zqVotLwHUv`HQe6BzL({Px!&?odqKlo)0{6wE5fxZVSFI-ZdS-fy@e)+L+$jyEdV?Ol!AK%))bx2724R#1 z{}bhtStEjlqb@ZB*@t()$D5o>g9 zlQD-jPCKXkVpY}z7~(u98d|ME#DiTYYro8M-Aj3H}tM*hQvWfR@nRP*6K z$*nHAD}#HGldRdk#Hv&5i2qw;tfs)W-eZ;8B~}wLhp}4zZ2x|{b`=Fk^!o>8Ct3=( z^l#Cz8j)~c`qBDD=_*zO0+y8$5vx?O$ID_M|K77VHtjw3=O!Ji0i}al-#B|i;9}^W z%;ek~TD^E4A4fbGtMjmtezC0UoLC(fecKMNiT>+j{}>=qU&}g;Sgix~t=`;NO|WNs z{~d&n>BsJ3Rf;j{#2QRQ?)boo_3o3*opVsiJAbohUMj{o-<(G~ymOApoWA5m0(?cE zjl!P9cv24KF~4V@?@L~!bjge9m_s=!i$9Bgr{$pliSkceSJ_hiA-WL{6JLTU*1g5T=K;`A#=`Uv2kFB z&Wi*mFD{F|{crnS)TB?hW{{|_W!(my+B3DjTBgclb*A&uhf^mnCfux{4nHmR<&BXZ zT#d25)^G^AQny2}gFg1gsuS_+y@n@siPZ&(x%I$>s3}9s10;mqdT-szmb8a&a%^wx z?@!iAzH25VLQNxq8K_0#j^8fRTcXucKdXRJdsafZ1UHEErU}y8CmXH3B+UkMZ zhnp~mHtzUb$I9o#YLnP~;^WS!RSRbYNYocGg08iWzIGS>^&YFq8tU+B__(JUPQlo> zso|h!USDgtR_64jhL6H8^x2sUk$I7TzTWfV<}P^=FLEY5v&Cw>P!S+8zef*xx~1u* zV2iGa-#+|d+M7EUOI{2?UbIKlaAY+Ah1iaHXK>T(JAUF^hsXY5Qz&Z0KlvBWJ)HTQ z=Rc09;U>(XjR(HadC}q5*Wo77xBs|*?RV$%doxMY7k5C=Dfe6K?U7p7!^b`4#SDz~ zwT4$gSK9Hy#mHENU|a98n%E^)yD%pU^8S6<=l$Xr*M&&DUrT$qqWOiu$Yvd@ghl_6 z_EhF9iPaSNr6Qt+Ct{x2o`L-PUwf-@@!Ord^?vvM@n43l=cf6W4&Br8+%N8GHRmkC z9NPHEB^|5LP7N;-yI0OXZe8`-*Z_(8s``yV+`s8{II@Ow;NzZRby4;eUPo6)_k11B ziRyYyO@_?A#+WwR_FoQ%%dw7kpWXzYP`A+_>d^gtaq@&NLAJ(QGjP@CbDp}=49DCg zYn+v0rJ_f*4EuQkIS;gI%!|pdPFnZK=T)t>W9s}5;QVye8UGv4{?5Bs;yJ^TyqJl+ z_~(F*vkwFPK?};3E~Fi1+YDPCIJP$}qwYy(e^0-+AoI4ISNz2feid3*b1c?%6Pd|pf42QG9y?*=zzSVyGKE}HDV^KbyzC2GD*dsBIetDy!IBL!Fr~D+!x%=(g zLl>6+(%CCE#EwmWyK|yEV;qNHKIl>}{V)g8@xN`om>7c^-}qQQ!g7}JN3QT_G#2z8BHxD>T6Y2LZ{Q-II_17 z*SyHPs@0N{-QAyz#u($pT&@3_dYNa`%RHG!ANWASKs`N2(nj0GSY|e7AM(^k zDq@%FT;nn@g%c-sbMupAYi!Eo^Sb+aO%jH6j^G)+<)>FxAf_43JT_-GAV>OIH)r58 z`tx#U~$IbklE`T1I!l?nhwQ_3_9T6=;N4a9MTkUSSXK`5XJ3o+Qp- z`}`QWnT*CH)@)?{T!C0Cn{=)x;GA{C9LNCS6NOBDpG^BQFs`!09z;E;NRLye_^RK3$F~(&{d46#Lc$~8<47Ro4d<*xUTFT+E=D2J*MXp@??>?74{>kz1K@o4Om8GU6CZ(jxIt-v zV;ZpGZoU?M*MJcGID9tm!)Na)_|SMK3U4YX6`zx*;zF1F9m^VrppL_5=G9l>6Ga%B z13LB(&T1Qsi-IH118Jur6$%e{>shNcoGo%6y?eGJ~Z> z`QS|dTu?HIew_bbYOh%j&d*X&z;=HY&T(iTlUE6@8Js@mnw%draN7iT8XRUi@~RD7 z$fF~1+>8Ce!s3EyON$@GG4(70!QJ*cyO4ZbFXla^7j@A2ei&o4GtNptCJeBBq5VPG zZryX-Y%!Rnt{3{gn;1P`uTl1{>r>V<$7h$6+aGh|yOZTOwf#)LtOON+Qb5#s%@Of2 zbZ7qQ{exrm@B^6R=Usx`11$61i#=jsPYHH7IAzc$8Xx`NYRx!|(FeMpYx-adn6u`1 z!JfvNUR<_;Th`|KK!^4re4dQ0 z2dD3pElR(7Lr#@o%WXOCdTj0@71Iu`L<<=P3ErQ(+EaS1`?q)xUa`ze7!-8!G zmhte)?J%&>e^IujU=E;mJoNV=BV_Cd(z$rmjzo7tXb>L2KInpEpRN?rPj~LSe`~t#5nEu$_Y1ZHT-oDd*BaPj!5##6?NRtD87sHPTp4YKjA+yc?csNl-#Y*Q zD*6AuvTxU#Mne6BwZ^Jq72 zscajL7;;C*`g6b;D~+>oj#J0(X@aYje)@>mJn7E{*K?-|hU>E}LS4~k{4TPmeU{gf z-tPU@om4i}oKQAB9y2jO;yMk+noWY;2Q2s6kxRc5AQ5}az@8Co2e900y>esiJ;C)u z!UswRALekcee;V40wl^!F|dBY&H$Fa^~#-RV2cG?3oM}aUc2O>I|HOD8LP$^_non^ zvjZfqx!I7jL$Ia5>iNVSG;p2R8+1%`{q*)6GUSx9JrQe|dvmhvLtKk3O|aR(s=dtJ zS91;QBEi-G%el-gOZMhfGPV|Dv|aaeojOC#Ho*pMIqrJ<4cz7bb#3o%AMfco>^S6d z-9)TI`yYS)vCJh!_cXIF88X3~dWjcZvcc`xd$73%c8XwYz$ruQ&%|fKnR8`qEx6ck z_uKXxa-I-u(3YdV=O=EzfxCQM+0XYldaB2se2{Qj^8Z8SgN&hnm?HIF3Ql{eoNYhOap=T)zTnn_ zQ+JKaGH_+6OYgcp-8&qWIzEm0_PSx^_i964G;*B!3U#&)c^$~S z*PARla4(?_T!%Cq=U|TQd4j73XPh-I!@%i%yj}XKFR>eCej7OBtLIl5^Y;p_K{#=B z2Idg_LI3g{EymS*KiiX?BgBVuz-cExGo@?`=VbOV_%y*)fYVNm8*Si<1-DQ7X(zF( zq`wiIcIx>>g464472JAojd{kv>_Q#VPQDk?)BYWc@!syIj>|jAXYp<RVB4)3R)`2D;9iGAY?>=eOf0n7U-uiP91yFjp|!18`-z@Yd5iE>vO z*mZ)f0hTfF%55;PO@ciKETHzDqTiu8Dq|-x##rcnu6farbA`Mo+YGE1=d<@1*FQ7y zj=YYE-cx$JpW?gVTr&uL=zq)eS#6~ue~n<*1FQB^cYm)pu)73%7FbGU4rKx%;>TG zGby*ySR+rc>%nQi7h7*&s|0%%98j^J?>xqYHpy5!xUygMbIlGz&LP1z+Hzc6BJ8DH z$9~ig?dLmnJ=J4RK3MQK<>ONLnm&lXp|FKS*(;58)(N%-So*+=Z7{G+f;|T;ptcY6 z`+i4d>?FqM1KrOxFB)>LIIr|;2G)!7!Dh9U-lGj`*hTYw*4FBzqTJ-*{|Ngq})nl zjXc4w2UqsH*m?t7CD^mzuKfzXNygg2mHn=q4nxi%!8Y1*TwJ2;D~|oB58BUnV0G;E z{Zvoa-4`H(^Y??(b}GvA6^3lRk9VM-c57U%fjfnB&d;!GRmGfG{acO{^wVBFpZgz9 zo%|hzan8>Lx0{T`iad_7O-3DfZS~&6@p|q3yzFIQIWPGuHx87|zBU=dq4g&@KB9FL z%t~YJ^Lh@rZj@DT;ErP4)Umhwy-^}N7o71J0HW+zoP#-jnkl%I;EadHB^$V9f;%Yv ztU+SeNdF#i#zW8N{)ba%ogIR!1=pBr0~11B(oVk5+t<9~Z+d7~7PvR>^ghWkw#kCy z-sH`@;W+2G#^niar}WcK0+vaCJ-9dTas;R6Zxmb`xZOl{rGeXu8uZ%g%{$guGpHKm z&A%VY{*{cmwyjuz>mD;?PZwMcaJH?2i?Qq8wY3a5`kC*8sCNX^`ylAD_gLyr`3)kE z{rWcw+ab&LgJ9+vviUndTQ~IU#`Dz%ZU=CtA9~Aey^p72F8x5?QT9ng_VuE}JaGC! z7IgfPlC3C z82bWH3W)18T~hwscTw4#b4z9miDSo%way5(16ba#HlbV}u#`bR?SJe*3n@>=iZDiBy;%8r3yEu17;>rvn+2?%Ph6dWJM_8hGrb@5 zb`O3^WS@g<=7#0D2aka~_HZq>Azv!n6ETOjd$Gv|Hchalz!FK@HU2&sE5I0S*Zo{) zg&}8^U^8qv?mbAYfje-)wVg6!L4COg-vPN?_Z+xwzq~8Wz8J^^bL>AZ*hJ`L+wZ~h zoqsPjUfU1Oe%pS*UoT??;I{o9IV%h~a|N40IUZcCf#YvoxG(Tsb;h2x(c8XoE#}b9 zS>UvtKI8e{4cUId@qK*St#L^>$Eo8V{acPb(odU-eM08%1lO_QIt9l3ErP2C*K4dc zFgsAAw3F}P_Ovf>Zg0>2@8h0?I`Dm4+I~yh_yEba-&k{Cr@{`yoZEr@b$Wb&MC@qj z1LpW(vS2fS+#p=b>J;Pjt?k`_W0@*MbT_+Aq^Y$4YSJ7xivAK0-aC#dCL18^HI#>ii4$wsSwW_4SCTRXMZX2et)*n+2{hSq7#IHADaMw*Y2b zdwNc861g4Vwy!atYt|aF`8x;pCt{5;;5x?p3|u_MiQ~QlX4}aF{?>*4x!|-@&yN)x z$Jk~HZY8+g(8sZ41DA(EudQY-<;Xm@-sq75s3Bb+Dz7Lb7Jpnt{l}r*^n1u!Gu^B7 zNfPzQh*0~L8dJ!DsBHKBe^Xa){ Date: Thu, 20 Aug 2015 13:33:48 +0800 Subject: [PATCH 024/118] Update code, using condition macro to determine studio or user project --- cocos/editor-support/cocostudio/CCBone.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCBone.cpp b/cocos/editor-support/cocostudio/CCBone.cpp index a13469cc8e..45ac09416b 100644 --- a/cocos/editor-support/cocostudio/CCBone.cpp +++ b/cocos/editor-support/cocostudio/CCBone.cpp @@ -257,15 +257,17 @@ void Bone::setBlendFunc(const BlendFunc& blendFunc) void Bone::updateDisplayedColor(const Color3B &parentColor) { - // remove comment mark for next line when use in studio -// _realColor = Color3B(255, 255, 255); +#ifdef CC_STUDIO_ENABLED_VIEW + _realColor = Color3B(255, 255, 255); +#endif // CC_STUDIO_ENABLED_VIEW Node::updateDisplayedColor(parentColor); } void Bone::updateDisplayedOpacity(GLubyte parentOpacity) { - // remove comment mark for next line when use in studio -// _realOpacity = 255; +#ifdef CC_STUDIO_ENABLED_VIEW + _realOpacity = 255; +#endif // CC_STUDIO_ENABLED_VIEW Node::updateDisplayedOpacity(parentOpacity); } From 72496ae42656ec12a10e34c887d1b67b0f48640c Mon Sep 17 00:00:00 2001 From: andyque Date: Wed, 19 Aug 2015 16:38:50 +0800 Subject: [PATCH 025/118] add missing ui test in Lua --- .../script/cocos2d/Cocos2dConstants.lua | 7 + .../lua-bindings/script/ui/GuiConstants.lua | 7 +- .../UIRadioButtonTest/UIRadioButtonTest.cpp | 2 +- .../CocoStudioGUITest/CocoStudioGUITest.lua | 7300 +++++++---------- tools/tolua/cocos2dx_ui.ini | 2 +- 5 files changed, 2998 insertions(+), 4320 deletions(-) diff --git a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua index d4672d201e..bc79cf3f05 100644 --- a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua +++ b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua @@ -619,3 +619,10 @@ cc.AsyncTaskPool.TaskType = TASK_MAX_TYPE = 3, } + +cc.RED = cc.c3b(255,0,0) +cc.GREEN = cc.c3b(0,255,0) +cc.BLUE = cc.c3b(0,0,255) +cc.BLACK = cc.c3b(0,0,0) +cc.WHITE = cc.c3b(255,255,255) +cc.YELLOW = cc.c3b(255,255,0) diff --git a/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua b/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua index 80ae6d2d15..5ee6a22cd2 100644 --- a/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua +++ b/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua @@ -107,7 +107,12 @@ ccui.RelativeAlign = locationBelowRightAlign = 21, } -ccui.SliderEventType = {percentChanged = 0} +ccui.SliderEventType = { + percentChanged = 0, + slideBallDown = 1, + slideBallUp = 2, + slideBallCancel = 3 +} ccui.LoadingBarDirection = { LEFT = 0, RIGHT = 1} diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRadioButtonTest/UIRadioButtonTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRadioButtonTest/UIRadioButtonTest.cpp index 0b2c83d554..f53b803ec4 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRadioButtonTest/UIRadioButtonTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRadioButtonTest/UIRadioButtonTest.cpp @@ -99,7 +99,7 @@ void UIRadioButtonTest::addRadioButton(Ref* sender) } RadioButton* radioButton = RadioButton::create("cocosui/radio_button_off.png", "cocosui/radio_button_on.png"); - pos.x += + BUTTON_WIDTH; + pos.x += BUTTON_WIDTH; radioButton->setPosition(pos); _radioButtonGroup->addRadioButton(radioButton); _uiLayer->addChild(radioButton); diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua index e452ea92d6..ebd6562360 100644 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua +++ b/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua @@ -72,7 +72,7 @@ function UIScene:init() backMenuLabel:setPosition(cc.p(430,30)) backMenuLabel:setTouchEnabled(true) backMenuLabel:addTouchEventListener(menuCloseCallback) - self._uiLayer:addChild(backMenuLabel) + self._uiLayer:addChild(backMenuLabel) end @@ -81,4336 +81,3002 @@ function UIScene.create() local layer = UIScene.extend(cc.Layer:create()) layer:init() scene:addChild(layer) - return scene -end - -local UIButtonTest = class("UIButtonTest",UIScene) -UIButtonTest._displayValueLabel = nil - -function UIButtonTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIButtonTest) - return target -end - -function UIButtonTest:initExtend() - self:init() - - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("No Event") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - self._uiLayer:addChild(self._displayValueLabel) - - local alert = ccui.Text:create() - alert:setString("Button") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function touchEvent(sender,eventType) - if eventType == ccui.TouchEventType.began then - self._displayValueLabel:setString("Touch Down") - elseif eventType == ccui.TouchEventType.moved then - self._displayValueLabel:setString("Touch Move") - elseif eventType == ccui.TouchEventType.ended then - self._displayValueLabel:setString("Touch Up") - elseif eventType == ccui.TouchEventType.canceled then - self._displayValueLabel:setString("Touch Cancelled") - end - end - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - button:addTouchEventListener(touchEvent) - self._uiLayer:addChild(button) -end - -function UIButtonTest.create() - local scene = cc.Scene:create() - local layer = UIButtonTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - - -local UIButtonScale9Test = class("UIButtonScale9Test",UIScene) -UIButtonScale9Test._displayValueLabel = nil - -function UIButtonScale9Test.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIButtonScale9Test) - return target -end - -function UIButtonScale9Test:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("No Event") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - self._uiLayer:addChild(self._displayValueLabel) - - local alert = ccui.Text:create() - alert:setString("Button scale9 render") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function touchEvent(sender,eventType) - if eventType == ccui.TouchEventType.began then - self._displayValueLabel:setString("Touch Down") - elseif eventType == ccui.TouchEventType.moved then - self._displayValueLabel:setString("Touch Move") - elseif eventType == ccui.TouchEventType.ended then - self._displayValueLabel:setString("Touch Up") - elseif eventType == ccui.TouchEventType.canceled then - self._displayValueLabel:setString("Touch Cancelled") - end - end - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:setScale9Enabled(true) - button:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - button:setContentSize(cc.size(150, button:getVirtualRendererSize().height * 1.5)) - button:addTouchEventListener(touchEvent) - self._uiLayer:addChild(button) -end - -function UIButtonScale9Test.create() - local scene = cc.Scene:create() - local layer = UIButtonScale9Test.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIButtonPressedActionTest = class("UIButtonPressedActionTest",UIScene) -UIButtonPressedActionTest._displayValueLabel = nil - -function UIButtonPressedActionTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIButtonPressedActionTest) - return target -end - -function UIButtonPressedActionTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("No Event") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - self._uiLayer:addChild(self._displayValueLabel) - - local alert = ccui.Text:create() - alert:setString("Button Pressed Action") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function touchEvent(sender,eventType) - if eventType == ccui.TouchEventType.began then - self._displayValueLabel:setString("Touch Down") - elseif eventType == ccui.TouchEventType.moved then - self._displayValueLabel:setString("Touch Move") - elseif eventType == ccui.TouchEventType.ended then - self._displayValueLabel:setString("Touch Up") - elseif eventType == ccui.TouchEventType.canceled then - self._displayValueLabel:setString("Touch Cancelled") - end - end - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:setPressedActionEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - button:addTouchEventListener(touchEvent) - self._uiLayer:addChild(button) -end - -function UIButtonPressedActionTest.create() - local scene = cc.Scene:create() - local layer = UIButtonPressedActionTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UITextButtonTest = class("UITextButtonTest",UIScene) -UITextButtonTest._displayValueLabel = nil - -function UITextButtonTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UITextButtonTest) - return target -end - -function UITextButtonTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("No Event") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - self._uiLayer:addChild(self._displayValueLabel) - - local alert = ccui.Text:create() - alert:setString("TextButton") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function touchEvent(sender,eventType) - if eventType == ccui.TouchEventType.began then - self._displayValueLabel:setString("Touch Down") - elseif eventType == ccui.TouchEventType.moved then - self._displayValueLabel:setString("Touch Move") - elseif eventType == ccui.TouchEventType.ended then - self._displayValueLabel:setString("Touch Up") - elseif eventType == ccui.TouchEventType.canceled then - self._displayValueLabel:setString("Touch Cancelled") - end - end - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - textButton:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - textButton:addTouchEventListener(touchEvent) - self._uiLayer:addChild(textButton) -end - -function UITextButtonTest.create() - local scene = cc.Scene:create() - local layer = UITextButtonTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) return scene end -local UITextButtonScale9Test = class("UITextButtonScale9Test",UIScene) -UITextButtonScale9Test._displayValueLabel = nil +local cocoStudioGuiArray = {} -function UITextButtonScale9Test.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UITextButtonScale9Test) - return target -end +local dsl_env = { + create = function(classname, superclass) + local newclass = class(classname, superclass) + newclass._displayValueLabel = nil -function UITextButtonScale9Test:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("No Event") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - self._uiLayer:addChild(self._displayValueLabel) - - local alert = ccui.Text:create() - alert:setString("TextButton scale9 render") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function touchEvent(sender,eventType) - if eventType == ccui.TouchEventType.began then - self._displayValueLabel:setString("Touch Down") - elseif eventType == ccui.TouchEventType.moved then - self._displayValueLabel:setString("Touch Move") - elseif eventType == ccui.TouchEventType.ended then - self._displayValueLabel:setString("Touch Up") - elseif eventType == ccui.TouchEventType.canceled then - self._displayValueLabel:setString("Touch Cancelled") - end - end - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:setScale9Enabled(true) - textButton:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - textButton:setContentSize(cc.size(180, textButton:getVirtualRendererSize().height * 1.5)) - textButton:setTitleText("Text Button scale9 render") - textButton:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - textButton:addTouchEventListener(touchEvent) - self._uiLayer:addChild(textButton) -end - -function UITextButtonScale9Test.create() - local scene = cc.Scene:create() - local layer = UITextButtonScale9Test.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UICheckBoxTest = class("UICheckBoxTest",UIScene) -UICheckBoxTest._displayValueLabel = nil - -function UICheckBoxTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UICheckBoxTest) - return target -end - -function UICheckBoxTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("No Event") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - self._uiLayer:addChild(self._displayValueLabel) - - local alert = ccui.Text:create() - alert:setString("CheckBox") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function selectedEvent(sender,eventType) - if eventType == ccui.CheckBoxEventType.selected then - self._displayValueLabel:setString("Selected") - elseif eventType == ccui.CheckBoxEventType.unselected then - self._displayValueLabel:setString("Unselected") - end - end - - local checkBox = ccui.CheckBox:create() - checkBox:setTouchEnabled(true) - checkBox:setSelectedState(true) - checkBox:loadTextures("cocosui/check_box_normal.png", - "cocosui/check_box_normal_press.png", - "cocosui/check_box_active.png", - "cocosui/check_box_normal_disable.png", - "cocosui/check_box_active_disable.png") - checkBox:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - - checkBox:addEventListener(selectedEvent) - - self._uiLayer:addChild(checkBox) -end - -function UICheckBoxTest.create() - local scene = cc.Scene:create() - local layer = UICheckBoxTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UISliderTest = class("UISliderTest",UIScene) -UISliderTest._displayValueLabel = nil - -function UISliderTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UISliderTest) - return target -end - -function UISliderTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("Move the slider thumb") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - self._uiLayer:addChild(self._displayValueLabel) - - local alert = ccui.Text:create() - alert:setString("Slider") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function percentChangedEvent(sender,eventType) - if eventType == ccui.SliderEventType.percentChanged then - local slider = sender - local percent = "Percent " .. slider:getPercent() - self._displayValueLabel:setString(percent) - end - end - - local slider = ccui.Slider:create() - slider:setTouchEnabled(true) - slider:loadBarTexture("cocosui/sliderTrack.png") - slider:loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "") - slider:loadProgressBarTexture("cocosui/sliderProgress.png") - slider:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - slider:addEventListener(percentChangedEvent) - - self._uiLayer:addChild(slider) -end - -function UISliderTest.create() - local scene = cc.Scene:create() - local layer = UISliderTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UISliderScale9Test = class("UISliderScale9Test",UIScene) -UISliderScale9Test._displayValueLabel = nil - -function UISliderScale9Test.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UISliderScale9Test) - return target -end - -function UISliderScale9Test:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("Move the slider thumb") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - self._uiLayer:addChild(self._displayValueLabel) - - local alert = ccui.Text:create() - alert:setString("Slider scale9 render") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function percentChangedEvent(sender,eventType) - if eventType == ccui.SliderEventType.percentChanged then - local slider = sender - local percent = "Percent " .. slider:getPercent() - self._displayValueLabel:setString(percent) - end - end - - local slider = ccui.Slider:create() - slider:setTouchEnabled(true) - slider:loadBarTexture("cocosui/sliderTrack2.png") - slider:loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "") - slider:loadProgressBarTexture("cocosui/slider_bar_active_9patch.png") - slider:setScale9Enabled(true) - slider:setCapInsets(cc.rect(0, 0, 0, 0)) - slider:setContentSize(cc.size(250, 10)) - slider:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - slider:addEventListener(percentChangedEvent) - - self._uiLayer:addChild(slider) -end - -function UISliderScale9Test.create() - local scene = cc.Scene:create() - local layer = UISliderScale9Test.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIImageViewTest = class("UIImageViewTest",UIScene) - -function UIImageViewTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIImageViewTest) - return target -end - -function UIImageViewTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("ImageView") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local imageView = ccui.ImageView:create() - imageView:loadTexture("cocosui/ccicon.png") - imageView:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + imageView:getContentSize().height / 4.0)) - self._uiLayer:addChild(imageView) -end - -function UIImageViewTest.create() - local scene = cc.Scene:create() - local layer = UIImageViewTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - - -local UIImageViewScale9Test = class("UIImageViewScale9Test",UIScene) - -function UIImageViewScale9Test.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIImageViewScale9Test) - return target -end - -function UIImageViewScale9Test:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("ImageView scale9 render") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local imageView = ccui.ImageView:create() - imageView:setScale9Enabled(true) - imageView:loadTexture("cocosui/buttonHighlighted.png") - imageView:setContentSize(cc.size(200, 85)) - imageView:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + imageView:getContentSize().height / 4.0)) - self._uiLayer:addChild(imageView) -end - -function UIImageViewScale9Test.create() - local scene = cc.Scene:create() - local layer = UIImageViewScale9Test.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UILoadingBarLeftTest = class("UILoadingBarLeftTest",UIScene) -UILoadingBarLeftTest._count = 0 - -function UILoadingBarLeftTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UILoadingBarLeftTest) - return target -end - -function UILoadingBarLeftTest:initExtend() - - self._uiLayer = cc.Layer:create() - self:addChild(self._uiLayer) - - self._widget = ccs.GUIReader:getInstance():widgetFromJsonFile("cocosui/UITest/UITest.json") - self._uiLayer:addChild(self._widget) - - local root = self._uiLayer:getChildByTag(81) - self._sceneTitle = root:getChildByName("UItest") - - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("LoadingBar") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local loadingBar = ccui.LoadingBar:create() - loadingBar:setTag(0) - loadingBar:setName("LoadingBar") - loadingBar:loadTexture("cocosui/sliderProgress.png") - loadingBar:setPercent(0) - - loadingBar:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + loadingBar:getContentSize().height / 4.0)) - self._uiLayer:addChild(loadingBar) - - local function update(delta) - self._count = self._count + 1 - if self._count > 100 then - self._count = 0 - end - - if self._uiLayer ~= nil then - local loadingBar = self._uiLayer:getChildByTag(0) - loadingBar:setPercent(self._count) - end - end - - self:scheduleUpdateWithPriorityLua(update, 0) - - local function onNodeEvent(tag) - if tag == "exit" then - self:unscheduleUpdate() - end - end - - self:registerScriptHandler(onNodeEvent) - - local function previousCallback(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self:unscheduleUpdate() - cc.Director:getInstance():replaceScene(guiSceneManager.previousUIScene()) - end - end - - local left_button = root:getChildByName("left_Button") - left_button:addTouchEventListener(previousCallback) - - local function restartCallback(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self:unscheduleUpdate() - cc.Director:getInstance():replaceScene(guiSceneManager.currentUIScene()) - end - end - - local middle_button = root:getChildByName("middle_Button") - middle_button:addTouchEventListener(restartCallback) - - local function nextCallback(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self:unscheduleUpdate() - cc.Director:getInstance():replaceScene(guiSceneManager.nextUIScene()) - end - end - - local right_button = root:getChildByName("right_Button") - right_button:addTouchEventListener(nextCallback) - - local function menuCloseCallback( sender,eventType) - if eventType == ccui.TouchEventType.ended then - self:unscheduleUpdate() - local scene = CocoStudioTestMain() - if scene ~= nil then - cc.Director:getInstance():replaceScene(scene) + function newclass.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) end - end - end - - local mainMenuLabel = ccui.Text:create() - mainMenuLabel:setString("Back") - mainMenuLabel:setFontSize(20) - mainMenuLabel:setTouchScaleChangeEnabled(true) - mainMenuLabel:setPosition(cc.p(430,30)) - mainMenuLabel:setTouchEnabled(true) - mainMenuLabel:addTouchEventListener(menuCloseCallback) - self._uiLayer:addChild(mainMenuLabel) -end - -function UILoadingBarLeftTest.create() - local scene = cc.Scene:create() - local layer = UILoadingBarLeftTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UILoadingBarRightTest = class("UILoadingBarRightTest",UIScene) -UILoadingBarRightTest._count = 0 - -function UILoadingBarRightTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UILoadingBarRightTest) - return target -end - -function UILoadingBarRightTest:initExtend() - - self._uiLayer = cc.Layer:create() - self:addChild(self._uiLayer) - - self._widget = ccs.GUIReader:getInstance():widgetFromJsonFile("cocosui/UITest/UITest.json") - self._uiLayer:addChild(self._widget) - - local root = self._uiLayer:getChildByTag(81) - self._sceneTitle = root:getChildByName("UItest") - - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("LoadingBar") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local loadingBar = ccui.LoadingBar:create() - loadingBar:setTag(0) - loadingBar:setName("LoadingBar") - loadingBar:loadTexture("cocosui/sliderProgress.png") - loadingBar:setDirection(ccui.LoadingBarDirection.RIGHT) - loadingBar:setPercent(0) - - loadingBar:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + loadingBar:getContentSize().height / 4.0)) - self._uiLayer:addChild(loadingBar) - - local function update(delta) - self._count = self._count + 1 - if self._count > 100 then - self._count = 0 + setmetatable(t, newclass) + return target end - if self._uiLayer ~= nil then - local loadingBar = self._uiLayer:getChildByTag(0) - loadingBar:setPercent(self._count) - end - end - - self:scheduleUpdateWithPriorityLua(update, 0) - - local function onNodeEvent(tag) - if tag == "exit" then - self:unscheduleUpdate() - end - end - - self:registerScriptHandler(onNodeEvent) - - local function previousCallback(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self:unscheduleUpdate() - cc.Director:getInstance():replaceScene(guiSceneManager.previousUIScene()) - end - end - - local left_button = root:getChildByName("left_Button") - left_button:addTouchEventListener(previousCallback) - - local function restartCallback(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self:unscheduleUpdate() - cc.Director:getInstance():replaceScene(guiSceneManager.currentUIScene()) - end - end - - local middle_button = root:getChildByName("middle_Button") - middle_button:addTouchEventListener(restartCallback) - - local function nextCallback(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self:unscheduleUpdate() - cc.Director:getInstance():replaceScene(guiSceneManager.nextUIScene()) - end - end - - local right_button = root:getChildByName("right_Button") - right_button:addTouchEventListener(nextCallback) - - local function menuCloseCallback( sender,eventType) - if eventType == ccui.TouchEventType.ended then - self:unscheduleUpdate() - local scene = CocoStudioTestMain() - if scene ~= nil then - cc.Director:getInstance():replaceScene(scene) - end - end - end - - local mainMenuLabel = ccui.Text:create() - mainMenuLabel:setString("Back") - mainMenuLabel:setFontSize(20) - mainMenuLabel:setTouchScaleChangeEnabled(true) - mainMenuLabel:setPosition(cc.p(430,30)) - mainMenuLabel:setTouchEnabled(true) - mainMenuLabel:addTouchEventListener(menuCloseCallback) - self._uiLayer:addChild(mainMenuLabel) -end - -function UILoadingBarRightTest.create() - local scene = cc.Scene:create() - local layer = UILoadingBarRightTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UILoadingBarLeftScale9Test = class("UILoadingBarLeftScale9Test",UIScene) -UILoadingBarLeftScale9Test._count = 0 - -function UILoadingBarLeftScale9Test.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UILoadingBarLeftScale9Test) - return target -end - -function UILoadingBarLeftScale9Test:initExtend() - - self._uiLayer = cc.Layer:create() - self:addChild(self._uiLayer) - - self._widget = ccs.GUIReader:getInstance():widgetFromJsonFile("cocosui/UITest/UITest.json") - self._uiLayer:addChild(self._widget) - - local root = self._uiLayer:getChildByTag(81) - self._sceneTitle = root:getChildByName("UItest") - - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("LoadingBar Scale9 Render") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local loadingBar = ccui.LoadingBar:create() - loadingBar:setTag(0) - loadingBar:setName("LoadingBar") - loadingBar:loadTexture("cocosui/slider_bar_active_9patch.png") - loadingBar:setScale9Enabled(true) - loadingBar:setCapInsets(cc.rect(0, 0, 0, 0)) - loadingBar:setContentSize(cc.size(300, 30)) - loadingBar:setPercent(0) - - loadingBar:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + loadingBar:getContentSize().height / 4.0)) - self._uiLayer:addChild(loadingBar) - - local function update(delta) - self._count = self._count + 1 - if self._count > 100 then - self._count = 0 + function newclass:initLabel() + self:init() + local widgetSize = self._widget:getContentSize() + self._displayValueLabel = ccui.Text:create() + self._displayValueLabel:setString(classname) + self._displayValueLabel:setFontName(font_TextName) + self._displayValueLabel:setFontSize(32) + self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) + self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getContentSize().height * 1.8)) + self._uiLayer:addChild(self._displayValueLabel) end - if self._uiLayer ~= nil then - local loadingBar = self._uiLayer:getChildByTag(0) - loadingBar:setPercent(self._count) - end - end - - self:scheduleUpdateWithPriorityLua(update, 0) - - local function onNodeEvent(tag) - if tag == "exit" then - self:unscheduleUpdate() - end - end - - self:registerScriptHandler(onNodeEvent) - - local function previousCallback(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self:unscheduleUpdate() - cc.Director:getInstance():replaceScene(guiSceneManager.previousUIScene()) - end - end - - local left_button = root:getChildByName("left_Button") - left_button:addTouchEventListener(previousCallback) - - local function restartCallback(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self:unscheduleUpdate() - cc.Director:getInstance():replaceScene(guiSceneManager.currentUIScene()) - end - end - - local middle_button = root:getChildByName("middle_Button") - middle_button:addTouchEventListener(restartCallback) - - local function nextCallback(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self:unscheduleUpdate() - cc.Director:getInstance():replaceScene(guiSceneManager.nextUIScene()) - end - end - - local right_button = root:getChildByName("right_Button") - right_button:addTouchEventListener(nextCallback) - - local function menuCloseCallback( sender,eventType) - if eventType == ccui.TouchEventType.ended then - self:unscheduleUpdate() - local scene = CocoStudioTestMain() - if scene ~= nil then - cc.Director:getInstance():replaceScene(scene) - end - end - end - - local mainMenuLabel = ccui.Text:create() - mainMenuLabel:setString("Back") - mainMenuLabel:setFontSize(20) - mainMenuLabel:setTouchScaleChangeEnabled(true) - mainMenuLabel:setPosition(cc.p(430,30)) - mainMenuLabel:setTouchEnabled(true) - mainMenuLabel:addTouchEventListener(menuCloseCallback) - self._uiLayer:addChild(mainMenuLabel) -end - -function UILoadingBarLeftScale9Test.create() - local scene = cc.Scene:create() - local layer = UILoadingBarLeftScale9Test.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UILoadingBarRightScale9Test = class("UILoadingBarRightScale9Test",UIScene) -UILoadingBarRightScale9Test._count = 0 - -function UILoadingBarRightScale9Test.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UILoadingBarRightScale9Test) - return target -end - -function UILoadingBarRightScale9Test:initExtend() - - self._uiLayer = cc.Layer:create() - self:addChild(self._uiLayer) - - self._widget = ccs.GUIReader:getInstance():widgetFromJsonFile("cocosui/UITest/UITest.json") - self._uiLayer:addChild(self._widget) - - local root = self._uiLayer:getChildByTag(81) - self._sceneTitle = root:getChildByName("UItest") - - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("LoadingBar Scale9 Render") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local loadingBar = ccui.LoadingBar:create() - loadingBar:setTag(0) - loadingBar:setName("LoadingBar") - loadingBar:loadTexture("cocosui/slider_bar_active_9patch.png") - loadingBar:setScale9Enabled(true) - loadingBar:setCapInsets(cc.rect(0, 0, 0, 0)) - loadingBar:setContentSize(cc.size(300, 30)) - loadingBar:setDirection(ccui.LoadingBarDirection.RIGHT) - loadingBar:setPercent(0) - - loadingBar:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + loadingBar:getContentSize().height / 4.0)) - self._uiLayer:addChild(loadingBar) - - local function update(delta) - self._count = self._count + 1 - if self._count > 100 then - self._count = 0 + function newclass.create() + local scene = cc.Scene:create() + local layer = newclass.extend(cc.Layer:create()) + layer:initLabel() + layer:initExtend() + scene:addChild(layer) + return scene end - if self._uiLayer ~= nil then - local loadingBar = self._uiLayer:getChildByTag(0) - loadingBar:setPercent(self._count) - end - end - - self:scheduleUpdateWithPriorityLua(update, 0) - - local function onNodeEvent(tag) - if tag == "exit" then - self:unscheduleUpdate() - end - end - - self:registerScriptHandler(onNodeEvent) - - local function previousCallback(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self:unscheduleUpdate() - cc.Director:getInstance():replaceScene(guiSceneManager.previousUIScene()) - end - end - - local left_button = root:getChildByName("left_Button") - left_button:addTouchEventListener(previousCallback) - - local function restartCallback(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self:unscheduleUpdate() - cc.Director:getInstance():replaceScene(guiSceneManager.currentUIScene()) - end - end - - local middle_button = root:getChildByName("middle_Button") - middle_button:addTouchEventListener(restartCallback) - - local function nextCallback(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self:unscheduleUpdate() - cc.Director:getInstance():replaceScene(guiSceneManager.nextUIScene()) - end - end - - local right_button = root:getChildByName("right_Button") - right_button:addTouchEventListener(nextCallback) - - local function menuCloseCallback( sender,eventType) - if eventType == ccui.TouchEventType.ended then - self:unscheduleUpdate() - local scene = CocoStudioTestMain() - if scene ~= nil then - cc.Director:getInstance():replaceScene(scene) - end - end - end - - local mainMenuLabel = ccui.Text:create() - mainMenuLabel:setString("Back") - mainMenuLabel:setFontSize(20) - mainMenuLabel:setTouchScaleChangeEnabled(true) - mainMenuLabel:setPosition(cc.p(430,30)) - mainMenuLabel:setTouchEnabled(true) - mainMenuLabel:addTouchEventListener(menuCloseCallback) - self._uiLayer:addChild(mainMenuLabel) -end - -function UILoadingBarRightScale9Test.create() - local scene = cc.Scene:create() - local layer = UILoadingBarRightScale9Test.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UILabelAtlasTest = class("UILabelAtlasTest",UIScene) - -function UILabelAtlasTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UILabelAtlasTest) - return target -end - -function UILabelAtlasTest:initExtend() - - self:init() - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("LabelAtlas") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - - local labelAtlas = ccui.TextAtlas:create() - if cc.Director:getInstance():getWinSizeInPixels().height > 320 then - labelAtlas:setProperty("1234567890", "cocosui/labelatlas.png", 34, 44, "0") - else - labelAtlas:setProperty("1234567890", "cocosui/labelatlas.png", 17, 22, "0") - end - - labelAtlas:setPosition(cc.p((widgetSize.width) / 2, widgetSize.height / 2.0)) - - self._uiLayer:addChild(labelAtlas) -end - -function UILabelAtlasTest.create() - local scene = cc.Scene:create() - local layer = UILabelAtlasTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UILabelBMFontTest = class("UILabelBMFontTest",UIScene) - -function UILabelBMFontTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UILabelBMFontTest) - return target -end - -function UILabelBMFontTest:initExtend() - - self:init() - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("LabelBMFont") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - - local labelBMFont = ccui.TextBMFont:create() - labelBMFont:setFntFile("cocosui/bitmapFontTest2.fnt") - labelBMFont:setString("BMFont") - labelBMFont:setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2.0 + labelBMFont:getContentSize().height / 8.0)) - - self._uiLayer:addChild(labelBMFont) -end - -function UILabelBMFontTest.create() - local scene = cc.Scene:create() - local layer = UILabelBMFontTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UILabelTest = class("UILabelTest",UIScene) - -function UILabelTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UILabelTest) - return target -end - -function UILabelTest:initExtend() - - self:init() - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("Label") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local label = ccui.Text:create() - label:setString("Label") - label:setFontName("AmericanTypewriter") - label:setFontSize(30) - label:setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 + label:getContentSize().height / 4)) - self._uiLayer:addChild(label) -end - -function UILabelTest.create() - local scene = cc.Scene:create() - local layer = UILabelTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UITextAreaTest = class("UITextAreaTest",UIScene) - -function UITextAreaTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UITextAreaTest) - return target -end - -function UITextAreaTest:initExtend() - - self:init() - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("TextArea") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local textArea = ccui.Text:create() - textArea:ignoreContentAdaptWithSize(false) - textArea:setContentSize(cc.size(280, 150)) - textArea:setTextHorizontalAlignment(cc.TEXT_ALIGNMENT_CENTER) - textArea:setString("TextArea widget can line wrap") - textArea:setFontName("AmericanTypewriter") - textArea:setFontSize(32) - textArea:setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 - textArea:getContentSize().height / 8)) - self._uiLayer:addChild(textArea) -end - -function UITextAreaTest.create() - local scene = cc.Scene:create() - local layer = UITextAreaTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UITextFieldTest = class("UITextFieldTest",UIScene) -UITextFieldTest._displayValueLabel = nil - -function UITextFieldTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UITextFieldTest) - return target -end - -function UITextFieldTest:initExtend() - - self:init() - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("No Event") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getContentSize().height * 1.5)) - self._uiLayer:addChild(self._displayValueLabel) - - local alert = ccui.Text:create() - alert:setString("TextField") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function textFieldEvent(sender, eventType) - if eventType == ccui.TextFiledEventType.attach_with_ime then - local textField = sender - local screenSize = cc.Director:getInstance():getWinSize() - textField:runAction(cc.MoveBy:create(0.225,cc.p(0, 20))) - self._displayValueLabel:setString("attach with IME") - elseif eventType == ccui.TextFiledEventType.detach_with_ime then - local textField = sender - local screenSize = cc.Director:getInstance():getWinSize() - textField:runAction(cc.MoveBy:create(0.175, cc.p(0, -20))) - self._displayValueLabel:setString("detach with IME") - elseif eventType == ccui.TextFiledEventType.insert_text then - self._displayValueLabel:setString("insert words") - elseif eventType == ccui.TextFiledEventType.delete_backward then - self._displayValueLabel:setString("delete word") - end - end - - local textField = ccui.TextField:create() - textField:setTouchEnabled(true) - textField:setFontName(font_TextName) - textField:setFontSize(30) - textField:setPlaceHolder("input words here") - textField:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - textField:addEventListener(textFieldEvent) - self._uiLayer:addChild(textField) -end - -function UITextFieldTest.create() - local scene = cc.Scene:create() - local layer = UITextFieldTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UITextFieldMaxLengthTest = class("UITextFieldMaxLengthTest",UIScene) -UITextFieldMaxLengthTest._displayValueLabel = nil - -function UITextFieldMaxLengthTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UITextFieldMaxLengthTest) - return target -end - -function UITextFieldMaxLengthTest:initExtend() - - self:init() - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("No Event") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getContentSize().height * 1.5)) - self._uiLayer:addChild(self._displayValueLabel) - - local alert = ccui.Text:create() - alert:setString("TextField max length") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function textFieldEvent(sender, eventType) - if eventType == ccui.TextFiledEventType.attach_with_ime then - local textField = sender - local screenSize = cc.Director:getInstance():getWinSize() - textField:runAction(cc.MoveBy:create(0.225,cc.p(0, 20))) - local info = string.format("attach with IME max length %d",textField:getMaxLength()) - self._displayValueLabel:setString(info) - elseif eventType == ccui.TextFiledEventType.detach_with_ime then - local textField = sender - local screenSize = cc.Director:getInstance():getWinSize() - textField:runAction(cc.MoveBy:create(0.175, cc.p(0, -20))) - local info = string.format("detach with IME max length %d",textField:getMaxLength()) - self._displayValueLabel:setString(info) - elseif eventType == ccui.TextFiledEventType.insert_text then - local textField = sender - local info = string.format("insert words max length %d",textField:getMaxLength()) - self._displayValueLabel:setString(info) - elseif eventType == ccui.TextFiledEventType.delete_backward then - local textField = sender - local info = string.format("delete word max length %d",textField:getMaxLength()) - self._displayValueLabel:setString(info) - end - end - - local textField = ccui.TextField:create() - textField:setMaxLengthEnabled(true) - textField:setMaxLength(3) - textField:setTouchEnabled(true) - textField:setFontName(font_TextName) - textField:setFontSize(30) - textField:setPlaceHolder("input words here") - textField:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - textField:addEventListener(textFieldEvent) - self._uiLayer:addChild(textField) -end - -function UITextFieldMaxLengthTest.create() - local scene = cc.Scene:create() - local layer = UITextFieldMaxLengthTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UITextFieldPasswordTest = class("UITextFieldPasswordTest",UIScene) -UITextFieldPasswordTest._displayValueLabel = nil - -function UITextFieldPasswordTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UITextFieldPasswordTest) - return target -end - -function UITextFieldPasswordTest:initExtend() - - self:init() - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("No Event") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getContentSize().height * 1.5)) - self._uiLayer:addChild(self._displayValueLabel) - - local alert = ccui.Text:create() - alert:setString("TextField password") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local function textFieldEvent(sender, eventType) - if eventType == ccui.TextFiledEventType.attach_with_ime then - local textField = sender - local screenSize = cc.Director:getInstance():getWinSize() - textField:runAction(cc.MoveBy:create(0.175, cc.p(0, 20))) - self._displayValueLabel:setString("detach with IME password") - elseif eventType == ccui.TextFiledEventType.detach_with_ime then - local textField = sender - local screenSize = cc.Director:getInstance():getWinSize() - textField:runAction(cc.MoveBy:create(0.175, cc.p(0, -20))) - self._displayValueLabel:setString("detach with IME password") - elseif eventType == ccui.TextFiledEventType.insert_text then - self._displayValueLabel:setString("insert words password") - elseif eventType == ccui.TextFiledEventType.delete_backward then - self._displayValueLabel:setString("delete word password") - end - end - - local textField = ccui.TextField:create() - textField:setPasswordEnabled(true) - textField:setPasswordStyleText("*") - textField:setTouchEnabled(true) - textField:setFontName(font_TextName) - textField:setFontSize(30) - textField:setPlaceHolder("input password here") - textField:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - textField:addEventListener(textFieldEvent) - self._uiLayer:addChild(textField) -end - -function UITextFieldPasswordTest.create() - local scene = cc.Scene:create() - local layer = UITextFieldPasswordTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIPanelTest = class("UIPanelTest",UIScene) - -function UIPanelTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIPanelTest) - return target -end - -function UIPanelTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("Panel") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - - local layout = ccui.Layout:create() - layout:setContentSize(cc.size(280, 150)) - local backgroundSize = background:getContentSize() - layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - layout:getContentSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - layout:getContentSize().height) / 2)) - self._uiLayer:addChild(layout) - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - button:setPosition(cc.p(button:getContentSize().width / 2, layout:getContentSize().height - button:getContentSize().height / 2)) - layout:addChild(button) - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - textButton:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) - layout:addChild(textButton) - - local button_scale9 = ccui.Button:create() - button_scale9:setTouchEnabled(true) - button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - button_scale9:setScale9Enabled(true) - button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) - button_scale9:setPosition(cc.p(layout:getContentSize().width - button_scale9:getContentSize().width / 2, button_scale9:getContentSize().height / 2)) - layout:addChild(button_scale9) -end - -function UIPanelTest.create() - local scene = cc.Scene:create() - local layer = UIPanelTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIPanelColorTest = class("UIPanelColorTest",UIScene) - -function UIPanelColorTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIPanelColorTest) - return target -end - -function UIPanelColorTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("Panel color render") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - - local layout = ccui.Layout:create() - layout:setBackGroundColorType(ccui.LayoutBackGroundColorType.solid) - layout:setBackGroundColor(cc.c3b(128, 128, 128)) - layout:setContentSize(cc.size(280, 150)) - local backgroundSize = background:getContentSize() - layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - layout:getContentSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - layout:getContentSize().height) / 2)) - self._uiLayer:addChild(layout) - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - button:setPosition(cc.p(button:getContentSize().width / 2, layout:getContentSize().height - button:getContentSize().height / 2)) - layout:addChild(button) - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - textButton:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) - layout:addChild(textButton) - - local button_scale9 = ccui.Button:create() - button_scale9:setTouchEnabled(true) - button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - button_scale9:setScale9Enabled(true) - button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) - button_scale9:setPosition(cc.p(layout:getContentSize().width - button_scale9:getContentSize().width / 2, button_scale9:getContentSize().height / 2)) - layout:addChild(button_scale9) -end - -function UIPanelColorTest.create() - local scene = cc.Scene:create() - local layer = UIPanelColorTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIPanelGradientTest = class("UIPanelGradientTest",UIScene) - -function UIPanelGradientTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIPanelGradientTest) - return target -end - -function UIPanelGradientTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("Panel color Gradient") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - - local layout = ccui.Layout:create() - layout:setBackGroundColorType(ccui.LayoutBackGroundColorType.gradient) - layout:setBackGroundColor(cc.c3b(64, 64, 64), cc.c3b(192, 192, 192)) - layout:setContentSize(cc.size(280, 150)) - local backgroundSize = background:getContentSize() - layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - layout:getContentSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - layout:getContentSize().height) / 2)) - self._uiLayer:addChild(layout) - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - button:setPosition(cc.p(button:getContentSize().width / 2, layout:getContentSize().height - button:getContentSize().height / 2)) - layout:addChild(button) - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - textButton:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) - layout:addChild(textButton) - - local button_scale9 = ccui.Button:create() - button_scale9:setTouchEnabled(true) - button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - button_scale9:setScale9Enabled(true) - button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) - button_scale9:setPosition(cc.p(layout:getContentSize().width - button_scale9:getContentSize().width / 2, button_scale9:getContentSize().height / 2)) - layout:addChild(button_scale9) -end - -function UIPanelGradientTest.create() - local scene = cc.Scene:create() - local layer = UIPanelGradientTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIPanelBackGroundImageTest = class("UIPanelBackGroundImageTest",UIScene) - -function UIPanelBackGroundImageTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIPanelBackGroundImageTest) - return target -end - -function UIPanelBackGroundImageTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("Panel background image") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - - local layout = ccui.Layout:create() - layout:setClippingEnabled(true) - layout:setBackGroundImage("cocosui/Hello.png") - layout:setContentSize(cc.size(280, 150)) - local backgroundSize = background:getContentSize() - layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - layout:getContentSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - layout:getContentSize().height) / 2)) - self._uiLayer:addChild(layout) - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - button:setPosition(cc.p(button:getContentSize().width / 2, layout:getContentSize().height - button:getContentSize().height / 2)) - layout:addChild(button) - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - textButton:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) - layout:addChild(textButton) - - local button_scale9 = ccui.Button:create() - button_scale9:setTouchEnabled(true) - button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - button_scale9:setScale9Enabled(true) - button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) - button_scale9:setPosition(cc.p(layout:getContentSize().width - button_scale9:getContentSize().width / 2, button_scale9:getContentSize().height / 2)) - layout:addChild(button_scale9) -end - -function UIPanelBackGroundImageTest.create() - local scene = cc.Scene:create() - local layer = UIPanelBackGroundImageTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIPanelBackGroundImageScale9Test = class("UIPanelBackGroundImageScale9Test",UIScene) - -function UIPanelBackGroundImageScale9Test.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIPanelBackGroundImageScale9Test) - return target -end - -function UIPanelBackGroundImageScale9Test:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("Panel background image scale9") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - - local layout = ccui.Layout:create() - layout:setBackGroundImageScale9Enabled(true) - layout:setBackGroundImage("cocosui/green_edit.png") - layout:setContentSize(cc.size(280, 150)) - local backgroundSize = background:getContentSize() - layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - layout:getContentSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - layout:getContentSize().height) / 2)) - self._uiLayer:addChild(layout) - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - button:setPosition(cc.p(button:getContentSize().width / 2, layout:getContentSize().height - button:getContentSize().height / 2)) - layout:addChild(button) - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - textButton:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) - layout:addChild(textButton) - - local button_scale9 = ccui.Button:create() - button_scale9:setTouchEnabled(true) - button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - button_scale9:setScale9Enabled(true) - button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) - button_scale9:setPosition(cc.p(layout:getContentSize().width - button_scale9:getContentSize().width / 2, button_scale9:getContentSize().height / 2)) - layout:addChild(button_scale9) -end - -function UIPanelBackGroundImageScale9Test.create() - local scene = cc.Scene:create() - local layer = UIPanelBackGroundImageScale9Test.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIPanelLayoutLinearVerticalTest = class("UIPanelLayoutLinearVerticalTest",UIScene) - -function UIPanelLayoutLinearVerticalTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIPanelLayoutLinearVerticalTest) - return target -end - -function UIPanelLayoutLinearVerticalTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("Panel Layout Linear Vertical") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - - local layout = ccui.Layout:create() - layout:setLayoutType(ccui.LayoutType.VERTICAL) - layout:setContentSize(cc.size(280, 150)) - local backgroundSize = background:getContentSize() - layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - layout:getContentSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - layout:getContentSize().height) / 2)) - self._uiLayer:addChild(layout) - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - layout:addChild(button) - - local lp1 = ccui.LinearLayoutParameter:create() - button:setLayoutParameter(lp1) - lp1:setGravity(ccui.LinearGravity.centerHorizontal) - lp1:setMargin({ left = 0, top = 5, right = 0, bottom = 10 }) - - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - layout:addChild(textButton) - - local lp2 = ccui.LinearLayoutParameter:create() - textButton:setLayoutParameter(lp2) - lp2:setGravity(ccui.LinearGravity.centerHorizontal) - lp2:setMargin({left = 0, top = 10, right = 0, bottom = 10} ) - - - local button_scale9 = ccui.Button:create() - button_scale9:setTouchEnabled(true) - button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - button_scale9:setScale9Enabled(true) - button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) - layout:addChild(button_scale9) - - local lp3 = ccui.LinearLayoutParameter:create() - button_scale9:setLayoutParameter(lp3) - lp3:setGravity(ccui.LinearGravity.centerHorizontal) - lp3:setMargin({ left = 0, top = 10, right = 0, bottom = 10 } ) -end - -function UIPanelLayoutLinearVerticalTest.create() - local scene = cc.Scene:create() - local layer = UIPanelLayoutLinearVerticalTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIPanelLayoutLinearHorizontalTest = class("UIPanelLayoutLinearHorizontalTest",UIScene) - -function UIPanelLayoutLinearHorizontalTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIPanelLayoutLinearHorizontalTest) - return target -end - -function UIPanelLayoutLinearHorizontalTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create() - alert:setString("Panel Layout Linear Horizontal") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - - local layout = ccui.Layout:create() - layout:setLayoutType(ccui.LayoutType.HORIZONTAL) - layout:setClippingEnabled(true) - layout:setContentSize(cc.size(280, 150)) - local backgroundSize = background:getContentSize() - layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - layout:getContentSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - layout:getContentSize().height) / 2)) - self._uiLayer:addChild(layout) - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - layout:addChild(button) - - local lp1 = ccui.LinearLayoutParameter:create() - button:setLayoutParameter(lp1) - lp1:setGravity(ccui.LinearGravity.centerVertical) - lp1:setMargin({left = 0, top = 10, right = 0, bottom = 10} ) - - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - layout:addChild(textButton) - - local lp2 = ccui.LinearLayoutParameter:create() - textButton:setLayoutParameter(lp2) - lp2:setGravity(ccui.LinearGravity.centerVertical) - lp2:setMargin({left = 0,top = 10,right = 0,bottom = 10}) - - - local button_scale9 = ccui.Button:create() - button_scale9:setTouchEnabled(true) - button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - button_scale9:setScale9Enabled(true) - button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) - layout:addChild(button_scale9) - - local lp3 = ccui.LinearLayoutParameter:create() - button_scale9:setLayoutParameter(lp3) - lp3:setGravity(ccui.LinearGravity.centerVertical) - lp3:setMargin({left = 0, top = 10, right = 0, bottom = 10}) -end - -function UIPanelLayoutLinearHorizontalTest.create() - local scene = cc.Scene:create() - local layer = UIPanelLayoutLinearHorizontalTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UILayoutComponentBerthTest = class("UILayoutComponentBerthTest",UIScene) -UILayoutComponentBerthTest._displayValueLabel = nil - -function UILayoutComponentBerthTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UILayoutComponentBerthTest) - return target -end - -function UILayoutComponentBerthTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("LayoutComponent Berth Test") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getContentSize().height * 1.5)) - self._uiLayer:addChild(self._displayValueLabel) - - local baseLayer = cc.LayerColor:create() - baseLayer:setColor(cc.c3b(50, 100, 0)) - baseLayer:setOpacity(100) - baseLayer:setContentSize(cc.size(200, 200)) - self._uiLayer:addChild(baseLayer) - - button = ccui.Button:create("cocosui/animationbuttonnormal.png") - print(string.format("content size should be greater than 0: width = %f, height = %f", button:getContentSize().width, - button:getContentSize().height)) - button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - - button:addTouchEventListener(function(sender, eventType) - - if eventType == ccui.TouchEventType.began then - - elseif eventType == ccui.TouchEventType.moved then - - elseif eventType == ccui.TouchEventType.ended then - local touchWidgetSize = self._widget:getContentSize() - local layerSize = baseLayer:getContentSize() - if (layerSize.width == touchWidgetSize.width and layerSize.height == touchWidgetSize.height) then - baseLayer:setContentSize(cc.size(200, 200)) - else - baseLayer:setContentSize(widgetSize) - end - ccui.Helper:doLayout(baseLayer) - else - - end - end) - button:setZoomScale(0.4) - button:setPressedActionEnabled(true) - self._uiLayer:addChild(button) - - - local leftTopSprite = cc.Sprite:create("cocosui/CloseSelected.png") - local leftTop = ccui.LayoutComponent:bindLayoutComponent(leftTopSprite) - leftTop:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Left) - leftTop:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Top) - baseLayer:addChild(leftTopSprite) - - local leftBottomSprite = cc.Sprite:create("cocosui/CloseSelected.png") - local leftBottom = ccui.LayoutComponent:bindLayoutComponent(leftBottomSprite) - leftBottom:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Left) - leftBottom:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Bottom) - baseLayer:addChild(leftBottomSprite) - - local rightTopSprite = cc.Sprite:create("cocosui/CloseSelected.png") - local rightTop = ccui.LayoutComponent:bindLayoutComponent(rightTopSprite) - rightTop:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Right) - rightTop:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Top) - baseLayer:addChild(rightTopSprite) - - local rightBottomSprite = cc.Sprite:create("cocosui/CloseSelected.png") - local rightBottom = ccui.LayoutComponent:bindLayoutComponent(rightBottomSprite) - rightBottom:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Right) - rightBottom:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Bottom) - baseLayer:addChild(rightBottomSprite) - - ccui.Helper:doLayout(baseLayer) -end - -function UILayoutComponentBerthTest.create() - local scene = cc.Scene:create() - local layer = UILayoutComponentBerthTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UILayoutComponentBerthStretchTest = class("UILayoutComponentBerthStretchTest",UIScene) -UILayoutComponentBerthStretchTest._displayValueLabel = nil - -function UILayoutComponentBerthStretchTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UILayoutComponentBerthStretchTest) - return target -end - -function UILayoutComponentBerthStretchTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("LayoutComponent Berth Stretch Test") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getContentSize().height * 1.5)) - self._uiLayer:addChild(self._displayValueLabel) - - local baseLayer = cc.LayerColor:create() - baseLayer:setColor(cc.c3b(50, 100, 0)) - baseLayer:setOpacity(100) - baseLayer:setContentSize(cc.size(200, 200)) - self._uiLayer:addChild(baseLayer) - - button = ccui.Button:create("cocosui/animationbuttonnormal.png") - print(string.format("content size should be greater than 0: width = %f, height = %f", button:getContentSize().width, - button:getContentSize().height)) - button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - - button:addTouchEventListener(function(sender, eventType) - - if eventType == ccui.TouchEventType.began then - - elseif eventType == ccui.TouchEventType.moved then - - elseif eventType == ccui.TouchEventType.ended then - local touchWidgetSize = self._widget:getContentSize() - local layerSize = baseLayer:getContentSize() - if (layerSize.width == touchWidgetSize.width and layerSize.height == touchWidgetSize.height) then - baseLayer:setContentSize(cc.size(200, 200)) - else - baseLayer:setContentSize(widgetSize) - end - ccui.Helper:doLayout(baseLayer) - else - - end - end) - button:setZoomScale(0.4) - button:setPressedActionEnabled(true) - self._uiLayer:addChild(button) - - local leftTopSprite = ccui.ImageView:create("cocosui/CloseSelected.png") - leftTopSprite:ignoreContentAdaptWithSize(false) - local leftTop = ccui.LayoutComponent:bindLayoutComponent(leftTopSprite) - leftTop:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Left) - leftTop:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Top) - leftTop:setStretchWidthEnabled(true) - leftTop:setStretchHeightEnabled(true) - baseLayer:addChild(leftTopSprite) - leftTop:setSize(leftTopSprite:getContentSize()) - leftTop:setLeftMargin(0) - leftTop:setTopMargin(0) - - local leftBottomSprite = ccui.ImageView:create("cocosui/CloseSelected.png") - leftBottomSprite:ignoreContentAdaptWithSize(false) - local leftBottom = ccui.LayoutComponent:bindLayoutComponent(leftBottomSprite) - leftBottom:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Left) - leftBottom:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Bottom) - leftBottom:setStretchWidthEnabled(true) - leftBottom:setStretchHeightEnabled(true) - baseLayer:addChild(leftBottomSprite) - leftBottom:setSize(leftBottomSprite:getContentSize()) - leftBottom:setLeftMargin(0) - leftBottom:setBottomMargin(0) - - local rightTopSprite = ccui.ImageView:create("cocosui/CloseSelected.png") - rightTopSprite:ignoreContentAdaptWithSize(false) - local rightTop = ccui.LayoutComponent:bindLayoutComponent(rightTopSprite) - rightTop:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Right) - rightTop:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Top) - rightTop:setStretchWidthEnabled(true) - rightTop:setStretchHeightEnabled(true) - baseLayer:addChild(rightTopSprite) - rightTop:setSize(rightTopSprite:getContentSize()) - rightTop:setTopMargin(0) - rightTop:setRightMargin(0) - - local rightBottomSprite = ccui.ImageView:create("cocosui/CloseSelected.png") - rightBottomSprite:ignoreContentAdaptWithSize(false) - local rightBottom = ccui.LayoutComponent:bindLayoutComponent(rightBottomSprite) - rightBottom:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Right) - rightBottom:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Bottom) - rightBottom:setStretchWidthEnabled(true) - rightBottom:setStretchHeightEnabled(true) - baseLayer:addChild(rightBottomSprite) - rightBottom:setSize(rightBottomSprite:getContentSize()) - rightBottom:setBottomMargin(0) - rightBottom:setRightMargin(0) - ccui.Helper:doLayout(baseLayer) -end - -function UILayoutComponentBerthStretchTest.create() - local scene = cc.Scene:create() - local layer = UILayoutComponentBerthStretchTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIScrollViewVerticalTest = class("UIScrollViewVerticalTest",UIScene) -UIScrollViewVerticalTest._displayValueLabel = nil - -function UIScrollViewVerticalTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIScrollViewVerticalTest) - return target -end - -function UIScrollViewVerticalTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("Move by vertical direction") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getContentSize().height * 1.5)) - self._uiLayer:addChild(self._displayValueLabel) - - local alert = ccui.Text:create() - alert:setString("ScrollView") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - - local scrollView = ccui.ScrollView:create() - scrollView:setTouchEnabled(true) - scrollView:setContentSize(cc.size(280, 150)) - local backgroundSize = background:getContentSize() - scrollView:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - scrollView:getContentSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - scrollView:getContentSize().height) / 2)) - self._uiLayer:addChild(scrollView) - - local imageView = ccui.ImageView:create() - imageView:loadTexture("cocosui/ccicon.png") - - local innerWidth = scrollView:getContentSize().width - local innerHeight = scrollView:getContentSize().height + imageView:getContentSize().height - - scrollView:setInnerContainerSize(cc.size(innerWidth, innerHeight)) - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - button:setPosition(cc.p(innerWidth / 2, scrollView:getInnerContainerSize().height - button:getContentSize().height / 2)) - scrollView:addChild(button) - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - textButton:setPosition(cc.p(innerWidth / 2, button:getBottomBoundary() - button:getContentSize().height)) - scrollView:addChild(textButton) - - local button_scale9 = ccui.Button:create() - button_scale9:setTouchEnabled(true) - button_scale9:setScale9Enabled(true) - button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) - button_scale9:setPosition(cc.p(innerWidth / 2, textButton:getBottomBoundary() - textButton:getContentSize().height)) - scrollView:addChild(button_scale9) - - imageView:setPosition(cc.p(innerWidth / 2, imageView:getContentSize().height / 2)) - scrollView:addChild(imageView) -end - -function UIScrollViewVerticalTest.create() - local scene = cc.Scene:create() - local layer = UIScrollViewVerticalTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIScrollViewHorizontalTest = class("UIScrollViewHorizontalTest",UIScene) -UIScrollViewHorizontalTest._displayValueLabel = nil - -function UIScrollViewHorizontalTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIScrollViewHorizontalTest) - return target -end - -function UIScrollViewHorizontalTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("Move by horizontal direction") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getContentSize().height * 1.5)) - self._uiLayer:addChild(self._displayValueLabel) - - local alert = ccui.Text:create() - alert:setString("ScrollView") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - - local scrollView = ccui.ScrollView:create() - scrollView:setBounceEnabled(true) - scrollView:setDirection(ccui.ScrollViewDir.horizontal) - scrollView:setTouchEnabled(true) - scrollView:setContentSize(cc.size(280, 150)) - scrollView:setInnerContainerSize(scrollView:getContentSize()) - local backgroundSize = background:getContentSize() - scrollView:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - scrollView:getContentSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - scrollView:getContentSize().height) / 2)) - self._uiLayer:addChild(scrollView) - - local imageView = ccui.ImageView:create() - imageView:loadTexture("cocosui/ccicon.png") - - local innerWidth = scrollView:getContentSize().width + imageView:getContentSize().width - local innerHeight = scrollView:getContentSize().height - - scrollView:setInnerContainerSize(cc.size(innerWidth, innerHeight)) - - local button = ccui.Button:create() - button:setTouchEnabled(true) - button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") - button:setPosition(cc.p(button:getContentSize().width / 2, - scrollView:getInnerContainerSize().height - button:getContentSize().height / 2)) - scrollView:addChild(button) - - local textButton = ccui.Button:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - textButton:setPosition(cc.p(button:getRightBoundary() + button:getContentSize().width / 2, - button:getBottomBoundary() - button:getContentSize().height / 2)) - scrollView:addChild(textButton) - - local button_scale9 = ccui.Button:create() - button_scale9:setTouchEnabled(true) - button_scale9:setScale9Enabled(true) - button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") - button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) - button_scale9:setPosition(cc.p(textButton:getRightBoundary() + textButton:getContentSize().width / 2, - textButton:getBottomBoundary() - textButton:getContentSize().height / 2)) - scrollView:addChild(button_scale9) - - imageView:setPosition(cc.p(innerWidth - imageView:getContentSize().width / 2, - button_scale9:getBottomBoundary() - button_scale9:getContentSize().height / 2)) - scrollView:addChild(imageView) -end - -function UIScrollViewHorizontalTest.create() - local scene = cc.Scene:create() - local layer = UIScrollViewHorizontalTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIPageViewTest = class("UIPageViewTest",UIScene) -UIPageViewTest._displayValueLabel = nil - -function UIPageViewTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIPageViewTest) - return target -end - -function UIPageViewTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("Move by horizontal direction") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getContentSize().height * 1.5)) - self._uiLayer:addChild(self._displayValueLabel) - - local alert = ccui.Text:create() - alert:setString("PageView") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - - local pageView = ccui.PageView:create() - pageView:setTouchEnabled(true) - pageView:setContentSize(cc.size(240, 130)) - local backgroundSize = background:getContentSize() - pageView:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - pageView:getContentSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - pageView:getContentSize().height) / 2)) - - for i = 1 , 3 do - local layout = ccui.Layout:create() - layout:setContentSize(cc.size(240, 130)) - - local imageView = ccui.ImageView:create() - imageView:setTouchEnabled(true) - imageView:setScale9Enabled(true) - imageView:loadTexture("cocosui/scrollviewbg.png") - imageView:setContentSize(cc.size(240, 130)) - imageView:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) - layout:addChild(imageView) - - local label = ccui.Text:create() - local pageInfo = string.format("page %d", i) - label:setString(pageInfo) - label:setFontName(font_TextName) - label:setFontSize(30) - label:setColor(cc.c3b(192, 192, 192)) - label:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) - layout:addChild(label) - - pageView:addPage(layout) - - end - - local function pageViewEvent(sender, eventType) - if eventType == ccui.PageViewEventType.turning then - local pageView = sender - local pageInfo = string.format("page %d " , pageView:getCurPageIndex() + 1) - self._displayValueLabel:setString(pageInfo) - end - end - - pageView:addEventListener(pageViewEvent) - - self._uiLayer:addChild(pageView) - -end - -function UIPageViewTest.create() - local scene = cc.Scene:create() - local layer = UIPageViewTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIListViewVerticalTest = class("UIListViewVerticalTest",UIScene) -UIListViewVerticalTest._displayValueLabel = nil - -function UIListViewVerticalTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIListViewVerticalTest) - return target -end - -function UIListViewVerticalTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("Move by vertical direction") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getContentSize().height * 1.5)) - self._uiLayer:addChild(self._displayValueLabel) - - local alert = ccui.Text:create() - alert:setString("ListView") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local root = self._uiLayer:getChildByTag(81) - - local background = root:getChildByName("background_Panel") - local backgroundSize = background:getContentSize() - - local array = {} - for i = 1,20 do - array[i] = string.format("ListView_item_%d",i - 1) - end - - local function listViewEvent(sender, eventType) - if eventType == ccui.ListViewEventType.ONSELECTEDITEM_START then - print("select child index = ",sender:getCurSelectedIndex()) - end - end - - local function scrollViewEvent(sender, evenType) - if evenType == ccui.ScrollviewEventType.scrollToBottom then - print("SCROLL_TO_BOTTOM") - elseif evenType == ccui.ScrollviewEventType.scrollToTop then - print("SCROLL_TO_TOP") - end - end - - local listView = ccui.ListView:create() - -- set list view ex direction - listView:setDirection(ccui.ScrollViewDir.vertical) - listView:setBounceEnabled(true) - listView:setBackGroundImage("cocosui/green_edit.png") - listView:setBackGroundImageScale9Enabled(true) - listView:setContentSize(cc.size(240, 130)) - listView:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2.0 + - (backgroundSize.width - listView:getContentSize().width) / 2.0, - (widgetSize.height - backgroundSize.height) / 2.0 + - (backgroundSize.height - listView:getContentSize().height) / 2.0)) - listView:addEventListener(listViewEvent) - listView:addScrollViewEventListener(scrollViewEvent) - self._uiLayer:addChild(listView) - - - -- create model - local default_button = ccui.Button:create("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png") - default_button:setName("Title Button") - - local default_item = ccui.Layout:create() - default_item:setTouchEnabled(true) - default_item:setContentSize(default_button:getContentSize()) - default_button:setPosition(cc.p(default_item:getContentSize().width / 2.0, default_item:getContentSize().height / 2.0)) - default_item:addChild(default_button) - - --set model - listView:setItemModel(default_item) - - --add default item - local count = table.getn(array) - for i = 1,math.floor(count / 4) do - listView:pushBackDefaultItem() - end - --insert default item - for i = 1,math.floor(count / 4) do - listView:insertDefaultItem(0) - end - - listView:removeAllChildren() - - local testSprite = cc.Sprite:create("cocosui/backtotoppressed.png") - testSprite:setPosition(cc.p(200,200)) - listView:addChild(testSprite) - - --add custom item - for i = 1,math.floor(count / 4) do - local custom_button = ccui.Button:create("cocosui/button.png", "cocosui/buttonHighlighted.png") - custom_button:setName("Title Button") - custom_button:setScale9Enabled(true) - custom_button:setContentSize(default_button:getContentSize()) - - local custom_item = ccui.Layout:create() - custom_item:setContentSize(custom_button:getContentSize()) - custom_button:setPosition(cc.p(custom_item:getContentSize().width / 2.0, custom_item:getContentSize().height / 2.0)) - custom_item:addChild(custom_button) - - listView:addChild(custom_item) - end - - --insert custom item - local items = listView:getItems() - local items_count = table.getn(items) - for i = 1, math.floor(count / 4) do - local custom_button = ccui.Button:create("cocosui/button.png", "cocosui/buttonHighlighted.png") - custom_button:setName("Title Button") - custom_button:setScale9Enabled(true) - custom_button:setContentSize(default_button:getContentSize()) - - local custom_item = ccui.Layout:create() - custom_item:setContentSize(custom_button:getContentSize()) - custom_button:setPosition(cc.p(custom_item:getContentSize().width / 2.0, custom_item:getContentSize().height / 2.0)) - custom_item:addChild(custom_button) - custom_item:setTag(1) - - listView:insertCustomItem(custom_item, items_count) - end - - -- set item data - items_count = table.getn(listView:getItems()) - for i = 1,items_count do - local item = listView:getItem(i - 1) - local button = item:getChildByName("Title Button") - local index = listView:getIndex(item) - button:setTitleText(array[index + 1]) - end - - -- remove last item - listView:removeChildByTag(1) - - -- remove item by index - items_count = table.getn(listView:getItems()) - listView:removeItem(items_count - 1) - - -- set all items layout gravity - listView:setGravity(ccui.ListViewGravity.centerVertical) - - --set items margin - listView:setItemsMargin(2.0) -end - -function UIListViewVerticalTest.create() - local scene = cc.Scene:create() - local layer = UIListViewVerticalTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIListViewHorizontalTest = class("UIListViewHorizontalTest",UIScene) -UIListViewHorizontalTest._displayValueLabel = nil - -function UIListViewHorizontalTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIListViewHorizontalTest) - return target -end - -function UIListViewHorizontalTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("Move by vertical direction") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getContentSize().height * 1.5)) - self._uiLayer:addChild(self._displayValueLabel) - - local alert = ccui.Text:create() - alert:setString("ListView") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - - local root = self._uiLayer:getChildByTag(81) - - local background = root:getChildByName("background_Panel") - local backgroundSize = background:getContentSize() - - local array = {} - for i = 1,20 do - array[i] = string.format("ListView_item_%d",i - 1) - end - - local function listViewEvent(sender, eventType) - if eventType == ccui.ListViewEventType.ons_selected_item then - print("select child index = ",sender:getCurSelectedIndex()) - end - end - - local listView = ccui.ListView:create() - -- set list view ex direction - listView:setDirection(ccui.ScrollViewDir.horizontal) - listView:setTouchEnabled(true) - listView:setBounceEnabled(true) - listView:setBackGroundImage("cocosui/green_edit.png") - listView:setBackGroundImageScale9Enabled(true) - listView:setContentSize(cc.size(240, 130)) - listView:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2.0 + - (backgroundSize.width - listView:getContentSize().width) / 2.0, - (widgetSize.height - backgroundSize.height) / 2.0 + - (backgroundSize.height - listView:getContentSize().height) / 2.0)) - listView:addEventListener(listViewEvent) - self._uiLayer:addChild(listView) - - - -- create model - local default_button = ccui.Button:create("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png") - default_button:setName("Title Button") - - local default_item = ccui.Layout:create() - default_item:setTouchEnabled(true) - default_item:setContentSize(default_button:getContentSize()) - default_button:setPosition(cc.p(default_item:getContentSize().width / 2.0, default_item:getContentSize().height / 2.0)) - default_item:addChild(default_button) - - --set model - listView:setItemModel(default_item) - - --add default item - local count = table.getn(array) - for i = 1,math.floor(count / 4) do - listView:pushBackDefaultItem() - end - --insert default item - for i = 1,math.floor(count / 4) do - listView:insertDefaultItem(0) - end - - --add custom item - for i = 1,math.floor(count / 4) do - local custom_button = ccui.Button:create("cocosui/button.png", "cocosui/buttonHighlighted.png") - custom_button:setName("Title Button") - custom_button:setScale9Enabled(true) - custom_button:setContentSize(default_button:getContentSize()) - - local custom_item = ccui.Layout:create() - custom_item:setContentSize(custom_button:getContentSize()) - custom_button:setPosition(cc.p(custom_item:getContentSize().width / 2.0, custom_item:getContentSize().height / 2.0)) - custom_item:addChild(custom_button) - - listView:pushBackCustomItem(custom_item) - end - - --insert custom item - local items = listView:getItems() - local items_count = table.getn(items) - for i = 1, math.floor(count / 4) do - local custom_button = ccui.Button:create("cocosui/button.png", "cocosui/buttonHighlighted.png") - custom_button:setName("Title Button") - custom_button:setScale9Enabled(true) - custom_button:setContentSize(default_button:getContentSize()) - - local custom_item = ccui.Layout:create() - custom_item:setContentSize(custom_button:getContentSize()) - custom_button:setPosition(cc.p(custom_item:getContentSize().width / 2.0, custom_item:getContentSize().height / 2.0)) - custom_item:addChild(custom_button) - - listView:insertCustomItem(custom_item, items_count) - end - - -- set item data - items_count = table.getn(listView:getItems()) - print("items_count", items_count) - for i = 1,items_count do - local item = listView:getItem(i - 1) - local button = item:getChildByName("Title Button") - local index = listView:getIndex(item) - print("index is ", index) - button:setTitleText(array[index + 1]) - end - - -- remove last item - listView:removeLastItem() - - -- remove item by index - items_count = table.getn(listView:getItems()) - listView:removeItem(items_count - 1) - - -- set all items layout gravity - listView:setGravity(ccui.ListViewGravity.centerVertical) - - --set items margin - listView:setItemsMargin(2.0) -end - -function UIListViewHorizontalTest.create() - local scene = cc.Scene:create() - local layer = UIListViewHorizontalTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIDragPanelTest = class("UIDragPanelTest",UIScene) -UIDragPanelTest._displayValueLabel = nil - -function UIDragPanelTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIDragPanelTest) - return target -end - -function UIDragPanelTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("No Event") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getContentSize().height * 1.5)) - self._uiLayer:addChild(self._displayValueLabel) - - local alert = ccui.Text:create() - alert:setString("DragPanel") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local sc = ccui.ScrollView:create() - sc:setBackGroundColor(cc.c3b(0,255,0)) - sc:setBackGroundColorType(ccui.LayoutBackGroundColorType.solid) - sc:setDirection(ccui.ScrollViewDir.both) - sc:setInnerContainerSize(cc.size(480, 320)) - sc:setContentSize(cc.size(100,100)) - sc:setPosition(cc.p(100,100)) - sc:scrollToPercentBothDirection(cc.p(50, 50), 1, true) - local iv = ccui.ImageView:create() - iv:loadTexture("cocosui/Hello.png") - iv:setPosition(cc.p(240, 160)) - sc:addChild(iv) - self._uiLayer:addChild(sc) - -end - -function UIDragPanelTest.create() - local scene = cc.Scene:create() - local layer = UIDragPanelTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIDragPanelBounceTest = class("UIDragPanelBounceTest",UIScene) -UIDragPanelBounceTest._displayValueLabel = nil - -function UIDragPanelBounceTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIDragPanelBounceTest) - return target -end - -function UIDragPanelBounceTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("No Event") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getContentSize().height * 1.5)) - self._uiLayer:addChild(self._displayValueLabel) - - - local alert = ccui.Text:create() - alert:setString("DragPanel Bounce") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) - self._uiLayer:addChild(alert) - - local sc = ccui.ScrollView:create() - sc:setBackGroundColor(cc.c3b(0, 255 , 0)) - sc:setBackGroundColorType(ccui.LayoutBackGroundColorType.solid) - sc:setBounceEnabled(true) - sc:setDirection(ccui.ScrollViewDir.both) - sc:setInnerContainerSize(cc.size(480, 320)) - sc:setContentSize(cc.size(100,100)) - sc:setPosition(cc.p(100,100)) - sc:scrollToPercentBothDirection(cc.p(50, 50), 1, true) - local iv = ccui.ImageView:create() - iv:loadTexture("cocosui/Hello.png") - iv:setPosition(cc.p(240, 160)) - sc:addChild(iv) - self._uiLayer:addChild(sc) -end - -function UIDragPanelBounceTest.create() - local scene = cc.Scene:create() - local layer = UIDragPanelBounceTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UINodeContainerTest = class("UINodeContainerTest",UIScene) -UINodeContainerTest._displayValueLabel = nil - -function UINodeContainerTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UINodeContainerTest) - return target -end - -function UINodeContainerTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - print("setFontName before") - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("NodeContainer Add CCNode") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getContentSize().height * 1.5)) - self._uiLayer:addChild(self._displayValueLabel) - - local alert = ccui.Text:create() - alert:setString("NodeContainer") - alert:setFontName(font_TextName) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) - self._uiLayer:addChild(alert) - - local nodeContainer = ccui.Widget:create() - nodeContainer:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - self._uiLayer:addChild(nodeContainer) - - local sprite = cc.Sprite:create("cocosui/ccicon.png") - sprite:setPosition(cc.p(0, sprite:getBoundingBox().height / 4)) - nodeContainer:addChild(sprite) -end - -function UINodeContainerTest.create() - local scene = cc.Scene:create() - local layer = UINodeContainerTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIRichTextTest = class("UIRichTextTest",UIScene) - -function UIRichTextTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIRichTextTest) - return target -end - -function UIRichTextTest:initExtend() - - self:init() - - local widgetSize = self._widget:getContentSize() - - local alert = ccui.Text:create("RichText", "fonts/Marker Felt.ttf", 30) - alert:setFontName(font_TextName) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 3.125)) - self._widget:addChild(alert) - - - local function touchEvent(sender, eventType) - if eventType == ccui.TouchEventType.ended then - if self._richText:isIgnoreContentAdaptWithSize() then - self._richText:ignoreContentAdaptWithSize(false) - self._richText:setContentSize(cc.size(100, 100)) - else - self._richText:ignoreContentAdaptWithSize(true) - end - end - end - - local button = ccui.Button:create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png") - button:setTouchEnabled(true) - button:setTitleText("switch") - button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + button:getContentSize().height * 2.5)) - button:addTouchEventListener(touchEvent) - button:setLocalZOrder(10) - self._widget:addChild(button) - - self._richText = ccui.RichText:create() - self._richText:ignoreContentAdaptWithSize(false) - self._richText:setContentSize(cc.size(100, 100)) - - local re1 = ccui.RichElementText:create(1, cc.c3b(255, 255, 255), 255, "This color is white. ", "Helvetica", 10) - local re2 = ccui.RichElementText:create(2, cc.c3b(255, 255, 0), 255, "And this is yellow. ", "Helvetica", 10) - local re3 = ccui.RichElementText:create(3, cc.c3b(0, 0, 255), 255, "This one is blue. ", "Helvetica", 10) - local re4 = ccui.RichElementText:create(4, cc.c3b(0, 255, 0), 255, "And green. ", "Helvetica", 10) - local re5 = ccui.RichElementText:create(5, cc.c3b(255, 0, 0), 255, "Last one is red ", "Helvetica", 10) - - local reimg = ccui.RichElementImage:create(6, cc.c3b(255, 255, 255), 255, "cocosui/sliderballnormal.png") - - ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("cocosui/100/100.ExportJson") - local arr = ccs.Armature:create("100") - arr:getAnimation():play("Animation1") - - local recustom = ccui.RichElementCustomNode:create(1, cc.c3b(255, 255, 255), 255, arr) - local re6 = ccui.RichElementText:create(7, cc.c3b(255, 127, 0), 255, "Have fun!! ", "Helvetica", 10) - self._richText:pushBackElement(re1) - self._richText:insertElement(re2, 1) - self._richText:pushBackElement(re3) - self._richText:pushBackElement(re4) - self._richText:pushBackElement(re5) - self._richText:insertElement(reimg, 2) - self._richText:pushBackElement(recustom) - self._richText:pushBackElement(re6) - - self._richText:setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2)) - self._richText:setLocalZOrder(10) - - - self._widget:addChild(self._richText) - -end - -function UIRichTextTest.create() - local scene = cc.Scene:create() - local layer = UIRichTextTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIFocusTestHorizontal = class("UIFocusTestHorizontal",UIScene) -function UIFocusTestHorizontal.extend( target ) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIFocusTestHorizontal) - return target -end - -function UIFocusTestHorizontal:initExtend() - self:init() - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - background:removeFromParent(true) - - local function onLeftKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_LEFT, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onRightKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_RIGHT, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onUpKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_UP, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onDownKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_DOWN, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - self._dpadMenu = cc.Menu:create() - local winSize = cc.Director:getInstance():getVisibleSize() - - local leftItem = cc.MenuItemFont:create("Left") - leftItem:setPosition(cc.p(winSize.width - 100, winSize.height/2)) - leftItem:registerScriptTapHandler(onLeftKeyPressed) - self._dpadMenu:addChild(leftItem) - - local rightItem = cc.MenuItemFont:create("Right") - rightItem:setPosition(cc.p(winSize.width - 30, winSize.height/2)) - rightItem:registerScriptTapHandler(onRightKeyPressed) - self._dpadMenu:addChild(rightItem) - - local upItem = cc.MenuItemFont:create("Up") - upItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 + 50)) - upItem:registerScriptTapHandler(onUpKeyPressed) - self._dpadMenu:addChild(upItem) - - local downItem = cc.MenuItemFont:create("Down") - downItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 - 50)) - downItem:registerScriptTapHandler(onDownKeyPressed) - self._dpadMenu:addChild(downItem) - self._dpadMenu:setPosition(cc.p(0, 0)) - self._uiLayer:addChild(self._dpadMenu) - - ccui.Widget:enableDpadNavigation(true) - - local function onFocusChanged(widgetLostFocus,widgetGetFocus) - if nil ~= widgetGetFocus and widgetGetFocus:isFocusEnabled() then - widgetGetFocus:setColor(cc.c3b(255, 0, 0)) - end - - if nil ~= widgetLostFocus and widgetLostFocus:isFocusEnabled() then - widgetLostFocus:setColor(cc.c3b(255, 255, 255)) - end - - if nil ~= widgetLostFocus and nil ~= widgetGetFocus then - print(string.format("on focus change, %d widget get focus, %d widget lose focus", widgetGetFocus:getTag(), widgetLostFocus:getTag())) - end - end - - local eventListener = cc.EventListenerFocus:create() - eventListener:registerScriptHandler(onFocusChanged) - local eventDispatcher = self:getEventDispatcher() - eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) - - local winSize = cc.Director:getInstance():getVisibleSize() - self._horizontalLayout = ccui.HBox:create() - self._horizontalLayout:setPosition(cc.p(20, winSize.height / 2 + 40)) - self._uiLayer:addChild(self._horizontalLayout) - - self._horizontalLayout:setFocused(true) - self._horizontalLayout:setLoopFocus(true) - self._horizontalLayout:setTag(100) - self._firstFocusedWidget = self._horizontalLayout - - local function onImageViewClicked(sender, eventType) - if eventType == ccui.TouchEventType.ended then - local w = sender - if w:isFocusEnabled() then - w:setFocusEnabled(false) - w:setColor(cc.c3b(255, 255, 0)) - else - w:setFocusEnabled(true) - w:setColor(cc.c3b(255, 255, 255)) - end - end - end - - local count = 3 - for i = 1, count do - local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") - imageView:setTouchEnabled(true) - imageView:setTag(i) - imageView:addTouchEventListener(onImageViewClicked) - self._horizontalLayout:addChild(imageView) - end - - self._loopText = ccui.Text:create("loop enabled", "Arial", 20) - self._loopText:setPosition(cc.p(winSize.width/2, winSize.height - 50)) - self._loopText:setColor(cc.c3b(255, 0 ,0)) - self:addChild(self._loopText) - - local function toggleFocusLoop(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self._horizontalLayout:setLoopFocus(not self._horizontalLayout:isLoopFocus()) - if self._horizontalLayout:isLoopFocus() then - self._loopText:setString("loop enabled") - else - self._loopText:setString("loop disabled") - end - end - end - - local btn = ccui.Button:create("cocosui/switch-mask.png") - btn:setTitleText("Toggle Loop") - btn:setPosition(cc.p(60, winSize.height - 50)) - btn:setTitleColor(cc.c3b(0, 255, 0)) - btn:addTouchEventListener(toggleFocusLoop) - self:addChild(btn) -end - -function UIFocusTestHorizontal.create() - local scene = cc.Scene:create() - local layer = UIFocusTestHorizontal.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIFocusTestVertical = class("UIFocusTestVertical",UIScene) - -function UIFocusTestVertical.extend( target ) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIFocusTestVertical) - return target -end - -function UIFocusTestVertical:initExtend() - self:init() - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - background:removeFromParent(true) - - local function onLeftKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_LEFT, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onRightKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_RIGHT, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onUpKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_UP, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onDownKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_DOWN, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - self._dpadMenu = cc.Menu:create() - local winSize = cc.Director:getInstance():getVisibleSize() - - local leftItem = cc.MenuItemFont:create("Left") - leftItem:setPosition(cc.p(winSize.width - 100, winSize.height/2)) - leftItem:registerScriptTapHandler(onLeftKeyPressed) - self._dpadMenu:addChild(leftItem) - - local rightItem = cc.MenuItemFont:create("Right") - rightItem:setPosition(cc.p(winSize.width - 30, winSize.height/2)) - rightItem:registerScriptTapHandler(onRightKeyPressed) - self._dpadMenu:addChild(rightItem) - - local upItem = cc.MenuItemFont:create("Up") - upItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 + 50)) - upItem:registerScriptTapHandler(onUpKeyPressed) - self._dpadMenu:addChild(upItem) - - local downItem = cc.MenuItemFont:create("Down") - downItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 - 50)) - downItem:registerScriptTapHandler(onDownKeyPressed) - self._dpadMenu:addChild(downItem) - self._dpadMenu:setPosition(cc.p(0, 0)) - self._uiLayer:addChild(self._dpadMenu) - - ccui.Widget:enableDpadNavigation(true) - - local function onFocusChanged(widgetLostFocus,widgetGetFocus) - if nil ~= widgetGetFocus and widgetGetFocus:isFocusEnabled() then - widgetGetFocus:setColor(cc.c3b(255, 0, 0)) - end - - if nil ~= widgetLostFocus and widgetLostFocus:isFocusEnabled() then - widgetLostFocus:setColor(cc.c3b(255, 255, 255)) - end - - if nil ~= widgetLostFocus and nil ~= widgetGetFocus then - print(string.format("on focus change, %d widget get focus, %d widget lose focus", widgetGetFocus:getTag(), widgetLostFocus:getTag())) - end - end - - local eventListener = cc.EventListenerFocus:create() - eventListener:registerScriptHandler(onFocusChanged) - local eventDispatcher = self:getEventDispatcher() - eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) - - local winSize = cc.Director:getInstance():getVisibleSize() - self._verticalLayout = ccui.VBox:create() - self._verticalLayout:setPosition(cc.p(winSize.width/2 - 100, winSize.height - 70)) - self._uiLayer:addChild(self._verticalLayout) - - self._verticalLayout:setFocused(true) - self._verticalLayout:setLoopFocus(true) - self._verticalLayout:setTag(100) - self._verticalLayout:setScale(0.5) - self._firstFocusedWidget = self._verticalLayout - - local function onImageViewClicked(sender, eventType) - if eventType == ccui.TouchEventType.ended then - local w = sender - if w:isFocusEnabled() then - w:setFocusEnabled(false) - w:setColor(cc.c3b(255, 255, 0)) - else - w:setFocusEnabled(true) - w:setColor(cc.c3b(255, 255, 255)) - end - end - end - - local count = 3 - for i = 1, count do - local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") - imageView:setTouchEnabled(true) - imageView:setTag(i) - imageView:addTouchEventListener(onImageViewClicked) - self._verticalLayout:addChild(imageView) - end - - self._loopText = ccui.Text:create("loop enabled", "Arial", 20) - self._loopText:setPosition(cc.p(winSize.width/2, winSize.height - 50)) - self._loopText:setColor(cc.c3b(255, 0 ,0)) - self:addChild(self._loopText) - - local function toggleFocusLoop(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self._verticalLayout:setLoopFocus(not self._verticalLayout:isLoopFocus()) - if self._verticalLayout:isLoopFocus() then - self._loopText:setString("loop enabled") - else - self._loopText:setString("loop disabled") - end - end - end - - local btn = ccui.Button:create("cocosui/switch-mask.png") - btn:setTitleText("Toggle Loop") - btn:setPosition(cc.p(60, winSize.height - 50)) - btn:setTitleColor(cc.c3b(0, 255, 0)) - btn:addTouchEventListener(toggleFocusLoop) - self:addChild(btn) -end - -function UIFocusTestVertical.create() - local scene = cc.Scene:create() - local layer = UIFocusTestVertical.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIFocusTestNestedLayout1 = class("UIFocusTestNestedLayout1",UIScene) - -function UIFocusTestNestedLayout1.extend( target ) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIFocusTestNestedLayout1) - return target -end - -function UIFocusTestNestedLayout1:initExtend() - self:init() - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - background:removeFromParent(true) - - local function onLeftKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_LEFT, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onRightKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_RIGHT, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onUpKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_UP, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onDownKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_DOWN, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - self._dpadMenu = cc.Menu:create() - local winSize = cc.Director:getInstance():getVisibleSize() - - local leftItem = cc.MenuItemFont:create("Left") - leftItem:setPosition(cc.p(winSize.width - 100, winSize.height/2)) - leftItem:registerScriptTapHandler(onLeftKeyPressed) - self._dpadMenu:addChild(leftItem) - - local rightItem = cc.MenuItemFont:create("Right") - rightItem:setPosition(cc.p(winSize.width - 30, winSize.height/2)) - rightItem:registerScriptTapHandler(onRightKeyPressed) - self._dpadMenu:addChild(rightItem) - - local upItem = cc.MenuItemFont:create("Up") - upItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 + 50)) - upItem:registerScriptTapHandler(onUpKeyPressed) - self._dpadMenu:addChild(upItem) - - local downItem = cc.MenuItemFont:create("Down") - downItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 - 50)) - downItem:registerScriptTapHandler(onDownKeyPressed) - self._dpadMenu:addChild(downItem) - self._dpadMenu:setPosition(cc.p(0, 0)) - self._uiLayer:addChild(self._dpadMenu) - - ccui.Widget:enableDpadNavigation(true) - - local function onFocusChanged(widgetLostFocus,widgetGetFocus) - if nil ~= widgetGetFocus and widgetGetFocus:isFocusEnabled() then - widgetGetFocus:setColor(cc.c3b(255, 0, 0)) - end - - if nil ~= widgetLostFocus and widgetLostFocus:isFocusEnabled() then - widgetLostFocus:setColor(cc.c3b(255, 255, 255)) - end - - if nil ~= widgetLostFocus and nil ~= widgetGetFocus then - print(string.format("on focus change, %d widget get focus, %d widget lose focus", widgetGetFocus:getTag(), widgetLostFocus:getTag())) - end - end - - local eventListener = cc.EventListenerFocus:create() - eventListener:registerScriptHandler(onFocusChanged) - local eventDispatcher = self:getEventDispatcher() - eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) - - local winSize = cc.Director:getInstance():getVisibleSize() - - self._verticalLayout = ccui.VBox:create() - self._verticalLayout:setPosition(cc.p(winSize.width/2 - 80, winSize.height - 70)) - self._uiLayer:addChild(self._verticalLayout) - self._verticalLayout:setScale(0.5) - - self._verticalLayout:setFocused(true) - self._verticalLayout:setLoopFocus(true) - self._verticalLayout:setTag(100) - self._firstFocusedWidget = self._verticalLayout - - local function onImageViewClicked(sender, eventType) - if eventType == ccui.TouchEventType.ended then - local w = sender - if w:isFocusEnabled() then - w:setFocusEnabled(false) - w:setColor(cc.c3b(255, 255, 0)) - else - w:setFocusEnabled(true) - w:setColor(cc.c3b(255, 255, 255)) - end - end - end - - local count1 = 1 - for i = 1, count1 do - local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") - imageView:setAnchorPoint(cc.p(0, 0)) - imageView:setTouchEnabled(true) - imageView:setScaleX(2.5) - imageView:setTag(i - 1 + count1) - imageView:addTouchEventListener(onImageViewClicked) - self._verticalLayout:addChild(imageView) - end - - local hbox = ccui.HBox:create() - hbox:setScale(0.8) - hbox:setTag(101) - self._verticalLayout:addChild(hbox) - - local count2 = 2 - for i = 1, count2 do - local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") - imageView:setAnchorPoint(cc.p(0, 1)) - imageView:setScaleY(2.0) - imageView:setTouchEnabled(true) - imageView:setTag(i - 1 + count1 + count2) - imageView:addTouchEventListener(onImageViewClicked) - hbox:addChild(imageView) - end - - local innerVBox = ccui.VBox:create() - hbox:addChild(innerVBox) - innerVBox:setTag(102) - - local count3 = 2 - for i = 1, count3 do - local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") - imageView:setTouchEnabled(true) - imageView:setTag(i - 1 + count1 + count2 + count3) - imageView:addTouchEventListener(onImageViewClicked) - innerVBox:addChild(imageView) - end - - self._loopText = ccui.Text:create("loop enabled", "Arial", 20) - self._loopText:setPosition(cc.p(winSize.width/2, winSize.height - 50)) - self._loopText:setColor(cc.c3b(255, 0 ,0)) - self:addChild(self._loopText) - - local function toggleFocusLoop(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self._verticalLayout:setLoopFocus(not self._verticalLayout:isLoopFocus()) - if self._verticalLayout:isLoopFocus() then - self._loopText:setString("loop enabled") - else - self._loopText:setString("loop disabled") - end - end - end - - local btn = ccui.Button:create("cocosui/switch-mask.png") - btn:setTitleText("Toggle Loop") - btn:setPosition(cc.p(60, winSize.height - 50)) - btn:setTitleColor(cc.c3b(0, 255, 0)) - btn:addTouchEventListener(toggleFocusLoop) - self:addChild(btn) -end - -function UIFocusTestNestedLayout1.create() - local scene = cc.Scene:create() - local layer = UIFocusTestNestedLayout1.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIFocusTestNestedLayout2 = class("UIFocusTestNestedLayout2",UIScene) - -function UIFocusTestNestedLayout2.extend( target ) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIFocusTestNestedLayout2) - return target -end - -function UIFocusTestNestedLayout2:initExtend() - self:init() - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - background:removeFromParent(true) - - local function onLeftKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_LEFT, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onRightKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_RIGHT, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onUpKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_UP, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onDownKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_DOWN, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - self._dpadMenu = cc.Menu:create() - local winSize = cc.Director:getInstance():getVisibleSize() - - local leftItem = cc.MenuItemFont:create("Left") - leftItem:setPosition(cc.p(winSize.width - 100, winSize.height/2)) - leftItem:registerScriptTapHandler(onLeftKeyPressed) - self._dpadMenu:addChild(leftItem) - - local rightItem = cc.MenuItemFont:create("Right") - rightItem:setPosition(cc.p(winSize.width - 30, winSize.height/2)) - rightItem:registerScriptTapHandler(onRightKeyPressed) - self._dpadMenu:addChild(rightItem) - - local upItem = cc.MenuItemFont:create("Up") - upItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 + 50)) - upItem:registerScriptTapHandler(onUpKeyPressed) - self._dpadMenu:addChild(upItem) - - local downItem = cc.MenuItemFont:create("Down") - downItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 - 50)) - downItem:registerScriptTapHandler(onDownKeyPressed) - self._dpadMenu:addChild(downItem) - self._dpadMenu:setPosition(cc.p(0, 0)) - self._uiLayer:addChild(self._dpadMenu) - - ccui.Widget:enableDpadNavigation(true) - - local function onFocusChanged(widgetLostFocus,widgetGetFocus) - if nil ~= widgetGetFocus and widgetGetFocus:isFocusEnabled() then - widgetGetFocus:setColor(cc.c3b(255, 0, 0)) - end - - if nil ~= widgetLostFocus and widgetLostFocus:isFocusEnabled() then - widgetLostFocus:setColor(cc.c3b(255, 255, 255)) - end - - if nil ~= widgetLostFocus and nil ~= widgetGetFocus then - print(string.format("on focus change, %d widget get focus, %d widget lose focus", widgetGetFocus:getTag(), widgetLostFocus:getTag())) - end - end - - local eventListener = cc.EventListenerFocus:create() - eventListener:registerScriptHandler(onFocusChanged) - local eventDispatcher = self:getEventDispatcher() - eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) - - local winSize = cc.Director:getInstance():getVisibleSize() - - self._horizontalLayout = ccui.HBox:create() - self._horizontalLayout:setPosition(cc.p(winSize.width/2 - 200, winSize.height - 70)) - self._uiLayer:addChild(self._horizontalLayout) - self._horizontalLayout:setScale(0.6) - - self._horizontalLayout:setFocused(true) - self._horizontalLayout:setLoopFocus(true) - self._horizontalLayout:setTag(100) - self._firstFocusedWidget = self._horizontalLayout - - local function onImageViewClicked(sender, eventType) - if eventType == ccui.TouchEventType.ended then - local w = sender - if w:isFocusEnabled() then - w:setFocusEnabled(false) - w:setColor(cc.c3b(255, 255, 0)) - else - w:setFocusEnabled(true) - w:setColor(cc.c3b(255, 255, 255)) - end - end - end - - local count1 = 2 - for i = 1, count1 do - local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") - imageView:setAnchorPoint(cc.p(0, 1)) - imageView:setTouchEnabled(true) - imageView:setScaleY(2.4) - imageView:setTag(i - 1 + count1) - imageView:addTouchEventListener(onImageViewClicked) - self._horizontalLayout:addChild(imageView) - end - - local vbox = ccui.VBox:create() - vbox:setScale(0.8) - vbox:setTag(101) - self._horizontalLayout:addChild(vbox) - - local count2 = 2 - for i = 1, count2 do - local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") - imageView:setAnchorPoint(cc.p(0, 1)) - imageView:setScaleX(2.0) - imageView:setTouchEnabled(true) - imageView:setTag(i - 1 + count1 + count2) - imageView:addTouchEventListener(onImageViewClicked) - vbox:addChild(imageView) - end - - local innerVBox = ccui.HBox:create() - vbox:addChild(innerVBox) - innerVBox:setTag(102) - - local count3 = 2 - for i = 1, count3 do - local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") - imageView:setTouchEnabled(true) - imageView:setTag(i - 1 + count1 + count2 + count3) - imageView:addTouchEventListener(onImageViewClicked) - innerVBox:addChild(imageView) - end - - self._loopText = ccui.Text:create("loop enabled", "Arial", 20) - self._loopText:setPosition(cc.p(winSize.width/2, winSize.height - 50)) - self._loopText:setColor(cc.c3b(255, 0 ,0)) - self:addChild(self._loopText) - - local function toggleFocusLoop(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self._horizontalLayout:setLoopFocus(not self._horizontalLayout:isLoopFocus()) - if self._horizontalLayout:isLoopFocus() then - self._loopText:setString("loop enabled") - else - self._loopText:setString("loop disabled") - end - end - end - - local btn = ccui.Button:create("cocosui/switch-mask.png") - btn:setTitleText("Toggle Loop") - btn:setPosition(cc.p(60, winSize.height - 50)) - btn:setTitleColor(cc.c3b(0, 255, 0)) - btn:addTouchEventListener(toggleFocusLoop) - self:addChild(btn) -end - -function UIFocusTestNestedLayout2.create() - local scene = cc.Scene:create() - local layer = UIFocusTestNestedLayout2.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIFocusTestNestedLayout3 = class("UIFocusTestNestedLayout3",UIScene) - -function UIFocusTestNestedLayout3.extend( target ) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIFocusTestNestedLayout3) - return target -end - -function UIFocusTestNestedLayout3:initExtend() - self:init() - - local root = self._uiLayer:getChildByTag(81) - local background = root:getChildByName("background_Panel") - background:removeFromParent(true) - - local function onLeftKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_LEFT, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onRightKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_RIGHT, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onUpKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_UP, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - local function onDownKeyPressed() - local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_DOWN, false) - cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) - end - - self._dpadMenu = cc.Menu:create() - local winSize = cc.Director:getInstance():getVisibleSize() - - local leftItem = cc.MenuItemFont:create("Left") - leftItem:setPosition(cc.p(winSize.width - 100, winSize.height/2)) - leftItem:registerScriptTapHandler(onLeftKeyPressed) - self._dpadMenu:addChild(leftItem) - - local rightItem = cc.MenuItemFont:create("Right") - rightItem:setPosition(cc.p(winSize.width - 30, winSize.height/2)) - rightItem:registerScriptTapHandler(onRightKeyPressed) - self._dpadMenu:addChild(rightItem) - - local upItem = cc.MenuItemFont:create("Up") - upItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 + 50)) - upItem:registerScriptTapHandler(onUpKeyPressed) - self._dpadMenu:addChild(upItem) - - local downItem = cc.MenuItemFont:create("Down") - downItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 - 50)) - downItem:registerScriptTapHandler(onDownKeyPressed) - self._dpadMenu:addChild(downItem) - self._dpadMenu:setPosition(cc.p(0, 0)) - self._uiLayer:addChild(self._dpadMenu) - - ccui.Widget:enableDpadNavigation(true) - - local function onFocusChanged(widgetLostFocus,widgetGetFocus) - if nil ~= widgetGetFocus and widgetGetFocus:isFocusEnabled() then - widgetGetFocus:setColor(cc.c3b(255, 0, 0)) - end - - if nil ~= widgetLostFocus and widgetLostFocus:isFocusEnabled() then - widgetLostFocus:setColor(cc.c3b(255, 255, 255)) - end - - if nil ~= widgetLostFocus and nil ~= widgetGetFocus then - print(string.format("on focus change, %d widget get focus, %d widget lose focus", widgetGetFocus:getTag(), widgetLostFocus:getTag())) - end - end - - local eventListener = cc.EventListenerFocus:create() - eventListener:registerScriptHandler(onFocusChanged) - local eventDispatcher = self:getEventDispatcher() - eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) - - local winSize = cc.Director:getInstance():getVisibleSize() - - self._verticalLayout = ccui.VBox:create() - self._verticalLayout:setPosition(cc.p(40, winSize.height - 70)) - self._uiLayer:addChild(self._verticalLayout) - self._verticalLayout:setScale(0.8) - - self._verticalLayout:setFocused(true) - self._verticalLayout:setLoopFocus(true) - self._verticalLayout:setTag(-1000) - self._firstFocusedWidget = self._verticalLayout - - local upperHBox = ccui.HBox:create() - upperHBox:setTag(-200) - self._verticalLayout:addChild(upperHBox) - - local params = ccui.LinearLayoutParameter:create() - params:setMargin({left = 0, top = 0, right = 50, bottom = 0}) - - local vparams = ccui.LinearLayoutParameter:create() - vparams:setMargin({left = 10, top = 0, right = 0, bottom = 140}) - upperHBox:setLayoutParameter(vparams) - - local function onImageViewClicked(sender, eventType) - if eventType == ccui.TouchEventType.ended then - local w = sender - if w:isFocusEnabled() then - w:setFocusEnabled(false) - w:setColor(cc.c3b(255, 255, 0)) - else - w:setFocusEnabled(true) - w:setColor(cc.c3b(255, 255, 255)) - end - end - end - - local count = 3 - for i = 1, count do - local firstVbox = ccui.VBox:create() - firstVbox:setScale(0.5) - firstVbox:setLayoutParameter(params) - firstVbox:setTag(i * 100) - - local count1 = 3 - for j = 1, count1 do - local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") - imageView:setTouchEnabled(true) - imageView:setTag(j + firstVbox:getTag()) - imageView:addTouchEventListener(onImageViewClicked) - firstVbox:addChild(imageView) - end - - upperHBox:addChild(firstVbox) - end - - local bottomHBox = ccui.HBox:create() - bottomHBox:setScale(0.5) - bottomHBox:setTag(600) - bottomHBox:setLayoutParameter(vparams) - - count = 3 - local bottomParams = ccui.LinearLayoutParameter:create() - bottomParams:setMargin({left = 0, top = 0, right = 8, bottom = 0}) - for i = 1, count do - local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") - imageView:setLayoutParameter(bottomParams) - imageView:setTouchEnabled(true) - imageView:setTag(i + 600) - imageView:addTouchEventListener(onImageViewClicked) - bottomHBox:addChild(imageView) - end - - self._verticalLayout:addChild(bottomHBox) - - self._loopText = ccui.Text:create("loop enabled", "Arial", 20) - self._loopText:setPosition(cc.p(winSize.width/2, winSize.height - 50)) - self._loopText:setColor(cc.c3b(255, 0 ,0)) - self:addChild(self._loopText) - - local function toggleFocusLoop(sender, eventType) - if eventType == ccui.TouchEventType.ended then - self._verticalLayout:setLoopFocus(not self._verticalLayout:isLoopFocus()) - if self._verticalLayout:isLoopFocus() then - self._loopText:setString("loop enabled") - else - self._loopText:setString("loop disabled") - end - end - end - - local btn = ccui.Button:create("cocosui/switch-mask.png") - btn:setTitleText("Toggle Loop") - btn:setPosition(cc.p(60, winSize.height - 50)) - btn:setTitleColor(cc.c3b(0, 255, 0)) - btn:addTouchEventListener(toggleFocusLoop) - self:addChild(btn) -end - -function UIFocusTestNestedLayout3.create() - local scene = cc.Scene:create() - local layer = UIFocusTestNestedLayout3.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local UIS9NinePatchTest = class("UIS9NinePatchTest",UIScene) - -function UIS9NinePatchTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIS9NinePatchTest) - return target -end - -function UIS9NinePatchTest:initExtend() - self:init() - - local widgetSize = self._widget:getContentSize() - self._displayValueLabel = ccui.Text:create() - self._displayValueLabel:setString("UIS9NinePatchTest") - self._displayValueLabel:setFontName(font_TextName) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getContentSize().height * 1.8)) - self._uiLayer:addChild(self._displayValueLabel) - - cc.SpriteFrameCache:getInstance():addSpriteFrames("cocosui/android9patch.plist") - - local winSize = cc.Director:getInstance():getWinSize() - local x = winSize.width / 2 - local y = 0 + (winSize.height / 2 + 50) - - local preferedSize = cc.size(99,99) - - --9-patch sprite with filename - local playerSprite = ccui.Scale9Sprite:create("cocosui/player.9.png") - playerSprite:setPosition(x, y) - playerSprite:setContentSize(preferedSize) - local capInsets = playerSprite:getCapInsets() - print(string.format("player sprite capInset = %f, %f %f, %f", capInsets.x, - capInsets.y, capInsets.width, capInsets.height)) - self:addChild(playerSprite) - - local animationBtnSprite = ccui.Scale9Sprite:createWithSpriteFrameName("animationbuttonpressed.png") - animationBtnSprite:setPosition(x-100, y-100) - capInsets = animationBtnSprite:getCapInsets() - print(string.format("animationBtnSprite capInset = %f, %f %f, %f", capInsets.x, - capInsets.y, capInsets.width, capInsets.height)) - self:addChild(animationBtnSprite) - - - local monsterSprite = ccui.Scale9Sprite:createWithSpriteFrameName("monster.9.png") - monsterSprite:setPosition(x+100, y-100) - capInsets = monsterSprite:getCapInsets() - monsterSprite:setContentSize(preferedSize) - print(string.format("monsterSprite capInset = %f, %f %f, %f", capInsets.x, - capInsets.y, capInsets.width, capInsets.height)) - self:addChild(monsterSprite) - - local spriteFrame = cc.SpriteFrameCache:getInstance():getSpriteFrame("buttonnormal.9.png") - local buttonScale9Sprite = ccui.Scale9Sprite:createWithSpriteFrame(spriteFrame) - buttonScale9Sprite:setContentSize(cc.size(150,80)) - buttonScale9Sprite:setPosition(cc.p(100,200)) - self:addChild(buttonScale9Sprite) -end - -function UIS9NinePatchTest.create() - local scene = cc.Scene:create() - local layer = UIS9NinePatchTest.extend(cc.Layer:create()) - layer:initExtend() - scene:addChild(layer) - return scene -end - -local cocoStudioGuiArray = -{ - { - title = "UIFocusTestHorizontal", - func = function () - return UIFocusTestHorizontal.create() - end, - }, - - { - title = "UIFocusTestVertical", - func = function () - return UIFocusTestVertical.create() - end, - }, - - { - title = "UIFocusTestNestedLayout1", - func = function () - return UIFocusTestNestedLayout1.create() - end, - }, - - { - title = "UIFocusTestNestedLayout2", - func = function () - return UIFocusTestNestedLayout2.create() - end, - }, - - { - title = "UIFocusTestNestedLayout3", - func = function () - return UIFocusTestNestedLayout3.create() - end, - }, - - { - title = "UIButtonTest", - func = function () - return UIButtonTest.create() - end, - }, - - { - title = "UIButtonScale9Test", - func = function () - return UIButtonScale9Test.create() - end, - }, - - { - title = "ButtonPressedActionTest", - func = function () - return UIButtonPressedActionTest.create() - end, - }, - - { - title = "UITextButtonTest", - func = function () - return UITextButtonTest.create() - end, - }, - - { - title = "UITextButtonScale9Test", - func = function () - return UITextButtonScale9Test.create() - end, - }, - - { - title = "UICheckBoxTest", - func = function () - return UICheckBoxTest.create() - end, - }, - - { - title = "UISliderTest", - func = function () - return UISliderTest.create() - end, - }, - - { - title = "UISliderScale9Test", - func = function () - return UISliderScale9Test.create() - end, - }, - - { - title = "UIImageViewTest", - func = function ( ) - return UIImageViewTest.create() - end, - }, - - { - title = "UIImageViewScale9Test", - func = function ( ) - return UIImageViewScale9Test.create() - end, - }, - - { - title = "UILoadingBarLeftTest", - func = function ( ) - return UILoadingBarLeftTest.create() - end, - }, - - { - title = "UILoadingBarRightTest", - func = function ( ) - return UILoadingBarRightTest.create() - end, - }, - - { - title = "UILoadingBarLeftScale9Test", - func = function ( ) - return UILoadingBarLeftScale9Test.create() - end, - }, - - { - title = "UILoadingBarRightScale9Test", - func = function ( ) - return UILoadingBarRightScale9Test.create() - end, - }, - - { - title = "UILabelAtlasTest", - func = function ( ) - return UILabelAtlasTest.create() - end, - }, - - { - title = "UILabelBMFontTest", - func = function ( ) - return UILabelBMFontTest.create() - end, - }, - - { - title = "UILabelTest", - func = function ( ) - return UILabelTest.create() - end, - }, - - { - title = "UITextAreaTest", - func = function ( ) - return UITextAreaTest.create() - end, - }, - - { - title = "UITextFieldTest", - func = function ( ) - return UITextFieldTest.create() - end, - }, - - { - title = "UITextFieldMaxLengthTest", - func = function ( ) - return UITextFieldMaxLengthTest.create() - end, - }, - - { - title = "UITextFieldPasswordTest", - func = function ( ) - return UITextFieldPasswordTest.create() - end, - }, - - { - title = "UIPanelTest", - func = function ( ) - return UIPanelTest.create() - end, - }, - - { - title = "UIPanelColorTest", - func = function ( ) - return UIPanelColorTest.create() - end, - }, - - { - title = "UIPanelGradientTest", - func = function ( ) - return UIPanelGradientTest.create() - end, - }, - - { - title = "UIPanelBackGroundImageTest", - func = function ( ) - return UIPanelBackGroundImageTest.create() - end, - }, - - { - title = "UIPanelBackGroundImageScale9Test", - func = function ( ) - return UIPanelBackGroundImageScale9Test.create() - end, - }, - - { - title = "UIPanelLayoutLinearVerticalTest", - func = function ( ) - return UIPanelLayoutLinearVerticalTest.create() - end, - }, - - { - title = "UIPanelLayoutLinearHorizontalTest", - func = function ( ) - return UIPanelLayoutLinearHorizontalTest.create() - end, - }, - - { - title = "UILayoutComponentBerthTest", - func = function() - return UILayoutComponentBerthTest.create() - end - }, - - { - title = "UILayoutComponentBerthStretchTest", - func = function() - return UILayoutComponentBerthStretchTest.create() - end - }, - - { - title = "UIScrollViewVerticalTest", - func = function ( ) - return UIScrollViewVerticalTest.create() - end, - }, - - { - title = "UIScrollViewHorizontalTest", - func = function ( ) - return UIScrollViewHorizontalTest.create() - end, - }, - - { - title = "UIPageViewTest", - func = function ( ) - return UIPageViewTest.create() - end, - }, - - { - title = "UIListViewVerticalTest", - func = function () - return UIListViewVerticalTest.create() - end, - }, - - { - title = "UIListViewHorizontalTest", - func = function () - return UIListViewHorizontalTest.create() - end, - }, - - { - title = "UIDragPanelTest", - func = function () - return UIDragPanelTest.create() - end, - }, - - { - title = "UIDragPanelBounceTest", - func = function () - return UIDragPanelBounceTest.create() - end, - }, - - { - title = "UINodeContainerTest", - func = function () - return UINodeContainerTest.create() - end, - }, - - { - title = "UIRichTextTest", - func = function() - return UIRichTextTest.create() - end - }, - { - title = "UIS9NinePatchTest", - func = function() - return UIS9NinePatchTest.create() - end - }, + table.insert(cocoStudioGuiArray, + { + title = classname, + func = function() + return newclass.create() + end + } + ) + return newclass + end, } +local function add_new_testcase(fn) + setfenv(fn, setmetatable(dsl_env, + { + __index = function(self, funName) + return _G[funName] + end + })) + + return fn() +end + +add_new_testcase(function() + local UIButtonTest = create("UIButtonTest", UIScene) + + function UIButtonTest:initExtend() + + local widgetSize = self._widget:getContentSize() + self._displayValueLabel:setString("No Event") + + local alert = ccui.Text:create() + alert:setString("Button") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + local function touchEvent(sender,eventType) + if eventType == ccui.TouchEventType.began then + self._displayValueLabel:setString("Touch Down") + elseif eventType == ccui.TouchEventType.moved then + self._displayValueLabel:setString("Touch Move") + elseif eventType == ccui.TouchEventType.ended then + self._displayValueLabel:setString("Touch Up") + elseif eventType == ccui.TouchEventType.canceled then + self._displayValueLabel:setString("Touch Cancelled") + end + end + local button = ccui.Button:create() + button:setTouchEnabled(true) + button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") + button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + button:addTouchEventListener(touchEvent) + self._uiLayer:addChild(button) + end + +end) + +add_new_testcase(function() + local UIButtonScale9Test = create("UIButtonScale9Test", UIScene) + + function UIButtonScale9Test:initExtend() + local widgetSize = self._widget:getContentSize() + self._displayValueLabel:setString("No Event") + + local alert = ccui.Text:create() + alert:setString("Button scale9 render") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + local function touchEvent(sender,eventType) + if eventType == ccui.TouchEventType.began then + self._displayValueLabel:setString("Touch Down") + elseif eventType == ccui.TouchEventType.moved then + self._displayValueLabel:setString("Touch Move") + elseif eventType == ccui.TouchEventType.ended then + self._displayValueLabel:setString("Touch Up") + elseif eventType == ccui.TouchEventType.canceled then + self._displayValueLabel:setString("Touch Cancelled") + end + end + + local button = ccui.Button:create() + button:setTouchEnabled(true) + button:setScale9Enabled(true) + button:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") + button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + button:setContentSize(cc.size(150, button:getVirtualRendererSize().height * 1.5)) + button:addTouchEventListener(touchEvent) + self._uiLayer:addChild(button) + end + +end) + +add_new_testcase(function() + local UIButtonPressedActionTest = create("UIButtonPressedActionTest",UIScene) + function UIButtonPressedActionTest:initExtend() + local widgetSize = self._widget:getContentSize() + self._displayValueLabel:setString("No Event") + + local alert = ccui.Text:create() + alert:setString("Button Pressed Action") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + local function touchEvent(sender,eventType) + if eventType == ccui.TouchEventType.began then + self._displayValueLabel:setString("Touch Down") + elseif eventType == ccui.TouchEventType.moved then + self._displayValueLabel:setString("Touch Move") + elseif eventType == ccui.TouchEventType.ended then + self._displayValueLabel:setString("Touch Up") + elseif eventType == ccui.TouchEventType.canceled then + self._displayValueLabel:setString("Touch Cancelled") + end + end + + local button = ccui.Button:create() + button:setTouchEnabled(true) + button:setPressedActionEnabled(true) + button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") + button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + button:addTouchEventListener(touchEvent) + self._uiLayer:addChild(button) + end +end) + +add_new_testcase(function() + local UITextButtonTest = create("UITextButtonTest",UIScene) + + function UITextButtonTest:initExtend() + local widgetSize = self._widget:getContentSize() + self._displayValueLabel:setString("No Event") + + local alert = ccui.Text:create() + alert:setString("TextButton") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + local function touchEvent(sender,eventType) + if eventType == ccui.TouchEventType.began then + self._displayValueLabel:setString("Touch Down") + elseif eventType == ccui.TouchEventType.moved then + self._displayValueLabel:setString("Touch Move") + elseif eventType == ccui.TouchEventType.ended then + self._displayValueLabel:setString("Touch Up") + elseif eventType == ccui.TouchEventType.canceled then + self._displayValueLabel:setString("Touch Cancelled") + end + end + + local textButton = ccui.Button:create() + textButton:setTouchEnabled(true) + textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") + textButton:setTitleText("Text Button") + textButton:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + textButton:addTouchEventListener(touchEvent) + self._uiLayer:addChild(textButton) + end +end) + +add_new_testcase(function() + local UITextButtonScale9Test = create("UITextButtonScale9Test",UIScene) + + function UITextButtonScale9Test:initExtend() + local widgetSize = self._widget:getContentSize() + self._displayValueLabel:setString("No Event") + + local alert = ccui.Text:create() + alert:setString("TextButton scale9 render") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + local function touchEvent(sender,eventType) + if eventType == ccui.TouchEventType.began then + self._displayValueLabel:setString("Touch Down") + elseif eventType == ccui.TouchEventType.moved then + self._displayValueLabel:setString("Touch Move") + elseif eventType == ccui.TouchEventType.ended then + self._displayValueLabel:setString("Touch Up") + elseif eventType == ccui.TouchEventType.canceled then + self._displayValueLabel:setString("Touch Cancelled") + end + end + + local textButton = ccui.Button:create() + textButton:setTouchEnabled(true) + textButton:setScale9Enabled(true) + textButton:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") + textButton:setContentSize(cc.size(180, textButton:getVirtualRendererSize().height * 1.5)) + textButton:setTitleText("Text Button scale9 render") + textButton:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + textButton:addTouchEventListener(touchEvent) + self._uiLayer:addChild(textButton) + end + +end) + +add_new_testcase(function() + local UICheckBoxTest = create("UICheckBoxTest",UIScene) + + function UICheckBoxTest:initExtend() + local widgetSize = self._widget:getContentSize() + self._displayValueLabel:setString("No Event") + + local alert = ccui.Text:create() + alert:setString("CheckBox") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + local function selectedEvent(sender,eventType) + if eventType == ccui.CheckBoxEventType.selected then + self._displayValueLabel:setString("Selected") + elseif eventType == ccui.CheckBoxEventType.unselected then + self._displayValueLabel:setString("Unselected") + end + end + + local checkBox = ccui.CheckBox:create() + checkBox:setTouchEnabled(true) + checkBox:setSelectedState(true) + checkBox:loadTextures("cocosui/check_box_normal.png", + "cocosui/check_box_normal_press.png", + "cocosui/check_box_active.png", + "cocosui/check_box_normal_disable.png", + "cocosui/check_box_active_disable.png") + checkBox:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + + checkBox:addEventListener(selectedEvent) + + self._uiLayer:addChild(checkBox) + end + +end) + +add_new_testcase(function() + local UIRadioBoxTest = create("UIRadioBoxTest",UIScene) + + function UIRadioBoxTest:initExtend() + local widgetSize = self._widget:getContentSize() + + local alert = ccui.Text:create() + alert:setString("No selection is disallowed.") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + 70)) + self._uiLayer:addChild(alert) + + local radioButtonGroup = ccui.RadioButtonGroup:create() + self._uiLayer:addChild(radioButtonGroup) + + local NUMBER_OF_BUTTONS = 5 + local BUTTON_WIDTH = 30 + local startPosX = widgetSize.width / 2.0 - ((NUMBER_OF_BUTTONS - 1) / 1.0) * BUTTON_WIDTH + for i = 0 , NUMBER_OF_BUTTONS-1 do + local radioButton = ccui.RadioButton:create("cocosui/radio_button_off.png", "cocosui/radio_button_on.png") + local posX = startPosX + BUTTON_WIDTH * i + radioButton:setPosition(cc.p(posX, widgetSize.height / 2.0 + 10)) + radioButtonGroup:addRadioButton(radioButton) + self._uiLayer:addChild(radioButton) + end + + local function buttonClickCallback(sender) + local name = (tolua.cast(sender, "ccui.Button")):getTitleText() + if name == "Add" then + local pos = cc.p(0,0) + if radioButtonGroup:getNumberOfRadioButtons() > 0 then + local lastRadioButton = radioButtonGroup:getRadioButtonByIndex(radioButtonGroup:getNumberOfRadioButtons() - 1) + pos.x, pos.y = lastRadioButton:getPosition() + else + pos.x = startPosX - BUTTON_WIDTH + pos.y = self._widget:getContentSize().height / 2. + 10 + end + local tempButton = ccui.RadioButton:create("cocosui/radio_button_off.png", "cocosui/radio_button_on.png") + pos.x = pos.x + BUTTON_WIDTH + tempButton:setPosition(pos) + radioButtonGroup:addRadioButton(tempButton) + self._uiLayer:addChild(tempButton) + elseif name == "Delete" then + if radioButtonGroup:getNumberOfRadioButtons() > 0 then + local radioButton = radioButtonGroup:getRadioButtonByIndex(radioButtonGroup:getNumberOfRadioButtons()-1) + radioButtonGroup:removeRadioButton(radioButton) + self._uiLayer:removeChild(radioButton) + end + elseif name == "Toggle" then + radioButtonGroup:setAllowedNoSelection(not radioButtonGroup:isAllowedNoSelection()) + alert:setString(radioButtonGroup:isAllowedNoSelection() and "No selection is allowed" or "No selection is disallowed") + end + end + + local hbox = ccui.HBox:create() + hbox:setPosition(cc.p(10, widgetSize.height/2-65)) + self._uiLayer:addChild(hbox) + + local addButton = ccui.Button:create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png") + addButton:setTitleText("Add") + addButton:setScale(0.7) + addButton:addClickEventListener(buttonClickCallback) + hbox:addChild(addButton) + + local deleteButton = addButton:clone() + deleteButton:setTitleText("Delete") + hbox:addChild(deleteButton) + + local toggleButton = addButton:clone() + toggleButton:setTitleText("Toggle") + hbox:addChild(toggleButton) + + end + +end) + +add_new_testcase(function() + local UISliderTest = create("UISliderTest",UIScene) + + function UISliderTest:initExtend() + local widgetSize = self._widget:getContentSize() + self._displayValueLabel:setString("Move the slider thumb") + + local alert = ccui.Text:create() + alert:setString("Slider") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + local function percentChangedEvent(sender,eventType) + print(eventType) + if eventType == ccui.SliderEventType.percentChanged then + local slider = sender + local percent = "Percent " .. (slider:getPercent() / slider:getMaxPercent() * 100) + self._displayValueLabel:setString(percent) + elseif eventType == ccui.SliderEventType.slideBallUp then + self._displayValueLabel:setString("Slide Ball Up") + elseif eventType == ccui.SliderEventType.slideBallDown then + self._displayValueLabel:setString("Slide Ball Down") + elseif eventType == ccui.SliderEventType.slideBallCancel then + self._displayValueLabel:setString("Slide Ball Cancel") + end + end + + local slider = ccui.Slider:create() + slider:setTouchEnabled(true) + slider:loadBarTexture("cocosui/sliderTrack.png") + slider:loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "") + slider:loadProgressBarTexture("cocosui/sliderProgress.png") + slider:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + slider:setMaxPercent(10000) + slider:addEventListener(percentChangedEvent) + + self._uiLayer:addChild(slider) + end + +end) + +add_new_testcase(function() + local UISliderScale9Test = create("UISliderScale9Test",UIScene) + + function UISliderScale9Test:initExtend() + local widgetSize = self._widget:getContentSize() + self._displayValueLabel:setString("Move the slider thumb") + + local alert = ccui.Text:create() + alert:setString("Slider scale9 render") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + local function percentChangedEvent(sender,eventType) + if eventType == ccui.SliderEventType.percentChanged then + local slider = sender + local percent = "Percent " .. slider:getPercent() + self._displayValueLabel:setString(percent) + end + end + + local slider = ccui.Slider:create() + slider:setTouchEnabled(true) + slider:loadBarTexture("cocosui/sliderTrack2.png") + slider:loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "") + slider:loadProgressBarTexture("cocosui/slider_bar_active_9patch.png") + slider:setScale9Enabled(true) + slider:setCapInsets(cc.rect(0, 0, 0, 0)) + slider:setContentSize(cc.size(250, 10)) + slider:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + slider:addEventListener(percentChangedEvent) + + self._uiLayer:addChild(slider) + end + +end) + +add_new_testcase(function() + local UIImageViewTest = create("UIImageViewTest",UIScene) + function UIImageViewTest:initExtend() + local widgetSize = self._widget:getContentSize() + + local alert = ccui.Text:create() + alert:setString("ImageView") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + local imageView = ccui.ImageView:create() + imageView:loadTexture("cocosui/ccicon.png") + imageView:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + imageView:getContentSize().height / 4.0)) + self._uiLayer:addChild(imageView) + end +end) + +add_new_testcase(function () + local UIImageViewScale9Test = create("UIImageViewScale9Test",UIScene) + function UIImageViewScale9Test:initExtend() + local widgetSize = self._widget:getContentSize() + + local alert = ccui.Text:create() + alert:setString("ImageView scale9 render") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + local imageView = ccui.ImageView:create() + imageView:setScale9Enabled(true) + imageView:loadTexture("cocosui/buttonHighlighted.png") + imageView:setContentSize(cc.size(200, 85)) + imageView:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + imageView:getContentSize().height / 4.0)) + self._uiLayer:addChild(imageView) + end +end) + +add_new_testcase(function () + local UILoadingBarLeftTest = create("UILoadingBarLeftTest",UIScene) + + function UILoadingBarLeftTest:initExtend() + self._count = 0 + + local widgetSize = self._widget:getContentSize() + + local alert = ccui.Text:create() + alert:setString("LoadingBar") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + local loadingBar = ccui.LoadingBar:create() + loadingBar:setTag(0) + loadingBar:setName("LoadingBar") + loadingBar:loadTexture("cocosui/sliderProgress.png") + loadingBar:setPercent(0) + + loadingBar:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + loadingBar:getContentSize().height / 4.0)) + self._uiLayer:addChild(loadingBar) + + local function update() + self._count = self._count + 1 + if self._count > 100 then + self._count = 0 + end + + if self._uiLayer ~= nil then + loadingBar:setPercent(self._count) + end + end + + self:scheduleUpdateWithPriorityLua(update, 0) + + local function onNodeEvent(tag) + if tag == "exit" then + self:unscheduleUpdate() + end + end + + self:registerScriptHandler(onNodeEvent) + + end + +end) + +add_new_testcase(function () + local UILoadingBarRightTest = create("UILoadingBarRightTest",UIScene) + + function UILoadingBarRightTest:initExtend() + self._count = 0; + + local widgetSize = self._widget:getContentSize() + + local alert = ccui.Text:create() + alert:setString("LoadingBar") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + local loadingBar = ccui.LoadingBar:create() + loadingBar:setTag(0) + loadingBar:setName("LoadingBar") + loadingBar:loadTexture("cocosui/sliderProgress.png") + loadingBar:setDirection(ccui.LoadingBarDirection.RIGHT) + loadingBar:setPercent(0) + + loadingBar:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + loadingBar:getContentSize().height / 4.0)) + self._uiLayer:addChild(loadingBar) + + local function update() + self._count = self._count + 1 + if self._count > 100 then + self._count = 0 + end + + if self._uiLayer ~= nil then + loadingBar:setPercent(self._count) + end + end + + self:scheduleUpdateWithPriorityLua(update, 0) + + local function onNodeEvent(tag) + if tag == "exit" then + self:unscheduleUpdate() + end + end + + self:registerScriptHandler(onNodeEvent) + + end + +end) + +add_new_testcase(function () + local UILoadingBarLeftScale9Test = create("UILoadingBarLeftScale9Test",UIScene) + function UILoadingBarLeftScale9Test:initExtend() + self._count = 0 + local widgetSize = self._widget:getContentSize() + + local alert = ccui.Text:create() + alert:setString("LoadingBar Scale9 Render") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + local loadingBar = ccui.LoadingBar:create() + loadingBar:setTag(0) + loadingBar:setName("LoadingBar") + loadingBar:loadTexture("cocosui/slider_bar_active_9patch.png") + loadingBar:setScale9Enabled(true) + loadingBar:setCapInsets(cc.rect(0, 0, 0, 0)) + loadingBar:setContentSize(cc.size(300, 30)) + loadingBar:setPercent(0) + + loadingBar:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + loadingBar:getContentSize().height / 4.0)) + self._uiLayer:addChild(loadingBar) + + local function update() + self._count = self._count + 1 + if self._count > 100 then + self._count = 0 + end + + if self._uiLayer ~= nil then + loadingBar:setPercent(self._count) + end + end + + self:scheduleUpdateWithPriorityLua(update, 0) + + local function onNodeEvent(tag) + if tag == "exit" then + self:unscheduleUpdate() + end + end + + self:registerScriptHandler(onNodeEvent) + + end +end) + +add_new_testcase(function () + local UILoadingBarRightScale9Test = create("UILoadingBarRightScale9Test",UIScene) + + function UILoadingBarRightScale9Test:initExtend() + self._count = 0 + local widgetSize = self._widget:getContentSize() + + local alert = ccui.Text:create() + alert:setString("LoadingBar Scale9 Render") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + local loadingBar = ccui.LoadingBar:create() + loadingBar:setTag(0) + loadingBar:setName("LoadingBar") + loadingBar:loadTexture("cocosui/slider_bar_active_9patch.png") + loadingBar:setScale9Enabled(true) + loadingBar:setCapInsets(cc.rect(0, 0, 0, 0)) + loadingBar:setContentSize(cc.size(300, 30)) + loadingBar:setDirection(ccui.LoadingBarDirection.RIGHT) + loadingBar:setPercent(0) + + loadingBar:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + loadingBar:getContentSize().height / 4.0)) + self._uiLayer:addChild(loadingBar) + + local function update() + self._count = self._count + 1 + if self._count > 100 then + self._count = 0 + end + + if self._uiLayer ~= nil then + loadingBar:setPercent(self._count) + end + end + + self:scheduleUpdateWithPriorityLua(update, 0) + + local function onNodeEvent(tag) + if tag == "exit" then + self:unscheduleUpdate() + end + end + + self:registerScriptHandler(onNodeEvent) + + end +end) + +add_new_testcase(function () + local UILabelAtlasTest = create("UILabelAtlasTest",UIScene) + + function UILabelAtlasTest:initExtend() + local widgetSize = self._widget:getContentSize() + + local alert = ccui.Text:create() + alert:setString("LabelAtlas") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + + local labelAtlas = ccui.TextAtlas:create() + if cc.Director:getInstance():getWinSizeInPixels().height > 320 then + labelAtlas:setProperty("1234567890", "cocosui/labelatlas.png", 34, 44, "0") + else + labelAtlas:setProperty("1234567890", "cocosui/labelatlas.png", 17, 22, "0") + end + + labelAtlas:setPosition(cc.p((widgetSize.width) / 2, widgetSize.height / 2.0)) + + self._uiLayer:addChild(labelAtlas) + end + +end) + +add_new_testcase(function () + local UILabelBMFontTest = create("UILabelBMFontTest",UIScene) + + function UILabelBMFontTest:initExtend() + local widgetSize = self._widget:getContentSize() + + local alert = ccui.Text:create() + alert:setString("LabelBMFont") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + + local labelBMFont = ccui.TextBMFont:create() + labelBMFont:setFntFile("cocosui/bitmapFontTest2.fnt") + labelBMFont:setString("BMFont") + labelBMFont:setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2.0 + labelBMFont:getContentSize().height / 8.0)) + + self._uiLayer:addChild(labelBMFont) + end + +end) + +add_new_testcase(function() + local UILabelTest = create("UILabelTest",UIScene) + + function UILabelTest:initExtend() + local widgetSize = self._widget:getContentSize() + + local alert = ccui.Text:create() + alert:setString("Label") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + local label = ccui.Text:create() + label:setString("Label") + label:setFontName("AmericanTypewriter") + label:setFontSize(30) + label:setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 + label:getContentSize().height / 4)) + self._uiLayer:addChild(label) + end +end) + +add_new_testcase(function() + local UITextAreaTest = create("UITextAreaTest",UIScene) + + function UITextAreaTest:initExtend() + local widgetSize = self._widget:getContentSize() + + local alert = ccui.Text:create() + alert:setString("TextArea") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + local textArea = ccui.Text:create() + textArea:ignoreContentAdaptWithSize(false) + textArea:setContentSize(cc.size(280, 150)) + textArea:setTextHorizontalAlignment(cc.TEXT_ALIGNMENT_CENTER) + textArea:setString("TextArea widget can line wrap") + textArea:setFontName("AmericanTypewriter") + textArea:setFontSize(32) + textArea:setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 - textArea:getContentSize().height / 8)) + self._uiLayer:addChild(textArea) + end +end) + +add_new_testcase(function() + local UITextFieldTest = create("UITextFieldTest",UIScene) + + function UITextFieldTest:initExtend() + local widgetSize = self._widget:getContentSize() + self._displayValueLabel:setString("No Event") + + local alert = ccui.Text:create() + alert:setString("TextField") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + local function textFieldEvent(sender, eventType) + if eventType == ccui.TextFiledEventType.attach_with_ime then + local textField = sender + textField:runAction(cc.MoveBy:create(0.225,cc.p(0, 20))) + self._displayValueLabel:setString("attach with IME") + elseif eventType == ccui.TextFiledEventType.detach_with_ime then + local textField = sender + textField:runAction(cc.MoveBy:create(0.175, cc.p(0, -20))) + self._displayValueLabel:setString("detach with IME") + elseif eventType == ccui.TextFiledEventType.insert_text then + self._displayValueLabel:setString("insert words") + elseif eventType == ccui.TextFiledEventType.delete_backward then + self._displayValueLabel:setString("delete word") + end + end + + local textField = ccui.TextField:create() + textField:setTouchEnabled(true) + textField:setFontName(font_TextName) + textField:setFontSize(30) + textField:setPlaceHolder("input words here") + textField:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + textField:addEventListener(textFieldEvent) + self._uiLayer:addChild(textField) + end +end) + +add_new_testcase(function() + local UITextFieldMaxLengthTest = create("UITextFieldMaxLengthTest",UIScene) + + function UITextFieldMaxLengthTest:initExtend() + local widgetSize = self._widget:getContentSize() + + self._displayValueLabel:setString("No Event") + + local alert = ccui.Text:create() + alert:setString("TextField max length") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + local function textFieldEvent(sender, eventType) + if eventType == ccui.TextFiledEventType.attach_with_ime then + local textField = sender + textField:runAction(cc.MoveBy:create(0.225,cc.p(0, 20))) + local info = string.format("attach with IME max length %d",textField:getMaxLength()) + self._displayValueLabel:setString(info) + elseif eventType == ccui.TextFiledEventType.detach_with_ime then + local textField = sender + textField:runAction(cc.MoveBy:create(0.175, cc.p(0, -20))) + local info = string.format("detach with IME max length %d",textField:getMaxLength()) + self._displayValueLabel:setString(info) + elseif eventType == ccui.TextFiledEventType.insert_text then + local textField = sender + local info = string.format("insert words max length %d",textField:getMaxLength()) + self._displayValueLabel:setString(info) + elseif eventType == ccui.TextFiledEventType.delete_backward then + local textField = sender + local info = string.format("delete word max length %d",textField:getMaxLength()) + self._displayValueLabel:setString(info) + end + end + + local textField = ccui.TextField:create() + textField:setMaxLengthEnabled(true) + textField:setMaxLength(3) + textField:setTouchEnabled(true) + textField:setFontName(font_TextName) + textField:setFontSize(30) + textField:setPlaceHolder("input words here") + textField:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + textField:addEventListener(textFieldEvent) + self._uiLayer:addChild(textField) + end +end) + +add_new_testcase(function() + local UITextFieldPasswordTest = create("UITextFieldPasswordTest",UIScene) + + function UITextFieldPasswordTest:initExtend() + local widgetSize = self._widget:getContentSize() + + self._displayValueLabel:setString("No Event") + + local alert = ccui.Text:create() + alert:setString("TextField password") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + local function textFieldEvent(sender, eventType) + if eventType == ccui.TextFiledEventType.attach_with_ime then + local textField = sender + textField:runAction(cc.MoveBy:create(0.175, cc.p(0, 20))) + self._displayValueLabel:setString("detach with IME password") + elseif eventType == ccui.TextFiledEventType.detach_with_ime then + local textField = sender + textField:runAction(cc.MoveBy:create(0.175, cc.p(0, -20))) + self._displayValueLabel:setString("detach with IME password") + elseif eventType == ccui.TextFiledEventType.insert_text then + self._displayValueLabel:setString("insert words password") + elseif eventType == ccui.TextFiledEventType.delete_backward then + self._displayValueLabel:setString("delete word password") + end + end + + local textField = ccui.TextField:create() + textField:setPasswordEnabled(true) + textField:setPasswordStyleText("*") + textField:setTouchEnabled(true) + textField:setFontName(font_TextName) + textField:setFontSize(30) + textField:setPlaceHolder("input password here") + textField:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + textField:addEventListener(textFieldEvent) + self._uiLayer:addChild(textField) + end +end) + +add_new_testcase(function() + local UIPanelTest = create("UIPanelTest",UIScene) + + function UIPanelTest:initExtend() + local widgetSize = self._widget:getContentSize() + + local alert = ccui.Text:create() + alert:setString("Panel") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + local root = self._uiLayer:getChildByTag(81) + local background = root:getChildByName("background_Panel") + + local layout = ccui.Layout:create() + layout:setContentSize(cc.size(280, 150)) + local backgroundSize = background:getContentSize() + layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + + (backgroundSize.width - layout:getContentSize().width) / 2, + (widgetSize.height - backgroundSize.height) / 2 + + (backgroundSize.height - layout:getContentSize().height) / 2)) + self._uiLayer:addChild(layout) + + local button = ccui.Button:create() + button:setTouchEnabled(true) + button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") + button:setPosition(cc.p(button:getContentSize().width / 2, layout:getContentSize().height - button:getContentSize().height / 2)) + layout:addChild(button) + + local textButton = ccui.Button:create() + textButton:setTouchEnabled(true) + textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") + textButton:setTitleText("Text Button") + textButton:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) + layout:addChild(textButton) + + local button_scale9 = ccui.Button:create() + button_scale9:setTouchEnabled(true) + button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") + button_scale9:setScale9Enabled(true) + button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) + button_scale9:setPosition(cc.p(layout:getContentSize().width - button_scale9:getContentSize().width / 2, button_scale9:getContentSize().height / 2)) + layout:addChild(button_scale9) + end +end) + +add_new_testcase(function() + local UIPanelColorTest = create("UIPanelColorTest",UIScene) + + function UIPanelColorTest:initExtend() + local widgetSize = self._widget:getContentSize() + + local alert = ccui.Text:create() + alert:setString("Panel color render") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) + self._uiLayer:addChild(alert) + + local root = self._uiLayer:getChildByTag(81) + local background = root:getChildByName("background_Panel") + + local layout = ccui.Layout:create() + layout:setBackGroundColorType(ccui.LayoutBackGroundColorType.solid) + layout:setBackGroundColor(cc.c3b(128, 128, 128)) + layout:setContentSize(cc.size(280, 150)) + local backgroundSize = background:getContentSize() + layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + + (backgroundSize.width - layout:getContentSize().width) / 2, + (widgetSize.height - backgroundSize.height) / 2 + + (backgroundSize.height - layout:getContentSize().height) / 2)) + self._uiLayer:addChild(layout) + + local button = ccui.Button:create() + button:setTouchEnabled(true) + button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") + button:setPosition(cc.p(button:getContentSize().width / 2, layout:getContentSize().height - button:getContentSize().height / 2)) + layout:addChild(button) + + local textButton = ccui.Button:create() + textButton:setTouchEnabled(true) + textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") + textButton:setTitleText("Text Button") + textButton:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) + layout:addChild(textButton) + + local button_scale9 = ccui.Button:create() + button_scale9:setTouchEnabled(true) + button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") + button_scale9:setScale9Enabled(true) + button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) + button_scale9:setPosition(cc.p(layout:getContentSize().width - button_scale9:getContentSize().width / 2, button_scale9:getContentSize().height / 2)) + layout:addChild(button_scale9) + end +end) + +add_new_testcase(function() + local UIPanelGradientTest = create("UIPanelGradientTest",UIScene) + + function UIPanelGradientTest:initExtend() + local widgetSize = self._widget:getContentSize() + + local alert = ccui.Text:create() + alert:setString("Panel color Gradient") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) + self._uiLayer:addChild(alert) + + local root = self._uiLayer:getChildByTag(81) + local background = root:getChildByName("background_Panel") + + local layout = ccui.Layout:create() + layout:setBackGroundColorType(ccui.LayoutBackGroundColorType.gradient) + layout:setBackGroundColor(cc.c3b(64, 64, 64), cc.c3b(192, 192, 192)) + layout:setContentSize(cc.size(280, 150)) + local backgroundSize = background:getContentSize() + layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + + (backgroundSize.width - layout:getContentSize().width) / 2, + (widgetSize.height - backgroundSize.height) / 2 + + (backgroundSize.height - layout:getContentSize().height) / 2)) + self._uiLayer:addChild(layout) + + local button = ccui.Button:create() + button:setTouchEnabled(true) + button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") + button:setPosition(cc.p(button:getContentSize().width / 2, layout:getContentSize().height - button:getContentSize().height / 2)) + layout:addChild(button) + + local textButton = ccui.Button:create() + textButton:setTouchEnabled(true) + textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") + textButton:setTitleText("Text Button") + textButton:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) + layout:addChild(textButton) + + local button_scale9 = ccui.Button:create() + button_scale9:setTouchEnabled(true) + button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") + button_scale9:setScale9Enabled(true) + button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) + button_scale9:setPosition(cc.p(layout:getContentSize().width - button_scale9:getContentSize().width / 2, button_scale9:getContentSize().height / 2)) + layout:addChild(button_scale9) + end +end) + +add_new_testcase(function() + local UIPanelBackGroundImageTest = create("UIPanelBackGroundImageTest",UIScene) + + function UIPanelBackGroundImageTest:initExtend() + local widgetSize = self._widget:getContentSize() + + local alert = ccui.Text:create() + alert:setString("Panel background image") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) + self._uiLayer:addChild(alert) + + local root = self._uiLayer:getChildByTag(81) + local background = root:getChildByName("background_Panel") + + local layout = ccui.Layout:create() + layout:setClippingEnabled(true) + layout:setBackGroundImage("cocosui/Hello.png") + layout:setContentSize(cc.size(280, 150)) + local backgroundSize = background:getContentSize() + layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + + (backgroundSize.width - layout:getContentSize().width) / 2, + (widgetSize.height - backgroundSize.height) / 2 + + (backgroundSize.height - layout:getContentSize().height) / 2)) + self._uiLayer:addChild(layout) + + local button = ccui.Button:create() + button:setTouchEnabled(true) + button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") + button:setPosition(cc.p(button:getContentSize().width / 2, layout:getContentSize().height - button:getContentSize().height / 2)) + layout:addChild(button) + + local textButton = ccui.Button:create() + textButton:setTouchEnabled(true) + textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") + textButton:setTitleText("Text Button") + textButton:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) + layout:addChild(textButton) + + local button_scale9 = ccui.Button:create() + button_scale9:setTouchEnabled(true) + button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") + button_scale9:setScale9Enabled(true) + button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) + button_scale9:setPosition(cc.p(layout:getContentSize().width - button_scale9:getContentSize().width / 2, button_scale9:getContentSize().height / 2)) + layout:addChild(button_scale9) + end +end) + +add_new_testcase(function() + local UIPanelBackGroundImageScale9Test = create("UIPanelBackGroundImageScale9Test",UIScene) + + function UIPanelBackGroundImageScale9Test:initExtend() + local widgetSize = self._widget:getContentSize() + + local alert = ccui.Text:create() + alert:setString("Panel background image scale9") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) + self._uiLayer:addChild(alert) + + local root = self._uiLayer:getChildByTag(81) + local background = root:getChildByName("background_Panel") + + local layout = ccui.Layout:create() + layout:setBackGroundImageScale9Enabled(true) + layout:setBackGroundImage("cocosui/green_edit.png") + layout:setContentSize(cc.size(280, 150)) + local backgroundSize = background:getContentSize() + layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + + (backgroundSize.width - layout:getContentSize().width) / 2, + (widgetSize.height - backgroundSize.height) / 2 + + (backgroundSize.height - layout:getContentSize().height) / 2)) + self._uiLayer:addChild(layout) + + local button = ccui.Button:create() + button:setTouchEnabled(true) + button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") + button:setPosition(cc.p(button:getContentSize().width / 2, layout:getContentSize().height - button:getContentSize().height / 2)) + layout:addChild(button) + + local textButton = ccui.Button:create() + textButton:setTouchEnabled(true) + textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") + textButton:setTitleText("Text Button") + textButton:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) + layout:addChild(textButton) + + local button_scale9 = ccui.Button:create() + button_scale9:setTouchEnabled(true) + button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") + button_scale9:setScale9Enabled(true) + button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) + button_scale9:setPosition(cc.p(layout:getContentSize().width - button_scale9:getContentSize().width / 2, button_scale9:getContentSize().height / 2)) + layout:addChild(button_scale9) + end +end) + +add_new_testcase(function() + local UIPanelLayoutLinearVerticalTest = create("UIPanelLayoutLinearVerticalTest",UIScene) + + function UIPanelLayoutLinearVerticalTest:initExtend() + local widgetSize = self._widget:getContentSize() + + local alert = ccui.Text:create() + alert:setString("Panel Layout Linear Vertical") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) + self._uiLayer:addChild(alert) + + local root = self._uiLayer:getChildByTag(81) + local background = root:getChildByName("background_Panel") + + local layout = ccui.Layout:create() + layout:setLayoutType(ccui.LayoutType.VERTICAL) + layout:setContentSize(cc.size(280, 150)) + local backgroundSize = background:getContentSize() + layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + + (backgroundSize.width - layout:getContentSize().width) / 2, + (widgetSize.height - backgroundSize.height) / 2 + + (backgroundSize.height - layout:getContentSize().height) / 2)) + self._uiLayer:addChild(layout) + + local button = ccui.Button:create() + button:setTouchEnabled(true) + button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") + layout:addChild(button) + + local lp1 = ccui.LinearLayoutParameter:create() + button:setLayoutParameter(lp1) + lp1:setGravity(ccui.LinearGravity.centerHorizontal) + lp1:setMargin({ left = 0, top = 5, right = 0, bottom = 10 }) + + + local textButton = ccui.Button:create() + textButton:setTouchEnabled(true) + textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") + textButton:setTitleText("Text Button") + layout:addChild(textButton) + + local lp2 = ccui.LinearLayoutParameter:create() + textButton:setLayoutParameter(lp2) + lp2:setGravity(ccui.LinearGravity.centerHorizontal) + lp2:setMargin({left = 0, top = 10, right = 0, bottom = 10} ) + + + local button_scale9 = ccui.Button:create() + button_scale9:setTouchEnabled(true) + button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") + button_scale9:setScale9Enabled(true) + button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) + layout:addChild(button_scale9) + + local lp3 = ccui.LinearLayoutParameter:create() + button_scale9:setLayoutParameter(lp3) + lp3:setGravity(ccui.LinearGravity.centerHorizontal) + lp3:setMargin({ left = 0, top = 10, right = 0, bottom = 10 } ) + end +end) + +add_new_testcase(function() + local UIPanelLayoutLinearHorizontalTest = create("UIPanelLayoutLinearHorizontalTest",UIScene) + + function UIPanelLayoutLinearHorizontalTest:initExtend() + local widgetSize = self._widget:getContentSize() + + local alert = ccui.Text:create() + alert:setString("Panel Layout Linear Horizontal") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) + self._uiLayer:addChild(alert) + + local root = self._uiLayer:getChildByTag(81) + local background = root:getChildByName("background_Panel") + + local layout = ccui.Layout:create() + layout:setLayoutType(ccui.LayoutType.HORIZONTAL) + layout:setClippingEnabled(true) + layout:setContentSize(cc.size(280, 150)) + local backgroundSize = background:getContentSize() + layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + + (backgroundSize.width - layout:getContentSize().width) / 2, + (widgetSize.height - backgroundSize.height) / 2 + + (backgroundSize.height - layout:getContentSize().height) / 2)) + self._uiLayer:addChild(layout) + + local button = ccui.Button:create() + button:setTouchEnabled(true) + button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") + layout:addChild(button) + + local lp1 = ccui.LinearLayoutParameter:create() + button:setLayoutParameter(lp1) + lp1:setGravity(ccui.LinearGravity.centerVertical) + lp1:setMargin({left = 0, top = 10, right = 0, bottom = 10} ) + + + local textButton = ccui.Button:create() + textButton:setTouchEnabled(true) + textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") + textButton:setTitleText("Text Button") + layout:addChild(textButton) + + local lp2 = ccui.LinearLayoutParameter:create() + textButton:setLayoutParameter(lp2) + lp2:setGravity(ccui.LinearGravity.centerVertical) + lp2:setMargin({left = 0,top = 10,right = 0,bottom = 10}) + + + local button_scale9 = ccui.Button:create() + button_scale9:setTouchEnabled(true) + button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") + button_scale9:setScale9Enabled(true) + button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) + layout:addChild(button_scale9) + + local lp3 = ccui.LinearLayoutParameter:create() + button_scale9:setLayoutParameter(lp3) + lp3:setGravity(ccui.LinearGravity.centerVertical) + lp3:setMargin({left = 0, top = 10, right = 0, bottom = 10}) + end +end) + +add_new_testcase(function() + local UILayoutComponentBerthTest = create("UILayoutComponentBerthTest",UIScene) + + function UILayoutComponentBerthTest:initExtend() + local widgetSize = self._widget:getContentSize() + + self._displayValueLabel:setString("LayoutComponent Berth Test") + + local baseLayer = cc.LayerColor:create() + baseLayer:setColor(cc.c3b(50, 100, 0)) + baseLayer:setOpacity(100) + baseLayer:setContentSize(cc.size(200, 200)) + self._uiLayer:addChild(baseLayer) + + button = ccui.Button:create("cocosui/animationbuttonnormal.png") + print(string.format("content size should be greater than 0: width = %f, height = %f", button:getContentSize().width, + button:getContentSize().height)) + button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + + button:addTouchEventListener(function(sender, eventType) + if eventType == ccui.TouchEventType.ended then + local touchWidgetSize = self._widget:getContentSize() + local layerSize = baseLayer:getContentSize() + if (layerSize.width == touchWidgetSize.width and layerSize.height == touchWidgetSize.height) then + baseLayer:setContentSize(cc.size(200, 200)) + else + baseLayer:setContentSize(widgetSize) + end + ccui.Helper:doLayout(baseLayer) + end + end) + button:setZoomScale(0.4) + button:setPressedActionEnabled(true) + self._uiLayer:addChild(button) + + + local leftTopSprite = cc.Sprite:create("cocosui/CloseSelected.png") + local leftTop = ccui.LayoutComponent:bindLayoutComponent(leftTopSprite) + leftTop:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Left) + leftTop:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Top) + baseLayer:addChild(leftTopSprite) + + local leftBottomSprite = cc.Sprite:create("cocosui/CloseSelected.png") + local leftBottom = ccui.LayoutComponent:bindLayoutComponent(leftBottomSprite) + leftBottom:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Left) + leftBottom:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Bottom) + baseLayer:addChild(leftBottomSprite) + + local rightTopSprite = cc.Sprite:create("cocosui/CloseSelected.png") + local rightTop = ccui.LayoutComponent:bindLayoutComponent(rightTopSprite) + rightTop:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Right) + rightTop:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Top) + baseLayer:addChild(rightTopSprite) + + local rightBottomSprite = cc.Sprite:create("cocosui/CloseSelected.png") + local rightBottom = ccui.LayoutComponent:bindLayoutComponent(rightBottomSprite) + rightBottom:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Right) + rightBottom:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Bottom) + baseLayer:addChild(rightBottomSprite) + + ccui.Helper:doLayout(baseLayer) + end +end) + +add_new_testcase(function() + local UILayoutComponentBerthStretchTest = create("UILayoutComponentBerthStretchTest",UIScene) + + function UILayoutComponentBerthStretchTest:initExtend() + local widgetSize = self._widget:getContentSize() + + self._displayValueLabel:setString("LayoutComponent Berth Stretch Test") + + local baseLayer = cc.LayerColor:create() + baseLayer:setColor(cc.c3b(50, 100, 0)) + baseLayer:setOpacity(100) + baseLayer:setContentSize(cc.size(200, 200)) + self._uiLayer:addChild(baseLayer) + + button = ccui.Button:create("cocosui/animationbuttonnormal.png") + print(string.format("content size should be greater than 0: width = %f, height = %f", button:getContentSize().width, + button:getContentSize().height)) + button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + + button:addTouchEventListener(function(sender, eventType) + if eventType == ccui.TouchEventType.ended then + local touchWidgetSize = self._widget:getContentSize() + local layerSize = baseLayer:getContentSize() + if (layerSize.width == touchWidgetSize.width and layerSize.height == touchWidgetSize.height) then + baseLayer:setContentSize(cc.size(200, 200)) + else + baseLayer:setContentSize(widgetSize) + end + ccui.Helper:doLayout(baseLayer) + end + end) + button:setZoomScale(0.4) + button:setPressedActionEnabled(true) + self._uiLayer:addChild(button) + + local leftTopSprite = ccui.ImageView:create("cocosui/CloseSelected.png") + leftTopSprite:ignoreContentAdaptWithSize(false) + local leftTop = ccui.LayoutComponent:bindLayoutComponent(leftTopSprite) + leftTop:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Left) + leftTop:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Top) + leftTop:setStretchWidthEnabled(true) + leftTop:setStretchHeightEnabled(true) + baseLayer:addChild(leftTopSprite) + leftTop:setSize(leftTopSprite:getContentSize()) + leftTop:setLeftMargin(0) + leftTop:setTopMargin(0) + + local leftBottomSprite = ccui.ImageView:create("cocosui/CloseSelected.png") + leftBottomSprite:ignoreContentAdaptWithSize(false) + local leftBottom = ccui.LayoutComponent:bindLayoutComponent(leftBottomSprite) + leftBottom:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Left) + leftBottom:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Bottom) + leftBottom:setStretchWidthEnabled(true) + leftBottom:setStretchHeightEnabled(true) + baseLayer:addChild(leftBottomSprite) + leftBottom:setSize(leftBottomSprite:getContentSize()) + leftBottom:setLeftMargin(0) + leftBottom:setBottomMargin(0) + + local rightTopSprite = ccui.ImageView:create("cocosui/CloseSelected.png") + rightTopSprite:ignoreContentAdaptWithSize(false) + local rightTop = ccui.LayoutComponent:bindLayoutComponent(rightTopSprite) + rightTop:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Right) + rightTop:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Top) + rightTop:setStretchWidthEnabled(true) + rightTop:setStretchHeightEnabled(true) + baseLayer:addChild(rightTopSprite) + rightTop:setSize(rightTopSprite:getContentSize()) + rightTop:setTopMargin(0) + rightTop:setRightMargin(0) + + local rightBottomSprite = ccui.ImageView:create("cocosui/CloseSelected.png") + rightBottomSprite:ignoreContentAdaptWithSize(false) + local rightBottom = ccui.LayoutComponent:bindLayoutComponent(rightBottomSprite) + rightBottom:setHorizontalEdge(ccui.LayoutComponent.HorizontalEdge.Right) + rightBottom:setVerticalEdge(ccui.LayoutComponent.VerticalEdge.Bottom) + rightBottom:setStretchWidthEnabled(true) + rightBottom:setStretchHeightEnabled(true) + baseLayer:addChild(rightBottomSprite) + rightBottom:setSize(rightBottomSprite:getContentSize()) + rightBottom:setBottomMargin(0) + rightBottom:setRightMargin(0) + ccui.Helper:doLayout(baseLayer) + end +end) + +add_new_testcase(function() + local UIScrollViewVerticalTest = create("UIScrollViewVerticalTest",UIScene) + + function UIScrollViewVerticalTest:initExtend() + local widgetSize = self._widget:getContentSize() + + self._displayValueLabel:setString("Move by vertical direction") + + local alert = ccui.Text:create() + alert:setString("ScrollView") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) + self._uiLayer:addChild(alert) + + local root = self._uiLayer:getChildByTag(81) + local background = root:getChildByName("background_Panel") + + local scrollView = ccui.ScrollView:create() + scrollView:setTouchEnabled(true) + scrollView:setContentSize(cc.size(280, 150)) + local backgroundSize = background:getContentSize() + scrollView:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + + (backgroundSize.width - scrollView:getContentSize().width) / 2, + (widgetSize.height - backgroundSize.height) / 2 + + (backgroundSize.height - scrollView:getContentSize().height) / 2)) + scrollView:setScrollBarWidth(4) + scrollView:setScrollBarPositionFromCorner(cc.p(2,2)) + scrollView:setScrollBarColor(cc.RED) + self._uiLayer:addChild(scrollView) + + local imageView = ccui.ImageView:create() + imageView:loadTexture("cocosui/ccicon.png") + + local innerWidth = scrollView:getContentSize().width + local innerHeight = scrollView:getContentSize().height + imageView:getContentSize().height + + scrollView:setInnerContainerSize(cc.size(innerWidth, innerHeight)) + + local button = ccui.Button:create() + button:setTouchEnabled(true) + button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") + button:setPosition(cc.p(innerWidth / 2, scrollView:getInnerContainerSize().height - button:getContentSize().height / 2)) + scrollView:addChild(button) + + local textButton = ccui.Button:create() + textButton:setTouchEnabled(true) + textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") + textButton:setTitleText("Text Button") + textButton:setPosition(cc.p(innerWidth / 2, button:getBottomBoundary() - button:getContentSize().height)) + scrollView:addChild(textButton) + + local button_scale9 = ccui.Button:create() + button_scale9:setTouchEnabled(true) + button_scale9:setScale9Enabled(true) + button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") + button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) + button_scale9:setPosition(cc.p(innerWidth / 2, textButton:getBottomBoundary() - textButton:getContentSize().height)) + scrollView:addChild(button_scale9) + + imageView:setPosition(cc.p(innerWidth / 2, imageView:getContentSize().height / 2)) + scrollView:addChild(imageView) + end +end) + +add_new_testcase(function() + local UIScrollViewHorizontalTest = create("UIScrollViewHorizontalTest",UIScene) + + function UIScrollViewHorizontalTest:initExtend() + local widgetSize = self._widget:getContentSize() + + self._displayValueLabel:setString("Move by horizontal direction") + + local alert = ccui.Text:create() + alert:setString("ScrollView") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) + self._uiLayer:addChild(alert) + + local root = self._uiLayer:getChildByTag(81) + local background = root:getChildByName("background_Panel") + + local scrollView = ccui.ScrollView:create() + scrollView:setBounceEnabled(true) + scrollView:setDirection(ccui.ScrollViewDir.horizontal) + scrollView:setTouchEnabled(true) + scrollView:setContentSize(cc.size(280, 150)) + scrollView:setInnerContainerSize(scrollView:getContentSize()) + local backgroundSize = background:getContentSize() + scrollView:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + + (backgroundSize.width - scrollView:getContentSize().width) / 2, + (widgetSize.height - backgroundSize.height) / 2 + + (backgroundSize.height - scrollView:getContentSize().height) / 2)) + self._uiLayer:addChild(scrollView) + + local imageView = ccui.ImageView:create() + imageView:loadTexture("cocosui/ccicon.png") + + local innerWidth = scrollView:getContentSize().width + imageView:getContentSize().width + local innerHeight = scrollView:getContentSize().height + + scrollView:setInnerContainerSize(cc.size(innerWidth, innerHeight)) + + local button = ccui.Button:create() + button:setTouchEnabled(true) + button:loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "") + button:setPosition(cc.p(button:getContentSize().width / 2, + scrollView:getInnerContainerSize().height - button:getContentSize().height / 2)) + scrollView:addChild(button) + + local textButton = ccui.Button:create() + textButton:setTouchEnabled(true) + textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") + textButton:setTitleText("Text Button") + textButton:setPosition(cc.p(button:getRightBoundary() + button:getContentSize().width / 2, + button:getBottomBoundary() - button:getContentSize().height / 2)) + scrollView:addChild(textButton) + + local button_scale9 = ccui.Button:create() + button_scale9:setTouchEnabled(true) + button_scale9:setScale9Enabled(true) + button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") + button_scale9:setContentSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) + button_scale9:setPosition(cc.p(textButton:getRightBoundary() + textButton:getContentSize().width / 2, + textButton:getBottomBoundary() - textButton:getContentSize().height / 2)) + scrollView:addChild(button_scale9) + + imageView:setPosition(cc.p(innerWidth - imageView:getContentSize().width / 2, + button_scale9:getBottomBoundary() - button_scale9:getContentSize().height / 2)) + scrollView:addChild(imageView) + end +end) + +add_new_testcase(function() + local UIPageViewTest = create("UIPageViewTest",UIScene) + function UIPageViewTest:initExtend() + local widgetSize = self._widget:getContentSize() + + self._displayValueLabel:setString("Move by horizontal direction") + + local alert = ccui.Text:create() + alert:setString("PageView") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) + self._uiLayer:addChild(alert) + + local root = self._uiLayer:getChildByTag(81) + local background = root:getChildByName("background_Panel") + + local pageView = ccui.PageView:create() + pageView:setTouchEnabled(true) + pageView:setContentSize(cc.size(240, 130)) + pageView:setDirection(ccui.PageViewDirection.HORIZONTAL) + local backgroundSize = background:getContentSize() + pageView:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + + (backgroundSize.width - pageView:getContentSize().width) / 2, + (widgetSize.height - backgroundSize.height) / 2 + + (backgroundSize.height - pageView:getContentSize().height) / 2)) + + for i = 1 , 3 do + local layout = ccui.Layout:create() + layout:setContentSize(cc.size(240, 130)) + + local imageView = ccui.ImageView:create() + imageView:setTouchEnabled(true) + imageView:setScale9Enabled(true) + imageView:loadTexture("cocosui/scrollviewbg.png") + imageView:setContentSize(cc.size(240, 130)) + imageView:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) + layout:addChild(imageView) + + local label = ccui.Text:create() + local pageInfo = string.format("page %d", i) + label:setString(pageInfo) + label:setFontName(font_TextName) + label:setFontSize(30) + label:setColor(cc.c3b(192, 192, 192)) + label:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) + layout:addChild(label) + + pageView:addPage(layout) + + end + + local function pageViewEvent(sender, eventType) + if eventType == ccui.PageViewEventType.turning then + local pageInfo = string.format("page %d " , pageView:getCurPageIndex() + 1) + self._displayValueLabel:setString(pageInfo) + end + end + + pageView:addEventListener(pageViewEvent) + + self._uiLayer:addChild(pageView) + + end +end) + +add_new_testcase(function() + local UIPageViewVerticalTest = create("UIPageViewVerticalTest",UIScene) + function UIPageViewVerticalTest:initExtend() + local widgetSize = self._widget:getContentSize() + + self._displayValueLabel:setString("Move by vertical direction") + + local alert = ccui.Text:create() + alert:setString("PageView") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) + self._uiLayer:addChild(alert) + + local root = self._uiLayer:getChildByTag(81) + local background = root:getChildByName("background_Panel") + + local pageView = ccui.PageView:create() + pageView:setTouchEnabled(true) + pageView:setContentSize(cc.size(240, 130)) + pageView:setDirection(ccui.PageViewDirection.VERTICAL) + local backgroundSize = background:getContentSize() + pageView:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + + (backgroundSize.width - pageView:getContentSize().width) / 2, + (widgetSize.height - backgroundSize.height) / 2 + + (backgroundSize.height - pageView:getContentSize().height) / 2)) + + for i = 1 , 3 do + local layout = ccui.Layout:create() + layout:setContentSize(cc.size(240, 130)) + + local imageView = ccui.ImageView:create() + imageView:setTouchEnabled(true) + imageView:setScale9Enabled(true) + imageView:loadTexture("cocosui/scrollviewbg.png") + imageView:setContentSize(cc.size(240, 130)) + imageView:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) + layout:addChild(imageView) + + local label = ccui.Text:create() + local pageInfo = string.format("page %d", i) + label:setString(pageInfo) + label:setFontName(font_TextName) + label:setFontSize(30) + label:setColor(cc.c3b(192, 192, 192)) + label:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) + layout:addChild(label) + + pageView:addPage(layout) + + end + + local function pageViewEvent(sender, eventType) + if eventType == ccui.PageViewEventType.turning then + local pageInfo = string.format("page %d " , pageView:getCurPageIndex() + 1) + self._displayValueLabel:setString(pageInfo) + end + end + + pageView:addEventListener(pageViewEvent) + + self._uiLayer:addChild(pageView) + + end +end) + +add_new_testcase(function() + local UIListViewVerticalTest = create("UIListViewVerticalTest",UIScene) + + function UIListViewVerticalTest:initExtend() + local widgetSize = self._widget:getContentSize() + + self._displayValueLabel:setString("Move by vertical direction") + + local alert = ccui.Text:create() + alert:setString("ListView") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) + self._uiLayer:addChild(alert) + + local root = self._uiLayer:getChildByTag(81) + + local background = root:getChildByName("background_Panel") + local backgroundSize = background:getContentSize() + + local array = {} + for i = 1,20 do + array[i] = string.format("ListView_item_%d",i - 1) + end + + local function listViewEvent(sender, eventType) + if eventType == ccui.ListViewEventType.ONSELECTEDITEM_START then + print("select child index = ",sender:getCurSelectedIndex()) + end + end + + local function scrollViewEvent(sender, evenType) + if evenType == ccui.ScrollviewEventType.scrollToBottom then + print("SCROLL_TO_BOTTOM") + elseif evenType == ccui.ScrollviewEventType.scrollToTop then + print("SCROLL_TO_TOP") + end + end + + local listView = ccui.ListView:create() + -- set list view ex direction + listView:setDirection(ccui.ScrollViewDir.vertical) + listView:setBounceEnabled(true) + listView:setBackGroundImage("cocosui/green_edit.png") + listView:setBackGroundImageScale9Enabled(true) + listView:setContentSize(cc.size(240, 130)) + listView:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2.0 + + (backgroundSize.width - listView:getContentSize().width) / 2.0, + (widgetSize.height - backgroundSize.height) / 2.0 + + (backgroundSize.height - listView:getContentSize().height) / 2.0)) + listView:addEventListener(listViewEvent) + listView:addScrollViewEventListener(scrollViewEvent) + self._uiLayer:addChild(listView) + + + -- create model + local default_button = ccui.Button:create("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png") + default_button:setName("Title Button") + + local default_item = ccui.Layout:create() + default_item:setTouchEnabled(true) + default_item:setContentSize(default_button:getContentSize()) + default_button:setPosition(cc.p(default_item:getContentSize().width / 2.0, default_item:getContentSize().height / 2.0)) + default_item:addChild(default_button) + + --set model + listView:setItemModel(default_item) + + --add default item + local count = table.getn(array) + for i = 1,math.floor(count / 4) do + listView:pushBackDefaultItem() + end + --insert default item + for i = 1,math.floor(count / 4) do + listView:insertDefaultItem(0) + end + + listView:removeAllChildren() + + local testSprite = cc.Sprite:create("cocosui/backtotoppressed.png") + testSprite:setPosition(cc.p(200,200)) + listView:addChild(testSprite) + + --add custom item + for i = 1,math.floor(count / 4) do + local custom_button = ccui.Button:create("cocosui/button.png", "cocosui/buttonHighlighted.png") + custom_button:setName("Title Button") + custom_button:setScale9Enabled(true) + custom_button:setContentSize(default_button:getContentSize()) + + local custom_item = ccui.Layout:create() + custom_item:setContentSize(custom_button:getContentSize()) + custom_button:setPosition(cc.p(custom_item:getContentSize().width / 2.0, custom_item:getContentSize().height / 2.0)) + custom_item:addChild(custom_button) + + listView:addChild(custom_item) + end + + --insert custom item + local items = listView:getItems() + local items_count = table.getn(items) + for i = 1, math.floor(count / 4) do + local custom_button = ccui.Button:create("cocosui/button.png", "cocosui/buttonHighlighted.png") + custom_button:setName("Title Button") + custom_button:setScale9Enabled(true) + custom_button:setContentSize(default_button:getContentSize()) + + local custom_item = ccui.Layout:create() + custom_item:setContentSize(custom_button:getContentSize()) + custom_button:setPosition(cc.p(custom_item:getContentSize().width / 2.0, custom_item:getContentSize().height / 2.0)) + custom_item:addChild(custom_button) + custom_item:setTag(1) + + listView:insertCustomItem(custom_item, items_count) + end + + -- set item data + items_count = table.getn(listView:getItems()) + for i = 1,items_count do + local item = listView:getItem(i - 1) + local button = item:getChildByName("Title Button") + local index = listView:getIndex(item) + button:setTitleText(array[index + 1]) + end + + -- remove last item + listView:removeChildByTag(1) + + -- remove item by index + items_count = table.getn(listView:getItems()) + listView:removeItem(items_count - 1) + + -- set all items layout gravity + listView:setGravity(ccui.ListViewGravity.centerVertical) + + --set items margin + listView:setItemsMargin(2.0) + end +end) + +add_new_testcase(function() + local UIListViewHorizontalTest = create("UIListViewHorizontalTest",UIScene) + + function UIListViewHorizontalTest:initExtend() + local widgetSize = self._widget:getContentSize() + + self._displayValueLabel:setString("Move by vertical direction") + + local alert = ccui.Text:create() + alert:setString("ListView") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) + self._uiLayer:addChild(alert) + + + local root = self._uiLayer:getChildByTag(81) + + local background = root:getChildByName("background_Panel") + local backgroundSize = background:getContentSize() + + local array = {} + for i = 1,20 do + array[i] = string.format("ListView_item_%d",i - 1) + end + + local function listViewEvent(sender, eventType) + if eventType == ccui.ListViewEventType.ons_selected_item then + print("select child index = ",sender:getCurSelectedIndex()) + end + end + + local listView = ccui.ListView:create() + -- set list view ex direction + listView:setDirection(ccui.ScrollViewDir.horizontal) + listView:setTouchEnabled(true) + listView:setBounceEnabled(true) + listView:setBackGroundImage("cocosui/green_edit.png") + listView:setBackGroundImageScale9Enabled(true) + listView:setContentSize(cc.size(240, 130)) + listView:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2.0 + + (backgroundSize.width - listView:getContentSize().width) / 2.0, + (widgetSize.height - backgroundSize.height) / 2.0 + + (backgroundSize.height - listView:getContentSize().height) / 2.0)) + listView:addEventListener(listViewEvent) + self._uiLayer:addChild(listView) + + + -- create model + local default_button = ccui.Button:create("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png") + default_button:setName("Title Button") + + local default_item = ccui.Layout:create() + default_item:setTouchEnabled(true) + default_item:setContentSize(default_button:getContentSize()) + default_button:setPosition(cc.p(default_item:getContentSize().width / 2.0, default_item:getContentSize().height / 2.0)) + default_item:addChild(default_button) + + --set model + listView:setItemModel(default_item) + + --add default item + local count = table.getn(array) + for i = 1,math.floor(count / 4) do + listView:pushBackDefaultItem() + end + --insert default item + for i = 1,math.floor(count / 4) do + listView:insertDefaultItem(0) + end + + --add custom item + for i = 1,math.floor(count / 4) do + local custom_button = ccui.Button:create("cocosui/button.png", "cocosui/buttonHighlighted.png") + custom_button:setName("Title Button") + custom_button:setScale9Enabled(true) + custom_button:setContentSize(default_button:getContentSize()) + + local custom_item = ccui.Layout:create() + custom_item:setContentSize(custom_button:getContentSize()) + custom_button:setPosition(cc.p(custom_item:getContentSize().width / 2.0, custom_item:getContentSize().height / 2.0)) + custom_item:addChild(custom_button) + + listView:pushBackCustomItem(custom_item) + end + + --insert custom item + local items = listView:getItems() + local items_count = table.getn(items) + for i = 1, math.floor(count / 4) do + local custom_button = ccui.Button:create("cocosui/button.png", "cocosui/buttonHighlighted.png") + custom_button:setName("Title Button") + custom_button:setScale9Enabled(true) + custom_button:setContentSize(default_button:getContentSize()) + + local custom_item = ccui.Layout:create() + custom_item:setContentSize(custom_button:getContentSize()) + custom_button:setPosition(cc.p(custom_item:getContentSize().width / 2.0, custom_item:getContentSize().height / 2.0)) + custom_item:addChild(custom_button) + + listView:insertCustomItem(custom_item, items_count) + end + + -- set item data + items_count = table.getn(listView:getItems()) + print("items_count", items_count) + for i = 1,items_count do + local item = listView:getItem(i - 1) + local button = item:getChildByName("Title Button") + local index = listView:getIndex(item) + print("index is ", index) + button:setTitleText(array[index + 1]) + end + + -- remove last item + listView:removeLastItem() + + -- remove item by index + items_count = table.getn(listView:getItems()) + listView:removeItem(items_count - 1) + + -- set all items layout gravity + listView:setGravity(ccui.ListViewGravity.centerVertical) + + --set items margin + listView:setItemsMargin(2.0) + end +end) + +add_new_testcase(function() + local UIDragPanelTest = create("UIDragPanelTest",UIScene) + + function UIDragPanelTest:initExtend() + local widgetSize = self._widget:getContentSize() + + self._displayValueLabel:setString("No Event") + + local alert = ccui.Text:create() + alert:setString("DragPanel") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) + self._uiLayer:addChild(alert) + + local sc = ccui.ScrollView:create() + sc:setBackGroundColor(cc.c3b(0,255,0)) + sc:setBackGroundColorType(ccui.LayoutBackGroundColorType.solid) + sc:setDirection(ccui.ScrollViewDir.both) + sc:setInnerContainerSize(cc.size(480, 320)) + sc:setContentSize(cc.size(100,100)) + sc:setPosition(cc.p(100,100)) + sc:scrollToPercentBothDirection(cc.p(50, 50), 1, true) + local iv = ccui.ImageView:create() + iv:loadTexture("cocosui/Hello.png") + iv:setPosition(cc.p(240, 160)) + sc:addChild(iv) + self._uiLayer:addChild(sc) + + end +end) + +add_new_testcase(function() + local UIDragPanelBounceTest = create("UIDragPanelBounceTest",UIScene) + + function UIDragPanelBounceTest:initExtend() + local widgetSize = self._widget:getContentSize() + + self._displayValueLabel:setString("No Event") + + local alert = ccui.Text:create() + alert:setString("DragPanel Bounce") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 2.925)) + self._uiLayer:addChild(alert) + + local sc = ccui.ScrollView:create() + sc:setBackGroundColor(cc.c3b(0, 255 , 0)) + sc:setBackGroundColorType(ccui.LayoutBackGroundColorType.solid) + sc:setBounceEnabled(true) + sc:setDirection(ccui.ScrollViewDir.both) + sc:setInnerContainerSize(cc.size(480, 320)) + sc:setContentSize(cc.size(100,100)) + sc:setPosition(cc.p(100,100)) + sc:scrollToPercentBothDirection(cc.p(50, 50), 1, true) + local iv = ccui.ImageView:create() + iv:loadTexture("cocosui/Hello.png") + iv:setPosition(cc.p(240, 160)) + sc:addChild(iv) + self._uiLayer:addChild(sc) + end +end) + +add_new_testcase(function() + local UINodeContainerTest = create("UINodeContainerTest",UIScene) + + function UINodeContainerTest:initExtend() + local widgetSize = self._widget:getContentSize() + self._displayValueLabel:setString("NodeContainer Add CCNode") + + local alert = ccui.Text:create() + alert:setString("NodeContainer") + alert:setFontName(font_TextName) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 1.75)) + self._uiLayer:addChild(alert) + + local nodeContainer = ccui.Widget:create() + nodeContainer:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + self._uiLayer:addChild(nodeContainer) + + local sprite = cc.Sprite:create("cocosui/ccicon.png") + sprite:setPosition(cc.p(0, sprite:getBoundingBox().height / 4)) + nodeContainer:addChild(sprite) + end +end) + +add_new_testcase(function() + local UIRichTextTest = create("UIRichTextTest",UIScene) + + function UIRichTextTest:initExtend() + local widgetSize = self._widget:getContentSize() + self._displayValueLabel:setString("") + + local alert = ccui.Text:create("RichText", "fonts/Marker Felt.ttf", 30) + alert:setFontName(font_TextName) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getContentSize().height * 3.125)) + self._widget:addChild(alert) + + + local function touchEvent(sender, eventType) + if eventType == ccui.TouchEventType.ended then + if self._richText:isIgnoreContentAdaptWithSize() then + self._richText:ignoreContentAdaptWithSize(false) + self._richText:setContentSize(cc.size(100, 100)) + else + self._richText:ignoreContentAdaptWithSize(true) + end + end + end + + local button = ccui.Button:create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png") + button:setTouchEnabled(true) + button:setTitleText("switch") + button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + button:getContentSize().height * 2.5)) + button:addTouchEventListener(touchEvent) + button:setLocalZOrder(10) + self._widget:addChild(button) + + self._richText = ccui.RichText:create() + self._richText:ignoreContentAdaptWithSize(false) + self._richText:setContentSize(cc.size(100, 100)) + + local re1 = ccui.RichElementText:create(1, cc.c3b(255, 255, 255), 255, "This color is white. ", "Helvetica", 10) + local re2 = ccui.RichElementText:create(2, cc.c3b(255, 255, 0), 255, "And this is yellow. ", "Helvetica", 10) + local re3 = ccui.RichElementText:create(3, cc.c3b(0, 0, 255), 255, "This one is blue. ", "Helvetica", 10) + local re4 = ccui.RichElementText:create(4, cc.c3b(0, 255, 0), 255, "And green. ", "Helvetica", 10) + local re5 = ccui.RichElementText:create(5, cc.c3b(255, 0, 0), 255, "Last one is red ", "Helvetica", 10) + + local reimg = ccui.RichElementImage:create(6, cc.c3b(255, 255, 255), 255, "cocosui/sliderballnormal.png") + + ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("cocosui/100/100.ExportJson") + local arr = ccs.Armature:create("100") + arr:getAnimation():play("Animation1") + + local recustom = ccui.RichElementCustomNode:create(1, cc.c3b(255, 255, 255), 255, arr) + local re6 = ccui.RichElementText:create(7, cc.c3b(255, 127, 0), 255, "Have fun!! ", "Helvetica", 10) + self._richText:pushBackElement(re1) + self._richText:insertElement(re2, 1) + self._richText:pushBackElement(re3) + self._richText:pushBackElement(re4) + self._richText:pushBackElement(re5) + self._richText:insertElement(reimg, 2) + self._richText:pushBackElement(recustom) + self._richText:pushBackElement(re6) + + self._richText:setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2)) + self._richText:setLocalZOrder(10) + + + self._widget:addChild(self._richText) + + end +end) + +add_new_testcase(function() + local UIFocusTestHorizontal = create("UIFocusTestHorizontal",UIScene) + + function UIFocusTestHorizontal:initExtend() + + self._displayValueLabel:setString("") + local root = self._uiLayer:getChildByTag(81) + local background = root:getChildByName("background_Panel") + background:removeFromParent(true) + + local function onLeftKeyPressed() + local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_LEFT, false) + cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) + end + + local function onRightKeyPressed() + local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_RIGHT, false) + cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) + end + + local function onUpKeyPressed() + local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_UP, false) + cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) + end + + local function onDownKeyPressed() + local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_DOWN, false) + cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) + end + + self._dpadMenu = cc.Menu:create() + local winSize = cc.Director:getInstance():getVisibleSize() + + local leftItem = cc.MenuItemFont:create("Left") + leftItem:setPosition(cc.p(winSize.width - 100, winSize.height/2)) + leftItem:registerScriptTapHandler(onLeftKeyPressed) + self._dpadMenu:addChild(leftItem) + + local rightItem = cc.MenuItemFont:create("Right") + rightItem:setPosition(cc.p(winSize.width - 30, winSize.height/2)) + rightItem:registerScriptTapHandler(onRightKeyPressed) + self._dpadMenu:addChild(rightItem) + + local upItem = cc.MenuItemFont:create("Up") + upItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 + 50)) + upItem:registerScriptTapHandler(onUpKeyPressed) + self._dpadMenu:addChild(upItem) + + local downItem = cc.MenuItemFont:create("Down") + downItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 - 50)) + downItem:registerScriptTapHandler(onDownKeyPressed) + self._dpadMenu:addChild(downItem) + self._dpadMenu:setPosition(cc.p(0, 0)) + self._uiLayer:addChild(self._dpadMenu) + + ccui.Widget:enableDpadNavigation(true) + + local function onFocusChanged(widgetLostFocus,widgetGetFocus) + if nil ~= widgetGetFocus and widgetGetFocus:isFocusEnabled() then + widgetGetFocus:setColor(cc.c3b(255, 0, 0)) + end + + if nil ~= widgetLostFocus and widgetLostFocus:isFocusEnabled() then + widgetLostFocus:setColor(cc.c3b(255, 255, 255)) + end + + if nil ~= widgetLostFocus and nil ~= widgetGetFocus then + print(string.format("on focus change, %d widget get focus, %d widget lose focus", widgetGetFocus:getTag(), widgetLostFocus:getTag())) + end + end + + local eventListener = cc.EventListenerFocus:create() + eventListener:registerScriptHandler(onFocusChanged) + local eventDispatcher = self:getEventDispatcher() + eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) + + local winSize = cc.Director:getInstance():getVisibleSize() + self._horizontalLayout = ccui.HBox:create() + self._horizontalLayout:setPosition(cc.p(20, winSize.height / 2 + 40)) + self._uiLayer:addChild(self._horizontalLayout) + + self._horizontalLayout:setFocused(true) + self._horizontalLayout:setLoopFocus(true) + self._horizontalLayout:setTag(100) + self._firstFocusedWidget = self._horizontalLayout + + local function onImageViewClicked(sender, eventType) + if eventType == ccui.TouchEventType.ended then + local w = sender + if w:isFocusEnabled() then + w:setFocusEnabled(false) + w:setColor(cc.c3b(255, 255, 0)) + else + w:setFocusEnabled(true) + w:setColor(cc.c3b(255, 255, 255)) + end + end + end + + local count = 3 + for i = 1, count do + local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") + imageView:setTouchEnabled(true) + imageView:setTag(i) + imageView:addTouchEventListener(onImageViewClicked) + self._horizontalLayout:addChild(imageView) + end + + self._loopText = ccui.Text:create("loop enabled", "Arial", 20) + self._loopText:setPosition(cc.p(winSize.width/2, winSize.height - 50)) + self._loopText:setColor(cc.c3b(255, 0 ,0)) + self:addChild(self._loopText) + + local function toggleFocusLoop(sender, eventType) + if eventType == ccui.TouchEventType.ended then + self._horizontalLayout:setLoopFocus(not self._horizontalLayout:isLoopFocus()) + if self._horizontalLayout:isLoopFocus() then + self._loopText:setString("loop enabled") + else + self._loopText:setString("loop disabled") + end + end + end + + local btn = ccui.Button:create("cocosui/switch-mask.png") + btn:setTitleText("Toggle Loop") + btn:setPosition(cc.p(60, winSize.height - 50)) + btn:setTitleColor(cc.c3b(0, 255, 0)) + btn:addTouchEventListener(toggleFocusLoop) + self:addChild(btn) + end +end) + +add_new_testcase(function() + local UIFocusTestVertical = create("UIFocusTestVertical",UIScene) + + function UIFocusTestVertical:initExtend() + + self._displayValueLabel:setString("") + local root = self._uiLayer:getChildByTag(81) + local background = root:getChildByName("background_Panel") + background:removeFromParent(true) + + local function onLeftKeyPressed() + local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_LEFT, false) + cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) + end + + local function onRightKeyPressed() + local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_RIGHT, false) + cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) + end + + local function onUpKeyPressed() + local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_UP, false) + cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) + end + + local function onDownKeyPressed() + local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_DOWN, false) + cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) + end + + self._dpadMenu = cc.Menu:create() + local winSize = cc.Director:getInstance():getVisibleSize() + + local leftItem = cc.MenuItemFont:create("Left") + leftItem:setPosition(cc.p(winSize.width - 100, winSize.height/2)) + leftItem:registerScriptTapHandler(onLeftKeyPressed) + self._dpadMenu:addChild(leftItem) + + local rightItem = cc.MenuItemFont:create("Right") + rightItem:setPosition(cc.p(winSize.width - 30, winSize.height/2)) + rightItem:registerScriptTapHandler(onRightKeyPressed) + self._dpadMenu:addChild(rightItem) + + local upItem = cc.MenuItemFont:create("Up") + upItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 + 50)) + upItem:registerScriptTapHandler(onUpKeyPressed) + self._dpadMenu:addChild(upItem) + + local downItem = cc.MenuItemFont:create("Down") + downItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 - 50)) + downItem:registerScriptTapHandler(onDownKeyPressed) + self._dpadMenu:addChild(downItem) + self._dpadMenu:setPosition(cc.p(0, 0)) + self._uiLayer:addChild(self._dpadMenu) + + ccui.Widget:enableDpadNavigation(true) + + local function onFocusChanged(widgetLostFocus,widgetGetFocus) + if nil ~= widgetGetFocus and widgetGetFocus:isFocusEnabled() then + widgetGetFocus:setColor(cc.c3b(255, 0, 0)) + end + + if nil ~= widgetLostFocus and widgetLostFocus:isFocusEnabled() then + widgetLostFocus:setColor(cc.c3b(255, 255, 255)) + end + + if nil ~= widgetLostFocus and nil ~= widgetGetFocus then + print(string.format("on focus change, %d widget get focus, %d widget lose focus", widgetGetFocus:getTag(), widgetLostFocus:getTag())) + end + end + + local eventListener = cc.EventListenerFocus:create() + eventListener:registerScriptHandler(onFocusChanged) + local eventDispatcher = self:getEventDispatcher() + eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) + + local winSize = cc.Director:getInstance():getVisibleSize() + self._verticalLayout = ccui.VBox:create() + self._verticalLayout:setPosition(cc.p(winSize.width/2 - 100, winSize.height - 70)) + self._uiLayer:addChild(self._verticalLayout) + + self._verticalLayout:setFocused(true) + self._verticalLayout:setLoopFocus(true) + self._verticalLayout:setTag(100) + self._verticalLayout:setScale(0.5) + self._firstFocusedWidget = self._verticalLayout + + local function onImageViewClicked(sender, eventType) + if eventType == ccui.TouchEventType.ended then + local w = sender + if w:isFocusEnabled() then + w:setFocusEnabled(false) + w:setColor(cc.c3b(255, 255, 0)) + else + w:setFocusEnabled(true) + w:setColor(cc.c3b(255, 255, 255)) + end + end + end + + local count = 3 + for i = 1, count do + local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") + imageView:setTouchEnabled(true) + imageView:setTag(i) + imageView:addTouchEventListener(onImageViewClicked) + self._verticalLayout:addChild(imageView) + end + + self._loopText = ccui.Text:create("loop enabled", "Arial", 20) + self._loopText:setPosition(cc.p(winSize.width/2, winSize.height - 50)) + self._loopText:setColor(cc.c3b(255, 0 ,0)) + self:addChild(self._loopText) + + local function toggleFocusLoop(sender, eventType) + if eventType == ccui.TouchEventType.ended then + self._verticalLayout:setLoopFocus(not self._verticalLayout:isLoopFocus()) + if self._verticalLayout:isLoopFocus() then + self._loopText:setString("loop enabled") + else + self._loopText:setString("loop disabled") + end + end + end + + local btn = ccui.Button:create("cocosui/switch-mask.png") + btn:setTitleText("Toggle Loop") + btn:setPosition(cc.p(60, winSize.height - 50)) + btn:setTitleColor(cc.c3b(0, 255, 0)) + btn:addTouchEventListener(toggleFocusLoop) + self:addChild(btn) + end +end) + +add_new_testcase(function() + local UIFocusTestNestedLayout1 = create("UIFocusTestNestedLayout1",UIScene) + + function UIFocusTestNestedLayout1:initExtend() + self._displayValueLabel:setString("") + local root = self._uiLayer:getChildByTag(81) + local background = root:getChildByName("background_Panel") + background:removeFromParent(true) + + local function onLeftKeyPressed() + local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_LEFT, false) + cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) + end + + local function onRightKeyPressed() + local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_RIGHT, false) + cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) + end + + local function onUpKeyPressed() + local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_UP, false) + cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) + end + + local function onDownKeyPressed() + local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_DOWN, false) + cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) + end + + self._dpadMenu = cc.Menu:create() + local winSize = cc.Director:getInstance():getVisibleSize() + + local leftItem = cc.MenuItemFont:create("Left") + leftItem:setPosition(cc.p(winSize.width - 100, winSize.height/2)) + leftItem:registerScriptTapHandler(onLeftKeyPressed) + self._dpadMenu:addChild(leftItem) + + local rightItem = cc.MenuItemFont:create("Right") + rightItem:setPosition(cc.p(winSize.width - 30, winSize.height/2)) + rightItem:registerScriptTapHandler(onRightKeyPressed) + self._dpadMenu:addChild(rightItem) + + local upItem = cc.MenuItemFont:create("Up") + upItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 + 50)) + upItem:registerScriptTapHandler(onUpKeyPressed) + self._dpadMenu:addChild(upItem) + + local downItem = cc.MenuItemFont:create("Down") + downItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 - 50)) + downItem:registerScriptTapHandler(onDownKeyPressed) + self._dpadMenu:addChild(downItem) + self._dpadMenu:setPosition(cc.p(0, 0)) + self._uiLayer:addChild(self._dpadMenu) + + ccui.Widget:enableDpadNavigation(true) + + local function onFocusChanged(widgetLostFocus,widgetGetFocus) + if nil ~= widgetGetFocus and widgetGetFocus:isFocusEnabled() then + widgetGetFocus:setColor(cc.c3b(255, 0, 0)) + end + + if nil ~= widgetLostFocus and widgetLostFocus:isFocusEnabled() then + widgetLostFocus:setColor(cc.c3b(255, 255, 255)) + end + + if nil ~= widgetLostFocus and nil ~= widgetGetFocus then + print(string.format("on focus change, %d widget get focus, %d widget lose focus", widgetGetFocus:getTag(), widgetLostFocus:getTag())) + end + end + + local eventListener = cc.EventListenerFocus:create() + eventListener:registerScriptHandler(onFocusChanged) + local eventDispatcher = self:getEventDispatcher() + eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) + + local winSize = cc.Director:getInstance():getVisibleSize() + + self._verticalLayout = ccui.VBox:create() + self._verticalLayout:setPosition(cc.p(winSize.width/2 - 80, winSize.height - 70)) + self._uiLayer:addChild(self._verticalLayout) + self._verticalLayout:setScale(0.5) + + self._verticalLayout:setFocused(true) + self._verticalLayout:setLoopFocus(true) + self._verticalLayout:setTag(100) + self._firstFocusedWidget = self._verticalLayout + + local function onImageViewClicked(sender, eventType) + if eventType == ccui.TouchEventType.ended then + local w = sender + if w:isFocusEnabled() then + w:setFocusEnabled(false) + w:setColor(cc.c3b(255, 255, 0)) + else + w:setFocusEnabled(true) + w:setColor(cc.c3b(255, 255, 255)) + end + end + end + + local count1 = 1 + for i = 1, count1 do + local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") + imageView:setAnchorPoint(cc.p(0, 0)) + imageView:setTouchEnabled(true) + imageView:setScaleX(2.5) + imageView:setTag(i - 1 + count1) + imageView:addTouchEventListener(onImageViewClicked) + self._verticalLayout:addChild(imageView) + end + + local hbox = ccui.HBox:create() + hbox:setScale(0.8) + hbox:setTag(101) + self._verticalLayout:addChild(hbox) + + local count2 = 2 + for i = 1, count2 do + local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") + imageView:setAnchorPoint(cc.p(0, 1)) + imageView:setScaleY(2.0) + imageView:setTouchEnabled(true) + imageView:setTag(i - 1 + count1 + count2) + imageView:addTouchEventListener(onImageViewClicked) + hbox:addChild(imageView) + end + + local innerVBox = ccui.VBox:create() + hbox:addChild(innerVBox) + innerVBox:setTag(102) + + local count3 = 2 + for i = 1, count3 do + local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") + imageView:setTouchEnabled(true) + imageView:setTag(i - 1 + count1 + count2 + count3) + imageView:addTouchEventListener(onImageViewClicked) + innerVBox:addChild(imageView) + end + + self._loopText = ccui.Text:create("loop enabled", "Arial", 20) + self._loopText:setPosition(cc.p(winSize.width/2, winSize.height - 50)) + self._loopText:setColor(cc.c3b(255, 0 ,0)) + self:addChild(self._loopText) + + local function toggleFocusLoop(sender, eventType) + if eventType == ccui.TouchEventType.ended then + self._verticalLayout:setLoopFocus(not self._verticalLayout:isLoopFocus()) + if self._verticalLayout:isLoopFocus() then + self._loopText:setString("loop enabled") + else + self._loopText:setString("loop disabled") + end + end + end + + local btn = ccui.Button:create("cocosui/switch-mask.png") + btn:setTitleText("Toggle Loop") + btn:setPosition(cc.p(60, winSize.height - 50)) + btn:setTitleColor(cc.c3b(0, 255, 0)) + btn:addTouchEventListener(toggleFocusLoop) + self:addChild(btn) + end +end) + +add_new_testcase(function() + local UIFocusTestNestedLayout2 = create("UIFocusTestNestedLayout2",UIScene) + + function UIFocusTestNestedLayout2:initExtend() + self._displayValueLabel:setString("") + local root = self._uiLayer:getChildByTag(81) + local background = root:getChildByName("background_Panel") + background:removeFromParent(true) + + local function onLeftKeyPressed() + local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_LEFT, false) + cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) + end + + local function onRightKeyPressed() + local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_RIGHT, false) + cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) + end + + local function onUpKeyPressed() + local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_UP, false) + cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) + end + + local function onDownKeyPressed() + local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_DOWN, false) + cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) + end + + self._dpadMenu = cc.Menu:create() + local winSize = cc.Director:getInstance():getVisibleSize() + + local leftItem = cc.MenuItemFont:create("Left") + leftItem:setPosition(cc.p(winSize.width - 100, winSize.height/2)) + leftItem:registerScriptTapHandler(onLeftKeyPressed) + self._dpadMenu:addChild(leftItem) + + local rightItem = cc.MenuItemFont:create("Right") + rightItem:setPosition(cc.p(winSize.width - 30, winSize.height/2)) + rightItem:registerScriptTapHandler(onRightKeyPressed) + self._dpadMenu:addChild(rightItem) + + local upItem = cc.MenuItemFont:create("Up") + upItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 + 50)) + upItem:registerScriptTapHandler(onUpKeyPressed) + self._dpadMenu:addChild(upItem) + + local downItem = cc.MenuItemFont:create("Down") + downItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 - 50)) + downItem:registerScriptTapHandler(onDownKeyPressed) + self._dpadMenu:addChild(downItem) + self._dpadMenu:setPosition(cc.p(0, 0)) + self._uiLayer:addChild(self._dpadMenu) + + ccui.Widget:enableDpadNavigation(true) + + local function onFocusChanged(widgetLostFocus,widgetGetFocus) + if nil ~= widgetGetFocus and widgetGetFocus:isFocusEnabled() then + widgetGetFocus:setColor(cc.c3b(255, 0, 0)) + end + + if nil ~= widgetLostFocus and widgetLostFocus:isFocusEnabled() then + widgetLostFocus:setColor(cc.c3b(255, 255, 255)) + end + + if nil ~= widgetLostFocus and nil ~= widgetGetFocus then + print(string.format("on focus change, %d widget get focus, %d widget lose focus", widgetGetFocus:getTag(), widgetLostFocus:getTag())) + end + end + + local eventListener = cc.EventListenerFocus:create() + eventListener:registerScriptHandler(onFocusChanged) + local eventDispatcher = self:getEventDispatcher() + eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) + + local winSize = cc.Director:getInstance():getVisibleSize() + + self._horizontalLayout = ccui.HBox:create() + self._horizontalLayout:setPosition(cc.p(winSize.width/2 - 200, winSize.height - 70)) + self._uiLayer:addChild(self._horizontalLayout) + self._horizontalLayout:setScale(0.6) + + self._horizontalLayout:setFocused(true) + self._horizontalLayout:setLoopFocus(true) + self._horizontalLayout:setTag(100) + self._firstFocusedWidget = self._horizontalLayout + + local function onImageViewClicked(sender, eventType) + if eventType == ccui.TouchEventType.ended then + local w = sender + if w:isFocusEnabled() then + w:setFocusEnabled(false) + w:setColor(cc.c3b(255, 255, 0)) + else + w:setFocusEnabled(true) + w:setColor(cc.c3b(255, 255, 255)) + end + end + end + + local count1 = 2 + for i = 1, count1 do + local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") + imageView:setAnchorPoint(cc.p(0, 1)) + imageView:setTouchEnabled(true) + imageView:setScaleY(2.4) + imageView:setTag(i - 1 + count1) + imageView:addTouchEventListener(onImageViewClicked) + self._horizontalLayout:addChild(imageView) + end + + local vbox = ccui.VBox:create() + vbox:setScale(0.8) + vbox:setTag(101) + self._horizontalLayout:addChild(vbox) + + local count2 = 2 + for i = 1, count2 do + local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") + imageView:setAnchorPoint(cc.p(0, 1)) + imageView:setScaleX(2.0) + imageView:setTouchEnabled(true) + imageView:setTag(i - 1 + count1 + count2) + imageView:addTouchEventListener(onImageViewClicked) + vbox:addChild(imageView) + end + + local innerVBox = ccui.HBox:create() + vbox:addChild(innerVBox) + innerVBox:setTag(102) + + local count3 = 2 + for i = 1, count3 do + local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") + imageView:setTouchEnabled(true) + imageView:setTag(i - 1 + count1 + count2 + count3) + imageView:addTouchEventListener(onImageViewClicked) + innerVBox:addChild(imageView) + end + + self._loopText = ccui.Text:create("loop enabled", "Arial", 20) + self._loopText:setPosition(cc.p(winSize.width/2, winSize.height - 50)) + self._loopText:setColor(cc.c3b(255, 0 ,0)) + self:addChild(self._loopText) + + local function toggleFocusLoop(sender, eventType) + if eventType == ccui.TouchEventType.ended then + self._horizontalLayout:setLoopFocus(not self._horizontalLayout:isLoopFocus()) + if self._horizontalLayout:isLoopFocus() then + self._loopText:setString("loop enabled") + else + self._loopText:setString("loop disabled") + end + end + end + + local btn = ccui.Button:create("cocosui/switch-mask.png") + btn:setTitleText("Toggle Loop") + btn:setPosition(cc.p(60, winSize.height - 50)) + btn:setTitleColor(cc.c3b(0, 255, 0)) + btn:addTouchEventListener(toggleFocusLoop) + self:addChild(btn) + end +end) + +add_new_testcase(function() + local UIFocusTestNestedLayout3 = create("UIFocusTestNestedLayout3",UIScene) + + function UIFocusTestNestedLayout3:initExtend() + self._displayValueLabel:setString("") + local root = self._uiLayer:getChildByTag(81) + local background = root:getChildByName("background_Panel") + background:removeFromParent(true) + + local function onLeftKeyPressed() + local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_LEFT, false) + cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) + end + + local function onRightKeyPressed() + local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_RIGHT, false) + cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) + end + + local function onUpKeyPressed() + local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_UP, false) + cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) + end + + local function onDownKeyPressed() + local event = cc.EventKeyboard:new(cc.KeyCode.KEY_DPAD_DOWN, false) + cc.Director:getInstance():getEventDispatcher():dispatchEvent(event) + end + + self._dpadMenu = cc.Menu:create() + local winSize = cc.Director:getInstance():getVisibleSize() + + local leftItem = cc.MenuItemFont:create("Left") + leftItem:setPosition(cc.p(winSize.width - 100, winSize.height/2)) + leftItem:registerScriptTapHandler(onLeftKeyPressed) + self._dpadMenu:addChild(leftItem) + + local rightItem = cc.MenuItemFont:create("Right") + rightItem:setPosition(cc.p(winSize.width - 30, winSize.height/2)) + rightItem:registerScriptTapHandler(onRightKeyPressed) + self._dpadMenu:addChild(rightItem) + + local upItem = cc.MenuItemFont:create("Up") + upItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 + 50)) + upItem:registerScriptTapHandler(onUpKeyPressed) + self._dpadMenu:addChild(upItem) + + local downItem = cc.MenuItemFont:create("Down") + downItem:setPosition(cc.p(winSize.width - 60, winSize.height/2 - 50)) + downItem:registerScriptTapHandler(onDownKeyPressed) + self._dpadMenu:addChild(downItem) + self._dpadMenu:setPosition(cc.p(0, 0)) + self._uiLayer:addChild(self._dpadMenu) + + ccui.Widget:enableDpadNavigation(true) + + local function onFocusChanged(widgetLostFocus,widgetGetFocus) + if nil ~= widgetGetFocus and widgetGetFocus:isFocusEnabled() then + widgetGetFocus:setColor(cc.c3b(255, 0, 0)) + end + + if nil ~= widgetLostFocus and widgetLostFocus:isFocusEnabled() then + widgetLostFocus:setColor(cc.c3b(255, 255, 255)) + end + + if nil ~= widgetLostFocus and nil ~= widgetGetFocus then + print(string.format("on focus change, %d widget get focus, %d widget lose focus", widgetGetFocus:getTag(), widgetLostFocus:getTag())) + end + end + + local eventListener = cc.EventListenerFocus:create() + eventListener:registerScriptHandler(onFocusChanged) + local eventDispatcher = self:getEventDispatcher() + eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) + + local winSize = cc.Director:getInstance():getVisibleSize() + + self._verticalLayout = ccui.VBox:create() + self._verticalLayout:setPosition(cc.p(40, winSize.height - 70)) + self._uiLayer:addChild(self._verticalLayout) + self._verticalLayout:setScale(0.8) + + self._verticalLayout:setFocused(true) + self._verticalLayout:setLoopFocus(true) + self._verticalLayout:setTag(-1000) + self._firstFocusedWidget = self._verticalLayout + + local upperHBox = ccui.HBox:create() + upperHBox:setTag(-200) + self._verticalLayout:addChild(upperHBox) + + local params = ccui.LinearLayoutParameter:create() + params:setMargin({left = 0, top = 0, right = 50, bottom = 0}) + + local vparams = ccui.LinearLayoutParameter:create() + vparams:setMargin({left = 10, top = 0, right = 0, bottom = 140}) + upperHBox:setLayoutParameter(vparams) + + local function onImageViewClicked(sender, eventType) + if eventType == ccui.TouchEventType.ended then + local w = sender + if w:isFocusEnabled() then + w:setFocusEnabled(false) + w:setColor(cc.c3b(255, 255, 0)) + else + w:setFocusEnabled(true) + w:setColor(cc.c3b(255, 255, 255)) + end + end + end + + local count = 3 + for i = 1, count do + local firstVbox = ccui.VBox:create() + firstVbox:setScale(0.5) + firstVbox:setLayoutParameter(params) + firstVbox:setTag(i * 100) + + local count1 = 3 + for j = 1, count1 do + local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") + imageView:setTouchEnabled(true) + imageView:setTag(j + firstVbox:getTag()) + imageView:addTouchEventListener(onImageViewClicked) + firstVbox:addChild(imageView) + end + + upperHBox:addChild(firstVbox) + end + + local bottomHBox = ccui.HBox:create() + bottomHBox:setScale(0.5) + bottomHBox:setTag(600) + bottomHBox:setLayoutParameter(vparams) + + count = 3 + local bottomParams = ccui.LinearLayoutParameter:create() + bottomParams:setMargin({left = 0, top = 0, right = 8, bottom = 0}) + for i = 1, count do + local imageView = ccui.ImageView:create("cocosui/scrollviewbg.png") + imageView:setLayoutParameter(bottomParams) + imageView:setTouchEnabled(true) + imageView:setTag(i + 600) + imageView:addTouchEventListener(onImageViewClicked) + bottomHBox:addChild(imageView) + end + + self._verticalLayout:addChild(bottomHBox) + + self._loopText = ccui.Text:create("loop enabled", "Arial", 20) + self._loopText:setPosition(cc.p(winSize.width/2, winSize.height - 50)) + self._loopText:setColor(cc.c3b(255, 0 ,0)) + self:addChild(self._loopText) + + local function toggleFocusLoop(sender, eventType) + if eventType == ccui.TouchEventType.ended then + self._verticalLayout:setLoopFocus(not self._verticalLayout:isLoopFocus()) + if self._verticalLayout:isLoopFocus() then + self._loopText:setString("loop enabled") + else + self._loopText:setString("loop disabled") + end + end + end + + local btn = ccui.Button:create("cocosui/switch-mask.png") + btn:setTitleText("Toggle Loop") + btn:setPosition(cc.p(60, winSize.height - 50)) + btn:setTitleColor(cc.c3b(0, 255, 0)) + btn:addTouchEventListener(toggleFocusLoop) + self:addChild(btn) + end +end) + +add_new_testcase(function() + local UIS9NinePatchTest = create( "UIS9NinePatchTest", UIScene) + + function UIS9NinePatchTest:initExtend() + + cc.SpriteFrameCache:getInstance():addSpriteFrames("cocosui/android9patch.plist") + + local winSize = cc.Director:getInstance():getWinSize() + local x = winSize.width / 2 + local y = 0 + (winSize.height / 2 + 50) + + local preferedSize = cc.size(99,99) + + --9-patch sprite with filename + local playerSprite = ccui.Scale9Sprite:create("cocosui/player.9.png") + playerSprite:setPosition(x, y) + playerSprite:setContentSize(preferedSize) + local capInsets = playerSprite:getCapInsets() + print(string.format("player sprite capInset = %f, %f %f, %f", capInsets.x, + capInsets.y, capInsets.width, capInsets.height)) + self:addChild(playerSprite) + + local animationBtnSprite = ccui.Scale9Sprite:createWithSpriteFrameName("animationbuttonpressed.png") + animationBtnSprite:setPosition(x-100, y-100) + capInsets = animationBtnSprite:getCapInsets() + print(string.format("animationBtnSprite capInset = %f, %f %f, %f", capInsets.x, + capInsets.y, capInsets.width, capInsets.height)) + self:addChild(animationBtnSprite) + + + local monsterSprite = ccui.Scale9Sprite:createWithSpriteFrameName("monster.9.png") + monsterSprite:setPosition(x+100, y-100) + capInsets = monsterSprite:getCapInsets() + monsterSprite:setContentSize(preferedSize) + print(string.format("monsterSprite capInset = %f, %f %f, %f", capInsets.x, + capInsets.y, capInsets.width, capInsets.height)) + self:addChild(monsterSprite) + + local spriteFrame = cc.SpriteFrameCache:getInstance():getSpriteFrame("buttonnormal.9.png") + local buttonScale9Sprite = ccui.Scale9Sprite:createWithSpriteFrame(spriteFrame) + buttonScale9Sprite:setContentSize(cc.size(150,80)) + buttonScale9Sprite:setPosition(cc.p(100,200)) + self:addChild(buttonScale9Sprite) + + end +end) + + + + function guiSceneManager.nextUIScene() guiSceneManager.currentUISceneIdx = (guiSceneManager.currentUISceneIdx + 1) % table.getn(cocoStudioGuiArray) if 0 == guiSceneManager.currentUISceneIdx then diff --git a/tools/tolua/cocos2dx_ui.ini b/tools/tolua/cocos2dx_ui.ini index 71fcee2e39..5c9eb9893f 100644 --- a/tools/tolua/cocos2dx_ui.ini +++ b/tools/tolua/cocos2dx_ui.ini @@ -30,7 +30,7 @@ headers = %(cocosdir)s/cocos/ui/CocosGUI.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = Helper Widget Layout Button CheckBox ImageView Text TextAtlas TextBMFont LoadingBar Slider TextField ScrollView ListView PageView LayoutParameter LinearLayoutParameter RelativeLayoutParameter Rich.* HBox VBox RelativeBox Scale9Sprite EditBox LayoutComponent AbstractCheckButton +classes = Helper Widget Layout Button CheckBox ImageView Text TextAtlas TextBMFont LoadingBar Slider TextField ScrollView ListView PageView LayoutParameter LinearLayoutParameter RelativeLayoutParameter Rich.* HBox VBox RelativeBox Scale9Sprite EditBox LayoutComponent AbstractCheckButton RadioButton RadioButtonGroup # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also From a3b8423977ed9258f09ce02051d04cd4084dac19 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Thu, 20 Aug 2015 07:39:25 +0000 Subject: [PATCH 026/118] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../lua-bindings/auto/api/RadioButton.lua | 48 + .../auto/api/RadioButtonGroup.lua | 99 +++ .../auto/api/lua_cocos2dx_ui_auto_api.lua | 10 + .../auto/lua_cocos2dx_ui_auto.cpp | 821 ++++++++++++++++++ .../auto/lua_cocos2dx_ui_auto.hpp | 17 + 5 files changed, 995 insertions(+) create mode 100644 cocos/scripting/lua-bindings/auto/api/RadioButton.lua create mode 100644 cocos/scripting/lua-bindings/auto/api/RadioButtonGroup.lua diff --git a/cocos/scripting/lua-bindings/auto/api/RadioButton.lua b/cocos/scripting/lua-bindings/auto/api/RadioButton.lua new file mode 100644 index 0000000000..64b28dd36a --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/api/RadioButton.lua @@ -0,0 +1,48 @@ + +-------------------------------- +-- @module RadioButton +-- @extend AbstractCheckButton +-- @parent_module ccui + +-------------------------------- +-- Add a callback function which would be called when radio button is selected or unselected.
+-- param callback A std::function with type @see `ccRadioButtonCallback` +-- @function [parent=#RadioButton] addEventListener +-- @param self +-- @param #function callback +-- @return RadioButton#RadioButton self (return value: ccui.RadioButton) + +-------------------------------- +-- @overload self, string, string, string, string, string, int +-- @overload self +-- @overload self, string, string, int +-- @function [parent=#RadioButton] create +-- @param self +-- @param #string backGround +-- @param #string backGroundSelected +-- @param #string cross +-- @param #string backGroundDisabled +-- @param #string frontCrossDisabled +-- @param #int texType +-- @return RadioButton#RadioButton ret (return value: ccui.RadioButton) + +-------------------------------- +-- +-- @function [parent=#RadioButton] createInstance +-- @param self +-- @return Ref#Ref ret (return value: cc.Ref) + +-------------------------------- +-- +-- @function [parent=#RadioButton] getDescription +-- @param self +-- @return string#string ret (return value: string) + +-------------------------------- +-- Default constructor.
+-- lua new +-- @function [parent=#RadioButton] RadioButton +-- @param self +-- @return RadioButton#RadioButton self (return value: ccui.RadioButton) + +return nil diff --git a/cocos/scripting/lua-bindings/auto/api/RadioButtonGroup.lua b/cocos/scripting/lua-bindings/auto/api/RadioButtonGroup.lua new file mode 100644 index 0000000000..38e177eee7 --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/api/RadioButtonGroup.lua @@ -0,0 +1,99 @@ + +-------------------------------- +-- @module RadioButtonGroup +-- @extend Widget +-- @parent_module ccui + +-------------------------------- +-- Remove a radio button from this group.
+-- param radio button instance +-- @function [parent=#RadioButtonGroup] removeRadioButton +-- @param self +-- @param #ccui.RadioButton radioButton +-- @return RadioButtonGroup#RadioButtonGroup self (return value: ccui.RadioButtonGroup) + +-------------------------------- +-- Query whether no-selection is allowed or not.
+-- param true means no-selection is allowed, false means no-selection is not allowed. +-- @function [parent=#RadioButtonGroup] isAllowedNoSelection +-- @param self +-- @return bool#bool ret (return value: bool) + +-------------------------------- +-- Get the index of selected radio button.
+-- return the selected button's index. Returns -1 if no button is selected. +-- @function [parent=#RadioButtonGroup] getSelectedButtonIndex +-- @param self +-- @return int#int ret (return value: int) + +-------------------------------- +-- Set a flag for allowing no-selection feature.
+-- If it is allowed, no radio button can be selected.
+-- If it is not allowed, one radio button must be selected all time except it is empty.
+-- Default is not allowed.
+-- param true means allowing no-selection, false means disallowing no-selection. +-- @function [parent=#RadioButtonGroup] setAllowedNoSelection +-- @param self +-- @param #bool allowedNoSelection +-- @return RadioButtonGroup#RadioButtonGroup self (return value: ccui.RadioButtonGroup) + +-------------------------------- +-- Add a callback function which would be called when radio button is selected or unselected.
+-- param callback A std::function with type @see `ccRadioButtonGroupCallback` +-- @function [parent=#RadioButtonGroup] addEventListener +-- @param self +-- @param #function callback +-- @return RadioButtonGroup#RadioButtonGroup self (return value: ccui.RadioButtonGroup) + +-------------------------------- +-- Get a radio button in this group by index.
+-- param index of the radio button
+-- return radio button instance. Returns nullptr if out of index. +-- @function [parent=#RadioButtonGroup] getRadioButtonByIndex +-- @param self +-- @param #int index +-- @return RadioButton#RadioButton ret (return value: ccui.RadioButton) + +-------------------------------- +-- Get the number of radio buttons in this group.
+-- return the number of radio buttons in this group +-- @function [parent=#RadioButtonGroup] getNumberOfRadioButtons +-- @param self +-- @return long#long ret (return value: long) + +-------------------------------- +-- Add a radio button into this group.
+-- param radio button instance +-- @function [parent=#RadioButtonGroup] addRadioButton +-- @param self +-- @param #ccui.RadioButton radioButton +-- @return RadioButtonGroup#RadioButtonGroup self (return value: ccui.RadioButtonGroup) + +-------------------------------- +-- @overload self, ccui.RadioButton +-- @overload self, int +-- @function [parent=#RadioButtonGroup] setSelectedButton +-- @param self +-- @param #int index +-- @return RadioButtonGroup#RadioButtonGroup self (return value: ccui.RadioButtonGroup) + +-------------------------------- +-- Create and return a empty RadioButtonGroup instance pointer. +-- @function [parent=#RadioButtonGroup] create +-- @param self +-- @return RadioButtonGroup#RadioButtonGroup ret (return value: ccui.RadioButtonGroup) + +-------------------------------- +-- +-- @function [parent=#RadioButtonGroup] getDescription +-- @param self +-- @return string#string ret (return value: string) + +-------------------------------- +-- Default constructor.
+-- lua new +-- @function [parent=#RadioButtonGroup] RadioButtonGroup +-- @param self +-- @return RadioButtonGroup#RadioButtonGroup self (return value: ccui.RadioButtonGroup) + +return nil diff --git a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_ui_auto_api.lua b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_ui_auto_api.lua index fae3758e25..18f8e8be60 100644 --- a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_ui_auto_api.lua +++ b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_ui_auto_api.lua @@ -41,6 +41,16 @@ -- @field [parent=#ccui] CheckBox#CheckBox CheckBox preloaded module +-------------------------------------------------------- +-- the ccui RadioButton +-- @field [parent=#ccui] RadioButton#RadioButton RadioButton preloaded module + + +-------------------------------------------------------- +-- the ccui RadioButtonGroup +-- @field [parent=#ccui] RadioButtonGroup#RadioButtonGroup RadioButtonGroup preloaded module + + -------------------------------------------------------- -- the ccui ImageView -- @field [parent=#ccui] ImageView#ImageView ImageView preloaded module diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp index 3c33ae510f..1dd4708e57 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp @@ -8830,6 +8830,825 @@ int lua_register_cocos2dx_ui_CheckBox(lua_State* tolua_S) return 1; } +int lua_cocos2dx_ui_RadioButton_addEventListener(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::RadioButton* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.RadioButton",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::RadioButton*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_RadioButton_addEventListener'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::function arg0; + + do { + // Lambda binding for lua is not supported. + assert(false); + } while(0) + ; + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_RadioButton_addEventListener'", nullptr); + return 0; + } + cobj->addEventListener(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.RadioButton:addEventListener",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_RadioButton_addEventListener'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_RadioButton_create(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"ccui.RadioButton",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S)-1; + + do + { + if (argc == 5) + { + std::string arg0; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.RadioButton:create"); + if (!ok) { break; } + std::string arg1; + ok &= luaval_to_std_string(tolua_S, 3,&arg1, "ccui.RadioButton:create"); + if (!ok) { break; } + std::string arg2; + ok &= luaval_to_std_string(tolua_S, 4,&arg2, "ccui.RadioButton:create"); + if (!ok) { break; } + std::string arg3; + ok &= luaval_to_std_string(tolua_S, 5,&arg3, "ccui.RadioButton:create"); + if (!ok) { break; } + std::string arg4; + ok &= luaval_to_std_string(tolua_S, 6,&arg4, "ccui.RadioButton:create"); + if (!ok) { break; } + cocos2d::ui::RadioButton* ret = cocos2d::ui::RadioButton::create(arg0, arg1, arg2, arg3, arg4); + object_to_luaval(tolua_S, "ccui.RadioButton",(cocos2d::ui::RadioButton*)ret); + return 1; + } + } while (0); + ok = true; + do + { + if (argc == 6) + { + std::string arg0; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.RadioButton:create"); + if (!ok) { break; } + std::string arg1; + ok &= luaval_to_std_string(tolua_S, 3,&arg1, "ccui.RadioButton:create"); + if (!ok) { break; } + std::string arg2; + ok &= luaval_to_std_string(tolua_S, 4,&arg2, "ccui.RadioButton:create"); + if (!ok) { break; } + std::string arg3; + ok &= luaval_to_std_string(tolua_S, 5,&arg3, "ccui.RadioButton:create"); + if (!ok) { break; } + std::string arg4; + ok &= luaval_to_std_string(tolua_S, 6,&arg4, "ccui.RadioButton:create"); + if (!ok) { break; } + cocos2d::ui::Widget::TextureResType arg5; + ok &= luaval_to_int32(tolua_S, 7,(int *)&arg5, "ccui.RadioButton:create"); + if (!ok) { break; } + cocos2d::ui::RadioButton* ret = cocos2d::ui::RadioButton::create(arg0, arg1, arg2, arg3, arg4, arg5); + object_to_luaval(tolua_S, "ccui.RadioButton",(cocos2d::ui::RadioButton*)ret); + return 1; + } + } while (0); + ok = true; + do + { + if (argc == 0) + { + cocos2d::ui::RadioButton* ret = cocos2d::ui::RadioButton::create(); + object_to_luaval(tolua_S, "ccui.RadioButton",(cocos2d::ui::RadioButton*)ret); + return 1; + } + } while (0); + ok = true; + do + { + if (argc == 2) + { + std::string arg0; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.RadioButton:create"); + if (!ok) { break; } + std::string arg1; + ok &= luaval_to_std_string(tolua_S, 3,&arg1, "ccui.RadioButton:create"); + if (!ok) { break; } + cocos2d::ui::RadioButton* ret = cocos2d::ui::RadioButton::create(arg0, arg1); + object_to_luaval(tolua_S, "ccui.RadioButton",(cocos2d::ui::RadioButton*)ret); + return 1; + } + } while (0); + ok = true; + do + { + if (argc == 3) + { + std::string arg0; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccui.RadioButton:create"); + if (!ok) { break; } + std::string arg1; + ok &= luaval_to_std_string(tolua_S, 3,&arg1, "ccui.RadioButton:create"); + if (!ok) { break; } + cocos2d::ui::Widget::TextureResType arg2; + ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2, "ccui.RadioButton:create"); + if (!ok) { break; } + cocos2d::ui::RadioButton* ret = cocos2d::ui::RadioButton::create(arg0, arg1, arg2); + object_to_luaval(tolua_S, "ccui.RadioButton",(cocos2d::ui::RadioButton*)ret); + return 1; + } + } while (0); + ok = true; + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "ccui.RadioButton:create",argc, 2); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_RadioButton_create'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_ui_RadioButton_createInstance(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"ccui.RadioButton",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_RadioButton_createInstance'", nullptr); + return 0; + } + cocos2d::Ref* ret = cocos2d::ui::RadioButton::createInstance(); + object_to_luaval(tolua_S, "cc.Ref",(cocos2d::Ref*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccui.RadioButton:createInstance",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_RadioButton_createInstance'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_ui_RadioButton_constructor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::RadioButton* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_RadioButton_constructor'", nullptr); + return 0; + } + cobj = new cocos2d::ui::RadioButton(); + cobj->autorelease(); + int ID = (int)cobj->_ID ; + int* luaID = &cobj->_luaID ; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.RadioButton"); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.RadioButton:RadioButton",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_RadioButton_constructor'.",&tolua_err); +#endif + + return 0; +} + +static int lua_cocos2dx_ui_RadioButton_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (RadioButton)"); + return 0; +} + +int lua_register_cocos2dx_ui_RadioButton(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"ccui.RadioButton"); + tolua_cclass(tolua_S,"RadioButton","ccui.RadioButton","ccui.AbstractCheckButton",nullptr); + + tolua_beginmodule(tolua_S,"RadioButton"); + tolua_function(tolua_S,"new",lua_cocos2dx_ui_RadioButton_constructor); + tolua_function(tolua_S,"addEventListener",lua_cocos2dx_ui_RadioButton_addEventListener); + tolua_function(tolua_S,"create", lua_cocos2dx_ui_RadioButton_create); + tolua_function(tolua_S,"createInstance", lua_cocos2dx_ui_RadioButton_createInstance); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::ui::RadioButton).name(); + g_luaType[typeName] = "ccui.RadioButton"; + g_typeCast["RadioButton"] = "ccui.RadioButton"; + return 1; +} + +int lua_cocos2dx_ui_RadioButtonGroup_removeRadioButton(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::RadioButtonGroup* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.RadioButtonGroup",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::RadioButtonGroup*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_RadioButtonGroup_removeRadioButton'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::ui::RadioButton* arg0; + + ok &= luaval_to_object(tolua_S, 2, "ccui.RadioButton",&arg0, "ccui.RadioButtonGroup:removeRadioButton"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_RadioButtonGroup_removeRadioButton'", nullptr); + return 0; + } + cobj->removeRadioButton(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.RadioButtonGroup:removeRadioButton",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_RadioButtonGroup_removeRadioButton'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_RadioButtonGroup_isAllowedNoSelection(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::RadioButtonGroup* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.RadioButtonGroup",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::RadioButtonGroup*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_RadioButtonGroup_isAllowedNoSelection'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_RadioButtonGroup_isAllowedNoSelection'", nullptr); + return 0; + } + bool ret = cobj->isAllowedNoSelection(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.RadioButtonGroup:isAllowedNoSelection",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_RadioButtonGroup_isAllowedNoSelection'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_RadioButtonGroup_getSelectedButtonIndex(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::RadioButtonGroup* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.RadioButtonGroup",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::RadioButtonGroup*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_RadioButtonGroup_getSelectedButtonIndex'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_RadioButtonGroup_getSelectedButtonIndex'", nullptr); + return 0; + } + int ret = cobj->getSelectedButtonIndex(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.RadioButtonGroup:getSelectedButtonIndex",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_RadioButtonGroup_getSelectedButtonIndex'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_RadioButtonGroup_setAllowedNoSelection(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::RadioButtonGroup* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.RadioButtonGroup",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::RadioButtonGroup*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_RadioButtonGroup_setAllowedNoSelection'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + bool arg0; + + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ccui.RadioButtonGroup:setAllowedNoSelection"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_RadioButtonGroup_setAllowedNoSelection'", nullptr); + return 0; + } + cobj->setAllowedNoSelection(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.RadioButtonGroup:setAllowedNoSelection",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_RadioButtonGroup_setAllowedNoSelection'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_RadioButtonGroup_addEventListener(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::RadioButtonGroup* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.RadioButtonGroup",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::RadioButtonGroup*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_RadioButtonGroup_addEventListener'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::function arg0; + + do { + // Lambda binding for lua is not supported. + assert(false); + } while(0) + ; + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_RadioButtonGroup_addEventListener'", nullptr); + return 0; + } + cobj->addEventListener(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.RadioButtonGroup:addEventListener",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_RadioButtonGroup_addEventListener'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_RadioButtonGroup_getRadioButtonByIndex(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::RadioButtonGroup* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.RadioButtonGroup",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::RadioButtonGroup*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_RadioButtonGroup_getRadioButtonByIndex'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + int arg0; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccui.RadioButtonGroup:getRadioButtonByIndex"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_RadioButtonGroup_getRadioButtonByIndex'", nullptr); + return 0; + } + cocos2d::ui::RadioButton* ret = cobj->getRadioButtonByIndex(arg0); + object_to_luaval(tolua_S, "ccui.RadioButton",(cocos2d::ui::RadioButton*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.RadioButtonGroup:getRadioButtonByIndex",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_RadioButtonGroup_getRadioButtonByIndex'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_RadioButtonGroup_getNumberOfRadioButtons(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::RadioButtonGroup* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.RadioButtonGroup",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::RadioButtonGroup*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_RadioButtonGroup_getNumberOfRadioButtons'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_RadioButtonGroup_getNumberOfRadioButtons'", nullptr); + return 0; + } + ssize_t ret = cobj->getNumberOfRadioButtons(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.RadioButtonGroup:getNumberOfRadioButtons",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_RadioButtonGroup_getNumberOfRadioButtons'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_RadioButtonGroup_addRadioButton(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::RadioButtonGroup* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.RadioButtonGroup",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::RadioButtonGroup*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_RadioButtonGroup_addRadioButton'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::ui::RadioButton* arg0; + + ok &= luaval_to_object(tolua_S, 2, "ccui.RadioButton",&arg0, "ccui.RadioButtonGroup:addRadioButton"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_RadioButtonGroup_addRadioButton'", nullptr); + return 0; + } + cobj->addRadioButton(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.RadioButtonGroup:addRadioButton",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_RadioButtonGroup_addRadioButton'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_RadioButtonGroup_setSelectedButton(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::RadioButtonGroup* cobj = nullptr; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.RadioButtonGroup",0,&tolua_err)) goto tolua_lerror; +#endif + cobj = (cocos2d::ui::RadioButtonGroup*)tolua_tousertype(tolua_S,1,0); +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_RadioButtonGroup_setSelectedButton'", nullptr); + return 0; + } +#endif + argc = lua_gettop(tolua_S)-1; + do{ + if (argc == 1) { + cocos2d::ui::RadioButton* arg0; + ok &= luaval_to_object(tolua_S, 2, "ccui.RadioButton",&arg0, "ccui.RadioButtonGroup:setSelectedButton"); + + if (!ok) { break; } + cobj->setSelectedButton(arg0); + lua_settop(tolua_S, 1); + return 1; + } + }while(0); + ok = true; + do{ + if (argc == 1) { + int arg0; + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccui.RadioButtonGroup:setSelectedButton"); + + if (!ok) { break; } + cobj->setSelectedButton(arg0); + lua_settop(tolua_S, 1); + return 1; + } + }while(0); + ok = true; + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.RadioButtonGroup:setSelectedButton",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_RadioButtonGroup_setSelectedButton'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_RadioButtonGroup_create(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"ccui.RadioButtonGroup",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_RadioButtonGroup_create'", nullptr); + return 0; + } + cocos2d::ui::RadioButtonGroup* ret = cocos2d::ui::RadioButtonGroup::create(); + object_to_luaval(tolua_S, "ccui.RadioButtonGroup",(cocos2d::ui::RadioButtonGroup*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccui.RadioButtonGroup:create",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_RadioButtonGroup_create'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_ui_RadioButtonGroup_constructor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::RadioButtonGroup* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_RadioButtonGroup_constructor'", nullptr); + return 0; + } + cobj = new cocos2d::ui::RadioButtonGroup(); + cobj->autorelease(); + int ID = (int)cobj->_ID ; + int* luaID = &cobj->_luaID ; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.RadioButtonGroup"); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.RadioButtonGroup:RadioButtonGroup",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_RadioButtonGroup_constructor'.",&tolua_err); +#endif + + return 0; +} + +static int lua_cocos2dx_ui_RadioButtonGroup_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (RadioButtonGroup)"); + return 0; +} + +int lua_register_cocos2dx_ui_RadioButtonGroup(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"ccui.RadioButtonGroup"); + tolua_cclass(tolua_S,"RadioButtonGroup","ccui.RadioButtonGroup","ccui.Widget",nullptr); + + tolua_beginmodule(tolua_S,"RadioButtonGroup"); + tolua_function(tolua_S,"new",lua_cocos2dx_ui_RadioButtonGroup_constructor); + tolua_function(tolua_S,"removeRadioButton",lua_cocos2dx_ui_RadioButtonGroup_removeRadioButton); + tolua_function(tolua_S,"isAllowedNoSelection",lua_cocos2dx_ui_RadioButtonGroup_isAllowedNoSelection); + tolua_function(tolua_S,"getSelectedButtonIndex",lua_cocos2dx_ui_RadioButtonGroup_getSelectedButtonIndex); + tolua_function(tolua_S,"setAllowedNoSelection",lua_cocos2dx_ui_RadioButtonGroup_setAllowedNoSelection); + tolua_function(tolua_S,"addEventListener",lua_cocos2dx_ui_RadioButtonGroup_addEventListener); + tolua_function(tolua_S,"getRadioButtonByIndex",lua_cocos2dx_ui_RadioButtonGroup_getRadioButtonByIndex); + tolua_function(tolua_S,"getNumberOfRadioButtons",lua_cocos2dx_ui_RadioButtonGroup_getNumberOfRadioButtons); + tolua_function(tolua_S,"addRadioButton",lua_cocos2dx_ui_RadioButtonGroup_addRadioButton); + tolua_function(tolua_S,"setSelectedButton",lua_cocos2dx_ui_RadioButtonGroup_setSelectedButton); + tolua_function(tolua_S,"create", lua_cocos2dx_ui_RadioButtonGroup_create); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::ui::RadioButtonGroup).name(); + g_luaType[typeName] = "ccui.RadioButtonGroup"; + g_typeCast["RadioButtonGroup"] = "ccui.RadioButtonGroup"; + return 1; +} + int lua_cocos2dx_ui_ImageView_loadTexture(lua_State* tolua_S) { int argc = 0; @@ -28422,12 +29241,14 @@ TOLUA_API int register_all_cocos2dx_ui(lua_State* tolua_S) lua_register_cocos2dx_ui_RichElementCustomNode(tolua_S); lua_register_cocos2dx_ui_VBox(tolua_S); lua_register_cocos2dx_ui_Slider(tolua_S); + lua_register_cocos2dx_ui_RadioButtonGroup(tolua_S); lua_register_cocos2dx_ui_ScrollView(tolua_S); lua_register_cocos2dx_ui_ListView(tolua_S); lua_register_cocos2dx_ui_LayoutComponent(tolua_S); lua_register_cocos2dx_ui_Button(tolua_S); lua_register_cocos2dx_ui_LayoutParameter(tolua_S); lua_register_cocos2dx_ui_LinearLayoutParameter(tolua_S); + lua_register_cocos2dx_ui_RadioButton(tolua_S); lua_register_cocos2dx_ui_ImageView(tolua_S); lua_register_cocos2dx_ui_HBox(tolua_S); lua_register_cocos2dx_ui_RichElementText(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp index 1bae8ec233..e88a593786 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp @@ -573,6 +573,23 @@ int register_all_cocos2dx_ui(lua_State* tolua_S); + + + + + + + + + + + + + + + + + From a4fec3a5e05cf1b3017377e4da767d7ad6825126 Mon Sep 17 00:00:00 2001 From: VisualSj Date: Thu, 20 Aug 2015 17:02:41 +0800 Subject: [PATCH 027/118] Update Studio js parser --- .../js-bindings/script/studio/parsers/action-2.x.js | 1 + .../js-bindings/script/studio/parsers/timelineParser-2.x.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/cocos/scripting/js-bindings/script/studio/parsers/action-2.x.js b/cocos/scripting/js-bindings/script/studio/parsers/action-2.x.js index 6c203a54f1..34e435a8d0 100644 --- a/cocos/scripting/js-bindings/script/studio/parsers/action-2.x.js +++ b/cocos/scripting/js-bindings/script/studio/parsers/action-2.x.js @@ -268,6 +268,7 @@ var blendFunc = options["BlendFunc"]; if(blendFunc) frame.setBlendFunc(new cc.BlendFunc(blendFunc["Src"], blendFunc["Dst"])); + return frame; } } ]; diff --git a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js index d584097b6f..1ecc5a070b 100644 --- a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js +++ b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js @@ -1312,12 +1312,18 @@ node.setBlendFunc(new cc.BlendFunc(blendFunc["Src"] || 0, blendFunc["Dst"] || 0)); parser.generalAttributes(node, json); + var color = json["CColor"]; + if(color && (color["R"] !== undefined || color["G"] !== undefined || color["B"] !== undefined)) + node.setColor(getColor(color)); return node; }; parser.initSkeletonNode = function(json){ var node = new ccs.SkeletonNode(); parser.generalAttributes(node, json); + var color = json["CColor"]; + if(color && (color["R"] !== undefined || color["G"] !== undefined || color["B"] !== undefined)) + node.setColor(getColor(color)); return node; }; From f133e5a7549672a0e4b28b37cb10130c34ffd295 Mon Sep 17 00:00:00 2001 From: fusijie Date: Thu, 20 Aug 2015 17:07:53 +0800 Subject: [PATCH 028/118] Fixed SpriteProgressToRadialMidpointChanged bug. --- cocos/2d/CCProgressTimer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cocos/2d/CCProgressTimer.cpp b/cocos/2d/CCProgressTimer.cpp index 9bf7e9f324..cb6a0787f3 100644 --- a/cocos/2d/CCProgressTimer.cpp +++ b/cocos/2d/CCProgressTimer.cpp @@ -114,9 +114,8 @@ void ProgressTimer::setSprite(Sprite *sprite) { CC_SAFE_FREE(_vertexData); _vertexDataCount = 0; + updateProgress(); } - - updateProgress(); } } From 10d5b73c7e49940faa0c47f1fd25e482bc0a090d Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Thu, 20 Aug 2015 17:42:26 +0800 Subject: [PATCH 029/118] fix opengl test error fix opengl test error, add the condition, when the data type is samewith long, it will reset data relate pr:#13449 fix open gl show error --- .../manual/js_manual_conversions.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp b/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp index e3c026cc2d..20a2bf7e9f 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp @@ -187,8 +187,12 @@ bool jsval_to_int( JSContext *cx, JS::HandleValue vp, int *ret ) // Since this is called to cast uint64 to uint32, // it is needed to initialize the value to 0 first #ifdef __LP64__ - long *tmp = (long*)ret; - *tmp = 0; + // When int size is 8 Bit (same as long), the following operation is needed + if (sizeof(int) == 8) + { + long *tmp = (long*)ret; + *tmp = 0; + } #endif return jsval_to_int32(cx, vp, (int32_t*)ret); } @@ -243,8 +247,12 @@ bool jsval_to_uint( JSContext *cx, JS::HandleValue vp, unsigned int *ret ) // Since this is called to cast uint64 to uint32, // it is needed to initialize the value to 0 first #ifdef __LP64__ - long *tmp = (long*)ret; - *tmp = 0; + // When unsigned int size is 8 Bit (same as long), the following operation is needed + if (sizeof(unsigned int)==8) + { + long *tmp = (long*)ret; + *tmp = 0; + } #endif return jsval_to_int32(cx, vp, (int32_t*)ret); } @@ -2841,4 +2849,4 @@ jsval std_map_string_string_to_jsval(JSContext* cx, const std::map Date: Thu, 20 Aug 2015 09:49:05 +0000 Subject: [PATCH 030/118] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index e139575b25..8dcf68e30c 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -6689,6 +6689,8 @@ "cocos/scripting/lua-bindings/auto/api/ProgressTo.lua", "cocos/scripting/lua-bindings/auto/api/Properties.lua", "cocos/scripting/lua-bindings/auto/api/ProtectedNode.lua", + "cocos/scripting/lua-bindings/auto/api/RadioButton.lua", + "cocos/scripting/lua-bindings/auto/api/RadioButtonGroup.lua", "cocos/scripting/lua-bindings/auto/api/Ref.lua", "cocos/scripting/lua-bindings/auto/api/RelativeBox.lua", "cocos/scripting/lua-bindings/auto/api/RelativeLayoutParameter.lua", From 788be3016a7c8e18d5279a0aef72da0b7531e172 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 20 Aug 2015 18:04:49 +0800 Subject: [PATCH 031/118] update annotation --- .../cocostudio/WidgetReader/GameMapReader/GameMapReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.cpp index f75e4780f5..b367709f92 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.cpp @@ -235,7 +235,7 @@ namespace cocostudio tmx = TMXTiledMap::create(path); if (tmx) { - //Ïȱ£´æ×ÊÔ´µÄ³ß´ç£¬µÈ±à¼­Æ÷µÄÊý¾ÝÉèÖÃÍê³Éºó£¬ÔÙË¢»Ø×ÊÔ´³ß´ç£¬·ÀÖ¹Êý¾ÝÖгߴçºÍ×ÊÔ´²¿Æ¥Åä + //prevent that editor's data does not match in size and resources Size fileSize = tmx->getContentSize(); setPropsWithFlatBuffers(tmx, (Table*)gameMapOptions); tmx->setContentSize(fileSize); From 895c29efe415c8224a6415e90cff309d6d56d3a8 Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Thu, 20 Aug 2015 18:11:05 +0800 Subject: [PATCH 032/118] fix texturecache didn't show correctly in win32 --- cocos/network/CCDownloader.cpp | 14 +++++++------- cocos/network/CCDownloaderImpl.cpp | 8 ++++++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cocos/network/CCDownloader.cpp b/cocos/network/CCDownloader.cpp index e47894c375..cb693aefbd 100644 --- a/cocos/network/CCDownloader.cpp +++ b/cocos/network/CCDownloader.cpp @@ -197,18 +197,18 @@ void Downloader::downloadToBuffer(const std::string& srcUrl, const std::string& CC_ASSERT(_downloaderImpl && "Cannot instanciate more than one instance of DownloaderImpl"); - DownloadUnit unit; - unit.srcUrl = srcUrl; - unit.customId = customId; - unit.fp = buffer; - unit.downloaded = 0; - unit.totalToDownload = 0; - StreamData streamBuffer; streamBuffer.buffer = buffer; streamBuffer.total = size; streamBuffer.offset = 0; + DownloadUnit unit; + unit.srcUrl = srcUrl; + unit.customId = customId; + unit.fp = &streamBuffer; + unit.downloaded = 0; + unit.totalToDownload = 0; + int res = _downloaderImpl->performDownload(&unit, std::bind(&Downloader::bufferWriteFunc, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), std::bind(&Downloader::downloadProgressFunc, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3) diff --git a/cocos/network/CCDownloaderImpl.cpp b/cocos/network/CCDownloaderImpl.cpp index 2616253d99..dad831d186 100644 --- a/cocos/network/CCDownloaderImpl.cpp +++ b/cocos/network/CCDownloaderImpl.cpp @@ -48,7 +48,10 @@ static size_t _fileWriteFunc(void *ptr, size_t size, size_t nmemb, void* userdat int ret = this_->getWriterCallback()(ptr, size, nmemb, unit); return ret; } - +static size_t _fileWriteFuncForAdapter(void *ptr, size_t size, size_t nmemb, void* userdata) +{ + return nmemb; +} static int _downloadProgressFunc(void* userdata, double totalToDownload, double nowDownloaded, double totalToUpLoad, double nowUpLoaded) { DownloadUnit *downloadUnit = (DownloadUnit*)userdata; @@ -284,7 +287,8 @@ int DownloaderImpl::getHeader(const std::string& url, HeaderInfo* headerInfo) curl_easy_setopt(curlHandle, CURLOPT_HEADER, 1); curl_easy_setopt(curlHandle, CURLOPT_NOBODY, 1); curl_easy_setopt(curlHandle, CURLOPT_NOSIGNAL, 1); - + // in win32 platform, if not set the writeFunction, it will return CURLE_WRITE_ERROR + curl_easy_setopt(curlHandle, CURLOPT_WRITEFUNCTION, _fileWriteFuncForAdapter); if ((_lastErrCode=curl_easy_perform(curlHandle)) == CURLE_OK) { char *effectiveUrl; From 15156a015a76d72b1233db4a65aeb21b17894f53 Mon Sep 17 00:00:00 2001 From: andyque Date: Thu, 20 Aug 2015 22:49:42 +0800 Subject: [PATCH 033/118] add RadioButton and RadioButtonGroup event type --- .../manual/ui/lua_cocos2dx_ui_manual.cpp | 136 ++++++++++++++++++ .../lua-bindings/script/ui/GuiConstants.lua | 11 ++ .../CocoStudioGUITest/CocoStudioGUITest.lua | 11 ++ 3 files changed, 158 insertions(+) diff --git a/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_ui_manual.cpp b/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_ui_manual.cpp index 68749b939d..0cc46d6774 100644 --- a/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_ui_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_ui_manual.cpp @@ -235,6 +235,140 @@ static void extendCheckBox(lua_State* L) lua_pop(L, 1); } +static int lua_cocos2dx_RadioButton_addEventListener(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + RadioButton* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"ccui.RadioButton",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_RadioButton_addEventListener'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) + { + goto tolua_lerror; + } +#endif + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + + self->addEventListener([=](RadioButton* radioButton,RadioButton::EventType eventType){ + LuaStack* stack = LuaEngine::getInstance()->getLuaStack(); + stack->pushObject(radioButton, "ccui.RadioButton"); + stack->pushInt((int)eventType); + + stack->executeFunctionByHandler(handler, 2); + stack->clean(); + }); + + ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler); + return 0; + } + + luaL_error(L, "'addEventListener' function of CheckBox has wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'addEventListener'.",&tolua_err); + return 0; +#endif +} + +static void extendRadioButton(lua_State* L) +{ + lua_pushstring(L, "ccui.RadioButton"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "addEventListener", lua_cocos2dx_RadioButton_addEventListener); + } + lua_pop(L, 1); +} + +static int lua_cocos2dx_RadioButtonGroup_addEventListener(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + RadioButtonGroup* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"ccui.RadioButtonGroup",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_RadioButtonGroup_addEventListener'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) + { + goto tolua_lerror; + } +#endif + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + + self->addEventListener([=](RadioButton* radioButton,int index,RadioButtonGroup::EventType eventType){ + LuaStack* stack = LuaEngine::getInstance()->getLuaStack(); + + stack->pushObject(radioButton, "ccui.RadioButton"); + stack->pushInt(index); + stack->pushInt((int)eventType); + + stack->executeFunctionByHandler(handler, 3); + stack->clean(); + }); + + ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler); + return 0; + } + + luaL_error(L, "'addEventListener' function of RadioButtonGroup has wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'addEventListener'.",&tolua_err); + return 0; +#endif +} + +static void extendRadioButtonGroup(lua_State* L) +{ + lua_pushstring(L, "ccui.RadioButtonGroup"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "addEventListener", lua_cocos2dx_RadioButtonGroup_addEventListener); + } + lua_pop(L, 1); +} + static int lua_cocos2dx_Slider_addEventListener(lua_State* L) { if (nullptr == L) @@ -850,6 +984,8 @@ int register_all_cocos2dx_ui_manual(lua_State* L) return 0; extendWidget(L); extendCheckBox(L); + extendRadioButton(L); + extendRadioButtonGroup(L); extendSlider(L); extendTextField(L); extendPageView(L); diff --git a/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua b/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua index 5ee6a22cd2..3a522ffa40 100644 --- a/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua +++ b/cocos/scripting/lua-bindings/script/ui/GuiConstants.lua @@ -40,6 +40,17 @@ ccui.CheckBoxEventType = unselected = 1, } +ccui.RadioButtonEventType= +{ + selected = 0, + unselected = 1 +} + +ccui.RadioButtonGroupEventType= +{ + select_changed = 0 +} + ccui.TextFiledEventType = { attach_with_ime = 0, diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua index ebd6562360..6a6ac7b451 100644 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua +++ b/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua @@ -390,6 +390,9 @@ add_new_testcase(function() self._uiLayer:addChild(alert) local radioButtonGroup = ccui.RadioButtonGroup:create() + radioButtonGroup:addEventListener(function(radioButton, index, type) + print("RadioButton" .. index .. "Clicked") + end) self._uiLayer:addChild(radioButtonGroup) local NUMBER_OF_BUTTONS = 5 @@ -399,7 +402,15 @@ add_new_testcase(function() local radioButton = ccui.RadioButton:create("cocosui/radio_button_off.png", "cocosui/radio_button_on.png") local posX = startPosX + BUTTON_WIDTH * i radioButton:setPosition(cc.p(posX, widgetSize.height / 2.0 + 10)) + radioButton:setName("button"..i) radioButtonGroup:addRadioButton(radioButton) + radioButton:addEventListener(function(radioButton, type) + if type == ccui.RadioButtonEventType.selected then + print("name: = " .. radioButton:getName() .. " selected") + elseif type == ccui.RadioButtonEventType.unselected then + print("name: = " .. radioButton:getName() .. " unselected") + end + end) self._uiLayer:addChild(radioButton) end From f49e6fda85c9b62eff492af48da3cb9e221aafc1 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Thu, 20 Aug 2015 11:13:17 -0700 Subject: [PATCH 034/118] updated Win10 UWP requirements --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d1826ea6fe..d5d0021dc6 100644 --- a/README.md +++ b/README.md @@ -104,10 +104,10 @@ Run * Visual Studio 2013 Update 4 or later is required for Windows 8.1 Universal Apps -* Visual Studio 2015 RC and Windows 10.0 (build 10074 or higher) is required for Windows 10.0 UWP Apps +* Visual Studio 2015 (Release version) and Windows 10.0 (Release version) are required for Windows 10.0 Universal Windows Platform (UWP) Apps. RC versions of Visual Studio and Window 10 are no longer supported. Starting with Cocos2d-x v3.3, you can create Windows 8.1 Universal Apps (Windows Store and Windows Phone 8.1). -Starting with Cocos2d-x v3.6 you can create Windows 10.0 UWP Apps (Windows Store and Windows Phone 10.0). +Starting with Cocos2d-x v3.8 you can create Windows 10.0 UWP Apps (Windows Store and Windows Phone 10.0). Starting with Cocos2d-x v3.6 there will no longer be support for Windows Phone 8.0. 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/ @@ -176,14 +176,15 @@ Build Requirements * or Windows 7+, VS 2013+ * Python 2.7.5 * NDK r10c+ is required to build Android games -* Windows Phone/Store 8.1 VS 2013 Update 4+ +* Windows Phone/Store 8.1 VS 2013 Update 4+ or VS 2015 +* Windows Phone/Store 10.0 VS 2015 * JRE or JDK 1.6+ is required for web publishing Runtime Requirements -------------------- * iOS 5.0+ for iPhone / iPad games * Android 2.3+ for Android games - * Windows 8.1 for Windows Phone/Store 8.1 games + * Windows 8.1 or Windows 10.0 for Windows Phone/Store 8.1 games * Windows 10.0 for Windows Phone/Store 10.0 games * OS X v10.6+ for Mac games * Windows 7+ for Win games From d55bc653e0e5c80c4f08ee34a0717935500cfa03 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Thu, 20 Aug 2015 13:25:17 -0700 Subject: [PATCH 035/118] update c++ debug info settings --- .../libcocos2d_8_1.Windows.vcxproj | 6 ++++++ .../libcocos2d_8_1.WindowsPhone.vcxproj | 4 ++++ cocos/2d/libcocos2d_win10/libcocos2d.vcxproj | 2 ++ .../editor-support/spine/proj.win10/libSpine.vcxproj | 8 ++++++++ .../libSpine.Windows/libSpine.Windows.vcxproj | 12 ++++++++++++ .../libSpine.WindowsPhone.vcxproj | 8 ++++++++ .../libjscocos2d.Windows.vcxproj | 11 +++++++---- .../libjscocos2d.WindowsPhone.vcxproj | 8 +++++--- .../cpp-empty-test/proj.win10/cpp-empty-test.vcxproj | 3 ++- .../HelloCpp.Windows/HelloCpp.Windows.vcxproj | 6 ++++++ .../HelloCpp.WindowsPhone.vcxproj | 4 ++++ tests/cpp-tests/proj.win10/cpp-tests.vcxproj | 2 ++ .../cpp-tests.Windows/cpp-tests.Windows.vcxproj | 8 +++++++- .../cpp-tests.WindowsPhone.vcxproj | 6 +++++- .../App.Windows/js-tests.Windows.vcxproj | 6 ++++++ .../App.WindowsPhone/js-tests.WindowsPhone.vcxproj | 6 +++++- 16 files changed, 89 insertions(+), 11 deletions(-) diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj index b0a4774f5e..a834e12594 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj @@ -166,6 +166,7 @@ _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) + ProgramDatabase Console @@ -187,6 +188,7 @@ _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) + ProgramDatabase Console @@ -207,6 +209,7 @@ _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) + ProgramDatabase Console @@ -228,6 +231,7 @@ _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) + ProgramDatabase Console @@ -248,6 +252,7 @@ _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) + ProgramDatabase Console @@ -269,6 +274,7 @@ _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) + ProgramDatabase Console diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj index 09ede23e91..36897d70d2 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj @@ -120,6 +120,7 @@ CC_WINDOWS_PHONE_8_1;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) + ProgramDatabase Console @@ -141,6 +142,7 @@ CC_WINDOWS_PHONE_8_1;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) + ProgramDatabase Console @@ -161,6 +163,7 @@ CC_WINDOWS_PHONE_8_1;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) + ProgramDatabase Console @@ -182,6 +185,7 @@ CC_WINDOWS_PHONE_8_1;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) + ProgramDatabase Console diff --git a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj index c23471ad51..5f0d9efca4 100644 --- a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj @@ -1560,6 +1560,7 @@ $(EngineRoot)external\win10-specific\zlib\include;$(EngineRoot)external\freetype2\include\win10\freetype2;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;$(EngineRoot)external\win10-specific\OggDecoder\include;%(AdditionalIncludeDirectories) /Zm384 /bigobj %(AdditionalOptions) false + ProgramDatabase Console @@ -1637,6 +1638,7 @@ $(EngineRoot)external\win10-specific\zlib\include;$(EngineRoot)external\freetype2\include\win10\freetype2;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;$(EngineRoot)external\win10-specific\OggDecoder\include;%(AdditionalIncludeDirectories) /Zm384 /bigobj %(AdditionalOptions) false + ProgramDatabase Console diff --git a/cocos/editor-support/spine/proj.win10/libSpine.vcxproj b/cocos/editor-support/spine/proj.win10/libSpine.vcxproj index 270853bbac..f53067aef1 100644 --- a/cocos/editor-support/spine/proj.win10/libSpine.vcxproj +++ b/cocos/editor-support/spine/proj.win10/libSpine.vcxproj @@ -383,6 +383,7 @@ 4458;4456;4996;%(DisableSpecificWarnings) $(EngineRoot)external\win10-specific\angle\include;%(AdditionalIncludeDirectories) ProgramDatabase + $(OutDir)$(TargetName).pdb Console @@ -401,6 +402,8 @@ false 4458;4456;4996;%(DisableSpecificWarnings) $(EngineRoot)external\win10-specific\angle\include;%(AdditionalIncludeDirectories) + $(OutDir)$(TargetName).pdb + ProgramDatabase Console @@ -420,6 +423,7 @@ 4458;4456;4996;%(DisableSpecificWarnings) $(EngineRoot)external\win10-specific\angle\include;%(AdditionalIncludeDirectories) ProgramDatabase + $(OutDir)$(TargetName).pdb Console @@ -439,6 +443,7 @@ 4458;4456;4996;%(DisableSpecificWarnings) $(EngineRoot)external\win10-specific\angle\include;%(AdditionalIncludeDirectories) ProgramDatabase + $(OutDir)$(TargetName).pdb Console @@ -458,6 +463,7 @@ 4458;4456;4996;%(DisableSpecificWarnings) $(EngineRoot)external\win10-specific\angle\include;%(AdditionalIncludeDirectories) ProgramDatabase + $(OutDir)$(TargetName).pdb Console @@ -476,6 +482,8 @@ false 4458;4456;4996;%(DisableSpecificWarnings) $(EngineRoot)external\win10-specific\angle\include;%(AdditionalIncludeDirectories) + $(OutDir)$(TargetName).pdb + ProgramDatabase Console diff --git a/cocos/editor-support/spine/proj.win8.1-universal/libSpine.Windows/libSpine.Windows.vcxproj b/cocos/editor-support/spine/proj.win8.1-universal/libSpine.Windows/libSpine.Windows.vcxproj index dce8fd1174..9531a55444 100644 --- a/cocos/editor-support/spine/proj.win8.1-universal/libSpine.Windows/libSpine.Windows.vcxproj +++ b/cocos/editor-support/spine/proj.win8.1-universal/libSpine.Windows/libSpine.Windows.vcxproj @@ -129,6 +129,8 @@ WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(EngineRoot)external\winrt_8.1-specific\angle\include;%(AdditionalIncludeDirectories) 4996;%(DisableSpecificWarnings) + ProgramDatabase + $(OutDir)$(TargetName).pdb Console @@ -147,6 +149,8 @@ WIN32;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(EngineRoot)external\winrt_8.1-specific\angle\include;%(AdditionalIncludeDirectories) 4996;%(DisableSpecificWarnings) + ProgramDatabase + $(OutDir)$(TargetName).pdb Console @@ -165,6 +169,8 @@ WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(EngineRoot)external\winrt_8.1-specific\angle\include;%(AdditionalIncludeDirectories) 4996;%(DisableSpecificWarnings) + ProgramDatabase + $(OutDir)$(TargetName).pdb Console @@ -183,6 +189,8 @@ WIN32;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(EngineRoot)external\winrt_8.1-specific\angle\include;%(AdditionalIncludeDirectories) 4996;%(DisableSpecificWarnings) + ProgramDatabase + $(OutDir)$(TargetName).pdb Console @@ -201,6 +209,8 @@ WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(EngineRoot)external\winrt_8.1-specific\angle\include;%(AdditionalIncludeDirectories) 4996;%(DisableSpecificWarnings) + ProgramDatabase + $(OutDir)$(TargetName).pdb Console @@ -219,6 +229,8 @@ WIN32;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(EngineRoot)external\winrt_8.1-specific\angle\include;%(AdditionalIncludeDirectories) 4996;%(DisableSpecificWarnings) + ProgramDatabase + $(OutDir)$(TargetName).pdb Console diff --git a/cocos/editor-support/spine/proj.win8.1-universal/libSpine.WindowsPhone/libSpine.WindowsPhone.vcxproj b/cocos/editor-support/spine/proj.win8.1-universal/libSpine.WindowsPhone/libSpine.WindowsPhone.vcxproj index f9a8f45178..278333145b 100644 --- a/cocos/editor-support/spine/proj.win8.1-universal/libSpine.WindowsPhone/libSpine.WindowsPhone.vcxproj +++ b/cocos/editor-support/spine/proj.win8.1-universal/libSpine.WindowsPhone/libSpine.WindowsPhone.vcxproj @@ -94,6 +94,8 @@ WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(EngineRoot)external\wp_8.1-specific\angle\include;%(AdditionalIncludeDirectories) 4996;%(DisableSpecificWarnings) + ProgramDatabase + $(OutDir)$(TargetName).pdb Console @@ -112,6 +114,8 @@ WIN32;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(EngineRoot)external\wp_8.1-specific\angle\include;%(AdditionalIncludeDirectories) 4996;%(DisableSpecificWarnings) + ProgramDatabase + $(OutDir)$(TargetName).pdb Console @@ -130,6 +134,8 @@ WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(EngineRoot)external\wp_8.1-specific\angle\include;%(AdditionalIncludeDirectories) 4996;%(DisableSpecificWarnings) + ProgramDatabase + $(OutDir)$(TargetName).pdb Console @@ -148,6 +154,8 @@ WIN32;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(EngineRoot)external\wp_8.1-specific\angle\include;%(AdditionalIncludeDirectories) 4996;%(DisableSpecificWarnings) + ProgramDatabase + $(OutDir)$(TargetName).pdb Console diff --git a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj index 1a7926f54d..0a007232a3 100644 --- a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj +++ b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj @@ -131,6 +131,7 @@ Level3 CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) true + ProgramDatabase Console @@ -151,7 +152,7 @@ Level3 CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) false - OldStyle + ProgramDatabase Console @@ -173,6 +174,7 @@ Level3 CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) true + ProgramDatabase Console @@ -193,7 +195,7 @@ Level3 CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) false - OldStyle + ProgramDatabase Console @@ -215,6 +217,7 @@ Level3 CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) true + ProgramDatabase Console @@ -235,7 +238,7 @@ Level3 CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) false - OldStyle + ProgramDatabase Console @@ -250,4 +253,4 @@ - + \ No newline at end of file diff --git a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj index f2b5f8c7f0..89be7f39b6 100644 --- a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj +++ b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj @@ -96,6 +96,7 @@ Level3 CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) true + ProgramDatabase Console @@ -116,7 +117,7 @@ Level3 CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) false - OldStyle + ProgramDatabase Console @@ -138,6 +139,7 @@ Level3 CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) true + ProgramDatabase Console @@ -158,7 +160,7 @@ Level3 CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) false - OldStyle + ProgramDatabase Console @@ -173,4 +175,4 @@ - + \ No newline at end of file diff --git a/tests/cpp-empty-test/proj.win10/cpp-empty-test.vcxproj b/tests/cpp-empty-test/proj.win10/cpp-empty-test.vcxproj index 3fed10d13a..cb9bfee2b0 100644 --- a/tests/cpp-empty-test/proj.win10/cpp-empty-test.vcxproj +++ b/tests/cpp-empty-test/proj.win10/cpp-empty-test.vcxproj @@ -234,7 +234,7 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templat pch.h false ..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) - OldStyle + ProgramDatabase echo "Copying Windows 10.0 Universal App CPP template files" @@ -287,6 +287,7 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templat pch.h false ..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + ProgramDatabase echo "Copying Windows 10.0 Universal App CPP template files" diff --git a/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.Windows/HelloCpp.Windows.vcxproj b/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.Windows/HelloCpp.Windows.vcxproj index cdcc55bdb8..b137ac9365 100644 --- a/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.Windows/HelloCpp.Windows.vcxproj +++ b/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.Windows/HelloCpp.Windows.vcxproj @@ -123,6 +123,7 @@ pch.h ../../Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false + ProgramDatabase echo "Copying Windows 8.1 Universal App CPP template files" @@ -151,6 +152,7 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templat pch.h ../../Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false + ProgramDatabase echo "Copying Windows 8.1 Universal App CPP template files" @@ -176,6 +178,7 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templat pch.h ../../Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false + ProgramDatabase echo "Copying Windows 8.1 Universal App CPP template files" @@ -204,6 +207,7 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templat pch.h ../../Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false + ProgramDatabase echo "Copying Windows 8.1 Universal App CPP template files" @@ -229,6 +233,7 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templat pch.h ../../Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false + ProgramDatabase echo "Copying Windows 8.1 Universal App CPP template files" @@ -257,6 +262,7 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templat pch.h ../../Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false + ProgramDatabase echo "Copying Windows 8.1 Universal App CPP template files" diff --git a/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.WindowsPhone/HelloCpp.WindowsPhone.vcxproj b/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.WindowsPhone/HelloCpp.WindowsPhone.vcxproj index 1aadc4ddd1..1adb645e97 100644 --- a/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.WindowsPhone/HelloCpp.WindowsPhone.vcxproj +++ b/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.WindowsPhone/HelloCpp.WindowsPhone.vcxproj @@ -90,6 +90,7 @@ ../../Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false CC_WINDOWS_PHONE_8_1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + ProgramDatabase MSVCRT;%(IgnoreSpecificDefaultLibraries) @@ -103,6 +104,7 @@ ../../Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false CC_WINDOWS_PHONE_8_1;WINRT;_VARIADIC_MAX=10;NOMINMAX;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_UNICODE;UNICODE;%(PreprocessorDefinitions) + ProgramDatabase @@ -113,6 +115,7 @@ ../../Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false CC_WINDOWS_PHONE_8_1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + ProgramDatabase MSVCRT;%(IgnoreSpecificDefaultLibraries) @@ -126,6 +129,7 @@ ../../Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false CC_WINDOWS_PHONE_8_1;WINRT;_VARIADIC_MAX=10;NOMINMAX;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_UNICODE;UNICODE;%(PreprocessorDefinitions) + ProgramDatabase diff --git a/tests/cpp-tests/proj.win10/cpp-tests.vcxproj b/tests/cpp-tests/proj.win10/cpp-tests.vcxproj index 51434d6881..3eeff99840 100644 --- a/tests/cpp-tests/proj.win10/cpp-tests.vcxproj +++ b/tests/cpp-tests/proj.win10/cpp-tests.vcxproj @@ -198,6 +198,7 @@ false false CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + ProgramDatabase @@ -226,6 +227,7 @@ false false CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + ProgramDatabase diff --git a/tests/cpp-tests/proj.win8.1-universal/cpp-tests.Windows/cpp-tests.Windows.vcxproj b/tests/cpp-tests/proj.win8.1-universal/cpp-tests.Windows/cpp-tests.Windows.vcxproj index 43403d9726..f4078934d9 100644 --- a/tests/cpp-tests/proj.win8.1-universal/cpp-tests.Windows/cpp-tests.Windows.vcxproj +++ b/tests/cpp-tests/proj.win8.1-universal/cpp-tests.Windows/cpp-tests.Windows.vcxproj @@ -118,6 +118,8 @@ CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) false false + ProgramDatabase + ProgramDatabase @@ -138,6 +140,8 @@ CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) false false + ProgramDatabase + ProgramDatabase @@ -158,6 +162,8 @@ CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) false false + ProgramDatabase + ProgramDatabase @@ -192,4 +198,4 @@ - + \ No newline at end of file diff --git a/tests/cpp-tests/proj.win8.1-universal/cpp-tests.WindowsPhone/cpp-tests.WindowsPhone.vcxproj b/tests/cpp-tests/proj.win8.1-universal/cpp-tests.WindowsPhone/cpp-tests.WindowsPhone.vcxproj index fab81c3729..e04b850c8e 100644 --- a/tests/cpp-tests/proj.win8.1-universal/cpp-tests.WindowsPhone/cpp-tests.WindowsPhone.vcxproj +++ b/tests/cpp-tests/proj.win8.1-universal/cpp-tests.WindowsPhone/cpp-tests.WindowsPhone.vcxproj @@ -90,6 +90,8 @@ Use false false + ProgramDatabase + ProgramDatabase @@ -113,6 +115,8 @@ Use false false + ProgramDatabase + ProgramDatabase @@ -158,4 +162,4 @@ - + \ No newline at end of file diff --git a/tests/js-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows.vcxproj b/tests/js-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows.vcxproj index bedded9b13..78058f09b1 100644 --- a/tests/js-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows.vcxproj +++ b/tests/js-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows.vcxproj @@ -124,6 +124,7 @@ $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + ProgramDatabase @@ -156,6 +157,7 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\cocos2d-js\pch.h" "$(EngineR $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + ProgramDatabase @@ -185,6 +187,7 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\cocos2d-js\pch.h" "$(EngineR $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + ProgramDatabase @@ -217,6 +220,7 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\cocos2d-js\pch.h" "$(EngineR $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + ProgramDatabase @@ -246,6 +250,7 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\cocos2d-js\pch.h" "$(EngineR $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + ProgramDatabase @@ -276,6 +281,7 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\cocos2d-js\pch.h" "$(EngineR $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + ProgramDatabase echo "Copying Windows 8.1 Universal App CPP template files" diff --git a/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/js-tests.WindowsPhone.vcxproj b/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/js-tests.WindowsPhone.vcxproj index 72f51d7a4c..07385eb555 100644 --- a/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/js-tests.WindowsPhone.vcxproj +++ b/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/js-tests.WindowsPhone.vcxproj @@ -90,6 +90,7 @@ $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + ProgramDatabase MSVCRT;%(IgnoreSpecificDefaultLibraries) @@ -103,6 +104,7 @@ $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + ProgramDatabase @@ -113,6 +115,7 @@ $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + ProgramDatabase MSVCRT;%(IgnoreSpecificDefaultLibraries) @@ -126,6 +129,7 @@ $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + ProgramDatabase @@ -158,4 +162,4 @@ - + \ No newline at end of file From c47de9d04fd4b45b85be5dba1d8315a37febf492 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Thu, 20 Aug 2015 13:25:57 -0700 Subject: [PATCH 036/118] make new render surface current after device lost --- cocos/platform/win8.1-universal/OpenGLESPage.xaml.cpp | 1 + .../proj.win10/App/Cocos2dEngine/OpenGLESPage.xaml.cpp | 1 + .../proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.cpp | 1 + .../proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.cpp | 1 + 4 files changed, 4 insertions(+) diff --git a/cocos/platform/win8.1-universal/OpenGLESPage.xaml.cpp b/cocos/platform/win8.1-universal/OpenGLESPage.xaml.cpp index 97423eb9b6..f3626be22d 100644 --- a/cocos/platform/win8.1-universal/OpenGLESPage.xaml.cpp +++ b/cocos/platform/win8.1-universal/OpenGLESPage.xaml.cpp @@ -433,6 +433,7 @@ void OpenGLESPage::StartRenderLoop() if (!mDeviceLost) { + mOpenGLES->MakeCurrent(mRenderSurface); // restart cocos2d-x mRenderer->DeviceLost(); } diff --git a/templates/cpp-template-default/proj.win10/App/Cocos2dEngine/OpenGLESPage.xaml.cpp b/templates/cpp-template-default/proj.win10/App/Cocos2dEngine/OpenGLESPage.xaml.cpp index 97423eb9b6..f3626be22d 100644 --- a/templates/cpp-template-default/proj.win10/App/Cocos2dEngine/OpenGLESPage.xaml.cpp +++ b/templates/cpp-template-default/proj.win10/App/Cocos2dEngine/OpenGLESPage.xaml.cpp @@ -433,6 +433,7 @@ void OpenGLESPage::StartRenderLoop() if (!mDeviceLost) { + mOpenGLES->MakeCurrent(mRenderSurface); // restart cocos2d-x mRenderer->DeviceLost(); } diff --git a/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.cpp b/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.cpp index 97423eb9b6..f3626be22d 100644 --- a/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.cpp +++ b/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.cpp @@ -433,6 +433,7 @@ void OpenGLESPage::StartRenderLoop() if (!mDeviceLost) { + mOpenGLES->MakeCurrent(mRenderSurface); // restart cocos2d-x mRenderer->DeviceLost(); } diff --git a/templates/js-template-default/frameworks/runtime-src/proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.cpp b/templates/js-template-default/frameworks/runtime-src/proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.cpp index 97423eb9b6..f3626be22d 100644 --- a/templates/js-template-default/frameworks/runtime-src/proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.cpp +++ b/templates/js-template-default/frameworks/runtime-src/proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.cpp @@ -433,6 +433,7 @@ void OpenGLESPage::StartRenderLoop() if (!mDeviceLost) { + mOpenGLES->MakeCurrent(mRenderSurface); // restart cocos2d-x mRenderer->DeviceLost(); } From 1bcc2dec37bb704745268559c80eee677d54bb96 Mon Sep 17 00:00:00 2001 From: ZhangMenghe Date: Fri, 21 Aug 2015 10:20:59 +0800 Subject: [PATCH 037/118] Notification effect enhancement --- cocos/base/CCDirector.cpp | 14 ++++++++++++-- tests/js-tests/src/SceneTest/SceneTest.js | 5 +++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp index 0ed8559af6..c85ddc4440 100644 --- a/cocos/base/CCDirector.cpp +++ b/cocos/base/CCDirector.cpp @@ -1252,8 +1252,18 @@ void Director::setContentScaleFactor(float scaleFactor) void Director::setNotificationNode(Node *node) { - CC_SAFE_RELEASE(_notificationNode); - _notificationNode = node; + if (_notificationNode != nullptr){ + _notificationNode->onExitTransitionDidStart(); + _notificationNode->onExit(); + _notificationNode->cleanup(); + } + CC_SAFE_RELEASE(_notificationNode); + + _notificationNode = node; + if (node == nullptr) + return; + _notificationNode->onEnter(); + _notificationNode->onEnterTransitionDidFinish(); CC_SAFE_RETAIN(_notificationNode); } diff --git a/tests/js-tests/src/SceneTest/SceneTest.js b/tests/js-tests/src/SceneTest/SceneTest.js index cf622438d6..87a94f3c39 100644 --- a/tests/js-tests/src/SceneTest/SceneTest.js +++ b/tests/js-tests/src/SceneTest/SceneTest.js @@ -45,7 +45,12 @@ var SceneTestLayer1 = cc.Layer.extend({ }, this); var item4 = new cc.MenuItemFont("setNotificationNode", function () { var layerTemp = new cc.LayerColor(cc.color(0, 255, 255, 120)); + var sprite = new cc.Sprite(s_pathGrossini); + sprite.setPosition(cc.p(winSize.width/2,winSize.height/2)); + layerTemp.addChild(sprite); cc.director.setNotificationNode(layerTemp); + var rotation = cc.rotateBy(2,360); + sprite.runAction(rotation.repeatForever()); cc.log("setNotificationNode!"); }, this); var item5 = new cc.MenuItemFont("clearNotificationNode", function () { From 3e2001bdb1aad08e4ca9ed2d4a90844c88e078ae Mon Sep 17 00:00:00 2001 From: yangxiao Date: Thu, 20 Aug 2015 16:19:57 +0800 Subject: [PATCH 038/118] Add CCCameraBackgroundBrush including Color, Depth, SkyBox brushes Squashed from https://github.com/cocos2d/cocos2d-x/pull/13490 --- build/cocos2d_libs.xcodeproj/project.pbxproj | 12 + cocos/2d/CCCamera.cpp | 92 +--- cocos/2d/CCCamera.h | 18 +- cocos/2d/CCCameraBackGroundBrush.cpp | 418 ++++++++++++++++++ cocos/2d/CCCameraBackGroundBrush.h | 263 +++++++++++ cocos/2d/CCScene.cpp | 2 +- cocos/2d/CMakeLists.txt | 1 + cocos/2d/libcocos2d.vcxproj | 2 + cocos/2d/libcocos2d.vcxproj.filters | 6 + .../libcocos2d_8_1.Shared.vcxitems | 2 + .../libcocos2d_8_1.Shared.vcxitems.filters | 6 + cocos/Android.mk | 1 + cocos/cocos2d.h | 1 + .../Classes/Sprite3DTest/Sprite3DTest.cpp | 65 +++ .../Classes/Sprite3DTest/Sprite3DTest.h | 14 + 15 files changed, 822 insertions(+), 81 deletions(-) create mode 100644 cocos/2d/CCCameraBackGroundBrush.cpp create mode 100644 cocos/2d/CCCameraBackGroundBrush.h diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index a132121d99..08e37fa3b1 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -3603,6 +3603,10 @@ B6DD2FF61B04825B00E47F5F /* fastlz.c in Sources */ = {isa = PBXBuildFile; fileRef = B6DD2FA51B04825B00E47F5F /* fastlz.c */; }; B6DD2FF71B04825B00E47F5F /* fastlz.h in Headers */ = {isa = PBXBuildFile; fileRef = B6DD2FA61B04825B00E47F5F /* fastlz.h */; }; B6DD2FF81B04825B00E47F5F /* fastlz.h in Headers */ = {isa = PBXBuildFile; fileRef = B6DD2FA61B04825B00E47F5F /* fastlz.h */; }; + B6DD36D51B8564EC0044745A /* CCCameraBackGroundBrush.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6DD36D31B8564EC0044745A /* CCCameraBackGroundBrush.cpp */; }; + B6DD36D61B8564EC0044745A /* CCCameraBackGroundBrush.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6DD36D31B8564EC0044745A /* CCCameraBackGroundBrush.cpp */; }; + B6DD36D71B8564EC0044745A /* CCCameraBackGroundBrush.h in Headers */ = {isa = PBXBuildFile; fileRef = B6DD36D41B8564EC0044745A /* CCCameraBackGroundBrush.h */; }; + B6DD36D81B8564EC0044745A /* CCCameraBackGroundBrush.h in Headers */ = {isa = PBXBuildFile; fileRef = B6DD36D41B8564EC0044745A /* CCCameraBackGroundBrush.h */; }; C50306691B60B583001E6D43 /* CCBoneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C50306631B60B583001E6D43 /* CCBoneNode.cpp */; }; C503066A1B60B583001E6D43 /* CCBoneNode.h in Headers */ = {isa = PBXBuildFile; fileRef = C50306641B60B583001E6D43 /* CCBoneNode.h */; }; C503066B1B60B583001E6D43 /* CCSkeletonNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C50306651B60B583001E6D43 /* CCSkeletonNode.cpp */; }; @@ -5546,6 +5550,8 @@ B6DD2FA31B04825B00E47F5F /* DetourTileCacheBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DetourTileCacheBuilder.h; sourceTree = ""; }; B6DD2FA51B04825B00E47F5F /* fastlz.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fastlz.c; sourceTree = ""; }; B6DD2FA61B04825B00E47F5F /* fastlz.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fastlz.h; sourceTree = ""; }; + B6DD36D31B8564EC0044745A /* CCCameraBackGroundBrush.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCCameraBackGroundBrush.cpp; sourceTree = ""; }; + B6DD36D41B8564EC0044745A /* CCCameraBackGroundBrush.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCCameraBackGroundBrush.h; sourceTree = ""; }; C50306631B60B583001E6D43 /* CCBoneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBoneNode.cpp; sourceTree = ""; }; C50306641B60B583001E6D43 /* CCBoneNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBoneNode.h; sourceTree = ""; }; C50306651B60B583001E6D43 /* CCSkeletonNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSkeletonNode.cpp; sourceTree = ""; }; @@ -7327,6 +7333,8 @@ 46A169A11807B037005B8026 /* 2d */ = { isa = PBXGroup; children = ( + B6DD36D31B8564EC0044745A /* CCCameraBackGroundBrush.cpp */, + B6DD36D41B8564EC0044745A /* CCCameraBackGroundBrush.h */, 3EACC99C19F5014D00EB3C5E /* CCCamera.cpp */, 3EACC99D19F5014D00EB3C5E /* CCCamera.h */, 3EACC99E19F5014D00EB3C5E /* CCLight.cpp */, @@ -9330,6 +9338,7 @@ 15AE1BDD19AAE01E00C27E9E /* CCControlUtils.h in Headers */, B6CAB3271AF9AA1A00B9B856 /* btGImpactBvh.h in Headers */, 15AE198D19AAD36E00C27E9E /* CheckBoxReader.h in Headers */, + B6DD36D71B8564EC0044745A /* CCCameraBackGroundBrush.h in Headers */, B29A7E0919EE1B7700872B35 /* AttachmentLoader.h in Headers */, 1A01C68818F57BE800EFE3A6 /* CCBool.h in Headers */, B29A7E3319EE1B7700872B35 /* SlotData.h in Headers */, @@ -10810,6 +10819,7 @@ B29A7DDA19EE1B7700872B35 /* SkeletonRenderer.h in Headers */, 15AE194119AAD35100C27E9E /* CCBone.h in Headers */, D0FD035A1A3B51AA00825BB5 /* CCAllocatorStrategyDefault.h in Headers */, + B6DD36D81B8564EC0044745A /* CCCameraBackGroundBrush.h in Headers */, 50ABBD471925AB0000A911A9 /* CCVertex.h in Headers */, B6CAB4D81AF9AA1A00B9B856 /* SpuLocalSupport.h in Headers */, B6CAB2921AF9AA1A00B9B856 /* btCollisionShape.h in Headers */, @@ -11041,6 +11051,7 @@ B6CAB2811AF9AA1A00B9B856 /* btBoxShape.cpp in Sources */, 50ABBE311925AB6F00A911A9 /* CCConfiguration.cpp in Sources */, B665E3821AA80A6500DDB1C5 /* CCPUPathFollower.cpp in Sources */, + B6DD36D51B8564EC0044745A /* CCCameraBackGroundBrush.cpp in Sources */, 1A01C6A418F58F7500EFE3A6 /* CCNotificationCenter.cpp in Sources */, 15AE1A5D19AAD40300C27E9E /* b2Body.cpp in Sources */, 15AE1BDA19AAE01E00C27E9E /* CCControlSwitch.cpp in Sources */, @@ -12051,6 +12062,7 @@ 3EACC9A519F5014D00EB3C5E /* CCLight.cpp in Sources */, 15AE1B7A19AADA9A00C27E9E /* UIScrollView.cpp in Sources */, 1A570076180BC5A10088DEC7 /* CCActionGrid3D.cpp in Sources */, + B6DD36D61B8564EC0044745A /* CCCameraBackGroundBrush.cpp in Sources */, B6CAB38C1AF9AA1A00B9B856 /* btPolyhedralContactClipping.cpp in Sources */, B6CAB3A41AF9AA1A00B9B856 /* btConeTwistConstraint.cpp in Sources */, 15AE19B219AAD39700C27E9E /* SliderReader.cpp in Sources */, diff --git a/cocos/2d/CCCamera.cpp b/cocos/2d/CCCamera.cpp index 1df03955a9..32fdfd055e 100644 --- a/cocos/2d/CCCamera.cpp +++ b/cocos/2d/CCCamera.cpp @@ -25,6 +25,7 @@ ****************************************************************************/ #include "2d/CCCamera.h" +#include "2d/CCCameraBackGroundBrush.h" #include "base/CCDirector.h" #include "platform/CCGLView.h" #include "2d/CCScene.h" @@ -96,11 +97,14 @@ Camera::Camera() , _fbo(nullptr) { _frustum.setClipZ(true); + _clearBrush = CameraBackGroundBrush::createDepthBrush(1.f); + _clearBrush->retain(); } Camera::~Camera() { CC_SAFE_RELEASE_NULL(_fbo); + CC_SAFE_RELEASE(_clearBrush); } const Mat4& Camera::getProjectionMatrix() const @@ -398,86 +402,11 @@ void Camera::setScene(Scene* scene) } } -void Camera::clearBackground(float depth) +void Camera::clearBackground() { - GLboolean oldDepthTest; - GLint oldDepthFunc; - GLboolean oldDepthMask; + if (_clearBrush) { - glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); - glStencilMask(0); - - oldDepthTest = glIsEnabled(GL_DEPTH_TEST); - glGetIntegerv(GL_DEPTH_FUNC, &oldDepthFunc); - glGetBooleanv(GL_DEPTH_WRITEMASK, &oldDepthMask); - - glDepthMask(GL_TRUE); - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_ALWAYS); - } - - //draw - static V3F_C4B_T2F_Quad quad; - quad.bl.vertices = Vec3(-1,-1,0); - quad.br.vertices = Vec3(1,-1,0); - quad.tl.vertices = Vec3(-1,1,0); - quad.tr.vertices = Vec3(1,1,0); - - quad.bl.colors = quad.br.colors = quad.tl.colors = quad.tr.colors = Color4B(0,0,0,1); - - quad.bl.texCoords = Tex2F(0,0); - quad.br.texCoords = Tex2F(1,0); - quad.tl.texCoords = Tex2F(0,1); - quad.tr.texCoords = Tex2F(1,1); - - auto shader = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_CAMERA_CLEAR); - auto programState = GLProgramState::getOrCreateWithGLProgram(shader); - programState->setUniformFloat("depth", 1.0); - programState->apply(Mat4()); - GLshort indices[6] = {0, 1, 2, 3, 2, 1}; - - { - GL::bindVAO(0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - - GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - - // vertices - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, sizeof(V3F_C4B_T2F), &quad.tl.vertices); - - // colors - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V3F_C4B_T2F), &quad.tl.colors); - - // tex coords - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V3F_C4B_T2F), &quad.tl.texCoords); - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices); - } - - - { - if(GL_FALSE == oldDepthTest) - { - glDisable(GL_DEPTH_TEST); - } - glDepthFunc(oldDepthFunc); - - if(GL_FALSE == oldDepthMask) - { - glDepthMask(GL_FALSE); - } - - /* IMPORTANT: We only need to update the states that are not restored. - Since we don't know what was the previous value of the mask, we update the RenderState - after setting it. - The other values don't need to be updated since they were restored to their original values - */ - glStencilMask(0xFFFFF); -// RenderState::StateBlock::_defaultState->setStencilWrite(0xFFFFF); - - /* BUG: RenderState does not support glColorMask yet. */ - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + _clearBrush->drawBackGround(this); } } @@ -545,4 +474,11 @@ void Camera::visit(Renderer* renderer, const Mat4 &parentTransform, uint32_t par return Node::visit(renderer, parentTransform, parentFlags); } +void Camera::setBackGroundBrush(CameraBackGroundBrush* clearBrush) +{ + CC_SAFE_RETAIN(clearBrush); + CC_SAFE_RELEASE(_clearBrush); + _clearBrush = clearBrush; +} + NS_CC_END diff --git a/cocos/2d/CCCamera.h b/cocos/2d/CCCamera.h index 1b6d253dbe..cd1dd06452 100644 --- a/cocos/2d/CCCamera.h +++ b/cocos/2d/CCCamera.h @@ -36,6 +36,7 @@ THE SOFTWARE. NS_CC_BEGIN class Scene; +class CameraBackGroundBrush; /** * Note: @@ -236,9 +237,9 @@ public: */ static Camera* getDefaultCamera(); /** - Before rendering scene with this camera, the background need to be cleared. + Before rendering scene with this camera, the background need to be cleared. It clears the depth buffer with max depth by default. Use setBackGroundBrush to modify the default behavior */ - void clearBackground(float depth); + void clearBackground(); /** Apply the FBO, RenderTargets and viewport. */ @@ -258,6 +259,17 @@ public: */ bool isViewProjectionUpdated() const {return _viewProjectionUpdated;} + /** + * set the background brush. See CameraBackGroundBrush for more information. + * @param clearBrush Brush used to clear the background + */ + void setBackGroundBrush(CameraBackGroundBrush* clearBrush); + + /** + * Get clear brush + */ + CameraBackGroundBrush* getBackGroundBrush() const { return _clearBrush; } + virtual void visit(Renderer* renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; CC_CONSTRUCTOR_ACCESS: @@ -300,6 +312,8 @@ protected: int8_t _depth; //camera depth, the depth of camera with CameraFlag::DEFAULT flag is 0 by default, a camera with larger depth is drawn on top of camera with smaller detph static Camera* _visitingCamera; + CameraBackGroundBrush* _clearBrush; //brush used to clear the back ground + experimental::Viewport _viewport; experimental::FrameBuffer* _fbo; diff --git a/cocos/2d/CCCameraBackGroundBrush.cpp b/cocos/2d/CCCameraBackGroundBrush.cpp new file mode 100644 index 0000000000..a9310460ab --- /dev/null +++ b/cocos/2d/CCCameraBackGroundBrush.cpp @@ -0,0 +1,418 @@ +/**************************************************************************** + Copyright (c) 2015 Chukong Technologies Inc. + + 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 "2d/CCCameraBackGroundBrush.h" +#include "2d/CCCamera.h" +#include "base/ccMacros.h" +#include "base/CCConfiguration.h" +#include "base/CCDirector.h" +#include "renderer/ccGLStateCache.h" +#include "renderer/CCGLProgram.h" +#include "renderer/CCGLProgramCache.h" +#include "renderer/CCGLProgramState.h" +#include "renderer/CCRenderer.h" +#include "renderer/CCRenderState.h" +#include "3d/CCTextureCube.h" + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#include "base/CCEventCustom.h" +#include "base/CCEventListenerCustom.h" +#include "base/CCEventType.h" +#include "base/CCEventDispatcher.h" +#endif + +NS_CC_BEGIN + +CameraBackGroundBrush::CameraBackGroundBrush() +: _glProgramState(nullptr) +{ + +} + +CameraBackGroundBrush::~CameraBackGroundBrush() +{ + CC_SAFE_RELEASE(_glProgramState); +} + +CameraBackGroundBrush* CameraBackGroundBrush::createNoneBrush() +{ + auto ret = new (std::nothrow) CameraBackGroundBrush(); + ret->init(); + + ret->autorelease(); + return ret; +} + +CameraBackGroundColorBrush* CameraBackGroundBrush::createColorBrush(const Color4F& color, float depth) +{ + return CameraBackGroundColorBrush::create(color, depth); +} + +CameraBackGroundDepthBrush* CameraBackGroundBrush::createDepthBrush(float depth) +{ + return CameraBackGroundDepthBrush::create(depth); +} + +CameraBackGroundSkyBoxBrush* CameraBackGroundBrush::createSkyboxBrush(const std::string& positive_x, const std::string& negative_x, const std::string& positive_y, const std::string& negative_y, const std::string& positive_z, const std::string& negative_z) +{ + return CameraBackGroundSkyBoxBrush::create(positive_x, negative_x, positive_y, negative_y, positive_z, negative_z); +} + +////////////////////////////////////////////////////////////////////////////////////////// + +CameraBackGroundDepthBrush::CameraBackGroundDepthBrush() +: _depth(0.f) +, _clearColor(GL_FALSE) +{ + +} +CameraBackGroundDepthBrush::~CameraBackGroundDepthBrush() +{ + +} + +CameraBackGroundDepthBrush* CameraBackGroundDepthBrush::create(float depth) +{ + auto ret = new (std::nothrow) CameraBackGroundDepthBrush(); + ret->_depth = depth; + ret->init(); + ret->autorelease(); + return ret; +} + +bool CameraBackGroundDepthBrush::init() +{ + auto shader = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_CAMERA_CLEAR); + _glProgramState = GLProgramState::getOrCreateWithGLProgram(shader); + _glProgramState->retain(); + + _quad.bl.vertices = Vec3(-1,-1,0); + _quad.br.vertices = Vec3(1,-1,0); + _quad.tl.vertices = Vec3(-1,1,0); + _quad.tr.vertices = Vec3(1,1,0); + + _quad.bl.colors = _quad.br.colors = _quad.tl.colors = _quad.tr.colors = Color4B(0,0,0,1); + + _quad.bl.texCoords = Tex2F(0,0); + _quad.br.texCoords = Tex2F(1,0); + _quad.tl.texCoords = Tex2F(0,1); + _quad.tr.texCoords = Tex2F(1,1); + return true; +} + +void CameraBackGroundDepthBrush::drawBackGround(Camera* camera) +{ + GLboolean oldDepthTest; + GLint oldDepthFunc; + GLboolean oldDepthMask; + { + glColorMask(_clearColor, _clearColor, _clearColor, _clearColor); + glStencilMask(0); + + oldDepthTest = glIsEnabled(GL_DEPTH_TEST); + glGetIntegerv(GL_DEPTH_FUNC, &oldDepthFunc); + glGetBooleanv(GL_DEPTH_WRITEMASK, &oldDepthMask); + + glDepthMask(GL_TRUE); + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_ALWAYS); + } + + //draw + + _glProgramState->setUniformFloat("depth", _depth); + _glProgramState->apply(Mat4::IDENTITY); + GLshort indices[6] = {0, 1, 2, 3, 2, 1}; + + { + GL::bindVAO(0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + + // vertices + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, sizeof(V3F_C4B_T2F), &_quad.tl.vertices); + + // colors + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V3F_C4B_T2F), &_quad.tl.colors); + + // tex coords + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V3F_C4B_T2F), &_quad.tl.texCoords); + + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices); + } + + + { + if(GL_FALSE == oldDepthTest) + { + glDisable(GL_DEPTH_TEST); + } + glDepthFunc(oldDepthFunc); + + if(GL_FALSE == oldDepthMask) + { + glDepthMask(GL_FALSE); + } + + /* IMPORTANT: We only need to update the states that are not restored. + Since we don't know what was the previous value of the mask, we update the RenderState + after setting it. + The other values don't need to be updated since they were restored to their original values + */ + glStencilMask(0xFFFFF); + // RenderState::StateBlock::_defaultState->setStencilWrite(0xFFFFF); + + /* BUG: RenderState does not support glColorMask yet. */ + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + } +} + +////////////////////////////////////////////////////////////////////////////////////////// + +CameraBackGroundColorBrush::CameraBackGroundColorBrush() +: _color(0.f, 0.f, 0.f, 0.f) +{ + +} + +CameraBackGroundColorBrush::~CameraBackGroundColorBrush() +{ + +} + +void CameraBackGroundColorBrush::setColor(const Color4F& color) +{ + _quad.bl.colors = _quad.br.colors = _quad.tl.colors = _quad.tr.colors = Color4B(color); +} + +CameraBackGroundColorBrush* CameraBackGroundColorBrush::create(const Color4F& color, float depth) +{ + auto ret = new (std::nothrow) CameraBackGroundColorBrush(); + ret->init(); + ret->_clearColor = GL_TRUE; + ret->setColor(color); + ret->setDepth(depth); + + ret->autorelease(); + return ret; +} + +///////////////////////////////////////////////////////////////////////////////////////////// +CameraBackGroundSkyBoxBrush::CameraBackGroundSkyBoxBrush() +: _vao(0) +, _vertexBuffer(0) +, _indexBuffer(0) +, _texture(nullptr) +{ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) + _backToForegroundListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, + [this](EventCustom*) + { + initBuffer(); + } + ); + Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundListener, -1); +#endif +} + +CameraBackGroundSkyBoxBrush::~CameraBackGroundSkyBoxBrush() +{ + CC_SAFE_RELEASE(_texture); + + glDeleteBuffers(1, &_vertexBuffer); + glDeleteBuffers(1, &_indexBuffer); + + _vertexBuffer = 0; + _indexBuffer = 0; + + if (Configuration::getInstance()->supportsShareableVAO()) + { + glDeleteVertexArrays(1, &_vao); + GL::bindVAO(0); + _vao = 0; + } +} + +CameraBackGroundSkyBoxBrush* CameraBackGroundSkyBoxBrush::create(const std::string& positive_x, const std::string& negative_x, const std::string& positive_y, const std::string& negative_y, const std::string& positive_z, const std::string& negative_z) +{ + auto texture = TextureCube::create(positive_x, negative_x, positive_y, negative_y, positive_z, negative_z); + if (texture == nullptr) + return nullptr; + + Texture2D::TexParams tRepeatParams; + tRepeatParams.magFilter = GL_LINEAR; + tRepeatParams.minFilter = GL_LINEAR; + tRepeatParams.wrapS = GL_CLAMP_TO_EDGE; + tRepeatParams.wrapT = GL_CLAMP_TO_EDGE; + texture->setTexParameters(tRepeatParams); + + auto ret = new(std::nothrow)CameraBackGroundSkyBoxBrush(); + + ret->init(); + ret->setTexture(texture); + + ret->autorelease(); + return ret; +} + +CameraBackGroundSkyBoxBrush* CameraBackGroundSkyBoxBrush::create() +{ + auto ret = new(std::nothrow)CameraBackGroundSkyBoxBrush(); + + ret->init(); + + ret->autorelease(); + return ret; +} + +void CameraBackGroundSkyBoxBrush::drawBackGround(Camera* camera) +{ + Mat4 cameraModelMat = camera->getNodeToWorldTransform(); + + _glProgramState->apply(Mat4::IDENTITY); + + Vec4 color(1.f, 1.f, 1.f, 1.f); + _glProgramState->setUniformVec4("u_color", color); + cameraModelMat.m[12] = cameraModelMat.m[13] = cameraModelMat.m[14] = 0; + _glProgramState->setUniformMat4("u_cameraRot", cameraModelMat); + + glEnable(GL_DEPTH_TEST); + RenderState::StateBlock::_defaultState->setDepthTest(true); + + glDepthFunc(GL_LEQUAL); + RenderState::StateBlock::_defaultState->setDepthFunction(RenderState::DEPTH_LEQUAL); + + glEnable(GL_CULL_FACE); + RenderState::StateBlock::_defaultState->setCullFace(true); + + glCullFace(GL_BACK); + RenderState::StateBlock::_defaultState->setCullFaceSide(RenderState::CULL_FACE_SIDE_BACK); + + if (Configuration::getInstance()->supportsShareableVAO()) + { + GL::bindVAO(_vao); + } + else + { + GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POSITION); + + glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, sizeof(Vec3), nullptr); + + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer); + } + + glDrawElements(GL_TRIANGLES, (GLsizei)36, GL_UNSIGNED_BYTE, nullptr); + + if (Configuration::getInstance()->supportsShareableVAO()) + { + GL::bindVAO(0); + } + else + { + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + } + + CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 8); + + CHECK_GL_ERROR_DEBUG(); +} + +bool CameraBackGroundSkyBoxBrush::init() +{ + auto shader = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_3D_SKYBOX); + _glProgramState = GLProgramState::create(shader); + _glProgramState->setVertexAttribPointer(GLProgram::ATTRIBUTE_NAME_POSITION, 3, GL_FLOAT, GL_FALSE, sizeof(Vec3), nullptr); + _glProgramState->retain(); + + initBuffer(); + + return true; +} + +void CameraBackGroundSkyBoxBrush::initBuffer() +{ + if (_vertexBuffer) + glDeleteBuffers(1, &_vertexBuffer); + if (_indexBuffer) + glDeleteBuffers(1, &_indexBuffer); + + if (Configuration::getInstance()->supportsShareableVAO() && _vao) + { + glDeleteVertexArrays(1, &_vao); + GL::bindVAO(0); + _vao = 0; + } + + if (Configuration::getInstance()->supportsShareableVAO()) + { + glGenVertexArrays(1, &_vao); + GL::bindVAO(_vao); + } + + // init vertex buffer object + Vec3 vexBuf[] = + { + Vec3(1, -1, 1), Vec3(1, 1, 1), Vec3(-1, 1, 1), Vec3(-1, -1, 1), + Vec3(1, -1, -1), Vec3(1, 1, -1), Vec3(-1, 1, -1), Vec3(-1, -1, -1) + }; + + glGenBuffers(1, &_vertexBuffer); + glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer); + glBufferData(GL_ARRAY_BUFFER, sizeof(vexBuf), vexBuf, GL_STATIC_DRAW); + + // init index buffer object + const unsigned char idxBuf[] = { 2, 1, 0, 3, 2, 0, // font + 1, 5, 4, 1, 4, 0, // right + 4, 5, 6, 4, 6, 7, // back + 7, 6, 2, 7, 2, 3, // left + 2, 6, 5, 2, 5, 1, // up + 3, 0, 4, 3, 4, 7 // down + }; + + glGenBuffers(1, &_indexBuffer); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(idxBuf), idxBuf, GL_STATIC_DRAW); + + if (Configuration::getInstance()->supportsShareableVAO()) + { + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); + _glProgramState->applyAttributes(false); + + GL::bindVAO(0); + } +} + +void CameraBackGroundSkyBoxBrush::setTexture(TextureCube* texture) +{ + CC_SAFE_RETAIN(texture); + CC_SAFE_RELEASE(_texture); + _texture = texture; + _glProgramState->setUniformTexture("u_Env", _texture); +} + +NS_CC_END diff --git a/cocos/2d/CCCameraBackGroundBrush.h b/cocos/2d/CCCameraBackGroundBrush.h new file mode 100644 index 0000000000..152ea98c88 --- /dev/null +++ b/cocos/2d/CCCameraBackGroundBrush.h @@ -0,0 +1,263 @@ +/**************************************************************************** + Copyright (c) 2015 Chukong Technologies Inc. + + 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. + + ****************************************************************************/ +#ifndef _CCCAMERA_BACKGROUND_BRUSH_H__ +#define _CCCAMERA_BACKGROUND_BRUSH_H__ + +#include "base/ccTypes.h" +#include "base/CCRef.h" +#include "3d/CCFrustum.h" +#include "renderer/CCQuadCommand.h" +#include "renderer/CCCustomCommand.h" +#include "renderer/CCFrameBuffer.h" + +NS_CC_BEGIN + +class CameraBackGroundColorBrush; +class CameraBackGroundDepthBrush; +class CameraBackGroundSkyBoxBrush; + +class GLProgramState; +class Camera; + +/** + * Defines a brush to clear the background of camera. + * There are 4 types of brush. None brush do nothing, Depth brush clear background with given depth, Color brush clear background with given color and depth, Skybox brush clear the background with a skybox. Camera uses depth brush by default. + */ +class CC_DLL CameraBackGroundBrush : public Ref +{ +public: + /** + * Brush types. There are 4 types of brush. See CameraBackGroundDepthBrush, CameraBackGroundColorBrush, CameraBackGroundSkyBoxBrush for more information. + */ + enum class BrushType + { + NONE, //none brush + DEPTH, // depth brush. See CameraBackGroundDepthBrush + COLOR, // color brush. See CameraBackGroundColorBrush + SKYBOX, // skybox brush. See CameraBackGroundSkyBoxBrush + }; + + /** + * get brush type + * @return BrushType + */ + virtual BrushType getBrushType() const { return BrushType::NONE; } + + /** + * Creates a none brush, it does nothing when clear the background + * @return Created brush. + */ + static CameraBackGroundBrush* createNoneBrush(); + + /** + * Creates a depth brush, which clears depth buffer with a given depth. + * @param depth Depth used to clear depth buffer + * @return Created brush + */ + static CameraBackGroundDepthBrush* createDepthBrush(float depth = 1.f); + + /** + * Creates a color brush + * @param color Color of brush + * @param depth Depth used to clear depth buffer + * @return Created brush + */ + static CameraBackGroundColorBrush* createColorBrush(const Color4F& color, float depth); + + + /** Creates a Skybox brush with 6 textures. + @param positive_x texture for the right side of the texture cube face. + @param negative_x texture for the up side of the texture cube face. + @param positive_y texture for the top side of the texture cube face + @param negative_y texture for the bottom side of the texture cube face + @param positive_z texture for the forward side of the texture cube face. + @param negative_z texture for the rear side of the texture cube face. + @return A new brush inited with given parameters. + */ + static CameraBackGroundSkyBoxBrush* createSkyboxBrush(const std::string& positive_x, const std::string& negative_x, + const std::string& positive_y, const std::string& negative_y, + const std::string& positive_z, const std::string& negative_z); + /** + * draw the background + */ + virtual void drawBackGround(Camera* camera) {} + +CC_CONSTRUCTOR_ACCESS: + CameraBackGroundBrush(); + virtual ~CameraBackGroundBrush(); + +protected: + virtual bool init() { return true; } + + GLProgramState* _glProgramState; +}; + +/** + * Depth brush clear depth buffer with given depth + */ +class CC_DLL CameraBackGroundDepthBrush : public CameraBackGroundBrush +{ +public: + /** + * Create a depth brush + * @param depth Depth used to clear the depth buffer + * @return Created brush + */ + static CameraBackGroundDepthBrush* create(float depth); + + /** + * Get brush type. Should be BrushType::DEPTH + * @return brush type + */ + virtual BrushType getBrushType() const override { return BrushType::DEPTH; } + + /** + * Draw background + */ + virtual void drawBackGround(Camera* camera) override; + + /** + * Set depth + * @param depth Depth used to clear depth buffer + */ + void setDepth(float depth) { _depth = depth; } + +CC_CONSTRUCTOR_ACCESS: + CameraBackGroundDepthBrush(); + virtual ~CameraBackGroundDepthBrush(); + +protected: + virtual bool init() override; + + float _depth; + + GLboolean _clearColor; + + V3F_C4B_T2F_Quad _quad; +}; + +/** + * Color brush clear buffer with given depth and color + */ +class CC_DLL CameraBackGroundColorBrush : public CameraBackGroundDepthBrush +{ +public: + /** + * Get brush type. Should be BrushType::COLOR + * @return brush type + */ + virtual BrushType getBrushType() const override { return BrushType::COLOR; } + + /** + * Create a color brush + * @param color Color used to clear the color buffer + * @param depth Depth used to clear the depth buffer + * @return Created brush + */ + static CameraBackGroundColorBrush* create(const Color4F& color, float depth); + + /** + * Set clear color + * @param color Color used to clear the color buffer + */ + void setColor(const Color4F& color); + +CC_CONSTRUCTOR_ACCESS: + CameraBackGroundColorBrush(); + virtual ~CameraBackGroundColorBrush(); + +protected: + + Color4F _color; +}; + +class TextureCube; +class GLProgramState; +class EventListenerCustom; + +/** + * Skybox brush clear buffer with a skybox + */ +class CC_DLL CameraBackGroundSkyBoxBrush : public CameraBackGroundBrush +{ +public: + /** + * Get brush type. Should be BrushType::SKYBOX + * @return brush type + */ + virtual BrushType getBrushType() const override { return BrushType::SKYBOX; } + + /** Creates a Skybox brush with 6 textures. + @param positive_x texture for the right side of the texture cube face. + @param negative_x texture for the up side of the texture cube face. + @param positive_y texture for the top side of the texture cube face + @param negative_y texture for the bottom side of the texture cube face + @param positive_z texture for the forward side of the texture cube face. + @param negative_z texture for the rear side of the texture cube face. + @return A new brush inited with given parameters. + */ + static CameraBackGroundSkyBoxBrush* create(const std::string& positive_x, const std::string& negative_x, + const std::string& positive_y, const std::string& negative_y, + const std::string& positive_z, const std::string& negative_z); + + /** Creates a Skybox brush with 6 textures. + */ + static CameraBackGroundSkyBoxBrush* create(); + /** + * Set skybox texutre + * @param texture Skybox texture + */ + void setTexture(TextureCube* texture); + + /** + * Draw background + */ + virtual void drawBackGround(Camera* camera) override; + +CC_CONSTRUCTOR_ACCESS: + CameraBackGroundSkyBoxBrush(); + virtual ~CameraBackGroundSkyBoxBrush(); + + /** + * init Skybox. + */ + virtual bool init() override; + + void initBuffer(); + + GLuint _vao; + GLuint _vertexBuffer; + GLuint _indexBuffer; + + TextureCube* _texture; + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) + EventListenerCustom* _backToForegroundListener; +#endif +}; + +NS_CC_END + +#endif// _CCCAMERA_BACKGROUND_BRUSH_H__ diff --git a/cocos/2d/CCScene.cpp b/cocos/2d/CCScene.cpp index bd1a8ddab6..336433654d 100644 --- a/cocos/2d/CCScene.cpp +++ b/cocos/2d/CCScene.cpp @@ -194,7 +194,7 @@ void Scene::render(Renderer* renderer) director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, Camera::_visitingCamera->getViewProjectionMatrix()); camera->apply(); //clear background with max depth - camera->clearBackground(1.0); + camera->clearBackground(); //visit the scene visit(renderer, transform, 0); #if CC_USE_NAVMESH diff --git a/cocos/2d/CMakeLists.txt b/cocos/2d/CMakeLists.txt index dadb7100bb..d76096e7ce 100644 --- a/cocos/2d/CMakeLists.txt +++ b/cocos/2d/CMakeLists.txt @@ -24,6 +24,7 @@ set(COCOS_2D_SRC 2d/CCAnimation.cpp 2d/CCAtlasNode.cpp 2d/CCCamera.cpp + 2d/CCCameraBackGroundBrush.cpp 2d/CCClippingNode.cpp 2d/CCClippingRectangleNode.cpp 2d/CCComponentContainer.cpp diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index 35b3c43480..3c15cea25c 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -681,6 +681,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + @@ -1296,6 +1297,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index bb2e25cb78..e0cd832b95 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -1931,6 +1931,9 @@ network\Source Files + + 2d + @@ -3765,6 +3768,9 @@ network\Header Files + + 2d + diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems index 9738344739..0871e51cb5 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems @@ -584,6 +584,7 @@ + @@ -1178,6 +1179,7 @@ + diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters index 5d90a435bc..31439fd209 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters @@ -1867,6 +1867,9 @@ cocostudio\reader\WidgetReader\GameNodeDReader + + 2d + @@ -3564,6 +3567,9 @@ cocostudio\reader\WidgetReader\GameNodeDReader + + 2d + diff --git a/cocos/Android.mk b/cocos/Android.mk index 608a575bc9..3635a8d21a 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -35,6 +35,7 @@ cocos2d.cpp \ 2d/CCAnimationCache.cpp \ 2d/CCAtlasNode.cpp \ 2d/CCCamera.cpp \ +2d/CCCameraBackGroundBrush.cpp \ 2d/CCClippingNode.cpp \ 2d/CCClippingRectangleNode.cpp \ 2d/CCComponent.cpp \ diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index c63d321809..d1dde6d6b0 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -138,6 +138,7 @@ THE SOFTWARE. // 2d utils #include "2d/CCCamera.h" +#include "2d/CCCameraBackGroundBrush.h" #include "2d/CCGrabber.h" #include "2d/CCGrid.h" #include "2d/CCLight.h" diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index 3996b8587c..2f5a7cb257 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -25,6 +25,7 @@ #include "Sprite3DTest.h" #include "DrawNode3D.h" +#include "2d/CCCameraBackGroundBrush.h" #include "extensions/Particle3D/PU/CCPUParticleSystem3D.h" @@ -61,6 +62,7 @@ Sprite3DTests::Sprite3DTests() ADD_TEST_CASE(Sprite3DClippingTest); ADD_TEST_CASE(Sprite3DTestMeshLight); ADD_TEST_CASE(Animate3DCallbackTest); + ADD_TEST_CASE(CameraBackGroundClearTest); }; //------------------------------------------------------------------ @@ -2720,3 +2722,66 @@ std::string Sprite3DTestMeshLight::subtitle() const { return ""; } + +CameraBackGroundClearTest::CameraBackGroundClearTest() +{ + TTFConfig ttfConfig("fonts/arial.ttf", 20); + auto label1 = Label::createWithTTF(ttfConfig,"Clear Mode"); + auto item1 = MenuItemLabel::create(label1,CC_CALLBACK_1(CameraBackGroundClearTest::switch_CameraClearMode,this) ); + + item1->setPosition( Vec2(VisibleRect::left().x+50, VisibleRect::bottom().y+item1->getContentSize().height*4 ) ); + + auto pMenu1 = Menu::create(item1, nullptr); + pMenu1->setPosition(Vec2(0,0)); + this->addChild(pMenu1, 10); + + //setup camera + auto s = Director::getInstance()->getWinSize(); + _camera = Camera::createPerspective(40, s.width / s.height, 0.01f, 1000.f); + _camera->setCameraFlag(CameraFlag::USER1); + _camera->setPosition3D(Vec3(0.f, 30.f, 100.f)); + _camera->lookAt(Vec3(0.f, 0.f, 0.f)); + addChild(_camera); + + auto sprite = Sprite3D::create("Sprite3DTest/orc.c3b"); + addChild(sprite); + sprite->setCameraMask(2); + + _label = Label::createWithTTF(ttfConfig, "Depth Clear Brush"); + addChild(_label); + _label->setPosition(s.width / 2.f , VisibleRect::top().y * 0.8f); +} + +void CameraBackGroundClearTest::switch_CameraClearMode(cocos2d::Ref* sender) +{ + auto type = _camera->getBackGroundBrush()->getBrushType(); + if (type == CameraBackGroundBrush::BrushType::NONE) + { + _camera->setBackGroundBrush(CameraBackGroundBrush::createDepthBrush(1.f)); + _label->setString("Depth Clear Brush"); + } + else if (type == CameraBackGroundBrush::BrushType::DEPTH) + { + _camera->setBackGroundBrush(CameraBackGroundBrush::createColorBrush(Color4F(1.f, 0.f, 0.f, 1.f), 1.f)); + _label->setString("Color Clear Brush"); + } + else if (type == CameraBackGroundBrush::BrushType::COLOR) + { + _camera->setBackGroundBrush(CameraBackGroundBrush::createSkyboxBrush("Sprite3DTest/skybox/left.jpg", "Sprite3DTest/skybox/right.jpg","Sprite3DTest/skybox/top.jpg", "Sprite3DTest/skybox/bottom.jpg","Sprite3DTest/skybox/front.jpg", "Sprite3DTest/skybox/back.jpg")); + _label->setString("Skybox Clear Brush"); + } + else if (type == CameraBackGroundBrush::BrushType::SKYBOX) + { + _camera->setBackGroundBrush(CameraBackGroundBrush::createNoneBrush()); + _label->setString("None Clear Brush"); + } +} + +std::string CameraBackGroundClearTest::title() const +{ + return "Camera Background Clear Brush"; +} +std::string CameraBackGroundClearTest::subtitle() const +{ + return ""; +} diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h index 9a8cca3ef1..27044b98f8 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h @@ -592,4 +592,18 @@ protected: cocos2d::Sprite3D* _sprite; }; +class CameraBackGroundClearTest : public Sprite3DTestDemo +{ +public: + CREATE_FUNC(CameraBackGroundClearTest); + CameraBackGroundClearTest(); + virtual std::string title() const override; + virtual std::string subtitle() const override; + + void switch_CameraClearMode(cocos2d::Ref* sender); +protected: + cocos2d::Camera* _camera; + cocos2d::Label* _label; +}; + #endif From 350182c1aaef374c633db790ee3c871ead2bc362 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 21 Aug 2015 10:27:19 +0800 Subject: [PATCH 039/118] Refactor BackGround to Background --- build/cocos2d_libs.xcodeproj/project.pbxproj | 24 +++---- cocos/2d/CCCamera.cpp | 8 +-- cocos/2d/CCCamera.h | 12 ++-- ...dBrush.cpp => CCCameraBackgroundBrush.cpp} | 64 +++++++++---------- ...roundBrush.h => CCCameraBackgroundBrush.h} | 60 ++++++++--------- cocos/2d/CMakeLists.txt | 2 +- cocos/2d/libcocos2d.vcxproj | 4 +- cocos/2d/libcocos2d.vcxproj.filters | 4 +- .../libcocos2d_8_1.Shared.vcxitems | 4 +- .../libcocos2d_8_1.Shared.vcxitems.filters | 4 +- cocos/Android.mk | 2 +- cocos/cocos2d.h | 2 +- .../Classes/Sprite3DTest/Sprite3DTest.cpp | 32 +++++----- .../Classes/Sprite3DTest/Sprite3DTest.h | 6 +- 14 files changed, 114 insertions(+), 114 deletions(-) rename cocos/2d/{CCCameraBackGroundBrush.cpp => CCCameraBackgroundBrush.cpp} (85%) rename cocos/2d/{CCCameraBackGroundBrush.h => CCCameraBackgroundBrush.h} (81%) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 08e37fa3b1..90af72ae38 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -3603,10 +3603,10 @@ B6DD2FF61B04825B00E47F5F /* fastlz.c in Sources */ = {isa = PBXBuildFile; fileRef = B6DD2FA51B04825B00E47F5F /* fastlz.c */; }; B6DD2FF71B04825B00E47F5F /* fastlz.h in Headers */ = {isa = PBXBuildFile; fileRef = B6DD2FA61B04825B00E47F5F /* fastlz.h */; }; B6DD2FF81B04825B00E47F5F /* fastlz.h in Headers */ = {isa = PBXBuildFile; fileRef = B6DD2FA61B04825B00E47F5F /* fastlz.h */; }; - B6DD36D51B8564EC0044745A /* CCCameraBackGroundBrush.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6DD36D31B8564EC0044745A /* CCCameraBackGroundBrush.cpp */; }; - B6DD36D61B8564EC0044745A /* CCCameraBackGroundBrush.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6DD36D31B8564EC0044745A /* CCCameraBackGroundBrush.cpp */; }; - B6DD36D71B8564EC0044745A /* CCCameraBackGroundBrush.h in Headers */ = {isa = PBXBuildFile; fileRef = B6DD36D41B8564EC0044745A /* CCCameraBackGroundBrush.h */; }; - B6DD36D81B8564EC0044745A /* CCCameraBackGroundBrush.h in Headers */ = {isa = PBXBuildFile; fileRef = B6DD36D41B8564EC0044745A /* CCCameraBackGroundBrush.h */; }; + B6DD36D51B8564EC0044745A /* CCCameraBackgroundBrush.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6DD36D31B8564EC0044745A /* CCCameraBackgroundBrush.cpp */; }; + B6DD36D61B8564EC0044745A /* CCCameraBackgroundBrush.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6DD36D31B8564EC0044745A /* CCCameraBackgroundBrush.cpp */; }; + B6DD36D71B8564EC0044745A /* CCCameraBackgroundBrush.h in Headers */ = {isa = PBXBuildFile; fileRef = B6DD36D41B8564EC0044745A /* CCCameraBackgroundBrush.h */; }; + B6DD36D81B8564EC0044745A /* CCCameraBackgroundBrush.h in Headers */ = {isa = PBXBuildFile; fileRef = B6DD36D41B8564EC0044745A /* CCCameraBackgroundBrush.h */; }; C50306691B60B583001E6D43 /* CCBoneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C50306631B60B583001E6D43 /* CCBoneNode.cpp */; }; C503066A1B60B583001E6D43 /* CCBoneNode.h in Headers */ = {isa = PBXBuildFile; fileRef = C50306641B60B583001E6D43 /* CCBoneNode.h */; }; C503066B1B60B583001E6D43 /* CCSkeletonNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C50306651B60B583001E6D43 /* CCSkeletonNode.cpp */; }; @@ -5550,8 +5550,8 @@ B6DD2FA31B04825B00E47F5F /* DetourTileCacheBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DetourTileCacheBuilder.h; sourceTree = ""; }; B6DD2FA51B04825B00E47F5F /* fastlz.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fastlz.c; sourceTree = ""; }; B6DD2FA61B04825B00E47F5F /* fastlz.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fastlz.h; sourceTree = ""; }; - B6DD36D31B8564EC0044745A /* CCCameraBackGroundBrush.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCCameraBackGroundBrush.cpp; sourceTree = ""; }; - B6DD36D41B8564EC0044745A /* CCCameraBackGroundBrush.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCCameraBackGroundBrush.h; sourceTree = ""; }; + B6DD36D31B8564EC0044745A /* CCCameraBackgroundBrush.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCCameraBackgroundBrush.cpp; sourceTree = ""; }; + B6DD36D41B8564EC0044745A /* CCCameraBackgroundBrush.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCCameraBackgroundBrush.h; sourceTree = ""; }; C50306631B60B583001E6D43 /* CCBoneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBoneNode.cpp; sourceTree = ""; }; C50306641B60B583001E6D43 /* CCBoneNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBoneNode.h; sourceTree = ""; }; C50306651B60B583001E6D43 /* CCSkeletonNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSkeletonNode.cpp; sourceTree = ""; }; @@ -7333,8 +7333,8 @@ 46A169A11807B037005B8026 /* 2d */ = { isa = PBXGroup; children = ( - B6DD36D31B8564EC0044745A /* CCCameraBackGroundBrush.cpp */, - B6DD36D41B8564EC0044745A /* CCCameraBackGroundBrush.h */, + B6DD36D31B8564EC0044745A /* CCCameraBackgroundBrush.cpp */, + B6DD36D41B8564EC0044745A /* CCCameraBackgroundBrush.h */, 3EACC99C19F5014D00EB3C5E /* CCCamera.cpp */, 3EACC99D19F5014D00EB3C5E /* CCCamera.h */, 3EACC99E19F5014D00EB3C5E /* CCLight.cpp */, @@ -9338,7 +9338,7 @@ 15AE1BDD19AAE01E00C27E9E /* CCControlUtils.h in Headers */, B6CAB3271AF9AA1A00B9B856 /* btGImpactBvh.h in Headers */, 15AE198D19AAD36E00C27E9E /* CheckBoxReader.h in Headers */, - B6DD36D71B8564EC0044745A /* CCCameraBackGroundBrush.h in Headers */, + B6DD36D71B8564EC0044745A /* CCCameraBackgroundBrush.h in Headers */, B29A7E0919EE1B7700872B35 /* AttachmentLoader.h in Headers */, 1A01C68818F57BE800EFE3A6 /* CCBool.h in Headers */, B29A7E3319EE1B7700872B35 /* SlotData.h in Headers */, @@ -10819,7 +10819,7 @@ B29A7DDA19EE1B7700872B35 /* SkeletonRenderer.h in Headers */, 15AE194119AAD35100C27E9E /* CCBone.h in Headers */, D0FD035A1A3B51AA00825BB5 /* CCAllocatorStrategyDefault.h in Headers */, - B6DD36D81B8564EC0044745A /* CCCameraBackGroundBrush.h in Headers */, + B6DD36D81B8564EC0044745A /* CCCameraBackgroundBrush.h in Headers */, 50ABBD471925AB0000A911A9 /* CCVertex.h in Headers */, B6CAB4D81AF9AA1A00B9B856 /* SpuLocalSupport.h in Headers */, B6CAB2921AF9AA1A00B9B856 /* btCollisionShape.h in Headers */, @@ -11051,7 +11051,7 @@ B6CAB2811AF9AA1A00B9B856 /* btBoxShape.cpp in Sources */, 50ABBE311925AB6F00A911A9 /* CCConfiguration.cpp in Sources */, B665E3821AA80A6500DDB1C5 /* CCPUPathFollower.cpp in Sources */, - B6DD36D51B8564EC0044745A /* CCCameraBackGroundBrush.cpp in Sources */, + B6DD36D51B8564EC0044745A /* CCCameraBackgroundBrush.cpp in Sources */, 1A01C6A418F58F7500EFE3A6 /* CCNotificationCenter.cpp in Sources */, 15AE1A5D19AAD40300C27E9E /* b2Body.cpp in Sources */, 15AE1BDA19AAE01E00C27E9E /* CCControlSwitch.cpp in Sources */, @@ -12062,7 +12062,7 @@ 3EACC9A519F5014D00EB3C5E /* CCLight.cpp in Sources */, 15AE1B7A19AADA9A00C27E9E /* UIScrollView.cpp in Sources */, 1A570076180BC5A10088DEC7 /* CCActionGrid3D.cpp in Sources */, - B6DD36D61B8564EC0044745A /* CCCameraBackGroundBrush.cpp in Sources */, + B6DD36D61B8564EC0044745A /* CCCameraBackgroundBrush.cpp in Sources */, B6CAB38C1AF9AA1A00B9B856 /* btPolyhedralContactClipping.cpp in Sources */, B6CAB3A41AF9AA1A00B9B856 /* btConeTwistConstraint.cpp in Sources */, 15AE19B219AAD39700C27E9E /* SliderReader.cpp in Sources */, diff --git a/cocos/2d/CCCamera.cpp b/cocos/2d/CCCamera.cpp index 32fdfd055e..bf6ffc9b8f 100644 --- a/cocos/2d/CCCamera.cpp +++ b/cocos/2d/CCCamera.cpp @@ -25,7 +25,7 @@ ****************************************************************************/ #include "2d/CCCamera.h" -#include "2d/CCCameraBackGroundBrush.h" +#include "2d/CCCameraBackgroundBrush.h" #include "base/CCDirector.h" #include "platform/CCGLView.h" #include "2d/CCScene.h" @@ -97,7 +97,7 @@ Camera::Camera() , _fbo(nullptr) { _frustum.setClipZ(true); - _clearBrush = CameraBackGroundBrush::createDepthBrush(1.f); + _clearBrush = CameraBackgroundBrush::createDepthBrush(1.f); _clearBrush->retain(); } @@ -406,7 +406,7 @@ void Camera::clearBackground() { if (_clearBrush) { - _clearBrush->drawBackGround(this); + _clearBrush->drawBackground(this); } } @@ -474,7 +474,7 @@ void Camera::visit(Renderer* renderer, const Mat4 &parentTransform, uint32_t par return Node::visit(renderer, parentTransform, parentFlags); } -void Camera::setBackGroundBrush(CameraBackGroundBrush* clearBrush) +void Camera::setBackgroundBrush(CameraBackgroundBrush* clearBrush) { CC_SAFE_RETAIN(clearBrush); CC_SAFE_RELEASE(_clearBrush); diff --git a/cocos/2d/CCCamera.h b/cocos/2d/CCCamera.h index cd1dd06452..7c5a3a30d9 100644 --- a/cocos/2d/CCCamera.h +++ b/cocos/2d/CCCamera.h @@ -36,7 +36,7 @@ THE SOFTWARE. NS_CC_BEGIN class Scene; -class CameraBackGroundBrush; +class CameraBackgroundBrush; /** * Note: @@ -237,7 +237,7 @@ public: */ static Camera* getDefaultCamera(); /** - Before rendering scene with this camera, the background need to be cleared. It clears the depth buffer with max depth by default. Use setBackGroundBrush to modify the default behavior + Before rendering scene with this camera, the background need to be cleared. It clears the depth buffer with max depth by default. Use setBackgroundBrush to modify the default behavior */ void clearBackground(); /** @@ -260,15 +260,15 @@ public: bool isViewProjectionUpdated() const {return _viewProjectionUpdated;} /** - * set the background brush. See CameraBackGroundBrush for more information. + * set the background brush. See CameraBackgroundBrush for more information. * @param clearBrush Brush used to clear the background */ - void setBackGroundBrush(CameraBackGroundBrush* clearBrush); + void setBackgroundBrush(CameraBackgroundBrush* clearBrush); /** * Get clear brush */ - CameraBackGroundBrush* getBackGroundBrush() const { return _clearBrush; } + CameraBackgroundBrush* getBackgroundBrush() const { return _clearBrush; } virtual void visit(Renderer* renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; @@ -312,7 +312,7 @@ protected: int8_t _depth; //camera depth, the depth of camera with CameraFlag::DEFAULT flag is 0 by default, a camera with larger depth is drawn on top of camera with smaller detph static Camera* _visitingCamera; - CameraBackGroundBrush* _clearBrush; //brush used to clear the back ground + CameraBackgroundBrush* _clearBrush; //brush used to clear the back ground experimental::Viewport _viewport; diff --git a/cocos/2d/CCCameraBackGroundBrush.cpp b/cocos/2d/CCCameraBackgroundBrush.cpp similarity index 85% rename from cocos/2d/CCCameraBackGroundBrush.cpp rename to cocos/2d/CCCameraBackgroundBrush.cpp index a9310460ab..2369719100 100644 --- a/cocos/2d/CCCameraBackGroundBrush.cpp +++ b/cocos/2d/CCCameraBackgroundBrush.cpp @@ -22,7 +22,7 @@ THE SOFTWARE. ****************************************************************************/ -#include "2d/CCCameraBackGroundBrush.h" +#include "2d/CCCameraBackgroundBrush.h" #include "2d/CCCamera.h" #include "base/ccMacros.h" #include "base/CCConfiguration.h" @@ -44,64 +44,64 @@ NS_CC_BEGIN -CameraBackGroundBrush::CameraBackGroundBrush() +CameraBackgroundBrush::CameraBackgroundBrush() : _glProgramState(nullptr) { } -CameraBackGroundBrush::~CameraBackGroundBrush() +CameraBackgroundBrush::~CameraBackgroundBrush() { CC_SAFE_RELEASE(_glProgramState); } -CameraBackGroundBrush* CameraBackGroundBrush::createNoneBrush() +CameraBackgroundBrush* CameraBackgroundBrush::createNoneBrush() { - auto ret = new (std::nothrow) CameraBackGroundBrush(); + auto ret = new (std::nothrow) CameraBackgroundBrush(); ret->init(); ret->autorelease(); return ret; } -CameraBackGroundColorBrush* CameraBackGroundBrush::createColorBrush(const Color4F& color, float depth) +CameraBackgroundColorBrush* CameraBackgroundBrush::createColorBrush(const Color4F& color, float depth) { - return CameraBackGroundColorBrush::create(color, depth); + return CameraBackgroundColorBrush::create(color, depth); } -CameraBackGroundDepthBrush* CameraBackGroundBrush::createDepthBrush(float depth) +CameraBackgroundDepthBrush* CameraBackgroundBrush::createDepthBrush(float depth) { - return CameraBackGroundDepthBrush::create(depth); + return CameraBackgroundDepthBrush::create(depth); } -CameraBackGroundSkyBoxBrush* CameraBackGroundBrush::createSkyboxBrush(const std::string& positive_x, const std::string& negative_x, const std::string& positive_y, const std::string& negative_y, const std::string& positive_z, const std::string& negative_z) +CameraBackgroundSkyBoxBrush* CameraBackgroundBrush::createSkyboxBrush(const std::string& positive_x, const std::string& negative_x, const std::string& positive_y, const std::string& negative_y, const std::string& positive_z, const std::string& negative_z) { - return CameraBackGroundSkyBoxBrush::create(positive_x, negative_x, positive_y, negative_y, positive_z, negative_z); + return CameraBackgroundSkyBoxBrush::create(positive_x, negative_x, positive_y, negative_y, positive_z, negative_z); } ////////////////////////////////////////////////////////////////////////////////////////// -CameraBackGroundDepthBrush::CameraBackGroundDepthBrush() +CameraBackgroundDepthBrush::CameraBackgroundDepthBrush() : _depth(0.f) , _clearColor(GL_FALSE) { } -CameraBackGroundDepthBrush::~CameraBackGroundDepthBrush() +CameraBackgroundDepthBrush::~CameraBackgroundDepthBrush() { } -CameraBackGroundDepthBrush* CameraBackGroundDepthBrush::create(float depth) +CameraBackgroundDepthBrush* CameraBackgroundDepthBrush::create(float depth) { - auto ret = new (std::nothrow) CameraBackGroundDepthBrush(); + auto ret = new (std::nothrow) CameraBackgroundDepthBrush(); ret->_depth = depth; ret->init(); ret->autorelease(); return ret; } -bool CameraBackGroundDepthBrush::init() +bool CameraBackgroundDepthBrush::init() { auto shader = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_CAMERA_CLEAR); _glProgramState = GLProgramState::getOrCreateWithGLProgram(shader); @@ -121,7 +121,7 @@ bool CameraBackGroundDepthBrush::init() return true; } -void CameraBackGroundDepthBrush::drawBackGround(Camera* camera) +void CameraBackgroundDepthBrush::drawBackground(Camera* camera) { GLboolean oldDepthTest; GLint oldDepthFunc; @@ -192,25 +192,25 @@ void CameraBackGroundDepthBrush::drawBackGround(Camera* camera) ////////////////////////////////////////////////////////////////////////////////////////// -CameraBackGroundColorBrush::CameraBackGroundColorBrush() +CameraBackgroundColorBrush::CameraBackgroundColorBrush() : _color(0.f, 0.f, 0.f, 0.f) { } -CameraBackGroundColorBrush::~CameraBackGroundColorBrush() +CameraBackgroundColorBrush::~CameraBackgroundColorBrush() { } -void CameraBackGroundColorBrush::setColor(const Color4F& color) +void CameraBackgroundColorBrush::setColor(const Color4F& color) { _quad.bl.colors = _quad.br.colors = _quad.tl.colors = _quad.tr.colors = Color4B(color); } -CameraBackGroundColorBrush* CameraBackGroundColorBrush::create(const Color4F& color, float depth) +CameraBackgroundColorBrush* CameraBackgroundColorBrush::create(const Color4F& color, float depth) { - auto ret = new (std::nothrow) CameraBackGroundColorBrush(); + auto ret = new (std::nothrow) CameraBackgroundColorBrush(); ret->init(); ret->_clearColor = GL_TRUE; ret->setColor(color); @@ -221,7 +221,7 @@ CameraBackGroundColorBrush* CameraBackGroundColorBrush::create(const Color4F& co } ///////////////////////////////////////////////////////////////////////////////////////////// -CameraBackGroundSkyBoxBrush::CameraBackGroundSkyBoxBrush() +CameraBackgroundSkyBoxBrush::CameraBackgroundSkyBoxBrush() : _vao(0) , _vertexBuffer(0) , _indexBuffer(0) @@ -238,7 +238,7 @@ CameraBackGroundSkyBoxBrush::CameraBackGroundSkyBoxBrush() #endif } -CameraBackGroundSkyBoxBrush::~CameraBackGroundSkyBoxBrush() +CameraBackgroundSkyBoxBrush::~CameraBackgroundSkyBoxBrush() { CC_SAFE_RELEASE(_texture); @@ -256,7 +256,7 @@ CameraBackGroundSkyBoxBrush::~CameraBackGroundSkyBoxBrush() } } -CameraBackGroundSkyBoxBrush* CameraBackGroundSkyBoxBrush::create(const std::string& positive_x, const std::string& negative_x, const std::string& positive_y, const std::string& negative_y, const std::string& positive_z, const std::string& negative_z) +CameraBackgroundSkyBoxBrush* CameraBackgroundSkyBoxBrush::create(const std::string& positive_x, const std::string& negative_x, const std::string& positive_y, const std::string& negative_y, const std::string& positive_z, const std::string& negative_z) { auto texture = TextureCube::create(positive_x, negative_x, positive_y, negative_y, positive_z, negative_z); if (texture == nullptr) @@ -269,7 +269,7 @@ CameraBackGroundSkyBoxBrush* CameraBackGroundSkyBoxBrush::create(const std::stri tRepeatParams.wrapT = GL_CLAMP_TO_EDGE; texture->setTexParameters(tRepeatParams); - auto ret = new(std::nothrow)CameraBackGroundSkyBoxBrush(); + auto ret = new(std::nothrow)CameraBackgroundSkyBoxBrush(); ret->init(); ret->setTexture(texture); @@ -278,9 +278,9 @@ CameraBackGroundSkyBoxBrush* CameraBackGroundSkyBoxBrush::create(const std::stri return ret; } -CameraBackGroundSkyBoxBrush* CameraBackGroundSkyBoxBrush::create() +CameraBackgroundSkyBoxBrush* CameraBackgroundSkyBoxBrush::create() { - auto ret = new(std::nothrow)CameraBackGroundSkyBoxBrush(); + auto ret = new(std::nothrow)CameraBackgroundSkyBoxBrush(); ret->init(); @@ -288,7 +288,7 @@ CameraBackGroundSkyBoxBrush* CameraBackGroundSkyBoxBrush::create() return ret; } -void CameraBackGroundSkyBoxBrush::drawBackGround(Camera* camera) +void CameraBackgroundSkyBoxBrush::drawBackground(Camera* camera) { Mat4 cameraModelMat = camera->getNodeToWorldTransform(); @@ -342,7 +342,7 @@ void CameraBackGroundSkyBoxBrush::drawBackGround(Camera* camera) CHECK_GL_ERROR_DEBUG(); } -bool CameraBackGroundSkyBoxBrush::init() +bool CameraBackgroundSkyBoxBrush::init() { auto shader = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_3D_SKYBOX); _glProgramState = GLProgramState::create(shader); @@ -354,7 +354,7 @@ bool CameraBackGroundSkyBoxBrush::init() return true; } -void CameraBackGroundSkyBoxBrush::initBuffer() +void CameraBackgroundSkyBoxBrush::initBuffer() { if (_vertexBuffer) glDeleteBuffers(1, &_vertexBuffer); @@ -407,7 +407,7 @@ void CameraBackGroundSkyBoxBrush::initBuffer() } } -void CameraBackGroundSkyBoxBrush::setTexture(TextureCube* texture) +void CameraBackgroundSkyBoxBrush::setTexture(TextureCube* texture) { CC_SAFE_RETAIN(texture); CC_SAFE_RELEASE(_texture); diff --git a/cocos/2d/CCCameraBackGroundBrush.h b/cocos/2d/CCCameraBackgroundBrush.h similarity index 81% rename from cocos/2d/CCCameraBackGroundBrush.h rename to cocos/2d/CCCameraBackgroundBrush.h index 152ea98c88..687b2c3e86 100644 --- a/cocos/2d/CCCameraBackGroundBrush.h +++ b/cocos/2d/CCCameraBackgroundBrush.h @@ -34,9 +34,9 @@ NS_CC_BEGIN -class CameraBackGroundColorBrush; -class CameraBackGroundDepthBrush; -class CameraBackGroundSkyBoxBrush; +class CameraBackgroundColorBrush; +class CameraBackgroundDepthBrush; +class CameraBackgroundSkyBoxBrush; class GLProgramState; class Camera; @@ -45,18 +45,18 @@ class Camera; * Defines a brush to clear the background of camera. * There are 4 types of brush. None brush do nothing, Depth brush clear background with given depth, Color brush clear background with given color and depth, Skybox brush clear the background with a skybox. Camera uses depth brush by default. */ -class CC_DLL CameraBackGroundBrush : public Ref +class CC_DLL CameraBackgroundBrush : public Ref { public: /** - * Brush types. There are 4 types of brush. See CameraBackGroundDepthBrush, CameraBackGroundColorBrush, CameraBackGroundSkyBoxBrush for more information. + * Brush types. There are 4 types of brush. See CameraBackgroundDepthBrush, CameraBackgroundColorBrush, CameraBackgroundSkyBoxBrush for more information. */ enum class BrushType { NONE, //none brush - DEPTH, // depth brush. See CameraBackGroundDepthBrush - COLOR, // color brush. See CameraBackGroundColorBrush - SKYBOX, // skybox brush. See CameraBackGroundSkyBoxBrush + DEPTH, // depth brush. See CameraBackgroundDepthBrush + COLOR, // color brush. See CameraBackgroundColorBrush + SKYBOX, // skybox brush. See CameraBackgroundSkyBoxBrush }; /** @@ -69,14 +69,14 @@ public: * Creates a none brush, it does nothing when clear the background * @return Created brush. */ - static CameraBackGroundBrush* createNoneBrush(); + static CameraBackgroundBrush* createNoneBrush(); /** * Creates a depth brush, which clears depth buffer with a given depth. * @param depth Depth used to clear depth buffer * @return Created brush */ - static CameraBackGroundDepthBrush* createDepthBrush(float depth = 1.f); + static CameraBackgroundDepthBrush* createDepthBrush(float depth = 1.f); /** * Creates a color brush @@ -84,7 +84,7 @@ public: * @param depth Depth used to clear depth buffer * @return Created brush */ - static CameraBackGroundColorBrush* createColorBrush(const Color4F& color, float depth); + static CameraBackgroundColorBrush* createColorBrush(const Color4F& color, float depth); /** Creates a Skybox brush with 6 textures. @@ -96,17 +96,17 @@ public: @param negative_z texture for the rear side of the texture cube face. @return A new brush inited with given parameters. */ - static CameraBackGroundSkyBoxBrush* createSkyboxBrush(const std::string& positive_x, const std::string& negative_x, + static CameraBackgroundSkyBoxBrush* createSkyboxBrush(const std::string& positive_x, const std::string& negative_x, const std::string& positive_y, const std::string& negative_y, const std::string& positive_z, const std::string& negative_z); /** * draw the background */ - virtual void drawBackGround(Camera* camera) {} + virtual void drawBackground(Camera* camera) {} CC_CONSTRUCTOR_ACCESS: - CameraBackGroundBrush(); - virtual ~CameraBackGroundBrush(); + CameraBackgroundBrush(); + virtual ~CameraBackgroundBrush(); protected: virtual bool init() { return true; } @@ -117,7 +117,7 @@ protected: /** * Depth brush clear depth buffer with given depth */ -class CC_DLL CameraBackGroundDepthBrush : public CameraBackGroundBrush +class CC_DLL CameraBackgroundDepthBrush : public CameraBackgroundBrush { public: /** @@ -125,7 +125,7 @@ public: * @param depth Depth used to clear the depth buffer * @return Created brush */ - static CameraBackGroundDepthBrush* create(float depth); + static CameraBackgroundDepthBrush* create(float depth); /** * Get brush type. Should be BrushType::DEPTH @@ -136,7 +136,7 @@ public: /** * Draw background */ - virtual void drawBackGround(Camera* camera) override; + virtual void drawBackground(Camera* camera) override; /** * Set depth @@ -145,8 +145,8 @@ public: void setDepth(float depth) { _depth = depth; } CC_CONSTRUCTOR_ACCESS: - CameraBackGroundDepthBrush(); - virtual ~CameraBackGroundDepthBrush(); + CameraBackgroundDepthBrush(); + virtual ~CameraBackgroundDepthBrush(); protected: virtual bool init() override; @@ -161,7 +161,7 @@ protected: /** * Color brush clear buffer with given depth and color */ -class CC_DLL CameraBackGroundColorBrush : public CameraBackGroundDepthBrush +class CC_DLL CameraBackgroundColorBrush : public CameraBackgroundDepthBrush { public: /** @@ -176,7 +176,7 @@ public: * @param depth Depth used to clear the depth buffer * @return Created brush */ - static CameraBackGroundColorBrush* create(const Color4F& color, float depth); + static CameraBackgroundColorBrush* create(const Color4F& color, float depth); /** * Set clear color @@ -185,8 +185,8 @@ public: void setColor(const Color4F& color); CC_CONSTRUCTOR_ACCESS: - CameraBackGroundColorBrush(); - virtual ~CameraBackGroundColorBrush(); + CameraBackgroundColorBrush(); + virtual ~CameraBackgroundColorBrush(); protected: @@ -200,7 +200,7 @@ class EventListenerCustom; /** * Skybox brush clear buffer with a skybox */ -class CC_DLL CameraBackGroundSkyBoxBrush : public CameraBackGroundBrush +class CC_DLL CameraBackgroundSkyBoxBrush : public CameraBackgroundBrush { public: /** @@ -218,13 +218,13 @@ public: @param negative_z texture for the rear side of the texture cube face. @return A new brush inited with given parameters. */ - static CameraBackGroundSkyBoxBrush* create(const std::string& positive_x, const std::string& negative_x, + static CameraBackgroundSkyBoxBrush* create(const std::string& positive_x, const std::string& negative_x, const std::string& positive_y, const std::string& negative_y, const std::string& positive_z, const std::string& negative_z); /** Creates a Skybox brush with 6 textures. */ - static CameraBackGroundSkyBoxBrush* create(); + static CameraBackgroundSkyBoxBrush* create(); /** * Set skybox texutre * @param texture Skybox texture @@ -234,11 +234,11 @@ public: /** * Draw background */ - virtual void drawBackGround(Camera* camera) override; + virtual void drawBackground(Camera* camera) override; CC_CONSTRUCTOR_ACCESS: - CameraBackGroundSkyBoxBrush(); - virtual ~CameraBackGroundSkyBoxBrush(); + CameraBackgroundSkyBoxBrush(); + virtual ~CameraBackgroundSkyBoxBrush(); /** * init Skybox. diff --git a/cocos/2d/CMakeLists.txt b/cocos/2d/CMakeLists.txt index d76096e7ce..9268255b86 100644 --- a/cocos/2d/CMakeLists.txt +++ b/cocos/2d/CMakeLists.txt @@ -24,7 +24,7 @@ set(COCOS_2D_SRC 2d/CCAnimation.cpp 2d/CCAtlasNode.cpp 2d/CCCamera.cpp - 2d/CCCameraBackGroundBrush.cpp + 2d/CCCameraBackgroundBrush.cpp 2d/CCClippingNode.cpp 2d/CCClippingRectangleNode.cpp 2d/CCComponentContainer.cpp diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index 3c15cea25c..4d33cd8871 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -681,7 +681,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* - + @@ -1297,7 +1297,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* - + diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index e0cd832b95..071543d2e7 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -1931,7 +1931,7 @@ network\Source Files - + 2d @@ -3768,7 +3768,7 @@ network\Header Files - + 2d diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems index 0871e51cb5..fe832bac5a 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems @@ -584,7 +584,7 @@ - + @@ -1179,7 +1179,7 @@ - + diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters index 31439fd209..b8cd7da27b 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters @@ -1867,7 +1867,7 @@ cocostudio\reader\WidgetReader\GameNodeDReader - + 2d @@ -3567,7 +3567,7 @@ cocostudio\reader\WidgetReader\GameNodeDReader - + 2d diff --git a/cocos/Android.mk b/cocos/Android.mk index 3635a8d21a..9343224bba 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -35,7 +35,7 @@ cocos2d.cpp \ 2d/CCAnimationCache.cpp \ 2d/CCAtlasNode.cpp \ 2d/CCCamera.cpp \ -2d/CCCameraBackGroundBrush.cpp \ +2d/CCCameraBackgroundBrush.cpp \ 2d/CCClippingNode.cpp \ 2d/CCClippingRectangleNode.cpp \ 2d/CCComponent.cpp \ diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index d1dde6d6b0..7ad0b66ae9 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -138,7 +138,7 @@ THE SOFTWARE. // 2d utils #include "2d/CCCamera.h" -#include "2d/CCCameraBackGroundBrush.h" +#include "2d/CCCameraBackgroundBrush.h" #include "2d/CCGrabber.h" #include "2d/CCGrid.h" #include "2d/CCLight.h" diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index 2f5a7cb257..e9853efd4c 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -25,7 +25,7 @@ #include "Sprite3DTest.h" #include "DrawNode3D.h" -#include "2d/CCCameraBackGroundBrush.h" +#include "2d/CCCameraBackgroundBrush.h" #include "extensions/Particle3D/PU/CCPUParticleSystem3D.h" @@ -62,7 +62,7 @@ Sprite3DTests::Sprite3DTests() ADD_TEST_CASE(Sprite3DClippingTest); ADD_TEST_CASE(Sprite3DTestMeshLight); ADD_TEST_CASE(Animate3DCallbackTest); - ADD_TEST_CASE(CameraBackGroundClearTest); + ADD_TEST_CASE(CameraBackgroundClearTest); }; //------------------------------------------------------------------ @@ -2723,11 +2723,11 @@ std::string Sprite3DTestMeshLight::subtitle() const return ""; } -CameraBackGroundClearTest::CameraBackGroundClearTest() +CameraBackgroundClearTest::CameraBackgroundClearTest() { TTFConfig ttfConfig("fonts/arial.ttf", 20); auto label1 = Label::createWithTTF(ttfConfig,"Clear Mode"); - auto item1 = MenuItemLabel::create(label1,CC_CALLBACK_1(CameraBackGroundClearTest::switch_CameraClearMode,this) ); + auto item1 = MenuItemLabel::create(label1,CC_CALLBACK_1(CameraBackgroundClearTest::switch_CameraClearMode,this) ); item1->setPosition( Vec2(VisibleRect::left().x+50, VisibleRect::bottom().y+item1->getContentSize().height*4 ) ); @@ -2752,36 +2752,36 @@ CameraBackGroundClearTest::CameraBackGroundClearTest() _label->setPosition(s.width / 2.f , VisibleRect::top().y * 0.8f); } -void CameraBackGroundClearTest::switch_CameraClearMode(cocos2d::Ref* sender) +void CameraBackgroundClearTest::switch_CameraClearMode(cocos2d::Ref* sender) { - auto type = _camera->getBackGroundBrush()->getBrushType(); - if (type == CameraBackGroundBrush::BrushType::NONE) + auto type = _camera->getBackgroundBrush()->getBrushType(); + if (type == CameraBackgroundBrush::BrushType::NONE) { - _camera->setBackGroundBrush(CameraBackGroundBrush::createDepthBrush(1.f)); + _camera->setBackgroundBrush(CameraBackgroundBrush::createDepthBrush(1.f)); _label->setString("Depth Clear Brush"); } - else if (type == CameraBackGroundBrush::BrushType::DEPTH) + else if (type == CameraBackgroundBrush::BrushType::DEPTH) { - _camera->setBackGroundBrush(CameraBackGroundBrush::createColorBrush(Color4F(1.f, 0.f, 0.f, 1.f), 1.f)); + _camera->setBackgroundBrush(CameraBackgroundBrush::createColorBrush(Color4F(1.f, 0.f, 0.f, 1.f), 1.f)); _label->setString("Color Clear Brush"); } - else if (type == CameraBackGroundBrush::BrushType::COLOR) + else if (type == CameraBackgroundBrush::BrushType::COLOR) { - _camera->setBackGroundBrush(CameraBackGroundBrush::createSkyboxBrush("Sprite3DTest/skybox/left.jpg", "Sprite3DTest/skybox/right.jpg","Sprite3DTest/skybox/top.jpg", "Sprite3DTest/skybox/bottom.jpg","Sprite3DTest/skybox/front.jpg", "Sprite3DTest/skybox/back.jpg")); + _camera->setBackgroundBrush(CameraBackgroundBrush::createSkyboxBrush("Sprite3DTest/skybox/left.jpg", "Sprite3DTest/skybox/right.jpg","Sprite3DTest/skybox/top.jpg", "Sprite3DTest/skybox/bottom.jpg","Sprite3DTest/skybox/front.jpg", "Sprite3DTest/skybox/back.jpg")); _label->setString("Skybox Clear Brush"); } - else if (type == CameraBackGroundBrush::BrushType::SKYBOX) + else if (type == CameraBackgroundBrush::BrushType::SKYBOX) { - _camera->setBackGroundBrush(CameraBackGroundBrush::createNoneBrush()); + _camera->setBackgroundBrush(CameraBackgroundBrush::createNoneBrush()); _label->setString("None Clear Brush"); } } -std::string CameraBackGroundClearTest::title() const +std::string CameraBackgroundClearTest::title() const { return "Camera Background Clear Brush"; } -std::string CameraBackGroundClearTest::subtitle() const +std::string CameraBackgroundClearTest::subtitle() const { return ""; } diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h index 27044b98f8..ad8035c4be 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h @@ -592,11 +592,11 @@ protected: cocos2d::Sprite3D* _sprite; }; -class CameraBackGroundClearTest : public Sprite3DTestDemo +class CameraBackgroundClearTest : public Sprite3DTestDemo { public: - CREATE_FUNC(CameraBackGroundClearTest); - CameraBackGroundClearTest(); + CREATE_FUNC(CameraBackgroundClearTest); + CameraBackgroundClearTest(); virtual std::string title() const override; virtual std::string subtitle() const override; From 7839a23c629f70ab4619bc0db3ce78319f1a5bb9 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Fri, 21 Aug 2015 03:53:16 +0000 Subject: [PATCH 040/118] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 8dcf68e30c..122e036069 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -78,6 +78,8 @@ "cocos/2d/CCAutoPolygon.h", "cocos/2d/CCCamera.cpp", "cocos/2d/CCCamera.h", + "cocos/2d/CCCameraBackgroundBrush.cpp", + "cocos/2d/CCCameraBackgroundBrush.h", "cocos/2d/CCClippingNode.cpp", "cocos/2d/CCClippingNode.h", "cocos/2d/CCClippingRectangleNode.cpp", From 29f97d63ed798ab1944585e0b9502c20c84307c0 Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 21 Aug 2015 11:56:19 +0800 Subject: [PATCH 041/118] fix scrollview innerContainer initial position. --- cocos/ui/UIScrollView.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index 2651ec5e01..401e4a8552 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -176,6 +176,21 @@ void ScrollView::setInnerContainerSize(const Size &size) } _innerContainer->setContentSize(Size(innerSizeWidth, innerSizeHeight)); + // move children appropriately + { + float offsetY = originalInnerSize.height - innerSizeHeight; + float offsetX = 0; + if (_innerContainer->getRightBoundary() <= _contentSize.width) + { + offsetX = originalInnerSize.width - innerSizeWidth; + } + if(offsetX != 0 || offsetY != 0) + { + setInnerContainerPosition(Vec2(offsetX, offsetY)); + } + } + + // Calculate and set the position of the inner container. Vec2 pos = _innerContainer->getPosition(); if (_innerContainer->getLeftBoundary() > 0.0f) From 9a6c7795805993f623f3b81baf8a494da48c2f87 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Fri, 21 Aug 2015 03:59:12 +0000 Subject: [PATCH 042/118] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/jsb_cocos2dx_auto_api.js | 258 ++++- .../js-bindings/auto/jsb_cocos2dx_auto.cpp | 830 ++++++++++++++- .../js-bindings/auto/jsb_cocos2dx_auto.hpp | 52 + .../lua-bindings/auto/api/Camera.lua | 17 +- .../auto/api/CameraBackgroundBrush.lua | 72 ++ .../auto/api/CameraBackgroundColorBrush.lua | 39 + .../auto/api/CameraBackgroundDepthBrush.lua | 44 + .../auto/api/CameraBackgroundSkyBoxBrush.lua | 60 ++ .../auto/api/lua_cocos2dx_auto_api.lua | 20 + .../lua-bindings/auto/lua_cocos2dx_auto.cpp | 994 +++++++++++++++++- .../lua-bindings/auto/lua_cocos2dx_auto.hpp | 24 + 11 files changed, 2391 insertions(+), 19 deletions(-) create mode 100644 cocos/scripting/lua-bindings/auto/api/CameraBackgroundBrush.lua create mode 100644 cocos/scripting/lua-bindings/auto/api/CameraBackgroundColorBrush.lua create mode 100644 cocos/scripting/lua-bindings/auto/api/CameraBackgroundDepthBrush.lua create mode 100644 cocos/scripting/lua-bindings/auto/api/CameraBackgroundSkyBoxBrush.lua diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js index 254afb029c..a81d2350dd 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js @@ -18379,6 +18379,16 @@ applyViewport : function ( { }, +/** + * @method setBackgroundBrush + * @param {cc.CameraBackgroundBrush} arg0 + */ +setBackgroundBrush : function ( +camerabackgroundbrush +) +{ +}, + /** * @method lookAt * @param {vec3_object} arg0 @@ -18399,6 +18409,16 @@ apply : function ( { }, +/** + * @method getBackgroundBrush + * @return {cc.CameraBackgroundBrush} + */ +getBackgroundBrush : function ( +) +{ + return cc.CameraBackgroundBrush; +}, + /** * @method getProjectionMatrix * @return {mat4_object} @@ -18423,10 +18443,8 @@ mat4 /** * @method clearBackground - * @param {float} arg0 */ clearBackground : function ( -float ) { }, @@ -18736,6 +18754,242 @@ Camera : function ( }; +/** + * @class CameraBackgroundBrush + */ +cc.CameraBackgroundBrush = { + +/** + * @method getBrushType + * @return {cc.CameraBackgroundBrush::BrushType} + */ +getBrushType : function ( +) +{ + return 0; +}, + +/** + * @method drawBackground + * @param {cc.Camera} arg0 + */ +drawBackground : function ( +camera +) +{ +}, + +/** + * @method createSkyboxBrush + * @param {String} arg0 + * @param {String} arg1 + * @param {String} arg2 + * @param {String} arg3 + * @param {String} arg4 + * @param {String} arg5 + * @return {cc.CameraBackgroundSkyBoxBrush} + */ +createSkyboxBrush : function ( +str, +str, +str, +str, +str, +str +) +{ + return cc.CameraBackgroundSkyBoxBrush; +}, + +/** + * @method createColorBrush + * @param {color4f_object} arg0 + * @param {float} arg1 + * @return {cc.CameraBackgroundColorBrush} + */ +createColorBrush : function ( +color4f, +float +) +{ + return cc.CameraBackgroundColorBrush; +}, + +/** + * @method createNoneBrush + * @return {cc.CameraBackgroundBrush} + */ +createNoneBrush : function ( +) +{ + return cc.CameraBackgroundBrush; +}, + +/** + * @method createDepthBrush + * @return {cc.CameraBackgroundDepthBrush} + */ +createDepthBrush : function ( +) +{ + return cc.CameraBackgroundDepthBrush; +}, + +/** + * @method CameraBackgroundBrush + * @constructor + */ +CameraBackgroundBrush : function ( +) +{ +}, + +}; + +/** + * @class CameraBackgroundDepthBrush + */ +cc.CameraBackgroundDepthBrush = { + +/** + * @method setDepth + * @param {float} arg0 + */ +setDepth : function ( +float +) +{ +}, + +/** + * @method create + * @param {float} arg0 + * @return {cc.CameraBackgroundDepthBrush} + */ +create : function ( +float +) +{ + return cc.CameraBackgroundDepthBrush; +}, + +/** + * @method CameraBackgroundDepthBrush + * @constructor + */ +CameraBackgroundDepthBrush : function ( +) +{ +}, + +}; + +/** + * @class CameraBackgroundColorBrush + */ +cc.CameraBackgroundColorBrush = { + +/** + * @method setColor + * @param {color4f_object} arg0 + */ +setColor : function ( +color4f +) +{ +}, + +/** + * @method create + * @param {color4f_object} arg0 + * @param {float} arg1 + * @return {cc.CameraBackgroundColorBrush} + */ +create : function ( +color4f, +float +) +{ + return cc.CameraBackgroundColorBrush; +}, + +/** + * @method CameraBackgroundColorBrush + * @constructor + */ +CameraBackgroundColorBrush : function ( +) +{ +}, + +}; + +/** + * @class CameraBackgroundSkyBoxBrush + */ +cc.CameraBackgroundSkyBoxBrush = { + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method setTexture + * @param {cc.TextureCube} arg0 + */ +setTexture : function ( +texturecube +) +{ +}, + +/** + * @method initBuffer + */ +initBuffer : function ( +) +{ +}, + +/** + * @method create +* @param {String} str +* @param {String} str +* @param {String} str +* @param {String} str +* @param {String} str +* @param {String} str +* @return {cc.CameraBackgroundSkyBoxBrush|cc.CameraBackgroundSkyBoxBrush} +*/ +create : function( +str, +str, +str, +str, +str, +str +) +{ + return cc.CameraBackgroundSkyBoxBrush; +}, + +/** + * @method CameraBackgroundSkyBoxBrush + * @constructor + */ +CameraBackgroundSkyBoxBrush : function ( +) +{ +}, + +}; + /** * @class GridBase */ diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp index af9e65d0c7..bc350b96d4 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp @@ -56732,6 +56732,34 @@ bool js_cocos2dx_Camera_applyViewport(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Camera_applyViewport : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_Camera_setBackgroundBrush(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_setBackgroundBrush : Invalid Native Object"); + if (argc == 1) { + cocos2d::CameraBackgroundBrush* arg0; + do { + if (args.get(0).isNull()) { arg0 = nullptr; break; } + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::CameraBackgroundBrush*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Camera_setBackgroundBrush : Error processing arguments"); + cobj->setBackgroundBrush(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Camera_setBackgroundBrush : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_Camera_lookAt(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -56778,6 +56806,31 @@ bool js_cocos2dx_Camera_apply(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Camera_apply : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_Camera_getBackgroundBrush(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_getBackgroundBrush : Invalid Native Object"); + if (argc == 0) { + cocos2d::CameraBackgroundBrush* ret = cobj->getBackgroundBrush(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::CameraBackgroundBrush*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Camera_getBackgroundBrush : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_Camera_getProjectionMatrix(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -56821,21 +56874,17 @@ bool js_cocos2dx_Camera_getDepthInView(JSContext *cx, uint32_t argc, jsval *vp) bool js_cocos2dx_Camera_clearBackground(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_clearBackground : Invalid Native Object"); - if (argc == 1) { - double arg0; - ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Camera_clearBackground : Error processing arguments"); - cobj->clearBackground(arg0); + if (argc == 0) { + cobj->clearBackground(); args.rval().setUndefined(); return true; } - JS_ReportError(cx, "js_cocos2dx_Camera_clearBackground : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_Camera_clearBackground : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_Camera_setAdditionalProjection(JSContext *cx, uint32_t argc, jsval *vp) @@ -57447,11 +57496,13 @@ void js_register_cocos2dx_Camera(JSContext *cx, JS::HandleObject global) { JS_FN("getDepth", js_cocos2dx_Camera_getDepth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getViewProjectionMatrix", js_cocos2dx_Camera_getViewProjectionMatrix, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("applyViewport", js_cocos2dx_Camera_applyViewport, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBackgroundBrush", js_cocos2dx_Camera_setBackgroundBrush, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("lookAt", js_cocos2dx_Camera_lookAt, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("apply", js_cocos2dx_Camera_apply, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBackgroundBrush", js_cocos2dx_Camera_getBackgroundBrush, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getProjectionMatrix", js_cocos2dx_Camera_getProjectionMatrix, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDepthInView", js_cocos2dx_Camera_getDepthInView, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("clearBackground", js_cocos2dx_Camera_clearBackground, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("clearBackground", js_cocos2dx_Camera_clearBackground, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAdditionalProjection", js_cocos2dx_Camera_setAdditionalProjection, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setViewport", js_cocos2dx_Camera_setViewport, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initDefault", js_cocos2dx_Camera_initDefault, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -57513,6 +57564,763 @@ void js_register_cocos2dx_Camera(JSContext *cx, JS::HandleObject global) { } } +JSClass *jsb_cocos2d_CameraBackgroundBrush_class; +JSObject *jsb_cocos2d_CameraBackgroundBrush_prototype; + +bool js_cocos2dx_CameraBackgroundBrush_getBrushType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::CameraBackgroundBrush* cobj = (cocos2d::CameraBackgroundBrush *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CameraBackgroundBrush_getBrushType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getBrushType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_CameraBackgroundBrush_getBrushType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_CameraBackgroundBrush_drawBackground(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::CameraBackgroundBrush* cobj = (cocos2d::CameraBackgroundBrush *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CameraBackgroundBrush_drawBackground : Invalid Native Object"); + if (argc == 1) { + cocos2d::Camera* arg0; + do { + if (args.get(0).isNull()) { arg0 = nullptr; break; } + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Camera*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_CameraBackgroundBrush_drawBackground : Error processing arguments"); + cobj->drawBackground(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_CameraBackgroundBrush_drawBackground : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_CameraBackgroundBrush_createSkyboxBrush(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 6) { + std::string arg0; + std::string arg1; + std::string arg2; + std::string arg3; + std::string arg4; + std::string arg5; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + ok &= jsval_to_std_string(cx, args.get(3), &arg3); + ok &= jsval_to_std_string(cx, args.get(4), &arg4); + ok &= jsval_to_std_string(cx, args.get(5), &arg5); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_CameraBackgroundBrush_createSkyboxBrush : Error processing arguments"); + cocos2d::CameraBackgroundSkyBoxBrush* ret = cocos2d::CameraBackgroundBrush::createSkyboxBrush(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::CameraBackgroundSkyBoxBrush*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_CameraBackgroundBrush_createSkyboxBrush : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_CameraBackgroundBrush_createColorBrush(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::Color4F arg0; + double arg1; + ok &= jsval_to_cccolor4f(cx, args.get(0), &arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_CameraBackgroundBrush_createColorBrush : Error processing arguments"); + cocos2d::CameraBackgroundColorBrush* ret = cocos2d::CameraBackgroundBrush::createColorBrush(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::CameraBackgroundColorBrush*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_CameraBackgroundBrush_createColorBrush : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_CameraBackgroundBrush_createNoneBrush(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::CameraBackgroundBrush* ret = cocos2d::CameraBackgroundBrush::createNoneBrush(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::CameraBackgroundBrush*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_CameraBackgroundBrush_createNoneBrush : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_CameraBackgroundBrush_createDepthBrush(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 0) { + cocos2d::CameraBackgroundDepthBrush* ret = cocos2d::CameraBackgroundBrush::createDepthBrush(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::CameraBackgroundDepthBrush*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_CameraBackgroundBrush_createDepthBrush : Error processing arguments"); + cocos2d::CameraBackgroundDepthBrush* ret = cocos2d::CameraBackgroundBrush::createDepthBrush(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::CameraBackgroundDepthBrush*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_CameraBackgroundBrush_createDepthBrush : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_CameraBackgroundBrush_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::CameraBackgroundBrush* cobj = new (std::nothrow) cocos2d::CameraBackgroundBrush(); + cocos2d::Ref *_ccobj = dynamic_cast(cobj); + if (_ccobj) { + _ccobj->autorelease(); + } + TypeTest t; + js_type_class_t *typeClass = nullptr; + std::string typeName = t.s_name(); + auto typeMapIter = _js_global_type_map.find(typeName); + CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); + typeClass = typeMapIter->second; + CCASSERT(typeClass, "The value is null."); + // JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::CameraBackgroundBrush"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + +void js_cocos2d_CameraBackgroundBrush_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (CameraBackgroundBrush)", obj); +} +void js_register_cocos2dx_CameraBackgroundBrush(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_CameraBackgroundBrush_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_CameraBackgroundBrush_class->name = "CameraBackgroundBrush"; + jsb_cocos2d_CameraBackgroundBrush_class->addProperty = JS_PropertyStub; + jsb_cocos2d_CameraBackgroundBrush_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_CameraBackgroundBrush_class->getProperty = JS_PropertyStub; + jsb_cocos2d_CameraBackgroundBrush_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_CameraBackgroundBrush_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_CameraBackgroundBrush_class->resolve = JS_ResolveStub; + jsb_cocos2d_CameraBackgroundBrush_class->convert = JS_ConvertStub; + jsb_cocos2d_CameraBackgroundBrush_class->finalize = js_cocos2d_CameraBackgroundBrush_finalize; + jsb_cocos2d_CameraBackgroundBrush_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getBrushType", js_cocos2dx_CameraBackgroundBrush_getBrushType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("drawBackground", js_cocos2dx_CameraBackgroundBrush_drawBackground, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("createSkyboxBrush", js_cocos2dx_CameraBackgroundBrush_createSkyboxBrush, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createColorBrush", js_cocos2dx_CameraBackgroundBrush_createColorBrush, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createNoneBrush", js_cocos2dx_CameraBackgroundBrush_createNoneBrush, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createDepthBrush", js_cocos2dx_CameraBackgroundBrush_createDepthBrush, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_CameraBackgroundBrush_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_CameraBackgroundBrush_class, + js_cocos2dx_CameraBackgroundBrush_constructor, 0, // constructor + properties, + funcs, + NULL, // no static properties + st_funcs); + // make the class enumerable in the registered namespace +// bool found; +//FIXME: Removed in Firefox v27 +// JS_SetPropertyAttributes(cx, global, "CameraBackgroundBrush", JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + // add the proto and JSClass to the type->js info hash table + TypeTest t; + js_type_class_t *p; + std::string typeName = t.s_name(); + if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) + { + p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); + p->jsclass = jsb_cocos2d_CameraBackgroundBrush_class; + p->proto = jsb_cocos2d_CameraBackgroundBrush_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_CameraBackgroundDepthBrush_class; +JSObject *jsb_cocos2d_CameraBackgroundDepthBrush_prototype; + +bool js_cocos2dx_CameraBackgroundDepthBrush_setDepth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::CameraBackgroundDepthBrush* cobj = (cocos2d::CameraBackgroundDepthBrush *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CameraBackgroundDepthBrush_setDepth : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_CameraBackgroundDepthBrush_setDepth : Error processing arguments"); + cobj->setDepth(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_CameraBackgroundDepthBrush_setDepth : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_CameraBackgroundDepthBrush_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_CameraBackgroundDepthBrush_create : Error processing arguments"); + cocos2d::CameraBackgroundDepthBrush* ret = cocos2d::CameraBackgroundDepthBrush::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::CameraBackgroundDepthBrush*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_CameraBackgroundDepthBrush_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_CameraBackgroundDepthBrush_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::CameraBackgroundDepthBrush* cobj = new (std::nothrow) cocos2d::CameraBackgroundDepthBrush(); + cocos2d::Ref *_ccobj = dynamic_cast(cobj); + if (_ccobj) { + _ccobj->autorelease(); + } + TypeTest t; + js_type_class_t *typeClass = nullptr; + std::string typeName = t.s_name(); + auto typeMapIter = _js_global_type_map.find(typeName); + CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); + typeClass = typeMapIter->second; + CCASSERT(typeClass, "The value is null."); + // JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::CameraBackgroundDepthBrush"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + +extern JSObject *jsb_cocos2d_CameraBackgroundBrush_prototype; + +void js_cocos2d_CameraBackgroundDepthBrush_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (CameraBackgroundDepthBrush)", obj); +} +void js_register_cocos2dx_CameraBackgroundDepthBrush(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_CameraBackgroundDepthBrush_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_CameraBackgroundDepthBrush_class->name = "CameraBackgroundDepthBrush"; + jsb_cocos2d_CameraBackgroundDepthBrush_class->addProperty = JS_PropertyStub; + jsb_cocos2d_CameraBackgroundDepthBrush_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_CameraBackgroundDepthBrush_class->getProperty = JS_PropertyStub; + jsb_cocos2d_CameraBackgroundDepthBrush_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_CameraBackgroundDepthBrush_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_CameraBackgroundDepthBrush_class->resolve = JS_ResolveStub; + jsb_cocos2d_CameraBackgroundDepthBrush_class->convert = JS_ConvertStub; + jsb_cocos2d_CameraBackgroundDepthBrush_class->finalize = js_cocos2d_CameraBackgroundDepthBrush_finalize; + jsb_cocos2d_CameraBackgroundDepthBrush_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setDepth", js_cocos2dx_CameraBackgroundDepthBrush_setDepth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_CameraBackgroundDepthBrush_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_CameraBackgroundDepthBrush_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_CameraBackgroundBrush_prototype), + jsb_cocos2d_CameraBackgroundDepthBrush_class, + js_cocos2dx_CameraBackgroundDepthBrush_constructor, 0, // constructor + properties, + funcs, + NULL, // no static properties + st_funcs); + // make the class enumerable in the registered namespace +// bool found; +//FIXME: Removed in Firefox v27 +// JS_SetPropertyAttributes(cx, global, "CameraBackgroundDepthBrush", JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + // add the proto and JSClass to the type->js info hash table + TypeTest t; + js_type_class_t *p; + std::string typeName = t.s_name(); + if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) + { + p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); + p->jsclass = jsb_cocos2d_CameraBackgroundDepthBrush_class; + p->proto = jsb_cocos2d_CameraBackgroundDepthBrush_prototype; + p->parentProto = jsb_cocos2d_CameraBackgroundBrush_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_CameraBackgroundColorBrush_class; +JSObject *jsb_cocos2d_CameraBackgroundColorBrush_prototype; + +bool js_cocos2dx_CameraBackgroundColorBrush_setColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::CameraBackgroundColorBrush* cobj = (cocos2d::CameraBackgroundColorBrush *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CameraBackgroundColorBrush_setColor : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color4F arg0; + ok &= jsval_to_cccolor4f(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_CameraBackgroundColorBrush_setColor : Error processing arguments"); + cobj->setColor(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_CameraBackgroundColorBrush_setColor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_CameraBackgroundColorBrush_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::Color4F arg0; + double arg1; + ok &= jsval_to_cccolor4f(cx, args.get(0), &arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_CameraBackgroundColorBrush_create : Error processing arguments"); + cocos2d::CameraBackgroundColorBrush* ret = cocos2d::CameraBackgroundColorBrush::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::CameraBackgroundColorBrush*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_CameraBackgroundColorBrush_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_CameraBackgroundColorBrush_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::CameraBackgroundColorBrush* cobj = new (std::nothrow) cocos2d::CameraBackgroundColorBrush(); + cocos2d::Ref *_ccobj = dynamic_cast(cobj); + if (_ccobj) { + _ccobj->autorelease(); + } + TypeTest t; + js_type_class_t *typeClass = nullptr; + std::string typeName = t.s_name(); + auto typeMapIter = _js_global_type_map.find(typeName); + CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); + typeClass = typeMapIter->second; + CCASSERT(typeClass, "The value is null."); + // JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::CameraBackgroundColorBrush"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + +extern JSObject *jsb_cocos2d_CameraBackgroundDepthBrush_prototype; + +void js_cocos2d_CameraBackgroundColorBrush_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (CameraBackgroundColorBrush)", obj); +} +void js_register_cocos2dx_CameraBackgroundColorBrush(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_CameraBackgroundColorBrush_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_CameraBackgroundColorBrush_class->name = "CameraBackgroundColorBrush"; + jsb_cocos2d_CameraBackgroundColorBrush_class->addProperty = JS_PropertyStub; + jsb_cocos2d_CameraBackgroundColorBrush_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_CameraBackgroundColorBrush_class->getProperty = JS_PropertyStub; + jsb_cocos2d_CameraBackgroundColorBrush_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_CameraBackgroundColorBrush_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_CameraBackgroundColorBrush_class->resolve = JS_ResolveStub; + jsb_cocos2d_CameraBackgroundColorBrush_class->convert = JS_ConvertStub; + jsb_cocos2d_CameraBackgroundColorBrush_class->finalize = js_cocos2d_CameraBackgroundColorBrush_finalize; + jsb_cocos2d_CameraBackgroundColorBrush_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setColor", js_cocos2dx_CameraBackgroundColorBrush_setColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_CameraBackgroundColorBrush_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_CameraBackgroundColorBrush_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_CameraBackgroundDepthBrush_prototype), + jsb_cocos2d_CameraBackgroundColorBrush_class, + js_cocos2dx_CameraBackgroundColorBrush_constructor, 0, // constructor + properties, + funcs, + NULL, // no static properties + st_funcs); + // make the class enumerable in the registered namespace +// bool found; +//FIXME: Removed in Firefox v27 +// JS_SetPropertyAttributes(cx, global, "CameraBackgroundColorBrush", JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + // add the proto and JSClass to the type->js info hash table + TypeTest t; + js_type_class_t *p; + std::string typeName = t.s_name(); + if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) + { + p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); + p->jsclass = jsb_cocos2d_CameraBackgroundColorBrush_class; + p->proto = jsb_cocos2d_CameraBackgroundColorBrush_prototype; + p->parentProto = jsb_cocos2d_CameraBackgroundDepthBrush_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_CameraBackgroundSkyBoxBrush_class; +JSObject *jsb_cocos2d_CameraBackgroundSkyBoxBrush_prototype; + +bool js_cocos2dx_CameraBackgroundSkyBoxBrush_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::CameraBackgroundSkyBoxBrush* cobj = (cocos2d::CameraBackgroundSkyBoxBrush *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CameraBackgroundSkyBoxBrush_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_CameraBackgroundSkyBoxBrush_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_CameraBackgroundSkyBoxBrush_setTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::CameraBackgroundSkyBoxBrush* cobj = (cocos2d::CameraBackgroundSkyBoxBrush *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CameraBackgroundSkyBoxBrush_setTexture : Invalid Native Object"); + if (argc == 1) { + cocos2d::TextureCube* arg0; + do { + if (args.get(0).isNull()) { arg0 = nullptr; break; } + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::TextureCube*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_CameraBackgroundSkyBoxBrush_setTexture : Error processing arguments"); + cobj->setTexture(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_CameraBackgroundSkyBoxBrush_setTexture : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_CameraBackgroundSkyBoxBrush_initBuffer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::CameraBackgroundSkyBoxBrush* cobj = (cocos2d::CameraBackgroundSkyBoxBrush *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CameraBackgroundSkyBoxBrush_initBuffer : Invalid Native Object"); + if (argc == 0) { + cobj->initBuffer(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_CameraBackgroundSkyBoxBrush_initBuffer : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_CameraBackgroundSkyBoxBrush_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 0) { + cocos2d::CameraBackgroundSkyBoxBrush* ret = cocos2d::CameraBackgroundSkyBoxBrush::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::CameraBackgroundSkyBoxBrush*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 6) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + std::string arg3; + ok &= jsval_to_std_string(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + std::string arg4; + ok &= jsval_to_std_string(cx, args.get(4), &arg4); + if (!ok) { ok = true; break; } + std::string arg5; + ok &= jsval_to_std_string(cx, args.get(5), &arg5); + if (!ok) { ok = true; break; } + cocos2d::CameraBackgroundSkyBoxBrush* ret = cocos2d::CameraBackgroundSkyBoxBrush::create(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::CameraBackgroundSkyBoxBrush*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_CameraBackgroundSkyBoxBrush_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_CameraBackgroundSkyBoxBrush_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::CameraBackgroundSkyBoxBrush* cobj = new (std::nothrow) cocos2d::CameraBackgroundSkyBoxBrush(); + cocos2d::Ref *_ccobj = dynamic_cast(cobj); + if (_ccobj) { + _ccobj->autorelease(); + } + TypeTest t; + js_type_class_t *typeClass = nullptr; + std::string typeName = t.s_name(); + auto typeMapIter = _js_global_type_map.find(typeName); + CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); + typeClass = typeMapIter->second; + CCASSERT(typeClass, "The value is null."); + // JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::CameraBackgroundSkyBoxBrush"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + +extern JSObject *jsb_cocos2d_CameraBackgroundBrush_prototype; + +void js_cocos2d_CameraBackgroundSkyBoxBrush_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (CameraBackgroundSkyBoxBrush)", obj); +} +void js_register_cocos2dx_CameraBackgroundSkyBoxBrush(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_CameraBackgroundSkyBoxBrush_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_CameraBackgroundSkyBoxBrush_class->name = "CameraBackgroundSkyBoxBrush"; + jsb_cocos2d_CameraBackgroundSkyBoxBrush_class->addProperty = JS_PropertyStub; + jsb_cocos2d_CameraBackgroundSkyBoxBrush_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_CameraBackgroundSkyBoxBrush_class->getProperty = JS_PropertyStub; + jsb_cocos2d_CameraBackgroundSkyBoxBrush_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_CameraBackgroundSkyBoxBrush_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_CameraBackgroundSkyBoxBrush_class->resolve = JS_ResolveStub; + jsb_cocos2d_CameraBackgroundSkyBoxBrush_class->convert = JS_ConvertStub; + jsb_cocos2d_CameraBackgroundSkyBoxBrush_class->finalize = js_cocos2d_CameraBackgroundSkyBoxBrush_finalize; + jsb_cocos2d_CameraBackgroundSkyBoxBrush_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_CameraBackgroundSkyBoxBrush_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTexture", js_cocos2dx_CameraBackgroundSkyBoxBrush_setTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initBuffer", js_cocos2dx_CameraBackgroundSkyBoxBrush_initBuffer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_CameraBackgroundSkyBoxBrush_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_CameraBackgroundSkyBoxBrush_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_CameraBackgroundBrush_prototype), + jsb_cocos2d_CameraBackgroundSkyBoxBrush_class, + js_cocos2dx_CameraBackgroundSkyBoxBrush_constructor, 0, // constructor + properties, + funcs, + NULL, // no static properties + st_funcs); + // make the class enumerable in the registered namespace +// bool found; +//FIXME: Removed in Firefox v27 +// JS_SetPropertyAttributes(cx, global, "CameraBackgroundSkyBoxBrush", JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + // add the proto and JSClass to the type->js info hash table + TypeTest t; + js_type_class_t *p; + std::string typeName = t.s_name(); + if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) + { + p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); + p->jsclass = jsb_cocos2d_CameraBackgroundSkyBoxBrush_class; + p->proto = jsb_cocos2d_CameraBackgroundSkyBoxBrush_prototype; + p->parentProto = jsb_cocos2d_CameraBackgroundBrush_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + JSClass *jsb_cocos2d_GridBase_class; JSObject *jsb_cocos2d_GridBase_prototype; @@ -69029,6 +69837,9 @@ void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj) { js_register_cocos2dx_Texture2D(cx, ns); js_register_cocos2dx_TransitionSceneOriented(cx, ns); js_register_cocos2dx_TransitionFlipX(cx, ns); + js_register_cocos2dx_CameraBackgroundBrush(cx, ns); + js_register_cocos2dx_CameraBackgroundDepthBrush(cx, ns); + js_register_cocos2dx_CameraBackgroundColorBrush(cx, ns); js_register_cocos2dx_GridAction(cx, ns); js_register_cocos2dx_TiledGrid3DAction(cx, ns); js_register_cocos2dx_FadeOutTRTiles(cx, ns); @@ -69094,13 +69905,14 @@ void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj) { js_register_cocos2dx_EaseCubicActionIn(cx, ns); js_register_cocos2dx_TextureCache(cx, ns); js_register_cocos2dx_SpriteBatchNode(cx, ns); + js_register_cocos2dx_TMXLayer(cx, ns); js_register_cocos2dx_Configuration(cx, ns); js_register_cocos2dx_ActionTween(cx, ns); js_register_cocos2dx_TransitionFadeDown(cx, ns); js_register_cocos2dx_ParticleSun(cx, ns); js_register_cocos2dx_TransitionProgressHorizontal(cx, ns); js_register_cocos2dx_TMXObjectGroup(cx, ns); - js_register_cocos2dx_TMXLayer(cx, ns); + js_register_cocos2dx_CameraBackgroundSkyBoxBrush(cx, ns); js_register_cocos2dx_FlipX(cx, ns); js_register_cocos2dx_FlipY(cx, ns); js_register_cocos2dx_TransitionSplitCols(cx, ns); diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp index 7bf3fb4e30..38fdc905cc 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp @@ -3342,8 +3342,10 @@ void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); bool js_cocos2dx_Camera_getDepth(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Camera_getViewProjectionMatrix(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Camera_applyViewport(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_setBackgroundBrush(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Camera_lookAt(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Camera_apply(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_getBackgroundBrush(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Camera_getProjectionMatrix(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Camera_getDepthInView(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Camera_clearBackground(JSContext *cx, uint32_t argc, jsval *vp); @@ -3375,6 +3377,56 @@ bool js_cocos2dx_Camera_setDefaultViewport(JSContext *cx, uint32_t argc, jsval * bool js_cocos2dx_Camera_getDefaultCamera(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Camera_Camera(JSContext *cx, uint32_t argc, jsval *vp); +extern JSClass *jsb_cocos2d_CameraBackgroundBrush_class; +extern JSObject *jsb_cocos2d_CameraBackgroundBrush_prototype; + +bool js_cocos2dx_CameraBackgroundBrush_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_CameraBackgroundBrush_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_CameraBackgroundBrush(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_CameraBackgroundBrush_getBrushType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_CameraBackgroundBrush_drawBackground(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_CameraBackgroundBrush_createSkyboxBrush(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_CameraBackgroundBrush_createColorBrush(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_CameraBackgroundBrush_createNoneBrush(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_CameraBackgroundBrush_createDepthBrush(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_CameraBackgroundBrush_CameraBackgroundBrush(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_CameraBackgroundDepthBrush_class; +extern JSObject *jsb_cocos2d_CameraBackgroundDepthBrush_prototype; + +bool js_cocos2dx_CameraBackgroundDepthBrush_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_CameraBackgroundDepthBrush_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_CameraBackgroundDepthBrush(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_CameraBackgroundDepthBrush_setDepth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_CameraBackgroundDepthBrush_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_CameraBackgroundDepthBrush_CameraBackgroundDepthBrush(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_CameraBackgroundColorBrush_class; +extern JSObject *jsb_cocos2d_CameraBackgroundColorBrush_prototype; + +bool js_cocos2dx_CameraBackgroundColorBrush_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_CameraBackgroundColorBrush_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_CameraBackgroundColorBrush(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_CameraBackgroundColorBrush_setColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_CameraBackgroundColorBrush_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_CameraBackgroundColorBrush_CameraBackgroundColorBrush(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_CameraBackgroundSkyBoxBrush_class; +extern JSObject *jsb_cocos2d_CameraBackgroundSkyBoxBrush_prototype; + +bool js_cocos2dx_CameraBackgroundSkyBoxBrush_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_CameraBackgroundSkyBoxBrush_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_CameraBackgroundSkyBoxBrush(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_CameraBackgroundSkyBoxBrush_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_CameraBackgroundSkyBoxBrush_setTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_CameraBackgroundSkyBoxBrush_initBuffer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_CameraBackgroundSkyBoxBrush_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_CameraBackgroundSkyBoxBrush_CameraBackgroundSkyBoxBrush(JSContext *cx, uint32_t argc, jsval *vp); + extern JSClass *jsb_cocos2d_GridBase_class; extern JSObject *jsb_cocos2d_GridBase_prototype; diff --git a/cocos/scripting/lua-bindings/auto/api/Camera.lua b/cocos/scripting/lua-bindings/auto/api/Camera.lua index 583a1854ed..35eb57a01b 100644 --- a/cocos/scripting/lua-bindings/auto/api/Camera.lua +++ b/cocos/scripting/lua-bindings/auto/api/Camera.lua @@ -22,6 +22,14 @@ -- @param self -- @return Camera#Camera self (return value: cc.Camera) +-------------------------------- +-- set the background brush. See CameraBackgroundBrush for more information.
+-- param clearBrush Brush used to clear the background +-- @function [parent=#Camera] setBackgroundBrush +-- @param self +-- @param #cc.CameraBackgroundBrush clearBrush +-- @return Camera#Camera self (return value: cc.Camera) + -------------------------------- -- Make Camera looks at target
-- param target The target camera is point at
@@ -38,6 +46,12 @@ -- @param self -- @return Camera#Camera self (return value: cc.Camera) +-------------------------------- +-- Get clear brush +-- @function [parent=#Camera] getBackgroundBrush +-- @param self +-- @return CameraBackgroundBrush#CameraBackgroundBrush ret (return value: cc.CameraBackgroundBrush) + -------------------------------- -- Gets the camera's projection matrix.
-- return The camera projection matrix. @@ -53,10 +67,9 @@ -- @return float#float ret (return value: float) -------------------------------- --- Before rendering scene with this camera, the background need to be cleared. +-- Before rendering scene with this camera, the background need to be cleared. It clears the depth buffer with max depth by default. Use setBackgroundBrush to modify the default behavior -- @function [parent=#Camera] clearBackground -- @param self --- @param #float depth -- @return Camera#Camera self (return value: cc.Camera) -------------------------------- diff --git a/cocos/scripting/lua-bindings/auto/api/CameraBackgroundBrush.lua b/cocos/scripting/lua-bindings/auto/api/CameraBackgroundBrush.lua new file mode 100644 index 0000000000..65ff9c104f --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/api/CameraBackgroundBrush.lua @@ -0,0 +1,72 @@ + +-------------------------------- +-- @module CameraBackgroundBrush +-- @extend Ref +-- @parent_module cc + +-------------------------------- +-- get brush type
+-- return BrushType +-- @function [parent=#CameraBackgroundBrush] getBrushType +-- @param self +-- @return int#int ret (return value: int) + +-------------------------------- +-- draw the background +-- @function [parent=#CameraBackgroundBrush] drawBackground +-- @param self +-- @param #cc.Camera camera +-- @return CameraBackgroundBrush#CameraBackgroundBrush self (return value: cc.CameraBackgroundBrush) + +-------------------------------- +-- Creates a Skybox brush with 6 textures.
+-- param positive_x texture for the right side of the texture cube face.
+-- param negative_x texture for the up side of the texture cube face.
+-- param positive_y texture for the top side of the texture cube face
+-- param negative_y texture for the bottom side of the texture cube face
+-- param positive_z texture for the forward side of the texture cube face.
+-- param negative_z texture for the rear side of the texture cube face.
+-- return A new brush inited with given parameters. +-- @function [parent=#CameraBackgroundBrush] createSkyboxBrush +-- @param self +-- @param #string positive_x +-- @param #string negative_x +-- @param #string positive_y +-- @param #string negative_y +-- @param #string positive_z +-- @param #string negative_z +-- @return CameraBackgroundSkyBoxBrush#CameraBackgroundSkyBoxBrush ret (return value: cc.CameraBackgroundSkyBoxBrush) + +-------------------------------- +-- Creates a color brush
+-- param color Color of brush
+-- param depth Depth used to clear depth buffer
+-- return Created brush +-- @function [parent=#CameraBackgroundBrush] createColorBrush +-- @param self +-- @param #color4f_table color +-- @param #float depth +-- @return CameraBackgroundColorBrush#CameraBackgroundColorBrush ret (return value: cc.CameraBackgroundColorBrush) + +-------------------------------- +-- Creates a none brush, it does nothing when clear the background
+-- return Created brush. +-- @function [parent=#CameraBackgroundBrush] createNoneBrush +-- @param self +-- @return CameraBackgroundBrush#CameraBackgroundBrush ret (return value: cc.CameraBackgroundBrush) + +-------------------------------- +-- Creates a depth brush, which clears depth buffer with a given depth.
+-- param depth Depth used to clear depth buffer
+-- return Created brush +-- @function [parent=#CameraBackgroundBrush] createDepthBrush +-- @param self +-- @return CameraBackgroundDepthBrush#CameraBackgroundDepthBrush ret (return value: cc.CameraBackgroundDepthBrush) + +-------------------------------- +-- +-- @function [parent=#CameraBackgroundBrush] CameraBackgroundBrush +-- @param self +-- @return CameraBackgroundBrush#CameraBackgroundBrush self (return value: cc.CameraBackgroundBrush) + +return nil diff --git a/cocos/scripting/lua-bindings/auto/api/CameraBackgroundColorBrush.lua b/cocos/scripting/lua-bindings/auto/api/CameraBackgroundColorBrush.lua new file mode 100644 index 0000000000..c7a4414f0c --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/api/CameraBackgroundColorBrush.lua @@ -0,0 +1,39 @@ + +-------------------------------- +-- @module CameraBackgroundColorBrush +-- @extend CameraBackgroundDepthBrush +-- @parent_module cc + +-------------------------------- +-- Set clear color
+-- param color Color used to clear the color buffer +-- @function [parent=#CameraBackgroundColorBrush] setColor +-- @param self +-- @param #color4f_table color +-- @return CameraBackgroundColorBrush#CameraBackgroundColorBrush self (return value: cc.CameraBackgroundColorBrush) + +-------------------------------- +-- Create a color brush
+-- param color Color used to clear the color buffer
+-- param depth Depth used to clear the depth buffer
+-- return Created brush +-- @function [parent=#CameraBackgroundColorBrush] create +-- @param self +-- @param #color4f_table color +-- @param #float depth +-- @return CameraBackgroundColorBrush#CameraBackgroundColorBrush ret (return value: cc.CameraBackgroundColorBrush) + +-------------------------------- +-- Get brush type. Should be BrushType::COLOR
+-- return brush type +-- @function [parent=#CameraBackgroundColorBrush] getBrushType +-- @param self +-- @return int#int ret (return value: int) + +-------------------------------- +-- +-- @function [parent=#CameraBackgroundColorBrush] CameraBackgroundColorBrush +-- @param self +-- @return CameraBackgroundColorBrush#CameraBackgroundColorBrush self (return value: cc.CameraBackgroundColorBrush) + +return nil diff --git a/cocos/scripting/lua-bindings/auto/api/CameraBackgroundDepthBrush.lua b/cocos/scripting/lua-bindings/auto/api/CameraBackgroundDepthBrush.lua new file mode 100644 index 0000000000..a7b9f6ac8b --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/api/CameraBackgroundDepthBrush.lua @@ -0,0 +1,44 @@ + +-------------------------------- +-- @module CameraBackgroundDepthBrush +-- @extend CameraBackgroundBrush +-- @parent_module cc + +-------------------------------- +-- Set depth
+-- param depth Depth used to clear depth buffer +-- @function [parent=#CameraBackgroundDepthBrush] setDepth +-- @param self +-- @param #float depth +-- @return CameraBackgroundDepthBrush#CameraBackgroundDepthBrush self (return value: cc.CameraBackgroundDepthBrush) + +-------------------------------- +-- Create a depth brush
+-- param depth Depth used to clear the depth buffer
+-- return Created brush +-- @function [parent=#CameraBackgroundDepthBrush] create +-- @param self +-- @param #float depth +-- @return CameraBackgroundDepthBrush#CameraBackgroundDepthBrush ret (return value: cc.CameraBackgroundDepthBrush) + +-------------------------------- +-- Get brush type. Should be BrushType::DEPTH
+-- return brush type +-- @function [parent=#CameraBackgroundDepthBrush] getBrushType +-- @param self +-- @return int#int ret (return value: int) + +-------------------------------- +-- Draw background +-- @function [parent=#CameraBackgroundDepthBrush] drawBackground +-- @param self +-- @param #cc.Camera camera +-- @return CameraBackgroundDepthBrush#CameraBackgroundDepthBrush self (return value: cc.CameraBackgroundDepthBrush) + +-------------------------------- +-- +-- @function [parent=#CameraBackgroundDepthBrush] CameraBackgroundDepthBrush +-- @param self +-- @return CameraBackgroundDepthBrush#CameraBackgroundDepthBrush self (return value: cc.CameraBackgroundDepthBrush) + +return nil diff --git a/cocos/scripting/lua-bindings/auto/api/CameraBackgroundSkyBoxBrush.lua b/cocos/scripting/lua-bindings/auto/api/CameraBackgroundSkyBoxBrush.lua new file mode 100644 index 0000000000..dcd09f14fd --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/api/CameraBackgroundSkyBoxBrush.lua @@ -0,0 +1,60 @@ + +-------------------------------- +-- @module CameraBackgroundSkyBoxBrush +-- @extend CameraBackgroundBrush +-- @parent_module cc + +-------------------------------- +-- init Skybox. +-- @function [parent=#CameraBackgroundSkyBoxBrush] init +-- @param self +-- @return bool#bool ret (return value: bool) + +-------------------------------- +-- Set skybox texutre
+-- param texture Skybox texture +-- @function [parent=#CameraBackgroundSkyBoxBrush] setTexture +-- @param self +-- @param #cc.TextureCube texture +-- @return CameraBackgroundSkyBoxBrush#CameraBackgroundSkyBoxBrush self (return value: cc.CameraBackgroundSkyBoxBrush) + +-------------------------------- +-- +-- @function [parent=#CameraBackgroundSkyBoxBrush] initBuffer +-- @param self +-- @return CameraBackgroundSkyBoxBrush#CameraBackgroundSkyBoxBrush self (return value: cc.CameraBackgroundSkyBoxBrush) + +-------------------------------- +-- @overload self +-- @overload self, string, string, string, string, string, string +-- @function [parent=#CameraBackgroundSkyBoxBrush] create +-- @param self +-- @param #string positive_x +-- @param #string negative_x +-- @param #string positive_y +-- @param #string negative_y +-- @param #string positive_z +-- @param #string negative_z +-- @return CameraBackgroundSkyBoxBrush#CameraBackgroundSkyBoxBrush ret (return value: cc.CameraBackgroundSkyBoxBrush) + +-------------------------------- +-- Get brush type. Should be BrushType::SKYBOX
+-- return brush type +-- @function [parent=#CameraBackgroundSkyBoxBrush] getBrushType +-- @param self +-- @return int#int ret (return value: int) + +-------------------------------- +-- Draw background +-- @function [parent=#CameraBackgroundSkyBoxBrush] drawBackground +-- @param self +-- @param #cc.Camera camera +-- @return CameraBackgroundSkyBoxBrush#CameraBackgroundSkyBoxBrush self (return value: cc.CameraBackgroundSkyBoxBrush) + +-------------------------------- +-- +-- @function [parent=#CameraBackgroundSkyBoxBrush] CameraBackgroundSkyBoxBrush +-- @param self +-- @return CameraBackgroundSkyBoxBrush#CameraBackgroundSkyBoxBrush self (return value: cc.CameraBackgroundSkyBoxBrush) + +return nil diff --git a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua index 206c88945c..9682fe5436 100644 --- a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua +++ b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua @@ -1141,6 +1141,26 @@ -- @field [parent=#cc] Camera#Camera Camera preloaded module +-------------------------------------------------------- +-- the cc CameraBackgroundBrush +-- @field [parent=#cc] CameraBackgroundBrush#CameraBackgroundBrush CameraBackgroundBrush preloaded module + + +-------------------------------------------------------- +-- the cc CameraBackgroundDepthBrush +-- @field [parent=#cc] CameraBackgroundDepthBrush#CameraBackgroundDepthBrush CameraBackgroundDepthBrush preloaded module + + +-------------------------------------------------------- +-- the cc CameraBackgroundColorBrush +-- @field [parent=#cc] CameraBackgroundColorBrush#CameraBackgroundColorBrush CameraBackgroundColorBrush preloaded module + + +-------------------------------------------------------- +-- the cc CameraBackgroundSkyBoxBrush +-- @field [parent=#cc] CameraBackgroundSkyBoxBrush#CameraBackgroundSkyBoxBrush CameraBackgroundSkyBoxBrush preloaded module + + -------------------------------------------------------- -- the cc GridBase -- @field [parent=#cc] GridBase#GridBase GridBase preloaded module diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index 51e3aada00..7592c19a24 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -76445,6 +76445,56 @@ int lua_cocos2dx_Camera_applyViewport(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Camera_setBackgroundBrush(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Camera* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Camera",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Camera*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Camera_setBackgroundBrush'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::CameraBackgroundBrush* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.CameraBackgroundBrush",&arg0, "cc.Camera:setBackgroundBrush"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Camera_setBackgroundBrush'", nullptr); + return 0; + } + cobj->setBackgroundBrush(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Camera:setBackgroundBrush",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Camera_setBackgroundBrush'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Camera_lookAt(lua_State* tolua_S) { int argc = 0; @@ -76559,6 +76609,53 @@ int lua_cocos2dx_Camera_apply(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Camera_getBackgroundBrush(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Camera* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Camera",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Camera*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Camera_getBackgroundBrush'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Camera_getBackgroundBrush'", nullptr); + return 0; + } + cocos2d::CameraBackgroundBrush* ret = cobj->getBackgroundBrush(); + object_to_luaval(tolua_S, "cc.CameraBackgroundBrush",(cocos2d::CameraBackgroundBrush*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Camera:getBackgroundBrush",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Camera_getBackgroundBrush'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Camera_getProjectionMatrix(lua_State* tolua_S) { int argc = 0; @@ -76682,21 +76779,18 @@ int lua_cocos2dx_Camera_clearBackground(lua_State* tolua_S) #endif argc = lua_gettop(tolua_S)-1; - if (argc == 1) + if (argc == 0) { - double arg0; - - ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.Camera:clearBackground"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Camera_clearBackground'", nullptr); return 0; } - cobj->clearBackground(arg0); + cobj->clearBackground(); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Camera:clearBackground",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Camera:clearBackground",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 @@ -78008,8 +78102,10 @@ int lua_register_cocos2dx_Camera(lua_State* tolua_S) tolua_function(tolua_S,"getDepth",lua_cocos2dx_Camera_getDepth); tolua_function(tolua_S,"getViewProjectionMatrix",lua_cocos2dx_Camera_getViewProjectionMatrix); tolua_function(tolua_S,"applyViewport",lua_cocos2dx_Camera_applyViewport); + tolua_function(tolua_S,"setBackgroundBrush",lua_cocos2dx_Camera_setBackgroundBrush); tolua_function(tolua_S,"lookAt",lua_cocos2dx_Camera_lookAt); tolua_function(tolua_S,"apply",lua_cocos2dx_Camera_apply); + tolua_function(tolua_S,"getBackgroundBrush",lua_cocos2dx_Camera_getBackgroundBrush); tolua_function(tolua_S,"getProjectionMatrix",lua_cocos2dx_Camera_getProjectionMatrix); tolua_function(tolua_S,"getDepthInView",lua_cocos2dx_Camera_getDepthInView); tolua_function(tolua_S,"clearBackground",lua_cocos2dx_Camera_clearBackground); @@ -78047,6 +78143,888 @@ int lua_register_cocos2dx_Camera(lua_State* tolua_S) return 1; } +int lua_cocos2dx_CameraBackgroundBrush_getBrushType(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::CameraBackgroundBrush* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.CameraBackgroundBrush",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::CameraBackgroundBrush*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_CameraBackgroundBrush_getBrushType'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_CameraBackgroundBrush_getBrushType'", nullptr); + return 0; + } + int ret = (int)cobj->getBrushType(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.CameraBackgroundBrush:getBrushType",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CameraBackgroundBrush_getBrushType'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_CameraBackgroundBrush_drawBackground(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::CameraBackgroundBrush* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.CameraBackgroundBrush",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::CameraBackgroundBrush*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_CameraBackgroundBrush_drawBackground'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Camera* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.Camera",&arg0, "cc.CameraBackgroundBrush:drawBackground"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_CameraBackgroundBrush_drawBackground'", nullptr); + return 0; + } + cobj->drawBackground(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.CameraBackgroundBrush:drawBackground",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CameraBackgroundBrush_drawBackground'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_CameraBackgroundBrush_createSkyboxBrush(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.CameraBackgroundBrush",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 6) + { + std::string arg0; + std::string arg1; + std::string arg2; + std::string arg3; + std::string arg4; + std::string arg5; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.CameraBackgroundBrush:createSkyboxBrush"); + ok &= luaval_to_std_string(tolua_S, 3,&arg1, "cc.CameraBackgroundBrush:createSkyboxBrush"); + ok &= luaval_to_std_string(tolua_S, 4,&arg2, "cc.CameraBackgroundBrush:createSkyboxBrush"); + ok &= luaval_to_std_string(tolua_S, 5,&arg3, "cc.CameraBackgroundBrush:createSkyboxBrush"); + ok &= luaval_to_std_string(tolua_S, 6,&arg4, "cc.CameraBackgroundBrush:createSkyboxBrush"); + ok &= luaval_to_std_string(tolua_S, 7,&arg5, "cc.CameraBackgroundBrush:createSkyboxBrush"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_CameraBackgroundBrush_createSkyboxBrush'", nullptr); + return 0; + } + cocos2d::CameraBackgroundSkyBoxBrush* ret = cocos2d::CameraBackgroundBrush::createSkyboxBrush(arg0, arg1, arg2, arg3, arg4, arg5); + object_to_luaval(tolua_S, "cc.CameraBackgroundSkyBoxBrush",(cocos2d::CameraBackgroundSkyBoxBrush*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.CameraBackgroundBrush:createSkyboxBrush",argc, 6); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CameraBackgroundBrush_createSkyboxBrush'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_CameraBackgroundBrush_createColorBrush(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.CameraBackgroundBrush",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 2) + { + cocos2d::Color4F arg0; + double arg1; + ok &=luaval_to_color4f(tolua_S, 2, &arg0, "cc.CameraBackgroundBrush:createColorBrush"); + ok &= luaval_to_number(tolua_S, 3,&arg1, "cc.CameraBackgroundBrush:createColorBrush"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_CameraBackgroundBrush_createColorBrush'", nullptr); + return 0; + } + cocos2d::CameraBackgroundColorBrush* ret = cocos2d::CameraBackgroundBrush::createColorBrush(arg0, arg1); + object_to_luaval(tolua_S, "cc.CameraBackgroundColorBrush",(cocos2d::CameraBackgroundColorBrush*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.CameraBackgroundBrush:createColorBrush",argc, 2); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CameraBackgroundBrush_createColorBrush'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_CameraBackgroundBrush_createNoneBrush(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.CameraBackgroundBrush",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_CameraBackgroundBrush_createNoneBrush'", nullptr); + return 0; + } + cocos2d::CameraBackgroundBrush* ret = cocos2d::CameraBackgroundBrush::createNoneBrush(); + object_to_luaval(tolua_S, "cc.CameraBackgroundBrush",(cocos2d::CameraBackgroundBrush*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.CameraBackgroundBrush:createNoneBrush",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CameraBackgroundBrush_createNoneBrush'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_CameraBackgroundBrush_createDepthBrush(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.CameraBackgroundBrush",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_CameraBackgroundBrush_createDepthBrush'", nullptr); + return 0; + } + cocos2d::CameraBackgroundDepthBrush* ret = cocos2d::CameraBackgroundBrush::createDepthBrush(); + object_to_luaval(tolua_S, "cc.CameraBackgroundDepthBrush",(cocos2d::CameraBackgroundDepthBrush*)ret); + return 1; + } + if (argc == 1) + { + double arg0; + ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.CameraBackgroundBrush:createDepthBrush"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_CameraBackgroundBrush_createDepthBrush'", nullptr); + return 0; + } + cocos2d::CameraBackgroundDepthBrush* ret = cocos2d::CameraBackgroundBrush::createDepthBrush(arg0); + object_to_luaval(tolua_S, "cc.CameraBackgroundDepthBrush",(cocos2d::CameraBackgroundDepthBrush*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.CameraBackgroundBrush:createDepthBrush",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CameraBackgroundBrush_createDepthBrush'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_CameraBackgroundBrush_constructor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::CameraBackgroundBrush* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_CameraBackgroundBrush_constructor'", nullptr); + return 0; + } + cobj = new cocos2d::CameraBackgroundBrush(); + cobj->autorelease(); + int ID = (int)cobj->_ID ; + int* luaID = &cobj->_luaID ; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.CameraBackgroundBrush"); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.CameraBackgroundBrush:CameraBackgroundBrush",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CameraBackgroundBrush_constructor'.",&tolua_err); +#endif + + return 0; +} + +static int lua_cocos2dx_CameraBackgroundBrush_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (CameraBackgroundBrush)"); + return 0; +} + +int lua_register_cocos2dx_CameraBackgroundBrush(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.CameraBackgroundBrush"); + tolua_cclass(tolua_S,"CameraBackgroundBrush","cc.CameraBackgroundBrush","cc.Ref",nullptr); + + tolua_beginmodule(tolua_S,"CameraBackgroundBrush"); + tolua_function(tolua_S,"new",lua_cocos2dx_CameraBackgroundBrush_constructor); + tolua_function(tolua_S,"getBrushType",lua_cocos2dx_CameraBackgroundBrush_getBrushType); + tolua_function(tolua_S,"drawBackground",lua_cocos2dx_CameraBackgroundBrush_drawBackground); + tolua_function(tolua_S,"createSkyboxBrush", lua_cocos2dx_CameraBackgroundBrush_createSkyboxBrush); + tolua_function(tolua_S,"createColorBrush", lua_cocos2dx_CameraBackgroundBrush_createColorBrush); + tolua_function(tolua_S,"createNoneBrush", lua_cocos2dx_CameraBackgroundBrush_createNoneBrush); + tolua_function(tolua_S,"createDepthBrush", lua_cocos2dx_CameraBackgroundBrush_createDepthBrush); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::CameraBackgroundBrush).name(); + g_luaType[typeName] = "cc.CameraBackgroundBrush"; + g_typeCast["CameraBackgroundBrush"] = "cc.CameraBackgroundBrush"; + return 1; +} + +int lua_cocos2dx_CameraBackgroundDepthBrush_setDepth(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::CameraBackgroundDepthBrush* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.CameraBackgroundDepthBrush",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::CameraBackgroundDepthBrush*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_CameraBackgroundDepthBrush_setDepth'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + double arg0; + + ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.CameraBackgroundDepthBrush:setDepth"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_CameraBackgroundDepthBrush_setDepth'", nullptr); + return 0; + } + cobj->setDepth(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.CameraBackgroundDepthBrush:setDepth",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CameraBackgroundDepthBrush_setDepth'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_CameraBackgroundDepthBrush_create(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.CameraBackgroundDepthBrush",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { + double arg0; + ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.CameraBackgroundDepthBrush:create"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_CameraBackgroundDepthBrush_create'", nullptr); + return 0; + } + cocos2d::CameraBackgroundDepthBrush* ret = cocos2d::CameraBackgroundDepthBrush::create(arg0); + object_to_luaval(tolua_S, "cc.CameraBackgroundDepthBrush",(cocos2d::CameraBackgroundDepthBrush*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.CameraBackgroundDepthBrush:create",argc, 1); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CameraBackgroundDepthBrush_create'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_CameraBackgroundDepthBrush_constructor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::CameraBackgroundDepthBrush* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_CameraBackgroundDepthBrush_constructor'", nullptr); + return 0; + } + cobj = new cocos2d::CameraBackgroundDepthBrush(); + cobj->autorelease(); + int ID = (int)cobj->_ID ; + int* luaID = &cobj->_luaID ; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.CameraBackgroundDepthBrush"); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.CameraBackgroundDepthBrush:CameraBackgroundDepthBrush",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CameraBackgroundDepthBrush_constructor'.",&tolua_err); +#endif + + return 0; +} + +static int lua_cocos2dx_CameraBackgroundDepthBrush_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (CameraBackgroundDepthBrush)"); + return 0; +} + +int lua_register_cocos2dx_CameraBackgroundDepthBrush(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.CameraBackgroundDepthBrush"); + tolua_cclass(tolua_S,"CameraBackgroundDepthBrush","cc.CameraBackgroundDepthBrush","cc.CameraBackgroundBrush",nullptr); + + tolua_beginmodule(tolua_S,"CameraBackgroundDepthBrush"); + tolua_function(tolua_S,"new",lua_cocos2dx_CameraBackgroundDepthBrush_constructor); + tolua_function(tolua_S,"setDepth",lua_cocos2dx_CameraBackgroundDepthBrush_setDepth); + tolua_function(tolua_S,"create", lua_cocos2dx_CameraBackgroundDepthBrush_create); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::CameraBackgroundDepthBrush).name(); + g_luaType[typeName] = "cc.CameraBackgroundDepthBrush"; + g_typeCast["CameraBackgroundDepthBrush"] = "cc.CameraBackgroundDepthBrush"; + return 1; +} + +int lua_cocos2dx_CameraBackgroundColorBrush_setColor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::CameraBackgroundColorBrush* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.CameraBackgroundColorBrush",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::CameraBackgroundColorBrush*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_CameraBackgroundColorBrush_setColor'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Color4F arg0; + + ok &=luaval_to_color4f(tolua_S, 2, &arg0, "cc.CameraBackgroundColorBrush:setColor"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_CameraBackgroundColorBrush_setColor'", nullptr); + return 0; + } + cobj->setColor(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.CameraBackgroundColorBrush:setColor",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CameraBackgroundColorBrush_setColor'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_CameraBackgroundColorBrush_create(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.CameraBackgroundColorBrush",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 2) + { + cocos2d::Color4F arg0; + double arg1; + ok &=luaval_to_color4f(tolua_S, 2, &arg0, "cc.CameraBackgroundColorBrush:create"); + ok &= luaval_to_number(tolua_S, 3,&arg1, "cc.CameraBackgroundColorBrush:create"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_CameraBackgroundColorBrush_create'", nullptr); + return 0; + } + cocos2d::CameraBackgroundColorBrush* ret = cocos2d::CameraBackgroundColorBrush::create(arg0, arg1); + object_to_luaval(tolua_S, "cc.CameraBackgroundColorBrush",(cocos2d::CameraBackgroundColorBrush*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.CameraBackgroundColorBrush:create",argc, 2); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CameraBackgroundColorBrush_create'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_CameraBackgroundColorBrush_constructor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::CameraBackgroundColorBrush* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_CameraBackgroundColorBrush_constructor'", nullptr); + return 0; + } + cobj = new cocos2d::CameraBackgroundColorBrush(); + cobj->autorelease(); + int ID = (int)cobj->_ID ; + int* luaID = &cobj->_luaID ; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.CameraBackgroundColorBrush"); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.CameraBackgroundColorBrush:CameraBackgroundColorBrush",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CameraBackgroundColorBrush_constructor'.",&tolua_err); +#endif + + return 0; +} + +static int lua_cocos2dx_CameraBackgroundColorBrush_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (CameraBackgroundColorBrush)"); + return 0; +} + +int lua_register_cocos2dx_CameraBackgroundColorBrush(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.CameraBackgroundColorBrush"); + tolua_cclass(tolua_S,"CameraBackgroundColorBrush","cc.CameraBackgroundColorBrush","cc.CameraBackgroundDepthBrush",nullptr); + + tolua_beginmodule(tolua_S,"CameraBackgroundColorBrush"); + tolua_function(tolua_S,"new",lua_cocos2dx_CameraBackgroundColorBrush_constructor); + tolua_function(tolua_S,"setColor",lua_cocos2dx_CameraBackgroundColorBrush_setColor); + tolua_function(tolua_S,"create", lua_cocos2dx_CameraBackgroundColorBrush_create); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::CameraBackgroundColorBrush).name(); + g_luaType[typeName] = "cc.CameraBackgroundColorBrush"; + g_typeCast["CameraBackgroundColorBrush"] = "cc.CameraBackgroundColorBrush"; + return 1; +} + +int lua_cocos2dx_CameraBackgroundSkyBoxBrush_init(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::CameraBackgroundSkyBoxBrush* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.CameraBackgroundSkyBoxBrush",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::CameraBackgroundSkyBoxBrush*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_CameraBackgroundSkyBoxBrush_init'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_CameraBackgroundSkyBoxBrush_init'", nullptr); + return 0; + } + bool ret = cobj->init(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.CameraBackgroundSkyBoxBrush:init",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CameraBackgroundSkyBoxBrush_init'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_CameraBackgroundSkyBoxBrush_setTexture(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::CameraBackgroundSkyBoxBrush* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.CameraBackgroundSkyBoxBrush",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::CameraBackgroundSkyBoxBrush*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_CameraBackgroundSkyBoxBrush_setTexture'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::TextureCube* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.TextureCube",&arg0, "cc.CameraBackgroundSkyBoxBrush:setTexture"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_CameraBackgroundSkyBoxBrush_setTexture'", nullptr); + return 0; + } + cobj->setTexture(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.CameraBackgroundSkyBoxBrush:setTexture",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CameraBackgroundSkyBoxBrush_setTexture'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_CameraBackgroundSkyBoxBrush_initBuffer(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::CameraBackgroundSkyBoxBrush* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.CameraBackgroundSkyBoxBrush",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::CameraBackgroundSkyBoxBrush*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_CameraBackgroundSkyBoxBrush_initBuffer'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_CameraBackgroundSkyBoxBrush_initBuffer'", nullptr); + return 0; + } + cobj->initBuffer(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.CameraBackgroundSkyBoxBrush:initBuffer",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CameraBackgroundSkyBoxBrush_initBuffer'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_CameraBackgroundSkyBoxBrush_create(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.CameraBackgroundSkyBoxBrush",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S)-1; + + do + { + if (argc == 0) + { + cocos2d::CameraBackgroundSkyBoxBrush* ret = cocos2d::CameraBackgroundSkyBoxBrush::create(); + object_to_luaval(tolua_S, "cc.CameraBackgroundSkyBoxBrush",(cocos2d::CameraBackgroundSkyBoxBrush*)ret); + return 1; + } + } while (0); + ok = true; + do + { + if (argc == 6) + { + std::string arg0; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.CameraBackgroundSkyBoxBrush:create"); + if (!ok) { break; } + std::string arg1; + ok &= luaval_to_std_string(tolua_S, 3,&arg1, "cc.CameraBackgroundSkyBoxBrush:create"); + if (!ok) { break; } + std::string arg2; + ok &= luaval_to_std_string(tolua_S, 4,&arg2, "cc.CameraBackgroundSkyBoxBrush:create"); + if (!ok) { break; } + std::string arg3; + ok &= luaval_to_std_string(tolua_S, 5,&arg3, "cc.CameraBackgroundSkyBoxBrush:create"); + if (!ok) { break; } + std::string arg4; + ok &= luaval_to_std_string(tolua_S, 6,&arg4, "cc.CameraBackgroundSkyBoxBrush:create"); + if (!ok) { break; } + std::string arg5; + ok &= luaval_to_std_string(tolua_S, 7,&arg5, "cc.CameraBackgroundSkyBoxBrush:create"); + if (!ok) { break; } + cocos2d::CameraBackgroundSkyBoxBrush* ret = cocos2d::CameraBackgroundSkyBoxBrush::create(arg0, arg1, arg2, arg3, arg4, arg5); + object_to_luaval(tolua_S, "cc.CameraBackgroundSkyBoxBrush",(cocos2d::CameraBackgroundSkyBoxBrush*)ret); + return 1; + } + } while (0); + ok = true; + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.CameraBackgroundSkyBoxBrush:create",argc, 6); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CameraBackgroundSkyBoxBrush_create'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_CameraBackgroundSkyBoxBrush_constructor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::CameraBackgroundSkyBoxBrush* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_CameraBackgroundSkyBoxBrush_constructor'", nullptr); + return 0; + } + cobj = new cocos2d::CameraBackgroundSkyBoxBrush(); + cobj->autorelease(); + int ID = (int)cobj->_ID ; + int* luaID = &cobj->_luaID ; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.CameraBackgroundSkyBoxBrush"); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.CameraBackgroundSkyBoxBrush:CameraBackgroundSkyBoxBrush",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CameraBackgroundSkyBoxBrush_constructor'.",&tolua_err); +#endif + + return 0; +} + +static int lua_cocos2dx_CameraBackgroundSkyBoxBrush_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (CameraBackgroundSkyBoxBrush)"); + return 0; +} + +int lua_register_cocos2dx_CameraBackgroundSkyBoxBrush(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.CameraBackgroundSkyBoxBrush"); + tolua_cclass(tolua_S,"CameraBackgroundSkyBoxBrush","cc.CameraBackgroundSkyBoxBrush","cc.CameraBackgroundBrush",nullptr); + + tolua_beginmodule(tolua_S,"CameraBackgroundSkyBoxBrush"); + tolua_function(tolua_S,"new",lua_cocos2dx_CameraBackgroundSkyBoxBrush_constructor); + tolua_function(tolua_S,"init",lua_cocos2dx_CameraBackgroundSkyBoxBrush_init); + tolua_function(tolua_S,"setTexture",lua_cocos2dx_CameraBackgroundSkyBoxBrush_setTexture); + tolua_function(tolua_S,"initBuffer",lua_cocos2dx_CameraBackgroundSkyBoxBrush_initBuffer); + tolua_function(tolua_S,"create", lua_cocos2dx_CameraBackgroundSkyBoxBrush_create); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::CameraBackgroundSkyBoxBrush).name(); + g_luaType[typeName] = "cc.CameraBackgroundSkyBoxBrush"; + g_typeCast["CameraBackgroundSkyBoxBrush"] = "cc.CameraBackgroundSkyBoxBrush"; + return 1; +} + int lua_cocos2dx_GridBase_setGridSize(lua_State* tolua_S) { int argc = 0; @@ -93544,6 +94522,9 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) lua_register_cocos2dx_Texture2D(tolua_S); lua_register_cocos2dx_TransitionSceneOriented(tolua_S); lua_register_cocos2dx_TransitionFlipX(tolua_S); + lua_register_cocos2dx_CameraBackgroundBrush(tolua_S); + lua_register_cocos2dx_CameraBackgroundDepthBrush(tolua_S); + lua_register_cocos2dx_CameraBackgroundColorBrush(tolua_S); lua_register_cocos2dx_GridAction(tolua_S); lua_register_cocos2dx_TiledGrid3DAction(tolua_S); lua_register_cocos2dx_FadeOutTRTiles(tolua_S); @@ -93705,6 +94686,7 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) lua_register_cocos2dx_Follow(tolua_S); lua_register_cocos2dx_Animate(tolua_S); lua_register_cocos2dx_ShuffleTiles(tolua_S); + lua_register_cocos2dx_CameraBackgroundSkyBoxBrush(tolua_S); lua_register_cocos2dx_ProgressTimer(tolua_S); lua_register_cocos2dx_EaseQuarticActionIn(tolua_S); lua_register_cocos2dx_Menu(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index c041d781c9..626bf16a60 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -2063,6 +2063,30 @@ int register_all_cocos2dx(lua_State* tolua_S); + + + + + + + + + + + + + + + + + + + + + + + + From 7bb25d8c66dbe97c62d419ee15ed6829d8610387 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Fri, 21 Aug 2015 04:24:34 +0000 Subject: [PATCH 043/118] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 122e036069..b7fccdd639 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -6456,6 +6456,10 @@ "cocos/scripting/lua-bindings/auto/api/CSLoader.lua", "cocos/scripting/lua-bindings/auto/api/CallFunc.lua", "cocos/scripting/lua-bindings/auto/api/Camera.lua", + "cocos/scripting/lua-bindings/auto/api/CameraBackgroundBrush.lua", + "cocos/scripting/lua-bindings/auto/api/CameraBackgroundColorBrush.lua", + "cocos/scripting/lua-bindings/auto/api/CameraBackgroundDepthBrush.lua", + "cocos/scripting/lua-bindings/auto/api/CameraBackgroundSkyBoxBrush.lua", "cocos/scripting/lua-bindings/auto/api/CardinalSplineBy.lua", "cocos/scripting/lua-bindings/auto/api/CardinalSplineTo.lua", "cocos/scripting/lua-bindings/auto/api/CatmullRomBy.lua", From 006f300ac9f1f3cf1b71e7262ea3d481a54f132f Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 21 Aug 2015 12:18:36 +0800 Subject: [PATCH 044/118] Add JS and Lua bindings for CCCameraBackgroundBrush --- cocos/2d/CCCameraBackgroundBrush.cpp | 7 +++- cocos/2d/CCCameraBackgroundBrush.h | 12 ++++--- .../js-bindings/script/3d/jsb_cocos2d_3d.js | 34 +++++++++++++++++++ .../script/cocos2d/Cocos2dConstants.lua | 8 +++++ 4 files changed, 55 insertions(+), 6 deletions(-) diff --git a/cocos/2d/CCCameraBackgroundBrush.cpp b/cocos/2d/CCCameraBackgroundBrush.cpp index 2369719100..17d21ad2e1 100644 --- a/cocos/2d/CCCameraBackgroundBrush.cpp +++ b/cocos/2d/CCCameraBackgroundBrush.cpp @@ -203,6 +203,12 @@ CameraBackgroundColorBrush::~CameraBackgroundColorBrush() } +bool CameraBackgroundColorBrush::init() +{ + this->_clearColor = GL_TRUE; + return true; +} + void CameraBackgroundColorBrush::setColor(const Color4F& color) { _quad.bl.colors = _quad.br.colors = _quad.tl.colors = _quad.tr.colors = Color4B(color); @@ -212,7 +218,6 @@ CameraBackgroundColorBrush* CameraBackgroundColorBrush::create(const Color4F& co { auto ret = new (std::nothrow) CameraBackgroundColorBrush(); ret->init(); - ret->_clearColor = GL_TRUE; ret->setColor(color); ret->setDepth(depth); diff --git a/cocos/2d/CCCameraBackgroundBrush.h b/cocos/2d/CCCameraBackgroundBrush.h index 687b2c3e86..74a461c03f 100644 --- a/cocos/2d/CCCameraBackgroundBrush.h +++ b/cocos/2d/CCCameraBackgroundBrush.h @@ -107,10 +107,10 @@ public: CC_CONSTRUCTOR_ACCESS: CameraBackgroundBrush(); virtual ~CameraBackgroundBrush(); - -protected: + virtual bool init() { return true; } +protected: GLProgramState* _glProgramState; }; @@ -147,10 +147,10 @@ public: CC_CONSTRUCTOR_ACCESS: CameraBackgroundDepthBrush(); virtual ~CameraBackgroundDepthBrush(); - -protected: + virtual bool init() override; +protected: float _depth; GLboolean _clearColor; @@ -187,9 +187,10 @@ public: CC_CONSTRUCTOR_ACCESS: CameraBackgroundColorBrush(); virtual ~CameraBackgroundColorBrush(); + + virtual bool init() override; protected: - Color4F _color; }; @@ -245,6 +246,7 @@ CC_CONSTRUCTOR_ACCESS: */ virtual bool init() override; +protected: void initBuffer(); GLuint _vao; diff --git a/cocos/scripting/js-bindings/script/3d/jsb_cocos2d_3d.js b/cocos/scripting/js-bindings/script/3d/jsb_cocos2d_3d.js index e2dde1c87b..dbbd139498 100644 --- a/cocos/scripting/js-bindings/script/3d/jsb_cocos2d_3d.js +++ b/cocos/scripting/js-bindings/script/3d/jsb_cocos2d_3d.js @@ -39,6 +39,13 @@ cc.Camera.Mode = { PERSPECTIVE : 1, ORTHOGRAPHIC : 2 }; +cc.CameraBackgroundBrush.BrushType = { + NONE : 0, + DEPTH : 1, + COLOR : 2, + SKYBOX : 3 +}; + cc.LightType = { DIRECTIONAL : 0, POINT : 1, @@ -464,6 +471,33 @@ cc.Camera.prototype._ctor = function(cameraMode, first, second, third, fourth){ } } +cc.CameraBackgroundBrush.prototype._ctor = function () { + this.init(); +} +cc.CameraBackgroundDepthBrush.prototype._ctor = function (depth) { + if (depth !== undefined) + this.setDepth(depth); + this.init(); +} +cc.CameraBackgroundColorBrush.prototype._ctor = function (color, depth) { + this.init(); + if (depth !== undefined) { + this.setColor(color); + this.setDepth(depth); + } +} +cc.CameraBackgroundSkyBoxBrush.prototype._ctor = function (positive_x, negative_x, positive_y, negative_y, positive_z, negative_z) +{ + if (negative_z !== undefined) { + var texture = jsb.TextureCube.create(positive_x, negative_x, positive_y, negative_y, positive_z, negative_z); + if (texture) { + texture.setTexParameters(gl.LINEAR, gl.LINEAR, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE); + this.setTexture(texture); + } + } + this.init(); +} + /** * static Physics3DShape* createBox(const cocos2d::Vec3& extent); * static Physics3DShape* createSphere(float radius); diff --git a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua index bc79cf3f05..dd56ba3e34 100644 --- a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua +++ b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua @@ -550,6 +550,14 @@ cc.CameraFlag = USER8 = 256, } +cc.CameraBackgroundBrush.BrushType = +{ + NONE = 0, + DEPTH = 1, + COLOR = 2, + SKYBOX = 3, +} + cc.BillBoard_Mode = { VIEW_POINT_ORIENTED = 0, From 6b6c6b242ce53652c9a1f697f6bae4e0f7a13d7d Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Fri, 21 Aug 2015 06:44:25 +0000 Subject: [PATCH 045/118] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/jsb_cocos2dx_auto_api.js | 28 ++-- .../js-bindings/auto/jsb_cocos2dx_auto.cpp | 55 +++---- .../js-bindings/auto/jsb_cocos2dx_auto.hpp | 3 +- .../auto/api/CameraBackgroundBrush.lua | 6 + .../auto/api/CameraBackgroundColorBrush.lua | 6 + .../auto/api/CameraBackgroundDepthBrush.lua | 6 + .../auto/api/CameraBackgroundSkyBoxBrush.lua | 18 +-- .../lua-bindings/auto/lua_cocos2dx_auto.cpp | 144 ++++++------------ .../lua-bindings/auto/lua_cocos2dx_auto.hpp | 1 - 9 files changed, 102 insertions(+), 165 deletions(-) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js index a81d2350dd..7969665b23 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js @@ -18779,6 +18779,16 @@ camera { }, +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + /** * @method createSkyboxBrush * @param {String} arg0 @@ -18929,16 +18939,6 @@ CameraBackgroundColorBrush : function ( */ cc.CameraBackgroundSkyBoxBrush = { -/** - * @method init - * @return {bool} - */ -init : function ( -) -{ - return false; -}, - /** * @method setTexture * @param {cc.TextureCube} arg0 @@ -18949,14 +18949,6 @@ texturecube { }, -/** - * @method initBuffer - */ -initBuffer : function ( -) -{ -}, - /** * @method create * @param {String} str diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp index bc350b96d4..5d9cd334d6 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp @@ -57613,6 +57613,24 @@ bool js_cocos2dx_CameraBackgroundBrush_drawBackground(JSContext *cx, uint32_t ar JS_ReportError(cx, "js_cocos2dx_CameraBackgroundBrush_drawBackground : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_CameraBackgroundBrush_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::CameraBackgroundBrush* cobj = (cocos2d::CameraBackgroundBrush *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CameraBackgroundBrush_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_CameraBackgroundBrush_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_CameraBackgroundBrush_createSkyboxBrush(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -57788,6 +57806,7 @@ void js_register_cocos2dx_CameraBackgroundBrush(JSContext *cx, JS::HandleObject static JSFunctionSpec funcs[] = { JS_FN("getBrushType", js_cocos2dx_CameraBackgroundBrush_getBrushType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("drawBackground", js_cocos2dx_CameraBackgroundBrush_drawBackground, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_CameraBackgroundBrush_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -58108,24 +58127,6 @@ void js_register_cocos2dx_CameraBackgroundColorBrush(JSContext *cx, JS::HandleOb JSClass *jsb_cocos2d_CameraBackgroundSkyBoxBrush_class; JSObject *jsb_cocos2d_CameraBackgroundSkyBoxBrush_prototype; -bool js_cocos2dx_CameraBackgroundSkyBoxBrush_init(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::CameraBackgroundSkyBoxBrush* cobj = (cocos2d::CameraBackgroundSkyBoxBrush *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CameraBackgroundSkyBoxBrush_init : Invalid Native Object"); - if (argc == 0) { - bool ret = cobj->init(); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_CameraBackgroundSkyBoxBrush_init : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} bool js_cocos2dx_CameraBackgroundSkyBoxBrush_setTexture(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -58154,22 +58155,6 @@ bool js_cocos2dx_CameraBackgroundSkyBoxBrush_setTexture(JSContext *cx, uint32_t JS_ReportError(cx, "js_cocos2dx_CameraBackgroundSkyBoxBrush_setTexture : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_CameraBackgroundSkyBoxBrush_initBuffer(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::CameraBackgroundSkyBoxBrush* cobj = (cocos2d::CameraBackgroundSkyBoxBrush *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CameraBackgroundSkyBoxBrush_initBuffer : Invalid Native Object"); - if (argc == 0) { - cobj->initBuffer(); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_CameraBackgroundSkyBoxBrush_initBuffer : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} bool js_cocos2dx_CameraBackgroundSkyBoxBrush_create(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -58282,9 +58267,7 @@ void js_register_cocos2dx_CameraBackgroundSkyBoxBrush(JSContext *cx, JS::HandleO }; static JSFunctionSpec funcs[] = { - JS_FN("init", js_cocos2dx_CameraBackgroundSkyBoxBrush_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTexture", js_cocos2dx_CameraBackgroundSkyBoxBrush_setTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("initBuffer", js_cocos2dx_CameraBackgroundSkyBoxBrush_initBuffer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp index 38fdc905cc..35eb6bfb37 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp @@ -3386,6 +3386,7 @@ void js_register_cocos2dx_CameraBackgroundBrush(JSContext *cx, JS::HandleObject void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); bool js_cocos2dx_CameraBackgroundBrush_getBrushType(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_CameraBackgroundBrush_drawBackground(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_CameraBackgroundBrush_init(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_CameraBackgroundBrush_createSkyboxBrush(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_CameraBackgroundBrush_createColorBrush(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_CameraBackgroundBrush_createNoneBrush(JSContext *cx, uint32_t argc, jsval *vp); @@ -3421,9 +3422,7 @@ bool js_cocos2dx_CameraBackgroundSkyBoxBrush_constructor(JSContext *cx, uint32_t void js_cocos2dx_CameraBackgroundSkyBoxBrush_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_CameraBackgroundSkyBoxBrush(JSContext *cx, JS::HandleObject global); void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); -bool js_cocos2dx_CameraBackgroundSkyBoxBrush_init(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_CameraBackgroundSkyBoxBrush_setTexture(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_CameraBackgroundSkyBoxBrush_initBuffer(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_CameraBackgroundSkyBoxBrush_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_CameraBackgroundSkyBoxBrush_CameraBackgroundSkyBoxBrush(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/cocos/scripting/lua-bindings/auto/api/CameraBackgroundBrush.lua b/cocos/scripting/lua-bindings/auto/api/CameraBackgroundBrush.lua index 65ff9c104f..bce2bc8585 100644 --- a/cocos/scripting/lua-bindings/auto/api/CameraBackgroundBrush.lua +++ b/cocos/scripting/lua-bindings/auto/api/CameraBackgroundBrush.lua @@ -18,6 +18,12 @@ -- @param #cc.Camera camera -- @return CameraBackgroundBrush#CameraBackgroundBrush self (return value: cc.CameraBackgroundBrush) +-------------------------------- +-- +-- @function [parent=#CameraBackgroundBrush] init +-- @param self +-- @return bool#bool ret (return value: bool) + -------------------------------- -- Creates a Skybox brush with 6 textures.
-- param positive_x texture for the right side of the texture cube face.
diff --git a/cocos/scripting/lua-bindings/auto/api/CameraBackgroundColorBrush.lua b/cocos/scripting/lua-bindings/auto/api/CameraBackgroundColorBrush.lua index c7a4414f0c..b5a2f57be6 100644 --- a/cocos/scripting/lua-bindings/auto/api/CameraBackgroundColorBrush.lua +++ b/cocos/scripting/lua-bindings/auto/api/CameraBackgroundColorBrush.lua @@ -30,6 +30,12 @@ -- @param self -- @return int#int ret (return value: int) +-------------------------------- +-- +-- @function [parent=#CameraBackgroundColorBrush] init +-- @param self +-- @return bool#bool ret (return value: bool) + -------------------------------- -- -- @function [parent=#CameraBackgroundColorBrush] CameraBackgroundColorBrush diff --git a/cocos/scripting/lua-bindings/auto/api/CameraBackgroundDepthBrush.lua b/cocos/scripting/lua-bindings/auto/api/CameraBackgroundDepthBrush.lua index a7b9f6ac8b..af177c3918 100644 --- a/cocos/scripting/lua-bindings/auto/api/CameraBackgroundDepthBrush.lua +++ b/cocos/scripting/lua-bindings/auto/api/CameraBackgroundDepthBrush.lua @@ -35,6 +35,12 @@ -- @param #cc.Camera camera -- @return CameraBackgroundDepthBrush#CameraBackgroundDepthBrush self (return value: cc.CameraBackgroundDepthBrush) +-------------------------------- +-- +-- @function [parent=#CameraBackgroundDepthBrush] init +-- @param self +-- @return bool#bool ret (return value: bool) + -------------------------------- -- -- @function [parent=#CameraBackgroundDepthBrush] CameraBackgroundDepthBrush diff --git a/cocos/scripting/lua-bindings/auto/api/CameraBackgroundSkyBoxBrush.lua b/cocos/scripting/lua-bindings/auto/api/CameraBackgroundSkyBoxBrush.lua index dcd09f14fd..96062d7151 100644 --- a/cocos/scripting/lua-bindings/auto/api/CameraBackgroundSkyBoxBrush.lua +++ b/cocos/scripting/lua-bindings/auto/api/CameraBackgroundSkyBoxBrush.lua @@ -4,12 +4,6 @@ -- @extend CameraBackgroundBrush -- @parent_module cc --------------------------------- --- init Skybox. --- @function [parent=#CameraBackgroundSkyBoxBrush] init --- @param self --- @return bool#bool ret (return value: bool) - -------------------------------- -- Set skybox texutre
-- param texture Skybox texture @@ -18,12 +12,6 @@ -- @param #cc.TextureCube texture -- @return CameraBackgroundSkyBoxBrush#CameraBackgroundSkyBoxBrush self (return value: cc.CameraBackgroundSkyBoxBrush) --------------------------------- --- --- @function [parent=#CameraBackgroundSkyBoxBrush] initBuffer --- @param self --- @return CameraBackgroundSkyBoxBrush#CameraBackgroundSkyBoxBrush self (return value: cc.CameraBackgroundSkyBoxBrush) - -------------------------------- -- @overload self -- @overload self, string, string, string, string, string, string @@ -51,6 +39,12 @@ -- @param #cc.Camera camera -- @return CameraBackgroundSkyBoxBrush#CameraBackgroundSkyBoxBrush self (return value: cc.CameraBackgroundSkyBoxBrush) +-------------------------------- +-- init Skybox. +-- @function [parent=#CameraBackgroundSkyBoxBrush] init +-- @param self +-- @return bool#bool ret (return value: bool) + -------------------------------- -- -- @function [parent=#CameraBackgroundSkyBoxBrush] CameraBackgroundSkyBoxBrush diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index 7592c19a24..3e14809075 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -78240,6 +78240,53 @@ int lua_cocos2dx_CameraBackgroundBrush_drawBackground(lua_State* tolua_S) return 0; } +int lua_cocos2dx_CameraBackgroundBrush_init(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::CameraBackgroundBrush* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.CameraBackgroundBrush",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::CameraBackgroundBrush*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_CameraBackgroundBrush_init'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_CameraBackgroundBrush_init'", nullptr); + return 0; + } + bool ret = cobj->init(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.CameraBackgroundBrush:init",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CameraBackgroundBrush_init'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_CameraBackgroundBrush_createSkyboxBrush(lua_State* tolua_S) { int argc = 0; @@ -78457,6 +78504,7 @@ int lua_register_cocos2dx_CameraBackgroundBrush(lua_State* tolua_S) tolua_function(tolua_S,"new",lua_cocos2dx_CameraBackgroundBrush_constructor); tolua_function(tolua_S,"getBrushType",lua_cocos2dx_CameraBackgroundBrush_getBrushType); tolua_function(tolua_S,"drawBackground",lua_cocos2dx_CameraBackgroundBrush_drawBackground); + tolua_function(tolua_S,"init",lua_cocos2dx_CameraBackgroundBrush_init); tolua_function(tolua_S,"createSkyboxBrush", lua_cocos2dx_CameraBackgroundBrush_createSkyboxBrush); tolua_function(tolua_S,"createColorBrush", lua_cocos2dx_CameraBackgroundBrush_createColorBrush); tolua_function(tolua_S,"createNoneBrush", lua_cocos2dx_CameraBackgroundBrush_createNoneBrush); @@ -78760,53 +78808,6 @@ int lua_register_cocos2dx_CameraBackgroundColorBrush(lua_State* tolua_S) return 1; } -int lua_cocos2dx_CameraBackgroundSkyBoxBrush_init(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::CameraBackgroundSkyBoxBrush* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.CameraBackgroundSkyBoxBrush",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::CameraBackgroundSkyBoxBrush*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_CameraBackgroundSkyBoxBrush_init'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_CameraBackgroundSkyBoxBrush_init'", nullptr); - return 0; - } - bool ret = cobj->init(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.CameraBackgroundSkyBoxBrush:init",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CameraBackgroundSkyBoxBrush_init'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_CameraBackgroundSkyBoxBrush_setTexture(lua_State* tolua_S) { int argc = 0; @@ -78857,53 +78858,6 @@ int lua_cocos2dx_CameraBackgroundSkyBoxBrush_setTexture(lua_State* tolua_S) return 0; } -int lua_cocos2dx_CameraBackgroundSkyBoxBrush_initBuffer(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::CameraBackgroundSkyBoxBrush* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.CameraBackgroundSkyBoxBrush",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::CameraBackgroundSkyBoxBrush*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_CameraBackgroundSkyBoxBrush_initBuffer'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_CameraBackgroundSkyBoxBrush_initBuffer'", nullptr); - return 0; - } - cobj->initBuffer(); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.CameraBackgroundSkyBoxBrush:initBuffer",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CameraBackgroundSkyBoxBrush_initBuffer'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_CameraBackgroundSkyBoxBrush_create(lua_State* tolua_S) { int argc = 0; @@ -79014,9 +78968,7 @@ int lua_register_cocos2dx_CameraBackgroundSkyBoxBrush(lua_State* tolua_S) tolua_beginmodule(tolua_S,"CameraBackgroundSkyBoxBrush"); tolua_function(tolua_S,"new",lua_cocos2dx_CameraBackgroundSkyBoxBrush_constructor); - tolua_function(tolua_S,"init",lua_cocos2dx_CameraBackgroundSkyBoxBrush_init); tolua_function(tolua_S,"setTexture",lua_cocos2dx_CameraBackgroundSkyBoxBrush_setTexture); - tolua_function(tolua_S,"initBuffer",lua_cocos2dx_CameraBackgroundSkyBoxBrush_initBuffer); tolua_function(tolua_S,"create", lua_cocos2dx_CameraBackgroundSkyBoxBrush_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::CameraBackgroundSkyBoxBrush).name(); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index 626bf16a60..4bfbed20a5 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -2105,7 +2105,6 @@ int register_all_cocos2dx(lua_State* tolua_S); - #endif // __cocos2dx_h__ From aab9e92394323c29a02a8184edf1b71d8e8fd2d0 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 21 Aug 2015 15:50:09 +0800 Subject: [PATCH 046/118] Update web engine --- web | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web b/web index 5d123ed296..6902509a62 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit 5d123ed2969f4f31380480d0c649fd6c0ff7a102 +Subproject commit 6902509a62efa5ec85a36cf83aca95f91b6519b4 From cbd7eed9c4fa5ff8176ca9520cd72ab2af723189 Mon Sep 17 00:00:00 2001 From: fusijie Date: Fri, 21 Aug 2015 17:38:56 +0800 Subject: [PATCH 047/118] fixed renderTexture crash bug. --- cocos/2d/CCScene.cpp | 2 ++ cocos/renderer/CCRenderer.cpp | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cocos/2d/CCScene.cpp b/cocos/2d/CCScene.cpp index bd1a8ddab6..ce1c053715 100644 --- a/cocos/2d/CCScene.cpp +++ b/cocos/2d/CCScene.cpp @@ -73,6 +73,8 @@ Scene::Scene() _event = Director::getInstance()->getEventDispatcher()->addCustomEventListener(Director::EVENT_PROJECTION_CHANGED, std::bind(&Scene::onProjectionChanged, this, std::placeholders::_1)); _event->retain(); + + Camera::_visitingCamera = nullptr; } Scene::~Scene() diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index 86ab1045b8..1aef8015e5 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -1028,8 +1028,10 @@ void Renderer::flushTriangles() bool Renderer::checkVisibility(const Mat4 &transform, const Size &size) { auto scene = Director::getInstance()->getRunningScene(); + + //If draw to Rendertexture, return true directly. // only cull the default camera. The culling algorithm is valid for default camera. - if (scene && scene->_defaultCamera != Camera::getVisitingCamera()) + if (!scene || (scene && scene->_defaultCamera != Camera::getVisitingCamera())) return true; auto director = Director::getInstance(); From b4f2fb09288685cb5f97c779923e9246f3c7e829 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Fri, 21 Aug 2015 09:23:01 -0700 Subject: [PATCH 048/118] added missing CCCameraBackgroundBrush files --- cocos/2d/libcocos2d_win10/libcocos2d.vcxproj | 2 ++ cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj index 5f0d9efca4..ab039d32fd 100644 --- a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj @@ -674,6 +674,7 @@ + @@ -1220,6 +1221,7 @@ + diff --git a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters index 24d7ff4ff8..673a6eb1c0 100644 --- a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters @@ -1939,6 +1939,9 @@ cocostudio\reader\WidgetReader\GameNodeDReader + + 2d + @@ -3788,6 +3791,9 @@ cocostudio\reader\WidgetReader\GameNodeDReader + + 2d + From fc1a2b2f997d80c9ef8199dcdb322ab11234cd88 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Fri, 21 Aug 2015 09:59:46 -0700 Subject: [PATCH 049/118] fixed for winrt audio issue 13254 --- cocos/audio/winrt/Audio.cpp | 17 +++++++++++++++-- cocos/audio/winrt/Audio.h | 8 +++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/cocos/audio/winrt/Audio.cpp b/cocos/audio/winrt/Audio.cpp index 061a91d0e6..bcf74e31aa 100644 --- a/cocos/audio/winrt/Audio.cpp +++ b/cocos/audio/winrt/Audio.cpp @@ -242,7 +242,7 @@ void Audio::RewindBackgroundMusic() bool Audio::IsBackgroundMusicPlaying() { - return IsSoundEffectStarted(m_backgroundID); + return IsSoundEffectStarted(m_backgroundID) && !IsSoundEffectPaused(m_backgroundID); } void Audio::SetBackgroundVolume(float volume) @@ -331,7 +331,8 @@ void Audio::PlaySoundEffect(unsigned int sound) return; } - m_soundEffects[sound].m_soundEffectStarted = true; + m_soundEffects[sound].m_soundEffectStarted = true; + m_soundEffects[sound].m_soundEffectPaused = false; } void Audio::StopSoundEffect(unsigned int sound) @@ -353,6 +354,7 @@ void Audio::StopSoundEffect(unsigned int sound) } m_soundEffects[sound].m_soundEffectStarted = false; + m_soundEffects[sound].m_soundEffectPaused = false; } void Audio::PauseSoundEffect(unsigned int sound) @@ -371,6 +373,7 @@ void Audio::PauseSoundEffect(unsigned int sound) m_engineExperiencedCriticalError = true; return; } + m_soundEffects[sound].m_soundEffectPaused = true; } void Audio::ResumeSoundEffect(unsigned int sound) @@ -389,6 +392,7 @@ void Audio::ResumeSoundEffect(unsigned int sound) m_engineExperiencedCriticalError = true; return; } + m_soundEffects[sound].m_soundEffectPaused = false; } void Audio::RewindSoundEffect(unsigned int sound) @@ -472,6 +476,14 @@ bool Audio::IsSoundEffectStarted(unsigned int sound) return m_soundEffects[sound].m_soundEffectStarted; } +bool Audio::IsSoundEffectPaused(unsigned int sound) +{ + if (m_soundEffects.end() == m_soundEffects.find(sound)) + return false; + + return m_soundEffects[sound].m_soundEffectPaused; +} + std::wstring CCUtf8ToUnicode(const char * pszUtf8Str) { std::wstring ret; @@ -628,6 +640,7 @@ void Audio::UnloadSoundEffect(unsigned int sound) m_soundEffects[sound].m_soundEffectBufferData = nullptr; m_soundEffects[sound].m_soundEffectSourceVoice = nullptr; m_soundEffects[sound].m_soundEffectStarted = false; + m_soundEffects[sound].m_soundEffectPaused = false; ZeroMemory(&m_soundEffects[sound].m_audioBuffer, sizeof(m_soundEffects[sound].m_audioBuffer)); } diff --git a/cocos/audio/winrt/Audio.h b/cocos/audio/winrt/Audio.h index a00b9a2ef7..42f3a3a37d 100644 --- a/cocos/audio/winrt/Audio.h +++ b/cocos/audio/winrt/Audio.h @@ -32,7 +32,8 @@ struct SoundEffectData byte* m_soundEffectBufferData; uint32 m_soundEffectBufferLength; uint32 m_soundEffectSampleRate; - bool m_soundEffectStarted; + bool m_soundEffectStarted; + bool m_soundEffectPaused; }; class Audio; @@ -148,8 +149,9 @@ public: void PlaySoundEffect(const char* pszFilePath, bool bLoop, unsigned int& sound, bool isMusic = false); void PlaySoundEffect(unsigned int sound); - bool IsSoundEffectStarted(unsigned int sound); - void StopSoundEffect(unsigned int sound); + bool IsSoundEffectStarted(unsigned int sound); + bool IsSoundEffectPaused(unsigned int sound); + void StopSoundEffect(unsigned int sound); void PauseSoundEffect(unsigned int sound); void ResumeSoundEffect(unsigned int sound); void RewindSoundEffect(unsigned int sound); From cfd2f08d82b2e67ae1c6e6ff2727d1976fd302e3 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Fri, 21 Aug 2015 13:14:01 -0700 Subject: [PATCH 050/118] added running tests section for Windows 10 UWP apps --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index d5d0021dc6..a9881ea68e 100644 --- a/README.md +++ b/README.md @@ -245,6 +245,10 @@ Open the `cocos2d-x/build/cocos2d-win32.sln` Open the `cocos2d-x/build/cocos2d-win8.1-universal.sln` +* For Windows 10.0 Universal Windows Platform (UWP) Apps (Phone and Store) + +Open the `cocos2d-x/build/cocos2d-win10.sln` + * For Android ``` From 6ee33499b499761ff4236868bff661d54d76aee1 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 21 Aug 2015 14:38:39 +0800 Subject: [PATCH 051/118] Update changelog and versions for v3.8 rc0 --- AUTHORS | 30 ++- CHANGELOG | 211 +++++++++++++++++- CMakeLists.txt | 2 +- .../js-bindings/manual/ScriptingCore.h | 2 +- .../js-bindings/script/jsb_cocos2d.js | 2 +- docs/doxygen.config | 2 +- .../runtime-src/proj.ios_mac/mac/Info.plist | 2 +- web | 2 +- 8 files changed, 239 insertions(+), 14 deletions(-) diff --git a/AUTHORS b/AUTHORS index c4cec455e8..53eb9bed07 100644 --- a/AUTHORS +++ b/AUTHORS @@ -95,6 +95,7 @@ Developers: stari4ek Fix VideoPlayer on Android ignore search paths Label: Improve rendering of letter's inner shapes when outline is used + platform: Fixed issue that depth/stencil buffers attributes are ignored on iOS FlagellumDei Center the window correctly on windows @@ -407,6 +408,10 @@ Developers: Add scroll bar feature into ui::ScrollView. Add RadioButton and RaidoButtonGroup widgets. Add a setter for line width in DrawNode. + UI: Added a setter for line width in DrawNode + UI: Added ScrollViewBar for displaying a scroll bar at the side of ScrollView + UI: Added RadioButton widget + UI: Refined scroll event dispatching for ScrollView Sam Clegg (sbc100) Author of Native Client port. @@ -700,6 +705,7 @@ Developers: Added operator == != for Value Replace dynamic_cast to std::is_base_of in object_to_luaval Added support normalize path on android + FileUtils: Remove old path while adding existing search path superrad Clear NoSuchMethodError Exception when JniHelper fails to find methodID @@ -977,6 +983,7 @@ Developers: billtt Fixed a bug that Node::setScale(float) may not work properly + network: Fixed a problem where WebSocket messages may pile up Teivaz Custom uniform search optimization @@ -1019,6 +1026,7 @@ Developers: takaken1994 Added function for setting min/max scale for ScrollView + studio: Removed "using namespace cocos2d" from CCFrame.h maltium Added 3D rotation support to RotateTo action @@ -1115,6 +1123,7 @@ Developers: kompjoefriek Fix compiling warnings + Device: Added vibrate support to enable vibration for a duration. tmr111116 fix random int overflow @@ -1148,6 +1157,7 @@ Developers: perminovVS Optimize Vec3 and Vec2 Added `UserDefault::setDelegate()` + platform: Correct all usage of unicode version winapi in FileUtils for win32 qiutaoleo Added a feature to check case characters for filename on windows @@ -1159,12 +1169,14 @@ Developers: Fixed crash on AssetsManager Fixed memory leak of WebView on iOS Fixed crahed that if url contains illegal characters on Android + log: Fixed crash on Windows if passing string more than 16kb to cocos2d::log tankorsmash Fixed the bug that ProgressTimer::setSprite() doesn't take effect namezero111111 ui: TextField add `getTextColor`, `getTextHorizontalAlignment` and `getTextVerticalAlignment` API + Physics: Fixed circle shape debug draw incorrect issue shinhirota JS: Fixed issue of iOS/JS reflection `callStaticMethod` with bool arg @@ -1177,15 +1189,27 @@ Developers: iris-wy platform: Fixed warning "Service Intent must be explicit" on Android + alexpeak + Label: Fixed rendering LabelTTF characters as black boxes on Android by ensuring atlases are purged before resetting + + ywxzm + Lua: Fixed onTouch begin don't return value + + xpol + Sprite: Fixed some warnings and a related bug in CCSprite + + marzapower + UI: Fixed inertial scrolling for CCScrollView + + MAUSMAUSgames + Action: Permitted setting bitwise flags to action + Retired Core Developers: WenSheng Yang Author of windows port, CCTextField, Designer of CCApplication/CCEGLView/platform structure. He's working together with 2dx core team but leading FishingJoy game - Bin Zhang - core-team member but put himself in FishingJoy game since 2012. - RongHong Huang (flyingpaper) Author of cocos2d-xna and spent all his time on wp7. diff --git a/CHANGELOG b/CHANGELOG index 1f7a557dc7..6b3e20ae0b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,9 +1,210 @@ -cocos2d-x-3.8 ?? - [NEW] ui: Enhance ScrollView with easing out scrolling - [NEW] Animate: Added Animate's getCurrentFrameIndex function +cocos2d-x-3.8 rc0 ?? +cocos2d-x-3.8 beta0 August.14 2015 + + [HIGHLIGHT] 3D: Added 3d physics collider + [HIGHLIGHT] 3D: Supported setting camera background brushes with color/depth/skybox + [HIGHLIGHT] 3D: Added key frame event Callback in Animate3D + [HIGHLIGHT] FileUtils: Added a set of file writing APIs: writeStringToFile, writeDataToFile, writeValueMapToFile, writeValueVectorToFile + [HIGHLIGHT] UI: Refined UI system + [HIGHLIGHT] UI: Added RadioButton widget (JSB/Lua ready) + [HIGHLIGHT] UI: Reimplemented and enhanced EditBox on Android + [HIGHLIGHT] JS: Bound new AudioEngine in JSB + [HIGHLIGHT] JS: Merged JSB test project into cocos2d test project + [HIGHLIGHT] network: Upgrade SocketIO support to v1.x + [HIGHLIGHT] tools: Optimize Bindings Generator + [HIGHLIGHT] Label: Added HANYI FullType font support - [FIX] renderer: UI component can't click correctly by moving UI and camera far away of origin. + [NEW] 3D: Added light map support in Terrain + [NEW] UI: Added ScrollViewBar for displaying a scroll bar at the side of ScrollView (JSB/Lua ready) + [NEW] UI: Enhanced ScrollView with easing out scrolling + [NEW] UI: Added PageView vertical scroll support + [NEW] UI: Added PageView::JumpToPage API + [NEW] UI: Added a setter for line width in DrawNode + [NEW] Action: Permitted setting bitwise flags to action + [NEW] Animate: Added Animate's getCurrentFrameIndex function + [NEW] FileUtils: Added FileUtils::getFileExtension for getting file's extension name + [NEW] Device: Added vibrate support to enable vibration for a duration + [NEW] audio: AudioEngine supported audio preloading + [NEW] UserDefault: Supported removing key pairs from UserDefault + [NEW] spine: Supported Spine runtime 2.3 (Both native and web engine) + [NEW] console: Supported new portrait projects from templates + [NEW] console: Moved the framework-compile tools into cocos2d-console + [NEW] framework: Support generate prebuilt libs of engine with debug mode + [NEW] Supported Xcode 7 + + [REFINE] 3D: Supported composite 2D/3D scene by moving UI and camera far away + [REFINE] 3D: Improved Particle3D performance + [REFINE] 3D: Made SkyBox not transparent + [REFINE] Director: Made types to handle time consistent by modifing setAnimationInterval argument from double to float + [REFINE] Sprite: Made Sprite::setTexture accept nullptr as parameter + [REFINE] TextureCache: Made addImageAsync function thread unsafe + [REFINE] Label: Improved code readability + [REFINE] Label: Supported adding child nodes in Label + [REFINE] Label: Refine the implementation about text layout and support debug draw + [REFINE] Label: Supported auto batch with bitmap font or char map + [REFINE] UI: Improved Slider's precision + [REFINE] UI: Made Label and Text share the same fontSize type + [REFINE] UI: Reduced memory usage in Text + [REFINE] UI: Refined scroll event dispatching for ScrollView + [REFINE] UI: Made EditBox::setFontSize not rely on font name property + [REFINE] UI: Made viewport constructor more compile friendly + [REFINE] UI: Improved event handling in TextField + [REFINE] studio: Avoid CSLoader from openning csb file multiple times with fopen + [REFINE] studio: Added BlendFrame support to Skeleton Animation + [REFINE] studio: Enabled blendfunc cascade to the skin of BoneNode + [REFINE] FileUtils: Remove old path while adding existing search path + [REFINE] Device: Implemented Device::getDPI for Mac + [REFINE] network: Refine NSLog in HttpAsynConnection in release mode + [REFINE] network: Fixed a problem where WebSocket messages may pile up + [REFINE] utils: Made utils::captureScreen saving file in another thread to improve the performance + [REFINE] 3rd party: Update Nibiru SDK to 2.6 + [REFINE] platform: Correct all usage of unicode version winapi in FileUtils for win32 + [REFINE] JS: Supported new construction for 3d classes in JS + [REFINE] JS: Automatically add extend to need to extend classes in bindings generator + [REFINE] JS: Made UI classes safely extendable in JSB + [REFINE] JS: Improved NodeGrid binding + [REFINE] JS: Refine performance for Cocos Studio JSON parser for 2.x + [REFINE] JS: Made binding functions accept null in JS and convert to nullptr + [REFINE] web: Avoid re-bake the content when the parent node's position get changed + [REFINE] web: Added GameNodeObjectData and GameLayerObjectData in JSON parser + [REFINE] web: Updated skeleton animation to the latest version + [REFINE] web: Optimized resources automatic loading in JSON parser + [REFINE] web: Avoid cc.loader resource loading being terminated while encounter errors + [REFINE] web: Throw new Error object instead of error message string + [REFINE] web: Move setDepthTest to renderer + [REFINE] web: Added BlendFuncFrame parser + [REFINE] web: Permitted webp image loading on Chrome + [REFINE] web: Suspended the video player when the browser is minimized + [REFINE] framework: Optimized the lua & js templates + [REFINE] simulator: Made Node, Skeleton needs shown in the middle of the simulator window + [REFINE] Removed EMSCRIPTEN support + [REFINE] Added template project daily build in Jenkins-ci + [REFINE] Removed unused tool gen-prebuilt + [REFINE] Removed deprecated API in templates + + [FIX] 3D: Fixed Effect3DOutline issue when the Sprite3D is mirrored + [FIX] 3D: Fixed issue that Sprite3D::getAABBRecursively does not get AABB of Nodes with Sprite3d children + [FIX] 3D: Fixed Menu unusable in 3D scene + [FIX] renderer: UI component can't click correctly by moving UI and camera far away of origin + [FIX] renderer: ListView in Camera with custom mask isn't visible + [FIX] renderer: Temporary fix for Sprite/Label/FastTMX auto-culling failure + [FIX] renderer: Fixed shader issue by reloading shader when light number changed + [FIX] Scheduler: Fixed timer's delta time is error when interval equals to zero + [FIX] Scheduler: Fixed Pause/Resume act incorrectly + [FIX] Node: Fixed issue that euler angle is NaN when update Euler angle from quaternion and asin value is not between -1 and 1 by accident + [FIX] Scene: Fixed bug that can't add custom member to Scene subclass + [FIX] Sprite: Fixed some warnings and a related bug in CCSprite + [FIX] AutoPolygon: Fixed copy construct & assignment operator memory leakage + [FIX] SpriteBatchNode: Touch screen might cause rendering order disorder when the screen have numerous sprites + [FIX] SpriteBatchNode: Fixed SpriteBatchNode doesn't support setFlipped + [FIX] event: Fixed EventDispatcher wrong dispatch order bug + [FIX] event: Fixed EventListenerKeyboard.onKeyPressed not firing for back button on Android + [FIX] FileUtils: Fixed bug that FileUtils::isDirectoryExist result is not correct on Android while using relative path in 'assets' + [FIX] Action: Fixed bug that CCTargetedAction executes callback twice + [FIX] audio: Fixed playing new audio after stopping an incessant(loop) audio may fail on MAC/iOS + [FIX] audio: Fixed bug that playing audio may fail(error code:-1) on iOS + [FIX] audio: Fixed AudioEngine possible crash on iOS/Mac while playing multiply audio + [FIX] Label: Fixed rendering LabelTTF characters as black boxes on Android by ensuring atlases are purged before resetting + [FIX] Label: Fixed bug that characters are displayed incorrectly with "dark roast.ttf" font + [FIX] Label: Fixed opacity setting is invalid with bitmap font + [FIX] Label: Fixed the color of letter will be overridden by fade action + [FIX] Label: Fixed Label with some specific font is cropped + [FIX] Label: Fixed the content size of Label is incorrect with GLOW effect + [FIX] Label: Fixed spaces is lost if label created with Fingerpop.ttf + [FIX] Label: Fixed Label::getLetter(index)->setVisible(true) cause rendering duplicate letters + [FIX] Label: Fixed Label::setGlobalZOrder invalid issue if label create with system font + [FIX] UI: Fixed issue that Slider::addEventListener doesn't respect the button pressed and button release event + [FIX] UI: Fixed bug that UI component can't be clicked correctly by moving UI and camera far away of origin + [FIX] UI: Fixed inertial scrolling for CCScrollView + [FIX] UI: Fixed bug that ListView::getCurSelectedIndex may cause out of range issue + [FIX] UI: Fixed PageView scrollToPage bug and the curPageIndex bug + [FIX] UI: Fixed game scene displays wrongly while clicking EditBox + [FIX] UI: Fixed RichText layout cause infinite loop issue + [FIX] UI: Fixed formarRenderers in RichText doesn’t update container size + [FIX] UI: Fixed TextField hitTest not working as expected issue + [FIX] UI: Fixed Widget::setHighlighted does not work after setBright + [FIX] UI: Fixed Button touch doesn't work with setScale9Enabled + [FIX] UI: Fixed calculation error of Layout viewing area's clipping position in SCISSOR mode + [FIX] UI: Fixed logic error in isMaxLengthEnabled handling invoked by TextField::setString + [FIX] UI: Fixed improper touch intercept event propagation in UI system + [FIX] UI: Fixed EditBox input maxLength for Chinese character issue on iOS + [FIX] UI: Fixed EditBox turning black when soft keyboard hiding + [FIX] UI: Fixed scrollview innerContainer initial position error + [FIX] studio: Removed "using namespace cocos2d" from CCFrame.h + [FIX] studio: Fixed the SkyBox display error while parsed from editor files + [FIX] studio: Fixed userCamera flag error while parsing old version exported files + [FIX] studio: Fixed GameNode3DReader parse failed error + [FIX] studio: Fixed crash when loading cocostudio json files with null or empty fontName + [FIX] studio: Fixed bug that setColor works on a whole armature, but not on an individual bone + [FIX] studio: Fixed object size error while data is error + [FIX] ClippingNode: Removed CCClippingRectangleNode transform error support + [FIX] spine: Fixed the position of debug draw of bones is incorrect + [FIX] spine: Fixed memory leak caused by SkeletonRenderer::initialize + [FIX] network: Fixed Downloader::getHeader failure on win32 + [FIX] AssetsManagerEx: Fix AssetsManager crash by protecting Downloader with shared_ptr + [FIX] RenderTexture: Fixed RenderTexture switch foreground to background issue + [FIX] Physics: Fixed circle shape debug draw incorrect issue + [FIX] Physics: Fix transform issue of PhysicsSprite itself and its children + [FIX] tilemap: Fixed small errors in the function TMXXMLParser::getRectForGID + [FIX] tilemap: Fixed crash caused by creating TMX object when related image file is missing or broken + [FIX] effect: Fixed PageTurn3D effect abnormal + [FIX] ProgressTimer: Fixed SpriteProgressToRadialMidpointChanged bug + [FIX] log: Fixed crash on Windows if passing string more than 16kb to cocos2d::log + [FIX] utils: Fixed utils::captureScreen bug while using multiple camera [FIX] JS: Fixed issue of iOS/JS reflection `callStaticMethod` with bool arg + [FIX] JS: Fixed Objective-C JS reflection bug while using callStaticMethod() with bool argument + [FIX] JS: Fixed issue that subclass of ccui.Widget which overwrote onEnter will cause infinite recursion + [FIX] JS: Fixed Node color property can not be used issue + [FIX] JS: Fixed issue that SocketIO events don’t get fired when compile mode set to release + [FIX] JS: Added the conversion for tmxTileFlags to fix TMXLayer::tileFlagsAt binding issue + [FIX] JS: Fixed jsval_to_int and jsval_to_uint issue on 64 bit system + [FIX] Lua: Fixed onTouch begin don't return value + [FIX] Lua: Fixed memory leak in LuaMinXmlHttpRequest + [FIX] Lua: Fixed checkbox Lua bindings issue + [FIX] Lua: Fixed logic issue in cc.pIsSegmentIntersect + [FIX] platform: Fixed issue that getStringUTFChars can not passing emotion from java to c++ on Android + [FIX] platform: Fixed bug that paused game will be awaked by the Clock on Android + [FIX] platform: Fixed bug that Cocos2dxHelper won't be initialized after activity recreate + [FIX] platform: Fixed clipping node doesn't work on Android 5.0 + [FIX] platform: Fixed blur shader compliant on win8 universal + [FIX] platform: Fixed the error when compiling android project with release mode on Windows + [FIX] platform: Fixed issue that depth/stencil buffers attributes are ignored on iOS + [FIX] platform: Fixed engine crash because of wrong initialisation on some android device + [FIX] platform: Removed unneeded protocol for AppController on iOS + [FIX] platform: Fixed link errors in release mode on win32 + [FIX] platform: Fixed Windows 10 UWP and WP8.1 app certification issue + [FIX] web: Fixed a bug that VideoPlayer remove event throw error + [FIX] web: Fixed Armature position error in studio JSON parser + [FIX] web: Fixed default clearColor error in director + [FIX] web: Fixed rotation value parsing error in the timeline parser + [FIX] web: Fixed a bug that nested animation may be affected by outer animation + [FIX] web: Made LabelAtlas ignoring invalid characters and updating correctly the content size + [FIX] web: Fixed a bug that VideoPlayer remove event throw error + [FIX] web: Fixed a bug that cc.director.setNotificationNode(null) doesn't take effect + [FIX] web: Fixed texture rect update issue while changing sprite frame + [FIX] web: Fixed effect issue in ActionGrid and NodeGrid + [FIX] web: Fixed logic issue in Menu's _onTouchCancelled function + [FIX] web: Fixed MenuItem crash when normal image is null + + [TEST] 3D: Avoid to trigger touch event multiple times in Physics3D Test and Physics3D Constraint Test + [TEST] 3D: Fixed Sprite3D test background to foreground bug + [TEST] renderer: Added auto culling test case + [TEST] renderer: Fixed material parsing test on wp8.1 + [TEST] OpenGL: Fixed shader-basic and OpenGL testcase 'center' uniform error + [TEST] OpenGL: Fixed ShaderRetroEffect random crash issue + [TEST] OpenGL: Fixed offset on retina screen in shaderTest + [TEST] OpenGL: Fixed shader test crash on android device + [TEST] OpenGL: Fixed retro effect pos bug in ShaderTest + [TEST] UI: Improved UIScene testcase + [TEST] studio: Fixed cocostudio 3d test crash on mobile platform + [TEST] studio: Added blendfunc Frame test case for skeleton animation + [TEST] spine: Fixed bug that spine animition can't be rendered in Scene3DTest + [TEST] tilemap: Fixed the problem that white frame didn't move as map did in JSB TMXOrthoObjectsTest + [TEST] JS: Fixed Button position error in UIPageViewTest + [TEST] web: Rewrote testcase for stencil depth mask in RenderTextureTest + [TEST] web: Improved renderTexture stencilDepth test + [TEST] web: Fixed abnormal effects in effectsTest + [TEST] web: Fixed invisiable testcase of effects cocos2d-x-3.7.1 August.12 2015 [HIGHLIGHT] studio: Added new skeleton animation support and csb parser for cocos v2.3.2 beta @@ -84,7 +285,7 @@ cocos2d-x-3.7rc0 July.1 2015 [HIGHLIGHT] 3d: Added Physics3d support (JS/Lua ready) [HIGHLIGHT] 3d: Added NavMesh support (JS/Lua ready) [HIGHLIGHT] Scale9Sprite: Added Android 9-patch image support (JS/Lua ready) - [HIGHLIGHT] sprite: Supportted polygon sprite with AutoPolygon generator (JS/Lua ready) + [HIGHLIGHT] sprite: Supported polygon sprite with AutoPolygon generator (JS/Lua ready) [HIGHLIGHT] platform: Added Windows 10.0 Universal App(UWP) support [HIGHLIGHT] platform: Add Samsung Enhanced API on Android for cocos, please refer to the release note for more details [HIGHLIGHT] C++: Added Android Studio support diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e11bb1b31..b7f9fcc2f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,7 @@ endif() project (Cocos2d-X) # The version number -set(COCOS2D_X_VERSION 3.7.1) +set(COCOS2D_X_VERSION 3.8) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules/") include(CocosBuildHelpers) diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.h b/cocos/scripting/js-bindings/manual/ScriptingCore.h index 04d67003f0..6d9565887f 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.h +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.h @@ -39,7 +39,7 @@ #include #include -#define ENGINE_VERSION "Cocos2d-JS v3.7.1" +#define ENGINE_VERSION "Cocos2d-JS v3.8 RC0" void js_log(const char *format, ...); diff --git a/cocos/scripting/js-bindings/script/jsb_cocos2d.js b/cocos/scripting/js-bindings/script/jsb_cocos2d.js index 0db94824db..c9cd0b1466 100644 --- a/cocos/scripting/js-bindings/script/jsb_cocos2d.js +++ b/cocos/scripting/js-bindings/script/jsb_cocos2d.js @@ -26,7 +26,7 @@ // CCConfig.js // -cc.ENGINE_VERSION = "Cocos2d-JS v3.7.1"; +cc.ENGINE_VERSION = "Cocos2d-JS v3.8 RC0"; cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0; cc.DIRECTOR_STATS_POSITION = {x: 0, y: 0}; diff --git a/docs/doxygen.config b/docs/doxygen.config index af7ce33c40..cc4098d332 100644 --- a/docs/doxygen.config +++ b/docs/doxygen.config @@ -38,7 +38,7 @@ PROJECT_NAME = Cocos2d-x # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = v3.7.1 +PROJECT_NUMBER = v3.8 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Info.plist b/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Info.plist index 6766324769..e52344dca3 100644 --- a/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Info.plist +++ b/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Info.plist @@ -41,7 +41,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 3.7.1 + 3.8 CFBundleSignature ???? CFBundleVersion diff --git a/web b/web index 6902509a62..b672abb239 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit 6902509a62efa5ec85a36cf83aca95f91b6519b4 +Subproject commit b672abb2392c715966a20a273d7371f0ec09fb63 From 055ef23931ea6efb49ddb2385392c0f020b30627 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sat, 22 Aug 2015 22:13:53 +0800 Subject: [PATCH 052/118] Fix AssetsManager crash by protecting Downloader with shared_ptr --- cocos/network/CCDownloader.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cocos/network/CCDownloader.cpp b/cocos/network/CCDownloader.cpp index cb693aefbd..ffb0c026d5 100644 --- a/cocos/network/CCDownloader.cpp +++ b/cocos/network/CCDownloader.cpp @@ -197,6 +197,9 @@ void Downloader::downloadToBuffer(const std::string& srcUrl, const std::string& CC_ASSERT(_downloaderImpl && "Cannot instanciate more than one instance of DownloaderImpl"); + std::weak_ptr ptr = shared_from_this(); + std::shared_ptr shared = ptr.lock(); + StreamData streamBuffer; streamBuffer.buffer = buffer; streamBuffer.total = size; @@ -256,6 +259,9 @@ void Downloader::downloadToFP(const std::string& srcUrl, const std::string& cust { CC_ASSERT(_downloaderImpl && "Cannot instanciate more than one instance of DownloaderImpl"); + std::weak_ptr ptr = shared_from_this(); + std::shared_ptr shared = ptr.lock(); + DownloadUnit unit; unit.srcUrl = srcUrl; unit.customId = customId; @@ -366,6 +372,9 @@ void Downloader::batchDownloadSync(const DownloadUnits& units, const std::string void Downloader::groupBatchDownload(const DownloadUnits& units) { + std::weak_ptr ptr = shared_from_this(); + std::shared_ptr shared = ptr.lock(); + // static_cast needed since notifyError is overloaded auto errorCallback = std::bind( static_cast (&Downloader::notifyError), this, From 110de9ee3ea1dd131ff980238f8d76c33bda5093 Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 21 Aug 2015 14:53:50 +0800 Subject: [PATCH 053/118] fix skybox crash with error data --- .../WidgetReader/GameNode3DReader/GameNode3DReader.cpp | 7 ++++++- .../WidgetReader/UserCameraReader/UserCameraReader.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.cpp index e3654eba29..2f9789f06a 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.cpp @@ -386,7 +386,12 @@ namespace cocostudio std::string forwardFileData = options->forwardFileData()->path()->c_str(); std::string backFileData = options->backFileData()->path()->c_str(); - if (leftFileData.empty() || rightFileData.empty() || upFileData.empty() || downFileData.empty() || forwardFileData.empty() || backFileData.empty()) + if (!FileUtils::getInstance()->isFileExist(leftFileData) + || !FileUtils::getInstance()->isFileExist(rightFileData) + || !FileUtils::getInstance()->isFileExist(upFileData) + || !FileUtils::getInstance()->isFileExist(downFileData) + || !FileUtils::getInstance()->isFileExist(forwardFileData) + || !FileUtils::getInstance()->isFileExist(backFileData)) return; Skybox* childBox = Skybox::create(leftFileData,rightFileData,upFileData,downFileData,forwardFileData,backFileData); unsigned short cameraFlag = 1 << 10; diff --git a/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp index 40f8199f33..0da9617894 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp @@ -430,7 +430,12 @@ namespace cocostudio std::string forwardFileData = options->forwardFileData()->path()->c_str(); std::string backFileData = options->backFileData()->path()->c_str(); - if (leftFileData.empty() || rightFileData.empty() || upFileData.empty() || downFileData.empty() || forwardFileData.empty() || backFileData.empty()) + if (!FileUtils::getInstance()->isFileExist(leftFileData) + || !FileUtils::getInstance()->isFileExist(rightFileData) + || !FileUtils::getInstance()->isFileExist(upFileData) + || !FileUtils::getInstance()->isFileExist(downFileData) + || !FileUtils::getInstance()->isFileExist(forwardFileData) + || !FileUtils::getInstance()->isFileExist(backFileData)) return; Skybox* childBox = Skybox::create(leftFileData, rightFileData, upFileData, downFileData, forwardFileData, backFileData); childBox->setCameraMask(cameraFlag); From 11113c85da27d994f87ea313a0988667f6d8c7ea Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 24 Aug 2015 10:00:22 +0800 Subject: [PATCH 054/118] Improved logic of skybox reader fix --- .../GameNode3DReader/GameNode3DReader.cpp | 15 +++++++++------ .../UserCameraReader/UserCameraReader.cpp | 15 +++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.cpp index 2f9789f06a..c96c61a550 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.cpp @@ -385,14 +385,17 @@ namespace cocostudio std::string downFileData = options->downFileData()->path()->c_str(); std::string forwardFileData = options->forwardFileData()->path()->c_str(); std::string backFileData = options->backFileData()->path()->c_str(); + FileUtils *fileUtils = FileUtils::getInstance(); - if (!FileUtils::getInstance()->isFileExist(leftFileData) - || !FileUtils::getInstance()->isFileExist(rightFileData) - || !FileUtils::getInstance()->isFileExist(upFileData) - || !FileUtils::getInstance()->isFileExist(downFileData) - || !FileUtils::getInstance()->isFileExist(forwardFileData) - || !FileUtils::getInstance()->isFileExist(backFileData)) + if (!fileUtils->isFileExist(leftFileData) + || !fileUtils->isFileExist(rightFileData) + || !fileUtils->isFileExist(upFileData) + || !fileUtils->isFileExist(downFileData) + || !fileUtils->isFileExist(forwardFileData) + || !fileUtils->isFileExist(backFileData)) + { return; + } Skybox* childBox = Skybox::create(leftFileData,rightFileData,upFileData,downFileData,forwardFileData,backFileData); unsigned short cameraFlag = 1 << 10; childBox->setCameraMask(cameraFlag); diff --git a/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp index 0da9617894..b6e67c5f26 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp @@ -429,14 +429,17 @@ namespace cocostudio std::string downFileData = options->downFileData()->path()->c_str(); std::string forwardFileData = options->forwardFileData()->path()->c_str(); std::string backFileData = options->backFileData()->path()->c_str(); + FileUtils *fileUtils = FileUtils::getInstance(); - if (!FileUtils::getInstance()->isFileExist(leftFileData) - || !FileUtils::getInstance()->isFileExist(rightFileData) - || !FileUtils::getInstance()->isFileExist(upFileData) - || !FileUtils::getInstance()->isFileExist(downFileData) - || !FileUtils::getInstance()->isFileExist(forwardFileData) - || !FileUtils::getInstance()->isFileExist(backFileData)) + if (!fileUtils->isFileExist(leftFileData) + || !fileUtils->isFileExist(rightFileData) + || !fileUtils->isFileExist(upFileData) + || !fileUtils->isFileExist(downFileData) + || !fileUtils->isFileExist(forwardFileData) + || !fileUtils->isFileExist(backFileData)) + { return; + } Skybox* childBox = Skybox::create(leftFileData, rightFileData, upFileData, downFileData, forwardFileData, backFileData); childBox->setCameraMask(cameraFlag); node->addChild(childBox, 0, "_innerSkyBox"); From be24586f4bf0b8c82b4c7af45cdc968307eb1a87 Mon Sep 17 00:00:00 2001 From: songchengjiang Date: Mon, 24 Aug 2015 10:23:59 +0800 Subject: [PATCH 055/118] fix crash of CameraBackgroundColorBrush --- cocos/2d/CCCameraBackgroundBrush.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/2d/CCCameraBackgroundBrush.cpp b/cocos/2d/CCCameraBackgroundBrush.cpp index 17d21ad2e1..d64cfdc7e9 100644 --- a/cocos/2d/CCCameraBackgroundBrush.cpp +++ b/cocos/2d/CCCameraBackgroundBrush.cpp @@ -205,6 +205,7 @@ CameraBackgroundColorBrush::~CameraBackgroundColorBrush() bool CameraBackgroundColorBrush::init() { + CameraBackgroundDepthBrush::init(); this->_clearColor = GL_TRUE; return true; } From 7dcc3dd982b8620f6a0879c004d858e711cc2ebc Mon Sep 17 00:00:00 2001 From: yangxiao Date: Mon, 24 Aug 2015 10:49:10 +0800 Subject: [PATCH 056/118] Move CCTextureCube From 3d to renderer to solve compilation issue --- build/cocos2d_libs.xcodeproj/project.pbxproj | 24 +++++++++---------- cocos/2d/CCCameraBackgroundBrush.cpp | 2 +- cocos/2d/libcocos2d.vcxproj | 4 ++-- cocos/2d/libcocos2d.vcxproj.filters | 12 +++++----- .../libcocos2d_8_1.Shared.vcxitems | 4 ++-- .../libcocos2d_8_1.Shared.vcxitems.filters | 12 +++++----- cocos/3d/Android.mk | 3 +-- cocos/3d/CCSkybox.cpp | 3 +-- cocos/3d/CMakeLists.txt | 1 - cocos/Android.mk | 1 + cocos/cocos2d.h | 3 ++- cocos/{3d => renderer}/CCTextureCube.cpp | 2 +- cocos/{3d => renderer}/CCTextureCube.h | 0 cocos/renderer/CMakeLists.txt | 1 + 14 files changed, 36 insertions(+), 36 deletions(-) rename cocos/{3d => renderer}/CCTextureCube.cpp (99%) rename cocos/{3d => renderer}/CCTextureCube.h (100%) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 90af72ae38..6f97b84ffa 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -2059,6 +2059,10 @@ B60C5BD519AC68B10056FBDE /* CCBillBoard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B60C5BD219AC68B10056FBDE /* CCBillBoard.cpp */; }; B60C5BD619AC68B10056FBDE /* CCBillBoard.h in Headers */ = {isa = PBXBuildFile; fileRef = B60C5BD319AC68B10056FBDE /* CCBillBoard.h */; }; B60C5BD719AC68B10056FBDE /* CCBillBoard.h in Headers */ = {isa = PBXBuildFile; fileRef = B60C5BD319AC68B10056FBDE /* CCBillBoard.h */; }; + B62305641B8ABA6600F0745D /* CCTextureCube.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B62305621B8ABA6600F0745D /* CCTextureCube.cpp */; }; + B62305651B8ABA6600F0745D /* CCTextureCube.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B62305621B8ABA6600F0745D /* CCTextureCube.cpp */; }; + B62305661B8ABA6600F0745D /* CCTextureCube.h in Headers */ = {isa = PBXBuildFile; fileRef = B62305631B8ABA6600F0745D /* CCTextureCube.h */; }; + B62305671B8ABA6600F0745D /* CCTextureCube.h in Headers */ = {isa = PBXBuildFile; fileRef = B62305631B8ABA6600F0745D /* CCTextureCube.h */; }; B63990CC1A490AFE00B07923 /* CCAsyncTaskPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B63990CA1A490AFE00B07923 /* CCAsyncTaskPool.cpp */; }; B63990CD1A490AFE00B07923 /* CCAsyncTaskPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B63990CA1A490AFE00B07923 /* CCAsyncTaskPool.cpp */; }; B63990CE1A490AFE00B07923 /* CCAsyncTaskPool.h in Headers */ = {isa = PBXBuildFile; fileRef = B63990CB1A490AFE00B07923 /* CCAsyncTaskPool.h */; }; @@ -3517,10 +3521,6 @@ B6D38B8B1AC3AFAC00043997 /* CCSkybox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6D38B861AC3AFAC00043997 /* CCSkybox.cpp */; }; B6D38B8C1AC3AFAC00043997 /* CCSkybox.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D38B871AC3AFAC00043997 /* CCSkybox.h */; }; B6D38B8D1AC3AFAC00043997 /* CCSkybox.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D38B871AC3AFAC00043997 /* CCSkybox.h */; }; - B6D38B8E1AC3AFAC00043997 /* CCTextureCube.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6D38B881AC3AFAC00043997 /* CCTextureCube.cpp */; }; - B6D38B8F1AC3AFAC00043997 /* CCTextureCube.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6D38B881AC3AFAC00043997 /* CCTextureCube.cpp */; }; - B6D38B901AC3AFAC00043997 /* CCTextureCube.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D38B891AC3AFAC00043997 /* CCTextureCube.h */; }; - B6D38B911AC3AFAC00043997 /* CCTextureCube.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D38B891AC3AFAC00043997 /* CCTextureCube.h */; }; B6DD2FA71B04825B00E47F5F /* DebugDraw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6DD2F7A1B04825B00E47F5F /* DebugDraw.cpp */; }; B6DD2FA81B04825B00E47F5F /* DebugDraw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6DD2F7A1B04825B00E47F5F /* DebugDraw.cpp */; }; B6DD2FA91B04825B00E47F5F /* DebugDraw.h in Headers */ = {isa = PBXBuildFile; fileRef = B6DD2F7B1B04825B00E47F5F /* DebugDraw.h */; }; @@ -4771,6 +4771,8 @@ B603F1B21AC8F1FD00A9579C /* ccShader_3D_Terrain.vert */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_3D_Terrain.vert; sourceTree = ""; }; B60C5BD219AC68B10056FBDE /* CCBillBoard.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBillBoard.cpp; sourceTree = ""; }; B60C5BD319AC68B10056FBDE /* CCBillBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBillBoard.h; sourceTree = ""; }; + B62305621B8ABA6600F0745D /* CCTextureCube.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTextureCube.cpp; sourceTree = ""; }; + B62305631B8ABA6600F0745D /* CCTextureCube.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTextureCube.h; sourceTree = ""; }; B63990CA1A490AFE00B07923 /* CCAsyncTaskPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCAsyncTaskPool.cpp; path = ../base/CCAsyncTaskPool.cpp; sourceTree = ""; }; B63990CB1A490AFE00B07923 /* CCAsyncTaskPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCAsyncTaskPool.h; path = ../base/CCAsyncTaskPool.h; sourceTree = ""; }; B665E0CC1AA80A6500DDB1C5 /* CCPUAffector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCPUAffector.cpp; path = Particle3D/PU/CCPUAffector.cpp; sourceTree = ""; }; @@ -5503,8 +5505,6 @@ B6CAB1E01AF9AA1A00B9B856 /* MiniCLTaskScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MiniCLTaskScheduler.h; sourceTree = ""; }; B6D38B861AC3AFAC00043997 /* CCSkybox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSkybox.cpp; sourceTree = ""; }; B6D38B871AC3AFAC00043997 /* CCSkybox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSkybox.h; sourceTree = ""; }; - B6D38B881AC3AFAC00043997 /* CCTextureCube.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTextureCube.cpp; sourceTree = ""; }; - B6D38B891AC3AFAC00043997 /* CCTextureCube.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTextureCube.h; sourceTree = ""; }; B6D38B941AC3B45600043997 /* ccShader_3D_Particle.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_3D_Particle.frag; sourceTree = ""; }; B6D38B951AC3B45600043997 /* ccShader_3D_Particle.vert */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_3D_Particle.vert; sourceTree = ""; }; B6D38B961AC3B45600043997 /* ccShader_3D_Skybox.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_3D_Skybox.frag; sourceTree = ""; }; @@ -7430,6 +7430,8 @@ 500DC89819105D41007B91BF /* renderer */ = { isa = PBXGroup; children = ( + B62305621B8ABA6600F0745D /* CCTextureCube.cpp */, + B62305631B8ABA6600F0745D /* CCTextureCube.h */, B240C5E71B09DFB000137F50 /* CCFrameBuffer.cpp */, B240C5E81B09DFB000137F50 /* CCFrameBuffer.h */, 5034CA5D191D591900CE6051 /* shaders */, @@ -7873,8 +7875,6 @@ B603F1A71AC8EA0900A9579C /* CCTerrain.h */, B6D38B861AC3AFAC00043997 /* CCSkybox.cpp */, B6D38B871AC3AFAC00043997 /* CCSkybox.h */, - B6D38B881AC3AFAC00043997 /* CCTextureCube.cpp */, - B6D38B891AC3AFAC00043997 /* CCTextureCube.h */, 5E9F61221A3FFE3D0038DE01 /* CCFrustum.cpp */, 5E9F61231A3FFE3D0038DE01 /* CCFrustum.h */, 5E9F61241A3FFE3D0038DE01 /* CCPlane.cpp */, @@ -9443,6 +9443,7 @@ B665E43C1AA80A6600DDB1C5 /* CCPUVortexAffectorTranslator.h in Headers */, 15AE191C19AAD35000C27E9E /* CCTransformHelp.h in Headers */, 5034CA2F191D591100CE6051 /* ccShader_PositionTexture.vert in Headers */, + B62305661B8ABA6600F0745D /* CCTextureCube.h in Headers */, B665E4241AA80A6600DDB1C5 /* CCPUTranslateManager.h in Headers */, 15AE1C1219AAE2C600C27E9E /* CCPhysicsDebugNode.h in Headers */, B665E3381AA80A6500DDB1C5 /* CCPUOnEmissionObserverTranslator.h in Headers */, @@ -9675,7 +9676,6 @@ B6CAB2B51AF9AA1A00B9B856 /* btConvexShape.h in Headers */, B60C5BD619AC68B10056FBDE /* CCBillBoard.h in Headers */, 15AE1BA419AADFDF00C27E9E /* UILayoutManager.h in Headers */, - B6D38B901AC3AFAC00043997 /* CCTextureCube.h in Headers */, 1A01C69418F57BE800EFE3A6 /* CCFloat.h in Headers */, 1A57034D180BD09B0088DEC7 /* tinyxml2.h in Headers */, B6CAB4C31AF9AA1A00B9B856 /* Box.h in Headers */, @@ -10295,6 +10295,7 @@ 1A5701A4180BCB590088DEC7 /* CCFontAtlas.h in Headers */, B6CAB4C41AF9AA1A00B9B856 /* Box.h in Headers */, 15AE1C0219AAE01E00C27E9E /* CCScrollView.h in Headers */, + B62305671B8ABA6600F0745D /* CCTextureCube.h in Headers */, 1A5701A8180BCB590088DEC7 /* CCFontAtlasCache.h in Headers */, B665E3E51AA80A6600DDB1C5 /* CCPUSineForceAffector.h in Headers */, 182C5CE81A9D725400C30D34 /* UserCameraReader.h in Headers */, @@ -10487,7 +10488,6 @@ 15AE1AC919AAD40300C27E9E /* b2Joint.h in Headers */, 382383EF1A258FA7002C4610 /* flatbuffers.h in Headers */, B677B0CC1B18492D006762CB /* CCNavMesh.h in Headers */, - B6D38B911AC3AFAC00043997 /* CCTextureCube.h in Headers */, B665E2811AA80A6500DDB1C5 /* CCPUDoScaleEventHandlerTranslator.h in Headers */, 15AE196819AAD35100C27E9E /* CCUtilMath.h in Headers */, B29A7E2019EE1B7700872B35 /* BoneData.h in Headers */, @@ -11099,7 +11099,6 @@ B665E24E1AA80A6500DDB1C5 /* CCPUColorAffectorTranslator.cpp in Sources */, B6CAB1E71AF9AA1A00B9B856 /* btAxisSweep3.cpp in Sources */, B6CAB2D91AF9AA1A00B9B856 /* btPolyhedralConvexShape.cpp in Sources */, - B6D38B8E1AC3AFAC00043997 /* CCTextureCube.cpp in Sources */, 15AE1B9B19AADFDF00C27E9E /* UIRelativeBox.cpp in Sources */, B665E3E21AA80A6600DDB1C5 /* CCPUSineForceAffector.cpp in Sources */, 50ABBD501925AB0000A911A9 /* Quaternion.cpp in Sources */, @@ -11174,6 +11173,7 @@ 1A57006D180BC5A10088DEC7 /* CCActionEase.cpp in Sources */, 15AE1A5019AAD40300C27E9E /* b2BlockAllocator.cpp in Sources */, B665E20E1AA80A6500DDB1C5 /* CCPUBaseForceAffector.cpp in Sources */, + B62305641B8ABA6600F0745D /* CCTextureCube.cpp in Sources */, B6CAB25D1AF9AA1A00B9B856 /* btInternalEdgeUtility.cpp in Sources */, 15AE1A8219AAD40300C27E9E /* b2GearJoint.cpp in Sources */, 1A570071180BC5A10088DEC7 /* CCActionGrid.cpp in Sources */, @@ -12027,6 +12027,7 @@ 15AE1A3C19AAD3D500C27E9E /* b2CollideCircle.cpp in Sources */, 501216951AC47393009A4BEA /* CCPass.cpp in Sources */, 50ABBE6E1925AB6F00A911A9 /* CCEventListenerKeyboard.cpp in Sources */, + B62305651B8ABA6600F0745D /* CCTextureCube.cpp in Sources */, B665E2CB1AA80A6500DDB1C5 /* CCPUGravityAffectorTranslator.cpp in Sources */, 15AE18D719AAD33D00C27E9E /* CCScrollViewLoader.cpp in Sources */, 50CB247C19D9C5A100687767 /* AudioEngine-inl.mm in Sources */, @@ -12228,7 +12229,6 @@ B6CAB2A41AF9AA1A00B9B856 /* btConvexHullShape.cpp in Sources */, 15AE1AA519AAD40300C27E9E /* b2Fixture.cpp in Sources */, B29A7DE219EE1B7700872B35 /* MeshAttachment.c in Sources */, - B6D38B8F1AC3AFAC00043997 /* CCTextureCube.cpp in Sources */, B6CAB2C01AF9AA1A00B9B856 /* btEmptyShape.cpp in Sources */, 15AE1BAD19AADFDF00C27E9E /* UILayoutParameter.cpp in Sources */, 3823843E1A259140002C4610 /* SingleNodeReader.cpp in Sources */, diff --git a/cocos/2d/CCCameraBackgroundBrush.cpp b/cocos/2d/CCCameraBackgroundBrush.cpp index 17d21ad2e1..b69c848ec6 100644 --- a/cocos/2d/CCCameraBackgroundBrush.cpp +++ b/cocos/2d/CCCameraBackgroundBrush.cpp @@ -33,7 +33,7 @@ #include "renderer/CCGLProgramState.h" #include "renderer/CCRenderer.h" #include "renderer/CCRenderState.h" -#include "3d/CCTextureCube.h" +#include "renderer/CCTextureCube.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) #include "base/CCEventCustom.h" diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index 4d33cd8871..f62d0aeb5a 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -395,7 +395,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* - @@ -627,6 +626,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + @@ -962,7 +962,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* - @@ -1243,6 +1242,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index 071543d2e7..eb2707d8f7 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -1362,9 +1362,6 @@ 3d - - 3d - extension\Particle3D\ParticleUniverse @@ -1934,6 +1931,9 @@ 2d + + renderer + @@ -3184,9 +3184,6 @@ 3d - - 3d - platform @@ -3771,6 +3768,9 @@ 2d + + renderer + diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems index fe832bac5a..0933df8075 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems @@ -230,7 +230,6 @@ - @@ -532,6 +531,7 @@ + @@ -856,7 +856,6 @@ - NotUsing @@ -1126,6 +1125,7 @@ + diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters index b8cd7da27b..f9759f3410 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters @@ -1728,9 +1728,6 @@ 3d - - 3d - 3d @@ -1870,6 +1867,9 @@ 2d + + renderer + @@ -3431,9 +3431,6 @@ 3d - - 3d - 3d @@ -3570,6 +3567,9 @@ 2d + + renderer + diff --git a/cocos/3d/Android.mk b/cocos/3d/Android.mk index 771a23da37..f08edf18c0 100644 --- a/cocos/3d/Android.mk +++ b/cocos/3d/Android.mk @@ -23,8 +23,7 @@ CCObjLoader.cpp \ CCSkeleton3D.cpp \ CCSprite3D.cpp \ CCTerrain.cpp \ -CCSkybox.cpp \ -CCTextureCube.cpp +CCSkybox.cpp LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. diff --git a/cocos/3d/CCSkybox.cpp b/cocos/3d/CCSkybox.cpp index 36d9bd4890..06e1b7c061 100644 --- a/cocos/3d/CCSkybox.cpp +++ b/cocos/3d/CCSkybox.cpp @@ -31,9 +31,8 @@ #include "renderer/CCGLProgramState.h" #include "renderer/CCRenderer.h" #include "renderer/CCRenderState.h" +#include "renderer/CCTextureCube.h" #include "3d/CCSkybox.h" -#include "3d/CCTextureCube.h" - #include "2d/CCCamera.h" NS_CC_BEGIN diff --git a/cocos/3d/CMakeLists.txt b/cocos/3d/CMakeLists.txt index 6d7df05657..b306935b3e 100644 --- a/cocos/3d/CMakeLists.txt +++ b/cocos/3d/CMakeLists.txt @@ -25,6 +25,5 @@ set(COCOS_3D_SRC 3d/CCSprite3D.cpp 3d/CCSprite3DMaterial.cpp 3d/CCTerrain.cpp - 3d/CCTextureCube.cpp ) diff --git a/cocos/Android.mk b/cocos/Android.mk index 9343224bba..d2049c1e68 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -181,6 +181,7 @@ renderer/CCTechnique.cpp \ renderer/CCTexture2D.cpp \ renderer/CCTextureAtlas.cpp \ renderer/CCTextureCache.cpp \ +renderer/CCTextureCube.cpp \ renderer/CCTrianglesCommand.cpp \ renderer/CCVertexAttribBinding.cpp \ renderer/CCVertexIndexBuffer.cpp \ diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index 7ad0b66ae9..fb205c046b 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -163,6 +163,7 @@ THE SOFTWARE. #include "renderer/CCRenderer.h" #include "renderer/CCTechnique.h" #include "renderer/CCTexture2D.h" +#include "renderer/CCTextureCube.h" #include "renderer/CCTextureCache.h" #include "renderer/CCTrianglesCommand.h" #include "renderer/CCVertexAttribBinding.h" @@ -298,7 +299,7 @@ THE SOFTWARE. #include "3d/CCSprite3D.h" #include "3d/CCSprite3DMaterial.h" #include "3d/CCTerrain.h" -#include "3d/CCTextureCube.h" + // Deprecated include #include "deprecated/CCArray.h" diff --git a/cocos/3d/CCTextureCube.cpp b/cocos/renderer/CCTextureCube.cpp similarity index 99% rename from cocos/3d/CCTextureCube.cpp rename to cocos/renderer/CCTextureCube.cpp index a867e38266..17fd54bd64 100644 --- a/cocos/3d/CCTextureCube.cpp +++ b/cocos/renderer/CCTextureCube.cpp @@ -22,7 +22,7 @@ THE SOFTWARE. ****************************************************************************/ -#include "3d/CCTextureCube.h" +#include "renderer/CCTextureCube.h" #include "platform/CCImage.h" #include "platform/CCFileUtils.h" diff --git a/cocos/3d/CCTextureCube.h b/cocos/renderer/CCTextureCube.h similarity index 100% rename from cocos/3d/CCTextureCube.h rename to cocos/renderer/CCTextureCube.h diff --git a/cocos/renderer/CMakeLists.txt b/cocos/renderer/CMakeLists.txt index bdfd0995d7..2f8eabe581 100644 --- a/cocos/renderer/CMakeLists.txt +++ b/cocos/renderer/CMakeLists.txt @@ -20,6 +20,7 @@ set(COCOS_RENDERER_SRC renderer/CCTexture2D.cpp renderer/CCTextureAtlas.cpp renderer/CCTextureCache.cpp + renderer/CCTextureCube.cpp renderer/CCTrianglesCommand.cpp renderer/CCVertexAttribBinding.cpp renderer/CCVertexIndexBuffer.cpp From 64b9c2b51fe6fe22035209ca7d31f87f3ecb5859 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Mon, 24 Aug 2015 06:07:38 +0000 Subject: [PATCH 057/118] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index b7fccdd639..3683794f2a 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -251,8 +251,6 @@ "cocos/3d/CCSprite3DMaterial.h", "cocos/3d/CCTerrain.cpp", "cocos/3d/CCTerrain.h", - "cocos/3d/CCTextureCube.cpp", - "cocos/3d/CCTextureCube.h", "cocos/3d/CMakeLists.txt", "cocos/3d/cocos3d.h", "cocos/Android.mk", @@ -1119,6 +1117,8 @@ "cocos/renderer/CCTextureAtlas.h", "cocos/renderer/CCTextureCache.cpp", "cocos/renderer/CCTextureCache.h", + "cocos/renderer/CCTextureCube.cpp", + "cocos/renderer/CCTextureCube.h", "cocos/renderer/CCTrianglesCommand.cpp", "cocos/renderer/CCTrianglesCommand.h", "cocos/renderer/CCVertexAttribBinding.cpp", From 31a09c9f235eeae1886f386d4f9519ccec9e58fa Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Mon, 24 Aug 2015 06:13:37 +0000 Subject: [PATCH 058/118] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/jsb_cocos2dx_3d_auto_api.js | 96 ++--- .../js-bindings/auto/jsb_cocos2dx_3d_auto.cpp | 292 ++++++------- .../js-bindings/auto/jsb_cocos2dx_3d_auto.hpp | 22 +- .../auto/api/lua_cocos2dx_3d_auto_api.lua | 10 +- .../auto/lua_cocos2dx_3d_auto.cpp | 406 +++++++++--------- 5 files changed, 413 insertions(+), 413 deletions(-) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js index 95215905e3..d4880670f8 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js @@ -285,6 +285,54 @@ Animate3D : function ( }; +/** + * @class TextureCube + */ +jsb.TextureCube = { + +/** + * @method reloadTexture + * @return {bool} + */ +reloadTexture : function ( +) +{ + return false; +}, + +/** + * @method create + * @param {String} arg0 + * @param {String} arg1 + * @param {String} arg2 + * @param {String} arg3 + * @param {String} arg4 + * @param {String} arg5 + * @return {cc.TextureCube} + */ +create : function ( +str, +str, +str, +str, +str, +str +) +{ + return cc.TextureCube; +}, + +/** + * @method TextureCube + * @constructor + */ +TextureCube : function ( +) +{ +}, + +}; + /** * @class AttachNode */ @@ -1550,54 +1598,6 @@ Terrain : function ( }; -/** - * @class TextureCube - */ -jsb.TextureCube = { - -/** - * @method reloadTexture - * @return {bool} - */ -reloadTexture : function ( -) -{ - return false; -}, - -/** - * @method create - * @param {String} arg0 - * @param {String} arg1 - * @param {String} arg2 - * @param {String} arg3 - * @param {String} arg4 - * @param {String} arg5 - * @return {cc.TextureCube} - */ -create : function ( -str, -str, -str, -str, -str, -str -) -{ - return cc.TextureCube; -}, - -/** - * @method TextureCube - * @constructor - */ -TextureCube : function ( -) -{ -}, - -}; - /** * @class Bundle3D */ diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp index 0a9be88cb6..76eba29288 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp @@ -837,6 +837,152 @@ void js_register_cocos2dx_3d_Animate3D(JSContext *cx, JS::HandleObject global) { } } +JSClass *jsb_cocos2d_TextureCube_class; +JSObject *jsb_cocos2d_TextureCube_prototype; + +bool js_cocos2dx_3d_TextureCube_reloadTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextureCube* cobj = (cocos2d::TextureCube *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_TextureCube_reloadTexture : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->reloadTexture(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_TextureCube_reloadTexture : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_TextureCube_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 6) { + std::string arg0; + std::string arg1; + std::string arg2; + std::string arg3; + std::string arg4; + std::string arg5; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + ok &= jsval_to_std_string(cx, args.get(3), &arg3); + ok &= jsval_to_std_string(cx, args.get(4), &arg4); + ok &= jsval_to_std_string(cx, args.get(5), &arg5); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_TextureCube_create : Error processing arguments"); + cocos2d::TextureCube* ret = cocos2d::TextureCube::create(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TextureCube*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_3d_TextureCube_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_3d_TextureCube_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TextureCube* cobj = new (std::nothrow) cocos2d::TextureCube(); + cocos2d::Ref *_ccobj = dynamic_cast(cobj); + if (_ccobj) { + _ccobj->autorelease(); + } + TypeTest t; + js_type_class_t *typeClass = nullptr; + std::string typeName = t.s_name(); + auto typeMapIter = _js_global_type_map.find(typeName); + CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); + typeClass = typeMapIter->second; + CCASSERT(typeClass, "The value is null."); + // JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TextureCube"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + +extern JSObject *jsb_cocos2d_Texture2D_prototype; + +void js_cocos2d_TextureCube_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TextureCube)", obj); +} +void js_register_cocos2dx_3d_TextureCube(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TextureCube_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TextureCube_class->name = "TextureCube"; + jsb_cocos2d_TextureCube_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TextureCube_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TextureCube_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TextureCube_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TextureCube_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TextureCube_class->resolve = JS_ResolveStub; + jsb_cocos2d_TextureCube_class->convert = JS_ConvertStub; + jsb_cocos2d_TextureCube_class->finalize = js_cocos2d_TextureCube_finalize; + jsb_cocos2d_TextureCube_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("reloadTexture", js_cocos2dx_3d_TextureCube_reloadTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_3d_TextureCube_create, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TextureCube_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Texture2D_prototype), + jsb_cocos2d_TextureCube_class, + js_cocos2dx_3d_TextureCube_constructor, 0, // constructor + properties, + funcs, + NULL, // no static properties + st_funcs); + // make the class enumerable in the registered namespace +// bool found; +//FIXME: Removed in Firefox v27 +// JS_SetPropertyAttributes(cx, global, "TextureCube", JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + // add the proto and JSClass to the type->js info hash table + TypeTest t; + js_type_class_t *p; + std::string typeName = t.s_name(); + if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) + { + p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); + p->jsclass = jsb_cocos2d_TextureCube_class; + p->proto = jsb_cocos2d_TextureCube_prototype; + p->parentProto = jsb_cocos2d_Texture2D_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + JSClass *jsb_cocos2d_AttachNode_class; JSObject *jsb_cocos2d_AttachNode_prototype; @@ -4360,152 +4506,6 @@ void js_register_cocos2dx_3d_Terrain(JSContext *cx, JS::HandleObject global) { } } -JSClass *jsb_cocos2d_TextureCube_class; -JSObject *jsb_cocos2d_TextureCube_prototype; - -bool js_cocos2dx_3d_TextureCube_reloadTexture(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::TextureCube* cobj = (cocos2d::TextureCube *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_TextureCube_reloadTexture : Invalid Native Object"); - if (argc == 0) { - bool ret = cobj->reloadTexture(); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_3d_TextureCube_reloadTexture : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_3d_TextureCube_create(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - if (argc == 6) { - std::string arg0; - std::string arg1; - std::string arg2; - std::string arg3; - std::string arg4; - std::string arg5; - ok &= jsval_to_std_string(cx, args.get(0), &arg0); - ok &= jsval_to_std_string(cx, args.get(1), &arg1); - ok &= jsval_to_std_string(cx, args.get(2), &arg2); - ok &= jsval_to_std_string(cx, args.get(3), &arg3); - ok &= jsval_to_std_string(cx, args.get(4), &arg4); - ok &= jsval_to_std_string(cx, args.get(5), &arg5); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_TextureCube_create : Error processing arguments"); - cocos2d::TextureCube* ret = cocos2d::TextureCube::create(arg0, arg1, arg2, arg3, arg4, arg5); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TextureCube*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - args.rval().set(jsret); - return true; - } - JS_ReportError(cx, "js_cocos2dx_3d_TextureCube_create : wrong number of arguments"); - return false; -} - -bool js_cocos2dx_3d_TextureCube_constructor(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - cocos2d::TextureCube* cobj = new (std::nothrow) cocos2d::TextureCube(); - cocos2d::Ref *_ccobj = dynamic_cast(cobj); - if (_ccobj) { - _ccobj->autorelease(); - } - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - // JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); - JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); - args.rval().set(OBJECT_TO_JSVAL(obj)); - // link the native object with the javascript object - js_proxy_t* p = jsb_new_proxy(cobj, obj); - AddNamedObjectRoot(cx, &p->obj, "cocos2d::TextureCube"); - if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); - return true; -} - -extern JSObject *jsb_cocos2d_Texture2D_prototype; - -void js_cocos2d_TextureCube_finalize(JSFreeOp *fop, JSObject *obj) { - CCLOGINFO("jsbindings: finalizing JS object %p (TextureCube)", obj); -} -void js_register_cocos2dx_3d_TextureCube(JSContext *cx, JS::HandleObject global) { - jsb_cocos2d_TextureCube_class = (JSClass *)calloc(1, sizeof(JSClass)); - jsb_cocos2d_TextureCube_class->name = "TextureCube"; - jsb_cocos2d_TextureCube_class->addProperty = JS_PropertyStub; - jsb_cocos2d_TextureCube_class->delProperty = JS_DeletePropertyStub; - jsb_cocos2d_TextureCube_class->getProperty = JS_PropertyStub; - jsb_cocos2d_TextureCube_class->setProperty = JS_StrictPropertyStub; - jsb_cocos2d_TextureCube_class->enumerate = JS_EnumerateStub; - jsb_cocos2d_TextureCube_class->resolve = JS_ResolveStub; - jsb_cocos2d_TextureCube_class->convert = JS_ConvertStub; - jsb_cocos2d_TextureCube_class->finalize = js_cocos2d_TextureCube_finalize; - jsb_cocos2d_TextureCube_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); - - static JSPropertySpec properties[] = { - JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_PS_END - }; - - static JSFunctionSpec funcs[] = { - JS_FN("reloadTexture", js_cocos2dx_3d_TextureCube_reloadTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FS_END - }; - - static JSFunctionSpec st_funcs[] = { - JS_FN("create", js_cocos2dx_3d_TextureCube_create, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FS_END - }; - - jsb_cocos2d_TextureCube_prototype = JS_InitClass( - cx, global, - JS::RootedObject(cx, jsb_cocos2d_Texture2D_prototype), - jsb_cocos2d_TextureCube_class, - js_cocos2dx_3d_TextureCube_constructor, 0, // constructor - properties, - funcs, - NULL, // no static properties - st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TextureCube", JSPROP_ENUMERATE | JSPROP_READONLY, &found); - - // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TextureCube_class; - p->proto = jsb_cocos2d_TextureCube_prototype; - p->parentProto = jsb_cocos2d_Texture2D_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } -} - JSClass *jsb_cocos2d_Bundle3D_class; JSObject *jsb_cocos2d_Bundle3D_prototype; diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.hpp index ad15fa8fc5..8163bc550c 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.hpp @@ -44,6 +44,17 @@ bool js_cocos2dx_3d_Animate3D_createWithFrames(JSContext *cx, uint32_t argc, jsv bool js_cocos2dx_3d_Animate3D_setTransitionTime(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_Animate3D_Animate3D(JSContext *cx, uint32_t argc, jsval *vp); +extern JSClass *jsb_cocos2d_TextureCube_class; +extern JSObject *jsb_cocos2d_TextureCube_prototype; + +bool js_cocos2dx_3d_TextureCube_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_3d_TextureCube_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_3d_TextureCube(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_3d(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_3d_TextureCube_reloadTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_TextureCube_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_TextureCube_TextureCube(JSContext *cx, uint32_t argc, jsval *vp); + extern JSClass *jsb_cocos2d_AttachNode_class; extern JSObject *jsb_cocos2d_AttachNode_prototype; @@ -219,17 +230,6 @@ bool js_cocos2dx_3d_Terrain_getMinHeight(JSContext *cx, uint32_t argc, jsval *vp bool js_cocos2dx_3d_Terrain_getMaxHeight(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_Terrain_Terrain(JSContext *cx, uint32_t argc, jsval *vp); -extern JSClass *jsb_cocos2d_TextureCube_class; -extern JSObject *jsb_cocos2d_TextureCube_prototype; - -bool js_cocos2dx_3d_TextureCube_constructor(JSContext *cx, uint32_t argc, jsval *vp); -void js_cocos2dx_3d_TextureCube_finalize(JSContext *cx, JSObject *obj); -void js_register_cocos2dx_3d_TextureCube(JSContext *cx, JS::HandleObject global); -void register_all_cocos2dx_3d(JSContext* cx, JS::HandleObject obj); -bool js_cocos2dx_3d_TextureCube_reloadTexture(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_3d_TextureCube_create(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_3d_TextureCube_TextureCube(JSContext *cx, uint32_t argc, jsval *vp); - extern JSClass *jsb_cocos2d_Bundle3D_class; extern JSObject *jsb_cocos2d_Bundle3D_prototype; diff --git a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_3d_auto_api.lua b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_3d_auto_api.lua index b756ba2c96..eb84e3a7b4 100644 --- a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_3d_auto_api.lua +++ b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_3d_auto_api.lua @@ -11,6 +11,11 @@ -- @field [parent=#cc] Animate3D#Animate3D Animate3D preloaded module +-------------------------------------------------------- +-- the cc TextureCube +-- @field [parent=#cc] TextureCube#TextureCube TextureCube preloaded module + + -------------------------------------------------------- -- the cc AttachNode -- @field [parent=#cc] AttachNode#AttachNode AttachNode preloaded module @@ -51,11 +56,6 @@ -- @field [parent=#cc] Terrain#Terrain Terrain preloaded module --------------------------------------------------------- --- the cc TextureCube --- @field [parent=#cc] TextureCube#TextureCube TextureCube preloaded module - - -------------------------------------------------------- -- the cc Bundle3D -- @field [parent=#cc] Bundle3D#Bundle3D Bundle3D preloaded module diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp index 77b00849d0..f85eea9c4f 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp @@ -1134,6 +1134,209 @@ int lua_register_cocos2dx_3d_Animate3D(lua_State* tolua_S) return 1; } +int lua_cocos2dx_3d_TextureCube_reloadTexture(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::TextureCube* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.TextureCube",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::TextureCube*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_TextureCube_reloadTexture'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_TextureCube_reloadTexture'", nullptr); + return 0; + } + bool ret = cobj->reloadTexture(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.TextureCube:reloadTexture",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_TextureCube_reloadTexture'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_TextureCube_setTexParameters(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::TextureCube* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.TextureCube",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::TextureCube*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_TextureCube_setTexParameters'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Texture2D::TexParams arg0; + + ok &= luaval_to_texparams(tolua_S, 2, &arg0, "cc.TextureCube:setTexParameters"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_TextureCube_setTexParameters'", nullptr); + return 0; + } + cobj->setTexParameters(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.TextureCube:setTexParameters",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_TextureCube_setTexParameters'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_TextureCube_create(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.TextureCube",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 6) + { + std::string arg0; + std::string arg1; + std::string arg2; + std::string arg3; + std::string arg4; + std::string arg5; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.TextureCube:create"); + ok &= luaval_to_std_string(tolua_S, 3,&arg1, "cc.TextureCube:create"); + ok &= luaval_to_std_string(tolua_S, 4,&arg2, "cc.TextureCube:create"); + ok &= luaval_to_std_string(tolua_S, 5,&arg3, "cc.TextureCube:create"); + ok &= luaval_to_std_string(tolua_S, 6,&arg4, "cc.TextureCube:create"); + ok &= luaval_to_std_string(tolua_S, 7,&arg5, "cc.TextureCube:create"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_TextureCube_create'", nullptr); + return 0; + } + cocos2d::TextureCube* ret = cocos2d::TextureCube::create(arg0, arg1, arg2, arg3, arg4, arg5); + object_to_luaval(tolua_S, "cc.TextureCube",(cocos2d::TextureCube*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.TextureCube:create",argc, 6); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_TextureCube_create'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_3d_TextureCube_constructor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::TextureCube* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_TextureCube_constructor'", nullptr); + return 0; + } + cobj = new cocos2d::TextureCube(); + cobj->autorelease(); + int ID = (int)cobj->_ID ; + int* luaID = &cobj->_luaID ; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.TextureCube"); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.TextureCube:TextureCube",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_TextureCube_constructor'.",&tolua_err); +#endif + + return 0; +} + +static int lua_cocos2dx_3d_TextureCube_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (TextureCube)"); + return 0; +} + +int lua_register_cocos2dx_3d_TextureCube(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.TextureCube"); + tolua_cclass(tolua_S,"TextureCube","cc.TextureCube","cc.Texture2D",nullptr); + + tolua_beginmodule(tolua_S,"TextureCube"); + tolua_function(tolua_S,"new",lua_cocos2dx_3d_TextureCube_constructor); + tolua_function(tolua_S,"reloadTexture",lua_cocos2dx_3d_TextureCube_reloadTexture); + tolua_function(tolua_S,"setTexParameters",lua_cocos2dx_3d_TextureCube_setTexParameters); + tolua_function(tolua_S,"create", lua_cocos2dx_3d_TextureCube_create); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::TextureCube).name(); + g_luaType[typeName] = "cc.TextureCube"; + g_typeCast["TextureCube"] = "cc.TextureCube"; + return 1; +} + int lua_cocos2dx_3d_AttachNode_create(lua_State* tolua_S) { int argc = 0; @@ -5854,209 +6057,6 @@ int lua_register_cocos2dx_3d_Terrain(lua_State* tolua_S) return 1; } -int lua_cocos2dx_3d_TextureCube_reloadTexture(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::TextureCube* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.TextureCube",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::TextureCube*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_TextureCube_reloadTexture'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_TextureCube_reloadTexture'", nullptr); - return 0; - } - bool ret = cobj->reloadTexture(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.TextureCube:reloadTexture",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_TextureCube_reloadTexture'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_3d_TextureCube_setTexParameters(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::TextureCube* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.TextureCube",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::TextureCube*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_TextureCube_setTexParameters'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Texture2D::TexParams arg0; - - ok &= luaval_to_texparams(tolua_S, 2, &arg0, "cc.TextureCube:setTexParameters"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_TextureCube_setTexParameters'", nullptr); - return 0; - } - cobj->setTexParameters(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.TextureCube:setTexParameters",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_TextureCube_setTexParameters'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_3d_TextureCube_create(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.TextureCube",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 6) - { - std::string arg0; - std::string arg1; - std::string arg2; - std::string arg3; - std::string arg4; - std::string arg5; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.TextureCube:create"); - ok &= luaval_to_std_string(tolua_S, 3,&arg1, "cc.TextureCube:create"); - ok &= luaval_to_std_string(tolua_S, 4,&arg2, "cc.TextureCube:create"); - ok &= luaval_to_std_string(tolua_S, 5,&arg3, "cc.TextureCube:create"); - ok &= luaval_to_std_string(tolua_S, 6,&arg4, "cc.TextureCube:create"); - ok &= luaval_to_std_string(tolua_S, 7,&arg5, "cc.TextureCube:create"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_TextureCube_create'", nullptr); - return 0; - } - cocos2d::TextureCube* ret = cocos2d::TextureCube::create(arg0, arg1, arg2, arg3, arg4, arg5); - object_to_luaval(tolua_S, "cc.TextureCube",(cocos2d::TextureCube*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.TextureCube:create",argc, 6); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_TextureCube_create'.",&tolua_err); -#endif - return 0; -} -int lua_cocos2dx_3d_TextureCube_constructor(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::TextureCube* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_TextureCube_constructor'", nullptr); - return 0; - } - cobj = new cocos2d::TextureCube(); - cobj->autorelease(); - int ID = (int)cobj->_ID ; - int* luaID = &cobj->_luaID ; - toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.TextureCube"); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.TextureCube:TextureCube",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_TextureCube_constructor'.",&tolua_err); -#endif - - return 0; -} - -static int lua_cocos2dx_3d_TextureCube_finalize(lua_State* tolua_S) -{ - printf("luabindings: finalizing LUA object (TextureCube)"); - return 0; -} - -int lua_register_cocos2dx_3d_TextureCube(lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"cc.TextureCube"); - tolua_cclass(tolua_S,"TextureCube","cc.TextureCube","cc.Texture2D",nullptr); - - tolua_beginmodule(tolua_S,"TextureCube"); - tolua_function(tolua_S,"new",lua_cocos2dx_3d_TextureCube_constructor); - tolua_function(tolua_S,"reloadTexture",lua_cocos2dx_3d_TextureCube_reloadTexture); - tolua_function(tolua_S,"setTexParameters",lua_cocos2dx_3d_TextureCube_setTexParameters); - tolua_function(tolua_S,"create", lua_cocos2dx_3d_TextureCube_create); - tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::TextureCube).name(); - g_luaType[typeName] = "cc.TextureCube"; - g_typeCast["TextureCube"] = "cc.TextureCube"; - return 1; -} - int lua_cocos2dx_3d_Bundle3D_load(lua_State* tolua_S) { int argc = 0; From da85b162928ba6028225784a86f4294c75dab63c Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Wed, 8 Jul 2015 18:25:40 +0900 Subject: [PATCH 059/118] Change not to dispatch event when add radio buttons --- cocos/ui/UIRadioButton.cpp | 11 ++++++++--- cocos/ui/UIRadioButton.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cocos/ui/UIRadioButton.cpp b/cocos/ui/UIRadioButton.cpp index 11607e0e4b..bcd48fd7a3 100644 --- a/cocos/ui/UIRadioButton.cpp +++ b/cocos/ui/UIRadioButton.cpp @@ -194,7 +194,7 @@ void RadioButtonGroup::addRadioButton(RadioButton* radioButton) if(!_allowedNoSelection && _selectedRadioButton == nullptr) { - setSelectedButton(radioButton); + setSelectedButtonWithoutEventCallback(radioButton); } } } @@ -219,7 +219,7 @@ void RadioButtonGroup::removeRadioButton(RadioButton* radioButton) if(!_allowedNoSelection && _selectedRadioButton == nullptr && !_radioButtons.empty()) { - setSelectedButton(0); + setSelectedButtonWithoutEventCallback(0); } } } @@ -261,6 +261,12 @@ void RadioButtonGroup::setSelectedButton(int index) } void RadioButtonGroup::setSelectedButton(RadioButton* radioButton) +{ + setSelectedButtonWithoutEventCallback(radioButton); + onChangedRadioButtonSelect(_selectedRadioButton); +} + +void RadioButtonGroup::setSelectedButtonWithoutEventCallback(RadioButton* radioButton) { if(!_allowedNoSelection && radioButton == nullptr) { @@ -282,7 +288,6 @@ void RadioButtonGroup::setSelectedButton(RadioButton* radioButton) { _selectedRadioButton->setSelected(true); } - onChangedRadioButtonSelect(_selectedRadioButton); } std::string RadioButtonGroup::getDescription() const diff --git a/cocos/ui/UIRadioButton.h b/cocos/ui/UIRadioButton.h index 2e51820851..26d982451d 100644 --- a/cocos/ui/UIRadioButton.h +++ b/cocos/ui/UIRadioButton.h @@ -258,6 +258,7 @@ protected: void onChangedRadioButtonSelect(RadioButton* radioButton); void deselect(); + void setSelectedButtonWithoutEventCallback(RadioButton* radioButton); Vector _radioButtons; ccRadioButtonGroupCallback _radioButtonGroupEventCallback; From 202b549073fff00d4c36ae52f4dc0208076d8d23 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Mon, 13 Jul 2015 12:38:28 +0900 Subject: [PATCH 060/118] Add getters for the internal renderer instances --- cocos/ui/UIAbstractCheckButton.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/cocos/ui/UIAbstractCheckButton.h b/cocos/ui/UIAbstractCheckButton.h index 8ff64aa7cc..bef259688e 100644 --- a/cocos/ui/UIAbstractCheckButton.h +++ b/cocos/ui/UIAbstractCheckButton.h @@ -131,6 +131,36 @@ public: */ float getZoomScale()const; + /** + * @brief Return the sprite instance of background + * @return the sprite instance of background. + */ + Sprite* getRendererBackground() const { return _backGroundBoxRenderer; } + + /** + * @brief Return the sprite instance of background when selected + * @return the sprite instance of background when selected + */ + Sprite* getRendererBackgroundSelected() const { return _backGroundSelectedBoxRenderer; } + + /** + * @brief Return the sprite instance of front cross + * @return the sprite instance of front cross + */ + Sprite* getRendererFrontCross() const { return _frontCrossRenderer; } + + /** + * @brief Return the sprite instance of background when disabled + * @return the sprite instance of background when disabled + */ + Sprite* getRendererBackgroundDisabled() const { return _backGroundBoxDisabledRenderer; } + + /** + * @brief Return the sprite instance of front cross when disabled + * @return the sprite instance of front cross when disabled + */ + Sprite* getRendererFrontCrossDisabled() const { return _frontCrossDisabledRenderer; } + CC_CONSTRUCTOR_ACCESS: virtual bool init() override; virtual bool init(const std::string& backGround, From 887efdca1b39d5bae556ab9866899f43bf046627 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Tue, 28 Jul 2015 20:23:22 +0900 Subject: [PATCH 061/118] Add 'removeAllRadioButtons()' --- cocos/ui/UIRadioButton.cpp | 8 ++++++++ cocos/ui/UIRadioButton.h | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/cocos/ui/UIRadioButton.cpp b/cocos/ui/UIRadioButton.cpp index bcd48fd7a3..a5c8e573a9 100644 --- a/cocos/ui/UIRadioButton.cpp +++ b/cocos/ui/UIRadioButton.cpp @@ -224,6 +224,14 @@ void RadioButtonGroup::removeRadioButton(RadioButton* radioButton) } } +void RadioButtonGroup::removeAllRadioButtons() +{ + while(!_radioButtons.empty()) + { + removeRadioButton(_radioButtons.at(0)); + } +} + ssize_t RadioButtonGroup::getNumberOfRadioButtons() const { return _radioButtons.size(); diff --git a/cocos/ui/UIRadioButton.h b/cocos/ui/UIRadioButton.h index 26d982451d..dda9f3ce89 100644 --- a/cocos/ui/UIRadioButton.h +++ b/cocos/ui/UIRadioButton.h @@ -218,6 +218,11 @@ public: */ virtual void removeRadioButton(RadioButton* radioButton); + /** + * Remove all radio button from this group. + */ + virtual void removeAllRadioButtons(); + /** * Get the number of radio buttons in this group. * From e1ed3ecb094f242884d5d8b63f43233ffb807079 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Fri, 7 Aug 2015 18:45:56 +0900 Subject: [PATCH 062/118] Add a method to change selected radio button without event dispatch. --- cocos/ui/UIRadioButton.cpp | 13 +++++++++---- cocos/ui/UIRadioButton.h | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/cocos/ui/UIRadioButton.cpp b/cocos/ui/UIRadioButton.cpp index a5c8e573a9..e14111e4ff 100644 --- a/cocos/ui/UIRadioButton.cpp +++ b/cocos/ui/UIRadioButton.cpp @@ -194,7 +194,7 @@ void RadioButtonGroup::addRadioButton(RadioButton* radioButton) if(!_allowedNoSelection && _selectedRadioButton == nullptr) { - setSelectedButtonWithoutEventCallback(radioButton); + setSelectedButtonWithoutEvent(radioButton); } } } @@ -219,7 +219,7 @@ void RadioButtonGroup::removeRadioButton(RadioButton* radioButton) if(!_allowedNoSelection && _selectedRadioButton == nullptr && !_radioButtons.empty()) { - setSelectedButtonWithoutEventCallback(0); + setSelectedButtonWithoutEvent(0); } } } @@ -270,11 +270,16 @@ void RadioButtonGroup::setSelectedButton(int index) void RadioButtonGroup::setSelectedButton(RadioButton* radioButton) { - setSelectedButtonWithoutEventCallback(radioButton); + setSelectedButtonWithoutEvent(radioButton); onChangedRadioButtonSelect(_selectedRadioButton); } -void RadioButtonGroup::setSelectedButtonWithoutEventCallback(RadioButton* radioButton) +void RadioButtonGroup::setSelectedButtonWithoutEvent(int index) +{ + setSelectedButtonWithoutEvent(_radioButtons.at(index)); +} + +void RadioButtonGroup::setSelectedButtonWithoutEvent(RadioButton* radioButton) { if(!_allowedNoSelection && radioButton == nullptr) { diff --git a/cocos/ui/UIRadioButton.h b/cocos/ui/UIRadioButton.h index dda9f3ce89..f895d480d4 100644 --- a/cocos/ui/UIRadioButton.h +++ b/cocos/ui/UIRadioButton.h @@ -204,6 +204,20 @@ public: */ virtual void setSelectedButton(RadioButton* radioButton); + /** + * Select a radio button by index without event dispatch. + * + * @param index of the radio button + */ + virtual void setSelectedButtonWithoutEvent(int index); + + /** + * Select a radio button by instance without event dispatch. + * + * @param radio button instance + */ + virtual void setSelectedButtonWithoutEvent(RadioButton* radioButton); + /** * Add a radio button into this group. * @@ -263,7 +277,6 @@ protected: void onChangedRadioButtonSelect(RadioButton* radioButton); void deselect(); - void setSelectedButtonWithoutEventCallback(RadioButton* radioButton); Vector _radioButtons; ccRadioButtonGroupCallback _radioButtonGroupEventCallback; From 9f693ef8f3dfb56e8b3dfcfb9ea6f3dbb41a0a18 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Mon, 24 Aug 2015 18:19:28 +0900 Subject: [PATCH 063/118] Enhance readability --- cocos/ui/UIScrollViewBar.cpp | 10 ++++++++-- cocos/ui/UIScrollViewBar.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cocos/ui/UIScrollViewBar.cpp b/cocos/ui/UIScrollViewBar.cpp index ec10cb2efc..d4682d9451 100644 --- a/cocos/ui/UIScrollViewBar.cpp +++ b/cocos/ui/UIScrollViewBar.cpp @@ -37,6 +37,7 @@ static const char* BODY_IMAGE_1_PIXEL_HEIGHT = "iVBORw0KGgoAAAANSUhEUgAAAAwAAAAB static const Color3B DEFAULT_COLOR(52, 65, 87); static const float DEFAULT_MARGIN = 20; static const float DEFAULT_AUTO_HIDE_TIME = 0.2f; +static const float DEFAULT_SCROLLBAR_OPACITY = 0.4f; static Sprite* createSpriteFromBase64(const char* base64String) { @@ -65,7 +66,7 @@ _direction(direction), _upperHalfCircle(nullptr), _lowerHalfCircle(nullptr), _body(nullptr), -_opacity(100), +_opacity(255 * DEFAULT_SCROLLBAR_OPACITY), _marginFromBoundary(DEFAULT_MARGIN), _marginForLength(DEFAULT_MARGIN), _touching(false), @@ -197,7 +198,12 @@ void ScrollViewBar::onEnter() void ScrollViewBar::update(float deltaTime) { - if(!_autoHideEnabled || _autoHideRemainingTime <= 0) + processAutoHide(deltaTime); +} + +void ScrollViewBar::processAutoHide(float deltaTime) +{ + if(!_autoHideEnabled || _autoHideRemainingTime <= 0) { return; } diff --git a/cocos/ui/UIScrollViewBar.h b/cocos/ui/UIScrollViewBar.h index 2331720c8b..8b466466da 100644 --- a/cocos/ui/UIScrollViewBar.h +++ b/cocos/ui/UIScrollViewBar.h @@ -153,6 +153,7 @@ private: Vec2 calculatePosition(float innerContainerMeasure, float scrollViewMeasure, float innerContainerPosition, float outOfBoundaryValue, float actualLength); void updateLength(float length); + void processAutoHide(float deltaTime); ScrollView* _parent; ScrollView::Direction _direction; From edd9fecf396b25fcfa1e974a00e29707d217baa7 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Mon, 24 Aug 2015 18:43:53 +0900 Subject: [PATCH 064/118] Update scroll bar when the inner container's size changes --- cocos/ui/UIScrollView.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index 401e4a8552..bce9d81253 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -210,6 +210,8 @@ void ScrollView::setInnerContainerSize(const Size &size) pos.y = _contentSize.height - (1.0f - _innerContainer->getAnchorPoint().y) * _innerContainer->getContentSize().height; } setInnerContainerPosition(pos); + + updateScrollBar(Vec2::ZERO); } const Size& ScrollView::getInnerContainerSize() const From 7117fa24bec756d678b5fcebf30a6e7aa82da0d3 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Mon, 24 Aug 2015 10:13:27 +0000 Subject: [PATCH 065/118] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/jsb_cocos2dx_ui_auto_api.js | 68 ++++ .../js-bindings/auto/jsb_cocos2dx_ui_auto.cpp | 192 ++++++++++ .../js-bindings/auto/jsb_cocos2dx_ui_auto.hpp | 7 + .../auto/api/AbstractCheckButton.lua | 35 ++ .../auto/api/RadioButtonGroup.lua | 14 + .../auto/lua_cocos2dx_ui_auto.cpp | 344 ++++++++++++++++++ .../auto/lua_cocos2dx_ui_auto.hpp | 7 + 7 files changed, 667 insertions(+) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js index 8dce033f52..de1b191482 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js @@ -1698,6 +1698,26 @@ bool { }, +/** + * @method getRendererFrontCrossDisabled + * @return {cc.Sprite} + */ +getRendererFrontCrossDisabled : function ( +) +{ + return cc.Sprite; +}, + +/** + * @method getRendererBackground + * @return {cc.Sprite} + */ +getRendererBackground : function ( +) +{ + return cc.Sprite; +}, + /** * @method loadTextureFrontCross * @param {String} arg0 @@ -1710,6 +1730,16 @@ texturerestype { }, +/** + * @method getRendererBackgroundDisabled + * @return {cc.Sprite} + */ +getRendererBackgroundDisabled : function ( +) +{ + return cc.Sprite; +}, + /** * @method isSelected * @return {bool} @@ -1772,6 +1802,26 @@ getZoomScale : function ( return 0; }, +/** + * @method getRendererFrontCross + * @return {cc.Sprite} + */ +getRendererFrontCross : function ( +) +{ + return cc.Sprite; +}, + +/** + * @method getRendererBackgroundSelected + * @return {cc.Sprite} + */ +getRendererBackgroundSelected : function ( +) +{ + return cc.Sprite; +}, + /** * @method loadTextureBackGround * @param {String} arg0 @@ -1949,6 +1999,24 @@ bool { }, +/** + * @method setSelectedButtonWithoutEvent +* @param {ccui.RadioButton|int} radiobutton +*/ +setSelectedButtonWithoutEvent : function( +int +) +{ +}, + +/** + * @method removeAllRadioButtons + */ +removeAllRadioButtons : function ( +) +{ +}, + /** * @method getRadioButtonByIndex * @param {int} arg0 diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp index 9152c185a2..e1410854fd 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp @@ -4244,6 +4244,56 @@ bool js_cocos2dx_ui_AbstractCheckButton_setSelected(JSContext *cx, uint32_t argc JS_ReportError(cx, "js_cocos2dx_ui_AbstractCheckButton_setSelected : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_AbstractCheckButton_getRendererFrontCrossDisabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::AbstractCheckButton* cobj = (cocos2d::ui::AbstractCheckButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_AbstractCheckButton_getRendererFrontCrossDisabled : Invalid Native Object"); + if (argc == 0) { + cocos2d::Sprite* ret = cobj->getRendererFrontCrossDisabled(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_AbstractCheckButton_getRendererFrontCrossDisabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_AbstractCheckButton_getRendererBackground(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::AbstractCheckButton* cobj = (cocos2d::ui::AbstractCheckButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_AbstractCheckButton_getRendererBackground : Invalid Native Object"); + if (argc == 0) { + cocos2d::Sprite* ret = cobj->getRendererBackground(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_AbstractCheckButton_getRendererBackground : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_AbstractCheckButton_loadTextureFrontCross(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -4274,6 +4324,31 @@ bool js_cocos2dx_ui_AbstractCheckButton_loadTextureFrontCross(JSContext *cx, uin JS_ReportError(cx, "js_cocos2dx_ui_AbstractCheckButton_loadTextureFrontCross : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundDisabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::AbstractCheckButton* cobj = (cocos2d::ui::AbstractCheckButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundDisabled : Invalid Native Object"); + if (argc == 0) { + cocos2d::Sprite* ret = cobj->getRendererBackgroundDisabled(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundDisabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_AbstractCheckButton_isSelected(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -4406,6 +4481,56 @@ bool js_cocos2dx_ui_AbstractCheckButton_getZoomScale(JSContext *cx, uint32_t arg JS_ReportError(cx, "js_cocos2dx_ui_AbstractCheckButton_getZoomScale : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_ui_AbstractCheckButton_getRendererFrontCross(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::AbstractCheckButton* cobj = (cocos2d::ui::AbstractCheckButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_AbstractCheckButton_getRendererFrontCross : Invalid Native Object"); + if (argc == 0) { + cocos2d::Sprite* ret = cobj->getRendererFrontCross(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_AbstractCheckButton_getRendererFrontCross : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundSelected(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::AbstractCheckButton* cobj = (cocos2d::ui::AbstractCheckButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundSelected : Invalid Native Object"); + if (argc == 0) { + cocos2d::Sprite* ret = cobj->getRendererBackgroundSelected(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundSelected : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_AbstractCheckButton_loadTextureBackGround(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -4514,11 +4639,16 @@ void js_register_cocos2dx_ui_AbstractCheckButton(JSContext *cx, JS::HandleObject JS_FN("loadTextureBackGroundSelected", js_cocos2dx_ui_AbstractCheckButton_loadTextureBackGroundSelected, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTextureBackGroundDisabled", js_cocos2dx_ui_AbstractCheckButton_loadTextureBackGroundDisabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSelected", js_cocos2dx_ui_AbstractCheckButton_setSelected, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRendererFrontCrossDisabled", js_cocos2dx_ui_AbstractCheckButton_getRendererFrontCrossDisabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRendererBackground", js_cocos2dx_ui_AbstractCheckButton_getRendererBackground, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTextureFrontCross", js_cocos2dx_ui_AbstractCheckButton_loadTextureFrontCross, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRendererBackgroundDisabled", js_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundDisabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isSelected", js_cocos2dx_ui_AbstractCheckButton_isSelected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_ui_AbstractCheckButton_init, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTextures", js_cocos2dx_ui_AbstractCheckButton_loadTextures, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getZoomScale", js_cocos2dx_ui_AbstractCheckButton_getZoomScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRendererFrontCross", js_cocos2dx_ui_AbstractCheckButton_getRendererFrontCross, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRendererBackgroundSelected", js_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundSelected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTextureBackGround", js_cocos2dx_ui_AbstractCheckButton_loadTextureBackGround, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setZoomScale", js_cocos2dx_ui_AbstractCheckButton_setZoomScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTextureFrontCrossDisabled", js_cocos2dx_ui_AbstractCheckButton_loadTextureFrontCrossDisabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -5182,6 +5312,66 @@ bool js_cocos2dx_ui_RadioButtonGroup_setAllowedNoSelection(JSContext *cx, uint32 JS_ReportError(cx, "js_cocos2dx_ui_RadioButtonGroup_setAllowedNoSelection : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ui::RadioButtonGroup* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ui::RadioButtonGroup *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::ui::RadioButton* arg0; + do { + if (args.get(0).isNull()) { arg0 = nullptr; break; } + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::RadioButton*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cobj->setSelectedButtonWithoutEvent(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + cobj->setSelectedButtonWithoutEvent(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_RadioButtonGroup_removeAllRadioButtons(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::RadioButtonGroup* cobj = (cocos2d::ui::RadioButtonGroup *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RadioButtonGroup_removeAllRadioButtons : Invalid Native Object"); + if (argc == 0) { + cobj->removeAllRadioButtons(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_RadioButtonGroup_removeAllRadioButtons : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_RadioButtonGroup_getRadioButtonByIndex(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -5395,6 +5585,8 @@ void js_register_cocos2dx_ui_RadioButtonGroup(JSContext *cx, JS::HandleObject gl JS_FN("isAllowedNoSelection", js_cocos2dx_ui_RadioButtonGroup_isAllowedNoSelection, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSelectedButtonIndex", js_cocos2dx_ui_RadioButtonGroup_getSelectedButtonIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAllowedNoSelection", js_cocos2dx_ui_RadioButtonGroup_setAllowedNoSelection, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSelectedButtonWithoutEvent", js_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllRadioButtons", js_cocos2dx_ui_RadioButtonGroup_removeAllRadioButtons, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRadioButtonByIndex", js_cocos2dx_ui_RadioButtonGroup_getRadioButtonByIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNumberOfRadioButtons", js_cocos2dx_ui_RadioButtonGroup_getNumberOfRadioButtons, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addRadioButton", js_cocos2dx_ui_RadioButtonGroup_addRadioButton, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp index 6239e2c5cf..d7a4847077 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp @@ -220,11 +220,16 @@ void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); bool js_cocos2dx_ui_AbstractCheckButton_loadTextureBackGroundSelected(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_loadTextureBackGroundDisabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_setSelected(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_AbstractCheckButton_getRendererFrontCrossDisabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_AbstractCheckButton_getRendererBackground(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_loadTextureFrontCross(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundDisabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_isSelected(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_init(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_loadTextures(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_getZoomScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_AbstractCheckButton_getRendererFrontCross(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundSelected(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_loadTextureBackGround(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_setZoomScale(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_AbstractCheckButton_loadTextureFrontCrossDisabled(JSContext *cx, uint32_t argc, jsval *vp); @@ -262,6 +267,8 @@ bool js_cocos2dx_ui_RadioButtonGroup_removeRadioButton(JSContext *cx, uint32_t a bool js_cocos2dx_ui_RadioButtonGroup_isAllowedNoSelection(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RadioButtonGroup_getSelectedButtonIndex(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RadioButtonGroup_setAllowedNoSelection(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RadioButtonGroup_removeAllRadioButtons(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RadioButtonGroup_getRadioButtonByIndex(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RadioButtonGroup_getNumberOfRadioButtons(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RadioButtonGroup_addRadioButton(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/cocos/scripting/lua-bindings/auto/api/AbstractCheckButton.lua b/cocos/scripting/lua-bindings/auto/api/AbstractCheckButton.lua index 6bc2572f1b..de1000aee4 100644 --- a/cocos/scripting/lua-bindings/auto/api/AbstractCheckButton.lua +++ b/cocos/scripting/lua-bindings/auto/api/AbstractCheckButton.lua @@ -33,6 +33,20 @@ -- @param #bool selected -- @return AbstractCheckButton#AbstractCheckButton self (return value: ccui.AbstractCheckButton) +-------------------------------- +-- brief Return the sprite instance of front cross when disabled
+-- return the sprite instance of front cross when disabled +-- @function [parent=#AbstractCheckButton] getRendererFrontCrossDisabled +-- @param self +-- @return Sprite#Sprite ret (return value: cc.Sprite) + +-------------------------------- +-- brief Return the sprite instance of background
+-- return the sprite instance of background. +-- @function [parent=#AbstractCheckButton] getRendererBackground +-- @param self +-- @return Sprite#Sprite ret (return value: cc.Sprite) + -------------------------------- -- Load cross texture for check button.
-- param crossTextureName The cross texture name.
@@ -43,6 +57,13 @@ -- @param #int texType -- @return AbstractCheckButton#AbstractCheckButton self (return value: ccui.AbstractCheckButton) +-------------------------------- +-- brief Return the sprite instance of background when disabled
+-- return the sprite instance of background when disabled +-- @function [parent=#AbstractCheckButton] getRendererBackgroundDisabled +-- @param self +-- @return Sprite#Sprite ret (return value: cc.Sprite) + -------------------------------- -- Query whether CheckBox is selected or not.
-- return true means "selected", false otherwise. @@ -88,6 +109,20 @@ -- @param self -- @return float#float ret (return value: float) +-------------------------------- +-- brief Return the sprite instance of front cross
+-- return the sprite instance of front cross +-- @function [parent=#AbstractCheckButton] getRendererFrontCross +-- @param self +-- @return Sprite#Sprite ret (return value: cc.Sprite) + +-------------------------------- +-- brief Return the sprite instance of background when selected
+-- return the sprite instance of background when selected +-- @function [parent=#AbstractCheckButton] getRendererBackgroundSelected +-- @param self +-- @return Sprite#Sprite ret (return value: cc.Sprite) + -------------------------------- -- Load background texture for check button.
-- param backGround The background image name.
diff --git a/cocos/scripting/lua-bindings/auto/api/RadioButtonGroup.lua b/cocos/scripting/lua-bindings/auto/api/RadioButtonGroup.lua index 38e177eee7..3a44afa07c 100644 --- a/cocos/scripting/lua-bindings/auto/api/RadioButtonGroup.lua +++ b/cocos/scripting/lua-bindings/auto/api/RadioButtonGroup.lua @@ -37,6 +37,14 @@ -- @param #bool allowedNoSelection -- @return RadioButtonGroup#RadioButtonGroup self (return value: ccui.RadioButtonGroup) +-------------------------------- +-- @overload self, ccui.RadioButton +-- @overload self, int +-- @function [parent=#RadioButtonGroup] setSelectedButtonWithoutEvent +-- @param self +-- @param #int index +-- @return RadioButtonGroup#RadioButtonGroup self (return value: ccui.RadioButtonGroup) + -------------------------------- -- Add a callback function which would be called when radio button is selected or unselected.
-- param callback A std::function with type @see `ccRadioButtonGroupCallback` @@ -45,6 +53,12 @@ -- @param #function callback -- @return RadioButtonGroup#RadioButtonGroup self (return value: ccui.RadioButtonGroup) +-------------------------------- +-- Remove all radio button from this group. +-- @function [parent=#RadioButtonGroup] removeAllRadioButtons +-- @param self +-- @return RadioButtonGroup#RadioButtonGroup self (return value: ccui.RadioButtonGroup) + -------------------------------- -- Get a radio button in this group by index.
-- param index of the radio button
diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp index 1dd4708e57..ae53270be6 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp @@ -8005,6 +8005,100 @@ int lua_cocos2dx_ui_AbstractCheckButton_setSelected(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_AbstractCheckButton_getRendererFrontCrossDisabled(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::AbstractCheckButton* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.AbstractCheckButton",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::AbstractCheckButton*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_AbstractCheckButton_getRendererFrontCrossDisabled'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_AbstractCheckButton_getRendererFrontCrossDisabled'", nullptr); + return 0; + } + cocos2d::Sprite* ret = cobj->getRendererFrontCrossDisabled(); + object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.AbstractCheckButton:getRendererFrontCrossDisabled",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_AbstractCheckButton_getRendererFrontCrossDisabled'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_AbstractCheckButton_getRendererBackground(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::AbstractCheckButton* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.AbstractCheckButton",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::AbstractCheckButton*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_AbstractCheckButton_getRendererBackground'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_AbstractCheckButton_getRendererBackground'", nullptr); + return 0; + } + cocos2d::Sprite* ret = cobj->getRendererBackground(); + object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.AbstractCheckButton:getRendererBackground",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_AbstractCheckButton_getRendererBackground'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_AbstractCheckButton_loadTextureFrontCross(lua_State* tolua_S) { int argc = 0; @@ -8072,6 +8166,53 @@ int lua_cocos2dx_ui_AbstractCheckButton_loadTextureFrontCross(lua_State* tolua_S return 0; } +int lua_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundDisabled(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::AbstractCheckButton* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.AbstractCheckButton",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::AbstractCheckButton*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundDisabled'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundDisabled'", nullptr); + return 0; + } + cocos2d::Sprite* ret = cobj->getRendererBackgroundDisabled(); + object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.AbstractCheckButton:getRendererBackgroundDisabled",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundDisabled'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_AbstractCheckButton_isSelected(lua_State* tolua_S) { int argc = 0; @@ -8348,6 +8489,100 @@ int lua_cocos2dx_ui_AbstractCheckButton_getZoomScale(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_AbstractCheckButton_getRendererFrontCross(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::AbstractCheckButton* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.AbstractCheckButton",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::AbstractCheckButton*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_AbstractCheckButton_getRendererFrontCross'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_AbstractCheckButton_getRendererFrontCross'", nullptr); + return 0; + } + cocos2d::Sprite* ret = cobj->getRendererFrontCross(); + object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.AbstractCheckButton:getRendererFrontCross",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_AbstractCheckButton_getRendererFrontCross'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundSelected(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::AbstractCheckButton* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.AbstractCheckButton",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::AbstractCheckButton*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundSelected'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundSelected'", nullptr); + return 0; + } + cocos2d::Sprite* ret = cobj->getRendererBackgroundSelected(); + object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.AbstractCheckButton:getRendererBackgroundSelected",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundSelected'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_AbstractCheckButton_loadTextureBackGround(lua_State* tolua_S) { int argc = 0; @@ -8547,11 +8782,16 @@ int lua_register_cocos2dx_ui_AbstractCheckButton(lua_State* tolua_S) tolua_function(tolua_S,"loadTextureBackGroundSelected",lua_cocos2dx_ui_AbstractCheckButton_loadTextureBackGroundSelected); tolua_function(tolua_S,"loadTextureBackGroundDisabled",lua_cocos2dx_ui_AbstractCheckButton_loadTextureBackGroundDisabled); tolua_function(tolua_S,"setSelected",lua_cocos2dx_ui_AbstractCheckButton_setSelected); + tolua_function(tolua_S,"getRendererFrontCrossDisabled",lua_cocos2dx_ui_AbstractCheckButton_getRendererFrontCrossDisabled); + tolua_function(tolua_S,"getRendererBackground",lua_cocos2dx_ui_AbstractCheckButton_getRendererBackground); tolua_function(tolua_S,"loadTextureFrontCross",lua_cocos2dx_ui_AbstractCheckButton_loadTextureFrontCross); + tolua_function(tolua_S,"getRendererBackgroundDisabled",lua_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundDisabled); tolua_function(tolua_S,"isSelected",lua_cocos2dx_ui_AbstractCheckButton_isSelected); tolua_function(tolua_S,"init",lua_cocos2dx_ui_AbstractCheckButton_init); tolua_function(tolua_S,"loadTextures",lua_cocos2dx_ui_AbstractCheckButton_loadTextures); tolua_function(tolua_S,"getZoomScale",lua_cocos2dx_ui_AbstractCheckButton_getZoomScale); + tolua_function(tolua_S,"getRendererFrontCross",lua_cocos2dx_ui_AbstractCheckButton_getRendererFrontCross); + tolua_function(tolua_S,"getRendererBackgroundSelected",lua_cocos2dx_ui_AbstractCheckButton_getRendererBackgroundSelected); tolua_function(tolua_S,"loadTextureBackGround",lua_cocos2dx_ui_AbstractCheckButton_loadTextureBackGround); tolua_function(tolua_S,"setZoomScale",lua_cocos2dx_ui_AbstractCheckButton_setZoomScale); tolua_function(tolua_S,"loadTextureFrontCrossDisabled",lua_cocos2dx_ui_AbstractCheckButton_loadTextureFrontCrossDisabled); @@ -9292,6 +9532,61 @@ int lua_cocos2dx_ui_RadioButtonGroup_setAllowedNoSelection(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::RadioButtonGroup* cobj = nullptr; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.RadioButtonGroup",0,&tolua_err)) goto tolua_lerror; +#endif + cobj = (cocos2d::ui::RadioButtonGroup*)tolua_tousertype(tolua_S,1,0); +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent'", nullptr); + return 0; + } +#endif + argc = lua_gettop(tolua_S)-1; + do{ + if (argc == 1) { + cocos2d::ui::RadioButton* arg0; + ok &= luaval_to_object(tolua_S, 2, "ccui.RadioButton",&arg0, "ccui.RadioButtonGroup:setSelectedButtonWithoutEvent"); + + if (!ok) { break; } + cobj->setSelectedButtonWithoutEvent(arg0); + lua_settop(tolua_S, 1); + return 1; + } + }while(0); + ok = true; + do{ + if (argc == 1) { + int arg0; + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "ccui.RadioButtonGroup:setSelectedButtonWithoutEvent"); + + if (!ok) { break; } + cobj->setSelectedButtonWithoutEvent(arg0); + lua_settop(tolua_S, 1); + return 1; + } + }while(0); + ok = true; + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.RadioButtonGroup:setSelectedButtonWithoutEvent",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_RadioButtonGroup_addEventListener(lua_State* tolua_S) { int argc = 0; @@ -9346,6 +9641,53 @@ int lua_cocos2dx_ui_RadioButtonGroup_addEventListener(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_RadioButtonGroup_removeAllRadioButtons(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::RadioButtonGroup* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.RadioButtonGroup",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::RadioButtonGroup*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_RadioButtonGroup_removeAllRadioButtons'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_RadioButtonGroup_removeAllRadioButtons'", nullptr); + return 0; + } + cobj->removeAllRadioButtons(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.RadioButtonGroup:removeAllRadioButtons",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_RadioButtonGroup_removeAllRadioButtons'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_RadioButtonGroup_getRadioButtonByIndex(lua_State* tolua_S) { int argc = 0; @@ -9636,7 +9978,9 @@ int lua_register_cocos2dx_ui_RadioButtonGroup(lua_State* tolua_S) tolua_function(tolua_S,"isAllowedNoSelection",lua_cocos2dx_ui_RadioButtonGroup_isAllowedNoSelection); tolua_function(tolua_S,"getSelectedButtonIndex",lua_cocos2dx_ui_RadioButtonGroup_getSelectedButtonIndex); tolua_function(tolua_S,"setAllowedNoSelection",lua_cocos2dx_ui_RadioButtonGroup_setAllowedNoSelection); + tolua_function(tolua_S,"setSelectedButtonWithoutEvent",lua_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent); tolua_function(tolua_S,"addEventListener",lua_cocos2dx_ui_RadioButtonGroup_addEventListener); + tolua_function(tolua_S,"removeAllRadioButtons",lua_cocos2dx_ui_RadioButtonGroup_removeAllRadioButtons); tolua_function(tolua_S,"getRadioButtonByIndex",lua_cocos2dx_ui_RadioButtonGroup_getRadioButtonByIndex); tolua_function(tolua_S,"getNumberOfRadioButtons",lua_cocos2dx_ui_RadioButtonGroup_getNumberOfRadioButtons); tolua_function(tolua_S,"addRadioButton",lua_cocos2dx_ui_RadioButtonGroup_addRadioButton); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp index e88a593786..e0819c16db 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp @@ -600,6 +600,13 @@ int register_all_cocos2dx_ui(lua_State* tolua_S); + + + + + + + From a7820c1eef7d8bf64c59144399c2567ef4e38ef3 Mon Sep 17 00:00:00 2001 From: fusijie Date: Mon, 24 Aug 2015 18:19:28 +0800 Subject: [PATCH 066/118] fix shaderTest draw twice. --- tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp | 11 ----------- tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp | 14 +++++++++++++- tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h | 2 ++ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp index bdbd3b992f..71e07258a9 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp @@ -143,7 +143,6 @@ void ShaderNode::onDraw(const Mat4 &transform, uint32_t flags) ShaderMonjori::ShaderMonjori() { - init(); } bool ShaderMonjori::init() @@ -177,7 +176,6 @@ std::string ShaderMonjori::subtitle() const /// ShaderMandelbrot ShaderMandelbrot::ShaderMandelbrot() { - init(); } bool ShaderMandelbrot::init() @@ -211,7 +209,6 @@ std::string ShaderMandelbrot::subtitle() const /// ShaderJulia ShaderJulia::ShaderJulia() { - init(); } bool ShaderJulia::init() @@ -246,7 +243,6 @@ std::string ShaderJulia::subtitle() const /// ShaderHeart ShaderHeart::ShaderHeart() { - init(); } bool ShaderHeart::init() @@ -279,7 +275,6 @@ std::string ShaderHeart::subtitle() const /// ShaderFlower ShaderFlower::ShaderFlower() { - init(); } bool ShaderFlower::init() @@ -312,7 +307,6 @@ std::string ShaderFlower::subtitle() const /// ShaderPlasma ShaderPlasma::ShaderPlasma() { - init(); } bool ShaderPlasma::init() @@ -440,7 +434,6 @@ void SpriteBlur::setBlurSampleNum(float num) ShaderBlur::ShaderBlur() { - init(); } std::string ShaderBlur::title() const @@ -540,7 +533,6 @@ ShaderRetroEffect::ShaderRetroEffect() : _label(nullptr) , _accum(0.0f) { - init(); } bool ShaderRetroEffect::init() @@ -600,7 +592,6 @@ std::string ShaderRetroEffect::subtitle() const ShaderLensFlare::ShaderLensFlare() { - init(); } std::string ShaderLensFlare::title() const @@ -635,7 +626,6 @@ bool ShaderLensFlare::init() // ShaderGlow::ShaderGlow() { - init(); } std::string ShaderGlow::title() const @@ -670,7 +660,6 @@ bool ShaderGlow::init() // ShaderMultiTexture::ShaderMultiTexture():_changedTextureId(0) { - init(); } std::string ShaderMultiTexture::title() const diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index 69c7c96937..03bc8abe48 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -444,6 +444,10 @@ void EffectNormalMapped::setLightColor(const Color4F& color) } EffectSpriteTest::EffectSpriteTest() +{ +} + +bool EffectSpriteTest::init() { if (ShaderTestDemo2::init()) { @@ -503,11 +507,17 @@ EffectSpriteTest::EffectSpriteTest() // _sprite->addEffect( _effects.at(8), -10 ); // _sprite->addEffect( _effects.at(1), 1 ); - + + return true; } + return false; } EffectSpriteLamp::EffectSpriteLamp() +{ +} + +bool EffectSpriteLamp::init() { if (ShaderTestDemo2::init()) { @@ -535,7 +545,9 @@ EffectSpriteLamp::EffectSpriteLamp() listerner->onTouchesMoved = CC_CALLBACK_2(EffectSpriteLamp::onTouchesMoved, this); listerner->onTouchesEnded = CC_CALLBACK_2(EffectSpriteLamp::onTouchesEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listerner, this); + return true; } + return false; } diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h index 06bdb867c6..3dbc94517f 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h @@ -40,6 +40,7 @@ class EffectSpriteTest : public ShaderTestDemo2 public: CREATE_FUNC(EffectSpriteTest); EffectSpriteTest(); + virtual bool init(); virtual std::string subtitle() const {return "Different effects on Sprite";} protected: @@ -53,6 +54,7 @@ class EffectSpriteLamp : public ShaderTestDemo2 public: CREATE_FUNC(EffectSpriteLamp); EffectSpriteLamp(); + virtual bool init(); virtual std::string subtitle() const {return "Sprite Lamp effects";} //callback public: From 43687bf7a0cc4c8fcbc2ef4b3d3de81ce12e33db Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Mon, 24 Aug 2015 03:45:55 -0700 Subject: [PATCH 067/118] moved CCTextureCube from 3D to renderer --- cocos/2d/libcocos2d_win10/libcocos2d.vcxproj | 4 ++-- cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj index ab039d32fd..ff127810f2 100644 --- a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj @@ -285,7 +285,6 @@ - NotUsing @@ -621,6 +620,7 @@ + @@ -942,7 +942,6 @@ - @@ -1220,6 +1219,7 @@ + diff --git a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters index 673a6eb1c0..ecf6c1b2d4 100644 --- a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters @@ -534,9 +534,6 @@ 3d - - 3d - base @@ -1942,6 +1939,9 @@ 2d + + renderer +
@@ -2219,9 +2219,6 @@ 3d - - 3d - 3d @@ -3794,6 +3791,9 @@ 2d + + renderer + From a6412e431dd86237b71268e4791e74625955fb2a Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Tue, 25 Aug 2015 10:28:18 +0800 Subject: [PATCH 068/118] [cpp-tests]Fixed title of test cases. --- tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp | 2 +- tests/cpp-tests/Classes/controller.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp index 71e07258a9..2637e1ccab 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp @@ -601,7 +601,7 @@ std::string ShaderLensFlare::title() const std::string ShaderLensFlare::subtitle() const { - return "Lens Flare "; + return "Lens Flare"; } bool ShaderLensFlare::init() diff --git a/tests/cpp-tests/Classes/controller.cpp b/tests/cpp-tests/Classes/controller.cpp index 0a0466839c..c18faa8e07 100644 --- a/tests/cpp-tests/Classes/controller.cpp +++ b/tests/cpp-tests/Classes/controller.cpp @@ -90,7 +90,7 @@ public: addTest("Renderer", []() { return new NewRendererTests(); }); addTest("ReleasePool", [](){ return new ReleasePoolTests(); }); addTest("Rotate World", [](){return new RotateWorldTests(); }); - addTest("Scheduler", [](){return new SchedulerTests(); });//!!!!!! + addTest("Scheduler", [](){return new SchedulerTests(); }); addTest("Shader - Basic", []() { return new ShaderTests(); }); addTest("Shader - Sprite", []() { return new Shader2Tests(); }); addTest("Texture2D", [](){return new Texture2DTests(); }); @@ -232,6 +232,7 @@ void TestController::traverseTestSuite(TestSuite* testSuite) logEx("%s%sBegin traverse TestSuite:%s", LOG_TAG, _logIndentation.c_str(), testSuite->getTestName().c_str()); _logIndentation += LOG_INDENTATION; + testSuite->_currTestIndex = -1; auto logIndentation = _logIndentation; for (auto& callback : testSuite->_testCallbacks) @@ -243,6 +244,7 @@ void TestController::traverseTestSuite(TestSuite* testSuite) TransitionScene* transitionScene = nullptr; if (_stopAutoTest) break; + while (_isRunInBackground) { logEx("_director is paused"); @@ -269,6 +271,7 @@ void TestController::traverseTestSuite(TestSuite* testSuite) testCase = (TestCase*)scene; testCaseDuration = testCase->getDuration(); } + testSuite->_currTestIndex++; testCase->setTestSuite(testSuite); testCase->setTestCaseName(testName); _director->replaceScene(scene); From 650a5c2318552c301034bbff6cb005356ece7bd3 Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 25 Aug 2015 13:20:19 +0800 Subject: [PATCH 069/118] update reader with new skybox --- .../GameNode3DReader/GameNode3DReader.cpp | 24 ++++++++------- .../GameNode3DReader/GameNode3DReader.h | 2 ++ .../UserCameraReader/UserCameraReader.cpp | 29 ++++++++++++------- 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.cpp index c96c61a550..22f47b916e 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.cpp @@ -62,6 +62,11 @@ namespace cocostudio return _instanceNode3DReader; } + static CameraBackgroundSkyBoxBrush* _sceneBrushInstance = nullptr; + CameraBackgroundSkyBoxBrush* GameNode3DReader::getSceneBrushInstance() + { + return _sceneBrushInstance; + } void GameNode3DReader::purge() { @@ -376,6 +381,7 @@ namespace cocostudio std::string name = options->name()->c_str(); node->setName(name); + _sceneBrushInstance = nullptr; bool skyBoxEnabled = options->skyBoxEnabled() != 0; if (skyBoxEnabled) { @@ -387,19 +393,15 @@ namespace cocostudio std::string backFileData = options->backFileData()->path()->c_str(); FileUtils *fileUtils = FileUtils::getInstance(); - if (!fileUtils->isFileExist(leftFileData) - || !fileUtils->isFileExist(rightFileData) - || !fileUtils->isFileExist(upFileData) - || !fileUtils->isFileExist(downFileData) - || !fileUtils->isFileExist(forwardFileData) - || !fileUtils->isFileExist(backFileData)) + if (fileUtils->isFileExist(leftFileData) + && fileUtils->isFileExist(rightFileData) + && fileUtils->isFileExist(upFileData) + && fileUtils->isFileExist(downFileData) + && fileUtils->isFileExist(forwardFileData) + && fileUtils->isFileExist(backFileData)) { - return; + _sceneBrushInstance = CameraBackgroundSkyBoxBrush::create(leftFileData, rightFileData, upFileData, downFileData, forwardFileData, backFileData); } - Skybox* childBox = Skybox::create(leftFileData,rightFileData,upFileData,downFileData,forwardFileData,backFileData); - unsigned short cameraFlag = 1 << 10; - childBox->setCameraMask(cameraFlag); - node->addChild(childBox,0,"_innerSkyBox"); } std::string customProperty = options->customProperty()->c_str(); diff --git a/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.h b/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.h index 3be6710f57..b32ec1249f 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.h @@ -26,6 +26,7 @@ #define __cocos2d_libs__GameNode3DReader__ #include "cocos2d.h" +#include "2d/CCCameraBackgroundBrush.h" #include "cocostudio/CocosStudioExport.h" #include "cocostudio/WidgetReader/NodeReaderProtocol.h" #include "cocostudio/WidgetReader/NodeReaderDefine.h" @@ -46,6 +47,7 @@ namespace cocostudio ~GameNode3DReader(); static GameNode3DReader* getInstance(); + static cocos2d::CameraBackgroundSkyBoxBrush* getSceneBrushInstance(); /** @deprecated Use method destroyInstance() instead */ CC_DEPRECATED_ATTRIBUTE static void purge(); static void destroyInstance(); diff --git a/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp index b6e67c5f26..64c85d0aa4 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp @@ -28,6 +28,7 @@ #include "cocostudio/CSParse3DBinary_generated.h" #include "cocostudio/FlatBuffersSerialize.h" #include "cocostudio/WidgetReader/Node3DReader/Node3DReader.h" +#include "cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.h" #include "tinyxml2.h" #include "flatbuffers/flatbuffers.h" @@ -431,18 +432,26 @@ namespace cocostudio std::string backFileData = options->backFileData()->path()->c_str(); FileUtils *fileUtils = FileUtils::getInstance(); - if (!fileUtils->isFileExist(leftFileData) - || !fileUtils->isFileExist(rightFileData) - || !fileUtils->isFileExist(upFileData) - || !fileUtils->isFileExist(downFileData) - || !fileUtils->isFileExist(forwardFileData) - || !fileUtils->isFileExist(backFileData)) + if (fileUtils->isFileExist(leftFileData) + && fileUtils->isFileExist(rightFileData) + && fileUtils->isFileExist(upFileData) + && fileUtils->isFileExist(downFileData) + && fileUtils->isFileExist(forwardFileData) + && fileUtils->isFileExist(backFileData)) { - return; + CameraBackgroundSkyBoxBrush* brush = CameraBackgroundSkyBoxBrush::create(leftFileData, rightFileData, upFileData, downFileData, forwardFileData, backFileData); + camera->setBackgroundBrush(brush); } - Skybox* childBox = Skybox::create(leftFileData, rightFileData, upFileData, downFileData, forwardFileData, backFileData); - childBox->setCameraMask(cameraFlag); - node->addChild(childBox, 0, "_innerSkyBox"); + else + { + if (GameNode3DReader::getSceneBrushInstance() != nullptr) + camera->setBackgroundBrush(GameNode3DReader::getSceneBrushInstance()); + } + } + else + { + if (GameNode3DReader::getSceneBrushInstance() != nullptr) + camera->setBackgroundBrush(GameNode3DReader::getSceneBrushInstance()); } } From 7884138dccc27adef0591da3577e9f7f3bc3ab7a Mon Sep 17 00:00:00 2001 From: yangxiao Date: Tue, 25 Aug 2015 14:32:25 +0800 Subject: [PATCH 070/118] disable blend when drawing skybox --- cocos/2d/CCCameraBackgroundBrush.cpp | 3 +++ cocos/3d/CCSkybox.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/cocos/2d/CCCameraBackgroundBrush.cpp b/cocos/2d/CCCameraBackgroundBrush.cpp index 302186c4ef..9d757abee0 100644 --- a/cocos/2d/CCCameraBackgroundBrush.cpp +++ b/cocos/2d/CCCameraBackgroundBrush.cpp @@ -317,6 +317,9 @@ void CameraBackgroundSkyBoxBrush::drawBackground(Camera* camera) glCullFace(GL_BACK); RenderState::StateBlock::_defaultState->setCullFaceSide(RenderState::CULL_FACE_SIDE_BACK); + glDisable(GL_BLEND); + RenderState::StateBlock::_defaultState->setBlend(false); + if (Configuration::getInstance()->supportsShareableVAO()) { GL::bindVAO(_vao); diff --git a/cocos/3d/CCSkybox.cpp b/cocos/3d/CCSkybox.cpp index 06e1b7c061..197358a56b 100644 --- a/cocos/3d/CCSkybox.cpp +++ b/cocos/3d/CCSkybox.cpp @@ -177,6 +177,9 @@ void Skybox::onDraw(const Mat4& transform, uint32_t flags) glCullFace(GL_BACK); RenderState::StateBlock::_defaultState->setCullFaceSide(RenderState::CULL_FACE_SIDE_BACK); + + glDisable(GL_BLEND); + RenderState::StateBlock::_defaultState->setBlend(false); if (Configuration::getInstance()->supportsShareableVAO()) { From 19901c43ea1b7a911e1a829e73946afffbf8fc50 Mon Sep 17 00:00:00 2001 From: fusijie Date: Tue, 25 Aug 2015 14:39:17 +0800 Subject: [PATCH 071/118] fix spriteblur crash foreground. --- tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp index 2637e1ccab..c3854e8992 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp @@ -380,7 +380,6 @@ bool SpriteBlur::initWithTexture(Texture2D* texture, const Rect& rect) { #if CC_ENABLE_CACHE_TEXTURE_DATA auto listener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom* event){ - setGLProgram(nullptr); initGLProgram(); }); From 65b78d4a490a54d21b7be047746804af40a1defa Mon Sep 17 00:00:00 2001 From: andyque Date: Tue, 25 Aug 2015 15:15:18 +0800 Subject: [PATCH 072/118] fix ListView innerContainer initial position error --- cocos/ui/UIScrollView.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index 401e4a8552..a72902411c 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -178,18 +178,20 @@ void ScrollView::setInnerContainerSize(const Size &size) // move children appropriately { - float offsetY = originalInnerSize.height - innerSizeHeight; + Size newInnerSize = _innerContainer->getContentSize(); + float offsetY = originalInnerSize.height - newInnerSize.height; float offsetX = 0; if (_innerContainer->getRightBoundary() <= _contentSize.width) { - offsetX = originalInnerSize.width - innerSizeWidth; + offsetX = originalInnerSize.width - newInnerSize.width; } if(offsetX != 0 || offsetY != 0) { - setInnerContainerPosition(Vec2(offsetX, offsetY)); + Vec2 position = _innerContainer->getPosition() + Vec2(offsetX, offsetY); + setInnerContainerPosition(position); } } - + // Calculate and set the position of the inner container. Vec2 pos = _innerContainer->getPosition(); From c998639c30c6078a1be4a23793367f7a574d83ca Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 25 Aug 2015 15:18:09 +0800 Subject: [PATCH 073/118] update interface for gamenode3d --- .../WidgetReader/GameNode3DReader/GameNode3DReader.cpp | 4 ++-- .../WidgetReader/GameNode3DReader/GameNode3DReader.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.cpp index 22f47b916e..aeeddc3cb6 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.cpp @@ -62,8 +62,8 @@ namespace cocostudio return _instanceNode3DReader; } - static CameraBackgroundSkyBoxBrush* _sceneBrushInstance = nullptr; - CameraBackgroundSkyBoxBrush* GameNode3DReader::getSceneBrushInstance() + static CameraBackgroundBrush* _sceneBrushInstance = nullptr; + CameraBackgroundBrush* GameNode3DReader::getSceneBrushInstance() { return _sceneBrushInstance; } diff --git a/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.h b/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.h index b32ec1249f..72ed03e1ca 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.h @@ -47,7 +47,7 @@ namespace cocostudio ~GameNode3DReader(); static GameNode3DReader* getInstance(); - static cocos2d::CameraBackgroundSkyBoxBrush* getSceneBrushInstance(); + static cocos2d::CameraBackgroundBrush* getSceneBrushInstance(); /** @deprecated Use method destroyInstance() instead */ CC_DEPRECATED_ATTRIBUTE static void purge(); static void destroyInstance(); From d6ed3b417cb63afadc30952fb1df98fb97c98f6d Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Tue, 25 Aug 2015 17:50:47 +0800 Subject: [PATCH 074/118] [cpp-tests]Refine test cases about label --- tests/cpp-tests/Classes/BaseTest.cpp | 1 + .../Classes/LabelTest/LabelTestNew.cpp | 296 ++++++------------ .../Classes/LabelTest/LabelTestNew.h | 45 --- 3 files changed, 98 insertions(+), 244 deletions(-) diff --git a/tests/cpp-tests/Classes/BaseTest.cpp b/tests/cpp-tests/Classes/BaseTest.cpp index e37514fd62..0f8e197100 100644 --- a/tests/cpp-tests/Classes/BaseTest.cpp +++ b/tests/cpp-tests/Classes/BaseTest.cpp @@ -401,6 +401,7 @@ bool TestCase::init() ttfConfig.fontSize = 16; _subtitleLabel = Label::createWithTTF(ttfConfig, subtitle()); + _subtitleLabel->setMaxLineWidth(VisibleRect::getVisibleRect().size.width); addChild(_subtitleLabel, 9999); _subtitleLabel->setPosition(VisibleRect::center().x, VisibleRect::top().y - 60); diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp index 9475ecef15..effdf3d436 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp +++ b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp @@ -34,91 +34,62 @@ enum { NewLabelTests::NewLabelTests() { - ADD_TEST_CASE(LabelFNTColorAndOpacity); - ADD_TEST_CASE(LabelFNTSpriteActions); - ADD_TEST_CASE(LabelFNTPadding); - ADD_TEST_CASE(LabelFNTOffset); + ADD_TEST_CASE(LabelFNTGlyphDesigner); ADD_TEST_CASE(LabelFNTColor); ADD_TEST_CASE(LabelFNTOpacity); - ADD_TEST_CASE(LabelFNTHundredLabels); + ADD_TEST_CASE(LabelFNTColorAndOpacity); + ADD_TEST_CASE(LabelFNTSpriteActions); ADD_TEST_CASE(LabelFNTMultiLine); - ADD_TEST_CASE(LabelFNTandTTFEmpty); ADD_TEST_CASE(LabelFNTRetina); - ADD_TEST_CASE(LabelFNTGlyphDesigner); - ADD_TEST_CASE(LabelTTFUnicodeChinese); - ADD_TEST_CASE(LabelFNTUnicodeChinese); ADD_TEST_CASE(LabelFNTMultiLineAlignment); ADD_TEST_CASE(LabelFNTUNICODELanguages); - ADD_TEST_CASE(LabelTTFAlignmentNew); ADD_TEST_CASE(LabelFNTBounds); - ADD_TEST_CASE(LabelTTFLongLineWrapping); - ADD_TEST_CASE(LabelTTFColor); + ADD_TEST_CASE(LabelFNTandTTFEmpty); + ADD_TEST_CASE(LabelFNTHundredLabels); + ADD_TEST_CASE(LabelFNTPadding); + ADD_TEST_CASE(LabelFNTOffset); + ADD_TEST_CASE(LabelTTFFontsTestNew); - ADD_TEST_CASE(LabelTTFDynamicAlignment); + ADD_TEST_CASE(LabelTTFLongLineWrapping); ADD_TEST_CASE(LabelTTFCJKWrappingTest); + ADD_TEST_CASE(LabelTTFColor); + ADD_TEST_CASE(LabelTTFDynamicAlignment); + ADD_TEST_CASE(LabelAlignmentTest); ADD_TEST_CASE(LabelTTFUnicodeNew); - ADD_TEST_CASE(LabelBMFontTestNew); ADD_TEST_CASE(LabelTTFDistanceField); ADD_TEST_CASE(LabelOutlineAndGlowTest); + ADD_TEST_CASE(LabelMultilineWithOutline); ADD_TEST_CASE(LabelShadowTest); - ADD_TEST_CASE(LabelCharMapTest); - ADD_TEST_CASE(LabelCharMapColorTest); - ADD_TEST_CASE(LabelCrashTest); - ADD_TEST_CASE(LabelTTFOldNew); - ADD_TEST_CASE(LabelFontNameTest); - ADD_TEST_CASE(LabelAlignmentTest); - ADD_TEST_CASE(LabelIssue4428Test); - ADD_TEST_CASE(LabelIssue4999Test); ADD_TEST_CASE(LabelLineHeightTest); ADD_TEST_CASE(LabelAdditionalKerningTest); - ADD_TEST_CASE(LabelIssue8492Test); - ADD_TEST_CASE(LabelMultilineWithOutline); - ADD_TEST_CASE(LabelIssue9255Test); + ADD_TEST_CASE(LabelAddChildTest); + ADD_TEST_CASE(LabelFullTypeFontTest); ADD_TEST_CASE(LabelSmallDimensionsTest); - ADD_TEST_CASE(LabelIssue10089Test); + + ADD_TEST_CASE(LabelCharMapTest); + ADD_TEST_CASE(LabelCharMapColorTest); + ADD_TEST_CASE(LabelSystemFontColor); + ADD_TEST_CASE(LabelTTFOldNew); + ADD_TEST_CASE(LabelFontNameTest); + + ADD_TEST_CASE(LabelCrashTest); + ADD_TEST_CASE(LabelIssue12775Test); + ADD_TEST_CASE(LabelIssue11585Test); ADD_TEST_CASE(LabelIssue10773Test); ADD_TEST_CASE(LabelIssue11576Test); ADD_TEST_CASE(LabelIssue11699Test); ADD_TEST_CASE(LabelIssue12409Test); - ADD_TEST_CASE(LabelAddChildTest); - ADD_TEST_CASE(LabelIssue12775Test); - ADD_TEST_CASE(LabelIssue11585Test); - ADD_TEST_CASE(LabelFullTypeFontTest); + ADD_TEST_CASE(LabelIssue10089Test); + ADD_TEST_CASE(LabelIssue9255Test); + ADD_TEST_CASE(LabelIssue8492Test); + ADD_TEST_CASE(LabelIssue4428Test); + ADD_TEST_CASE(LabelIssue4999Test); ADD_TEST_CASE(LabelIssue10688Test); ADD_TEST_CASE(LabelIssue13202Test); ADD_TEST_CASE(LabelIssue9500Test); }; -LabelTTFAlignmentNew::LabelTTFAlignmentNew() -{ - auto s = Director::getInstance()->getWinSize(); - - TTFConfig config("fonts/tahoma.ttf",16); - - auto ttf0 = Label::createWithTTF(config,"Alignment 0\nnew line",TextHAlignment::LEFT); - ttf0->setPosition(Vec2(s.width/2,(s.height/6)*2 - 30)); - this->addChild(ttf0); - - auto ttf1 = Label::createWithTTF(config,"Alignment 1\nnew line",TextHAlignment::CENTER); - ttf1->setPosition(Vec2(s.width/2,(s.height/6)*3 - 30)); - this->addChild(ttf1); - - auto ttf2 = Label::createWithTTF(config,"Alignment 2\nnew line",TextHAlignment::RIGHT); - ttf2->setPosition(Vec2(s.width/2,(s.height/6)*4 - 30)); - this->addChild(ttf2); -} - -std::string LabelTTFAlignmentNew::title() const -{ - return "New Label + TTF"; -} - -std::string LabelTTFAlignmentNew::subtitle() const -{ - return "Tests alignment values"; -} - LabelFNTColorAndOpacity::LabelFNTColorAndOpacity() { _time = 0; @@ -174,12 +145,12 @@ void LabelFNTColorAndOpacity::step(float dt) std::string LabelFNTColorAndOpacity::title() const { - return "New Label + .FNT file"; + return "New Label + Bitmap font"; } std::string LabelFNTColorAndOpacity::subtitle() const { - return "Testing opacity + tint"; + return "Testing fade/tint action"; } LabelFNTSpriteActions::LabelFNTSpriteActions() @@ -249,12 +220,12 @@ void LabelFNTSpriteActions::step(float dt) std::string LabelFNTSpriteActions::title() const { - return "New Label + .FNT file"; + return "New Label + Bitmap font"; } std::string LabelFNTSpriteActions::subtitle() const { - return "Using fonts as Sprite objects. Some characters should rotate."; + return "Testing run action on the specified character"; } LabelFNTPadding::LabelFNTPadding() @@ -269,7 +240,7 @@ LabelFNTPadding::LabelFNTPadding() std::string LabelFNTPadding::title() const { - return "New Label + .FNT file"; + return "New Label + Bitmap font"; } std::string LabelFNTPadding::subtitle() const @@ -297,7 +268,7 @@ LabelFNTOffset::LabelFNTOffset() std::string LabelFNTOffset::title() const { - return "New Label + .FNT file"; + return "New Label + Bitmap font"; } std::string LabelFNTOffset::subtitle() const @@ -307,29 +278,28 @@ std::string LabelFNTOffset::subtitle() const LabelFNTColor::LabelFNTColor() { - auto s = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); - Label* label = nullptr; - label = Label::createWithBMFont("fonts/bitmapFontTest5.fnt", "Blue"); + auto label = Label::createWithBMFont("fonts/bitmapFontTest5.fnt", "Blue"); label->setColor( Color3B::BLUE ); addChild(label); - label->setPosition( Vec2(s.width/2, s.height/4) ); + label->setPosition(winSize.width / 2, winSize.height * 0.7f); label = Label::createWithBMFont("fonts/bitmapFontTest5.fnt", "Red"); addChild(label); - label->setPosition( Vec2(s.width/2, 2*s.height/4) ); + label->setPosition(winSize.width / 2, winSize.height * 0.5f); label->setColor( Color3B::RED ); label = Label::createWithBMFont("fonts/bitmapFontTest5.fnt", "Green"); addChild(label); - label->setPosition( Vec2(s.width/2, 3*s.height/4) ); + label->setPosition(winSize.width / 2, winSize.height * 0.3f); label->setColor( Color3B::GREEN ); label->setString("Green"); } std::string LabelFNTColor::title() const { - return "New Label + .FNT file"; + return "New Label + Bitmap font"; } std::string LabelFNTColor::subtitle() const @@ -339,22 +309,22 @@ std::string LabelFNTColor::subtitle() const LabelFNTOpacity::LabelFNTOpacity() { - auto s = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); auto label = Label::createWithBMFont("fonts/bitmapFontTest5.fnt", "Opacity 100"); label->setOpacity(100); addChild(label); - label->setPosition(Vec2(s.width / 2, s.height / 2)); + label->setPosition(winSize.width / 2, winSize.height * 0.6f); label = Label::createWithBMFont("fonts/bitmapFontTest5.fnt", "Opacity 200"); label->setOpacity(200); addChild(label); - label->setPosition(Vec2(s.width / 2, s.height / 3)); + label->setPosition(winSize.width / 2, winSize.height * 0.4f); } std::string LabelFNTOpacity::title() const { - return "New Label + .FNT file"; + return "New Label + Bitmap font"; } std::string LabelFNTOpacity::subtitle() const @@ -381,7 +351,7 @@ LabelFNTHundredLabels::LabelFNTHundredLabels() std::string LabelFNTHundredLabels::title() const { - return "New Label + .FNT file"; + return "New Label + Bitmap font"; } std::string LabelFNTHundredLabels::subtitle() const @@ -424,7 +394,7 @@ LabelFNTMultiLine::LabelFNTMultiLine() std::string LabelFNTMultiLine::title() const { - return "New Label + .FNT file"; + return "New Label + Bitmap font"; } std::string LabelFNTMultiLine::subtitle() const @@ -482,12 +452,12 @@ void LabelFNTandTTFEmpty::updateStrings(float dt) std::string LabelFNTandTTFEmpty::title() const { - return "New Label : .FNT file & .TTF file"; + return "New Label + FNT/TTF/CharMap"; } std::string LabelFNTandTTFEmpty::subtitle() const { - return "3 empty labels: new Label + FNT/TTF/CharMap"; + return "Testing empty string."; } LabelFNTRetina::LabelFNTRetina() @@ -502,7 +472,7 @@ LabelFNTRetina::LabelFNTRetina() std::string LabelFNTRetina::title() const { - return "New Label + .FNT file"; + return "New Label + Bitmap font"; } std::string LabelFNTRetina::subtitle() const @@ -512,70 +482,30 @@ std::string LabelFNTRetina::subtitle() const LabelFNTGlyphDesigner::LabelFNTGlyphDesigner() { - auto s = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); auto layer = LayerColor::create(Color4B(128,128,128,255)); addChild(layer, -10); - // LabelBMFont auto label1 = Label::createWithBMFont("fonts/futura-48.fnt", "Testing Glyph Designer"); addChild(label1); - label1->setPosition(Vec2(s.width/2, s.height/2)); + label1->setPosition(Vec2(winSize.width / 2, winSize.height * 0.4f)); + + auto label2 = Label::createWithBMFont("fonts/bitmapFontTest2.fnt", "Hello World"); + label2->setPosition(Vec2(winSize.width / 2, winSize.height * 0.6f)); + addChild(label2); } std::string LabelFNTGlyphDesigner::title() const { - return "New Label + .FNT file"; + return "New Label + Bitmap font"; } std::string LabelFNTGlyphDesigner::subtitle() const { - return "Testing Glyph Designer: you should see a font with shawdows and outline"; + return "Testing Glyph Designer"; } -LabelTTFUnicodeChinese::LabelTTFUnicodeChinese() -{ - auto size = Director::getInstance()->getWinSize(); - // Adding "å•Š" letter at the end of string to make VS2012 happy, otherwise VS will generate errors - // like "Error 3 error C2146: syntax error : missing ')' before identifier 'label'"; - TTFConfig ttfConfig("fonts/HKYuanMini.ttf",28,GlyphCollection::CUSTOM, "美好的一天啊"); - auto label = Label::createWithTTF(ttfConfig,"美好的一天啊", TextHAlignment::CENTER, size.width); - - if(label) { - label->setPosition(Vec2(size.width / 2, size.height /2)); - this->addChild(label); - } -} - -std::string LabelTTFUnicodeChinese::title() const -{ - return "New Label + .TTF file Chinese"; -} - -std::string LabelTTFUnicodeChinese::subtitle() const -{ - return "Testing new Label + TTF with Chinese character"; -} - -LabelFNTUnicodeChinese::LabelFNTUnicodeChinese() -{ - auto size = Director::getInstance()->getWinSize(); - auto label = Label::createWithBMFont("fonts/bitmapFontChinese.fnt", "中国"); - label->setPosition(Vec2(size.width / 2, size.height /2)); - this->addChild(label); -} - -std::string LabelFNTUnicodeChinese::title() const -{ - return "New Label + .FNT file Chinese"; -} - -std::string LabelFNTUnicodeChinese::subtitle() const -{ - return "Testing new Label + FNT with Chinese character"; -} - - /// BitmapFontMultiLineAlignmentNew #define LongSentencesExample "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." @@ -809,12 +739,12 @@ LabelFNTUNICODELanguages::LabelFNTUNICODELanguages() std::string LabelFNTUNICODELanguages::title() const { - return "New Label + .FNT + UNICODE"; + return "New Label + Bitmap font"; } std::string LabelFNTUNICODELanguages::subtitle() const { - return "You should see 4 differnt labels:\nIn Spanish, Chinese, Russian and Japanese"; + return "Testing Unicode.You should see 4 different labels:In Spanish, Chinese, Russian and Japanese"; } LabelFNTBounds::LabelFNTBounds() @@ -849,12 +779,12 @@ LabelFNTBounds::LabelFNTBounds() std::string LabelFNTBounds::title() const { - return "New Label + .FNT + Bounds"; + return "New Label + Bitmap font"; } std::string LabelFNTBounds::subtitle() const { - return "You should see string enclosed by a box"; + return "Testing bounding-box"; } LabelTTFLongLineWrapping::LabelTTFLongLineWrapping() @@ -876,7 +806,7 @@ std::string LabelTTFLongLineWrapping::title() const std::string LabelTTFLongLineWrapping::subtitle() const { - return "Uses the new Label with TTF. Testing auto-wrapping"; + return "Testing auto-wrapping"; } LabelTTFColor::LabelTTFColor() @@ -886,19 +816,19 @@ LabelTTFColor::LabelTTFColor() TTFConfig ttfConfig("fonts/arial.ttf", 18); // Green auto label1 = Label::createWithTTF(ttfConfig,"Green", TextHAlignment::CENTER, size.width); - label1->setPosition( Vec2(size.width/2, size.height * 0.3f) ); + label1->setPosition(size.width/2, size.height * 0.5f); label1->setTextColor( Color4B::GREEN ); addChild(label1); // Red auto label2 = Label::createWithTTF(ttfConfig,"Red", TextHAlignment::CENTER, size.width); - label2->setPosition( Vec2(size.width/2, size.height * 0.4f) ); + label2->setPosition(size.width/2, size.height * 0.65f); label2->setTextColor( Color4B::RED ); addChild(label2); // Blue auto label3 = Label::createWithTTF(ttfConfig,"Blue", TextHAlignment::CENTER, size.width); - label3->setPosition( Vec2(size.width/2, size.height * 0.5f) ); + label3->setPosition(size.width/2, size.height * 0.35f); label3->setTextColor( Color4B::BLUE ); addChild(label3); } @@ -910,27 +840,27 @@ std::string LabelTTFColor::title() const std::string LabelTTFColor::subtitle() const { - return "Uses the new Label with TTF. Testing Color"; + return "Testing Color"; } LabelTTFDynamicAlignment::LabelTTFDynamicAlignment() { - auto size = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); + TTFConfig ttfConfig("fonts/arial.ttf", 23); - _label = Label::createWithTTF(ttfConfig,LongSentencesExample, TextHAlignment::CENTER, size.width); - _label->setPosition( Vec2(size.width/2, size.height/2) ); - + _label = Label::createWithTTF(ttfConfig, LongSentencesExample, TextHAlignment::CENTER, winSize.width); + _label->setPosition(winSize.width / 2, winSize.height / 2); + addChild(_label); + auto menu = Menu::create( MenuItemFont::create("Left", CC_CALLBACK_1(LabelTTFDynamicAlignment::setAlignmentLeft, this)), MenuItemFont::create("Center", CC_CALLBACK_1(LabelTTFDynamicAlignment::setAlignmentCenter, this)), MenuItemFont::create("Right", CC_CALLBACK_1(LabelTTFDynamicAlignment::setAlignmentRight, this)), nullptr); - menu->alignItemsVerticallyWithPadding(4); - menu->setPosition(Vec2(50, size.height / 4 )); - - addChild(_label); - this->addChild(menu); + menu->alignItemsHorizontallyWithPadding(20); + menu->setPosition(winSize.width / 2, winSize.height * 0.25f); + addChild(menu); } void LabelTTFDynamicAlignment::updateAlignment() @@ -966,7 +896,7 @@ std::string LabelTTFDynamicAlignment::title() const std::string LabelTTFDynamicAlignment::subtitle() const { - return "Uses the new Label with TTF. Testing alignment"; + return "Testing text alignment"; } // @@ -1033,36 +963,22 @@ LabelTTFUnicodeNew::LabelTTFUnicodeNew() { auto strings = FileUtils::getInstance()->getValueMapFromFile("fonts/strings.xml"); std::string chinese = strings["chinese1"].asString(); - -// std::string russian = strings["russian"].asString(); -// std::string spanish = strings["spanish"].asString(); -// std::string japanese = strings["japanese"].asString(); - - auto size = Director::getInstance()->getWinSize(); - - float vStep = size.height/9; - float vSize = size.height; - - TTFConfig ttfConfig("fonts/arial.ttf", 23,GlyphCollection::ASCII); + auto winSize = Director::getInstance()->getWinSize(); + // Spanish - auto label1 = Label::createWithTTF(ttfConfig,"Buen día, ¿cómo te llamas?", TextHAlignment::CENTER, size.width); - label1->setPosition( Vec2(size.width/2, vSize - (vStep * 4.5)) ); + auto label1 = Label::createWithTTF("Buen día, ¿cómo te llamas?", "fonts/arial.ttf", 23); + label1->setPosition(winSize.width / 2, winSize.height * 0.65f); addChild(label1); // German - auto label2 = Label::createWithTTF(ttfConfig,"In welcher Straße haben Sie gelebt?", TextHAlignment::CENTER,size.width); - label2->setPosition( Vec2(size.width/2, vSize - (vStep * 5.5)) ); + auto label2 = Label::createWithTTF("In welcher Straße haben Sie gelebt?", "fonts/arial.ttf", 23); + label2->setPosition(winSize.width / 2, winSize.height * 0.5f); addChild(label2); - // chinese - ttfConfig.fontFilePath = "fonts/HKYuanMini.ttf"; - ttfConfig.glyphs = GlyphCollection::CUSTOM; - ttfConfig.customGlyphs = chinese.c_str(); - auto label3 = Label::createWithTTF(ttfConfig,chinese, TextHAlignment::CENTER,size.width); - if(label3) { - label3->setPosition( Vec2(size.width/2, vSize - (vStep * 6.5)) ); - addChild(label3); - } + // Chinese + auto label3 = Label::createWithTTF(chinese, "fonts/HKYuanMini.ttf", 24); + label3->setPosition(winSize.width / 2, winSize.height * 0.35f); + addChild(label3); } std::string LabelTTFUnicodeNew::title() const @@ -1086,15 +1002,16 @@ LabelTTFFontsTestNew::LabelTTFFontsTestNew() "fonts/Schwarzwald.ttf", "fonts/Scissor Cuts.ttf", }; -#define arraysize(ar) (sizeof(ar) / sizeof(ar[0])) + int fontCount = sizeof(ttfpaths) / sizeof(ttfpaths[0]); auto size = Director::getInstance()->getWinSize(); TTFConfig ttfConfig(ttfpaths[0],20, GlyphCollection::NEHE); - for(size_t i=0;i < arraysize(ttfpaths); ++i) { + + for (size_t i = 0; i < fontCount; ++i) { ttfConfig.fontFilePath = ttfpaths[i]; auto label = Label::createWithTTF(ttfConfig, ttfpaths[i], TextHAlignment::CENTER,0); if( label ) { - label->setPosition( Vec2(size.width/2, ((size.height * 0.6)/arraysize(ttfpaths) * i) + (size.height/5))); + label->setPosition(size.width / 2, ((size.height * 0.6) / fontCount * i) + (size.height / 4)); addChild(label); } else { log("ERROR: Cannot load: %s", ttfpaths[i]); @@ -1112,25 +1029,6 @@ std::string LabelTTFFontsTestNew::subtitle() const return ""; } -LabelBMFontTestNew::LabelBMFontTestNew() -{ - auto size = Director::getInstance()->getWinSize(); - - auto label1 = Label::createWithBMFont("fonts/bitmapFontTest2.fnt", "Hello World, this is testing the new Label using fnt file", TextHAlignment::CENTER, size.width); - label1->setPosition( Vec2(size.width/2, size.height/2) ); - addChild(label1); -} - -std::string LabelBMFontTestNew::title() const -{ - return "New Label + FNT"; -} - -std::string LabelBMFontTestNew::subtitle() const -{ - return "Uses the new Label with .FNT file"; -} - LabelTTFDistanceField::LabelTTFDistanceField() { auto size = Director::getInstance()->getWinSize(); @@ -1203,7 +1101,7 @@ LabelOutlineAndGlowTest::LabelOutlineAndGlowTest() std::string LabelOutlineAndGlowTest::title() const { - return "New Label"; + return "New Label + .TTF"; } std::string LabelOutlineAndGlowTest::subtitle() const @@ -1407,7 +1305,7 @@ std::string LabelCrashTest::title() const std::string LabelCrashTest::subtitle() const { - return "Not crash and show [Test123] when using unknown character."; + return "Not crash when use character that is not contained in font."; } LabelTTFOldNew::LabelTTFOldNew() @@ -1674,7 +1572,7 @@ LabelAdditionalKerningTest::LabelAdditionalKerningTest() TTFConfig ttfConfig("fonts/arial.ttf", 40, GlyphCollection::DYNAMIC,nullptr,false); label = Label::createWithTTF(ttfConfig,"Test additional kerning"); - label->setPosition( Vec2(size.width/2, size.height*0.65f) ); + label->setPosition(size.width/2, size.height * 0.5f); label->setTextColor( Color4B::RED ); addChild(label); @@ -1777,12 +1675,12 @@ LabelSmallDimensionsTest::LabelSmallDimensionsTest() std::string LabelSmallDimensionsTest::title() const { - return "Test create Label[system font] with small dimensions"; + return "New Label + System font"; } std::string LabelSmallDimensionsTest::subtitle() const { - return "Program should not dead loop"; + return "Testing create Label with small dimensions.Program should not dead loop"; } LabelIssue10089Test::LabelIssue10089Test() diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h index 998e6f2d1b..13cb6d24fa 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h +++ b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h @@ -11,16 +11,6 @@ class AtlasDemoNew : public TestCase { }; -class LabelTTFAlignmentNew : public AtlasDemoNew -{ -public: - CREATE_FUNC(LabelTTFAlignmentNew); - - LabelTTFAlignmentNew(); - virtual std::string title() const override; - virtual std::string subtitle() const override; -}; - class LabelFNTColorAndOpacity : public AtlasDemoNew { float _time; @@ -145,26 +135,6 @@ public: virtual std::string subtitle() const override; }; -class LabelTTFUnicodeChinese : public AtlasDemoNew -{ -public: - CREATE_FUNC(LabelTTFUnicodeChinese); - - LabelTTFUnicodeChinese(); - virtual std::string title() const override; - virtual std::string subtitle() const override; -}; - -class LabelFNTUnicodeChinese : public AtlasDemoNew -{ -public: - CREATE_FUNC(LabelFNTUnicodeChinese); - - LabelFNTUnicodeChinese(); - virtual std::string title() const override; - virtual std::string subtitle() const override; -}; - class LabelFNTMultiLineAlignment : public AtlasDemoNew { public: @@ -278,7 +248,6 @@ public: private: }; - class LabelTTFFontsTestNew : public AtlasDemoNew { public: @@ -290,20 +259,6 @@ public: virtual std::string subtitle() const override; }; - -class LabelBMFontTestNew : public AtlasDemoNew -{ -public: - CREATE_FUNC(LabelBMFontTestNew); - - LabelBMFontTestNew(); - - virtual std::string title() const override; - virtual std::string subtitle() const override; - -private: -}; - class LabelFontDefTestNew : public AtlasDemoNew { public: From 4a3ace6ff53d7fb8f5cca6e1ddaa37eae4efa26f Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 24 Aug 2015 09:40:59 +0800 Subject: [PATCH 075/118] Add release note for v3.8 --- CHANGELOG | 4 +- docs/RELEASE_NOTES.md | 446 ++++++++++++++++++++++++++++++++---------- web | 2 +- 3 files changed, 352 insertions(+), 100 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6b3e20ae0b..cda46bc560 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -37,7 +37,7 @@ cocos2d-x-3.8 beta0 August.14 2015 [REFINE] 3D: Made SkyBox not transparent [REFINE] Director: Made types to handle time consistent by modifing setAnimationInterval argument from double to float [REFINE] Sprite: Made Sprite::setTexture accept nullptr as parameter - [REFINE] TextureCache: Made addImageAsync function thread unsafe + [REFINE] TextureCache: Made addImageAsync function thread safe [REFINE] Label: Improved code readability [REFINE] Label: Supported adding child nodes in Label [REFINE] Label: Refine the implementation about text layout and support debug draw @@ -66,6 +66,7 @@ cocos2d-x-3.8 beta0 August.14 2015 [REFINE] JS: Refine performance for Cocos Studio JSON parser for 2.x [REFINE] JS: Made binding functions accept null in JS and convert to nullptr [REFINE] web: Avoid re-bake the content when the parent node's position get changed + [REFINE] web: Solved repeat loading same resource issue when parsing cocos studio project [REFINE] web: Added GameNodeObjectData and GameLayerObjectData in JSON parser [REFINE] web: Updated skeleton animation to the latest version [REFINE] web: Optimized resources automatic loading in JSON parser @@ -185,6 +186,7 @@ cocos2d-x-3.8 beta0 August.14 2015 [FIX] web: Fixed effect issue in ActionGrid and NodeGrid [FIX] web: Fixed logic issue in Menu's _onTouchCancelled function [FIX] web: Fixed MenuItem crash when normal image is null + [FIX] web: Fixed CCTouch's startPoint unset issue [TEST] 3D: Avoid to trigger touch event multiple times in Physics3D Test and Physics3D Constraint Test [TEST] 3D: Fixed Sprite3D test background to foreground bug diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index 37aaf12198..4fdbc15ac4 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -2,7 +2,7 @@ **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* -- [Cocos2d-x v3.7 Release Notes](#cocos2d-x-v37-release-notes) +- [Cocos2d-x v3.8 Release Notes](#cocos2d-x-v38-release-notes) - [Misc Information](#misc-information) - [Requirements](#requirements) - [Runtime Requirements](#runtime-requirements) @@ -14,22 +14,22 @@ - [Windows](#windows) - [Linux](#linux) - [How to start a new game](#how-to-start-a-new-game) -- [v3.7.1](#v371) - - [Highlights of v3.7.1](#highlights-of-v371) +- [v3.8](#v38) + - [Highlights and API changes of v3.8](#highlights-and-api-changes-of-v38) - [Download](#download) - [The main features in detail:](#the-main-features-in-detail) - - [Skeleton Animation](#skeleton-animation) - - [Get Node's transform to its ancestor](#get-nodes-transform-to-its-ancestor) - - [Set background color for web engine](#set-background-color-for-web-engine) - - [Widget's enable state and bright state](#widgets-enable-state-and-bright-state) - - [Firefox remote debugger support](#firefox-remote-debugger-support) -- [v3.7](#v37) - - [Highlights of v3.7](#highlights-of-v37) + - [3D Module](#3d-module) + - [UI System](#ui-system) + - [AudioEngine](#audioengine) + - [FileUtils](#fileutils) + - [Others](#others) + - [Other changes](#other-changes) + - [New APIs](#new-apis) - [The Next Step](#the-next-step) -# Cocos2d-x v3.7 Release Notes # +# Cocos2d-x v3.8 Release Notes # # Misc Information @@ -44,6 +44,7 @@ * OS X 10.7 or newer * Windows 7 or newer * Windows Phone 8.1 +* Windows 10 UWP * Linux Ubuntu 14.04 or newer * Mordern browsers and IE 9+ (On mobile platforms, only iOS and Android 5 activated WebGL support) @@ -84,8 +85,8 @@ cocos run -p android -m release ### Mac OSX & iOS -* Enter `cocos2d-x/build` folder, open `cocos2d_test.xcodeproj` or `cocos2d_js_tests.xcodeproj` (For JS test, we will merge these two project in v3.8) -* Select `iOS` or `OS X` target in scheme toolbar +* Enter `cocos2d-x/build` folder, open `cocos2d_test.xcodeproj` +* Select `cpp-tests`, `lua-tests`, `js-tests` for `iOS` or `OS X` target in scheme toolbar * Click `run` button ### Android @@ -117,8 +118,8 @@ Then ### Windows -* For win32 project, enter `cocos2d-x/build`, and open `cocos2d-win32.sln` or `cocos2d-js-win32.sln` -* For win 8.1 project, enter `cocos2d-x/build`, and open `cocos2d-win8.1-universal.sln` or `cocos2d-js-win8.1-universal.sln` +* For win32 project, enter `cocos2d-x/build`, and open `cocos2d-win32.sln` +* For win 8.1 project, enter `cocos2d-x/build`, and open `cocos2d-win8.1-universal.sln` * For win 10 project, enter `cocos2d-x/build`, and open `cocos2d-win10.sln` * Select running target * Click run button @@ -146,130 +147,379 @@ Run Use Cocos Console to create a new game: ``` -cocos new -l cpp|js|lua MyGame +cocos new -l cpp|js|lua MyNewGame ``` -# v3.7.1 +# v3.8 -## Highlights of v3.7.1 +## Highlights and API changes of v3.8 -Cocos2d-x v3.7.1 is a stable version based on v3.7. The most important update is that we added skeleton animation support for Cocos 2.3.2Beta. +As promised, Cocos2d-x v3.8 have greatly improved the stability and API friendliness. On one side, we continue to improve 3D capacity by providing 3D physics collider, skybox background brush and key frame event callback in Animate3D. On another side, we have refined several core modules, including UI system, AudioEngine, FileUtils, Bindings Generator, etc. -* [NEW] studio: Added new skeleton animation support and csb parser for cocos v2.3.2 beta -* [NEW] studio: Added new skeleton animation support and JSON parser in the web engine -* [NEW] studio: Added Skybox csb/JSON parser for cocos v2.3.2 beta -* [NEW] studio: Parsed Touch/Click/Event callback in JSON parser -* [NEW] Node: Added getNodeToParentTransform with selected ancestor -* [NEW] web: Added cc.director.setClearColor and support transparent background -* [REFINE] Widget: Synchronize enable state and bright state for Widget -* [REFINE] studio: Optimized JSON parser's performance by removing audio play -* [REFINE] JSB: Add Firefox remote debugger support in JS templates +Here is some highlighted improvments and API changes: + +1. 3D Module + - Added 3D physics collider + - Supported setting camera background brushes with color/depth/skybox + - Added key frame event Callback in Animate3D + - Added light map support in Terrain +2. UI System + - Reimplemented and enhanced EditBox on Android + - Added ScrollViewBar for displaying a scroll bar at the side of ScrollView (JSB/Lua ready) + - Added RadioButton widget (JSB/Lua ready) + - Added HANYI FullType font support +3. AudioEngine + - AudioEngine supported audio preloading + - Bound new AudioEngine in JSB +4. FileUtils + - Added a set of file writing APIs: writeStringToFile, writeDataToFile, writeValueMapToFile, writeValueVectorToFile +5. Others + - Improved Bindings Generator tool + - Merged JSB test project into cocos2d test project + - framework: Support generate prebuilt libs of engine with debug mode + - console: Supported new portrait projects from templates ## Download -[Cocos2d-x v3.7.1](http://www.cocos2d-x.org/filedown/cocos2d-x-3.7.1.zip) including : C++, Lua & JS +[Cocos2d-x v3.8 rc0](http://www.cocos2d-x.org/filedown/cocos2d-x-3.8-rc0.zip) including : C++, Lua & JS ## The main features in detail: -### Skeleton Animation +### 3D Module -In v3.7.1 and Cocos 2.3.2, we are providing a new skeleton animation system which is different from Armature. The reason is that we abstract ActionTimeline system to support all sort of animations but Armature doesn't support it. To benefit the timeline system and to make skeleton animation system much more compact, we have implemented the new skeleton animation system. From this version, you will be able to edit skeleton animations in Cocos v2. +1. 3D physics collider -New skeleton animation system contains `BoneNode`, `SkeletonNode`, `SkinNode`. SkeletonNode is a subclass of BoneNode and extended container functionalities, so it can contain BoneNode and nested SkeletonNode to construct a skeleton. + 3D physics collider is a new type of physics object. It can be used as both trigger and collider. -Features provided: + Trigger is a region defined by physics shapes and can get callback when other physics objects enter or leave. Its usage is described in the following code: + + ```cpp + //create a collider using colliderDes + Physics3DColliderDes colliderDes; + colliderDes.shape = Physics3DShape::createSphere(10.0f); + colliderDes.isTrigger = true; + auto collider = Physics3DCollider::create(&colliderDes); + auto component = Physics3DComponent::create(collider); + auto node = Node::create(); + addChild(node); + node->addComponent(component); -1. Playable skeleton animation -2. Nested skeleton -3. Skin replacement -4. Time scale control -5. Debug draw -6. Frame event callback + collider->onTriggerEnter = [=](Physics3DObject *otherObject){ + //some body entering + }; + collider->onTriggerExit = [=](Physics3DObject *otherObject){ + //some one leaving + }; + ``` -New skeleton animation is also supported by the web engine. We will keep enhancing it in the future versions. + Collider is similar to rigid body, it can give force to the rigid body that collides with it. However, it is static and has better performance than rigid body. It is proper to represent a static scene or objects using collider and dynamic part using rigid body. You can set colliderDes.isTrigger to false when you want to make it collider. -![](https://raw.githubusercontent.com/minggo/Pictures/master/action-timeline.gif) +2. Camera background brushes -### Get Node's transform to its ancestor + Different with previous versions, in v3.8, developers can choose to erase the camera’s background with 4 types of brush: none, color, depth, skybox. None brush means do nothing; Color brush erases background using given color and depth; depth brush erases background using given depth; skybox brush erases background using given skybox with 6 texture faces. The default brush is depth brush. The usage of brushes is showing below: -We have added a new functionality in `getNodeToParentTransform` API of Node, in v3.7.1, you can pass a ancestor as a parameter to get the node's transform related to this specific ancestor. Here is an example: + ```cpp + // Using none brush + _camera->setBackgroundBrush(CameraBackgroundBrush::createNoneBrush()); + // Using depth brush, clear depth with 1.0 + _camera->setBackgroundBrush(CameraBackgroundBrush::createDepthBrush(1.f)); + // Using color brush, clear color is (1,0,0,1), depth is 1 + _camera->setBackgroundBrush(CameraBackgroundBrush::createColorBrush(Color4F(1.f, 0.f, 0.f, 1.f), 1.f)); + // SkyBox brush + _camera->setBackgroundBrush(CameraBackgroundBrush::createSkyboxBrush("Sprite3DTest/skybox/left.jpg", "Sprite3DTest/skybox/right.jpg","Sprite3DTest/skybox/top.jpg", "Sprite3DTest/skybox/bottom.jpg","Sprite3DTest/skybox/front.jpg", "Sprite3DTest/skybox/back.jpg")); + ``` -``` -auto parent2 = Node::create(); -auto parent1 = Node::create(); -auto node = Node::create(); -parent2->addChild(parent1); -parent1->addChild(node); -// This will give you the transform of node in parent2's coordinate system -auto transform = node->getNodeToParentTransform(parent2); -``` +3. Animate3D key frame event callback -This API is also usable in the web engine. + Similar to 2d AnimationFrame callback, frame event callback is supported in Animated3D now. It allows developer to set a callback to be invoked when specific frame is played. Sample code: -### Set background color for web engine + ```cpp + auto animation = Animation3D::create(“XX.c3bâ€); + auto animate = Animate3D::create(animation); + ValueMap valuemap0;//you can add some user data here, it can be used in the frame event callback + //add a callback when frame 275 is played + animate->setKeyFrameUserInfo(275, valuemap0); + + auto listener = EventListenerCustom::create(Animate3DDisplayedNotification, [&](EventCustom* event) + { + auto info = (Animate3D::Animate3DDisplayedEventInfo*)event->getUserData(); + + //frame 275 is played, you can add some code here + cocos2d::log(“frame %dâ€, info->frame); + }); + Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(listener, -1); + ``` -From v3.7.1, you can control the background of your game in the web engine easily. We have provided a new API: `cc.director.setClearColor()`. The color you passed can be non-transparent or with transparency. Note that if the clear color you want is not transparent, it's more efficient than creating a background layer. Take a look at the example: +4. Light map support in Terrain -``` -// Solution1: Using colored background layer -var background = cc.LayerColor(cc.color(255, 0, 0)); -background.width = cc.winSize.width; -background.height = cc.winSize.height; -// This will give you a red background -scene.addChild(background, 0); + Terrain with light map is supported in v3.8, which means you can add a light map texture baked from other tools to the terrain. The light map texture contains light info, so that the terrain seems to be lighted with several lights. Terrain with light map can be created like this, -// Solution2: Using setClearColor -// This will give you a red background and much more efficient than solution1 -cc.director.setClearColor(cc.color(255, 0, 0)); -``` + ```cpp + //create a normal terrain as before + Terrain::DetailMap r(“TerrainTest/dirt.jpgâ€),g(“TerrainTest/Grass2.jpgâ€),b(“TerrainTest/road.jpgâ€),a(“TerrainTest/GreenSkin.jpgâ€); + Terrain::TerrainData data(“TerrainTest/heightmap16.jpgâ€,â€TerrainTest/alphamap.pngâ€,r,g,b,a); + _terrain = Terrain::create(data,Terrain::CrackFixedType::SKIRT); + _terrain->setLODDistance(3.2f,6.4f,9.6f); + _terrain->setMaxDetailMapAmount(4); + _terrain->setDrawWire(false); + //set light map for the terrain + _terrain->setLightMap(“TerrainTest/Lightmap.pngâ€); + ``` -Besides, you can make your background totally tranparent too. +### UI System -### Widget's enable state and bright state +1. Reimplemented EditBox -In the old Widget API design, `setEnabled` only controls whether the widget should respond to user input events, while `setBright` only controls whether the widget's display should be in gray state (which indicates disable) or bright state (which indicates enable). This is very frustrating for our developers. So from v3.7.1, we decided to synchronise bright state with enable state. That means, once your widghet is disabled via `setEnabled(false)`, its display will also change to gray state. + The usage of EditBox is the same as before. It is more likely a iOS version EditBox remake plus a few improvments. -``` -// In old version, you will do -widget->setEnabled(false); -widget->setBright(false); + Besides, it supports multi-line input now, you should set InputMode to `ANY` to enable multi-line input. -// In v3.7.1, you only need to do -widget->setEnabled(false); -``` +2. ScrollViewBar + + In the previous versions, the ScrollView doesn't have any visual notification for the current location in view. In v3.8, we have added a scroll bar attached to the ScrollView. You could tweak the the opacity, color, width and the duration for auto hiding the scroll bar. Speical thanks to @neokim. -### Firefox remote debugger support + Usage: -In v3.7.1, we have enabled Firefox remote debugger support for JSB projects. You only need to follow [this documentation](http://www.cocos2d-x.org/docs/manual/framework/native/v3/js-remote-debugger/en), and you can debug your JSB projects with your Firefox browser. Note that it permits you to debug JavaScript code in your JSB project, for native code debugging you should still use Xcode or Visual Studio. + ```cpp + ui::ScrollView* scrollView = ui::ScrollView::create(); + scrollView->setScrollBarWidth(4); + scrollView->setScrollBarPositionFromCorner(Vec2(2, 2)); + scrollView->setScrollBarColor(Color3B::WHITE); + this->addChild(scrollView); + ``` -![](https://raw.githubusercontent.com/minggo/Pictures/master/js-remote-debug.png) +3. RadioButton widget + RadioButton is a specific type of two-states button that is similar to CheckBox. -# v3.7 + Additionally, it can be used together with RadioButtonGroup to interact with other radio buttons. -## Highlights of v3.7 + There is only one RadioButton in checked state at the same time within a RadioButtonGroup. Special thanks to @neokim who have contributed the implementation of this new widget. -1. Cocos2d-x will only publish the final versions publicly in the future, all alpha, beta, rc versions will be exclusively published in the community. By that I mean in the English and Chinese forum, in developers QQ groups, by the github tags. The final versions will be published with the all in one Cocos. + Usage: -2. Cocos2d-JS is merged into Cocos2d-x in v3.7, from now on, developers won't get confused about which product they should use. With Cocos2d-x, you can work with C++/Lua/JS and publish to Windows/WP8.1/Android/Mac/iOS/Linux and Web if you use JS. For a smooth transition, we will still announce two products in v3.7, Cocos2d-x v3.7 and Cocos2d-JS v3.7, but they share exactly the same package. In the future versions, there will be only one package. For reference, this have been discussed in [another thread](http://discuss.cocos2d-x.org/t/discuss-the-next-step-of-cocos2d-x/21182/) + ```cpp + //create a RadioButtonGroup + auto radioButtonGroup = RadioButtonGroup::create(); + this->addChild(radioButtonGroup); -* 3d: Added Physics3d support (JS/Lua ready) -* 3d: Added NavMesh support (JS/Lua ready) -* core: Added Material system (JS/Lua ready) -* sprite: Supportted polygon sprite with AutoPolygon generator (JS/Lua ready) -* Scale9Sprite: Added Android 9-patch image support (JS/Lua ready) -* platform: Added Windows 10.0 Universal App(UWP) support -* platform: Add Samsung Enhanced API on Android for cocos -* C++: Added Android Studio support -* JS: Merged JSB and web engine into Cocos2d-x for a All-in-one engine -* JS: Added `ccui.VideoPlayer` and `ccui.WebView` for iOS/Android/Web -* console: Supported build & run Android Studio project with cocos console -* SDKBOX: super EASY way to integrate 3rd party SDKs into cocos2d-x + //create a RadioButton + RadioButton* radioButton1 = RadioButton::create("radio_button_off.png", "radio_button_on.png"); + radioButton1->setPosition(Vec2(100,100); + this->addChild(radioButton1); + + //create another RadioButton + RadioButton* radioButton2 = RadioButton::create("radio_button_off.png", "radio_button_on.png"); + radioButton2->setPosition(Vec2(100,100); + this->addChild(radioButton2); + + //add the RadioButtons into RadioButtonGroup + radioButtonGroup->addRadioButton(radioButton1); + radioButtonGroup->addRadioButton(radioButton2); + ``` + +### AudioEngine + +1. Audio preloading + + AudioEngine now supports preload audio files before playing it. For some large audio file, this feature can smooth the audio playing experience in user's games. Sample code: + + ```cpp + //Use it with callback + AudioEngine::preload("audio1.mp3",[](bool isSuccess){ + //... + }); + //Use it without callback + AudioEngine::preload("audio2.mp3"); + ``` + +2. JSB new AudioEngine + + In JSB, the default audio engine was SimpleAudioEngine (renamed to cc.audioEngine). It was the old audio engine provided since v2, and it have some inconvenience like delay time, no event support, etc. So we decided to provide new AudioEngine in JSB, the API remains the same as C++ API, and its usage can be found in [its test case](https://github.com/cocos2d/cocos2d-x/blob/v3/tests/js-tests/src/NativeTest/AudioEngineTest.js). + +### FileUtils + +1. New file writing APIs + + In v3.8, we have provided a bunch of file writing APIs in FileUtils. Now you can use very simple APIs to write string, binary data, value map, and value vector into a file in user's file system. Each API is demonstrated in the following sample code: + + ```cpp + std::string writablePath = FileUtils::getInstance()->getWritablePath(); + + // FileUtils::writeStringToFile + std::string writeDataStr = "the string data will be write into a file"; + std::string fullPath = writablePath + "writeStringTest.txt"; + FileUtils::getInstance()->writeStringToFile(writeDataStr, fullPath.c_str()); + + // FileUtils::writeDataToFile + std::string writeDataStr = "the binary data will be write into a file"; + Data writeData; + writeData.copy((unsigned char *)writeDataStr.c_str(), writeDataStr.size()); + std::string fullPath = writablePath + "writeDataTest.txt"; + FileUtils::getInstance()->writeDataToFile(writeData, fullPath.c_str())); + + // FileUtils::writeValueMapToFile + std::string fullPath = writablePath + "testWriteValueMap.plist"; + FileUtils::getInstance()->writeValueMapToFile(valueMap, fullPath.c_str()); + + // FileUtils::writeValueVectorToFile + std::string fullPath = writablePath + "testWriteValueVector.plist"; + FileUtils::getInstance()->writeValueVectorToFile(valueVector, fullPath.c_str()); + ``` + + Besides, you can retrieve the extension (in lower case) of a file with `FileUtils::getFileExtension` API. + +### Others + +1. Bindings Generator + + In v3.8, we also improved our bindings generator tool, now it's even more powerful and be able to bind almost all kind of C++ APIs to script. Here is a detailed list about improvement in bindings generator. + + - Supported generating auto bindings code for public member variables + - Avoid memory leak of non-Ref classes instance by controlling C++ object memory with JS object + - Made JSB classes automatically extendable if configured in classes_need_extend list + - Improved support for Lambda functions in JS auto bindings + +2. JSB test project + + In v3.8, JSB test project have been merged into C++ test project. That means cocos2d_js_tests.xcodeproj, cocos2d-js-win32.sln, cocos2d-js-win8.1-universal.sln have been removed. You can find jsb test targets in cocos2d_test.xcodeproj, cocos2d-win32.sln and cocos2d-win8.1-universal.sln. + +3. Compile custom framework in debug mode + + From v3.7, you was able to generate customized Cocos Framework from cocos2d-x. We have improved this ability in v3.8, now you will be able to generate framework in debug mode. Here is the some documentation about it: + + - [Framework compile documentation](http://www.cocos2d-x.org/wiki/Cocos_gen-libs). + - [How to customize Cocos Framework](http://www.cocos2d-x.org/docs/manual/studio/v4/chapter3/HowToCode/CustomizeFramework-v3.8/en) + - [How to generate Cocos Simulator](http://www.cocos2d-x.org/wiki/Cocos_gen-simulator) + +4. Portrait projects support + + From v3.8, you can generate portrait oriented games with Cocos Console: + + ``` + cocos new -l cpp|lua|js --portrait MyPortraitGame + ``` + + More details can be found in [Cocos new command](http://www.cocos2d-x.org/wiki/Cocos_new) and [Cocos Console general documentation](http://www.cocos2d-x.org/wiki/Cocos2d-console) + +## Other changes + +- [NEW] UI: Enhanced ScrollView with easing out scrolling +- [NEW] UI: Added PageView vertical scroll support +- [NEW] UI: Added PageView::JumpToPage API +- [NEW] UI: Added a setter for line width in DrawNode +- [NEW] Action: Permitted setting bitwise flags to action +- [NEW] Animate: Added Animate's getCurrentFrameIndex function +- [NEW] FileUtils: Added FileUtils::getFileExtension for getting file's extension name +- [NEW] Device: Added vibrate support to enable vibration for a duration +- [NEW] UserDefault: Supported removing key pairs from UserDefault +- [NEW] spine: Supported Spine runtime 2.3 (Both native and web engine) +- [NEW] console: Moved the framework-compile tools into cocos2d-console +- [NEW] network: Upgrade SocketIO support to v1.x + +- [REFINE] 3D: Supported composite 2D/3D scene by moving UI and camera far away +- [REFINE] 3D: Improved Particle3D performance +- [REFINE] Label: Supported adding child nodes in Label +- [REFINE] UI: Improved Slider's precision +- [REFINE] UI: Refined scroll event dispatching for ScrollView +- [REFINE] UI: Improved event handling in TextField +- [REFINE] Label: Supported auto batch with bitmap font or char map +- [REFINE] studio: Added BlendFrame support to Skeleton Animation +- [REFINE] studio: Enabled blendfunc cascade to the skin of BoneNode +- [REFINE] utils: Made utils::captureScreen saving file in another thread to improve the performance +- [REFINE] 3rd party: Update Nibiru SDK to 2.6 +- [REFINE] JS: Supported new construction for 3d classes in JS +- [REFINE] JS: Refine performance for Cocos Studio JSON parser for 2.x +- [REFINE] web: Avoid re-bake the content when the parent node's position get changed +- [REFINE] web: Solved repeat loading same resource issue when parsing cocos studio project +- [REFINE] web: Optimized resources automatic loading in JSON parser +- [REFINE] web: Avoid cc.loader resource loading being terminated while encounter errors +- [REFINE] web: Suspended the video player when the browser is minimized + +You can also take a look at [the full changelog](https://github.com/cocos2d/cocos2d-x/blob/v3/CHANGELOG) + +## New APIs + +In the above changes, there are some new APIs introduced in v3.8, they are listed here: + +1. PageView vertical scroll support + + ``` + PageView* pageView = PageView::create(); + pageView->setContentSize(Size(240.0f, 130.0f)); + pageView->setDirection(ui::PageView::Direction::VERTICAL); + ``` + +2. Setter for line width in DrawNode + + ``` + DrawNode* drawNode = DrawNode::create(); + drawNode->setLineWidth(5.0f); + ``` + +3. Bitwise flags of action + + ``` + enum Flags { + FRAME = 1, + COLOR = 2, + OPACITY = 4, + POSITION = 8, + SCALE = 16, + ROTATION = 32, + SKEW = 64 + }; + + auto action = RepeatForever::create(Sequence::create(FadeTo::create( 0.1f, 155), TintTo::create(0.1f, 255,0,0), nullptr)); + // Since opacity and color will be modified in this action, it can be flagged as opacity and color action + action->setFlags(Flags::OPACITY|Flags::COLOR); + + auto action2 = RepeatForever::create(Sequence::create(MoveBy::create(0.3f, Vec2(5, 0)), nullptr)); + // Since position will be modified in this action, it can be flagged as position action + action->setFlags(Flags::POSITION); + ``` + +4. Get current frame index in animation + + ``` + auto action = RepeatForever::create( Animate::create(animation); + sprite->runAction(action); + sprite->scheduleOnce([=](float){ + int index = action->getCurrentFrameIndex(); + // ... + }, 1.0f, "get-current-frame"); + + ``` + +5. File's extension name getter + + ``` + std::string extension = FileUtils::getInstance()->getFileExtension("grossini.png"); + ``` + +6. Vibration support + + ``` + // Virate the device for 0.5 second + Device::vibrate(0.5f); + ``` + +7. Remove key pairs from UserDefault + + ``` + // Remove value referenced by "some key" + UserDefault::getInstance()->deleteValueForKey("some key"); + ``` # The Next Step -As you can see, in v3.7, we have enhanced our 2d rendering with material system and integrated polygon sprite. More importantly, our 3d features become more and more complete, 3d Physics and Navigation Mesh with the previous Camera, 3d Sprite, 3d Particle System, 3d Light, 3d Terrain, Skybox, now you can really start to use Cocos to make a 3d game. +In v3.9, we will continue to improve our framework, several important tasks are: -In v3.8, we won't do much more features, but we'd like to slow down and refine our current 3D and 2D modules. +1. We are about to provide a script based component system. +2. Improve ScrollView, ListView performance in both native and web engine. +3. Improve 2D particle system performance. +4. Improve web engine renderer logic and performance. +5. Support Action inheritance in JSB. +6. Remove libcurl dependency on iOS and Android. -[The v3.8 milestone tasks](https://github.com/cocos2d/cocos2d-x/milestones/v3.8) +[The v3.9 milestone tasks](https://github.com/cocos2d/cocos2d-x/milestones/v3.9) (It's still being reviewing and will be updated) diff --git a/web b/web index b672abb239..690beb02cb 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit b672abb2392c715966a20a273d7371f0ec09fb63 +Subproject commit 690beb02cb853b8778944ed4e0db2d0b49c94a48 From 634bf0dd3a157487018de489f07bd66667e6b33e Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 25 Aug 2015 18:28:48 +0800 Subject: [PATCH 076/118] Update web engine --- web | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web b/web index 690beb02cb..d7d08fca58 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit 690beb02cb853b8778944ed4e0db2d0b49c94a48 +Subproject commit d7d08fca58b6fcbd5fd533c3687eb8a20074e03d From 6cea66f932cf69d15f305f3cbf2cc45a648b522b Mon Sep 17 00:00:00 2001 From: andyque Date: Tue, 25 Aug 2015 23:31:34 +0800 Subject: [PATCH 077/118] fixed Scale9Sprite default capInset bug. Fixed https://github.com/cocos2d/cocos2d-x/issues/13560 --- cocos/ui/UIScale9Sprite.cpp | 17 ++++++++--------- .../CocoStudioGUITest/UIScale9SpriteTest.cpp | 6 +++++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cocos/ui/UIScale9Sprite.cpp b/cocos/ui/UIScale9Sprite.cpp index 90e381b6a0..7178b1a60a 100644 --- a/cocos/ui/UIScale9Sprite.cpp +++ b/cocos/ui/UIScale9Sprite.cpp @@ -150,6 +150,8 @@ namespace ui { { auto texture = sprite->getTexture(); auto spriteFrame = sprite->getSpriteFrame(); + Rect actualCapInsets = capInsets; + if (texture->isContain9PatchInfo()) { auto& parsedCapInset = texture->getSpriteFrameCapInset(spriteFrame); @@ -158,7 +160,7 @@ namespace ui { this->_isPatch9 = true; if(capInsets.equals(Rect::ZERO)) { - this->_capInsetsInternal = this->_capInsets = parsedCapInset; + actualCapInsets = parsedCapInset; } } @@ -169,7 +171,7 @@ namespace ui { rotated, offset, originalSize, - capInsets); + actualCapInsets); } return true; @@ -522,9 +524,8 @@ namespace ui { Rect rect(textureRect); Size size(originalSize); - - if(_capInsets.equals(Rect::ZERO)) - _capInsets = capInsets; + + _capInsets = capInsets; // If there is no given rect if ( rect.equals(Rect::ZERO) ) @@ -546,10 +547,8 @@ namespace ui { _spriteFrameRotated = rotated; _originalSize = size; _preferredSize = size; - if(!capInsets.equals(Rect::ZERO)) - { - _capInsetsInternal = capInsets; - } + + _capInsetsInternal = capInsets; if (_scale9Enabled) { diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp index 0218af0b1f..187ca1e2cc 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp @@ -297,7 +297,11 @@ bool UIS9FrameNameSpriteSheet::init() auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9.png"); - + blocks->setInsetLeft(0); + blocks->setInsetRight(0); + blocks->setInsetTop(0); + blocks->setInsetBottom(0); + blocks->setPreferredSize(Size(400,80)); blocks->setPosition(Vec2(x, y)); this->addChild(blocks); From dfed33f6f2df195b67a71dbf098cea9d3223858d Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 25 Aug 2015 15:07:03 -0700 Subject: [PATCH 078/118] Adds `PrimitiveCommand` test --- cocos/renderer/CCPrimitive.cpp | 18 ++++- cocos/renderer/CCPrimitive.h | 4 +- cocos/renderer/CCVertexIndexData.cpp | 22 ++++-- .../DrawPrimitivesTest/DrawPrimitivesTest.cpp | 76 +++++++++++++++++++ .../DrawPrimitivesTest/DrawPrimitivesTest.h | 20 +++++ 5 files changed, 130 insertions(+), 10 deletions(-) diff --git a/cocos/renderer/CCPrimitive.cpp b/cocos/renderer/CCPrimitive.cpp index 5263c699af..f85b8216e6 100644 --- a/cocos/renderer/CCPrimitive.cpp +++ b/cocos/renderer/CCPrimitive.cpp @@ -54,6 +54,8 @@ Primitive::Primitive() : _verts(nullptr) , _indices(nullptr) , _type(GL_POINTS) +, _start(0) +, _count(0) { } @@ -79,7 +81,7 @@ bool Primitive::init(VertexData* verts, IndexBuffer* indices, int type) CC_SAFE_RELEASE(_indices); _indices = indices; } - + _type = type; return true; @@ -94,8 +96,8 @@ void Primitive::draw() { GLenum type = (_indices->getType() == IndexBuffer::IndexType::INDEX_TYPE_SHORT_16) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT; glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indices->getVBO()); - size_t offet = _start * _indices->getSizePerIndex(); - glDrawElements((GLenum)_type, _count, type, (GLvoid*)offet); + size_t offset = _start * _indices->getSizePerIndex(); + glDrawElements((GLenum)_type, _count, type, (GLvoid*)offset); } else { @@ -107,4 +109,14 @@ void Primitive::draw() } } +void Primitive::setStart(int start) +{ + _start = start; +} + +void Primitive::setCount(int count) +{ + _count = count; +} + NS_CC_END diff --git a/cocos/renderer/CCPrimitive.h b/cocos/renderer/CCPrimitive.h index dfaaa21249..2d6239efe9 100644 --- a/cocos/renderer/CCPrimitive.h +++ b/cocos/renderer/CCPrimitive.h @@ -65,9 +65,9 @@ public: /**Get the number of vertices or indices used for drawing.*/ int getCount() const { return _count; } /**Setter for the start index.*/ - void setStart(int start) { _start = start; } + void setStart(int start); /**Setter for the count. */ - void setCount(int count) { _count = count; } + void setCount(int count); protected: Primitive(); diff --git a/cocos/renderer/CCVertexIndexData.cpp b/cocos/renderer/CCVertexIndexData.cpp index 6faa54a2a7..72807bec34 100644 --- a/cocos/renderer/CCVertexIndexData.cpp +++ b/cocos/renderer/CCVertexIndexData.cpp @@ -122,14 +122,26 @@ void VertexData::use() } GL::enableVertexAttribs(flags); - + + int lastVBO = -1; for(auto& element : _vertexStreams) { //glEnableVertexAttribArray((GLint)element.second._stream._semantic); - glBindBuffer(GL_ARRAY_BUFFER, element.second._buffer->getVBO()); - size_t offet = element.second._stream._offset; - glVertexAttribPointer(GLint(element.second._stream._semantic),element.second._stream._size, - element.second._stream._type,element.second._stream._normalize, element.second._buffer->getSizePerVertex(), (GLvoid*)offet); + auto vertexStreamAttrib = element.second._stream; + auto vertexBuffer = element.second._buffer; + + // don't call glBindBuffer() if not needed. Expensive operation. + int vbo = vertexBuffer->getVBO(); + if (vbo != lastVBO) { + glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer->getVBO()); + lastVBO = vbo; + } + glVertexAttribPointer(GLint(vertexStreamAttrib._semantic), + vertexStreamAttrib._size, + vertexStreamAttrib._type, + vertexStreamAttrib._normalize, + vertexBuffer->getSizePerVertex(), + (GLvoid*)((ssize_t)vertexStreamAttrib._offset)); } } diff --git a/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp b/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp index c1785f7d65..4e50aa2e24 100644 --- a/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp +++ b/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp @@ -17,6 +17,7 @@ DrawPrimitivesTests::DrawPrimitivesTests() { ADD_TEST_CASE(DrawPrimitivesTest); ADD_TEST_CASE(DrawNodeTest); + ADD_TEST_CASE(PrimitivesCommandTest); } string DrawPrimitivesBaseTest::title() const @@ -302,6 +303,81 @@ string DrawNodeTest::subtitle() const return "Testing DrawNode - batched draws. Concave polygons are BROKEN"; } +// PrimitivesCommandTest +PrimitivesCommandTest::PrimitivesCommandTest() +{ + // draws a quad + V3F_C4B_T2F data[] = { + {{0, 0,0}, {255, 0, 0,255}, {0,1}}, + {{200, 0,0}, {0, 255,255,255}, {1,1}}, + {{200,200,0}, {255,255, 0,255}, {1,0}}, + {{0, 200,0}, {255,255,255,255}, {0,0}}, + }; + + uint16_t indices[] = { + 0,1,2, + 2,0,3 + }; + + static const int TOTAL_VERTS = sizeof(data) / sizeof(data[0]); + static const int TOTAL_INDICES = TOTAL_VERTS*6/4; + + auto vertexBuffer = VertexBuffer::create(sizeof(V3F_C4B_T2F), TOTAL_VERTS); + vertexBuffer->updateVertices(data, TOTAL_VERTS,0); + + auto vertsData = VertexData::create(); + vertsData->setStream(vertexBuffer, VertexStreamAttribute(0, GLProgram::VERTEX_ATTRIB_POSITION, GL_FLOAT, 3)); + vertsData->setStream(vertexBuffer, VertexStreamAttribute(offsetof(V3F_C4B_T2F, colors), GLProgram::VERTEX_ATTRIB_COLOR, GL_UNSIGNED_BYTE, 4, true)); + vertsData->setStream(vertexBuffer, VertexStreamAttribute(offsetof(V3F_C4B_T2F, texCoords), GLProgram::VERTEX_ATTRIB_TEX_COORD, GL_FLOAT, 2)); + + + auto indexBuffer = IndexBuffer::create(IndexBuffer::IndexType::INDEX_TYPE_SHORT_16, TOTAL_INDICES); + indexBuffer->updateIndices(indices, TOTAL_INDICES, 0); + + _primitive = Primitive::create(vertsData, indexBuffer, GL_TRIANGLES); + _primitive->setCount(TOTAL_INDICES); + _primitive->setStart(0); + + auto cache = Director::getInstance()->getTextureCache(); + _texture = cache->addImage("Images/grossini.png"); + _programState = GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR); + + _primitive->retain(); + _texture->retain(); + _programState->retain(); +} + +PrimitivesCommandTest::~PrimitivesCommandTest() +{ + CC_SAFE_RELEASE(_primitive); + CC_SAFE_RELEASE(_texture); + CC_SAFE_RELEASE(_programState); +} + + +void PrimitivesCommandTest::draw(Renderer* renderer, const Mat4& transform, uint32_t flags) +{ + _primitiveCommand.init(_globalZOrder, + _texture->getName(), + _programState, + BlendFunc::ALPHA_NON_PREMULTIPLIED, + _primitive, + transform, + flags); + renderer->addCommand(&_primitiveCommand); +} + +string PrimitivesCommandTest::title() const +{ + return "PrimitiveCommand test"; +} + +string PrimitivesCommandTest::subtitle() const +{ + return "Drawing Primitives using PrimitiveCommand"; +} + + #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) #pragma GCC diagnostic warning "-Wdeprecated-declarations" #elif _MSC_VER >= 1400 //vs 2005 or higher diff --git a/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h b/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h index 37745a1629..b56456df05 100644 --- a/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h +++ b/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h @@ -40,4 +40,24 @@ public: virtual std::string subtitle() const override; }; +class PrimitivesCommandTest : public DrawPrimitivesBaseTest +{ +public: + CREATE_FUNC(PrimitivesCommandTest); + + PrimitivesCommandTest(); + virtual ~PrimitivesCommandTest(); + + virtual void draw(cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t flags) override; + virtual std::string title() const override; + virtual std::string subtitle() const override; + +protected: + cocos2d::Texture2D* _texture; + cocos2d::GLProgramState* _programState; + cocos2d::Primitive* _primitive; + + cocos2d::PrimitiveCommand _primitiveCommand; +}; + #endif From 5a997cec1c04c9afa9c410e4c57ccf78d361ddb9 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 26 Aug 2015 10:22:20 +0800 Subject: [PATCH 079/118] update reader with skybox valid --- .../WidgetReader/GameNode3DReader/GameNode3DReader.cpp | 8 ++++++++ .../WidgetReader/UserCameraReader/UserCameraReader.cpp | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.cpp index aeeddc3cb6..29c08d2dd2 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.cpp @@ -84,6 +84,7 @@ namespace cocostudio std::string name = ""; int skyBoxMask = 1; bool skyBoxEnabled = false; + bool skyBoxValid = true; std::string leftPath = ""; std::string leftPlistFile = ""; @@ -127,6 +128,10 @@ namespace cocostudio { skyBoxEnabled = (value == "True") ? true : false; } + else if (attriname == "SkyBoxValid") + { + skyBoxValid = (value == "True") ? true : false; + } else if (attriname == "skyBoxMask") { skyBoxMask = atoi(value.c_str()); @@ -143,6 +148,9 @@ namespace cocostudio attribute = attribute->Next(); } + if (!skyBoxValid) + skyBoxEnabled = false; + const tinyxml2::XMLElement* child = objectData->FirstChildElement(); while (child) { diff --git a/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp index 64c85d0aa4..6d9336a4e8 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp @@ -109,6 +109,7 @@ namespace cocostudio float fov = 60.f; unsigned int cameraFlag = 0; bool skyBoxEnabled = false; + bool skyBoxValid = true; std::string attriname; const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute(); @@ -142,10 +143,17 @@ namespace cocostudio { skyBoxEnabled = (value == "True") ? true : false; } + else if (attriname == "SkyBoxValid") + { + skyBoxValid = (value == "True") ? true : false; + } attribute = attribute->Next(); } + if (!skyBoxValid) + skyBoxEnabled = false; + Vec2 clipPlane(1, 1000); std::string leftPath = ""; From 71f4b804ea8c22bdba11edd92c26244aec131e32 Mon Sep 17 00:00:00 2001 From: VisualSj Date: Wed, 26 Aug 2015 13:42:52 +0800 Subject: [PATCH 080/118] Add BlendFuncFrame auto binding --- tools/tojs/cocos2dx_studio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/tojs/cocos2dx_studio.ini b/tools/tojs/cocos2dx_studio.ini index 57f9fa4cf0..6942b4f657 100644 --- a/tools/tojs/cocos2dx_studio.ini +++ b/tools/tojs/cocos2dx_studio.ini @@ -27,7 +27,7 @@ headers = %(cocosdir)s/cocos/editor-support/cocostudio/CocoStudio.h %(cocosdir)s # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = Armature ArmatureAnimation Skin Bone ColliderDetector ColliderBody ArmatureDataManager InputDelegate ComController ComAudio ComAttribute ComRender ActionManagerEx SceneReader GUIReader BatchNode ActionObject BaseData Tween ColliderFilter DisplayManager DecorativeDisplay ProcessBase AnimationData MovementData ContourData TextureData ActionTimelineData ActionTimeline ActionTimelineCache Frame TextureFrame RotationFrame SkewFrame VisibleFrame RotationSkewFrame PositionFrame ScaleFrame AnchorPointFrame InnerActionFrame ColorFrame AlphaFrame EventFrame ZOrderFrame NodeReader Timeline CSLoader ComExtensionData BoneNode SkeletonNode +classes = Armature ArmatureAnimation Skin Bone ColliderDetector ColliderBody ArmatureDataManager InputDelegate ComController ComAudio ComAttribute ComRender ActionManagerEx SceneReader GUIReader BatchNode ActionObject BaseData Tween ColliderFilter DisplayManager DecorativeDisplay ProcessBase AnimationData MovementData ContourData TextureData ActionTimelineData ActionTimeline ActionTimelineCache Frame TextureFrame RotationFrame SkewFrame VisibleFrame RotationSkewFrame PositionFrame ScaleFrame AnchorPointFrame InnerActionFrame ColorFrame AlphaFrame EventFrame ZOrderFrame BlendFuncFrame NodeReader Timeline CSLoader ComExtensionData BoneNode SkeletonNode # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also From 7ce5542ffc88f0e4dca3fe183b39ef797bdb362e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E9=BE=99?= Date: Wed, 26 Aug 2015 14:50:34 +0800 Subject: [PATCH 081/118] add scriptTest project manifest --- .../Resources/Manifests/ScriptTest/project.manifest | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tests/cpp-tests/Resources/Manifests/ScriptTest/project.manifest diff --git a/tests/cpp-tests/Resources/Manifests/ScriptTest/project.manifest b/tests/cpp-tests/Resources/Manifests/ScriptTest/project.manifest new file mode 100644 index 0000000000..83fb2282ef --- /dev/null +++ b/tests/cpp-tests/Resources/Manifests/ScriptTest/project.manifest @@ -0,0 +1,13 @@ +{ + "packageUrl" : "http://tools.itharbors.com/assets_manager/ScriptTest/", + "remoteManifestUrl" : "http://tools.itharbors.com/assets_manager/ScriptTest/project_dev.manifest", + "remoteVersionUrl" : "http://tools.itharbors.com/assets_manager/ScriptTest/version_dev.manifest", + "version" : "1.0.0", + "engineVersion" : "3.0", + + "assets" : { + }, + + "searchPaths" : [ + ] +} \ No newline at end of file From 7f7341518938d42b55763d63a92f5e95677c312c Mon Sep 17 00:00:00 2001 From: andyque Date: Wed, 26 Aug 2015 16:15:00 +0800 Subject: [PATCH 082/118] fix Scale9Sprite draw extra pixels in spritesheet Fixed https://github.com/cocos2d/cocos2d-x/issues/13564 --- cocos/base/CCNinePatchImageParser.cpp | 5 +---- cocos/ui/UIScale9Sprite.cpp | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/cocos/base/CCNinePatchImageParser.cpp b/cocos/base/CCNinePatchImageParser.cpp index 8ed4c2bb55..9a33d7081b 100644 --- a/cocos/base/CCNinePatchImageParser.cpp +++ b/cocos/base/CCNinePatchImageParser.cpp @@ -184,10 +184,7 @@ Rect NinePatchImageParser::parseCapInset() const verticalLine.y - verticalLine.x); } - capInsets = Rect(capInsets.origin.x / CC_CONTENT_SCALE_FACTOR(), - capInsets.origin.y / CC_CONTENT_SCALE_FACTOR(), - capInsets.size.width / CC_CONTENT_SCALE_FACTOR(), - capInsets.size.height / CC_CONTENT_SCALE_FACTOR()); + capInsets = CC_RECT_PIXELS_TO_POINTS(capInsets); return capInsets; } diff --git a/cocos/ui/UIScale9Sprite.cpp b/cocos/ui/UIScale9Sprite.cpp index 7178b1a60a..eddf5bef5c 100644 --- a/cocos/ui/UIScale9Sprite.cpp +++ b/cocos/ui/UIScale9Sprite.cpp @@ -580,8 +580,8 @@ namespace ui { float width = _originalSize.width; float height = _originalSize.height; - Vec2 offsetPosition(ceilf(_offset.x + (_originalSize.width - _spriteRect.size.width) / 2), - ceilf(_offset.y + (_originalSize.height - _spriteRect.size.height) / 2)); + Vec2 offsetPosition(floor(_offset.x + (_originalSize.width - _spriteRect.size.width) / 2), + floor(_offset.y + (_originalSize.height - _spriteRect.size.height) / 2)); // If there is no specified center region if ( _capInsetsInternal.equals(Rect::ZERO) ) @@ -794,7 +794,7 @@ namespace ui { //shrink the image size when it is 9-patch if(_isPatch9) { - float offset = 1.4f; + float offset = 1.0f; //Top left if(!_spriteFrameRotated) { From 2239b624a8ec49e69663190ba6ae0c6299cfa8c4 Mon Sep 17 00:00:00 2001 From: songchengjiang Date: Wed, 26 Aug 2015 16:19:30 +0800 Subject: [PATCH 083/118] add annotations --- cocos/physics3d/CCPhysics3DObject.h | 13 +++++++++++-- cocos/physics3d/CCPhysicsSprite3D.h | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cocos/physics3d/CCPhysics3DObject.h b/cocos/physics3d/CCPhysics3DObject.h index f2e7597e79..2f7d6e1d5f 100644 --- a/cocos/physics3d/CCPhysics3DObject.h +++ b/cocos/physics3d/CCPhysics3DObject.h @@ -365,7 +365,7 @@ protected: */ struct CC_DLL Physics3DColliderDes { - Physics3DShape* shape; + Physics3DShape* shape; // shape pointer cocos2d::Mat4 originalTransform; bool isTrigger; //is it a trigger? float friction; @@ -390,14 +390,20 @@ struct CC_DLL Physics3DColliderDes }; /** -* @brief Inherit from Physics3DObject, the main class for Colliders +* @brief Inherit from Physics3DObject, the main class for Colliders. */ class CC_DLL Physics3DCollider : public Physics3DObject { public: + /** + * Creates a Physics3DCollider with Physics3DColliderDes. + * + * @return An autoreleased Physics3DCollider object. + */ static Physics3DCollider* create(Physics3DColliderDes *info); + /** Get the pointer of btGhostObject. */ btGhostObject* getGhostObject() const { return _btGhostObject; } /** Set trigger. */ @@ -445,7 +451,10 @@ public: /** Get the world matrix of Physics3DObject. */ virtual cocos2d::Mat4 getWorldTransform() const; + /** Set a callback when trigger enter. */ std::function onTriggerEnter; + + /** Set a callback when trigger exit. */ std::function onTriggerExit; CC_CONSTRUCTOR_ACCESS : diff --git a/cocos/physics3d/CCPhysicsSprite3D.h b/cocos/physics3d/CCPhysicsSprite3D.h index 4596d5c9dc..4d34df22fb 100644 --- a/cocos/physics3d/CCPhysicsSprite3D.h +++ b/cocos/physics3d/CCPhysicsSprite3D.h @@ -50,7 +50,7 @@ public: /** creates a PhysicsSprite3D*/ static PhysicsSprite3D* create(const std::string &modelPath, Physics3DRigidBodyDes* rigidDes, const cocos2d::Vec3& translateInPhysics = cocos2d::Vec3::ZERO, const cocos2d::Quaternion& rotInPhsyics = cocos2d::Quaternion::ZERO); - /** creates a PhysicsSprite3D*/ + /** creates a PhysicsSprite3D as a collider*/ static PhysicsSprite3D* createWithCollider(const std::string &modelPath, Physics3DColliderDes* colliderDes, const cocos2d::Vec3& translateInPhysics = cocos2d::Vec3::ZERO, const cocos2d::Quaternion& rotInPhsyics = cocos2d::Quaternion::ZERO); /** Get the Physics3DObject. */ From 2f72a88a20bcdc173e285e528c0504f02c7dce38 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Wed, 26 Aug 2015 16:37:48 +0800 Subject: [PATCH 084/118] depth test always --- cocos/2d/CCCameraBackgroundBrush.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/2d/CCCameraBackgroundBrush.cpp b/cocos/2d/CCCameraBackgroundBrush.cpp index 9d757abee0..e8d6d668f4 100644 --- a/cocos/2d/CCCameraBackgroundBrush.cpp +++ b/cocos/2d/CCCameraBackgroundBrush.cpp @@ -308,8 +308,8 @@ void CameraBackgroundSkyBoxBrush::drawBackground(Camera* camera) glEnable(GL_DEPTH_TEST); RenderState::StateBlock::_defaultState->setDepthTest(true); - glDepthFunc(GL_LEQUAL); - RenderState::StateBlock::_defaultState->setDepthFunction(RenderState::DEPTH_LEQUAL); + glDepthFunc(GL_ALWAYS); + RenderState::StateBlock::_defaultState->setDepthFunction(RenderState::DEPTH_ALWAYS); glEnable(GL_CULL_FACE); RenderState::StateBlock::_defaultState->setCullFace(true); From f9e9871bccc6bf19450a21ac0759090791098122 Mon Sep 17 00:00:00 2001 From: songchengjiang Date: Wed, 26 Aug 2015 17:24:36 +0800 Subject: [PATCH 085/118] supplement annotations --- cocos/physics3d/CCPhysics3DObject.h | 77 ++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 19 deletions(-) diff --git a/cocos/physics3d/CCPhysics3DObject.h b/cocos/physics3d/CCPhysics3DObject.h index 2f7d6e1d5f..62287693d3 100644 --- a/cocos/physics3d/CCPhysics3DObject.h +++ b/cocos/physics3d/CCPhysics3DObject.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2015 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -365,14 +365,23 @@ protected: */ struct CC_DLL Physics3DColliderDes { - Physics3DShape* shape; // shape pointer + /**shape pointer*/ + Physics3DShape* shape; + /**original world Transform*/ cocos2d::Mat4 originalTransform; - bool isTrigger; //is it a trigger? + /**Is collider a trigger?*/ + bool isTrigger; + /**the friction*/ float friction; + /**the rolling friction*/ float rollingFriction; + /**the restitution*/ float restitution; + /**the hit fraction*/ float hitFraction; + /**the swep sphere radius*/ float ccdSweptSphereRadius; + /**the motion threshold*/ float ccdMotionThreshold; Physics3DColliderDes() @@ -403,52 +412,82 @@ public: */ static Physics3DCollider* create(Physics3DColliderDes *info); - /** Get the pointer of btGhostObject. */ + /** Get the pointer of btGhostObject. + * @return The pointer of btGhostObject. + */ btGhostObject* getGhostObject() const { return _btGhostObject; } - /** Set trigger. */ + /** Set trigger. + * @param isTrigger Is a trigger. + */ void setTrigger(bool isTrigger); - /** Check is a trigger. */ + /** Check is a trigger. + * @return Is a trigger. + */ bool isTrigger() const; - /** Set restitution. */ + /** Set restitution. + * @param rest The restitution. + */ void setRestitution(float rest); - /** Get restitution. */ + /** Get restitution. + * @return The restitution. + */ float getRestitution() const; - /** Set friction. */ + /** Set friction. + * @param rest The friction. + */ void setFriction(float frict); - /** Get friction. */ + /** Get friction. + * @return The friction. + */ float getFriction() const; - /** Set rolling friction. */ + /** Set rolling friction. + * @param frict The rolling friction. + */ void setRollingFriction(float frict); - /** Get rolling friction. */ + /** Get rolling friction. + * @return The rolling friction. + */ float getRollingFriction() const; - /** Set hit friction. */ + /** Set hit friction. + * @param hitFraction The hit friction. + */ void setHitFraction(float hitFraction); - /** Get hit friction. */ + /** Get hit friction. + * @return The hit friction. + */ float getHitFraction() const; - /** Set motion threshold, don't do continuous collision detection if the motion (in one step) is less then ccdMotionThreshold */ + /** Set motion threshold, don't do continuous collision detection if the motion (in one step) is less then ccdMotionThreshold. + * @param ccdMotionThreshold The motion threshold. + */ void setCcdMotionThreshold(float ccdMotionThreshold); - /** Get motion threshold. */ + /** Get motion threshold. + * @return The motion threshold. + */ float getCcdMotionThreshold() const; - /** Set swept sphere radius. */ + /** Set swept sphere radius. + * @param radius The swept sphere radius. + */ void setCcdSweptSphereRadius(float radius); - /** Get swept sphere radius. */ + /** Get swept sphere radius. + * @return The swept sphere radius. + */ float getCcdSweptSphereRadius() const; - /** Get the world matrix of Physics3DObject. */ + /** override. */ virtual cocos2d::Mat4 getWorldTransform() const; /** Set a callback when trigger enter. */ From 7d01b16f62edb21d65d8cd48722563dbdd50fe4e Mon Sep 17 00:00:00 2001 From: geron-cn Date: Wed, 26 Aug 2015 20:24:20 +0800 Subject: [PATCH 086/118] bone's color and opacity cannot cascade to bone, also bone can not cascade from its parent. --- .../cocostudio/ActionTimeline/CCBoneNode.cpp | 42 ++++++++++++++++++- .../cocostudio/ActionTimeline/CCBoneNode.h | 6 +++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp index 1cb40ca31d..e3fa31a5cc 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp @@ -74,14 +74,14 @@ BoneNode* BoneNode::create(int length) void BoneNode::addChild(cocos2d::Node* child, int localZOrder, int tag) { - Node::addChild(child, localZOrder, tag); addToChildrenListHelper(child); + Node::addChild(child, localZOrder, tag); } void BoneNode::addChild(Node* child, int localZOrder, const std::string &name) { - Node::addChild(child, localZOrder, name); addToChildrenListHelper(child); + Node::addChild(child, localZOrder, name); } void BoneNode::addSkin(SkinNode* skin, bool isDisplay, bool hideOthers) @@ -441,6 +441,44 @@ void BoneNode::updateColor() _transformUpdated = _transformDirty = _inverseDirty = _contentSizeDirty = true; } +void BoneNode::updateDisplayedColor(const cocos2d::Color3B& parentColor) +{ + if (_cascadeColorEnabled) + { + for (const auto &child : _boneSkins) + { + child->updateDisplayedColor(_displayedColor); + } + } +} + +void BoneNode::updateDisplayedOpacity(GLubyte parentOpacity) +{ + if (_cascadeOpacityEnabled) + { + for (const auto& child : _boneSkins) + { + child->updateDisplayedOpacity(_displayedOpacity); + } + } +} + +void BoneNode::disableCascadeOpacity() +{ + for (const auto& child : _boneSkins) + { + child->updateDisplayedOpacity(255); + } +} + +void BoneNode::disableCascadeColor() +{ + for (const auto& child : _boneSkins) + { + child->updateDisplayedColor(cocos2d::Color3B::WHITE); + } +} + void BoneNode::onDraw(const cocos2d::Mat4 &transform, uint32_t flags) { getGLProgram()->use(); diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.h b/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.h index 8fe804dd62..0190348149 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.h +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.h @@ -185,6 +185,12 @@ protected: virtual void updateVertices(); virtual void updateColor() override; + // bone's color and opacity cannot cascade to bone + virtual void updateDisplayedColor(const cocos2d::Color3B& parentColor) override; + virtual void updateDisplayedOpacity(GLubyte parentOpacity) override; + virtual void disableCascadeOpacity() override; + virtual void disableCascadeColor() override; + virtual void onDraw(const cocos2d::Mat4 &transform, uint32_t flags); // override Node::visit, just visit bones in children From 3d6866279af70db869378428c8dce073eae28966 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Wed, 26 Aug 2015 13:01:17 +0000 Subject: [PATCH 087/118] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/jsb_cocos2dx_studio_auto_api.js | 46 ++++++ .../auto/jsb_cocos2dx_studio_auto.cpp | 154 ++++++++++++++++++ .../auto/jsb_cocos2dx_studio_auto.hpp | 12 ++ 3 files changed, 212 insertions(+) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_studio_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_studio_auto_api.js index 57804d202e..a3b48d4863 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_studio_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_studio_auto_api.js @@ -3904,6 +3904,52 @@ ZOrderFrame : function ( }; +/** + * @class BlendFuncFrame + */ +ccs.BlendFuncFrame = { + +/** + * @method getBlendFunc + * @return {cc.BlendFunc} + */ +getBlendFunc : function ( +) +{ + return cc.BlendFunc; +}, + +/** + * @method setBlendFunc + * @param {cc.BlendFunc} arg0 + */ +setBlendFunc : function ( +blendfunc +) +{ +}, + +/** + * @method create + * @return {ccs.timeline::BlendFuncFrame} + */ +create : function ( +) +{ + return ccs.timeline::BlendFuncFrame; +}, + +/** + * @method BlendFuncFrame + * @constructor + */ +BlendFuncFrame : function ( +) +{ +}, + +}; + /** * @class Timeline */ diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.cpp index ba7f33fdd0..0d03c24b6b 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.cpp @@ -11265,6 +11265,159 @@ void js_register_cocos2dx_studio_ZOrderFrame(JSContext *cx, JS::HandleObject glo } } +JSClass *jsb_cocostudio_timeline_BlendFuncFrame_class; +JSObject *jsb_cocostudio_timeline_BlendFuncFrame_prototype; + +bool js_cocos2dx_studio_BlendFuncFrame_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::BlendFuncFrame* cobj = (cocostudio::timeline::BlendFuncFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_BlendFuncFrame_getBlendFunc : Invalid Native Object"); + if (argc == 0) { + cocos2d::BlendFunc ret = cobj->getBlendFunc(); + jsval jsret = JSVAL_NULL; + jsret = blendfunc_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_BlendFuncFrame_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_BlendFuncFrame_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::BlendFuncFrame* cobj = (cocostudio::timeline::BlendFuncFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_BlendFuncFrame_setBlendFunc : Invalid Native Object"); + if (argc == 1) { + cocos2d::BlendFunc arg0; + ok &= jsval_to_blendfunc(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_BlendFuncFrame_setBlendFunc : Error processing arguments"); + cobj->setBlendFunc(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_BlendFuncFrame_setBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_BlendFuncFrame_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::timeline::BlendFuncFrame* ret = cocostudio::timeline::BlendFuncFrame::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::BlendFuncFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_BlendFuncFrame_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_BlendFuncFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::timeline::BlendFuncFrame* cobj = new (std::nothrow) cocostudio::timeline::BlendFuncFrame(); + cocos2d::Ref *_ccobj = dynamic_cast(cobj); + if (_ccobj) { + _ccobj->autorelease(); + } + TypeTest t; + js_type_class_t *typeClass = nullptr; + std::string typeName = t.s_name(); + auto typeMapIter = _js_global_type_map.find(typeName); + CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); + typeClass = typeMapIter->second; + CCASSERT(typeClass, "The value is null."); + // JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::timeline::BlendFuncFrame"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + +extern JSObject *jsb_cocostudio_timeline_Frame_prototype; + +void js_cocostudio_timeline_BlendFuncFrame_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (BlendFuncFrame)", obj); +} +void js_register_cocos2dx_studio_BlendFuncFrame(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_timeline_BlendFuncFrame_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_timeline_BlendFuncFrame_class->name = "BlendFuncFrame"; + jsb_cocostudio_timeline_BlendFuncFrame_class->addProperty = JS_PropertyStub; + jsb_cocostudio_timeline_BlendFuncFrame_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_timeline_BlendFuncFrame_class->getProperty = JS_PropertyStub; + jsb_cocostudio_timeline_BlendFuncFrame_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_timeline_BlendFuncFrame_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_timeline_BlendFuncFrame_class->resolve = JS_ResolveStub; + jsb_cocostudio_timeline_BlendFuncFrame_class->convert = JS_ConvertStub; + jsb_cocostudio_timeline_BlendFuncFrame_class->finalize = js_cocostudio_timeline_BlendFuncFrame_finalize; + jsb_cocostudio_timeline_BlendFuncFrame_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getBlendFunc", js_cocos2dx_studio_BlendFuncFrame_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBlendFunc", js_cocos2dx_studio_BlendFuncFrame_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_BlendFuncFrame_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_timeline_BlendFuncFrame_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + jsb_cocostudio_timeline_BlendFuncFrame_class, + js_cocos2dx_studio_BlendFuncFrame_constructor, 0, // constructor + properties, + funcs, + NULL, // no static properties + st_funcs); + // make the class enumerable in the registered namespace +// bool found; +//FIXME: Removed in Firefox v27 +// JS_SetPropertyAttributes(cx, global, "BlendFuncFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + // add the proto and JSClass to the type->js info hash table + TypeTest t; + js_type_class_t *p; + std::string typeName = t.s_name(); + if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) + { + p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); + p->jsclass = jsb_cocostudio_timeline_BlendFuncFrame_class; + p->proto = jsb_cocostudio_timeline_BlendFuncFrame_prototype; + p->parentProto = jsb_cocostudio_timeline_Frame_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + JSClass *jsb_cocostudio_timeline_Timeline_class; JSObject *jsb_cocostudio_timeline_Timeline_prototype; @@ -13740,6 +13893,7 @@ void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj) { js_register_cocos2dx_studio_Bone(cx, ns); js_register_cocos2dx_studio_ComAttribute(cx, ns); js_register_cocos2dx_studio_TextureData(cx, ns); + js_register_cocos2dx_studio_BlendFuncFrame(cx, ns); js_register_cocos2dx_studio_AlphaFrame(cx, ns); js_register_cocos2dx_studio_ComExtensionData(cx, ns); js_register_cocos2dx_studio_AnimationData(cx, ns); diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.hpp index 54c83e209b..286f8e7f30 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.hpp @@ -668,6 +668,18 @@ bool js_cocos2dx_studio_ZOrderFrame_setZOrder(JSContext *cx, uint32_t argc, jsva bool js_cocos2dx_studio_ZOrderFrame_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ZOrderFrame_ZOrderFrame(JSContext *cx, uint32_t argc, jsval *vp); +extern JSClass *jsb_cocostudio_timeline_BlendFuncFrame_class; +extern JSObject *jsb_cocostudio_timeline_BlendFuncFrame_prototype; + +bool js_cocos2dx_studio_BlendFuncFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_BlendFuncFrame_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_BlendFuncFrame(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_BlendFuncFrame_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_BlendFuncFrame_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_BlendFuncFrame_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_BlendFuncFrame_BlendFuncFrame(JSContext *cx, uint32_t argc, jsval *vp); + extern JSClass *jsb_cocostudio_timeline_Timeline_class; extern JSObject *jsb_cocostudio_timeline_Timeline_prototype; From 393af19237c928de28dca59ca14f2fb22e7dd040 Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Wed, 26 Aug 2015 23:41:48 +0800 Subject: [PATCH 088/118] [Node::scheduleOnce]Fixed the callback will be executed multiple times if the value of delay equal zero. --- cocos/base/CCScheduler.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/cocos/base/CCScheduler.cpp b/cocos/base/CCScheduler.cpp index 0acc1d3b93..7977dfff65 100644 --- a/cocos/base/CCScheduler.cpp +++ b/cocos/base/CCScheduler.cpp @@ -130,19 +130,15 @@ void Timer::update(float dt) trigger(interval); _elapsed -= interval; _timesExecuted += 1; - if (_elapsed <= 0.f) + + if (!_runForever && _timesExecuted > _repeat) { + cancel(); break; } - if (_runForever) + if (_elapsed <= 0.f) { - continue; - } - - if (_timesExecuted > _repeat) - { //unschedule timer - cancel(); break; } } From fcae139857dc9da4b0e3ceff3317a17b493c3b25 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Wed, 26 Aug 2015 08:50:11 -0700 Subject: [PATCH 089/118] removed old WP8_SHADER_COMPILER defines --- cocos/base/CCDirector.cpp | 2 -- cocos/platform/winrt/CCCommon.cpp | 2 -- cocos/platform/winrt/CCDevice.cpp | 2 -- cocos/platform/winrt/CCGL.h | 2 +- cocos/platform/winrt/CCPrecompiledShaders.cpp | 2 +- cocos/platform/winrt/CCPrecompiledShaders.h | 2 +- cocos/platform/winrt/CCWinRTUtils.cpp | 2 -- 7 files changed, 3 insertions(+), 11 deletions(-) diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp index 0ed8559af6..d4fc458a74 100644 --- a/cocos/base/CCDirector.cpp +++ b/cocos/base/CCDirector.cpp @@ -1305,9 +1305,7 @@ void DisplayLinkDirector::startAnimation() _cocos2d_thread_id = std::this_thread::get_id(); -#ifndef WP8_SHADER_COMPILER Application::getInstance()->setAnimationInterval(_animationInterval); -#endif // fix issue #3509, skip one fps to avoid incorrect time calculation. setNextDeltaTimeZero(true); diff --git a/cocos/platform/winrt/CCCommon.cpp b/cocos/platform/winrt/CCCommon.cpp index 8e6a59267c..ff64437fdb 100644 --- a/cocos/platform/winrt/CCCommon.cpp +++ b/cocos/platform/winrt/CCCommon.cpp @@ -38,9 +38,7 @@ void MessageBox(const char * pszMsg, const char * pszTitle) // Create the message dialog and set its content Platform::String^ message = ref new Platform::String(CCUtf8ToUnicode(pszMsg, -1).c_str()); Platform::String^ title = ref new Platform::String(CCUtf8ToUnicode(pszTitle, -1).c_str()); -#ifndef WP8_SHADER_COMPILER GLViewImpl::sharedOpenGLView()->ShowMessageBox(title, message); -#endif } diff --git a/cocos/platform/winrt/CCDevice.cpp b/cocos/platform/winrt/CCDevice.cpp index 529ed20b5b..d7dfcad52f 100644 --- a/cocos/platform/winrt/CCDevice.cpp +++ b/cocos/platform/winrt/CCDevice.cpp @@ -53,7 +53,6 @@ static Accelerometer^ sAccelerometer = nullptr; void Device::setAccelerometerEnabled(bool isEnabled) { -#ifndef WP8_SHADER_COMPILER static Windows::Foundation::EventRegistrationToken sToken; static bool sEnabled = false; @@ -160,7 +159,6 @@ void Device::setAccelerometerEnabled(bool isEnabled) cocos2d::GLViewImpl::sharedOpenGLView()->QueueEvent(event); }); } -#endif } void Device::setAccelerometerInterval(float interval) diff --git a/cocos/platform/winrt/CCGL.h b/cocos/platform/winrt/CCGL.h index 2b39255fed..37a9ef5b32 100644 --- a/cocos/platform/winrt/CCGL.h +++ b/cocos/platform/winrt/CCGL.h @@ -30,7 +30,7 @@ THE SOFTWARE. #define glClearDepth glClearDepthf #define GL_WRITE_ONLY GL_WRITE_ONLY_OES -#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT && !defined(WP8_SHADER_COMPILER) +#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT #include "EGL/egl.h" #include "EGL/eglext.h" #include "EGL/eglplatform.h" diff --git a/cocos/platform/winrt/CCPrecompiledShaders.cpp b/cocos/platform/winrt/CCPrecompiledShaders.cpp index c835e7ee93..5b67b55899 100644 --- a/cocos/platform/winrt/CCPrecompiledShaders.cpp +++ b/cocos/platform/winrt/CCPrecompiledShaders.cpp @@ -185,7 +185,7 @@ bool CCPrecompiledShaders::addProgram(GLuint program, const std::string& id) return true; } -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) && defined(WP8_SHADER_COMPILER) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) void CCPrecompiledShaders::savePrecompiledPrograms(Windows::Storage::StorageFolder^ folder) { diff --git a/cocos/platform/winrt/CCPrecompiledShaders.h b/cocos/platform/winrt/CCPrecompiledShaders.h index 6d8dc289d8..eb853e9e2c 100644 --- a/cocos/platform/winrt/CCPrecompiledShaders.h +++ b/cocos/platform/winrt/CCPrecompiledShaders.h @@ -68,7 +68,7 @@ public: bool loadProgram(GLuint program, const GLchar* vShaderByteArray, const GLchar* fShaderByteArray); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) && defined(WP8_SHADER_COMPILER) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) void savePrecompiledShaders(); #endif diff --git a/cocos/platform/winrt/CCWinRTUtils.cpp b/cocos/platform/winrt/CCWinRTUtils.cpp index 2eed1618c7..a3162d7cc1 100644 --- a/cocos/platform/winrt/CCWinRTUtils.cpp +++ b/cocos/platform/winrt/CCWinRTUtils.cpp @@ -121,7 +121,6 @@ float getScaledDPIValue(float v) { void CC_DLL CCLogIPAddresses() { -#ifndef WP8_SHADER_COMPILER auto hostnames = NetworkInformation::GetHostNames(); int length = hostnames->Size; @@ -134,7 +133,6 @@ void CC_DLL CCLogIPAddresses() log("IP Address: %s:", s.c_str()); } } -#endif } std::string CC_DLL getDeviceIPAddresses() From 4cb3d8823254295d6e715321ef76047082bd9d02 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Wed, 26 Aug 2015 09:19:28 -0700 Subject: [PATCH 090/118] added isWindowsPhone() to correctly detect Windows 10 phone --- cocos/platform/winrt/CCDevice.cpp | 101 ++++++++++++++------------ cocos/platform/winrt/CCWinRTUtils.cpp | 14 ++++ cocos/platform/winrt/CCWinRTUtils.h | 2 +- 3 files changed, 68 insertions(+), 49 deletions(-) diff --git a/cocos/platform/winrt/CCDevice.cpp b/cocos/platform/winrt/CCDevice.cpp index d7dfcad52f..17185d5532 100644 --- a/cocos/platform/winrt/CCDevice.cpp +++ b/cocos/platform/winrt/CCDevice.cpp @@ -30,6 +30,7 @@ THE SOFTWARE. #include "platform/CCDevice.h" #include "platform/CCFileUtils.h" #include "platform/winrt/CCFreeTypeFont.h" +#include "platform/winrt/CCWinRTUtils.h" #include "platform/CCStdC.h" using namespace Windows::Graphics::Display; @@ -97,64 +98,68 @@ void Device::setAccelerometerEnabled(bool isEnabled) auto orientation = GLViewImpl::sharedOpenGLView()->getDeviceOrientation(); -#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) - switch (orientation) + if (isWindowsPhone()) { - case DisplayOrientations::Portrait: - acc.x = reading->AccelerationX; - acc.y = reading->AccelerationY; - break; - - case DisplayOrientations::Landscape: - acc.x = -reading->AccelerationY; - acc.y = reading->AccelerationX; - break; - - case DisplayOrientations::PortraitFlipped: - acc.x = -reading->AccelerationX; - acc.y = reading->AccelerationY; - break; - - case DisplayOrientations::LandscapeFlipped: - acc.x = reading->AccelerationY; - acc.y = -reading->AccelerationX; + switch (orientation) + { + case DisplayOrientations::Portrait: + acc.x = reading->AccelerationX; + acc.y = reading->AccelerationY; break; - default: - acc.x = reading->AccelerationX; - acc.y = reading->AccelerationY; - break; + case DisplayOrientations::Landscape: + acc.x = -reading->AccelerationY; + acc.y = reading->AccelerationX; + break; + + case DisplayOrientations::PortraitFlipped: + acc.x = -reading->AccelerationX; + acc.y = reading->AccelerationY; + break; + + case DisplayOrientations::LandscapeFlipped: + acc.x = reading->AccelerationY; + acc.y = -reading->AccelerationX; + break; + + default: + acc.x = reading->AccelerationX; + acc.y = reading->AccelerationY; + break; + } } -#else // Windows Store App - // from http://msdn.microsoft.com/en-us/library/windows/apps/dn440593 - switch (orientation) + else // Windows Store App { - case DisplayOrientations::Portrait: - acc.x = reading->AccelerationY; - acc.y = -reading->AccelerationX; - break; + // from http://msdn.microsoft.com/en-us/library/windows/apps/dn440593 + switch (orientation) + { + case DisplayOrientations::Portrait: + acc.x = reading->AccelerationY; + acc.y = -reading->AccelerationX; + break; - case DisplayOrientations::Landscape: - acc.x = reading->AccelerationX; - acc.y = reading->AccelerationY; - break; + case DisplayOrientations::Landscape: + acc.x = reading->AccelerationX; + acc.y = reading->AccelerationY; + break; - case DisplayOrientations::PortraitFlipped: - acc.x = -reading->AccelerationY; - acc.y = reading->AccelerationX; - break; + case DisplayOrientations::PortraitFlipped: + acc.x = -reading->AccelerationY; + acc.y = reading->AccelerationX; + break; - case DisplayOrientations::LandscapeFlipped: - acc.x = -reading->AccelerationX; - acc.y = -reading->AccelerationY; - break; + case DisplayOrientations::LandscapeFlipped: + acc.x = -reading->AccelerationX; + acc.y = -reading->AccelerationY; + break; - default: - acc.x = reading->AccelerationY; - acc.y = -reading->AccelerationX; - break; + default: + acc.x = reading->AccelerationY; + acc.y = -reading->AccelerationX; + break; + } } -#endif + std::shared_ptr event(new AccelerometerEvent(acc)); cocos2d::GLViewImpl::sharedOpenGLView()->QueueEvent(event); }); diff --git a/cocos/platform/winrt/CCWinRTUtils.cpp b/cocos/platform/winrt/CCWinRTUtils.cpp index a3162d7cc1..02738ea40f 100644 --- a/cocos/platform/winrt/CCWinRTUtils.cpp +++ b/cocos/platform/winrt/CCWinRTUtils.cpp @@ -47,6 +47,20 @@ using namespace Windows::Storage::Pickers; using namespace Windows::Storage::Streams; using namespace Windows::Networking::Connectivity; +bool isWindowsPhone() +{ +#if _MSC_VER >= 1900 + if (Windows::Foundation::Metadata::ApiInformation::IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) + { + return true; + } +#elif (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) + return true; +#else + return false; +#endif +} + std::wstring CCUtf8ToUnicode(const char * pszUtf8Str, unsigned len/* = -1*/) { std::wstring ret; diff --git a/cocos/platform/winrt/CCWinRTUtils.h b/cocos/platform/winrt/CCWinRTUtils.h index 9f791dd1ea..e89a726684 100644 --- a/cocos/platform/winrt/CCWinRTUtils.h +++ b/cocos/platform/winrt/CCWinRTUtils.h @@ -37,7 +37,7 @@ THE SOFTWARE. NS_CC_BEGIN - +bool isWindowsPhone(); std::wstring CC_DLL CCUtf8ToUnicode(const char * pszUtf8Str, unsigned len = -1); std::string CC_DLL CCUnicodeToUtf8(const wchar_t* pwszStr); Platform::Object^ findXamlElement(Platform::Object^ parent, Platform::String^ name); From 161954da87e2e3d04550f0015d2399cd96c72c65 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Wed, 26 Aug 2015 09:41:23 -0700 Subject: [PATCH 091/118] fixed pdb file output location --- .../editor-support/spine/proj.win10/libSpine.vcxproj | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cocos/editor-support/spine/proj.win10/libSpine.vcxproj b/cocos/editor-support/spine/proj.win10/libSpine.vcxproj index f53067aef1..790ec240dd 100644 --- a/cocos/editor-support/spine/proj.win10/libSpine.vcxproj +++ b/cocos/editor-support/spine/proj.win10/libSpine.vcxproj @@ -383,7 +383,7 @@ 4458;4456;4996;%(DisableSpecificWarnings) $(EngineRoot)external\win10-specific\angle\include;%(AdditionalIncludeDirectories) ProgramDatabase - $(OutDir)$(TargetName).pdb + $(IntDir)$(ProjectName).pdb
Console @@ -402,7 +402,7 @@ false 4458;4456;4996;%(DisableSpecificWarnings) $(EngineRoot)external\win10-specific\angle\include;%(AdditionalIncludeDirectories) - $(OutDir)$(TargetName).pdb + $(IntDir)$(ProjectName).pdb ProgramDatabase
@@ -423,7 +423,7 @@ 4458;4456;4996;%(DisableSpecificWarnings) $(EngineRoot)external\win10-specific\angle\include;%(AdditionalIncludeDirectories) ProgramDatabase - $(OutDir)$(TargetName).pdb + $(IntDir)$(ProjectName).pdb
Console @@ -443,7 +443,7 @@ 4458;4456;4996;%(DisableSpecificWarnings) $(EngineRoot)external\win10-specific\angle\include;%(AdditionalIncludeDirectories) ProgramDatabase - $(OutDir)$(TargetName).pdb + $(IntDir)$(ProjectName).pdb
Console @@ -463,7 +463,7 @@ 4458;4456;4996;%(DisableSpecificWarnings) $(EngineRoot)external\win10-specific\angle\include;%(AdditionalIncludeDirectories) ProgramDatabase - $(OutDir)$(TargetName).pdb + $(IntDir)$(ProjectName).pdb
Console @@ -482,7 +482,7 @@ false 4458;4456;4996;%(DisableSpecificWarnings) $(EngineRoot)external\win10-specific\angle\include;%(AdditionalIncludeDirectories) - $(OutDir)$(TargetName).pdb + $(IntDir)$(ProjectName).pdb ProgramDatabase
From 09a1211c9647fe2df299849aa24fcf590b41ba2f Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Wed, 26 Aug 2015 09:47:59 -0700 Subject: [PATCH 092/118] use isWindowsPhone() to check for Windows Phone platform --- cocos/platform/winrt/CCApplication.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cocos/platform/winrt/CCApplication.cpp b/cocos/platform/winrt/CCApplication.cpp index d6cb848e7f..02dfc998ce 100644 --- a/cocos/platform/winrt/CCApplication.cpp +++ b/cocos/platform/winrt/CCApplication.cpp @@ -214,11 +214,14 @@ LanguageType Application::getCurrentLanguage() Application::Platform Application::getTargetPlatform() { -#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) - return Platform::OS_WP8; -#else - return Platform::OS_WINRT; -#endif + if (isWindowsPhone()) + { + return Platform::OS_WP8; + } + else + { + return Platform::OS_WINRT; + } } bool Application::openURL(const std::string &url) From d5d1be93cca2bb09880d0fb9ba36157ba2ae0adb Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Wed, 26 Aug 2015 10:16:50 -0700 Subject: [PATCH 093/118] make it compile on win32 --- cocos/renderer/CCVertexIndexData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/renderer/CCVertexIndexData.cpp b/cocos/renderer/CCVertexIndexData.cpp index 72807bec34..685c88f677 100644 --- a/cocos/renderer/CCVertexIndexData.cpp +++ b/cocos/renderer/CCVertexIndexData.cpp @@ -141,7 +141,7 @@ void VertexData::use() vertexStreamAttrib._type, vertexStreamAttrib._normalize, vertexBuffer->getSizePerVertex(), - (GLvoid*)((ssize_t)vertexStreamAttrib._offset)); + (GLvoid*)((long)vertexStreamAttrib._offset)); } } From 30d52d1394b293c325d16f0be4af94be58d295fd Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Thu, 27 Aug 2015 17:10:33 +0900 Subject: [PATCH 094/118] Fix #13591 --- .../src/org/cocos2dx/lib/Cocos2dxActivity.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java index 685fd027fc..cadabac2e2 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java @@ -108,6 +108,7 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe private Cocos2dxVideoHelper mVideoHelper = null; private Cocos2dxWebViewHelper mWebViewHelper = null; private Cocos2dxEditBoxHelper mEditBoxHelper = null; + private boolean hasFocus = false; public Cocos2dxGLSurfaceView getGLSurfaceView(){ return mGLSurfaceView; @@ -338,21 +339,30 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe @Override protected void onResume() { + Log.d(TAG, "onResume()"); super.onResume(); + resumeIfHasFocus(); } @Override public void onWindowFocusChanged(boolean hasFocus) { + Log.d(TAG, "onWindowFocusChanged() hasFocus=" + hasFocus); super.onWindowFocusChanged(hasFocus); - if (hasFocus) { - Cocos2dxHelper.onResume(); - mGLSurfaceView.onResume(); + this.hasFocus = hasFocus; + resumeIfHasFocus(); + } + + private void resumeIfHasFocus() { + if(hasFocus) { + Cocos2dxHelper.onResume(); + mGLSurfaceView.onResume(); } } @Override protected void onPause() { + Log.d(TAG, "onPause()"); super.onPause(); Cocos2dxHelper.onPause(); mGLSurfaceView.onPause(); From a060a82d88144e1e52e881f6da4d723a5cea3393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E9=BE=99?= Date: Thu, 27 Aug 2015 17:35:09 +0800 Subject: [PATCH 095/118] fix Action:Place, RotateTo param wrong number error --- cocos/scripting/js-bindings/script/jsb_create_apis.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/scripting/js-bindings/script/jsb_create_apis.js b/cocos/scripting/js-bindings/script/jsb_create_apis.js index 77e4257016..e38362db87 100644 --- a/cocos/scripting/js-bindings/script/jsb_create_apis.js +++ b/cocos/scripting/js-bindings/script/jsb_create_apis.js @@ -546,7 +546,7 @@ cc.Place.prototype._ctor = function(pos, y) { y = pos.y; pos = pos.x; } - this.initWithPosition(pos, y); + this.initWithPosition(cc.p(pos, y)); } }; @@ -609,7 +609,7 @@ cc.RotateTo.prototype._ctor = cc.RotateBy.prototype._ctor = function(duration, d if (deltaAngleY !== undefined) this.initWithDuration(duration, deltaAngleX, deltaAngleY); else - this.initWithDuration(duration, deltaAngleX); + this.initWithDuration(duration, deltaAngleX, deltaAngleX); } }; From b02e110529d98983cbfd08aafd9d06d089edd997 Mon Sep 17 00:00:00 2001 From: VisualSj Date: Thu, 27 Aug 2015 17:39:41 +0800 Subject: [PATCH 096/118] Update web index --- web | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web b/web index d7d08fca58..d17e705f56 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit d7d08fca58b6fcbd5fd533c3687eb8a20074e03d +Subproject commit d17e705f562d97f9cbae5e25a4beb17c02b4686d From ed49250b9bbe38cd3586c275dab61bf47cb1b596 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 27 Aug 2015 18:23:13 +0800 Subject: [PATCH 097/118] update for reader 1.update for sprite3d cullface 2.sync js code --- .../cocostudio/CSParse3DBinary_generated.h | 226 +++++++++--------- .../Sprite3DReader/Sprite3DReader.cpp | 17 +- .../script/jsb_opengl_constants.js | 5 + .../studio/parsers/timelineParser-2.x.js | 79 +++--- 4 files changed, 187 insertions(+), 140 deletions(-) diff --git a/cocos/editor-support/cocostudio/CSParse3DBinary_generated.h b/cocos/editor-support/cocostudio/CSParse3DBinary_generated.h index e8ef83081d..70dcda6f98 100644 --- a/cocos/editor-support/cocostudio/CSParse3DBinary_generated.h +++ b/cocos/editor-support/cocostudio/CSParse3DBinary_generated.h @@ -43,6 +43,7 @@ struct EventFrame; struct IntFrame; struct BoolFrame; struct InnerActionFrame; +struct EasingData; struct RotationSkew; struct Position; struct Scale; @@ -51,7 +52,9 @@ struct Color; struct ColorVector; struct FlatSize; struct CapInsets; +struct BlendFunc; struct ResourceData; +struct BlendFrame; } // namespace flatbuffers namespace flatbuffers { @@ -60,6 +63,7 @@ struct Node3DOption; struct Sprite3DOptions; struct Particle3DOptions; struct UserCameraOptions; +struct GameNode3DOption; struct Vector2; struct Vector3; @@ -93,92 +97,6 @@ MANUALLY_ALIGNED_STRUCT(4) Vector3 { }; STRUCT_END(Vector3, 12); -struct GameNode3DOption : private flatbuffers::Table { - const flatbuffers::String *name() const { return GetPointer(4); } - int32_t skyBoxMask() const { return GetField(6, 0); } - uint8_t skyBoxEnabled() const { return GetField(8, 0); } - const ResourceData *leftFileData() const { return GetPointer(10); } - const ResourceData *rightFileData() const { return GetPointer(12); } - const ResourceData *upFileData() const { return GetPointer(14); } - const ResourceData *downFileData() const { return GetPointer(16); } - const ResourceData *forwardFileData() const { return GetPointer(18); } - const ResourceData *backFileData() const { return GetPointer(20); } - const flatbuffers::String *frameEvent() const { return GetPointer(22); } - const flatbuffers::String *customProperty() const { return GetPointer(24); } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, 4 /* nodeOptions */) && - verifier.Verify(name()) && - VerifyField(verifier, 6 /* skyBoxMask */) && - VerifyField(verifier, 8 /* skyBoxEnabled */) && - VerifyField(verifier, 10 /* leftFileData */) && - verifier.VerifyTable(leftFileData()) && - VerifyField(verifier, 12 /* rightFileData */) && - verifier.VerifyTable(rightFileData()) && - VerifyField(verifier, 14 /* upFileData */) && - verifier.VerifyTable(upFileData()) && - VerifyField(verifier, 16 /* downFileData */) && - verifier.VerifyTable(downFileData()) && - VerifyField(verifier, 18 /* forwardFileData */) && - verifier.VerifyTable(forwardFileData()) && - VerifyField(verifier, 20 /* backFileData */) && - verifier.VerifyTable(backFileData()) && - VerifyField(verifier, 22 /* frameEvent */) && - verifier.Verify(frameEvent()) && - VerifyField(verifier, 24 /* customProperty */) && - verifier.Verify(customProperty()) && - verifier.EndTable(); - } -}; - -struct GameNode3DOptionBuilder { - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_name(flatbuffers::Offset name) { fbb_.AddOffset(4, name); } - void add_skyBoxMask(int32_t skyBoxMask) { fbb_.AddElement(6, skyBoxMask, 0); } - void add_skyboxEnabled(uint8_t skyBoxEnabled) { fbb_.AddElement(8, skyBoxEnabled, 0); } - void add_leftFileData(flatbuffers::Offset leftFileData) { fbb_.AddOffset(10, leftFileData); } - void add_rightFileData(flatbuffers::Offset rightFileData) { fbb_.AddOffset(12, rightFileData); } - void add_upFileData(flatbuffers::Offset upFileData) { fbb_.AddOffset(14, upFileData); } - void add_downFileData(flatbuffers::Offset downFileData) { fbb_.AddOffset(16, downFileData); } - void add_forwardFileData(flatbuffers::Offset forwardFileData) { fbb_.AddOffset(18, forwardFileData); } - void add_backFileData(flatbuffers::Offset backFileData) { fbb_.AddOffset(20, backFileData); } - void add_frameEvent(flatbuffers::Offset frameEvent) { fbb_.AddOffset(22, frameEvent); } - void add_customProperty(flatbuffers::Offset customProperty) { fbb_.AddOffset(24, customProperty); } - GameNode3DOptionBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - flatbuffers::Offset Finish() { - auto o = flatbuffers::Offset(fbb_.EndTable(start_, 11)); - return o; - } -}; - -inline flatbuffers::Offset CreateGameNode3DOption(flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset name = 0, - int32_t skyBoxMask = 0, - uint8_t skyBoxEnabled = 0, - flatbuffers::Offset leftFileData = 0, - flatbuffers::Offset rightFileData = 0, - flatbuffers::Offset upFileData = 0, - flatbuffers::Offset downFileData = 0, - flatbuffers::Offset forwardFileData = 0, - flatbuffers::Offset backFileData = 0, - flatbuffers::Offset frameEvent = 0, - flatbuffers::Offset customProperty = 0) { - GameNode3DOptionBuilder builder_(_fbb); - builder_.add_customProperty(customProperty); - builder_.add_frameEvent(frameEvent); - builder_.add_backFileData(backFileData); - builder_.add_forwardFileData(forwardFileData); - builder_.add_downFileData(downFileData); - builder_.add_upFileData(upFileData); - builder_.add_rightFileData(rightFileData); - builder_.add_leftFileData(leftFileData); - builder_.add_skyboxEnabled(skyBoxEnabled); - builder_.add_skyBoxMask(skyBoxMask); - builder_.add_name(name); - return builder_.Finish(); -} - struct Node3DOption : private flatbuffers::Table { const flatbuffers::WidgetOptions *nodeOptions() const { return GetPointer(4); } const Vector3 *position3D() const { return GetStruct(6); } @@ -232,6 +150,7 @@ struct Sprite3DOptions : private flatbuffers::Table { const Node3DOption *node3DOption() const { return GetPointer(4); } const flatbuffers::ResourceData *fileData() const { return GetPointer(6); } uint8_t runAction() const { return GetField(8, 0); } + uint8_t isFlipped() const { return GetField(10, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, 4 /* node3DOption */) && @@ -239,6 +158,7 @@ struct Sprite3DOptions : private flatbuffers::Table { VerifyField(verifier, 6 /* fileData */) && verifier.VerifyTable(fileData()) && VerifyField(verifier, 8 /* runAction */) && + VerifyField(verifier, 10 /* isFlipped */) && verifier.EndTable(); } }; @@ -249,10 +169,11 @@ struct Sprite3DOptionsBuilder { void add_node3DOption(flatbuffers::Offset node3DOption) { fbb_.AddOffset(4, node3DOption); } void add_fileData(flatbuffers::Offset fileData) { fbb_.AddOffset(6, fileData); } void add_runAction(uint8_t runAction) { fbb_.AddElement(8, runAction, 0); } + void add_isFlipped(uint8_t isFlipped) { fbb_.AddElement(10, isFlipped, 0); } Sprite3DOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } Sprite3DOptionsBuilder &operator=(const Sprite3DOptionsBuilder &); flatbuffers::Offset Finish() { - auto o = flatbuffers::Offset(fbb_.EndTable(start_, 3)); + auto o = flatbuffers::Offset(fbb_.EndTable(start_, 4)); return o; } }; @@ -260,10 +181,12 @@ struct Sprite3DOptionsBuilder { inline flatbuffers::Offset CreateSprite3DOptions(flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset node3DOption = 0, flatbuffers::Offset fileData = 0, - uint8_t runAction = 0) { + uint8_t runAction = 0, + uint8_t isFlipped = 0) { Sprite3DOptionsBuilder builder_(_fbb); builder_.add_fileData(fileData); builder_.add_node3DOption(node3DOption); + builder_.add_isFlipped(isFlipped); builder_.add_runAction(runAction); return builder_.Finish(); } @@ -310,12 +233,12 @@ struct UserCameraOptions : private flatbuffers::Table { float farClip() const { return GetField(10, 1000); } int32_t cameraFlag() const { return GetField(12, 0); } uint8_t skyBoxEnabled() const { return GetField(14, 0); } - const ResourceData *leftFileData() const { return GetPointer(16); } - const ResourceData *rightFileData() const { return GetPointer(18); } - const ResourceData *upFileData() const { return GetPointer(20); } - const ResourceData *downFileData() const { return GetPointer(22); } - const ResourceData *forwardFileData() const { return GetPointer(24); } - const ResourceData *backFileData() const { return GetPointer(26); } + const flatbuffers::ResourceData *leftFileData() const { return GetPointer(16); } + const flatbuffers::ResourceData *rightFileData() const { return GetPointer(18); } + const flatbuffers::ResourceData *upFileData() const { return GetPointer(20); } + const flatbuffers::ResourceData *downFileData() const { return GetPointer(22); } + const flatbuffers::ResourceData *forwardFileData() const { return GetPointer(24); } + const flatbuffers::ResourceData *backFileData() const { return GetPointer(26); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, 4 /* node3DOption */) && @@ -349,13 +272,13 @@ struct UserCameraOptionsBuilder { void add_nearClip(float nearClip) { fbb_.AddElement(8, nearClip, 1); } void add_farClip(float farClip) { fbb_.AddElement(10, farClip, 1000); } void add_cameraFlag(int32_t cameraFlag) { fbb_.AddElement(12, cameraFlag, 0); } - void add_skyboxEnabled(uint8_t skyBoxEnabled) { fbb_.AddElement(14, skyBoxEnabled, 0); } - void add_leftFileData(flatbuffers::Offset leftFileData) { fbb_.AddOffset(16, leftFileData); } - void add_rightFileData(flatbuffers::Offset rightFileData) { fbb_.AddOffset(18, rightFileData); } - void add_upFileData(flatbuffers::Offset upFileData) { fbb_.AddOffset(20, upFileData); } - void add_downFileData(flatbuffers::Offset downFileData) { fbb_.AddOffset(22, downFileData); } - void add_forwardFileData(flatbuffers::Offset forwardFileData) { fbb_.AddOffset(24, forwardFileData); } - void add_backFileData(flatbuffers::Offset backFileData) { fbb_.AddOffset(26, backFileData); } + void add_skyBoxEnabled(uint8_t skyBoxEnabled) { fbb_.AddElement(14, skyBoxEnabled, 0); } + void add_leftFileData(flatbuffers::Offset leftFileData) { fbb_.AddOffset(16, leftFileData); } + void add_rightFileData(flatbuffers::Offset rightFileData) { fbb_.AddOffset(18, rightFileData); } + void add_upFileData(flatbuffers::Offset upFileData) { fbb_.AddOffset(20, upFileData); } + void add_downFileData(flatbuffers::Offset downFileData) { fbb_.AddOffset(22, downFileData); } + void add_forwardFileData(flatbuffers::Offset forwardFileData) { fbb_.AddOffset(24, forwardFileData); } + void add_backFileData(flatbuffers::Offset backFileData) { fbb_.AddOffset(26, backFileData); } UserCameraOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } UserCameraOptionsBuilder &operator=(const UserCameraOptionsBuilder &); flatbuffers::Offset Finish() { @@ -371,12 +294,12 @@ inline flatbuffers::Offset CreateUserCameraOptions(flatbuffer float farClip = 1000, int32_t cameraFlag = 0, uint8_t skyBoxEnabled = 0, - flatbuffers::Offset leftFileData = 0, - flatbuffers::Offset rightFileData = 0, - flatbuffers::Offset upFileData = 0, - flatbuffers::Offset downFileData = 0, - flatbuffers::Offset forwardFileData = 0, - flatbuffers::Offset backFileData = 0) { + flatbuffers::Offset leftFileData = 0, + flatbuffers::Offset rightFileData = 0, + flatbuffers::Offset upFileData = 0, + flatbuffers::Offset downFileData = 0, + flatbuffers::Offset forwardFileData = 0, + flatbuffers::Offset backFileData = 0) { UserCameraOptionsBuilder builder_(_fbb); builder_.add_backFileData(backFileData); builder_.add_forwardFileData(forwardFileData); @@ -384,12 +307,99 @@ inline flatbuffers::Offset CreateUserCameraOptions(flatbuffer builder_.add_upFileData(upFileData); builder_.add_rightFileData(rightFileData); builder_.add_leftFileData(leftFileData); - builder_.add_skyboxEnabled(skyBoxEnabled); builder_.add_cameraFlag(cameraFlag); builder_.add_farClip(farClip); builder_.add_nearClip(nearClip); builder_.add_fov(fov); builder_.add_node3DOption(node3DOption); + builder_.add_skyBoxEnabled(skyBoxEnabled); + return builder_.Finish(); +} + +struct GameNode3DOption : private flatbuffers::Table { + const flatbuffers::String *name() const { return GetPointer(4); } + int32_t skyBoxMask() const { return GetField(6, 0); } + uint8_t skyBoxEnabled() const { return GetField(8, 0); } + const flatbuffers::ResourceData *leftFileData() const { return GetPointer(10); } + const flatbuffers::ResourceData *rightFileData() const { return GetPointer(12); } + const flatbuffers::ResourceData *upFileData() const { return GetPointer(14); } + const flatbuffers::ResourceData *downFileData() const { return GetPointer(16); } + const flatbuffers::ResourceData *forwardFileData() const { return GetPointer(18); } + const flatbuffers::ResourceData *backFileData() const { return GetPointer(20); } + const flatbuffers::String *frameEvent() const { return GetPointer(22); } + const flatbuffers::String *customProperty() const { return GetPointer(24); } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, 4 /* name */) && + verifier.Verify(name()) && + VerifyField(verifier, 6 /* skyBoxMask */) && + VerifyField(verifier, 8 /* skyBoxEnabled */) && + VerifyField(verifier, 10 /* leftFileData */) && + verifier.VerifyTable(leftFileData()) && + VerifyField(verifier, 12 /* rightFileData */) && + verifier.VerifyTable(rightFileData()) && + VerifyField(verifier, 14 /* upFileData */) && + verifier.VerifyTable(upFileData()) && + VerifyField(verifier, 16 /* downFileData */) && + verifier.VerifyTable(downFileData()) && + VerifyField(verifier, 18 /* forwardFileData */) && + verifier.VerifyTable(forwardFileData()) && + VerifyField(verifier, 20 /* backFileData */) && + verifier.VerifyTable(backFileData()) && + VerifyField(verifier, 22 /* frameEvent */) && + verifier.Verify(frameEvent()) && + VerifyField(verifier, 24 /* customProperty */) && + verifier.Verify(customProperty()) && + verifier.EndTable(); + } +}; + +struct GameNode3DOptionBuilder { + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_name(flatbuffers::Offset name) { fbb_.AddOffset(4, name); } + void add_skyBoxMask(int32_t skyBoxMask) { fbb_.AddElement(6, skyBoxMask, 0); } + void add_skyBoxEnabled(uint8_t skyBoxEnabled) { fbb_.AddElement(8, skyBoxEnabled, 0); } + void add_leftFileData(flatbuffers::Offset leftFileData) { fbb_.AddOffset(10, leftFileData); } + void add_rightFileData(flatbuffers::Offset rightFileData) { fbb_.AddOffset(12, rightFileData); } + void add_upFileData(flatbuffers::Offset upFileData) { fbb_.AddOffset(14, upFileData); } + void add_downFileData(flatbuffers::Offset downFileData) { fbb_.AddOffset(16, downFileData); } + void add_forwardFileData(flatbuffers::Offset forwardFileData) { fbb_.AddOffset(18, forwardFileData); } + void add_backFileData(flatbuffers::Offset backFileData) { fbb_.AddOffset(20, backFileData); } + void add_frameEvent(flatbuffers::Offset frameEvent) { fbb_.AddOffset(22, frameEvent); } + void add_customProperty(flatbuffers::Offset customProperty) { fbb_.AddOffset(24, customProperty); } + GameNode3DOptionBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } + GameNode3DOptionBuilder &operator=(const GameNode3DOptionBuilder &); + flatbuffers::Offset Finish() { + auto o = flatbuffers::Offset(fbb_.EndTable(start_, 11)); + return o; + } +}; + +inline flatbuffers::Offset CreateGameNode3DOption(flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset name = 0, + int32_t skyBoxMask = 0, + uint8_t skyBoxEnabled = 0, + flatbuffers::Offset leftFileData = 0, + flatbuffers::Offset rightFileData = 0, + flatbuffers::Offset upFileData = 0, + flatbuffers::Offset downFileData = 0, + flatbuffers::Offset forwardFileData = 0, + flatbuffers::Offset backFileData = 0, + flatbuffers::Offset frameEvent = 0, + flatbuffers::Offset customProperty = 0) { + GameNode3DOptionBuilder builder_(_fbb); + builder_.add_customProperty(customProperty); + builder_.add_frameEvent(frameEvent); + builder_.add_backFileData(backFileData); + builder_.add_forwardFileData(forwardFileData); + builder_.add_downFileData(downFileData); + builder_.add_upFileData(upFileData); + builder_.add_rightFileData(rightFileData); + builder_.add_leftFileData(leftFileData); + builder_.add_skyBoxMask(skyBoxMask); + builder_.add_name(name); + builder_.add_skyBoxEnabled(skyBoxEnabled); return builder_.Finish(); } diff --git a/cocos/editor-support/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.cpp index 48ea48db4c..b9a7e588e8 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.cpp @@ -109,6 +109,7 @@ namespace cocostudio bool runAction = false; std::string path; int resourceType = 0; + bool isFlipped = false; std::string attriname; const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute(); @@ -120,7 +121,10 @@ namespace cocostudio if(attriname == "RunAction3D") { runAction = value == "True" ? true : false; - break; + } + else if (attriname == "IsFlipped") + { + isFlipped = value == "True" ? true : false; } attribute = attribute->Next(); @@ -170,7 +174,8 @@ namespace cocostudio builder->CreateString(path), builder->CreateString(""), resourceType), - runAction + runAction, + isFlipped ); return *(Offset*)(&options); @@ -184,6 +189,7 @@ namespace cocostudio auto options = (Sprite3DOptions*)sprite3DOptions; bool runAction = options->runAction() != 0; + bool isFlipped = options->isFlipped() != 0; auto fileData = options->fileData(); std::string path = fileData->path()->c_str(); @@ -213,6 +219,11 @@ namespace cocostudio { sprite3D->setColor(Color3B(red, green, blue)); } + if (isFlipped) + { + sprite3D->setCullFaceEnabled(true); + sprite3D->setCullFace(GL_FRONT); + } auto node3DReader = Node3DReader::getInstance(); node3DReader->setPropsWithFlatBuffers(sprite3D, (Table*)(options->node3DOption())); @@ -230,7 +241,7 @@ namespace cocostudio { ret->initWithFile(path); } - + setPropsWithFlatBuffers(ret, sprite3DOptions); return ret; diff --git a/cocos/scripting/js-bindings/script/jsb_opengl_constants.js b/cocos/scripting/js-bindings/script/jsb_opengl_constants.js index d9bed9393c..da648e6e1a 100644 --- a/cocos/scripting/js-bindings/script/jsb_opengl_constants.js +++ b/cocos/scripting/js-bindings/script/jsb_opengl_constants.js @@ -826,6 +826,11 @@ gl.WRITEONLY_RENDERING_QCOM = 0x8823; gl.WRITE_ONLY_OES = 0x88b9; gl.Z400_BINARY_AMD = 0x8740; gl.ZERO = 0x0; +gl.FRONT = 0x0404; +gl.BACK = 0x0405; +gl.LEFT = 0x0406; +gl.RIGHT = 0x0407; +gl.FRONT_AND_BACK = 0x0408; //------------Shader Name--------------- /** diff --git a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js index 1ecc5a070b..5699352c79 100644 --- a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js +++ b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js @@ -160,6 +160,7 @@ } }; + var skyBoxBrushInstance = null; var getSkyboxRes = function(json, key) { if(json.hasOwnProperty(key) && json[key].hasOwnProperty("Path")) { return json[key]["Path"]; @@ -172,7 +173,7 @@ * @param json * @returns {cc.Node} */ - parser.initSingleNode = function(json){ + parser.initSingleNode = function(json, resourcePath){ var node = new cc.Node(); this.generalAttributes(node, json); @@ -180,23 +181,25 @@ if(color != null) node.setColor(getColor(color)); - if(json.hasOwnProperty("SkyBoxEnabled") && true == json["SkyBoxEnabled"]) + if(json.hasOwnProperty("SkyBoxEnabled") && true == json["SkyBoxEnabled"]&& + json.hasOwnProperty("SkyBoxValid") && true == json["SkyBoxValid"]) { - var leftFileData = getSkyboxRes(json, "LeftImage"); - var rightFileData = getSkyboxRes(json, "RightImage"); - var upFileData = getSkyboxRes(json, "UpImage"); - var downFileData = getSkyboxRes(json, "DownImage"); - var forwardFileData = getSkyboxRes(json, "ForwardImage"); - var backFileData = getSkyboxRes(json, "BackImage"); - var cameraFlag = json["SkyBoxMask"]; - if(undefined === cameraFlag || isNaN(cameraFlag)) { - cameraFlag = 1024; + var leftFileData = resourcePath + getSkyboxRes(json, "LeftImage"); + var rightFileData = resourcePath + getSkyboxRes(json, "RightImage"); + var upFileData = resourcePath + getSkyboxRes(json, "UpImage"); + var downFileData = resourcePath + getSkyboxRes(json, "DownImage"); + var forwardFileData = resourcePath + getSkyboxRes(json, "ForwardImage"); + var backFileData = resourcePath + getSkyboxRes(json, "BackImage"); + var fileUtil = jsb.fileUtils; + if(fileUtil.isFileExist(leftFileData)&& + fileUtil.isFileExist(rightFileData)&& + fileUtil.isFileExist(upFileData)&& + fileUtil.isFileExist(downFileData)&& + fileUtil.isFileExist(forwardFileData)&& + fileUtil.isFileExist(backFileData)) + { + skyBoxBrushInstance = cc.CameraBackgroundSkyBoxBrush.create(leftFileData,rightFileData,upFileData,downFileData,forwardFileData,backFileData); } - - var skyBox = new jsb.Skybox(); - skyBox.init(leftFileData,rightFileData,upFileData,downFileData,forwardFileData,backFileData); - skyBox.setCameraMask(cameraFlag, false); - node.addChild(skyBox); } return node; @@ -1439,7 +1442,7 @@ * @param json * @returns {*} */ - parser.initCamera = function(json){ + parser.initCamera = function(json,resourcePath){ var s = cc.winSize; var fov = json["Fov"] ? json["Fov"] : 60; @@ -1500,21 +1503,34 @@ node.setCameraFlag(cameraFlag); } - if(json.hasOwnProperty("SkyBoxEnabled") && true == json["SkyBoxEnabled"]) + if(json.hasOwnProperty("SkyBoxEnabled") && true == json["SkyBoxEnabled"] && + json.hasOwnProperty("SkyBoxValid") && true == json["SkyBoxValid"]) { - var leftFileData = getSkyboxRes(json, "LeftImage"); - var rightFileData = getSkyboxRes(json, "RightImage"); - var upFileData = getSkyboxRes(json, "UpImage"); - var downFileData = getSkyboxRes(json, "DownImage"); - var forwardFileData = getSkyboxRes(json, "ForwardImage"); - var backFileData = getSkyboxRes(json, "BackImage"); + var leftFileData = resourcePath + getSkyboxRes(json, "LeftImage"); + var rightFileData = resourcePath + getSkyboxRes(json, "RightImage"); + var upFileData = resourcePath + getSkyboxRes(json, "UpImage"); + var downFileData = resourcePath + getSkyboxRes(json, "DownImage"); + var forwardFileData = resourcePath + getSkyboxRes(json, "ForwardImage"); + var backFileData = resourcePath + getSkyboxRes(json, "BackImage"); - var skyBox = new jsb.Skybox(); - skyBox.init(leftFileData,rightFileData,upFileData,downFileData,forwardFileData,backFileData); - skyBox.setCameraMask(cameraFlag); - node.addChild(skyBox); + var fileUtil = jsb.fileUtils; + if(fileUtil.isFileExist(leftFileData)&& + fileUtil.isFileExist(rightFileData)&& + fileUtil.isFileExist(upFileData)&& + fileUtil.isFileExist(downFileData)&& + fileUtil.isFileExist(forwardFileData)&& + fileUtil.isFileExist(backFileData)) + { + var innerBrush = cc.CameraBackgroundSkyBoxBrush.create(leftFileData,rightFileData,upFileData,downFileData,forwardFileData,backFileData); + node.setBackgroundBrush(innerBrush); + } + else + node.setBackgroundBrush(skyBoxBrushInstance); } - + else if(skyBoxBrushInstance != null) + { + node.setBackgroundBrush(skyBoxBrushInstance); + } return node; }; @@ -1546,6 +1562,11 @@ node.setColor(col); } + if(json.hasOwnProperty("IsFlipped") && true == json["IsFlipped"]) { + node.setCullFaceEnabled(true); + node.setCullFace(gl.FRONT); + } + var autoAction = getParam(json["RunAction3D"], false); if(autoAction && resFile){ var animation = jsb.Animation3D.create(resFile, ""); From 40492e6169ee244d1c27f30ea64c44054ef34b44 Mon Sep 17 00:00:00 2001 From: andyque Date: Thu, 27 Aug 2015 23:34:39 +0800 Subject: [PATCH 098/118] fix Slider create missing res type. fixed https://github.com/cocos2d/cocos2d-x/issues/13575 --- cocos/ui/UISlider.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/ui/UISlider.cpp b/cocos/ui/UISlider.cpp index a827b6e87a..54371e1e60 100644 --- a/cocos/ui/UISlider.cpp +++ b/cocos/ui/UISlider.cpp @@ -98,8 +98,8 @@ Slider* Slider::create(const std::string& barTextureName, Slider* widget = new (std::nothrow) Slider(); if (widget && widget->init()) { - widget->loadBarTexture(barTextureName); - widget->loadSlidBallTextureNormal(normalBallTextureName); + widget->loadBarTexture(barTextureName, resType); + widget->loadSlidBallTextureNormal(normalBallTextureName, resType); widget->autorelease(); return widget; } From 104013aebeeb2c04b5738c07a2fb0cb1bc5283fa Mon Sep 17 00:00:00 2001 From: Vladimir Perminov Date: Thu, 27 Aug 2015 23:19:30 +0300 Subject: [PATCH 099/118] commit v3.8 overwrite this unused code From commit #13397 --- cocos/audio/winrt/Audio.cpp | 47 ------------------------------------- 1 file changed, 47 deletions(-) diff --git a/cocos/audio/winrt/Audio.cpp b/cocos/audio/winrt/Audio.cpp index bcf74e31aa..5da8a06272 100644 --- a/cocos/audio/winrt/Audio.cpp +++ b/cocos/audio/winrt/Audio.cpp @@ -484,53 +484,6 @@ bool Audio::IsSoundEffectPaused(unsigned int sound) return m_soundEffects[sound].m_soundEffectPaused; } -std::wstring CCUtf8ToUnicode(const char * pszUtf8Str) -{ - std::wstring ret; - do - { - if (! pszUtf8Str) break; - size_t len = strlen(pszUtf8Str); - if (len <= 0) break; - ++len; - wchar_t * pwszStr = new wchar_t[len]; - if (! pwszStr) break; - pwszStr[len - 1] = 0; - MultiByteToWideChar(CP_UTF8, 0, pszUtf8Str, len, pwszStr, len); - ret = pwszStr; - - if(pwszStr) { - delete[] (pwszStr); - (pwszStr) = 0; - } - - - } while (0); - return ret; -} - -std::string CCUnicodeToUtf8(const wchar_t* pwszStr) -{ - std::string ret; - do - { - if(! pwszStr) break; - size_t len = wcslen(pwszStr); - if (len <= 0) break; - - char * pszUtf8Str = new char[len*3 + 1]; - WideCharToMultiByte(CP_UTF8, 0, pwszStr, len+1, pszUtf8Str, len*3 + 1, 0, 0); - ret = pszUtf8Str; - - if(pszUtf8Str) { - delete[] (pszUtf8Str); - (pszUtf8Str) = 0; - } - }while(0); - - return ret; -} - void Audio::PreloadSoundEffect(const char* pszFilePath, bool isMusic) { if (m_engineExperiencedCriticalError) { From b5688f504c5a91dba052de88c6b2933fe7ef0086 Mon Sep 17 00:00:00 2001 From: Vladimir Perminov Date: Thu, 27 Aug 2015 23:46:24 +0300 Subject: [PATCH 100/118] Desktop and WinRT use correct keyboard codes Desktop: GLFW_KEY_ENTER equals KEY_ENTER ( GLFW_KEY_KP_ENTER = KEY_KP_ENTER) WinRT: VK_PRIOR equals KEY_PG_UP ( not KEY_KP_PG_UP ) --- cocos/platform/desktop/CCGLViewImpl-desktop.cpp | 8 ++++---- cocos/platform/winrt/Keyboard-winrt.cpp | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cocos/platform/desktop/CCGLViewImpl-desktop.cpp b/cocos/platform/desktop/CCGLViewImpl-desktop.cpp index 17c88cb170..e35894bf43 100644 --- a/cocos/platform/desktop/CCGLViewImpl-desktop.cpp +++ b/cocos/platform/desktop/CCGLViewImpl-desktop.cpp @@ -186,7 +186,7 @@ static keyCodeItem g_keyCodeStructArray[] = { /* Function keys */ { GLFW_KEY_ESCAPE , EventKeyboard::KeyCode::KEY_ESCAPE }, - { GLFW_KEY_ENTER , EventKeyboard::KeyCode::KEY_KP_ENTER }, + { GLFW_KEY_ENTER , EventKeyboard::KeyCode::KEY_ENTER }, { GLFW_KEY_TAB , EventKeyboard::KeyCode::KEY_TAB }, { GLFW_KEY_BACKSPACE , EventKeyboard::KeyCode::KEY_BACKSPACE }, { GLFW_KEY_INSERT , EventKeyboard::KeyCode::KEY_INSERT }, @@ -195,9 +195,9 @@ static keyCodeItem g_keyCodeStructArray[] = { { GLFW_KEY_LEFT , EventKeyboard::KeyCode::KEY_LEFT_ARROW }, { GLFW_KEY_DOWN , EventKeyboard::KeyCode::KEY_DOWN_ARROW }, { GLFW_KEY_UP , EventKeyboard::KeyCode::KEY_UP_ARROW }, - { GLFW_KEY_PAGE_UP , EventKeyboard::KeyCode::KEY_KP_PG_UP }, - { GLFW_KEY_PAGE_DOWN , EventKeyboard::KeyCode::KEY_KP_PG_DOWN }, - { GLFW_KEY_HOME , EventKeyboard::KeyCode::KEY_KP_HOME }, + { GLFW_KEY_PAGE_UP , EventKeyboard::KeyCode::KEY_PG_UP }, + { GLFW_KEY_PAGE_DOWN , EventKeyboard::KeyCode::KEY_PG_DOWN }, + { GLFW_KEY_HOME , EventKeyboard::KeyCode::KEY_HOME }, { GLFW_KEY_END , EventKeyboard::KeyCode::KEY_END }, { GLFW_KEY_CAPS_LOCK , EventKeyboard::KeyCode::KEY_CAPS_LOCK }, { GLFW_KEY_SCROLL_LOCK , EventKeyboard::KeyCode::KEY_SCROLL_LOCK }, diff --git a/cocos/platform/winrt/Keyboard-winrt.cpp b/cocos/platform/winrt/Keyboard-winrt.cpp index f844159b36..491a649c4c 100644 --- a/cocos/platform/winrt/Keyboard-winrt.cpp +++ b/cocos/platform/winrt/Keyboard-winrt.cpp @@ -117,9 +117,9 @@ static keyCodeItem g_keyCodeStructArray [] = { { (int) VirtualKey::Left, EventKeyboard::KeyCode::KEY_LEFT_ARROW }, { (int) VirtualKey::Down, EventKeyboard::KeyCode::KEY_DOWN_ARROW }, { (int) VirtualKey::Up, EventKeyboard::KeyCode::KEY_UP_ARROW }, - { VK_PRIOR, EventKeyboard::KeyCode::KEY_KP_PG_UP }, - { VK_NEXT, EventKeyboard::KeyCode::KEY_KP_PG_DOWN }, - { VK_HOME, EventKeyboard::KeyCode::KEY_KP_HOME }, + { VK_PRIOR, EventKeyboard::KeyCode::KEY_PG_UP }, + { VK_NEXT, EventKeyboard::KeyCode::KEY_PG_DOWN }, + { VK_HOME, EventKeyboard::KeyCode::KEY_HOME }, { VK_END, EventKeyboard::KeyCode::KEY_END }, { VK_CAPITAL, EventKeyboard::KeyCode::KEY_CAPS_LOCK }, { VK_SCROLL, EventKeyboard::KeyCode::KEY_SCROLL_LOCK }, From 69da65d7a4d698c137eefb6ef91314adcb993b81 Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 28 Aug 2015 08:42:55 +0800 Subject: [PATCH 101/118] update for jsb_opengl_constants --- cocos/scripting/js-bindings/script/jsb_opengl_constants.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cocos/scripting/js-bindings/script/jsb_opengl_constants.js b/cocos/scripting/js-bindings/script/jsb_opengl_constants.js index da648e6e1a..1a2b892da5 100644 --- a/cocos/scripting/js-bindings/script/jsb_opengl_constants.js +++ b/cocos/scripting/js-bindings/script/jsb_opengl_constants.js @@ -381,6 +381,7 @@ gl.INVERT = 0x150a; gl.KEEP = 0x1e00; gl.KHR_debug = 0x1; gl.KHR_texture_compression_astc_ldr = 0x1; +gl.LEFT = 0x0406; gl.LEQUAL = 0x203; gl.LESS = 0x201; gl.LINEAR = 0x2601; @@ -620,6 +621,7 @@ gl.RGBA4_OES = 0x8056; gl.RGBA8_OES = 0x8058; gl.RGB_422_APPLE = 0x8a1f; gl.RG_EXT = 0x8227; +gl.RIGHT = 0x0407; gl.SAMPLER = 0x82e6; gl.SAMPLER_2D = 0x8b5e; gl.SAMPLER_2D_ARRAY_SHADOW_NV = 0x8dc4; @@ -826,11 +828,6 @@ gl.WRITEONLY_RENDERING_QCOM = 0x8823; gl.WRITE_ONLY_OES = 0x88b9; gl.Z400_BINARY_AMD = 0x8740; gl.ZERO = 0x0; -gl.FRONT = 0x0404; -gl.BACK = 0x0405; -gl.LEFT = 0x0406; -gl.RIGHT = 0x0407; -gl.FRONT_AND_BACK = 0x0408; //------------Shader Name--------------- /** From 6fa6f1f0dae198450f913ae73197c0e5f15ab17f Mon Sep 17 00:00:00 2001 From: yangxiao Date: Fri, 28 Aug 2015 11:46:11 +0800 Subject: [PATCH 102/118] enable depth write --- cocos/2d/CCCameraBackgroundBrush.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cocos/2d/CCCameraBackgroundBrush.cpp b/cocos/2d/CCCameraBackgroundBrush.cpp index e8d6d668f4..d5886888db 100644 --- a/cocos/2d/CCCameraBackgroundBrush.cpp +++ b/cocos/2d/CCCameraBackgroundBrush.cpp @@ -308,6 +308,9 @@ void CameraBackgroundSkyBoxBrush::drawBackground(Camera* camera) glEnable(GL_DEPTH_TEST); RenderState::StateBlock::_defaultState->setDepthTest(true); + glDepthMask(GL_TRUE); + RenderState::StateBlock::_defaultState->setDepthWrite(true); + glDepthFunc(GL_ALWAYS); RenderState::StateBlock::_defaultState->setDepthFunction(RenderState::DEPTH_ALWAYS); From 2d77609fb7621e8c0660c17dac9806bc78f4620e Mon Sep 17 00:00:00 2001 From: VisualSj Date: Fri, 28 Aug 2015 11:48:58 +0800 Subject: [PATCH 103/118] Update socket@1.3.6 and web index --- tests/js-tests/src/ExtensionsTest/NetworkTest/SocketIOTest.js | 2 +- web | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/js-tests/src/ExtensionsTest/NetworkTest/SocketIOTest.js b/tests/js-tests/src/ExtensionsTest/NetworkTest/SocketIOTest.js index 57af0589b1..61b185fa08 100644 --- a/tests/js-tests/src/ExtensionsTest/NetworkTest/SocketIOTest.js +++ b/tests/js-tests/src/ExtensionsTest/NetworkTest/SocketIOTest.js @@ -193,7 +193,7 @@ var SocketIOTestLayer = cc.Layer.extend({ onMenuSIOEndpointClicked: function(sender) { //repeat the same connection steps for the namespace "testpoint" - var sioendpoint = SocketIO.connect("ws://tools.itharbors.com:4000/testpoint"); + var sioendpoint = SocketIO.connect("ws://tools.itharbors.com:4000/testpoint", {"force new connection" : true}); //a tag to differentiate in shared callbacks sioendpoint.tag = "Test Endpoint"; diff --git a/web b/web index d17e705f56..63a21206cd 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit d17e705f562d97f9cbae5e25a4beb17c02b4686d +Subproject commit 63a21206cd0fc6e80fc074727293a6c95be6b6ea From 6a7922caf1433532d63a4a22a805224554956ca4 Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 28 Aug 2015 14:10:41 +0800 Subject: [PATCH 104/118] rename contribute.md to contributing.md --- docs/CONTRIBUTE.md => CONTRIBUTING.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/CONTRIBUTE.md => CONTRIBUTING.md (100%) diff --git a/docs/CONTRIBUTE.md b/CONTRIBUTING.md similarity index 100% rename from docs/CONTRIBUTE.md rename to CONTRIBUTING.md From 8a1b74125b7065c8a21375a284e2e5ed42d49447 Mon Sep 17 00:00:00 2001 From: Vladimir Perminov Date: Fri, 28 Aug 2015 11:35:29 +0300 Subject: [PATCH 105/118] Correct contribution in v3.8 --- AUTHORS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AUTHORS b/AUTHORS index 53eb9bed07..696cef8b7a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1157,7 +1157,10 @@ Developers: perminovVS Optimize Vec3 and Vec2 Added `UserDefault::setDelegate()` + FileUtils: Added FileUtils::getSuitableFOpen() for convert utf8 to locale, for specific platform platform: Correct all usage of unicode version winapi in FileUtils for win32 + FileUtils: Added FileUtils::getFileExtension for getting file's extension name + utils: Made utils::captureScreen saving file in another thread to improve the performance qiutaoleo Added a feature to check case characters for filename on windows From bc07d7954a7cfc7fe97500611f1016bd8964f9bd Mon Sep 17 00:00:00 2001 From: yangxiao Date: Fri, 28 Aug 2015 23:00:45 +0800 Subject: [PATCH 106/118] fix render state --- cocos/3d/CCMesh.cpp | 1 + cocos/renderer/CCRenderer.cpp | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/cocos/3d/CCMesh.cpp b/cocos/3d/CCMesh.cpp index 8239f9085f..d8ea82cf06 100644 --- a/cocos/3d/CCMesh.cpp +++ b/cocos/3d/CCMesh.cpp @@ -359,6 +359,7 @@ void Mesh::draw(Renderer* renderer, float globalZOrder, const Mat4& transform, u _meshCommand.setSkipBatching(isTransparent); _meshCommand.setTransparent(isTransparent); _meshCommand.set3D(!_force2DQueue); + _material->getStateBlock()->setBlend(_force2DQueue || isTransparent); // set default uniforms for Mesh // 'u_color' and others diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index 1aef8015e5..3dcd282d6e 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -543,15 +543,19 @@ void Renderer::visitRenderQueue(RenderQueue& queue) { glEnable(GL_DEPTH_TEST); glDepthMask(true); + glEnable(GL_BLEND); RenderState::StateBlock::_defaultState->setDepthTest(true); RenderState::StateBlock::_defaultState->setDepthWrite(true); + RenderState::StateBlock::_defaultState->setBlend(true); } else { glDisable(GL_DEPTH_TEST); glDepthMask(false); + glEnable(GL_BLEND); RenderState::StateBlock::_defaultState->setDepthTest(false); RenderState::StateBlock::_defaultState->setDepthWrite(false); + RenderState::StateBlock::_defaultState->setBlend(true); } for (auto it = zNegQueue.cbegin(); it != zNegQueue.cend(); ++it) { @@ -569,8 +573,10 @@ void Renderer::visitRenderQueue(RenderQueue& queue) //Clear depth to achieve layered rendering glEnable(GL_DEPTH_TEST); glDepthMask(true); + glDisable(GL_BLEND); RenderState::StateBlock::_defaultState->setDepthTest(true); RenderState::StateBlock::_defaultState->setDepthWrite(true); + RenderState::StateBlock::_defaultState->setBlend(false); for (auto it = opaqueQueue.cbegin(); it != opaqueQueue.cend(); ++it) @@ -588,9 +594,11 @@ void Renderer::visitRenderQueue(RenderQueue& queue) { glEnable(GL_DEPTH_TEST); glDepthMask(false); + glEnable(GL_BLEND); RenderState::StateBlock::_defaultState->setDepthTest(true); RenderState::StateBlock::_defaultState->setDepthWrite(false); + RenderState::StateBlock::_defaultState->setBlend(true); for (auto it = transQueue.cbegin(); it != transQueue.cend(); ++it) @@ -610,18 +618,22 @@ void Renderer::visitRenderQueue(RenderQueue& queue) { glEnable(GL_DEPTH_TEST); glDepthMask(true); + glEnable(GL_BLEND); RenderState::StateBlock::_defaultState->setDepthTest(true); RenderState::StateBlock::_defaultState->setDepthWrite(true); + RenderState::StateBlock::_defaultState->setBlend(true); } else { glDisable(GL_DEPTH_TEST); glDepthMask(false); + glEnable(GL_BLEND); RenderState::StateBlock::_defaultState->setDepthTest(false); RenderState::StateBlock::_defaultState->setDepthWrite(false); + RenderState::StateBlock::_defaultState->setBlend(true); } for (auto it = zZeroQueue.cbegin(); it != zZeroQueue.cend(); ++it) @@ -637,6 +649,29 @@ void Renderer::visitRenderQueue(RenderQueue& queue) const auto& zPosQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::GLOBALZ_POS); if (zPosQueue.size() > 0) { + if(_isDepthTestFor2D) + { + glEnable(GL_DEPTH_TEST); + glDepthMask(true); + glEnable(GL_BLEND); + + RenderState::StateBlock::_defaultState->setDepthTest(true); + RenderState::StateBlock::_defaultState->setDepthWrite(true); + RenderState::StateBlock::_defaultState->setBlend(true); + + } + else + { + glDisable(GL_DEPTH_TEST); + glDepthMask(false); + glEnable(GL_BLEND); + + RenderState::StateBlock::_defaultState->setDepthTest(false); + RenderState::StateBlock::_defaultState->setDepthWrite(false); + RenderState::StateBlock::_defaultState->setBlend(true); + + } + for (auto it = zPosQueue.cbegin(); it != zPosQueue.cend(); ++it) { processRenderCommand(*it); From 8e195723e610dc72345bd4086087cfed0ab92301 Mon Sep 17 00:00:00 2001 From: frranck Date: Sun, 30 Aug 2015 09:40:15 +0200 Subject: [PATCH 107/118] Update CCImage.cpp When you're creating a sprite (e.g. with Sprite* Sprite::create(filename)) There's no way to test the file before, without getting "a unsupport image format!" thrown. --- cocos/platform/CCImage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/platform/CCImage.cpp b/cocos/platform/CCImage.cpp index 3ff9040b2f..3373c8b5b3 100644 --- a/cocos/platform/CCImage.cpp +++ b/cocos/platform/CCImage.cpp @@ -576,7 +576,7 @@ bool Image::initWithImageData(const unsigned char * data, ssize_t dataLen) } else { - CCAssert(false, "unsupport image format!"); + CCLOG("cocos2d: unsupported image format!"); } free(tgaData); From 2520e16cc00c95c93482a04522da9fddb1836fd1 Mon Sep 17 00:00:00 2001 From: zhangbin Date: Mon, 31 Aug 2015 12:04:18 +0800 Subject: [PATCH 108/118] Update the reference of submodule cocos2d-console. --- tools/cocos2d-console | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cocos2d-console b/tools/cocos2d-console index 597bba8f77..1b5f17b4a2 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit 597bba8f777aaa8c40872b791594fc7f847a339e +Subproject commit 1b5f17b4a2aa53a13582b1c97e6fe2fbc71c18d0 From 8f6f5c1191469f06b7d0328e77d335c09a625472 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 27 Aug 2015 09:30:35 +0800 Subject: [PATCH 109/118] Update engine versions --- CHANGELOG | 2 +- cocos/cocos2d.cpp | 2 +- cocos/scripting/js-bindings/manual/ScriptingCore.h | 2 +- cocos/scripting/js-bindings/script/jsb_cocos2d.js | 2 +- docs/RELEASE_NOTES.md | 9 ++++++--- web | 2 +- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index cda46bc560..1eb672ca75 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -cocos2d-x-3.8 rc0 ?? +cocos2d-x-3.8 rc0 August.26 2015 cocos2d-x-3.8 beta0 August.14 2015 [HIGHLIGHT] 3D: Added 3d physics collider diff --git a/cocos/cocos2d.cpp b/cocos/cocos2d.cpp index f9c868609f..ccc0f8a29a 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.8-github"; + return "cocos2d-x-3.8"; } NS_CC_END diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.h b/cocos/scripting/js-bindings/manual/ScriptingCore.h index 6d9565887f..7e2e1df406 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.h +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.h @@ -39,7 +39,7 @@ #include #include -#define ENGINE_VERSION "Cocos2d-JS v3.8 RC0" +#define ENGINE_VERSION "Cocos2d-JS v3.8" void js_log(const char *format, ...); diff --git a/cocos/scripting/js-bindings/script/jsb_cocos2d.js b/cocos/scripting/js-bindings/script/jsb_cocos2d.js index c9cd0b1466..6adb05e786 100644 --- a/cocos/scripting/js-bindings/script/jsb_cocos2d.js +++ b/cocos/scripting/js-bindings/script/jsb_cocos2d.js @@ -26,7 +26,7 @@ // CCConfig.js // -cc.ENGINE_VERSION = "Cocos2d-JS v3.8 RC0"; +cc.ENGINE_VERSION = "Cocos2d-JS v3.8"; cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0; cc.DIRECTOR_STATS_POSITION = {x: 0, y: 0}; diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index 4fdbc15ac4..19350b0fc5 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -181,7 +181,7 @@ Here is some highlighted improvments and API changes: ## Download -[Cocos2d-x v3.8 rc0](http://www.cocos2d-x.org/filedown/cocos2d-x-3.8-rc0.zip) including : C++, Lua & JS +[Cocos2d-x v3.8](http://www.cocos2d-x.org/filedown/cocos2d-x-3.8.zip) including : C++, Lua & JS ## The main features in detail: @@ -270,9 +270,12 @@ Here is some highlighted improvments and API changes: 1. Reimplemented EditBox - The usage of EditBox is the same as before. It is more likely a iOS version EditBox remake plus a few improvments. + The usage of EditBox is the same as before, but we have reimplemented it for Android platform. The use experience is highly improved, important improvements are: - Besides, it supports multi-line input now, you should set InputMode to `ANY` to enable multi-line input. + - Display cursor in EditBox + - Support copy, cut, paste and select actions in EditBox + - Support multi-line input, you should set InputMode to `ANY` to enable multi-line input + - EditBox won't be masked by the keyboard UI anymore 2. ScrollViewBar diff --git a/web b/web index 63a21206cd..31263de3f6 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit 63a21206cd0fc6e80fc074727293a6c95be6b6ea +Subproject commit 31263de3f661cdf42760884f162c56af0824ed0d From e7c7b248d6b03cbbd3c8da3850154c88c84a4ff1 Mon Sep 17 00:00:00 2001 From: geron-cn Date: Mon, 31 Aug 2015 16:04:17 +0800 Subject: [PATCH 110/118] fix bug: bone can be see by other cameras --- .../editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp index e3fa31a5cc..56a55e73a3 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCBoneNode.cpp @@ -588,6 +588,12 @@ bool BoneNode::isPointOnRack(const cocos2d::Vec2& bonePoint) void BoneNode::batchBoneDrawToSkeleton(BoneNode* bone) const { + bool visibleByCamera = bone->isVisitableByVisitingCamera(); + if (!visibleByCamera) + { + return; + } + cocos2d::Vec3 vpos[4]; for (int i = 0; i < 4; i++) { From b8105349c7e7afdcdfe973f10fde62ef9ac5448b Mon Sep 17 00:00:00 2001 From: Jeff Wang Date: Tue, 1 Sep 2015 00:06:18 +0800 Subject: [PATCH 111/118] revert to the original state when user cancel input --- cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp b/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp index fb7e3a4f96..87487e89a7 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp @@ -836,6 +836,7 @@ void EditBoxImplWin::openKeyboard() placeHolder = "Enter value"; std::string text = getText(); + std::string originalText = text; auto glView = Director::getInstance()->getOpenGLView(); HWND hwnd = glView->getWin32Window(); bool didChange = CWin32InputBox::InputBox("Input", placeHolder.c_str(), &text, _maxLength, false, hwnd, @@ -843,13 +844,11 @@ void EditBoxImplWin::openKeyboard() &EditBoxImplWin::onWin32InputBoxTextChange, this) == IDOK; _isEditing = false; - if (didChange) - setText(text.c_str()); + setText(didChange ? text.c_str() : originalText.c_str()); if (_delegate != nullptr) { - if (didChange) - _delegate->editBoxTextChanged(_editBox, getText()); + _delegate->editBoxTextChanged(_editBox, getText()); _delegate->editBoxEditingDidEnd(_editBox); _delegate->editBoxReturn(_editBox); } @@ -859,10 +858,7 @@ void EditBoxImplWin::openKeyboard() { CommonScriptData data(_editBox->getScriptEditBoxHandler(), "changed",_editBox); ScriptEvent event(kCommonEvent,(void*)&data); - if (didChange) - { - ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); - } + ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); memset(data.eventName,0,sizeof(data.eventName)); strncpy(data.eventName,"ended",sizeof(data.eventName)); event.data = (void*)&data; From 5fdb0418569c944fdb794cf66015cd67b2f9d39c Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Tue, 1 Sep 2015 11:26:09 +0800 Subject: [PATCH 112/118] Use string::empty() to check whether string is empty. --- cocos/2d/CCNode.cpp | 6 +++--- cocos/2d/CCParticleSystem.cpp | 8 ++++---- cocos/2d/CCSpriteFrame.cpp | 2 +- cocos/2d/CCTextFieldTTF.cpp | 12 ++++++------ cocos/base/CCConsole.cpp | 10 +++++----- cocos/deprecated/CCDictionary.cpp | 4 ++-- cocos/deprecated/CCString.cpp | 2 +- .../cocosbuilder/CCBAnimationManager.cpp | 2 +- cocos/editor-support/cocosbuilder/CCBReader.cpp | 2 +- cocos/editor-support/cocosbuilder/CCNodeLoader.cpp | 12 ++++++------ cocos/editor-support/cocostudio/CCArmature.cpp | 2 +- .../editor-support/cocostudio/CCDataReaderHelper.cpp | 2 +- cocos/editor-support/cocostudio/CCDisplayFactory.cpp | 2 +- cocos/editor-support/cocostudio/CCTween.cpp | 6 +++--- cocos/platform/CCFileUtils.cpp | 8 ++++---- cocos/platform/win32/CCFileUtils-win32.cpp | 4 ++-- 16 files changed, 42 insertions(+), 42 deletions(-) diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 6a9dc68a0f..6f6a8b45f8 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -893,7 +893,7 @@ Node* Node::getChildByTag(int tag) const Node* Node::getChildByName(const std::string& name) const { - CCASSERT(name.length() != 0, "Invalid name"); + CCASSERT(!name.empty(), "Invalid name"); std::hash h; size_t hash = h(name); @@ -909,7 +909,7 @@ Node* Node::getChildByName(const std::string& name) const void Node::enumerateChildren(const std::string &name, std::function callback) const { - CCASSERT(name.length() != 0, "Invalid name"); + CCASSERT(!name.empty(), "Invalid name"); CCASSERT(callback != nullptr, "Invalid callback function"); size_t length = name.length(); @@ -1158,7 +1158,7 @@ void Node::removeChildByTag(int tag, bool cleanup/* = true */) void Node::removeChildByName(const std::string &name, bool cleanup) { - CCASSERT(name.length() != 0, "Invalid name"); + CCASSERT(!name.empty(), "Invalid name"); Node *child = this->getChildByName(name); diff --git a/cocos/2d/CCParticleSystem.cpp b/cocos/2d/CCParticleSystem.cpp index 8d423f8eda..0979bd162f 100644 --- a/cocos/2d/CCParticleSystem.cpp +++ b/cocos/2d/CCParticleSystem.cpp @@ -211,7 +211,7 @@ bool ParticleSystem::initWithDictionary(ValueMap& dictionary, const std::string& _duration = dictionary["duration"].asFloat(); // blend function - if (_configName.length()>0) + if (!_configName.empty()) { _blendFunc.src = dictionary["blendFuncSource"].asFloat(); } @@ -289,7 +289,7 @@ bool ParticleSystem::initWithDictionary(ValueMap& dictionary, const std::string& // or Mode B: radius movement else if (_emitterMode == Mode::RADIUS) { - if (_configName.length()>0) + if (!_configName.empty()) { modeB.startRadius = dictionary["maxRadius"].asInt(); } @@ -298,7 +298,7 @@ bool ParticleSystem::initWithDictionary(ValueMap& dictionary, const std::string& modeB.startRadius = dictionary["maxRadius"].asFloat(); } modeB.startRadiusVar = dictionary["maxRadiusVariance"].asFloat(); - if (_configName.length()>0) + if (!_configName.empty()) { modeB.endRadius = dictionary["minRadius"].asInt(); } @@ -316,7 +316,7 @@ bool ParticleSystem::initWithDictionary(ValueMap& dictionary, const std::string& modeB.endRadiusVar = 0.0f; } - if (_configName.length()>0) + if (!_configName.empty()) { modeB.rotatePerSecond = dictionary["rotatePerSecond"].asInt(); } diff --git a/cocos/2d/CCSpriteFrame.cpp b/cocos/2d/CCSpriteFrame.cpp index 62e5403c81..4e6849ab2c 100644 --- a/cocos/2d/CCSpriteFrame.cpp +++ b/cocos/2d/CCSpriteFrame.cpp @@ -188,7 +188,7 @@ Texture2D* SpriteFrame::getTexture() return _texture; } - if( _textureFilename.length() > 0 ) { + if( !_textureFilename.empty()) { return Director::getInstance()->getTextureCache()->addImage(_textureFilename.c_str()); } // no texture or texture filename diff --git a/cocos/2d/CCTextFieldTTF.cpp b/cocos/2d/CCTextFieldTTF.cpp index 31bd5ba1e4..8b9d5f86a8 100644 --- a/cocos/2d/CCTextFieldTTF.cpp +++ b/cocos/2d/CCTextFieldTTF.cpp @@ -259,7 +259,7 @@ const std::string& TextFieldTTF::getContentText() void TextFieldTTF::setTextColor(const Color4B &color) { _colorText = color; - if (_inputText.length() > 0) { + if (!_inputText.empty()) { Label::setTextColor(_colorText); } } @@ -284,7 +284,7 @@ void TextFieldTTF::setColorSpaceHolder(const Color3B& color) _colorSpaceHolder.g = color.g; _colorSpaceHolder.b = color.b; _colorSpaceHolder.a = 255; - if (0 == _inputText.length()) + if (_inputText.empty()) { Label::setTextColor(_colorSpaceHolder); } @@ -293,7 +293,7 @@ void TextFieldTTF::setColorSpaceHolder(const Color3B& color) void TextFieldTTF::setColorSpaceHolder(const Color4B& color) { _colorSpaceHolder = color; - if (0 == _inputText.length()) { + if (_inputText.empty()) { Label::setTextColor(_colorSpaceHolder); } } @@ -309,7 +309,7 @@ void TextFieldTTF::setString(const std::string &text) std::string displayText; size_t length; - if (text.length()>0) + if (!text.empty()) { _inputText = text; displayText = _inputText; @@ -330,7 +330,7 @@ void TextFieldTTF::setString(const std::string &text) } // if there is no input text, display placeholder instead - if (0 == _inputText.length()) + if (_inputText.empty()) { Label::setTextColor(_colorSpaceHolder); Label::setString(_placeHolder); @@ -352,7 +352,7 @@ const std::string& TextFieldTTF::getString() const void TextFieldTTF::setPlaceHolder(const std::string& text) { _placeHolder = text; - if (0 == _inputText.length()) + if (_inputText.empty()) { Label::setTextColor(_colorSpaceHolder); Label::setString(_placeHolder); diff --git a/cocos/base/CCConsole.cpp b/cocos/base/CCConsole.cpp index 9433a37714..f400881811 100644 --- a/cocos/base/CCConsole.cpp +++ b/cocos/base/CCConsole.cpp @@ -404,7 +404,7 @@ bool Console::listenOnTCP(int port) setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, (const char*)&on, sizeof(on)); // bind address - if (_bindAddress.length() > 0) + if (!_bindAddress.empty()) { if (res->ai_family == AF_INET) { @@ -533,7 +533,7 @@ void Console::commandFileUtils(int fd, const std::string &args) { FileUtils::getInstance()->purgeCachedEntries(); } - else if( args.length()==0) + else if( args.empty()) { sched->performFunctionInCocosThread( std::bind(&printFileUtils, fd) ); } @@ -555,7 +555,7 @@ void Console::commandConfig(int fd, const std::string& args) void Console::commandResolution(int fd, const std::string& args) { - if(args.length()==0) { + if(args.empty()) { auto director = Director::getInstance(); Size points = director->getWinSize(); Size pixels = director->getWinSizeInPixels(); @@ -598,7 +598,7 @@ void Console::commandProjection(int fd, const std::string& args) auto director = Director::getInstance(); Scheduler *sched = director->getScheduler(); - if(args.length()==0) + if(args.empty()) { char buf[20]; auto proj = director->getProjection(); @@ -648,7 +648,7 @@ void Console::commandTextures(int fd, const std::string& args) } ); } - else if(args.length()==0) + else if(args.empty()) { sched->performFunctionInCocosThread( [=](){ mydprintf(fd, "%s", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str()); diff --git a/cocos/deprecated/CCDictionary.cpp b/cocos/deprecated/CCDictionary.cpp index 59f57e8490..5e24ccc73b 100644 --- a/cocos/deprecated/CCDictionary.cpp +++ b/cocos/deprecated/CCDictionary.cpp @@ -217,7 +217,7 @@ const __String* __Dictionary::valueForKey(intptr_t key) void __Dictionary::setObject(Ref* pObject, const std::string& key) { - CCASSERT(key.length() > 0 && pObject != nullptr, "Invalid Argument!"); + CCASSERT(!key.empty() && pObject != nullptr, "Invalid Argument!"); if (_dictType == kDictUnknown) { _dictType = kDictStr; @@ -276,7 +276,7 @@ void __Dictionary::removeObjectForKey(const std::string& key) } CCASSERT(_dictType == kDictStr, "this dictionary doesn't use string as its key"); - CCASSERT(key.length() > 0, "Invalid Argument!"); + CCASSERT(!key.empty(), "Invalid Argument!"); DictElement *pElement = nullptr; HASH_FIND_STR(_elements, key.c_str(), pElement); removeObjectForElememt(pElement); diff --git a/cocos/deprecated/CCString.cpp b/cocos/deprecated/CCString.cpp index 38d153b95f..a44867cdf8 100644 --- a/cocos/deprecated/CCString.cpp +++ b/cocos/deprecated/CCString.cpp @@ -196,7 +196,7 @@ __Array* __String::componentsSeparatedByString(const char *delimiter) strTmp = strTmp.substr(cutAt + 1); } - if(strTmp.length() > 0) + if(!strTmp.empty()) { result->addObject(__String::create(strTmp)); } diff --git a/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp b/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp index 9b80686720..f3d0806fe7 100644 --- a/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp +++ b/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp @@ -663,7 +663,7 @@ Sequence* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* ch if(target != nullptr) { - if(selectorName.length() > 0) + if(!selectorName.empty()) { SEL_CallFuncN selCallFunc = 0; diff --git a/cocos/editor-support/cocosbuilder/CCBReader.cpp b/cocos/editor-support/cocosbuilder/CCBReader.cpp index 6b7d9c8f8a..68ce5c10c8 100644 --- a/cocos/editor-support/cocosbuilder/CCBReader.cpp +++ b/cocos/editor-support/cocosbuilder/CCBReader.cpp @@ -796,7 +796,7 @@ CCBKeyframe* CCBReader::readKeyframe(PropertyType type) SpriteFrame* spriteFrame; - if (spriteSheet.length() == 0) + if (spriteSheet.empty()) { spriteFile = _CCBRootPath + spriteFile; diff --git a/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp b/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp index d1febae816..4f763bed43 100644 --- a/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp +++ b/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp @@ -575,9 +575,9 @@ SpriteFrame * NodeLoader::parsePropTypeSpriteFrame(Node * pNode, Node * pParent, std::string spriteFile = ccbReader->readCachedString(); SpriteFrame *spriteFrame = nullptr; - if (spriteFile.length() != 0) + if (!spriteFile.empty()) { - if (spriteSheet.length() == 0) + if (spriteSheet.empty()) { spriteFile = ccbReader->getCCBRootPath() + spriteFile; Texture2D * texture = Director::getInstance()->getTextureCache()->addImage(spriteFile.c_str()); @@ -623,7 +623,7 @@ Animation * NodeLoader::parsePropTypeAnimation(Node * pNode, Node * pParent, CCB animation = CCBReader::lastPathComponent(animation.c_str()); animationFile = CCBReader::lastPathComponent(animationFile.c_str()); - if (animation.length() > 0) + if (!animation.empty()) { AnimationCache * animationCache = AnimationCache::getInstance(); animationCache->addAnimationsWithFile(animationFile.c_str()); @@ -636,7 +636,7 @@ Animation * NodeLoader::parsePropTypeAnimation(Node * pNode, Node * pParent, CCB Texture2D * NodeLoader::parsePropTypeTexture(Node * pNode, Node * pParent, CCBReader * ccbReader) { std::string spriteFile = ccbReader->getCCBRootPath() + ccbReader->readCachedString(); - if (spriteFile.length() > 0) + if (!spriteFile.empty()) { return Director::getInstance()->getTextureCache()->addImage(spriteFile.c_str()); } @@ -775,7 +775,7 @@ BlockData * NodeLoader::parsePropTypeBlock(Node * pNode, Node * pParent, CCBRead if(target != nullptr) { - if(selectorName.length() > 0) + if(!selectorName.empty()) { SEL_MenuHandler selMenuHandler = 0; @@ -856,7 +856,7 @@ BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pP if(target != nullptr) { - if(selectorName.length() > 0) + if(!selectorName.empty()) { Control::Handler selControlHandler = 0; diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index cfbed59a52..701d2ec8a9 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -212,7 +212,7 @@ Bone *Armature::createBone(const std::string& boneName) Bone *bone = nullptr; - if( parentName.length() != 0 ) + if( !parentName.empty()) { createBone(parentName.c_str()); bone = Bone::create(boneName); diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp index 4d645dbf44..db2b87cdf9 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp @@ -809,7 +809,7 @@ MovementData *DataReaderHelper::decodeMovement(tinyxml2::XMLElement *movementXML tinyxml2::XMLElement *parentXml = nullptr; - if (parentName.length() != 0) + if (!parentName.empty()) { parentXml = movementXML->FirstChildElement(BONE); diff --git a/cocos/editor-support/cocostudio/CCDisplayFactory.cpp b/cocos/editor-support/cocostudio/CCDisplayFactory.cpp index 43c483c919..90934aefc8 100644 --- a/cocos/editor-support/cocostudio/CCDisplayFactory.cpp +++ b/cocos/editor-support/cocostudio/CCDisplayFactory.cpp @@ -151,7 +151,7 @@ void DisplayFactory::createSpriteDisplay(Bone *bone, DecorativeDisplay *decoDisp } //! create display - if(textureName.length() == 0) + if(textureName.empty()) { skin = Skin::create(); } diff --git a/cocos/editor-support/cocostudio/CCTween.cpp b/cocos/editor-support/cocostudio/CCTween.cpp index 8ca0024762..f6bb49020f 100644 --- a/cocos/editor-support/cocostudio/CCTween.cpp +++ b/cocos/editor-support/cocostudio/CCTween.cpp @@ -345,9 +345,9 @@ void Tween::arriveKeyFrame(FrameData *keyFrameData) Armature *childAramture = _bone->getChildArmature(); if(childAramture) { - if(keyFrameData->strMovement.length() != 0) + if(!keyFrameData->strMovement.empty()) { - childAramture->getAnimation()->play(keyFrameData->strMovement.c_str()); + childAramture->getAnimation()->play(keyFrameData->strMovement); } } } @@ -450,7 +450,7 @@ float Tween::updateFrameData(float currentPercent) to = frames.at(_toIndex); //! Guaranteed to trigger frame event - if(from->strEvent.length() != 0 && !_animation->isIgnoreFrameEvent()) + if(!from->strEvent.empty() && !_animation->isIgnoreFrameEvent()) { _animation->frameEvent(_bone, from->strEvent.c_str(), from->frameID, playedTime); } diff --git a/cocos/platform/CCFileUtils.cpp b/cocos/platform/CCFileUtils.cpp index 7349264842..93636e1856 100644 --- a/cocos/platform/CCFileUtils.cpp +++ b/cocos/platform/CCFileUtils.cpp @@ -827,7 +827,7 @@ std::string FileUtils::fullPathForFilename(const std::string &filename) const { fullpath = this->getPathForFilename(newFilename, resolutionIt, searchIt); - if (fullpath.length() > 0) + if (!fullpath.empty()) { // Using the filename passed in as key. _fullPathCache.insert(std::make_pair(filename, fullpath)); @@ -926,7 +926,7 @@ void FileUtils::setSearchPaths(const std::vector& searchPaths) prefix = _defaultResRootPath; } path = prefix + (iter); - if (path.length() > 0 && path[path.length()-1] != '/') + if (!path.empty() && path[path.length()-1] != '/') { path += "/"; } @@ -951,7 +951,7 @@ void FileUtils::addSearchPath(const std::string &searchpath,const bool front) prefix = _defaultResRootPath; std::string path = prefix + searchpath; - if (path.length() > 0 && path[path.length()-1] != '/') + if (!path.empty() && path[path.length()-1] != '/') { path += "/"; } @@ -971,7 +971,7 @@ void FileUtils::setFilenameLookupDictionary(const ValueMap& filenameLookupDict) void FileUtils::loadFilenameLookupDictionaryFromFile(const std::string &filename) { const std::string fullPath = fullPathForFilename(filename); - if (fullPath.length() > 0) + if (!fullPath.empty()) { ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(fullPath); if (!dict.empty()) diff --git a/cocos/platform/win32/CCFileUtils-win32.cpp b/cocos/platform/win32/CCFileUtils-win32.cpp index c0369dd4c4..c890faf2cf 100644 --- a/cocos/platform/win32/CCFileUtils-win32.cpp +++ b/cocos/platform/win32/CCFileUtils-win32.cpp @@ -134,7 +134,7 @@ static std::string UTF8StringToMultiByte(const std::string& strUtf8) static void _checkPath() { - if (0 == s_resourcePath.length()) + if (s_resourcePath.empty()) { WCHAR *pUtf16ExePath = nullptr; _get_wpgmptr(&pUtf16ExePath); @@ -193,7 +193,7 @@ std::string FileUtilsWin32::getSuitableFOpen(const std::string& filenameUtf8) co bool FileUtilsWin32::isFileExistInternal(const std::string& strFilePath) const { - if (0 == strFilePath.length()) + if (strFilePath.empty()) { return false; } From f3190206e03b61ec4c4a78fc51e1de235216f4e8 Mon Sep 17 00:00:00 2001 From: ZhangMenghe Date: Tue, 1 Sep 2015 14:21:08 +0800 Subject: [PATCH 113/118] Remove clickAndMove testcase --- tests/js-tests/project.json | 1 - .../src/ClickAndMoveTest/ClickAndMoveTest.js | 101 ------------------ tests/js-tests/src/tests-main.js | 9 -- 3 files changed, 111 deletions(-) delete mode 100644 tests/js-tests/src/ClickAndMoveTest/ClickAndMoveTest.js diff --git a/tests/js-tests/project.json b/tests/js-tests/project.json index b085e88a37..17b933b141 100644 --- a/tests/js-tests/project.json +++ b/tests/js-tests/project.json @@ -31,7 +31,6 @@ "src/TouchesTest/Paddle.js", "src/TouchesTest/TouchesTest.js", "src/SchedulerTest/SchedulerTest.js", - "src/ClickAndMoveTest/ClickAndMoveTest.js", "src/MenuTest/MenuTest.js", "src/ActionsTest/ActionsTest.js", "src/TileMapTest/TileMapTest.js", diff --git a/tests/js-tests/src/ClickAndMoveTest/ClickAndMoveTest.js b/tests/js-tests/src/ClickAndMoveTest/ClickAndMoveTest.js deleted file mode 100644 index 3e5121e739..0000000000 --- a/tests/js-tests/src/ClickAndMoveTest/ClickAndMoveTest.js +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011-2012 cocos2d-x.org - Copyright (c) 2013-2014 Chukong Technologies Inc. - - 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. - ****************************************************************************/ -var TAG_SPRITE = 1; - -var ClickAndMoveTestScene = TestScene.extend({ - runThisTest:function () { - var layer = new ClickAndMoveTestLayer(); - - this.addChild(layer); - director.runScene(this); - } -}); - -var ClickAndMoveTestLayer = cc.Layer.extend({ - ctor:function () { - - if(window.sideIndexBar){ - window.sideIndexBar.changeTest(0, 4); - } - - this._super(); - - this.init(); - - if( 'touches' in cc.sys.capabilities ) - cc.eventManager.addListener(cc.EventListener.create({ - event: cc.EventListener.TOUCH_ALL_AT_ONCE, - onTouchesEnded:function (touches, event) { - if (touches.length <= 0) - return; - event.getCurrentTarget().moveSprite(touches[0].getLocation()); - } - }), this); - else if ('mouse' in cc.sys.capabilities ) - cc.eventManager.addListener({ - event: cc.EventListener.MOUSE, - onMouseUp: function (event) { - event.getCurrentTarget().moveSprite(event.getLocation()); - } - }, this); - - var sprite = new cc.Sprite(s_pathGrossini); - - var layer = new cc.LayerColor(cc.color(255, 255, 0, 100)); - this.addChild(layer, -1); - - this.addChild(sprite, 0, TAG_SPRITE); - sprite.x = 20; - sprite.y = 150; - - sprite.runAction(cc.jumpTo(4, cc.p(300, 48), 100, 4)); - - var fadeIn = cc.fadeIn(1); - var fadeOut = cc.fadeOut(1); - var forever = cc.sequence(fadeIn, fadeOut).repeatForever(); - layer.runAction(forever); - }, - - moveSprite:function(position) { - var sprite = this.getChildByTag(TAG_SPRITE); - sprite.stopAllActions(); - sprite.runAction(cc.moveTo(1, position)); - var o = position.x - sprite.x; - var a = position.y - sprite.y; - var at = Math.atan(o / a) * 57.29577951; // radians to degrees - - if (a < 0) { - if (o < 0) - at = 180 + Math.abs(at); - else - at = 180 - Math.abs(at); - } - - sprite.runAction(cc.rotateTo(1, at)); - } -}); - -var arrayOfClickMoveTest = [ClickAndMoveTestLayer]; \ No newline at end of file diff --git a/tests/js-tests/src/tests-main.js b/tests/js-tests/src/tests-main.js index 1beb3568ab..7e311a6cad 100644 --- a/tests/js-tests/src/tests-main.js +++ b/tests/js-tests/src/tests-main.js @@ -291,15 +291,6 @@ var testNames = [ return new ChipmunkTestScene(); } }, - //"BugsTest", - { - title:"Click and Move Test", - platforms: PLATFORM_ALL, - linksrc:"src/ClickAndMoveTest/ClickAndMoveTest.js", - testScene:function () { - return new ClickAndMoveTestScene(); - } - }, { title:"ClippingNode Test", platforms: PLATFORM_ALL, From 7fc382055bfa956df24c236c15b0131e7bbadcdc Mon Sep 17 00:00:00 2001 From: linguofeng Date: Wed, 2 Sep 2015 11:27:47 +0800 Subject: [PATCH 114/118] lua add UPDATE_FAILED ERROR_DECOMPRESS add cc.EventAssetsManagerEx.EventCode.UPDATE_FAILED cc.EventAssetsManagerEx.EventCode.ERROR_DECOMPRESS --- .../scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua index dd56ba3e34..5a56473349 100644 --- a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua +++ b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua @@ -508,6 +508,8 @@ cc.EventAssetsManagerEx = ASSET_UPDATED = 6, ERROR_UPDATING = 7, UPDATE_FINISHED = 8, + UPDATE_FAILED = 9, + ERROR_DECOMPRESS = 10 }, } From be60f7f65c0ed6108874fb2bba1fd01b099af71a Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Wed, 2 Sep 2015 13:48:57 +0800 Subject: [PATCH 115/118] [ci skip]js-template-default:Fixed the path of link resources. --- .../frameworks/runtime-src/proj.android/.project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/js-template-default/frameworks/runtime-src/proj.android/.project b/templates/js-template-default/frameworks/runtime-src/proj.android/.project index 2509d6ba53..506d4d652f 100644 --- a/templates/js-template-default/frameworks/runtime-src/proj.android/.project +++ b/templates/js-template-default/frameworks/runtime-src/proj.android/.project @@ -44,7 +44,7 @@ jsjavabridge 2 - PARENT-2-PROJECT_LOC/js-bindings/bindings/manual/platform/android/java/src + PARENT-2-PROJECT_LOC/cocos2d-x/cocos/platform/android/java/src From 7fb36b4c9c5c2701dff02e64e9745132c49178d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=90=E9=BE=99=E5=B1=B1=E4=BA=BA?= Date: Fri, 4 Sep 2015 09:43:45 +0800 Subject: [PATCH 116/118] Update Jenkins build status icon link --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a9881ea68e..0b82c061ac 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ cocos2d-x | |iOS|Mac|Linux|Win32|Android|Win8.1-Universal| | ----|----|----- | ---|----|------|---| -|v3|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v3/node=ios)](http://45.56.80.45:8080/job/daily-build-v3/node=ios)|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v3/node=mac)](http://45.56.80.45:8080/job/daily-build-v3/node=mac)|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v3/node=linux)](http://45.56.80.45:8080/job/daily-build-v3/node=linux)|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v3/node=win32)](http://45.56.80.45:8080/job/daily-build-v3/node=win32)|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v3/node=android)](http://45.56.80.45:8080/job/daily-build-v3/node=android)|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v3/node=windows-universal)](http://45.56.80.45:8080/job/daily-build-v3/node=windows-universal)| -|v4|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v4/node=ios)](http://45.56.80.45:8080/job/daily-build-v4/node=ios)|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v4/node=mac)](http://45.56.80.45:8080/job/daily-build-v4/node=mac)|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v4/node=linux)](http://45.56.80.45:8080/job/daily-build-v4/node=linux)|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v4/node=win32)](http://45.56.80.45:8080/job/daily-build-v4/node=win32)|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v4/node=android)](http://45.56.80.45:8080/job/daily-build-v4/node=android)|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v4/node=windows-universal)](http://45.56.80.45:8080/job/daily-build-v4/node=windows-universal)| +|v3|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v3/node=ios)](http://45.56.80.45:8080/job/daily-build-v3/node=ios)|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v3/node=mac)](http://45.56.80.45:8080/job/daily-build-v3/node=mac)|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v3/node=linux)](http://45.56.80.45:8080/job/daily-build-v3/node=linux)|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v3/node=win32_bak)](http://45.56.80.45:8080/job/daily-build-v3/node=win32_bak)|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v3/node=android)](http://45.56.80.45:8080/job/daily-build-v3/node=android)|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v3/node=windows-universal_bak)](http://45.56.80.45:8080/job/daily-build-v3/node=windows-universal_bak)| +|v4|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v4/node=ios)](http://45.56.80.45:8080/job/daily-build-v4/node=ios)|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v4/node=mac)](http://45.56.80.45:8080/job/daily-build-v4/node=mac)|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v4/node=linux)](http://45.56.80.45:8080/job/daily-build-v4/node=linux)|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v4/node=win32_bak)](http://45.56.80.45:8080/job/daily-build-v4/node=win32_bak)|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v4/node=android)](http://45.56.80.45:8080/job/daily-build-v4/node=android)|[![Build Status](http://45.56.80.45:8080/buildStatus/icon?job=daily-build-v4/node=windows-universal_bak)](http://45.56.80.45:8080/job/daily-build-v4/node=windows-universal_bak)| From 030157ded0f8a95e9bff4c59bea8fc4bc0b50b22 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Fri, 4 Sep 2015 08:46:08 -0700 Subject: [PATCH 117/118] update libcococs2d name to v3.9 for WinRT platforms --- .../libcocos2d_8_1.Windows.vcxproj | 12 ++++++------ .../libcocos2d_8_1.WindowsPhone.vcxproj | 8 ++++---- cocos/2d/libcocos2d_win10/libcocos2d.vcxproj | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj index a834e12594..50933fe0eb 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj @@ -119,40 +119,40 @@ false false - libcocos2d_v3.8_Windows_8.1 + libcocos2d_v3.9_Windows_8.1 false false - libcocos2d_v3.8_Windows_8.1 + libcocos2d_v3.9_Windows_8.1 false false - libcocos2d_v3.8_Windows_8.1 + libcocos2d_v3.9_Windows_8.1 false false false - libcocos2d_v3.8_Windows_8.1 + libcocos2d_v3.9_Windows_8.1 false false false - libcocos2d_v3.8_Windows_8.1 + libcocos2d_v3.9_Windows_8.1 false false - libcocos2d_v3.8_Windows_8.1 + libcocos2d_v3.9_Windows_8.1 diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj index 36897d70d2..022d9a1540 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj @@ -91,23 +91,23 @@ false false - libcocos2d_v3.8_WindowsPhone_8.1 + libcocos2d_v3.9_WindowsPhone_8.1 false false - libcocos2d_v3.8_WindowsPhone_8.1 + libcocos2d_v3.9_WindowsPhone_8.1 false false - libcocos2d_v3.8_WindowsPhone_8.1 + libcocos2d_v3.9_WindowsPhone_8.1 false false false - libcocos2d_v3.8_WindowsPhone_8.1 + libcocos2d_v3.9_WindowsPhone_8.1 false diff --git a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj index ff127810f2..547868ac0c 100644 --- a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj @@ -1503,34 +1503,34 @@ false false - libcocos2d_v3.8_Windows_10.0 + libcocos2d_v3.9_Windows_10.0 false false - libcocos2d_v3.8_Windows_10.0 + libcocos2d_v3.9_Windows_10.0 false false false - libcocos2d_v3.8_Windows_10.0 + libcocos2d_v3.9_Windows_10.0 false false false - libcocos2d_v3.8_Windows_10.0 + libcocos2d_v3.9_Windows_10.0 false false - libcocos2d_v3.8_Windows_10.0 + libcocos2d_v3.9_Windows_10.0 false false - libcocos2d_v3.8_Windows_10.0 + libcocos2d_v3.9_Windows_10.0 From 42b24a9c5b6ad4e6374bc2850eca0ffaa784ed45 Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Mon, 7 Sep 2015 11:12:13 +0800 Subject: [PATCH 118/118] Rename AVAudioPlayer to CCAudioPlayer for avoid conflicting with system framework --- cocos/audio/mac/CDAudioManager.h | 8 ++++---- cocos/audio/mac/CDAudioManager.m | 12 ++++++------ cocos/audio/mac/CDXMacOSXSupport.h | 22 +++++++++++----------- cocos/audio/mac/CDXMacOSXSupport.mm | 2 +- cocos/audio/mac/CocosDenshion.h | 4 ++-- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/cocos/audio/mac/CDAudioManager.h b/cocos/audio/mac/CDAudioManager.h index af0ab4a98a..a7971f9251 100644 --- a/cocos/audio/mac/CDAudioManager.h +++ b/cocos/audio/mac/CDAudioManager.h @@ -90,7 +90,7 @@ typedef enum { @since v0.99 */ @interface CDLongAudioSource : NSObject { - AVAudioPlayer *audioSourcePlayer; + CCAudioPlayer *audioSourcePlayer; NSString *audioSourceFilePath; NSInteger numberOfLoops; float volume; @@ -106,7 +106,7 @@ typedef enum { @protected tLongAudioSourceState state; } -@property (readonly) AVAudioPlayer *audioSourcePlayer; +@property (readonly) CCAudioPlayer *audioSourcePlayer; @property (readonly) NSString *audioSourceFilePath; @property (readwrite, nonatomic) NSInteger numberOfLoops; @property (readwrite, nonatomic) float volume; @@ -196,13 +196,13 @@ typedef enum { /** Call if you want to use built in resign behavior but need to do some additional audio processing on become active. */ - (void) applicationDidBecomeActive; -//New AVAudioPlayer API +//New CCAudioPlayer API /** Loads the data from the specified file path to the channel's audio source */ -(CDLongAudioSource*) audioSourceLoad:(NSString*) filePath channel:(tAudioSourceChannel) channel; /** Retrieves the audio source for the specified channel */ -(CDLongAudioSource*) audioSourceForChannel:(tAudioSourceChannel) channel; -//Legacy AVAudioPlayer API +//Legacy CCAudioPlayer API /** Plays music in background. The music can be looped or not It is recommended to use .aac files as background music since they are decoded by the device (hardware). */ diff --git a/cocos/audio/mac/CDAudioManager.m b/cocos/audio/mac/CDAudioManager.m index b5365af68c..2c36961393 100644 --- a/cocos/audio/mac/CDAudioManager.m +++ b/cocos/audio/mac/CDAudioManager.m @@ -66,12 +66,12 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised"; //New file if (state != kLAS_Init) { [audioSourceFilePath release];//Release old file path - [audioSourcePlayer release];//Release old AVAudioPlayer, they can't be reused + [audioSourcePlayer release];//Release old CCAudioPlayer, they can't be reused } audioSourceFilePath = [filePath copy]; NSError *error = nil; NSString *path = [CDUtilities fullPathFromRelativePath:audioSourceFilePath]; - audioSourcePlayer = [(AVAudioPlayer*)[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:&error]; + audioSourcePlayer = [(CCAudioPlayer*)[CCAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:&error]; if (error == nil) { [audioSourcePlayer prepareToPlay]; audioSourcePlayer.delegate = self; @@ -190,12 +190,12 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised"; numberOfLoops = loopCount; } -- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag { +- (void)audioPlayerDidFinishPlaying:(CCAudioPlayer *)player successfully:(BOOL)flag { CDLOGINFO(@"Denshion::CDLongAudioSource - audio player finished"); #if TARGET_IPHONE_SIMULATOR CDLOGINFO(@"Denshion::CDLongAudioSource - workaround for OpenAL clobbered audio issue"); //This is a workaround for an issue in all simulators (tested to 3.1.2). Problem is - //that OpenAL audio playback is clobbered when an AVAudioPlayer stops. Workaround + //that OpenAL audio playback is clobbered when an CCAudioPlayer stops. Workaround //is to keep the player playing on an endless loop with 0 volume and then when //it is played again reset the volume and set loop count appropriately. //NB: this workaround is not foolproof but it is good enough for most situations. @@ -208,11 +208,11 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised"; } } --(void)audioPlayerBeginInterruption:(AVAudioPlayer *)player { +-(void)audioPlayerBeginInterruption:(CCAudioPlayer *)player { CDLOGINFO(@"Denshion::CDLongAudioSource - audio player interrupted"); } --(void)audioPlayerEndInterruption:(AVAudioPlayer *)player { +-(void)audioPlayerEndInterruption:(CCAudioPlayer *)player { CDLOGINFO(@"Denshion::CDLongAudioSource - audio player resumed"); if (self.backgroundMusic) { //Check if background music can play as rules may have changed during diff --git a/cocos/audio/mac/CDXMacOSXSupport.h b/cocos/audio/mac/CDXMacOSXSupport.h index ccab5531e7..eaa97f2e34 100644 --- a/cocos/audio/mac/CDXMacOSXSupport.h +++ b/cocos/audio/mac/CDXMacOSXSupport.h @@ -23,13 +23,13 @@ */ /** - A set of proxy classes to allow iOS audio code to run on MacOS X. AVAudioPlayer is implemented using NSSound. + A set of proxy classes to allow iOS audio code to run on MacOS X. CCAudioPlayer is implemented using NSSound. AVAudioSession is a "do nothing" class as it isn't really relevant on MacOS X. Limitations: - AVAudioPlayer numberOfLoops not correctly supported. Looping is either on or off, can not specify a specific number of loops. - AVAudioPlayer panning not supported. - AVAudioPlayer metering not supported. + CCAudioPlayer numberOfLoops not correctly supported. Looping is either on or off, can not specify a specific number of loops. + CCAudioPlayer panning not supported. + CCAudioPlayer metering not supported. AVAudioSession nothing is supported, not applicable to MacOS X. */ @@ -60,7 +60,7 @@ extern OSStatus AudioSessionGetProperty(UInt32 inID, UInt32 *ioDataSize, void *o @protocol AVAudioPlayerDelegate; /* This class is available with iPhone 2.2 or later */ -@interface AVAudioPlayer : NSObject { +@interface CCAudioPlayer : NSObject { // properties id delegate; @@ -137,24 +137,24 @@ extern OSStatus AudioSessionGetProperty(UInt32 inID, UInt32 *ioDataSize, void *o @end -/* A protocol for delegates of AVAudioPlayer */ +/* A protocol for delegates of CCAudioPlayer */ @protocol AVAudioPlayerDelegate @optional /* audioPlayerDidFinishPlaying:successfully: is called when a sound has finished playing. This method is NOT called if the player is stopped due to an interruption. */ -- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag; +- (void)audioPlayerDidFinishPlaying:(CCAudioPlayer *)player successfully:(BOOL)flag; /* if an error occurs while decoding it will be reported to the delegate. */ -- (void)audioPlayerDecodeErrorDidOccur:(AVAudioPlayer *)player error:(NSError *)error; +- (void)audioPlayerDecodeErrorDidOccur:(CCAudioPlayer *)player error:(NSError *)error; /* audioPlayerBeginInterruption: is called when the audio session has been interrupted while the player was playing. The player will have been paused. */ -- (void)audioPlayerBeginInterruption:(AVAudioPlayer *)player; +- (void)audioPlayerBeginInterruption:(CCAudioPlayer *)player; /* audioPlayerEndInterruption:withFlags: is called when the audio session interruption has ended and this player had been interrupted while playing. */ /* Currently the only flag is AVAudioSessionInterruptionFlags_ShouldResume. */ -- (void)audioPlayerEndInterruption:(AVAudioPlayer *)player withFlags:(NSUInteger)flags; +- (void)audioPlayerEndInterruption:(CCAudioPlayer *)player withFlags:(NSUInteger)flags; /* audioPlayerEndInterruption: is called when the preferred method, audioPlayerEndInterruption:withFlags:, is not implemented. */ -- (void)audioPlayerEndInterruption:(AVAudioPlayer *)player; +- (void)audioPlayerEndInterruption:(CCAudioPlayer *)player; @end diff --git a/cocos/audio/mac/CDXMacOSXSupport.mm b/cocos/audio/mac/CDXMacOSXSupport.mm index 57fb53a715..98605d342d 100644 --- a/cocos/audio/mac/CDXMacOSXSupport.mm +++ b/cocos/audio/mac/CDXMacOSXSupport.mm @@ -42,7 +42,7 @@ OSStatus AudioSessionGetProperty(UInt32 inID, UInt32 *ioDataSize, void *outData) return 0; } -@implementation AVAudioPlayer +@implementation CCAudioPlayer @synthesize delegate, numberOfChannels, pan, deviceCurrentTime, url, data; diff --git a/cocos/audio/mac/CocosDenshion.h b/cocos/audio/mac/CocosDenshion.h index 2e40c2eaae..ccd571c0c0 100644 --- a/cocos/audio/mac/CocosDenshion.h +++ b/cocos/audio/mac/CocosDenshion.h @@ -41,12 +41,12 @@ Requirements: - Frameworks: OpenAL, AudioToolbox, AVFoundation @par CDAudioManager -CDAudioManager is basically a thin wrapper around an AVAudioPlayer object used for playing +CDAudioManager is basically a thin wrapper around an CCAudioPlayer object used for playing background music and a CDSoundEngine object used for playing sound effects. It manages the audio session for you deals with audio session interruption. It is fairly low level and it is expected you have some understanding of the underlying technologies. For example, for many use cases regarding background music it is expected you will work directly with the -backgroundMusic AVAudioPlayer which is exposed as a property. +backgroundMusic CCAudioPlayer which is exposed as a property. Requirements: - Firmware: OS 2.2 or greater