From d8cdb758514afd2c88443d6e87347028e3d27f95 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Fri, 11 Jul 2014 15:10:19 +0800 Subject: [PATCH] Fix compile errors on WP8 --- cocos/2d/CCMenuItem.cpp | 13 +++++++++++++ cocos/2d/CCMenuItem.h | 18 ++++++++++++++++++ .../WidgetReader/TextReader/TextReader.cpp | 2 +- cocos/renderer/CCMeshCommand.cpp | 2 +- cocos/renderer/CCMeshCommand.h | 2 +- tests/cpp-tests/Classes/MenuTest/MenuTest.cpp | 2 +- 6 files changed, 35 insertions(+), 4 deletions(-) diff --git a/cocos/2d/CCMenuItem.cpp b/cocos/2d/CCMenuItem.cpp index ceda096b82..54146875dc 100644 --- a/cocos/2d/CCMenuItem.cpp +++ b/cocos/2d/CCMenuItem.cpp @@ -839,6 +839,18 @@ MenuItemToggle * MenuItemToggle::createWithTarget(Ref* target, SEL_MenuHandler s return ret; } +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +MenuItemToggle * MenuItemToggle::createWithCallbackVA(const ccMenuCallback &callback, MenuItem* item, ...) +{ + va_list args; + va_start(args, item); + MenuItemToggle *ret = new MenuItemToggle(); + ret->initWithCallback(callback, item, args); + ret->autorelease(); + va_end(args); + return ret; +} +#else MenuItemToggle * MenuItemToggle::createWithCallback(const ccMenuCallback &callback, MenuItem* item, ...) { va_list args; @@ -849,6 +861,7 @@ MenuItemToggle * MenuItemToggle::createWithCallback(const ccMenuCallback &callba va_end(args); return ret; } +#endif MenuItemToggle * MenuItemToggle::create() { diff --git a/cocos/2d/CCMenuItem.h b/cocos/2d/CCMenuItem.h index 2152046acc..b089f914d4 100644 --- a/cocos/2d/CCMenuItem.h +++ b/cocos/2d/CCMenuItem.h @@ -478,7 +478,25 @@ public: /** creates a menu item from a Array with a callable object */ static MenuItemToggle * createWithCallback(const ccMenuCallback& callback, const Vector& menuItems); /** creates a menu item from a list of items with a callable object */ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) + // WP8 in VS2012 does not support nullptr in variable args lists and variadic templates are also not supported + typedef MenuItem* M; + static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, NULL); } + static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, NULL); } + static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, NULL); } + static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, NULL); } + static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, NULL); } + static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, M m6, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, m6, NULL); } + static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, M m6, M m7, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, m6, m7, NULL); } + static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, m6, m7, m8, NULL); } + static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, m6, m7, m8, m9, NULL); } + static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, M m10, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, NULL); } + + // On WP8 for lists longer than 10 items, use createWithArray or variadicCreate with NULL as the last argument + static MenuItemToggle* createWithCallbackVA(const ccMenuCallback& callback, M item, ...); +#else static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, MenuItem* item, ...) CC_REQUIRES_NULL_TERMINATION; +#endif /** creates a menu item with no target/selector and no items */ static MenuItemToggle* create(); /** creates a menu item with a item */ diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp index a071c0ac71..9ea9889f8d 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp @@ -102,7 +102,7 @@ namespace cocostudio label->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize,20)); std::string fontName = DICTOOL->getStringValue_json(options, P_FontName, "微软雅黑"); - std::string file_extension = “”; + std::string file_extension = ""; size_t pos = fontName.find_last_of('.'); if (pos != std::string::npos) { diff --git a/cocos/renderer/CCMeshCommand.cpp b/cocos/renderer/CCMeshCommand.cpp index e37e607cb6..ad251cb9cc 100644 --- a/cocos/renderer/CCMeshCommand.cpp +++ b/cocos/renderer/CCMeshCommand.cpp @@ -292,7 +292,7 @@ void MeshCommand::releaseVAO() } } -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8) void MeshCommand::listenRendererRecreated(EventCustom* event) { _vao = 0; diff --git a/cocos/renderer/CCMeshCommand.h b/cocos/renderer/CCMeshCommand.h index c88cc593e9..d1e995da7a 100644 --- a/cocos/renderer/CCMeshCommand.h +++ b/cocos/renderer/CCMeshCommand.h @@ -74,7 +74,7 @@ public: uint32_t getMaterialID() const { return _materialID; } -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8) void listenRendererRecreated(EventCustom* event); #endif diff --git a/tests/cpp-tests/Classes/MenuTest/MenuTest.cpp b/tests/cpp-tests/Classes/MenuTest/MenuTest.cpp index 3fba8b87f5..762fc02754 100644 --- a/tests/cpp-tests/Classes/MenuTest/MenuTest.cpp +++ b/tests/cpp-tests/Classes/MenuTest/MenuTest.cpp @@ -445,7 +445,7 @@ MenuLayer4::MenuLayer4() item3, item4, back, nullptr ); // 9 items. - menu->alignItemsInColumns(2, 2, 2, 2, 1, nullptr); + menu->alignItemsInColumns(2, 2, 2, 2, 1, NULL); addChild( menu );