From de97900b6c67503afeb170105a68def76a524b01 Mon Sep 17 00:00:00 2001 From: yangws Date: Tue, 23 Nov 2010 11:23:29 +0800 Subject: [PATCH] CCLOG support for cocos2d-win32 --- .gitignore | 29 +++++++++++++ cocos2d-win32.sln | 14 +++++-- cocos2dx/include/ccMacros.h | 20 +++++---- cocos2dx/platform/win32/CCXCommon_win32.cpp | 46 +++++++++++++++++++++ cocos2dx/platform/win32/ccxCommon_win32.h | 9 ++++ cocos2dx/proj.win32/cocos2d-win32.vcproj | 4 ++ 6 files changed, 109 insertions(+), 13 deletions(-) create mode 100644 .gitignore create mode 100644 cocos2dx/platform/win32/CCXCommon_win32.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..c1058fb395 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ + +#ignore thumbnails created by windows +Thumbs.db +#Ignore files build by Visual Studio +*.obj +*.exe +*.pdb +*.aps +*.vcproj.*.user +*.pch +*.vspscc +*_i.c +*_p.c +*.ncb +*.suo +*.tlb +*.tlh +*.bak +*.cache +*.ilk +*.log +[Bb]in +[Dd]ebug*/ +*.lib +*.sbr +obj/ +[Rr]elease*/ +_ReSharper*/ +[Tt]est[Rr]esult* \ No newline at end of file diff --git a/cocos2d-win32.sln b/cocos2d-win32.sln index 92102f659b..061c75de45 100644 --- a/cocos2d-win32.sln +++ b/cocos2d-win32.sln @@ -13,18 +13,20 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tests", "tests\proj.win32\t {929480E7-23C0-4DF6-8456-096D71547116} = {929480E7-23C0-4DF6-8456-096D71547116} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "box2d", "Box2D\proj.win32\Box2D.win32.vcproj", "{929480E7-23C0-4DF6-8456-096D71547116}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libBox2D", "Box2D\proj.win32\Box2D.win32.vcproj", "{929480E7-23C0-4DF6-8456-096D71547116}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "chipmunk", "chipmunk\proj.win32\chipmunk.win32.vcproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "chipmunk\proj.win32\chipmunk.win32.vcproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cocosdenshion", "CocosDenshion\proj.win32\CocosDenshion.win32.vcproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosDenshion", "CocosDenshion\proj.win32\CocosDenshion.win32.vcproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloWorld", "HelloWorld.win32\HelloWorld.win32.vcproj", "{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}" ProjectSection(ProjectDependencies) = postProject {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cocos2d-win32", "cocos2dx\proj.win32\cocos2d-win32.vcproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "cocos2dx\proj.win32\cocos2d-win32.vcproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestWin32Wizard.win32", "TestWin32Wizard\TestWin32Wizard.win32.vcproj", "{2CADAE24-E793-480C-883F-6D90244B1ABD}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -60,6 +62,10 @@ Global {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.Build.0 = Debug|Win32 {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.ActiveCfg = Release|Win32 {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.Build.0 = Release|Win32 + {2CADAE24-E793-480C-883F-6D90244B1ABD}.Debug|Win32.ActiveCfg = Debug|Win32 + {2CADAE24-E793-480C-883F-6D90244B1ABD}.Debug|Win32.Build.0 = Debug|Win32 + {2CADAE24-E793-480C-883F-6D90244B1ABD}.Release|Win32.ActiveCfg = Release|Win32 + {2CADAE24-E793-480C-883F-6D90244B1ABD}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/cocos2dx/include/ccMacros.h b/cocos2dx/include/ccMacros.h index 4681f034b6..d95b5f12db 100644 --- a/cocos2dx/include/ccMacros.h +++ b/cocos2dx/include/ccMacros.h @@ -52,19 +52,21 @@ THE SOFTWARE. */ #if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0 -#define CCLOG(...) do {} while (0) -#define CCLOGINFO(...) do {} while (0) -#define CCLOGERROR(...) do {} while (0) +#define CCLOG(...) do {} while (0) +#define CCLOGINFO(...) do {} while (0) +#define CCLOGERROR(...) do {} while (0) #elif COCOS2D_DEBUG == 1 -#define CCLOG(...) std::printf(__VA_ARGS__) -#define CCLOGERROR(...) std::printf(__VA_ARGS__) -#define CCLOGINFO(...) do {} while (0) +#include "ccxCommon.h" +#define CCLOG(format, ...) cocos2d::CCXLog(format, __VA_ARGS__) +#define CCLOGERROR(format,...) cocos2d::CCXLog(format, __VA_ARGS__) +#define CCLOGINFO(format,...) do {} while (0) #elif COCOS2D_DEBUG > 1 -#define CCLOG(...) std::printf(__VA_ARGS__) -#define CCLOGERROR(...) std::printf(__VA_ARGS__) -#define CCLOGINFO(...) std::printf(__VA_ARGS__) +#include "ccxCommon.h" +#define CCLOG(format, ...) cocos2d::CCXLog(format, __VA_ARGS__) +#define CCLOGERROR(format,...) cocos2d::CCXLog(format, __VA_ARGS__) +#define CCLOGINFO(format,...) cocos2d::CCXLog(format, __VA_ARGS__) #endif // COCOS2D_DEBUG /** @def CC_SWAP diff --git a/cocos2dx/platform/win32/CCXCommon_win32.cpp b/cocos2dx/platform/win32/CCXCommon_win32.cpp new file mode 100644 index 0000000000..5bec01b83b --- /dev/null +++ b/cocos2dx/platform/win32/CCXCommon_win32.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +Copyright (c) 2010 cocos2d-x.org + +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 "ccxCommon_win32.h" + +#include +#include +#include + +#define MAX_LEN 256 + +namespace cocos2d { + +void CCXLog(const char * pszFormat, ...) +{ + char szBuf[MAX_LEN]; + + va_list ap; + va_start(ap, pszFormat); + vsprintf_s(szBuf, MAX_LEN, pszFormat, ap); + va_end(ap); + OutputDebugStringA(szBuf); +} + +}//namespace cocos2d diff --git a/cocos2dx/platform/win32/ccxCommon_win32.h b/cocos2dx/platform/win32/ccxCommon_win32.h index d6bf9df435..f9cc1061cb 100644 --- a/cocos2dx/platform/win32/ccxCommon_win32.h +++ b/cocos2dx/platform/win32/ccxCommon_win32.h @@ -31,4 +31,13 @@ THE SOFTWARE. #define CCX_DLL __declspec(dllimport) #endif +namespace cocos2d{ + + /** + @brief Output Debug message to VS Output window. + */ + void CCX_DLL CCXLog(const char * pszFormat, ...); + +}//namespace cocos2d + #endif // end of __CCX_COMMON_WIN32__ diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcproj b/cocos2dx/proj.win32/cocos2d-win32.vcproj index 5f1b90183a..6529cdb087 100644 --- a/cocos2dx/proj.win32/cocos2d-win32.vcproj +++ b/cocos2dx/proj.win32/cocos2d-win32.vcproj @@ -769,6 +769,10 @@ RelativePath="..\platform\win32\CCXCocos2dDefine_win32.h" > + +