From a42533ebd9d0a5eceea32ab4fd06e641396d7794 Mon Sep 17 00:00:00 2001 From: trentmillar Date: Sat, 1 Sep 2012 11:42:59 -0600 Subject: [PATCH 01/19] adding VC2012 sln. Also to build-win32.bat I changed the ordering in the bat file to process newer VC versions before older ones. This was an issue for me running multiple versions of VS on my box --- build-win32.bat | 16 ++++--- cocos2d-win32.vc2012.sln | 94 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 5 deletions(-) create mode 100644 cocos2d-win32.vc2012.sln diff --git a/build-win32.bat b/build-win32.bat index ebd9c837f4..68c9444dde 100644 --- a/build-win32.bat +++ b/build-win32.bat @@ -5,16 +5,19 @@ echo.* Check VC++ environment... echo.*/ echo. -if defined VS90COMNTOOLS ( - set VSVARS="%VS90COMNTOOLS%vsvars32.bat" - set VC_VER=90 +if defined VS110COMNTOOLS ( + set VSVARS="%VS110COMNTOOLS%vsvars32.bat" + set VC_VER=110 ) else if defined VS100COMNTOOLS ( set VSVARS="%VS100COMNTOOLS%vsvars32.bat" set VC_VER=100 -) +) else if defined VS90COMNTOOLS ( + set VSVARS="%VS90COMNTOOLS%vsvars32.bat" + set VC_VER=90 +) if not defined VSVARS ( - echo Can't find VC2008 or VC2010 installed! + echo Can't find VC2008, VC2010 or VC2012 installed! goto ERROR ) @@ -29,6 +32,9 @@ if %VC_VER%==90 ( ) else if %VC_VER%==100 ( msbuild cocos2d-win32.vc2010.sln /p:Configuration="Debug" msbuild cocos2d-win32.vc2010.sln /p:Configuration="Release" +) else if %VC_VER%==110 ( + msbuild cocos2d-win32.vc2012.sln /p:Configuration="Debug" + msbuild cocos2d-win32.vc2012.sln /p:Configuration="Release" ) else ( echo Script error. goto ERROR diff --git a/cocos2d-win32.vc2012.sln b/cocos2d-win32.vc2012.sln new file mode 100644 index 0000000000..79ba236ca0 --- /dev/null +++ b/cocos2d-win32.vc2012.sln @@ -0,0 +1,94 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libBox2D", "external\Box2D\proj.win32\Box2D.vcxproj", "{929480E7-23C0-4DF6-8456-096D71547116}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosDenshion", "CocosDenshion\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "cocos2dx\proj.win32\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblua", "scripting\lua\proj.win32\liblua.vcxproj", "{DDC3E27F-004D-4DD4-9DD3-931A013D2159}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloLua", "samples\HelloLua\proj.win32\HelloLua.vcxproj", "{13E55395-94A2-4CD9-BFC2-1A051F80C17D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloCpp", "samples\HelloCpp\proj.win32\HelloCpp.vcxproj", "{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestCpp", "samples\TestCpp\proj.win32\TestCpp.vcxproj", "{76A39BB2-9B84-4C65-98A5-654D86B86F2A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestJavascript", "samples\TestJavascript\proj.win32\TestJavascript.vcxproj", "{D0F06A44-A245-4D13-A498-0120C203B539}" + ProjectSection(ProjectDependencies) = postProject + {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "extensions\proj.win32\libExtensions.vcxproj", "{21B2C324-891F-48EA-AD1A-5AE13DE12E28}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestLua", "samples\TestLua\proj.win32\TestLua.win32.vcxproj", "{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}" + ProjectSection(ProjectDependencies) = postProject + {21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28} + {DDC3E27F-004D-4DD4-9DD3-931A013D2159} = {DDC3E27F-004D-4DD4-9DD3-931A013D2159} + {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} + {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} + {929480E7-23C0-4DF6-8456-096D71547116} = {929480E7-23C0-4DF6-8456-096D71547116} + {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} + EndProjectSection +EndProject +Global + GlobalSection(DPCodeReviewSolutionGUID) = preSolution + DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.ActiveCfg = Debug|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.Build.0 = Debug|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.ActiveCfg = Release|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.Build.0 = Release|Win32 + {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.ActiveCfg = Debug|Win32 + {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.Build.0 = Debug|Win32 + {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.ActiveCfg = Release|Win32 + {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.Build.0 = Release|Win32 + {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.ActiveCfg = Debug|Win32 + {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.Build.0 = Debug|Win32 + {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.ActiveCfg = Release|Win32 + {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.Build.0 = Release|Win32 + {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.ActiveCfg = Debug|Win32 + {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 + {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Debug|Win32.ActiveCfg = Debug|Win32 + {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Debug|Win32.Build.0 = Debug|Win32 + {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Release|Win32.ActiveCfg = Release|Win32 + {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Release|Win32.Build.0 = Release|Win32 + {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Debug|Win32.ActiveCfg = Debug|Win32 + {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Debug|Win32.Build.0 = Debug|Win32 + {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Release|Win32.ActiveCfg = Release|Win32 + {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Release|Win32.Build.0 = Release|Win32 + {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Debug|Win32.ActiveCfg = Debug|Win32 + {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Debug|Win32.Build.0 = Debug|Win32 + {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Release|Win32.ActiveCfg = Release|Win32 + {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Release|Win32.Build.0 = Release|Win32 + {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.ActiveCfg = Debug|Win32 + {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.Build.0 = Debug|Win32 + {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.ActiveCfg = Release|Win32 + {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.Build.0 = Release|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Debug|Win32.ActiveCfg = Debug|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Debug|Win32.Build.0 = Debug|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Release|Win32.ActiveCfg = Release|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Release|Win32.Build.0 = Release|Win32 + {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.ActiveCfg = Debug|Win32 + {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.Build.0 = Debug|Win32 + {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.ActiveCfg = Release|Win32 + {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.Build.0 = Release|Win32 + {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Debug|Win32.ActiveCfg = Debug|Win32 + {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Debug|Win32.Build.0 = Debug|Win32 + {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Release|Win32.ActiveCfg = Release|Win32 + {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal From a12054c00f57b686f31b2a810d9777805520f3d4 Mon Sep 17 00:00:00 2001 From: Trent Millar Date: Sat, 1 Sep 2012 14:32:46 -0600 Subject: [PATCH 02/19] Adding the VC++2012 template to install-templates-msvc.bat Tested against VS2012 RTM. Note, the .sln location is incorect on all the templates. It needs to move up relative to the cocos2d-x folder. I can look at fixing this later but for now I guess it must have been left to the user to manually move it. --- install-templates-msvc.bat | 35 ++-- template/msvc/InstallWizardForVS2012.js | 239 ++++++++++++++++++++++++ 2 files changed, 257 insertions(+), 17 deletions(-) create mode 100644 template/msvc/InstallWizardForVS2012.js diff --git a/install-templates-msvc.bat b/install-templates-msvc.bat index a603e4fa2c..0a3818dd53 100644 --- a/install-templates-msvc.bat +++ b/install-templates-msvc.bat @@ -1,17 +1,18 @@ - -echo./* -echo.* Install Cocos2d-win32 application wizard... -echo.*/ -echo. - -set SCRIPT_LOG=InstallWizardLog.txt -set SCRIPT_DIR=.\template\msvc\ - -if exist %SCRIPT_LOG% del /Q %SCRIPT_LOG% -cscript "%SCRIPT_DIR%InstallWizardForVC2008Express.js" /quiet -cscript "%SCRIPT_DIR%InstallWizardForVC2010Express.js" /quiet -cscript "%SCRIPT_DIR%InstallWizardForVS2008.js" /quiet -cscript "%SCRIPT_DIR%InstallWizardForVS2010.js" /quiet -if exist %SCRIPT_LOG% more %SCRIPT_LOG% -if exist %SCRIPT_LOG% del /Q %SCRIPT_LOG% - + +echo./* +echo.* Install Cocos2d-win32 application wizard... +echo.*/ +echo. + +set SCRIPT_LOG=InstallWizardLog.txt +set SCRIPT_DIR=.\template\msvc\ + +if exist %SCRIPT_LOG% del /Q %SCRIPT_LOG% +cscript "%SCRIPT_DIR%InstallWizardForVC2008Express.js" /quiet +cscript "%SCRIPT_DIR%InstallWizardForVC2010Express.js" /quiet +cscript "%SCRIPT_DIR%InstallWizardForVS2008.js" /quiet +cscript "%SCRIPT_DIR%InstallWizardForVS2010.js" /quiet +cscript "%SCRIPT_DIR%InstallWizardForVS2012.js" /quiet +if exist %SCRIPT_LOG% more %SCRIPT_LOG% +if exist %SCRIPT_LOG% del /Q %SCRIPT_LOG% + diff --git a/template/msvc/InstallWizardForVS2012.js b/template/msvc/InstallWizardForVS2012.js new file mode 100644 index 0000000000..a1b02be4eb --- /dev/null +++ b/template/msvc/InstallWizardForVS2012.js @@ -0,0 +1,239 @@ +// Setup program for the Cocos2d-win32 App Wizard for VC++ 11.0 (VC2012) + +main(); + +function EchoInfo(bQuiet, strMsg) { + if (! bQuiet) { + WScript.Echo(strMsg); + } + else { + var FileSys = new ActiveXObject("Scripting.FileSystemObject"); + var strLogPath = "InstallWizardLog.txt" + var file = FileSys.OpenTextFile(strLogPath, 8, true); + file.WriteLine(strMsg); + file.Close(); + } +} + +function EchoError(bQuiet, strMsg) { + strMsg = "Error: " + strMsg; + if (! bQuiet) { + WScript.Echo(strMsg); + } + else { + var FileSys = new ActiveXObject("Scripting.FileSystemObject"); + var strLogPath = "InstallWizardLog.txt" + var file = FileSys.OpenTextFile(strLogPath, 8, true); + file.WriteLine(strMsg); + file.Close(); + } +} + +function main() { + // Decode command line arguments + var bDebug = false; + var bQuiet = false; + var bElevated = false; + var Args = WScript.Arguments; + for (var i = 0; i < Args.length; i++) { + if (Args(i) == "/debug") + bDebug = true; + else if (Args(i) == "/elevated") + bElevated = true; + else if (Args(i) == "/quiet") + bQuiet = true; + } + + // See if UAC is enabled + var Shell = WScript.CreateObject("Shell.Application"); + if (!bElevated && Shell.IsRestricted("System", "EnableLUA")) { + // Check that the script is being run interactively. + if (!WScript.Interactive) { + EchoError(bQuiet, "(Windows LUA) Elevation required."); + return; + } + + // Now relaunch the script, using the "RunAs" verb to elevate + var strParams = "\"" + WScript.ScriptFullName + "\""; + if (bDebug) + strParams += " /debug"; + strParams += " /elevated"; + Shell.ShellExecute(WScript.FullName, strParams, null, "RunAs"); + return; + } + + // Create shell object + var WSShell = WScript.CreateObject("WScript.Shell"); + // Create file system object + var FileSys = WScript.CreateObject("Scripting.FileSystemObject"); + + // Get the folder containing the script file + var strScriptPath = FileSys.GetParentFolderName(WScript.ScriptFullName); + if (strScriptPath == null || strScriptPath == "") + strScriptPath = "."; + + // Get the folder script files copy to + var strValue = ""; + try { + var strVCKey = "HKLM\\Software\\Microsoft\\VisualStudio\\11.0\\Setup\\VC\\ProductDir"; + strValue = WSShell.RegRead(strVCKey); + } + catch (e) { + try { + var strVCKey_x64 = "HKLM\\Software\\Wow6432Node\\Microsoft\\VisualStudio\\11.0\\Setup\\VC\\ProductDir"; + strValue = WSShell.RegRead(strVCKey_x64); + } + catch (e) { + EchoError(bQuiet, "Cannot find where Visual Studio 2012 is installed."); + return; + } + } + + var strDestFolder = FileSys.BuildPath(strValue, "vcprojects"); + if (bDebug) + WScript.Echo("Destination: " + strDestFolder); + + if (!FileSys.FolderExists(strDestFolder)) { + EchoError(bQuiet, "Cannot find destination folder (should be: " + strDestFolder + ")"); + return; + } + + // Wizard Info + var nNumWizards = 1; + + var astrWizardName = new Array(); + astrWizardName[0] = "CCAppWiz.win32"; + + var nCntr; + for (nCntr = 0; nCntr < nNumWizards; nCntr++) { + var strSourceFolder = FileSys.BuildPath(strScriptPath, astrWizardName[nCntr]); + + if (bDebug) + WScript.Echo("Source: " + strSourceFolder); + + if (!FileSys.FolderExists(strSourceFolder)) { + EchoError(bQuiet, "Cannot find Wizard folder (should be: " + strSourceFolder + ")"); + return; + } + + // Copy files + try { + var strSrc = FileSys.BuildPath(strSourceFolder, astrWizardName[nCntr] + ".ico"); + var strDest = FileSys.BuildPath(strDestFolder, astrWizardName[nCntr] + ".ico"); + FileSys.CopyFile(strSrc, strDest); + + strSrc = FileSys.BuildPath(strSourceFolder, astrWizardName[nCntr] + ".vsdir"); + strDest = FileSys.BuildPath(strDestFolder, astrWizardName[nCntr] + ".vsdir"); + FileSys.CopyFile(strSrc, strDest); + } + catch (e) { + var strError = "no info"; + if (e.description.length != 0) + strError = e.description; + EchoError(bQuiet, "Cannot copy file (" + strError + ")"); + return; + } + + // Read and write CCAppWiz.vsz, add engine version and replace path when found + try { + var strSrc = FileSys.BuildPath(strSourceFolder, astrWizardName[nCntr] + ".vsz"); + var strDest = FileSys.BuildPath(strDestFolder, astrWizardName[nCntr] + ".vsz"); + + var ForReading = 1; + var fileSrc = FileSys.OpenTextFile(strSrc, ForReading); + if (fileSrc == null) { + EchoError(bQuiet, "Cannot open source file: " + strSrc); + return; + } + + var ForWriting = 2; + var fileDest = FileSys.OpenTextFile(strDest, ForWriting, true); + if (fileDest == null) { + EchoError(bQuiet, " Cannot open destination file: " + strDest); + return; + } + + while (!fileSrc.AtEndOfStream) { + var strLine = fileSrc.ReadLine(); + if (strLine.indexOf("Wizard=VsWizard.VsWizardEngine") != -1) + strLine += ".11.0"; + else if (strLine.indexOf("WIZARD_VERSION") != -1) + strLine = "Param=\"WIZARD_VERSION = 11.0\""; + else if (strLine.indexOf("ABSOLUTE_PATH") != -1) + strLine = "Param=\"ABSOLUTE_PATH = " + strSourceFolder + "\""; + fileDest.WriteLine(strLine); + } + + fileSrc.Close(); + fileDest.Close(); + } + catch (e) { + var strError = "no info"; + if (e.description.length != 0) + strError = e.description; + EchoError(bQuiet, "Cannot read and write CCAppWiz.vsz (" + strError + ")"); + return; + } + } + + // Create Cocos2d-x folder + var strDestCCFolder = ""; + try { + strDestCCFolder = FileSys.BuildPath(strDestFolder, "Cocos2d-x"); + if (!FileSys.FolderExists(strDestCCFolder)) + FileSys.CreateFolder(strDestCCFolder); + if (bDebug) + WScript.Echo("Cocos2d-x Folder: " + strDestCCFolder); + } + catch (e) { + var strError = "no info"; + if (e.description.length != 0) + strError = e.description; + EchoError(bQuiet, "Cannot create Cocos2d-x folder (" + strError + ")"); + return; + } + + // Read and write additional CCAppWiz.vsdir, add path to the wizard location + try { + var strDest = FileSys.BuildPath(strDestCCFolder, "Cocos2d-x.vsdir"); + + var ForWriting = 2; + + var fileDest = FileSys.OpenTextFile(strDest, ForWriting, true); + if (fileDest == null) { + EchoError(bQuiet, "Cannot open destination file: " + strDest); + return; + } + + var nCntr; + for (nCntr = 0; nCntr < nNumWizards; nCntr++) { + var strSourceFolder = FileSys.BuildPath(strScriptPath, astrWizardName[nCntr]); + var strSrc = FileSys.BuildPath(strSourceFolder, astrWizardName[nCntr] + ".vsdir"); + var ForReading = 1; + var fileSrc = FileSys.OpenTextFile(strSrc, ForReading); + if (fileSrc == null) { + EchoError(bQuiet, "Cannot open source file: " + strSrc); + return; + } + + while (!fileSrc.AtEndOfStream) { + var strLine = fileSrc.ReadLine(); + if (strLine.indexOf(astrWizardName[nCntr] + ".vsz|") != -1) + strLine = "..\\" + strLine; + fileDest.WriteLine(strLine); + } + + fileSrc.Close(); + } + fileDest.Close(); + } + catch (e) { + var strError = "no info"; + if (e.description.length != 0) + strError = e.description; + EchoError(bQuiet, "Cannot read and write Cocos2d-x\\CCAppWiz.vsdir (" + strError + ")"); + return; + } + + EchoInfo(bQuiet, "App Wizard successfully installed for VS2012!"); +} From 1d2b7c5b334a22824f8e5162e343df26ff197b9c Mon Sep 17 00:00:00 2001 From: trentmillar Date: Sun, 2 Sep 2012 13:23:33 -0600 Subject: [PATCH 03/19] Comment in VS2012 sln file. changed to 2012 --- cocos2d-win32.vc2012.sln | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d-win32.vc2012.sln b/cocos2d-win32.vc2012.sln index 79ba236ca0..5160de0d46 100644 --- a/cocos2d-win32.vc2012.sln +++ b/cocos2d-win32.vc2012.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +# Visual Studio 2012 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libBox2D", "external\Box2D\proj.win32\Box2D.vcxproj", "{929480E7-23C0-4DF6-8456-096D71547116}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}" From 82ea6fbb99dff48aedd7c9956f705eb71c1151fc Mon Sep 17 00:00:00 2001 From: ThePickleMan Date: Sun, 2 Sep 2012 16:08:13 -0500 Subject: [PATCH 04/19] Update extensions/GUI/CCControlExtension/CCControlSlider.h Added fields and methods for setting the maximum allowed value. --- extensions/GUI/CCControlExtension/CCControlSlider.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.h b/extensions/GUI/CCControlExtension/CCControlSlider.h index 21b6a934d9..bfe8136f2e 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.h +++ b/extensions/GUI/CCControlExtension/CCControlSlider.h @@ -55,6 +55,11 @@ class CCControlSlider: public CCControl virtual void setMinimumValue(float val); CC_SYNTHESIZE_READONLY(float, m_maximumValue, MaximumValue); virtual void setMaximumValue(float val); + CC_SYNTHESIZE_READONLY(float, m_minimumAllowedValue, MinimumAllowedValue); + virtual void setMinimumAllowedValue(float val); + CC_SYNTHESIZE_READONLY(float, m_maximumAllowedValue, MaximumAllowedValue); + virtual void setMaximumAllowedValue(float val); + //interval to snap to CC_SYNTHESIZE(float, m_snappingInterval, SnappingInterval); From e07320f6a8a18aeb4b262ace220b89b87b9f9b8f Mon Sep 17 00:00:00 2001 From: ThePickleMan Date: Sun, 2 Sep 2012 16:10:25 -0500 Subject: [PATCH 05/19] Update extensions/GUI/CCControlExtension/CCControlSlider.cpp Added minimum/maximum allowed values --- .../GUI/CCControlExtension/CCControlSlider.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.cpp b/extensions/GUI/CCControlExtension/CCControlSlider.cpp index b8b3c1bd6a..d47df67c7c 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSlider.cpp @@ -161,6 +161,16 @@ CCControlSlider* CCControlSlider::create(CCSprite * backgroundSprite, CCSprite* m_minimumValue = m_maximumValue - 1.0f; setValue(m_value); } + + void CCControlSlider::setMinimumAllowedValue(float minimumAllowedValue) + { + m_minimumAllowedValue = minimumAllowedValue; + } + + void CCControlSlider::setMaximumAllowedValue(float maximumAllowedValue) + { + m_maximumAllowedValue = maximumAllowedValue; + } //this is the same as CCControl::getTouchLocation, but it returns the position relative to the position of this control CCPoint CCControlSlider::getTouchLocationInControl(CCTouch* touch) @@ -224,7 +234,7 @@ void CCControlSlider::sliderEnded(CCPoint location) float CCControlSlider::valueForLocation(CCPoint location) { float percent = (location.x-SLIDER_MARGIN_H)/ m_backgroundSprite->getContentSize().width; - return m_minimumValue + percent * (m_maximumValue - m_minimumValue); + return max(min(m_minimumValue + percent * (m_maximumValue - m_minimumValue), m_maximumAllowedValue), m_minimumAllowedValue); } NS_CC_EXT_END From da819e1109563c5f73edfa4bf49f153aeca88552 Mon Sep 17 00:00:00 2001 From: ThePickleMan Date: Sun, 2 Sep 2012 16:31:12 -0500 Subject: [PATCH 06/19] Update extensions/GUI/CCControlExtension/CCControlSlider.cpp Added default values for max/min allowed values --- extensions/GUI/CCControlExtension/CCControlSlider.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.cpp b/extensions/GUI/CCControlExtension/CCControlSlider.cpp index d47df67c7c..077cc7288b 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSlider.cpp @@ -149,6 +149,7 @@ CCControlSlider* CCControlSlider::create(CCSprite * backgroundSprite, CCSprite* void CCControlSlider::setMinimumValue(float minimumValue) { m_minimumValue=minimumValue; + m_minimumAllowedValue = minimumValue; if (m_minimumValue >= m_maximumValue) m_maximumValue = m_minimumValue + 1.0f; setValue(m_value); @@ -157,6 +158,7 @@ CCControlSlider* CCControlSlider::create(CCSprite * backgroundSprite, CCSprite* void CCControlSlider::setMaximumValue(float maximumValue) { m_maximumValue=maximumValue; + m_maximumAllowedValue = maximumValue; if (m_maximumValue <= m_minimumValue) m_minimumValue = m_maximumValue - 1.0f; setValue(m_value); From b0d7ecec420e6cf6aea544f3740d08ec0e0ffbc9 Mon Sep 17 00:00:00 2001 From: yodesoft Date: Mon, 3 Sep 2012 12:38:29 +0800 Subject: [PATCH 07/19] Supported display Unicode chars. --- cocos2dx/platform/linux/CCImage.cpp | 174 +++++++++++++++++----------- 1 file changed, 107 insertions(+), 67 deletions(-) diff --git a/cocos2dx/platform/linux/CCImage.cpp b/cocos2dx/platform/linux/CCImage.cpp index 0925eb7cc0..3e65ef7919 100644 --- a/cocos2dx/platform/linux/CCImage.cpp +++ b/cocos2dx/platform/linux/CCImage.cpp @@ -22,8 +22,8 @@ using namespace std; struct TextLine { - string sLineStr; int iLineWidth; + wchar_t* text; }; NS_CC_BEGIN @@ -43,89 +43,134 @@ public: // if (m_pData) { // delete m_pData; // } - + reset(); } void reset() { iMaxLineWidth = 0; iMaxLineHeight = 0; - vLines.clear(); + //Free all text lines + size_t size = vLines.size(); + for (int i=0; iglyph->metrics.horiAdvance + face->glyph->metrics.horiBearingX - face->glyph->metrics.width))/*-iInterval*/;//TODO interval + return a; + } + if ((**p & 0xE0) == 0xC0) + { + int a = *((*p)++) & 0x1F; + int b = *((*p)++) & 0x3F; + + return (a << 6) | b; + } + if ((**p & 0xF0) == 0xE0) + { + int a = *((*p)++) & 0x0F; + int b = *((*p)++) & 0x3F; + int c = *((*p)++) & 0x3F; + + return (a << 12) | (b << 6) | c; + } + if ((**p & 0xF8) == 0xF0) + { + int a = *((*p)++) & 0x07; + int b = *((*p)++) & 0x3F; + int c = *((*p)++) & 0x3F; + int d = *((*p)++) & 0x3F; + + return (a << 18) | (b << 12) | (c << 8) | d; + } + return 0; + } + + void buildLine(wchar_t* buf, size_t buf_len, FT_Face face, int iCurXCursor, FT_UInt cLastChar) { + TextLine oTempLine; + wchar_t* text = (wchar_t*)malloc(sizeof(wchar_t) * (buf_len+1)); + memcpy(text, buf, sizeof(wchar_t) * buf_len); + text[buf_len] = '\0'; + oTempLine.text = text; + + //get last glyph + int iError = FT_Load_Char(face, cLastChar, FT_LOAD_DEFAULT); + + oTempLine.iLineWidth = iCurXCursor;// - SHIFT6((face->glyph->metrics.horiAdvance + face->glyph->metrics.horiBearingX - face->glyph->metrics.width))/*-iInterval*/;//TODO interval iMaxLineWidth = MAX(iMaxLineWidth, oTempLine.iLineWidth); - ss.clear(); - ss.str(""); - vLines.push_back(oTempLine); + vLines.push_back(oTempLine); } bool divideString(FT_Face face, const char* sText, int iMaxWidth, int iMaxHeight) { - const char* pText = sText; int iError = 0; int iCurXCursor, iCurYCursor; - iError = FT_Load_Glyph(face, FT_Get_Char_Index(face, *pText), - FT_LOAD_DEFAULT); + const char* pText = sText; + + FT_UInt unicode = utf8((char**)&pText); + iError = FT_Load_Char(face, unicode, FT_LOAD_DEFAULT); if (iError) { return false; } iCurXCursor = -SHIFT6(face->glyph->metrics.horiBearingX); - //init stringstream - stringstream ss; + FT_UInt cLastCh = 0; - int cLastCh = 0; + pText = sText; + size_t text_len = 0; + wchar_t* text_buf = (wchar_t*) malloc(sizeof(wchar_t) * strlen(sText)); + while (unicode=utf8((char**)&pText)) { + if (unicode == '\n') { + buildLine(text_buf, text_len, face, iCurXCursor, cLastCh); + text_len = 0; - while (*pText != '\0') { - if (*pText == '\n') { - buildLine(ss, face, iCurXCursor, cLastCh); - - pText++; - iError = FT_Load_Glyph(face, FT_Get_Char_Index(face, *pText), - FT_LOAD_DEFAULT); + iError = FT_Load_Char(face, unicode, FT_LOAD_DEFAULT); if (iError) { + free(text_buf); return false; } iCurXCursor = -SHIFT6(face->glyph->metrics.horiBearingX); continue; } - iError = FT_Load_Glyph(face, FT_Get_Char_Index(face, *pText), - FT_LOAD_DEFAULT); + iError = FT_Load_Char(face, unicode, FT_LOAD_DEFAULT); if (iError) { + free(text_buf); return false; - //break; } + //check its width //divide it when exceeding if ((iMaxWidth > 0 && iCurXCursor + SHIFT6(face->glyph->metrics.width) > iMaxWidth)) { - buildLine(ss, face , iCurXCursor, cLastCh); + buildLine(text_buf, text_len, face , iCurXCursor, cLastCh); + text_len = 0; iCurXCursor = -SHIFT6(face->glyph->metrics.horiBearingX); } - cLastCh = *pText; - ss << *pText; + cLastCh = unicode; + text_buf[text_len] = unicode; + ++text_len; iCurXCursor += SHIFT6(face->glyph->metrics.horiAdvance) + iInterval; - pText++; - } + if (iError) { + free(text_buf); return false; } - buildLine(ss,face, iCurXCursor, cLastCh); + buildLine(text_buf, text_len, face, iCurXCursor, cLastCh); + free(text_buf); return true; } @@ -137,11 +182,10 @@ public: * while -1 means fail * */ - int computeLineStart(FT_Face face, CCImage::ETextAlign eAlignMask, char cText, + int computeLineStart(FT_Face face, CCImage::ETextAlign eAlignMask, FT_UInt unicode, int iLineIndex) { int iRet; - int iError = FT_Load_Glyph(face, FT_Get_Char_Index(face, cText), - FT_LOAD_DEFAULT); + int iError = FT_Load_Char(face, unicode, FT_LOAD_DEFAULT); if (iError) { return -1; } @@ -183,7 +227,6 @@ public: FT_Face face; FT_Error iError; - const char* pText = text; //data will be deleted by CCImage // if (m_pData) { // delete m_pData; @@ -195,7 +238,9 @@ public: return false; } do { - iError = FT_New_Face( library, pFontName, 0, &face ); + //iError = FT_New_Face( library, pFontName, 0, &face ); + //TODO: Create font name array??? + iError = FT_New_Face( library, "/usr/share/fonts/truetype/wqy/wqy-microhei.ttc", 0, &face ); if (iError) { //no valid font found use default @@ -216,8 +261,7 @@ public: //compute the final line width iMaxLineWidth = MAX(iMaxLineWidth, nWidth); - iMaxLineHeight = (face->size->metrics.ascender >> 6) - - (face->size->metrics.descender >> 6); + iMaxLineHeight = (face->size->metrics.ascender >> 6) - (face->size->metrics.descender >> 6); iMaxLineHeight *= vLines.size(); int txtHeight = iMaxLineHeight; @@ -230,31 +274,34 @@ public: memset(m_pData,0, iMaxLineWidth * iMaxLineHeight*4); - for (size_t i = 0; i < vLines.size(); i++) { - pText = vLines[i].sLineStr.c_str(); - //initialize the origin cursor - iCurXCursor = computeLineStart(face, eAlignMask, *pText, i); + size_t lines = vLines.size(); + for (size_t i = 0; i < lines; i++) { + const wchar_t* text_ptr = vLines[i].text; - while (*pText != 0) { - int iError = FT_Load_Glyph(face, FT_Get_Char_Index(face, *pText), - FT_LOAD_RENDER); + //initialize the origin cursor + iCurXCursor = computeLineStart(face, eAlignMask, text_ptr[0], i); + + size_t text_len = wcslen(text_ptr); + for (size_t i=0; iglyph->bitmap; + FT_Bitmap& bitmap = face->glyph->bitmap; + int yoffset = iCurYCursor - (face->glyph->metrics.horiBearingY >> 6); + int xoffset = iCurXCursor + (face->glyph->metrics.horiBearingX >> 6); for (int i = 0; i < bitmap.rows; ++i) { for (int j = 0; j < bitmap.width; ++j) { + unsigned char cTemp = bitmap.buffer[i * bitmap.width + j]; + if (cTemp == 0) continue; + // if it has gray>0 we set show it as 1, o otherwise - int iY = iCurYCursor + i - - (face->glyph->metrics.horiBearingY - >> 6); - int iX = iCurXCursor - + (face->glyph->metrics.horiBearingX - >> 6) + j; + int iY = yoffset + i; + int iX = xoffset + j; if (iY>=iMaxLineHeight) { //exceed the height truncate @@ -270,20 +317,16 @@ public: // bitmap.buffer[i * bitmap.width + j];//G // m_pData[(iY * iMaxLineWidth + iX) * 4 + 0] = // bitmap.buffer[i * bitmap.width + j];//B + int iTemp = 0; - unsigned char cTemp = bitmap.buffer[i - * bitmap.width + j]; iTemp |= (cTemp ? 0xff : 0)<<24; iTemp |= cTemp << 16 | cTemp << 8 | cTemp; - *(int*) &m_pData[(iY * iMaxLineWidth + iX) - * 4 + 0] = iTemp; + *(int*) &m_pData[(iY * iMaxLineWidth + iX) * 4 + 0] = iTemp; } } //step to next glyph - iCurXCursor += (face->glyph->metrics.horiAdvance >> 6) - + iInterval; + iCurXCursor += (face->glyph->metrics.horiAdvance >> 6) + iInterval; - pText++; } iCurYCursor += (face->size->metrics.ascender >> 6) - (face->size->metrics.descender >> 6); @@ -301,9 +344,6 @@ public: FT_Done_Face(face); face = NULL; - //clear all lines - vLines.clear(); - //success; if (iError) { bRet = false; From a4d2d317b53a67ca588e295fa04fa36c8a0be442 Mon Sep 17 00:00:00 2001 From: ThePickleMan Date: Mon, 3 Sep 2012 09:46:55 -0500 Subject: [PATCH 08/19] Update extensions/GUI/CCControlExtension/CCControlSlider.cpp --- extensions/GUI/CCControlExtension/CCControlSlider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.cpp b/extensions/GUI/CCControlExtension/CCControlSlider.cpp index 077cc7288b..061527f710 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSlider.cpp @@ -236,7 +236,7 @@ void CCControlSlider::sliderEnded(CCPoint location) float CCControlSlider::valueForLocation(CCPoint location) { float percent = (location.x-SLIDER_MARGIN_H)/ m_backgroundSprite->getContentSize().width; - return max(min(m_minimumValue + percent * (m_maximumValue - m_minimumValue), m_maximumAllowedValue), m_minimumAllowedValue); + return MAX(MIN(m_minimumValue + percent * (m_maximumValue - m_minimumValue), m_maximumAllowedValue), m_minimumAllowedValue); } NS_CC_EXT_END From f67839705f245bdf3be7355d5fa808bd7c4192a1 Mon Sep 17 00:00:00 2001 From: Trent Millar Date: Mon, 3 Sep 2012 13:18:54 -0600 Subject: [PATCH 09/19] Had wrong version in 2012 sln file. Adding clean /m to build --- build-win32.bat | 157 ++++++++++++++++++++------------------- cocos2d-win32.vc2012.sln | 94 +++++++++++++++++++++++ 2 files changed, 173 insertions(+), 78 deletions(-) diff --git a/build-win32.bat b/build-win32.bat index 68c9444dde..609b6c53ed 100644 --- a/build-win32.bat +++ b/build-win32.bat @@ -1,78 +1,79 @@ -@echo off - -echo./* -echo.* Check VC++ environment... -echo.*/ -echo. - -if defined VS110COMNTOOLS ( - set VSVARS="%VS110COMNTOOLS%vsvars32.bat" - set VC_VER=110 -) else if defined VS100COMNTOOLS ( - set VSVARS="%VS100COMNTOOLS%vsvars32.bat" - set VC_VER=100 -) else if defined VS90COMNTOOLS ( - set VSVARS="%VS90COMNTOOLS%vsvars32.bat" - set VC_VER=90 -) - -if not defined VSVARS ( - echo Can't find VC2008, VC2010 or VC2012 installed! - goto ERROR -) - -echo./* -echo.* Building cocos2d-x library binary, please wait a while... -echo.*/ -echo. - -call %VSVARS% -if %VC_VER%==90 ( - vcbuild /MP /M10 cocos2d-win32.vc2008.sln $ALL -) else if %VC_VER%==100 ( - msbuild cocos2d-win32.vc2010.sln /p:Configuration="Debug" - msbuild cocos2d-win32.vc2010.sln /p:Configuration="Release" -) else if %VC_VER%==110 ( - msbuild cocos2d-win32.vc2012.sln /p:Configuration="Debug" - msbuild cocos2d-win32.vc2012.sln /p:Configuration="Release" -) else ( - echo Script error. - goto ERROR -) - -echo./* -echo.* Check the cocos2d-win32 application "TestCpp.exe" ... -echo.*/ -echo. - -cd ".\Release.win32\" - -set CC_TEST_BIN=TestCpp.exe - -set CC_TEST_RES=..\samples\TestCpp\Resources\*.* -set CC_HELLOWORLD_RES=..\samples\HelloCpp\Resources\*.* -set CC_HELLOLUA_RES=..\samples\HelloLua\Resources\*.* -set CC_TESTJS_RES=..\samples\TestJavascript\Resources\*.* - -if not exist "%CC_TEST_BIN%" ( - echo Can't find the binary "TestCpp.exe", is there build error? - goto ERROR -) - -echo./* -echo.* Run cocos2d-win32 tests.exe and view Cocos2d-x Application Wizard for Visual Studio User Guide. -echo.*/ -echo. -xcopy /E /Y /Q "%CC_TEST_RES%" . -xcopy /E /Y /Q "%CC_HELLOWORLD_RES%" . -xcopy /E /Y /Q "%CC_HELLOLUA_RES%" . -xcopy /E /Y /Q "%CC_TESTJS_RES%" . - -call "%CC_TEST_BIN%" -start http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Cocos2d-x_Application_Wizard_for_Visual_Studio_User_Guide -goto EOF - -:ERROR -pause - -:EOF +@echo off + +echo./* +echo.* Check VC++ environment... +echo.*/ +echo. + +if defined VS110COMNTOOLS ( + set VSVARS="%VS110COMNTOOLS%vsvars32.bat" + set VC_VER=110 +) else if defined VS100COMNTOOLS ( + set VSVARS="%VS100COMNTOOLS%vsvars32.bat" + set VC_VER=100 +) else if defined VS90COMNTOOLS ( + set VSVARS="%VS90COMNTOOLS%vsvars32.bat" + set VC_VER=90 +) + +if not defined VSVARS ( + echo Can't find VC2008, VC2010 or VC2012 installed! + goto ERROR +) + +echo./* +echo.* Building cocos2d-x library binary, please wait a while... +echo.*/ +echo. + +call %VSVARS% +if %VC_VER%==90 ( + vcbuild /MP /M10 cocos2d-win32.vc2008.sln $ALL +) else if %VC_VER%==100 ( + msbuild cocos2d-win32.vc2010.sln /p:Configuration="Debug" + msbuild cocos2d-win32.vc2010.sln /p:Configuration="Release" +) else if %VC_VER%==110 ( + msbuild cocos2d-win32.vc2012.sln /t:Clean + msbuild cocos2d-win32.vc2012.sln /p:Configuration="Debug" /m + msbuild cocos2d-win32.vc2012.sln /p:Configuration="Release" /m +) else ( + echo Script error. + goto ERROR +) + +echo./* +echo.* Check the cocos2d-win32 application "TestCpp.exe" ... +echo.*/ +echo. + +cd ".\Release.win32\" + +set CC_TEST_BIN=TestCpp.exe + +set CC_TEST_RES=..\samples\TestCpp\Resources\*.* +set CC_HELLOWORLD_RES=..\samples\HelloCpp\Resources\*.* +set CC_HELLOLUA_RES=..\samples\HelloLua\Resources\*.* +set CC_TESTJS_RES=..\samples\TestJavascript\Resources\*.* + +if not exist "%CC_TEST_BIN%" ( + echo Can't find the binary "TestCpp.exe", is there build error? + goto ERROR +) + +echo./* +echo.* Run cocos2d-win32 tests.exe and view Cocos2d-x Application Wizard for Visual Studio User Guide. +echo.*/ +echo. +xcopy /E /Y /Q "%CC_TEST_RES%" . +xcopy /E /Y /Q "%CC_HELLOWORLD_RES%" . +xcopy /E /Y /Q "%CC_HELLOLUA_RES%" . +xcopy /E /Y /Q "%CC_TESTJS_RES%" . + +call "%CC_TEST_BIN%" +start http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Cocos2d-x_Application_Wizard_for_Visual_Studio_User_Guide +goto EOF + +:ERROR +pause + +:EOF diff --git a/cocos2d-win32.vc2012.sln b/cocos2d-win32.vc2012.sln index 5160de0d46..8245115887 100644 --- a/cocos2d-win32.vc2012.sln +++ b/cocos2d-win32.vc2012.sln @@ -92,3 +92,97 @@ Global HideSolutionNode = FALSE EndGlobalSection EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libBox2D", "external\Box2D\proj.win32\Box2D.vcxproj", "{929480E7-23C0-4DF6-8456-096D71547116}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosDenshion", "CocosDenshion\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "cocos2dx\proj.win32\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblua", "scripting\lua\proj.win32\liblua.vcxproj", "{DDC3E27F-004D-4DD4-9DD3-931A013D2159}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloLua", "samples\HelloLua\proj.win32\HelloLua.vcxproj", "{13E55395-94A2-4CD9-BFC2-1A051F80C17D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloCpp", "samples\HelloCpp\proj.win32\HelloCpp.vcxproj", "{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestCpp", "samples\TestCpp\proj.win32\TestCpp.vcxproj", "{76A39BB2-9B84-4C65-98A5-654D86B86F2A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestJavascript", "samples\TestJavascript\proj.win32\TestJavascript.vcxproj", "{D0F06A44-A245-4D13-A498-0120C203B539}" + ProjectSection(ProjectDependencies) = postProject + {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "extensions\proj.win32\libExtensions.vcxproj", "{21B2C324-891F-48EA-AD1A-5AE13DE12E28}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestLua", "samples\TestLua\proj.win32\TestLua.win32.vcxproj", "{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}" + ProjectSection(ProjectDependencies) = postProject + {21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28} + {DDC3E27F-004D-4DD4-9DD3-931A013D2159} = {DDC3E27F-004D-4DD4-9DD3-931A013D2159} + {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} + {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} + {929480E7-23C0-4DF6-8456-096D71547116} = {929480E7-23C0-4DF6-8456-096D71547116} + {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} + EndProjectSection +EndProject +Global + GlobalSection(DPCodeReviewSolutionGUID) = preSolution + DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.ActiveCfg = Debug|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.Build.0 = Debug|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.ActiveCfg = Release|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.Build.0 = Release|Win32 + {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.ActiveCfg = Debug|Win32 + {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.Build.0 = Debug|Win32 + {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.ActiveCfg = Release|Win32 + {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.Build.0 = Release|Win32 + {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.ActiveCfg = Debug|Win32 + {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.Build.0 = Debug|Win32 + {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.ActiveCfg = Release|Win32 + {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.Build.0 = Release|Win32 + {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.ActiveCfg = Debug|Win32 + {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 + {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Debug|Win32.ActiveCfg = Debug|Win32 + {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Debug|Win32.Build.0 = Debug|Win32 + {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Release|Win32.ActiveCfg = Release|Win32 + {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Release|Win32.Build.0 = Release|Win32 + {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Debug|Win32.ActiveCfg = Debug|Win32 + {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Debug|Win32.Build.0 = Debug|Win32 + {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Release|Win32.ActiveCfg = Release|Win32 + {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Release|Win32.Build.0 = Release|Win32 + {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Debug|Win32.ActiveCfg = Debug|Win32 + {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Debug|Win32.Build.0 = Debug|Win32 + {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Release|Win32.ActiveCfg = Release|Win32 + {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Release|Win32.Build.0 = Release|Win32 + {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.ActiveCfg = Debug|Win32 + {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.Build.0 = Debug|Win32 + {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.ActiveCfg = Release|Win32 + {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.Build.0 = Release|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Debug|Win32.ActiveCfg = Debug|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Debug|Win32.Build.0 = Debug|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Release|Win32.ActiveCfg = Release|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Release|Win32.Build.0 = Release|Win32 + {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.ActiveCfg = Debug|Win32 + {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.Build.0 = Debug|Win32 + {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.ActiveCfg = Release|Win32 + {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.Build.0 = Release|Win32 + {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Debug|Win32.ActiveCfg = Debug|Win32 + {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Debug|Win32.Build.0 = Debug|Win32 + {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Release|Win32.ActiveCfg = Release|Win32 + {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal From 95f204cd17e0ed31484aeb25eafb25588f5b2a33 Mon Sep 17 00:00:00 2001 From: yodesoft Date: Tue, 4 Sep 2012 10:48:02 +0800 Subject: [PATCH 10/19] Add font table to handler font info, eg. family_name, style_name, filename --- cocos2dx/platform/linux/CCImage.cpp | 48 ++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/cocos2dx/platform/linux/CCImage.cpp b/cocos2dx/platform/linux/CCImage.cpp index 3e65ef7919..e9ea9daa2e 100644 --- a/cocos2dx/platform/linux/CCImage.cpp +++ b/cocos2dx/platform/linux/CCImage.cpp @@ -26,6 +26,21 @@ struct TextLine { wchar_t* text; }; +struct FontTableItem { + char* family_name; + char* style_name; + char* filename; +}; + +const int fontTableItems = 4; +const char* fontPath = "/usr/share/fonts/truetype/"; +FontTableItem fontsTable[fontTableItems] = { + { "Serif", "Medium", "freefont/FreeSerif.ttf" }, + { "Sans", "Medium", "freefont/FreeSans.ttf" }, + { "WenQuanYi Micro Hei", "Regular", "wqy/wqy-microhei.ttc" }, + { "WenQuanYi Zen Hei", "Regular", "wqy/wqy-zenhei.ttc" }, +}; + NS_CC_BEGIN class BitmapDC { @@ -223,6 +238,29 @@ public: return iRet; } + char* getFontFile(const char* family_name) { + char* ret = NULL; + for (int i=0; ifamily_name, family_name) == 0) { + size_t len = strlen(fontPath) + strlen(item->filename) + 1; + ret = (char*) malloc(len); + snprintf(ret, len, "%s%s", fontPath, item->filename); + break; + } + } + + // Return a default font , if font is not found + if (ret == NULL) { + FontTableItem* item = &fontsTable[0]; + size_t len = strlen(fontPath) + strlen(item->filename) + 1; + ret = (char*) malloc(len); + snprintf(ret, len, "%s%s", fontPath, item->filename); + } + + return ret; + } + bool getBitmap(const char *text, int nWidth, int nHeight, CCImage::ETextAlign eAlignMask, const char * pFontName, float fontSize) { FT_Face face; FT_Error iError; @@ -238,9 +276,9 @@ public: return false; } do { - //iError = FT_New_Face( library, pFontName, 0, &face ); - //TODO: Create font name array??? - iError = FT_New_Face( library, "/usr/share/fonts/truetype/wqy/wqy-microhei.ttc", 0, &face ); + char* fontfile = getFontFile(pFontName); + iError = FT_New_Face( library, fontfile, 0, &face ); + free(fontfile); if (iError) { //no valid font found use default @@ -384,9 +422,9 @@ bool CCImage::initWithString( BitmapDC &dc = sharedBitmapDC(); - const char* pFullFontName = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pFontName); + //const char* pFullFontName = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pFontName); - CC_BREAK_IF(! dc.getBitmap(pText, nWidth, nHeight, eAlignMask, pFullFontName, nSize)); + CC_BREAK_IF(! dc.getBitmap(pText, nWidth, nHeight, eAlignMask, pFontName, nSize)); // assign the dc.m_pData to m_pData in order to save time m_pData = dc.m_pData; From f6f370ffeab2c654595f1e1a659b37c91cf8e560 Mon Sep 17 00:00:00 2001 From: ThePickleMan Date: Tue, 4 Sep 2012 20:48:04 -0500 Subject: [PATCH 11/19] Update extensions/GUI/CCControlExtension/CCControlSlider.h changed CC_SYNTHESIZE_READONLY to CC_SYNTHESIZE --- extensions/GUI/CCControlExtension/CCControlSlider.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.h b/extensions/GUI/CCControlExtension/CCControlSlider.h index bfe8136f2e..e8fe9de314 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.h +++ b/extensions/GUI/CCControlExtension/CCControlSlider.h @@ -55,9 +55,9 @@ class CCControlSlider: public CCControl virtual void setMinimumValue(float val); CC_SYNTHESIZE_READONLY(float, m_maximumValue, MaximumValue); virtual void setMaximumValue(float val); - CC_SYNTHESIZE_READONLY(float, m_minimumAllowedValue, MinimumAllowedValue); + CC_SYNTHESIZE(float, m_minimumAllowedValue, MinimumAllowedValue); virtual void setMinimumAllowedValue(float val); - CC_SYNTHESIZE_READONLY(float, m_maximumAllowedValue, MaximumAllowedValue); + CC_SYNTHESIZE(float, m_maximumAllowedValue, MaximumAllowedValue); virtual void setMaximumAllowedValue(float val); From 423abc6f1070742b901ea9eaeb968808da9d086b Mon Sep 17 00:00:00 2001 From: ThePickleMan Date: Tue, 4 Sep 2012 20:54:17 -0500 Subject: [PATCH 12/19] Update extensions/GUI/CCControlExtension/CCControlSlider.h Removed meaningless setter...the macro already makes one... --- extensions/GUI/CCControlExtension/CCControlSlider.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.h b/extensions/GUI/CCControlExtension/CCControlSlider.h index e8fe9de314..407c2b41ec 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.h +++ b/extensions/GUI/CCControlExtension/CCControlSlider.h @@ -55,10 +55,9 @@ class CCControlSlider: public CCControl virtual void setMinimumValue(float val); CC_SYNTHESIZE_READONLY(float, m_maximumValue, MaximumValue); virtual void setMaximumValue(float val); + CC_SYNTHESIZE(float, m_minimumAllowedValue, MinimumAllowedValue); - virtual void setMinimumAllowedValue(float val); CC_SYNTHESIZE(float, m_maximumAllowedValue, MaximumAllowedValue); - virtual void setMaximumAllowedValue(float val); //interval to snap to From 0a96915da2ad3b66b09f1ee2b0a65dd91f4f15c7 Mon Sep 17 00:00:00 2001 From: ThePickleMan Date: Tue, 4 Sep 2012 20:54:34 -0500 Subject: [PATCH 13/19] Update extensions/GUI/CCControlExtension/CCControlSlider.cpp Removed meaningless setter...the macro already makes one... --- extensions/GUI/CCControlExtension/CCControlSlider.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.cpp b/extensions/GUI/CCControlExtension/CCControlSlider.cpp index 061527f710..18a7bc28c4 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSlider.cpp @@ -163,16 +163,6 @@ CCControlSlider* CCControlSlider::create(CCSprite * backgroundSprite, CCSprite* m_minimumValue = m_maximumValue - 1.0f; setValue(m_value); } - - void CCControlSlider::setMinimumAllowedValue(float minimumAllowedValue) - { - m_minimumAllowedValue = minimumAllowedValue; - } - - void CCControlSlider::setMaximumAllowedValue(float maximumAllowedValue) - { - m_maximumAllowedValue = maximumAllowedValue; - } //this is the same as CCControl::getTouchLocation, but it returns the position relative to the position of this control CCPoint CCControlSlider::getTouchLocationInControl(CCTouch* touch) From 5cf699f6689dfad4bb30f72f10762fcd9f749083 Mon Sep 17 00:00:00 2001 From: ThePickleMan Date: Tue, 4 Sep 2012 22:32:29 -0500 Subject: [PATCH 14/19] Update samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp Added a test for the restricted slider --- .../CCControlSliderTest.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp b/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp index 6dd4ff2bef..f1fd8ce83f 100644 --- a/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp +++ b/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp @@ -43,10 +43,10 @@ bool CCControlSliderTest::init() CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); // Add a label in which the slider value will be displayed - m_pDisplayValueLabel = CCLabelTTF::create("Move the slider thumb!" ,"Marker Felt", 32); + m_pDisplayValueLabel = CCLabelTTF::create("Move the slider thumb!\nThe lower slider is restricted." ,"Marker Felt", 32); m_pDisplayValueLabel->retain(); m_pDisplayValueLabel->setAnchorPoint(ccp(0.5f, -1.0f)); - m_pDisplayValueLabel->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f)); + m_pDisplayValueLabel->setPosition(ccp(screenSize.width / 1.7f, screenSize.height / 2.0f)); addChild(m_pDisplayValueLabel); // Add the slider @@ -54,12 +54,22 @@ bool CCControlSliderTest::init() slider->setAnchorPoint(ccp(0.5f, 1.0f)); slider->setMinimumValue(0.0f); // Sets the min value of range slider->setMaximumValue(5.0f); // Sets the max value of range - slider->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f)); + slider->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f + 16)); // When the value of the slider will change, the given selector will be call slider->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlSliderTest::valueChanged), CCControlEventValueChanged); + CCControlSlider *restrictSlider = CCControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png"); + restrictSlider->setAnchorPoint(ccp(0.5f, 1.0f)); + restrictSlider->setMinimumValue(0.0f); // Sets the min value of range + restrictSlider->setMaximumValue(5.0f); // Sets the max value of range + restrictSlider->setMaximumAllowedValue(4.0f); + restrictSlider->setMinimumAllowedValue(1.5f); + restrictSlider->setValue(3.0f); + restrictSlider->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f - 24)); + addChild(slider); + addChild(restrictSlider); return true; } return false; @@ -69,6 +79,6 @@ void CCControlSliderTest::valueChanged(CCObject *sender, CCControlEvent controlE { CCControlSlider* pSlider = (CCControlSlider*)sender; // Change value of label. - m_pDisplayValueLabel->setString(CCString::createWithFormat("Slider value = %.02f", pSlider->getValue())->getCString()); + m_pDisplayValueLabel->setString(CCString::createWithFormat("Upper slider value = %.02f", pSlider->getValue())->getCString()); } From ea87d6304d333374438960bd2adaef4da500bdad Mon Sep 17 00:00:00 2001 From: ThePickleMan Date: Tue, 4 Sep 2012 23:52:18 -0500 Subject: [PATCH 15/19] Update samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp Made the lower slider's value display too. --- .../CCControlSliderTest/CCControlSliderTest.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp b/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp index f1fd8ce83f..1832a45694 100644 --- a/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp +++ b/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp @@ -55,11 +55,12 @@ bool CCControlSliderTest::init() slider->setMinimumValue(0.0f); // Sets the min value of range slider->setMaximumValue(5.0f); // Sets the max value of range slider->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f + 16)); + slider->setTag(1); // When the value of the slider will change, the given selector will be call slider->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlSliderTest::valueChanged), CCControlEventValueChanged); - CCControlSlider *restrictSlider = CCControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png"); + CCControlSlider *restrictSlider = CCControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png"); restrictSlider->setAnchorPoint(ccp(0.5f, 1.0f)); restrictSlider->setMinimumValue(0.0f); // Sets the min value of range restrictSlider->setMaximumValue(5.0f); // Sets the max value of range @@ -67,6 +68,7 @@ bool CCControlSliderTest::init() restrictSlider->setMinimumAllowedValue(1.5f); restrictSlider->setValue(3.0f); restrictSlider->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f - 24)); + restrictSlider->setTag(2); addChild(slider); addChild(restrictSlider); @@ -79,6 +81,9 @@ void CCControlSliderTest::valueChanged(CCObject *sender, CCControlEvent controlE { CCControlSlider* pSlider = (CCControlSlider*)sender; // Change value of label. - m_pDisplayValueLabel->setString(CCString::createWithFormat("Upper slider value = %.02f", pSlider->getValue())->getCString()); + if(pSlider->getTag() == 1) + m_pDisplayValueLabel->setString(CCString::createWithFormat("Upper slider value = %.02f", pSlider->getValue())->getCString()); + if(pSlider->getTag() == 2) + m_pDisplayValueLabel->setString(CCString::createWithFormat("Lower slider value = %.02f", pSlider->getValue())->getCString()); } From 469584e8b8d111eaabb3db4f5e88570466a2970e Mon Sep 17 00:00:00 2001 From: ThePickleMan Date: Tue, 4 Sep 2012 23:53:17 -0500 Subject: [PATCH 16/19] Update samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp --- .../CCControlSliderTest/CCControlSliderTest.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp b/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp index 1832a45694..411b16ef38 100644 --- a/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp +++ b/samples/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp @@ -70,6 +70,9 @@ bool CCControlSliderTest::init() restrictSlider->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f - 24)); restrictSlider->setTag(2); + //same with restricted + restrictSlider->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlSliderTest::valueChanged), CCControlEventValueChanged); + addChild(slider); addChild(restrictSlider); return true; From 1b51b709ee0d82848b2b85588efc06dae106ae14 Mon Sep 17 00:00:00 2001 From: moadib Date: Wed, 5 Sep 2012 11:36:34 +0400 Subject: [PATCH 17/19] Fixed crash with CCLabelBMFont when center- or right-aligned text have line breaks each other --- cocos2dx/label_nodes/CCLabelBMFont.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 931a2682d3..07d1de5661 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -1260,6 +1260,11 @@ void CCLabelBMFont::updateLabel() { float lineWidth = 0.0f; unsigned int line_length = last_line.size(); + if (line_length == 0) + { + lineNumber++; + continue; + } int index = i + line_length - 1 + lineNumber; if (index < 0) continue; From cf67922ee09823abf2610e4924c09602b5b613e8 Mon Sep 17 00:00:00 2001 From: ivzave Date: Wed, 5 Sep 2012 22:30:44 +0400 Subject: [PATCH 18/19] remove delete this from init methods --- cocos2dx/base_nodes/CCAtlasNode.cpp | 1 - cocos2dx/effects/CCGrid.cpp | 1 - cocos2dx/textures/CCTextureAtlas.cpp | 4 +--- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/cocos2dx/base_nodes/CCAtlasNode.cpp b/cocos2dx/base_nodes/CCAtlasNode.cpp index 46d42e3f51..4c814419a6 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.cpp +++ b/cocos2dx/base_nodes/CCAtlasNode.cpp @@ -101,7 +101,6 @@ bool CCAtlasNode::initWithTileFile(const char *tile, unsigned int tileWidth, uns if (! m_pTextureAtlas) { CCLOG("cocos2d: Could not initialize CCAtlasNode. Invalid Texture."); - delete this; return false; } diff --git a/cocos2dx/effects/CCGrid.cpp b/cocos2dx/effects/CCGrid.cpp index 4086810404..7b21ab4a1e 100644 --- a/cocos2dx/effects/CCGrid.cpp +++ b/cocos2dx/effects/CCGrid.cpp @@ -146,7 +146,6 @@ bool CCGridBase::initWithSize(const ccGridSize& gridSize) if (! pTexture) { CCLOG("cocos2d: CCGrid: error creating texture"); - delete this; return false; } diff --git a/cocos2dx/textures/CCTextureAtlas.cpp b/cocos2dx/textures/CCTextureAtlas.cpp index c738b8dc15..9dd22e3c56 100644 --- a/cocos2dx/textures/CCTextureAtlas.cpp +++ b/cocos2dx/textures/CCTextureAtlas.cpp @@ -148,9 +148,7 @@ bool CCTextureAtlas::initWithFile(const char * file, unsigned int capacity) else { CCLOG("cocos2d: Could not open file: %s", file); - delete this; - - return NULL; + return false; } } From a574d17bed3b995ff5c3acf44df0f686c2ffa68f Mon Sep 17 00:00:00 2001 From: moadib Date: Thu, 6 Sep 2012 10:09:29 +0400 Subject: [PATCH 19/19] Added comment as minggo requested --- cocos2dx/label_nodes/CCLabelBMFont.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 07d1de5661..737e801e42 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -1260,6 +1260,7 @@ void CCLabelBMFont::updateLabel() { float lineWidth = 0.0f; unsigned int line_length = last_line.size(); + // if last line is empty we must just increase lineNumber and work with next line if (line_length == 0) { lineNumber++;