mirror of https://github.com/axmolengine/axmol.git
resolve conflict and fix checktexture bug
This commit is contained in:
commit
ebd5c1cca7
32
CHANGELOG
32
CHANGELOG
|
@ -1,4 +1,30 @@
|
||||||
cocos2d-x-3.9 beta0 October.20 2015
|
cocos2d-x-3.10 December ? 2015
|
||||||
|
[NEW] Core: Added Application::getVersion() to get the app version.
|
||||||
|
[NEW] UI: Add PageView indicator.
|
||||||
|
[NEW] Label: Add three Overflow type to new label, see release note for more information.
|
||||||
|
|
||||||
|
[REFINE] UI: RichText support new line element.
|
||||||
|
[REFINE] UI: Set focus to Widget when touched.
|
||||||
|
[REFINE] UI: Change PageView to derived from ListView.
|
||||||
|
[REFINE] UI: Rewrite Scale9Sprite and improve the scale9sprite performance and reduce memory consumption.
|
||||||
|
[REFINE] 3D: Change char* to string in Terrain.
|
||||||
|
[REFINE] Editor: Merge Studio ActionTimeLine change back into engine.
|
||||||
|
[REFINE] Mac: Make engine compatible for 32bit Mac.
|
||||||
|
[REFINE] Audio: AudioEngine on Linux replace the original SimpleAudioEngine with a new version of FMOD, now AudioEngine support all platforms!
|
||||||
|
|
||||||
|
[FIX] Core: Fix premultiplyAlpha for mipmaps and compressed textures.
|
||||||
|
[FIX] UI: Fix Scale9sprite rendering error when content size smaller than the sum of leftInset and rightInset.
|
||||||
|
[FIX] Win32: Fix EditBox crash when removing an EditBox in a scheduler.
|
||||||
|
[FIX] Android: Fix cannot add view to mFrameLayout when extends Cocos2dxActivity.
|
||||||
|
[FIX] 2D: Fixed actionNode position error bug.
|
||||||
|
[FIX] 3D: Fix the movement of PUParticle lags one frame.
|
||||||
|
[FIX] UI: Fix the wront argument of setPlaceholderFontName in EditBox.
|
||||||
|
[FIX] UI: Fix EditBox editBoxEditingDidEnd may use the original text after change the text of EditBox in user script.
|
||||||
|
[FIX] Audio: Fix `FinishCallback` never be called in Windows.
|
||||||
|
[FIX] UI: Fix Layout stencil clipping nested with Clipping Node rendering issue.
|
||||||
|
[FIX] UI: Keyboard doesn't hide when click the screen outside of EditBox on iOS platform.
|
||||||
|
|
||||||
|
cocos2d-x-3.9 November.09 2015
|
||||||
|
|
||||||
[NEW] Label: Added line spacing/leading feature to Label.
|
[NEW] Label: Added line spacing/leading feature to Label.
|
||||||
[NEW] ListView: Added APIs to scroll to specific item in list.
|
[NEW] ListView: Added APIs to scroll to specific item in list.
|
||||||
|
@ -124,6 +150,10 @@ cocos2d-x-3.9 beta0 October.20 2015
|
||||||
[TEST] JS: Fixed crash bug when click "remove ui" in "native test-JSBExtendTest" under project js-test.
|
[TEST] JS: Fixed crash bug when click "remove ui" in "native test-JSBExtendTest" under project js-test.
|
||||||
[TEST] JS: Updated testcase in js-test to show notificationNode to runAction.
|
[TEST] JS: Updated testcase in js-test to show notificationNode to runAction.
|
||||||
|
|
||||||
|
cocos2d-x-3.8.1 September.17 2015
|
||||||
|
|
||||||
|
[HIGHLIGHT] platform: Supported Xcode 7 for iOS 9 deployment
|
||||||
|
|
||||||
cocos2d-x-3.8 final September.6 2015
|
cocos2d-x-3.8 final September.6 2015
|
||||||
cocos2d-x-3.8 rc0 August.26 2015
|
cocos2d-x-3.8 rc0 August.26 2015
|
||||||
cocos2d-x-3.8 beta0 August.14 2015
|
cocos2d-x-3.8 beta0 August.14 2015
|
||||||
|
|
|
@ -200,7 +200,7 @@ if(LINUX OR MACOSX OR WINDOWS)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
set(THREADS_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
|
set(THREADS_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
|
||||||
cocos_find_package(FMODEX FMODEX REQUIRED)
|
cocos_find_package(FMOD FMOD REQUIRED)
|
||||||
cocos_find_package(Fontconfig FONTCONFIG REQUIRED)
|
cocos_find_package(Fontconfig FONTCONFIG REQUIRED)
|
||||||
cocos_find_package(GTK3 GTK3 REQUIRED)
|
cocos_find_package(GTK3 GTK3 REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -182,7 +182,7 @@ Build Requirements
|
||||||
|
|
||||||
Runtime Requirements
|
Runtime Requirements
|
||||||
--------------------
|
--------------------
|
||||||
* iOS 5.0+ for iPhone / iPad games
|
* iOS 6.0+ for iPhone / iPad games
|
||||||
* Android 2.3+ for Android games
|
* Android 2.3+ for Android games
|
||||||
* Windows 8.1 or Windows 10.0 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
|
* Windows 10.0 for Windows Phone/Store 10.0 games
|
||||||
|
|
|
@ -1234,6 +1234,11 @@
|
||||||
2980F02B1BA9A5550059E678 /* UITextView+CCUITextInput.h in Headers */ = {isa = PBXBuildFile; fileRef = 2980F0201BA9A5550059E678 /* UITextView+CCUITextInput.h */; };
|
2980F02B1BA9A5550059E678 /* UITextView+CCUITextInput.h in Headers */ = {isa = PBXBuildFile; fileRef = 2980F0201BA9A5550059E678 /* UITextView+CCUITextInput.h */; };
|
||||||
2980F02C1BA9A5550059E678 /* UITextView+CCUITextInput.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2980F0211BA9A5550059E678 /* UITextView+CCUITextInput.mm */; };
|
2980F02C1BA9A5550059E678 /* UITextView+CCUITextInput.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2980F0211BA9A5550059E678 /* UITextView+CCUITextInput.mm */; };
|
||||||
2986667F18B1B246000E39CA /* CCTweenFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2986667818B1B079000E39CA /* CCTweenFunction.cpp */; };
|
2986667F18B1B246000E39CA /* CCTweenFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2986667818B1B079000E39CA /* CCTweenFunction.cpp */; };
|
||||||
|
298C75D51C0465D0006BAE63 /* CCStencilStateManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 298C75D31C0465D0006BAE63 /* CCStencilStateManager.cpp */; };
|
||||||
|
298C75D61C0465D1006BAE63 /* CCStencilStateManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 298C75D31C0465D0006BAE63 /* CCStencilStateManager.cpp */; };
|
||||||
|
298C75D71C0465D1006BAE63 /* CCStencilStateManager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 298C75D41C0465D0006BAE63 /* CCStencilStateManager.hpp */; };
|
||||||
|
298C75D81C0465D1006BAE63 /* CCStencilStateManager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 298C75D41C0465D0006BAE63 /* CCStencilStateManager.hpp */; };
|
||||||
|
298C75D91C04681F006BAE63 /* CCStencilStateManager.hpp in Sources */ = {isa = PBXBuildFile; fileRef = 298C75D41C0465D0006BAE63 /* CCStencilStateManager.hpp */; };
|
||||||
299754F4193EC95400A54AC3 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */; };
|
299754F4193EC95400A54AC3 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */; };
|
||||||
299754F5193EC95400A54AC3 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */; };
|
299754F5193EC95400A54AC3 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */; };
|
||||||
299754F6193EC95400A54AC3 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 299754F3193EC95400A54AC3 /* ObjectFactory.h */; };
|
299754F6193EC95400A54AC3 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 299754F3193EC95400A54AC3 /* ObjectFactory.h */; };
|
||||||
|
@ -2072,6 +2077,10 @@
|
||||||
B5668D7E1B3838E4003CBD5E /* UIScrollViewBar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5668D7B1B3838E4003CBD5E /* UIScrollViewBar.cpp */; };
|
B5668D7E1B3838E4003CBD5E /* UIScrollViewBar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5668D7B1B3838E4003CBD5E /* UIScrollViewBar.cpp */; };
|
||||||
B5668D7F1B3838E4003CBD5E /* UIScrollViewBar.h in Headers */ = {isa = PBXBuildFile; fileRef = B5668D7C1B3838E4003CBD5E /* UIScrollViewBar.h */; };
|
B5668D7F1B3838E4003CBD5E /* UIScrollViewBar.h in Headers */ = {isa = PBXBuildFile; fileRef = B5668D7C1B3838E4003CBD5E /* UIScrollViewBar.h */; };
|
||||||
B5668D801B3838E4003CBD5E /* UIScrollViewBar.h in Headers */ = {isa = PBXBuildFile; fileRef = B5668D7C1B3838E4003CBD5E /* UIScrollViewBar.h */; };
|
B5668D801B3838E4003CBD5E /* UIScrollViewBar.h in Headers */ = {isa = PBXBuildFile; fileRef = B5668D7C1B3838E4003CBD5E /* UIScrollViewBar.h */; };
|
||||||
|
B5A738961BB0051F00BAAEF8 /* UIPageViewIndicator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5A738941BB0051F00BAAEF8 /* UIPageViewIndicator.cpp */; };
|
||||||
|
B5A738971BB0051F00BAAEF8 /* UIPageViewIndicator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5A738941BB0051F00BAAEF8 /* UIPageViewIndicator.cpp */; };
|
||||||
|
B5A738981BB0051F00BAAEF8 /* UIPageViewIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = B5A738951BB0051F00BAAEF8 /* UIPageViewIndicator.h */; };
|
||||||
|
B5A738991BB0051F00BAAEF8 /* UIPageViewIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = B5A738951BB0051F00BAAEF8 /* UIPageViewIndicator.h */; };
|
||||||
B5CE6DBE1B3BF2B1002B0419 /* UIAbstractCheckButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5CE6DBC1B3BF2B1002B0419 /* UIAbstractCheckButton.cpp */; };
|
B5CE6DBE1B3BF2B1002B0419 /* UIAbstractCheckButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5CE6DBC1B3BF2B1002B0419 /* UIAbstractCheckButton.cpp */; };
|
||||||
B5CE6DBF1B3BF2B1002B0419 /* UIAbstractCheckButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5CE6DBC1B3BF2B1002B0419 /* UIAbstractCheckButton.cpp */; };
|
B5CE6DBF1B3BF2B1002B0419 /* UIAbstractCheckButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5CE6DBC1B3BF2B1002B0419 /* UIAbstractCheckButton.cpp */; };
|
||||||
B5CE6DC01B3BF2B1002B0419 /* UIAbstractCheckButton.h in Headers */ = {isa = PBXBuildFile; fileRef = B5CE6DBD1B3BF2B1002B0419 /* UIAbstractCheckButton.h */; };
|
B5CE6DC01B3BF2B1002B0419 /* UIAbstractCheckButton.h in Headers */ = {isa = PBXBuildFile; fileRef = B5CE6DBD1B3BF2B1002B0419 /* UIAbstractCheckButton.h */; };
|
||||||
|
@ -4140,6 +4149,8 @@
|
||||||
2980F0211BA9A5550059E678 /* UITextView+CCUITextInput.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "UITextView+CCUITextInput.mm"; sourceTree = "<group>"; };
|
2980F0211BA9A5550059E678 /* UITextView+CCUITextInput.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "UITextView+CCUITextInput.mm"; sourceTree = "<group>"; };
|
||||||
2986667818B1B079000E39CA /* CCTweenFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTweenFunction.cpp; sourceTree = "<group>"; };
|
2986667818B1B079000E39CA /* CCTweenFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTweenFunction.cpp; sourceTree = "<group>"; };
|
||||||
2986667918B1B079000E39CA /* CCTweenFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTweenFunction.h; sourceTree = "<group>"; };
|
2986667918B1B079000E39CA /* CCTweenFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTweenFunction.h; sourceTree = "<group>"; };
|
||||||
|
298C75D31C0465D0006BAE63 /* CCStencilStateManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCStencilStateManager.cpp; path = ../base/CCStencilStateManager.cpp; sourceTree = "<group>"; };
|
||||||
|
298C75D41C0465D0006BAE63 /* CCStencilStateManager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CCStencilStateManager.hpp; path = ../base/CCStencilStateManager.hpp; sourceTree = "<group>"; };
|
||||||
299754F2193EC95400A54AC3 /* ObjectFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ObjectFactory.cpp; path = ../base/ObjectFactory.cpp; sourceTree = "<group>"; };
|
299754F2193EC95400A54AC3 /* ObjectFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ObjectFactory.cpp; path = ../base/ObjectFactory.cpp; sourceTree = "<group>"; };
|
||||||
299754F3193EC95400A54AC3 /* ObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjectFactory.h; path = ../base/ObjectFactory.h; sourceTree = "<group>"; };
|
299754F3193EC95400A54AC3 /* ObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjectFactory.h; path = ../base/ObjectFactory.h; sourceTree = "<group>"; };
|
||||||
299CF1F919A434BC00C378C1 /* ccRandom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ccRandom.cpp; path = ../base/ccRandom.cpp; sourceTree = "<group>"; };
|
299CF1F919A434BC00C378C1 /* ccRandom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ccRandom.cpp; path = ../base/ccRandom.cpp; sourceTree = "<group>"; };
|
||||||
|
@ -4805,6 +4816,8 @@
|
||||||
B3AF019F1842FBA400A98B85 /* b2MotorJoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = b2MotorJoint.h; sourceTree = "<group>"; };
|
B3AF019F1842FBA400A98B85 /* b2MotorJoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = b2MotorJoint.h; sourceTree = "<group>"; };
|
||||||
B5668D7B1B3838E4003CBD5E /* UIScrollViewBar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIScrollViewBar.cpp; sourceTree = "<group>"; };
|
B5668D7B1B3838E4003CBD5E /* UIScrollViewBar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIScrollViewBar.cpp; sourceTree = "<group>"; };
|
||||||
B5668D7C1B3838E4003CBD5E /* UIScrollViewBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIScrollViewBar.h; sourceTree = "<group>"; };
|
B5668D7C1B3838E4003CBD5E /* UIScrollViewBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIScrollViewBar.h; sourceTree = "<group>"; };
|
||||||
|
B5A738941BB0051F00BAAEF8 /* UIPageViewIndicator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIPageViewIndicator.cpp; sourceTree = "<group>"; };
|
||||||
|
B5A738951BB0051F00BAAEF8 /* UIPageViewIndicator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIPageViewIndicator.h; sourceTree = "<group>"; };
|
||||||
B5CE6DBC1B3BF2B1002B0419 /* UIAbstractCheckButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIAbstractCheckButton.cpp; sourceTree = "<group>"; };
|
B5CE6DBC1B3BF2B1002B0419 /* UIAbstractCheckButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIAbstractCheckButton.cpp; sourceTree = "<group>"; };
|
||||||
B5CE6DBD1B3BF2B1002B0419 /* UIAbstractCheckButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIAbstractCheckButton.h; sourceTree = "<group>"; };
|
B5CE6DBD1B3BF2B1002B0419 /* UIAbstractCheckButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIAbstractCheckButton.h; sourceTree = "<group>"; };
|
||||||
B5CE6DC61B3C05BA002B0419 /* UIRadioButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIRadioButton.cpp; sourceTree = "<group>"; };
|
B5CE6DC61B3C05BA002B0419 /* UIRadioButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIRadioButton.cpp; sourceTree = "<group>"; };
|
||||||
|
@ -6031,6 +6044,8 @@
|
||||||
50ABBE1C1925AB6F00A911A9 /* utlist.h */,
|
50ABBE1C1925AB6F00A911A9 /* utlist.h */,
|
||||||
50ABBE1D1925AB6F00A911A9 /* ZipUtils.cpp */,
|
50ABBE1D1925AB6F00A911A9 /* ZipUtils.cpp */,
|
||||||
50ABBE1E1925AB6F00A911A9 /* ZipUtils.h */,
|
50ABBE1E1925AB6F00A911A9 /* ZipUtils.h */,
|
||||||
|
298C75D31C0465D0006BAE63 /* CCStencilStateManager.cpp */,
|
||||||
|
298C75D41C0465D0006BAE63 /* CCStencilStateManager.hpp */,
|
||||||
);
|
);
|
||||||
name = base;
|
name = base;
|
||||||
path = ../cocos/2d;
|
path = ../cocos/2d;
|
||||||
|
@ -6971,6 +6986,8 @@
|
||||||
2905FA0118CF08D000240AA3 /* UILoadingBar.h */,
|
2905FA0118CF08D000240AA3 /* UILoadingBar.h */,
|
||||||
2905FA0218CF08D000240AA3 /* UIPageView.cpp */,
|
2905FA0218CF08D000240AA3 /* UIPageView.cpp */,
|
||||||
2905FA0318CF08D000240AA3 /* UIPageView.h */,
|
2905FA0318CF08D000240AA3 /* UIPageView.h */,
|
||||||
|
B5A738941BB0051F00BAAEF8 /* UIPageViewIndicator.cpp */,
|
||||||
|
B5A738951BB0051F00BAAEF8 /* UIPageViewIndicator.h */,
|
||||||
2905FA0418CF08D000240AA3 /* UIRichText.cpp */,
|
2905FA0418CF08D000240AA3 /* UIRichText.cpp */,
|
||||||
2905FA0518CF08D000240AA3 /* UIRichText.h */,
|
2905FA0518CF08D000240AA3 /* UIRichText.h */,
|
||||||
2905FA0718CF08D000240AA3 /* UIScrollView.cpp */,
|
2905FA0718CF08D000240AA3 /* UIScrollView.cpp */,
|
||||||
|
@ -9221,6 +9238,7 @@
|
||||||
15AE182A19AAD2F700C27E9E /* CCMeshSkin.h in Headers */,
|
15AE182A19AAD2F700C27E9E /* CCMeshSkin.h in Headers */,
|
||||||
B276EF5F1988D1D500CD400F /* CCVertexIndexData.h in Headers */,
|
B276EF5F1988D1D500CD400F /* CCVertexIndexData.h in Headers */,
|
||||||
1A57007F180BC5A10088DEC7 /* CCActionInterval.h in Headers */,
|
1A57007F180BC5A10088DEC7 /* CCActionInterval.h in Headers */,
|
||||||
|
298C75D71C0465D1006BAE63 /* CCStencilStateManager.hpp in Headers */,
|
||||||
B6DD2FDB1B04825B00E47F5F /* DetourLocalBoundary.h in Headers */,
|
B6DD2FDB1B04825B00E47F5F /* DetourLocalBoundary.h in Headers */,
|
||||||
B6CAB3491AF9AA1A00B9B856 /* gim_clip_polygon.h in Headers */,
|
B6CAB3491AF9AA1A00B9B856 /* gim_clip_polygon.h in Headers */,
|
||||||
B677B0DB1B18492D006762CB /* CCNavMeshUtils.h in Headers */,
|
B677B0DB1B18492D006762CB /* CCNavMeshUtils.h in Headers */,
|
||||||
|
@ -9481,6 +9499,7 @@
|
||||||
B665E3F41AA80A6600DDB1C5 /* CCPUSlaveEmitter.h in Headers */,
|
B665E3F41AA80A6600DDB1C5 /* CCPUSlaveEmitter.h in Headers */,
|
||||||
15AE1B6919AADA9900C27E9E /* UIDeprecated.h in Headers */,
|
15AE1B6919AADA9900C27E9E /* UIDeprecated.h in Headers */,
|
||||||
1A570223180BCC1A0088DEC7 /* CCParticleBatchNode.h in Headers */,
|
1A570223180BCC1A0088DEC7 /* CCParticleBatchNode.h in Headers */,
|
||||||
|
B5A738981BB0051F00BAAEF8 /* UIPageViewIndicator.h in Headers */,
|
||||||
B6CAB53F1AF9AA1A00B9B856 /* cl_platform.h in Headers */,
|
B6CAB53F1AF9AA1A00B9B856 /* cl_platform.h in Headers */,
|
||||||
15AE1A8319AAD40300C27E9E /* b2GearJoint.h in Headers */,
|
15AE1A8319AAD40300C27E9E /* b2GearJoint.h in Headers */,
|
||||||
15AE1BD519AAE01E00C27E9E /* CCControlSaturationBrightnessPicker.h in Headers */,
|
15AE1BD519AAE01E00C27E9E /* CCControlSaturationBrightnessPicker.h in Headers */,
|
||||||
|
@ -10660,6 +10679,7 @@
|
||||||
85505F051B60E3B2003F2CD4 /* CCBoneNode.h in Headers */,
|
85505F051B60E3B2003F2CD4 /* CCBoneNode.h in Headers */,
|
||||||
B665E2491AA80A6500DDB1C5 /* CCPUCollisionAvoidanceAffectorTranslator.h in Headers */,
|
B665E2491AA80A6500DDB1C5 /* CCPUCollisionAvoidanceAffectorTranslator.h in Headers */,
|
||||||
B6CAB4461AF9AA1A00B9B856 /* btParallelConstraintSolver.h in Headers */,
|
B6CAB4461AF9AA1A00B9B856 /* btParallelConstraintSolver.h in Headers */,
|
||||||
|
298C75D81C0465D1006BAE63 /* CCStencilStateManager.hpp in Headers */,
|
||||||
15AE18D119AAD33D00C27E9E /* CCNodeLoaderLibrary.h in Headers */,
|
15AE18D119AAD33D00C27E9E /* CCNodeLoaderLibrary.h in Headers */,
|
||||||
15AE1AC319AAD40300C27E9E /* b2DistanceJoint.h in Headers */,
|
15AE1AC319AAD40300C27E9E /* b2DistanceJoint.h in Headers */,
|
||||||
B6CAB5261AF9AA1A00B9B856 /* btQuickprof.h in Headers */,
|
B6CAB5261AF9AA1A00B9B856 /* btQuickprof.h in Headers */,
|
||||||
|
@ -10984,6 +11004,7 @@
|
||||||
B665E2951AA80A6500DDB1C5 /* CCPUEmitter.h in Headers */,
|
B665E2951AA80A6500DDB1C5 /* CCPUEmitter.h in Headers */,
|
||||||
B6CAB3BE1AF9AA1A00B9B856 /* btGeneric6DofSpringConstraint.h in Headers */,
|
B6CAB3BE1AF9AA1A00B9B856 /* btGeneric6DofSpringConstraint.h in Headers */,
|
||||||
B6CAB3521AF9AA1A00B9B856 /* gim_geometry.h in Headers */,
|
B6CAB3521AF9AA1A00B9B856 /* gim_geometry.h in Headers */,
|
||||||
|
B5A738991BB0051F00BAAEF8 /* UIPageViewIndicator.h in Headers */,
|
||||||
15AE1BED19AAE01E00C27E9E /* CCControlColourPicker.h in Headers */,
|
15AE1BED19AAE01E00C27E9E /* CCControlColourPicker.h in Headers */,
|
||||||
15AE195019AAD35100C27E9E /* CCDatas.h in Headers */,
|
15AE195019AAD35100C27E9E /* CCDatas.h in Headers */,
|
||||||
15AE18B319AAD33D00C27E9E /* CCBReader.h in Headers */,
|
15AE18B319AAD33D00C27E9E /* CCBReader.h in Headers */,
|
||||||
|
@ -11169,6 +11190,7 @@
|
||||||
ED9C6A9418599AD8000A5232 /* CCNodeGrid.cpp in Sources */,
|
ED9C6A9418599AD8000A5232 /* CCNodeGrid.cpp in Sources */,
|
||||||
15AE1A2C19AAD3D500C27E9E /* b2DynamicTree.cpp in Sources */,
|
15AE1A2C19AAD3D500C27E9E /* b2DynamicTree.cpp in Sources */,
|
||||||
B665E36A1AA80A6500DDB1C5 /* CCPUOnVelocityObserver.cpp in Sources */,
|
B665E36A1AA80A6500DDB1C5 /* CCPUOnVelocityObserver.cpp in Sources */,
|
||||||
|
B5A738961BB0051F00BAAEF8 /* UIPageViewIndicator.cpp in Sources */,
|
||||||
B665E3961AA80A6500DDB1C5 /* CCPUPointEmitter.cpp in Sources */,
|
B665E3961AA80A6500DDB1C5 /* CCPUPointEmitter.cpp in Sources */,
|
||||||
15AE184019AAD2F700C27E9E /* CCSprite3D.cpp in Sources */,
|
15AE184019AAD2F700C27E9E /* CCSprite3D.cpp in Sources */,
|
||||||
B6CAB2E51AF9AA1A00B9B856 /* btSphereShape.cpp in Sources */,
|
B6CAB2E51AF9AA1A00B9B856 /* btSphereShape.cpp in Sources */,
|
||||||
|
@ -11819,6 +11841,7 @@
|
||||||
B665E2EE1AA80A6500DDB1C5 /* CCPULineEmitter.cpp in Sources */,
|
B665E2EE1AA80A6500DDB1C5 /* CCPULineEmitter.cpp in Sources */,
|
||||||
B6CAB2DD1AF9AA1A00B9B856 /* btScaledBvhTriangleMeshShape.cpp in Sources */,
|
B6CAB2DD1AF9AA1A00B9B856 /* btScaledBvhTriangleMeshShape.cpp in Sources */,
|
||||||
B665E4121AA80A6600DDB1C5 /* CCPUTextureAnimator.cpp in Sources */,
|
B665E4121AA80A6600DDB1C5 /* CCPUTextureAnimator.cpp in Sources */,
|
||||||
|
298C75D51C0465D0006BAE63 /* CCStencilStateManager.cpp in Sources */,
|
||||||
B665E3D21AA80A6600DDB1C5 /* CCPUScriptLexer.cpp in Sources */,
|
B665E3D21AA80A6600DDB1C5 /* CCPUScriptLexer.cpp in Sources */,
|
||||||
B665E4021AA80A6600DDB1C5 /* CCPUSphereColliderTranslator.cpp in Sources */,
|
B665E4021AA80A6600DDB1C5 /* CCPUSphereColliderTranslator.cpp in Sources */,
|
||||||
15AE1A3619AAD3D500C27E9E /* b2PolygonShape.cpp in Sources */,
|
15AE1A3619AAD3D500C27E9E /* b2PolygonShape.cpp in Sources */,
|
||||||
|
@ -11953,6 +11976,7 @@
|
||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
298C75D91C04681F006BAE63 /* CCStencilStateManager.hpp in Sources */,
|
||||||
D0FD03541A3B51AA00825BB5 /* CCAllocatorGlobalNewDelete.cpp in Sources */,
|
D0FD03541A3B51AA00825BB5 /* CCAllocatorGlobalNewDelete.cpp in Sources */,
|
||||||
15AE1B9819AADAA100C27E9E /* UIVideoPlayer-ios.mm in Sources */,
|
15AE1B9819AADAA100C27E9E /* UIVideoPlayer-ios.mm in Sources */,
|
||||||
B665E38F1AA80A6500DDB1C5 /* CCPUPlaneCollider.cpp in Sources */,
|
B665E38F1AA80A6500DDB1C5 /* CCPUPlaneCollider.cpp in Sources */,
|
||||||
|
@ -12103,6 +12127,7 @@
|
||||||
15AE193C19AAD35100C27E9E /* CCArmatureDefine.cpp in Sources */,
|
15AE193C19AAD35100C27E9E /* CCArmatureDefine.cpp in Sources */,
|
||||||
B665E35F1AA80A6500DDB1C5 /* CCPUOnRandomObserverTranslator.cpp in Sources */,
|
B665E35F1AA80A6500DDB1C5 /* CCPUOnRandomObserverTranslator.cpp in Sources */,
|
||||||
B29594B51926D5EC003EEF37 /* CCMeshCommand.cpp in Sources */,
|
B29594B51926D5EC003EEF37 /* CCMeshCommand.cpp in Sources */,
|
||||||
|
298C75D61C0465D1006BAE63 /* CCStencilStateManager.cpp in Sources */,
|
||||||
15AE194B19AAD35100C27E9E /* CCComRender.cpp in Sources */,
|
15AE194B19AAD35100C27E9E /* CCComRender.cpp in Sources */,
|
||||||
382384451A25915C002C4610 /* SpriteReader.cpp in Sources */,
|
382384451A25915C002C4610 /* SpriteReader.cpp in Sources */,
|
||||||
B6CAB2321AF9AA1A00B9B856 /* btCollisionWorld.cpp in Sources */,
|
B6CAB2321AF9AA1A00B9B856 /* btCollisionWorld.cpp in Sources */,
|
||||||
|
@ -12644,6 +12669,7 @@
|
||||||
B665E1FB1AA80A6500DDB1C5 /* CCPUAffectorTranslator.cpp in Sources */,
|
B665E1FB1AA80A6500DDB1C5 /* CCPUAffectorTranslator.cpp in Sources */,
|
||||||
B665E3931AA80A6500DDB1C5 /* CCPUPlaneColliderTranslator.cpp in Sources */,
|
B665E3931AA80A6500DDB1C5 /* CCPUPlaneColliderTranslator.cpp in Sources */,
|
||||||
382383F71A258FA7002C4610 /* idl_gen_fbs.cpp in Sources */,
|
382383F71A258FA7002C4610 /* idl_gen_fbs.cpp in Sources */,
|
||||||
|
B5A738971BB0051F00BAAEF8 /* UIPageViewIndicator.cpp in Sources */,
|
||||||
B665E24B1AA80A6500DDB1C5 /* CCPUColorAffector.cpp in Sources */,
|
B665E24B1AA80A6500DDB1C5 /* CCPUColorAffector.cpp in Sources */,
|
||||||
B665E20F1AA80A6500DDB1C5 /* CCPUBaseForceAffector.cpp in Sources */,
|
B665E20F1AA80A6500DDB1C5 /* CCPUBaseForceAffector.cpp in Sources */,
|
||||||
15AE1B7419AADA9A00C27E9E /* UILoadingBar.cpp in Sources */,
|
15AE1B7419AADA9A00C27E9E /* UILoadingBar.cpp in Sources */,
|
||||||
|
|
|
@ -60,9 +60,9 @@ set(_OpenalSoft_libs OpenAL32)
|
||||||
set(_zlib_inc zlib.h)
|
set(_zlib_inc zlib.h)
|
||||||
set(_zlib_libs z libzlib libz)
|
set(_zlib_libs z libzlib libz)
|
||||||
|
|
||||||
set(_fmod_prefix FMODEX)
|
set(_fmod_prefix FMOD)
|
||||||
set(_fmod_inc fmod.h)
|
set(_fmod_inc fmod.hpp)
|
||||||
set(_fmod_libs fmodex fmodex64 fmodexL fmodexL64)
|
set(_fmod_libs fmod fmod64 fmod fmod64)
|
||||||
|
|
||||||
set(all_prebuilt_libs
|
set(all_prebuilt_libs
|
||||||
chipmunk
|
chipmunk
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
#.rst:
|
||||||
|
# FindFMOD
|
||||||
|
# ------------
|
||||||
|
#
|
||||||
|
# Locate FMOD Ex library
|
||||||
|
#
|
||||||
|
# This module defines
|
||||||
|
#
|
||||||
|
# ::
|
||||||
|
#
|
||||||
|
# FMOD_LIBRARIES, the library to link against
|
||||||
|
# FMOD_FOUND, if false, do not try to link to fmodex
|
||||||
|
# FMOD_INCLUDE_DIRS, where to find headers.
|
||||||
|
#
|
||||||
|
|
||||||
|
find_path(FMOD_INCLUDE_DIR fmod.hpp
|
||||||
|
HINTS ENV FMOD_DIR
|
||||||
|
PATH_SUFFIXES include/fmod include
|
||||||
|
PATHS
|
||||||
|
~/Library/Frameworks
|
||||||
|
/Library/Frameworks
|
||||||
|
/usr/local
|
||||||
|
/usr
|
||||||
|
/sw # Fink
|
||||||
|
/opt/local # DarwinPorts
|
||||||
|
/opt/csw # Blastwave
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(FMOD_LIBRARY NAMES fmod fmod64
|
||||||
|
HINTS ENV FMOD_DIR
|
||||||
|
PATH_SUFFIXES lib
|
||||||
|
PATHS
|
||||||
|
~/Library/Frameworks
|
||||||
|
/Library/Frameworks
|
||||||
|
/usr/local
|
||||||
|
/usr
|
||||||
|
/sw # Fink
|
||||||
|
/opt/local # DarwinPorts
|
||||||
|
/opt/csw # Blastwave
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
|
||||||
|
set(FMOD_INCLUDE_DIRS "${FMOD_INCLUDE_DIR}")
|
||||||
|
set(FMOD_LIBRARIES "${FMOD_LIBRARY}")
|
||||||
|
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
||||||
|
find_package_handle_standard_args(FMOD DEFAULT_MSG FMOD_LIBRARIES FMOD_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
mark_as_advanced(FMOD_INCLUDE_DIR FMOD_LIBRARY FMOD_INCLUDE_DIRS FMOD_LIBRARIES)
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
#.rst:
|
|
||||||
# FindFMODEX
|
|
||||||
# ------------
|
|
||||||
#
|
|
||||||
# Locate FMOD Ex library
|
|
||||||
#
|
|
||||||
# This module defines
|
|
||||||
#
|
|
||||||
# ::
|
|
||||||
#
|
|
||||||
# FMODEX_LIBRARIES, the library to link against
|
|
||||||
# FMODEX_FOUND, if false, do not try to link to fmodex
|
|
||||||
# FMODEX_INCLUDE_DIRS, where to find headers.
|
|
||||||
#
|
|
||||||
|
|
||||||
find_path(FMODEX_INCLUDE_DIR fmod.h
|
|
||||||
HINTS ENV FMODEX_DIR
|
|
||||||
PATH_SUFFIXES include/fmodex include
|
|
||||||
PATHS
|
|
||||||
~/Library/Frameworks
|
|
||||||
/Library/Frameworks
|
|
||||||
/usr/local
|
|
||||||
/usr
|
|
||||||
/sw # Fink
|
|
||||||
/opt/local # DarwinPorts
|
|
||||||
/opt/csw # Blastwave
|
|
||||||
/opt
|
|
||||||
)
|
|
||||||
|
|
||||||
find_library(FMODEX_LIBRARY NAMES fmodex fmodex64
|
|
||||||
HINTS ENV FMODEX_DIR
|
|
||||||
PATH_SUFFIXES lib
|
|
||||||
PATHS
|
|
||||||
~/Library/Frameworks
|
|
||||||
/Library/Frameworks
|
|
||||||
/usr/local
|
|
||||||
/usr
|
|
||||||
/sw # Fink
|
|
||||||
/opt/local # DarwinPorts
|
|
||||||
/opt/csw # Blastwave
|
|
||||||
/opt
|
|
||||||
)
|
|
||||||
|
|
||||||
set(FMODEX_INCLUDE_DIRS "${FMODEX_INCLUDE_DIR}")
|
|
||||||
set(FMODEX_LIBRARIES "${FMODEX_LIBRARY}")
|
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
|
||||||
find_package_handle_standard_args(FMODEX DEFAULT_MSG FMODEX_LIBRARIES FMODEX_INCLUDE_DIRS)
|
|
||||||
|
|
||||||
mark_as_advanced(FMODEX_INCLUDE_DIR FMODEX_LIBRARY FMODEX_INCLUDE_DIRS FMODEX_LIBRARIES)
|
|
||||||
|
|
|
@ -87,6 +87,17 @@ void PolygonInfo::setQuad(V3F_C4B_T2F_Quad *quad)
|
||||||
triangles.verts = (V3F_C4B_T2F*)quad;
|
triangles.verts = (V3F_C4B_T2F*)quad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PolygonInfo::setTriangles(TrianglesCommand::Triangles other)
|
||||||
|
{
|
||||||
|
this->releaseVertsAndIndices();
|
||||||
|
isVertsOwner = false;
|
||||||
|
|
||||||
|
this->triangles.vertCount = other.vertCount;
|
||||||
|
this->triangles.indexCount = other.indexCount;
|
||||||
|
this->triangles.verts = other.verts;
|
||||||
|
this->triangles.indices = other.indices;
|
||||||
|
}
|
||||||
|
|
||||||
void PolygonInfo::releaseVertsAndIndices()
|
void PolygonInfo::releaseVertsAndIndices()
|
||||||
{
|
{
|
||||||
if(isVertsOwner)
|
if(isVertsOwner)
|
||||||
|
|
|
@ -89,6 +89,14 @@ public:
|
||||||
*/
|
*/
|
||||||
void setQuad(V3F_C4B_T2F_Quad *quad);
|
void setQuad(V3F_C4B_T2F_Quad *quad);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the data to be a pointer to a triangles
|
||||||
|
* the member verts will not be released when this PolygonInfo destructs
|
||||||
|
* as the verts memory are managed by other objects
|
||||||
|
* @param triangles a pointer to the TrianglesCommand::Triangles object
|
||||||
|
*/
|
||||||
|
void setTriangles(TrianglesCommand::Triangles triangles);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get vertex count
|
* get vertex count
|
||||||
* @return number of vertices
|
* @return number of vertices
|
||||||
|
@ -110,7 +118,6 @@ public:
|
||||||
Rect rect;
|
Rect rect;
|
||||||
std::string filename;
|
std::string filename;
|
||||||
TrianglesCommand::Triangles triangles;
|
TrianglesCommand::Triangles triangles;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool isVertsOwner;
|
bool isVertsOwner;
|
||||||
|
|
||||||
|
@ -267,4 +274,4 @@ protected:
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
||||||
#endif // #ifndef COCOS_2D_CCAUTOPOLYGON_H__
|
#endif // #ifndef COCOS_2D_CCAUTOPOLYGON_H__
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "renderer/CCRenderer.h"
|
#include "renderer/CCRenderer.h"
|
||||||
#include "renderer/CCRenderState.h"
|
#include "renderer/CCRenderState.h"
|
||||||
#include "base/CCDirector.h"
|
#include "base/CCDirector.h"
|
||||||
|
#include "base/CCStencilStateManager.hpp"
|
||||||
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
|
||||||
#define CC_CLIPPING_NODE_OPENGLES 0
|
#define CC_CLIPPING_NODE_OPENGLES 0
|
||||||
|
@ -41,12 +42,6 @@
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
static GLint g_sStencilBits = -1;
|
|
||||||
// store the current stencil layer (position in the stencil buffer),
|
|
||||||
// this will allow nesting up to n ClippingNode,
|
|
||||||
// where n is the number of bits of the stencil buffer.
|
|
||||||
static GLint s_layer = -1;
|
|
||||||
|
|
||||||
#if CC_CLIPPING_NODE_OPENGLES
|
#if CC_CLIPPING_NODE_OPENGLES
|
||||||
static void setProgram(Node *n, GLProgram *p)
|
static void setProgram(Node *n, GLProgram *p)
|
||||||
{
|
{
|
||||||
|
@ -61,22 +56,8 @@ static void setProgram(Node *n, GLProgram *p)
|
||||||
|
|
||||||
ClippingNode::ClippingNode()
|
ClippingNode::ClippingNode()
|
||||||
: _stencil(nullptr)
|
: _stencil(nullptr)
|
||||||
, _alphaThreshold(0.0f)
|
,_stencilStateManager(new StencilStateManager())
|
||||||
, _inverted(false)
|
|
||||||
, _currentStencilEnabled(GL_FALSE)
|
|
||||||
, _currentStencilWriteMask(~0)
|
|
||||||
, _currentStencilFunc(GL_ALWAYS)
|
|
||||||
, _currentStencilRef(0)
|
|
||||||
, _currentStencilValueMask(~0)
|
|
||||||
, _currentStencilFail(GL_KEEP)
|
|
||||||
, _currentStencilPassDepthFail(GL_KEEP)
|
|
||||||
, _currentStencilPassDepthPass(GL_KEEP)
|
|
||||||
, _currentDepthWriteMask(GL_TRUE)
|
|
||||||
, _currentAlphaTestEnabled(GL_FALSE)
|
|
||||||
, _currentAlphaTestFunc(GL_ALWAYS)
|
|
||||||
, _currentAlphaTestRef(1)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClippingNode::~ClippingNode()
|
ClippingNode::~ClippingNode()
|
||||||
|
@ -128,21 +109,6 @@ bool ClippingNode::init(Node *stencil)
|
||||||
CC_SAFE_RELEASE(_stencil);
|
CC_SAFE_RELEASE(_stencil);
|
||||||
_stencil = stencil;
|
_stencil = stencil;
|
||||||
CC_SAFE_RETAIN(_stencil);
|
CC_SAFE_RETAIN(_stencil);
|
||||||
|
|
||||||
_alphaThreshold = 1;
|
|
||||||
_inverted = false;
|
|
||||||
// get (only once) the number of bits of the stencil buffer
|
|
||||||
static bool once = true;
|
|
||||||
if (once)
|
|
||||||
{
|
|
||||||
glGetIntegerv(GL_STENCIL_BITS, &g_sStencilBits);
|
|
||||||
if (g_sStencilBits <= 0)
|
|
||||||
{
|
|
||||||
CCLOG("Stencil buffer is not enabled.");
|
|
||||||
}
|
|
||||||
once = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,45 +188,6 @@ void ClippingNode::onExit()
|
||||||
Node::onExit();
|
Node::onExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClippingNode::drawFullScreenQuadClearStencil()
|
|
||||||
{
|
|
||||||
Director* director = Director::getInstance();
|
|
||||||
CCASSERT(nullptr != director, "Director is null when setting matrix stack");
|
|
||||||
|
|
||||||
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
|
||||||
director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
|
||||||
|
|
||||||
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
|
||||||
director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
|
||||||
|
|
||||||
Vec2 vertices[] = {
|
|
||||||
Vec2(-1.0f, -1.0f),
|
|
||||||
Vec2(1.0f, -1.0f),
|
|
||||||
Vec2(1.0f, 1.0f),
|
|
||||||
Vec2(-1.0f, 1.0f)
|
|
||||||
};
|
|
||||||
|
|
||||||
auto glProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_U_COLOR);
|
|
||||||
|
|
||||||
int colorLocation = glProgram->getUniformLocation("u_color");
|
|
||||||
CHECK_GL_ERROR_DEBUG();
|
|
||||||
|
|
||||||
Color4F color(1, 1, 1, 1);
|
|
||||||
|
|
||||||
glProgram->use();
|
|
||||||
glProgram->setUniformsForBuiltins();
|
|
||||||
glProgram->setUniformLocationWith4fv(colorLocation, (GLfloat*) &color.r, 1);
|
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
||||||
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
|
|
||||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
|
||||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
|
||||||
|
|
||||||
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 4);
|
|
||||||
|
|
||||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
|
||||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
||||||
{
|
{
|
||||||
|
@ -285,9 +212,11 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32
|
||||||
renderer->pushGroup(_groupCommand.getRenderQueueID());
|
renderer->pushGroup(_groupCommand.getRenderQueueID());
|
||||||
|
|
||||||
_beforeVisitCmd.init(_globalZOrder);
|
_beforeVisitCmd.init(_globalZOrder);
|
||||||
_beforeVisitCmd.func = CC_CALLBACK_0(ClippingNode::onBeforeVisit, this);
|
_beforeVisitCmd.func = CC_CALLBACK_0(StencilStateManager::onBeforeVisit, _stencilStateManager);
|
||||||
renderer->addCommand(&_beforeVisitCmd);
|
renderer->addCommand(&_beforeVisitCmd);
|
||||||
if (_alphaThreshold < 1)
|
|
||||||
|
auto alphaThreshold = this->getAlphaThreshold();
|
||||||
|
if (alphaThreshold < 1)
|
||||||
{
|
{
|
||||||
#if CC_CLIPPING_NODE_OPENGLES
|
#if CC_CLIPPING_NODE_OPENGLES
|
||||||
// since glAlphaTest do not exists in OES, use a shader that writes
|
// since glAlphaTest do not exists in OES, use a shader that writes
|
||||||
|
@ -296,7 +225,7 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32
|
||||||
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE);
|
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE);
|
||||||
// set our alphaThreshold
|
// set our alphaThreshold
|
||||||
program->use();
|
program->use();
|
||||||
program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
|
program->setUniformLocationWith1f(alphaValueLocation, alphaThreshold);
|
||||||
// we need to recursively apply this shader to all the nodes in the stencil node
|
// we need to recursively apply this shader to all the nodes in the stencil node
|
||||||
// FIXME: we should have a way to apply shader to all nodes without having to do this
|
// FIXME: we should have a way to apply shader to all nodes without having to do this
|
||||||
setProgram(_stencil, program);
|
setProgram(_stencil, program);
|
||||||
|
@ -307,7 +236,7 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32
|
||||||
_stencil->visit(renderer, _modelViewTransform, flags);
|
_stencil->visit(renderer, _modelViewTransform, flags);
|
||||||
|
|
||||||
_afterDrawStencilCmd.init(_globalZOrder);
|
_afterDrawStencilCmd.init(_globalZOrder);
|
||||||
_afterDrawStencilCmd.func = CC_CALLBACK_0(ClippingNode::onAfterDrawStencil, this);
|
_afterDrawStencilCmd.func = CC_CALLBACK_0(StencilStateManager::onAfterDrawStencil, _stencilStateManager);
|
||||||
renderer->addCommand(&_afterDrawStencilCmd);
|
renderer->addCommand(&_afterDrawStencilCmd);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -339,7 +268,7 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
_afterVisitCmd.init(_globalZOrder);
|
_afterVisitCmd.init(_globalZOrder);
|
||||||
_afterVisitCmd.func = CC_CALLBACK_0(ClippingNode::onAfterVisit, this);
|
_afterVisitCmd.func = CC_CALLBACK_0(StencilStateManager::onAfterVisit, _stencilStateManager);
|
||||||
renderer->addCommand(&_afterVisitCmd);
|
renderer->addCommand(&_afterVisitCmd);
|
||||||
|
|
||||||
renderer->popGroup();
|
renderer->popGroup();
|
||||||
|
@ -374,196 +303,23 @@ bool ClippingNode::hasContent() const
|
||||||
|
|
||||||
GLfloat ClippingNode::getAlphaThreshold() const
|
GLfloat ClippingNode::getAlphaThreshold() const
|
||||||
{
|
{
|
||||||
return _alphaThreshold;
|
return _stencilStateManager->getAlphaThreshold();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClippingNode::setAlphaThreshold(GLfloat alphaThreshold)
|
void ClippingNode::setAlphaThreshold(GLfloat alphaThreshold)
|
||||||
{
|
{
|
||||||
_alphaThreshold = alphaThreshold;
|
_stencilStateManager->setAlphaThreshold(alphaThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClippingNode::isInverted() const
|
bool ClippingNode::isInverted() const
|
||||||
{
|
{
|
||||||
return _inverted;
|
return _stencilStateManager->isInverted();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClippingNode::setInverted(bool inverted)
|
void ClippingNode::setInverted(bool inverted)
|
||||||
{
|
{
|
||||||
_inverted = inverted;
|
_stencilStateManager->setInverted(inverted);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClippingNode::onBeforeVisit()
|
|
||||||
{
|
|
||||||
///////////////////////////////////
|
|
||||||
// INIT
|
|
||||||
|
|
||||||
// increment the current layer
|
|
||||||
s_layer++;
|
|
||||||
|
|
||||||
// mask of the current layer (ie: for layer 3: 00000100)
|
|
||||||
GLint mask_layer = 0x1 << s_layer;
|
|
||||||
// mask of all layers less than the current (ie: for layer 3: 00000011)
|
|
||||||
GLint mask_layer_l = mask_layer - 1;
|
|
||||||
// mask of all layers less than or equal to the current (ie: for layer 3: 00000111)
|
|
||||||
_mask_layer_le = mask_layer | mask_layer_l;
|
|
||||||
|
|
||||||
// manually save the stencil state
|
|
||||||
|
|
||||||
_currentStencilEnabled = glIsEnabled(GL_STENCIL_TEST);
|
|
||||||
glGetIntegerv(GL_STENCIL_WRITEMASK, (GLint *)&_currentStencilWriteMask);
|
|
||||||
glGetIntegerv(GL_STENCIL_FUNC, (GLint *)&_currentStencilFunc);
|
|
||||||
glGetIntegerv(GL_STENCIL_REF, &_currentStencilRef);
|
|
||||||
glGetIntegerv(GL_STENCIL_VALUE_MASK, (GLint *)&_currentStencilValueMask);
|
|
||||||
glGetIntegerv(GL_STENCIL_FAIL, (GLint *)&_currentStencilFail);
|
|
||||||
glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, (GLint *)&_currentStencilPassDepthFail);
|
|
||||||
glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, (GLint *)&_currentStencilPassDepthPass);
|
|
||||||
|
|
||||||
// enable stencil use
|
|
||||||
glEnable(GL_STENCIL_TEST);
|
|
||||||
// RenderState::StateBlock::_defaultState->setStencilTest(true);
|
|
||||||
|
|
||||||
// check for OpenGL error while enabling stencil test
|
|
||||||
CHECK_GL_ERROR_DEBUG();
|
|
||||||
|
|
||||||
// all bits on the stencil buffer are readonly, except the current layer bit,
|
|
||||||
// this means that operation like glClear or glStencilOp will be masked with this value
|
|
||||||
glStencilMask(mask_layer);
|
|
||||||
// RenderState::StateBlock::_defaultState->setStencilWrite(mask_layer);
|
|
||||||
|
|
||||||
// manually save the depth test state
|
|
||||||
|
|
||||||
glGetBooleanv(GL_DEPTH_WRITEMASK, &_currentDepthWriteMask);
|
|
||||||
|
|
||||||
// disable depth test while drawing the stencil
|
|
||||||
//glDisable(GL_DEPTH_TEST);
|
|
||||||
// disable update to the depth buffer while drawing the stencil,
|
|
||||||
// as the stencil is not meant to be rendered in the real scene,
|
|
||||||
// it should never prevent something else to be drawn,
|
|
||||||
// only disabling depth buffer update should do
|
|
||||||
glDepthMask(GL_FALSE);
|
|
||||||
RenderState::StateBlock::_defaultState->setDepthWrite(false);
|
|
||||||
|
|
||||||
///////////////////////////////////
|
|
||||||
// CLEAR STENCIL BUFFER
|
|
||||||
|
|
||||||
// manually clear the stencil buffer by drawing a fullscreen rectangle on it
|
|
||||||
// setup the stencil test func like this:
|
|
||||||
// for each pixel in the fullscreen rectangle
|
|
||||||
// never draw it into the frame buffer
|
|
||||||
// if not in inverted mode: set the current layer value to 0 in the stencil buffer
|
|
||||||
// if in inverted mode: set the current layer value to 1 in the stencil buffer
|
|
||||||
glStencilFunc(GL_NEVER, mask_layer, mask_layer);
|
|
||||||
glStencilOp(!_inverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP);
|
|
||||||
|
|
||||||
// draw a fullscreen solid rectangle to clear the stencil buffer
|
|
||||||
//ccDrawSolidRect(Vec2::ZERO, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1));
|
|
||||||
drawFullScreenQuadClearStencil();
|
|
||||||
|
|
||||||
///////////////////////////////////
|
|
||||||
// DRAW CLIPPING STENCIL
|
|
||||||
|
|
||||||
// setup the stencil test func like this:
|
|
||||||
// for each pixel in the stencil node
|
|
||||||
// never draw it into the frame buffer
|
|
||||||
// if not in inverted mode: set the current layer value to 1 in the stencil buffer
|
|
||||||
// if in inverted mode: set the current layer value to 0 in the stencil buffer
|
|
||||||
glStencilFunc(GL_NEVER, mask_layer, mask_layer);
|
|
||||||
// RenderState::StateBlock::_defaultState->setStencilFunction(RenderState::STENCIL_NEVER, mask_layer, mask_layer);
|
|
||||||
|
|
||||||
glStencilOp(!_inverted ? GL_REPLACE : GL_ZERO, GL_KEEP, GL_KEEP);
|
|
||||||
// RenderState::StateBlock::_defaultState->setStencilOperation(
|
|
||||||
// !_inverted ? RenderState::STENCIL_OP_REPLACE : RenderState::STENCIL_OP_ZERO,
|
|
||||||
// RenderState::STENCIL_OP_KEEP,
|
|
||||||
// RenderState::STENCIL_OP_KEEP);
|
|
||||||
|
|
||||||
|
|
||||||
// enable alpha test only if the alpha threshold < 1,
|
|
||||||
// indeed if alpha threshold == 1, every pixel will be drawn anyways
|
|
||||||
if (_alphaThreshold < 1) {
|
|
||||||
#if !CC_CLIPPING_NODE_OPENGLES
|
|
||||||
// manually save the alpha test state
|
|
||||||
_currentAlphaTestEnabled = glIsEnabled(GL_ALPHA_TEST);
|
|
||||||
glGetIntegerv(GL_ALPHA_TEST_FUNC, (GLint *)&_currentAlphaTestFunc);
|
|
||||||
glGetFloatv(GL_ALPHA_TEST_REF, &_currentAlphaTestRef);
|
|
||||||
// enable alpha testing
|
|
||||||
glEnable(GL_ALPHA_TEST);
|
|
||||||
// check for OpenGL error while enabling alpha test
|
|
||||||
CHECK_GL_ERROR_DEBUG();
|
|
||||||
// pixel will be drawn only if greater than an alpha threshold
|
|
||||||
glAlphaFunc(GL_GREATER, _alphaThreshold);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
//Draw _stencil
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClippingNode::onAfterDrawStencil()
|
|
||||||
{
|
|
||||||
// restore alpha test state
|
|
||||||
if (_alphaThreshold < 1)
|
|
||||||
{
|
|
||||||
#if CC_CLIPPING_NODE_OPENGLES
|
|
||||||
// FIXME: we need to find a way to restore the shaders of the stencil node and its children
|
|
||||||
#else
|
|
||||||
// manually restore the alpha test state
|
|
||||||
glAlphaFunc(_currentAlphaTestFunc, _currentAlphaTestRef);
|
|
||||||
if (!_currentAlphaTestEnabled)
|
|
||||||
{
|
|
||||||
glDisable(GL_ALPHA_TEST);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// restore the depth test state
|
|
||||||
glDepthMask(_currentDepthWriteMask);
|
|
||||||
RenderState::StateBlock::_defaultState->setDepthWrite(_currentDepthWriteMask != 0);
|
|
||||||
|
|
||||||
//if (currentDepthTestEnabled) {
|
|
||||||
// glEnable(GL_DEPTH_TEST);
|
|
||||||
//}
|
|
||||||
|
|
||||||
///////////////////////////////////
|
|
||||||
// DRAW CONTENT
|
|
||||||
|
|
||||||
// setup the stencil test function like this:
|
|
||||||
// for each pixel of this node and its children
|
|
||||||
// if all layers less than or equals to the current are set to 1 in the stencil buffer
|
|
||||||
// draw the pixel and keep the current layer in the stencil buffer
|
|
||||||
// else
|
|
||||||
// do not draw the pixel but keep the current layer in the stencil buffer
|
|
||||||
glStencilFunc(GL_EQUAL, _mask_layer_le, _mask_layer_le);
|
|
||||||
// RenderState::StateBlock::_defaultState->setStencilFunction(RenderState::STENCIL_EQUAL, _mask_layer_le, _mask_layer_le);
|
|
||||||
|
|
||||||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
|
||||||
// RenderState::StateBlock::_defaultState->setStencilOperation(RenderState::STENCIL_OP_KEEP, RenderState::STENCIL_OP_KEEP, RenderState::STENCIL_OP_KEEP);
|
|
||||||
|
|
||||||
// draw (according to the stencil test function) this node and its children
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ClippingNode::onAfterVisit()
|
|
||||||
{
|
|
||||||
///////////////////////////////////
|
|
||||||
// CLEANUP
|
|
||||||
|
|
||||||
// manually restore the stencil state
|
|
||||||
glStencilFunc(_currentStencilFunc, _currentStencilRef, _currentStencilValueMask);
|
|
||||||
// RenderState::StateBlock::_defaultState->setStencilFunction((RenderState::StencilFunction)_currentStencilFunc, _currentStencilRef, _currentStencilValueMask);
|
|
||||||
|
|
||||||
glStencilOp(_currentStencilFail, _currentStencilPassDepthFail, _currentStencilPassDepthPass);
|
|
||||||
// RenderState::StateBlock::_defaultState->setStencilOperation((RenderState::StencilOperation)_currentStencilFail,
|
|
||||||
// (RenderState::StencilOperation)_currentStencilPassDepthFail,
|
|
||||||
// (RenderState::StencilOperation)_currentStencilPassDepthPass);
|
|
||||||
|
|
||||||
glStencilMask(_currentStencilWriteMask);
|
|
||||||
if (!_currentStencilEnabled)
|
|
||||||
{
|
|
||||||
glDisable(GL_STENCIL_TEST);
|
|
||||||
// RenderState::StateBlock::_defaultState->setStencilTest(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// we are done using this layer, decrement
|
|
||||||
s_layer--;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
#include "renderer/CCCustomCommand.h"
|
#include "renderer/CCCustomCommand.h"
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
class StencilStateManager;
|
||||||
/**
|
/**
|
||||||
* @addtogroup _2d
|
* @addtogroup _2d
|
||||||
* @{
|
* @{
|
||||||
|
@ -153,34 +155,9 @@ CC_CONSTRUCTOR_ACCESS:
|
||||||
virtual bool init(Node *stencil);
|
virtual bool init(Node *stencil);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**draw fullscreen quad to clear stencil bits
|
|
||||||
*/
|
|
||||||
void drawFullScreenQuadClearStencil();
|
|
||||||
|
|
||||||
Node* _stencil;
|
Node* _stencil;
|
||||||
GLfloat _alphaThreshold;
|
|
||||||
bool _inverted;
|
StencilStateManager* _stencilStateManager;
|
||||||
|
|
||||||
//renderData and callback
|
|
||||||
void onBeforeVisit();
|
|
||||||
void onAfterDrawStencil();
|
|
||||||
void onAfterVisit();
|
|
||||||
|
|
||||||
GLboolean _currentStencilEnabled;
|
|
||||||
GLuint _currentStencilWriteMask;
|
|
||||||
GLenum _currentStencilFunc;
|
|
||||||
GLint _currentStencilRef;
|
|
||||||
GLuint _currentStencilValueMask;
|
|
||||||
GLenum _currentStencilFail;
|
|
||||||
GLenum _currentStencilPassDepthFail;
|
|
||||||
GLenum _currentStencilPassDepthPass;
|
|
||||||
GLboolean _currentDepthWriteMask;
|
|
||||||
|
|
||||||
GLboolean _currentAlphaTestEnabled;
|
|
||||||
GLenum _currentAlphaTestFunc;
|
|
||||||
GLclampf _currentAlphaTestRef;
|
|
||||||
|
|
||||||
GLint _mask_layer_le;
|
|
||||||
|
|
||||||
GroupCommand _groupCommand;
|
GroupCommand _groupCommand;
|
||||||
CustomCommand _beforeVisitCmd;
|
CustomCommand _beforeVisitCmd;
|
||||||
|
|
|
@ -62,7 +62,7 @@ bool ComponentContainer::add(Component *com)
|
||||||
|
|
||||||
if (_componentMap.find(componentName) != _componentMap.end())
|
if (_componentMap.find(componentName) != _componentMap.end())
|
||||||
{
|
{
|
||||||
CCASSERT(true, "ComponentContainer already have this kind of component");
|
CCASSERT(false, "ComponentContainer already have this kind of component");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_componentMap[componentName] = com;
|
_componentMap[componentName] = com;
|
||||||
|
|
|
@ -157,6 +157,18 @@ void FontAtlas::addLetterDefinition(char16_t utf16Char, const FontLetterDefiniti
|
||||||
_letterDefinitions[utf16Char] = letterDefinition;
|
_letterDefinitions[utf16Char] = letterDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FontAtlas::scaleFontLetterDefinition(float scaleFactor)
|
||||||
|
{
|
||||||
|
for (auto&& fontDefinition : _letterDefinitions) {
|
||||||
|
auto& letterDefinition = fontDefinition.second;
|
||||||
|
letterDefinition.width *= scaleFactor;
|
||||||
|
letterDefinition.height *= scaleFactor;
|
||||||
|
letterDefinition.offsetX *= scaleFactor;
|
||||||
|
letterDefinition.offsetY *= scaleFactor;
|
||||||
|
letterDefinition.xAdvance *= scaleFactor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool FontAtlas::getLetterDefinitionForChar(char16_t utf16Char, FontLetterDefinition &letterDefinition)
|
bool FontAtlas::getLetterDefinitionForChar(char16_t utf16Char, FontLetterDefinition &letterDefinition)
|
||||||
{
|
{
|
||||||
auto outIterator = _letterDefinitions.find(utf16Char);
|
auto outIterator = _letterDefinitions.find(utf16Char);
|
||||||
|
|
|
@ -115,6 +115,13 @@ protected:
|
||||||
|
|
||||||
void conversionU16TOGB2312(const std::u16string& u16Text, std::unordered_map<unsigned short, unsigned short>& charCodeMap);
|
void conversionU16TOGB2312(const std::u16string& u16Text, std::unordered_map<unsigned short, unsigned short>& charCodeMap);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scale each font letter by scaleFactor.
|
||||||
|
*
|
||||||
|
* @param scaleFactor A float scale factor for scaling font letter info.
|
||||||
|
*/
|
||||||
|
void scaleFontLetterDefinition(float scaleFactor);
|
||||||
|
|
||||||
std::unordered_map<ssize_t, Texture2D*> _atlasTextures;
|
std::unordered_map<ssize_t, Texture2D*> _atlasTextures;
|
||||||
std::unordered_map<char16_t, FontLetterDefinition> _letterDefinitions;
|
std::unordered_map<char16_t, FontLetterDefinition> _letterDefinitions;
|
||||||
float _lineHeight;
|
float _lineHeight;
|
||||||
|
|
|
@ -119,6 +119,8 @@ public://@public
|
||||||
|
|
||||||
// Character Set defines the letters that actually exist in the font
|
// Character Set defines the letters that actually exist in the font
|
||||||
std::set<unsigned int> *_characterSet;
|
std::set<unsigned int> *_characterSet;
|
||||||
|
//! Font Size
|
||||||
|
int _fontSize;
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @js ctor
|
* @js ctor
|
||||||
|
@ -225,6 +227,7 @@ BMFontConfiguration::BMFontConfiguration()
|
||||||
, _commonHeight(0)
|
, _commonHeight(0)
|
||||||
, _kerningDictionary(nullptr)
|
, _kerningDictionary(nullptr)
|
||||||
, _characterSet(nullptr)
|
, _characterSet(nullptr)
|
||||||
|
, _fontSize(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -539,7 +542,7 @@ void BMFontConfiguration::parseInfoArguments(const char* line)
|
||||||
// info face="Script" size=32 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=1,4,3,2 spacing=0,0 outline=0
|
// info face="Script" size=32 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=1,4,3,2 spacing=0,0 outline=0
|
||||||
// info face="Cracked" size=36 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1
|
// info face="Cracked" size=36 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
sscanf(strstr(line, "size=") + 5, "%d", &_fontSize);
|
||||||
// padding
|
// padding
|
||||||
sscanf(strstr(line,"padding=") + 8, "%d,%d,%d,%d", &_padding.top, &_padding.right, &_padding.bottom, &_padding.left);
|
sscanf(strstr(line,"padding=") + 8, "%d,%d,%d,%d", &_padding.top, &_padding.right, &_padding.bottom, &_padding.left);
|
||||||
//CCLOG("cocos2d: padding: %d,%d,%d,%d", _padding.left, _padding.top, _padding.right, _padding.bottom);
|
//CCLOG("cocos2d: padding: %d,%d,%d,%d", _padding.left, _padding.top, _padding.right, _padding.bottom);
|
||||||
|
@ -647,7 +650,7 @@ FontFNT * FontFNT::create(const std::string& fntFilePath, const Vec2& imageOffse
|
||||||
}
|
}
|
||||||
|
|
||||||
FontFNT *tempFont = new FontFNT(newConf,imageOffset);
|
FontFNT *tempFont = new FontFNT(newConf,imageOffset);
|
||||||
|
tempFont->setFontSize(newConf->_fontSize);
|
||||||
if (!tempFont)
|
if (!tempFont)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -716,6 +719,16 @@ int FontFNT::getHorizontalKerningForChars(unsigned short firstChar, unsigned sh
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FontFNT::setFontSize(float fontSize)
|
||||||
|
{
|
||||||
|
_fontSize = fontSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FontFNT::getOriginalFontSize()const
|
||||||
|
{
|
||||||
|
return _configuration->_fontSize;
|
||||||
|
}
|
||||||
|
|
||||||
FontAtlas * FontFNT::createFontAtlas()
|
FontAtlas * FontFNT::createFontAtlas()
|
||||||
{
|
{
|
||||||
FontAtlas *tempAtlas = new (std::nothrow) FontAtlas(*this);
|
FontAtlas *tempAtlas = new (std::nothrow) FontAtlas(*this);
|
||||||
|
@ -734,7 +747,16 @@ FontAtlas * FontFNT::createFontAtlas()
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// common height
|
// common height
|
||||||
tempAtlas->setLineHeight(_configuration->_commonHeight);
|
int originalFontSize = _configuration->_fontSize;
|
||||||
|
float originalLineHeight = _configuration->_commonHeight;
|
||||||
|
float factor = 0.0f;
|
||||||
|
if (fabs(_fontSize - originalFontSize) < FLT_EPSILON) {
|
||||||
|
factor = 1.0f;
|
||||||
|
}else {
|
||||||
|
factor = _fontSize / originalFontSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
tempAtlas->setLineHeight(originalLineHeight * factor);
|
||||||
|
|
||||||
|
|
||||||
BMFontDef fontDef;
|
BMFontDef fontDef;
|
||||||
|
|
|
@ -46,7 +46,8 @@ public:
|
||||||
static void purgeCachedData();
|
static void purgeCachedData();
|
||||||
virtual int* getHorizontalKerningForTextUTF16(const std::u16string& text, int &outNumLetters) const override;
|
virtual int* getHorizontalKerningForTextUTF16(const std::u16string& text, int &outNumLetters) const override;
|
||||||
virtual FontAtlas *createFontAtlas() override;
|
virtual FontAtlas *createFontAtlas() override;
|
||||||
|
void setFontSize(float fontSize);
|
||||||
|
int getOriginalFontSize()const;
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
FontFNT(BMFontConfiguration *theContfig, const Vec2& imageOffset = Vec2::ZERO);
|
FontFNT(BMFontConfiguration *theContfig, const Vec2& imageOffset = Vec2::ZERO);
|
||||||
|
@ -62,7 +63,8 @@ private:
|
||||||
|
|
||||||
BMFontConfiguration * _configuration;
|
BMFontConfiguration * _configuration;
|
||||||
Vec2 _imageOffset;
|
Vec2 _imageOffset;
|
||||||
|
//User defined font size
|
||||||
|
float _fontSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @endcond
|
/// @endcond
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "base/CCEventListenerCustom.h"
|
#include "base/CCEventListenerCustom.h"
|
||||||
#include "base/CCEventDispatcher.h"
|
#include "base/CCEventDispatcher.h"
|
||||||
#include "base/CCEventCustom.h"
|
#include "base/CCEventCustom.h"
|
||||||
|
#include "2d/CCFontFNT.h"
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
@ -472,6 +473,12 @@ void Label::reset()
|
||||||
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
|
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
|
||||||
_isOpacityModifyRGB = false;
|
_isOpacityModifyRGB = false;
|
||||||
_insideBounds = true;
|
_insideBounds = true;
|
||||||
|
_enableWrap = true;
|
||||||
|
_bmFontSize = -1;
|
||||||
|
_bmfontScale = 1.0f;
|
||||||
|
_overflow = Overflow::NORMAL;
|
||||||
|
_originalFontSize = 0.0f;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Label::updateShaderProgram()
|
void Label::updateShaderProgram()
|
||||||
|
@ -548,46 +555,37 @@ void Label::setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = false *
|
||||||
|
|
||||||
bool Label::setTTFConfig(const TTFConfig& ttfConfig)
|
bool Label::setTTFConfig(const TTFConfig& ttfConfig)
|
||||||
{
|
{
|
||||||
FontAtlas *newAtlas = FontAtlasCache::getFontAtlasTTF(&ttfConfig);
|
_originalFontSize = ttfConfig.fontSize;
|
||||||
|
return setTTFConfigInternal(ttfConfig);
|
||||||
if (!newAtlas)
|
|
||||||
{
|
|
||||||
reset();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
_systemFontDirty = false;
|
|
||||||
|
|
||||||
_currentLabelType = LabelType::TTF;
|
|
||||||
setFontAtlas(newAtlas,ttfConfig.distanceFieldEnabled,true);
|
|
||||||
|
|
||||||
_fontConfig = ttfConfig;
|
|
||||||
if (_fontConfig.outlineSize > 0)
|
|
||||||
{
|
|
||||||
_fontConfig.distanceFieldEnabled = false;
|
|
||||||
_useDistanceField = false;
|
|
||||||
_useA8Shader = false;
|
|
||||||
_currLabelEffect = LabelEffect::OUTLINE;
|
|
||||||
updateShaderProgram();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_currLabelEffect = LabelEffect::NORMAL;
|
|
||||||
updateShaderProgram();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Vec2& imageOffset /* = Vec2::ZERO */)
|
bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Vec2& imageOffset, float fontSize)
|
||||||
{
|
{
|
||||||
FontAtlas *newAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath,imageOffset);
|
FontAtlas *newAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath,imageOffset);
|
||||||
|
|
||||||
if (!newAtlas)
|
if (!newAtlas)
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//asign the default fontSize
|
||||||
|
if (fabs(fontSize) < FLT_EPSILON) {
|
||||||
|
FontFNT *bmFont = (FontFNT*)newAtlas->getFont();
|
||||||
|
if (bmFont) {
|
||||||
|
float originalFontSize = bmFont->getOriginalFontSize();
|
||||||
|
if(fabs(_bmFontSize+1) < FLT_EPSILON){
|
||||||
|
_bmFontSize = originalFontSize / CC_CONTENT_SCALE_FACTOR();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fontSize > 0.0f){
|
||||||
|
_bmFontSize = fontSize;
|
||||||
|
}
|
||||||
|
|
||||||
_bmFontPath = bmfontFilePath;
|
_bmFontPath = bmfontFilePath;
|
||||||
|
|
||||||
_currentLabelType = LabelType::BMFONT;
|
_currentLabelType = LabelType::BMFONT;
|
||||||
setFontAtlas(newAtlas);
|
setFontAtlas(newAtlas);
|
||||||
|
|
||||||
|
@ -631,6 +629,9 @@ void Label::setMaxLineWidth(float maxLineWidth)
|
||||||
|
|
||||||
void Label::setDimensions(float width, float height)
|
void Label::setDimensions(float width, float height)
|
||||||
{
|
{
|
||||||
|
if(_overflow == Overflow::RESIZE_HEIGHT){
|
||||||
|
height = 0;
|
||||||
|
}
|
||||||
if (height != _labelHeight || width != _labelWidth)
|
if (height != _labelHeight || width != _labelWidth)
|
||||||
{
|
{
|
||||||
_labelWidth = width;
|
_labelWidth = width;
|
||||||
|
@ -640,7 +641,26 @@ void Label::setDimensions(float width, float height)
|
||||||
|
|
||||||
_maxLineWidth = width;
|
_maxLineWidth = width;
|
||||||
_contentDirty = true;
|
_contentDirty = true;
|
||||||
}
|
|
||||||
|
if(_overflow == Overflow::SHRINK){
|
||||||
|
if (_originalFontSize > 0) {
|
||||||
|
this->restoreFontSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Label::restoreFontSize()
|
||||||
|
{
|
||||||
|
if(_currentLabelType == LabelType::TTF){
|
||||||
|
auto ttfConfig = this->getTTFConfig();
|
||||||
|
ttfConfig.fontSize = _originalFontSize;
|
||||||
|
this->setTTFConfigInternal(ttfConfig);
|
||||||
|
}else if(_currentLabelType == LabelType::BMFONT){
|
||||||
|
this->setBMFontSizeInternal(_originalFontSize);
|
||||||
|
}else if(_currentLabelType == LabelType::STRING_TEXTURE){
|
||||||
|
this->setSystemFontSize(_originalFontSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Label::setLineBreakWithoutSpace(bool breakWithoutSpace)
|
void Label::setLineBreakWithoutSpace(bool breakWithoutSpace)
|
||||||
|
@ -679,6 +699,8 @@ void Label::updateLabelLetters()
|
||||||
uvRect.origin.x = letterDef.U;
|
uvRect.origin.x = letterDef.U;
|
||||||
uvRect.origin.y = letterDef.V;
|
uvRect.origin.y = letterDef.V;
|
||||||
|
|
||||||
|
auto batchNode = _batchNodes.at(letterDef.textureID);
|
||||||
|
letterSprite->setTextureAtlas(batchNode->getTextureAtlas());
|
||||||
letterSprite->setTexture(_fontAtlas->getTexture(letterDef.textureID));
|
letterSprite->setTexture(_fontAtlas->getTexture(letterDef.textureID));
|
||||||
if (letterDef.width <= 0.f || letterDef.height <= 0.f)
|
if (letterDef.width <= 0.f || letterDef.height <= 0.f)
|
||||||
{
|
{
|
||||||
|
@ -695,61 +717,81 @@ void Label::updateLabelLetters()
|
||||||
auto py = letterInfo.positionY - letterDef.height / 2 + _letterOffsetY;
|
auto py = letterInfo.positionY - letterDef.height / 2 + _letterOffsetY;
|
||||||
letterSprite->setPosition(px, py);
|
letterSprite->setPosition(px, py);
|
||||||
|
|
||||||
|
this->updateLetterSpriteScale(letterSprite);
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Label::alignText()
|
bool Label::alignText()
|
||||||
{
|
{
|
||||||
if (_fontAtlas == nullptr || _utf16Text.empty())
|
if (_fontAtlas == nullptr || _utf16Text.empty())
|
||||||
{
|
{
|
||||||
setContentSize(Size::ZERO);
|
setContentSize(Size::ZERO);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_fontAtlas->prepareLetterDefinitions(_utf16Text);
|
bool ret = true;
|
||||||
auto& textures = _fontAtlas->getTextures();
|
do {
|
||||||
if (textures.size() > _batchNodes.size())
|
_fontAtlas->prepareLetterDefinitions(_utf16Text);
|
||||||
{
|
auto& textures = _fontAtlas->getTextures();
|
||||||
for (auto index = _batchNodes.size(); index < textures.size(); ++index)
|
if (textures.size() > _batchNodes.size())
|
||||||
{
|
{
|
||||||
auto batchNode = SpriteBatchNode::createWithTexture(textures.at(index));
|
for (auto index = _batchNodes.size(); index < textures.size(); ++index)
|
||||||
if (batchNode)
|
|
||||||
{
|
{
|
||||||
_isOpacityModifyRGB = batchNode->getTexture()->hasPremultipliedAlpha();
|
auto batchNode = SpriteBatchNode::createWithTexture(textures.at(index));
|
||||||
_blendFunc = batchNode->getBlendFunc();
|
if (batchNode)
|
||||||
batchNode->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT);
|
{
|
||||||
batchNode->setPosition(Vec2::ZERO);
|
_isOpacityModifyRGB = batchNode->getTexture()->hasPremultipliedAlpha();
|
||||||
_batchNodes.pushBack(batchNode);
|
_blendFunc = batchNode->getBlendFunc();
|
||||||
|
batchNode->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT);
|
||||||
|
batchNode->setPosition(Vec2::ZERO);
|
||||||
|
_batchNodes.pushBack(batchNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (_batchNodes.empty())
|
||||||
if (_batchNodes.empty())
|
{
|
||||||
{
|
return true;
|
||||||
return;
|
}
|
||||||
}
|
_reusedLetter->setBatchNode(_batchNodes.at(0));
|
||||||
_reusedLetter->setBatchNode(_batchNodes.at(0));
|
|
||||||
|
_lengthOfString = 0;
|
||||||
|
_textDesiredHeight = 0.f;
|
||||||
|
_linesWidth.clear();
|
||||||
|
if (_maxLineWidth > 0.f && !_lineBreakWithoutSpaces)
|
||||||
|
{
|
||||||
|
multilineTextWrapByWord();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
multilineTextWrapByChar();
|
||||||
|
}
|
||||||
|
computeAlignmentOffset();
|
||||||
|
|
||||||
_lengthOfString = 0;
|
if(_overflow == Overflow::SHRINK){
|
||||||
_textDesiredHeight = 0.f;
|
float fontSize = this->getRenderingFontSize();
|
||||||
_linesWidth.clear();
|
|
||||||
if (_maxLineWidth > 0.f && !_lineBreakWithoutSpaces)
|
|
||||||
{
|
|
||||||
multilineTextWrapByWord();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
multilineTextWrapByChar();
|
|
||||||
}
|
|
||||||
computeAlignmentOffset();
|
|
||||||
|
|
||||||
updateQuads();
|
if(fontSize > 0 && isVerticalClamp()){
|
||||||
|
this->shrinkLabelToContentSize(CC_CALLBACK_0(Label::isVerticalClamp, this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updateLabelLetters();
|
if(!updateQuads()){
|
||||||
|
ret = false;
|
||||||
|
if(!_enableWrap && _overflow == Overflow::SHRINK){
|
||||||
|
this->shrinkLabelToContentSize(CC_CALLBACK_0(Label::isHorizontalClamp, this));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateLabelLetters();
|
||||||
|
|
||||||
|
updateColor();
|
||||||
|
}while (0);
|
||||||
|
|
||||||
updateColor();
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Label::computeHorizontalKernings(const std::u16string& stringToRender)
|
bool Label::computeHorizontalKernings(const std::u16string& stringToRender)
|
||||||
|
@ -769,13 +811,15 @@ bool Label::computeHorizontalKernings(const std::u16string& stringToRender)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Label::updateQuads()
|
bool Label::updateQuads()
|
||||||
{
|
{
|
||||||
|
bool ret = true;
|
||||||
for (auto&& batchNode : _batchNodes)
|
for (auto&& batchNode : _batchNodes)
|
||||||
{
|
{
|
||||||
batchNode->getTextureAtlas()->removeAllQuads();
|
batchNode->getTextureAtlas()->removeAllQuads();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool letterClamp = false;
|
||||||
for (int ctr = 0; ctr < _lengthOfString; ++ctr)
|
for (int ctr = 0; ctr < _lengthOfString; ++ctr)
|
||||||
{
|
{
|
||||||
if (_lettersInfo[ctr].valid)
|
if (_lettersInfo[ctr].valid)
|
||||||
|
@ -802,16 +846,107 @@ void Label::updateQuads()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!_enableWrap){
|
||||||
|
auto px = _lettersInfo[ctr].positionX + letterDef.width/2 + _linesOffsetX[_lettersInfo[ctr].lineIndex];
|
||||||
|
if(_labelWidth > 0.f){
|
||||||
|
if (px > _contentSize.width || px < 0) {
|
||||||
|
if(_overflow == Overflow::CLAMP){
|
||||||
|
_reusedRect.size.width = 0;
|
||||||
|
}else if(_overflow == Overflow::SHRINK){
|
||||||
|
if (letterDef.width > 0
|
||||||
|
&& _contentSize.width > letterDef.width) {
|
||||||
|
letterClamp = true;
|
||||||
|
ret = false;
|
||||||
|
break;
|
||||||
|
}else{
|
||||||
|
//clamp
|
||||||
|
_reusedRect.size.width = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_reusedRect.size.height > 0.f && _reusedRect.size.width > 0.f)
|
if (_reusedRect.size.height > 0.f && _reusedRect.size.width > 0.f)
|
||||||
{
|
{
|
||||||
_reusedLetter->setTextureRect(_reusedRect, false, _reusedRect.size);
|
_reusedLetter->setTextureRect(_reusedRect, false, _reusedRect.size);
|
||||||
_reusedLetter->setPosition(_lettersInfo[ctr].positionX + _linesOffsetX[_lettersInfo[ctr].lineIndex], py);
|
float letterPositionX = _lettersInfo[ctr].positionX + _linesOffsetX[_lettersInfo[ctr].lineIndex];
|
||||||
|
_reusedLetter->setPosition(letterPositionX, py);
|
||||||
auto index = static_cast<int>(_batchNodes.at(letterDef.textureID)->getTextureAtlas()->getTotalQuads());
|
auto index = static_cast<int>(_batchNodes.at(letterDef.textureID)->getTextureAtlas()->getTotalQuads());
|
||||||
_lettersInfo[ctr].atlasIndex = index;
|
_lettersInfo[ctr].atlasIndex = index;
|
||||||
|
|
||||||
|
this->updateLetterSpriteScale(_reusedLetter);
|
||||||
|
|
||||||
_batchNodes.at(letterDef.textureID)->insertQuadFromSprite(_reusedLetter, index);
|
_batchNodes.at(letterDef.textureID)->insertQuadFromSprite(_reusedLetter, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Label::setTTFConfigInternal(const TTFConfig& ttfConfig)
|
||||||
|
{
|
||||||
|
FontAtlas *newAtlas = FontAtlasCache::getFontAtlasTTF(&ttfConfig);
|
||||||
|
|
||||||
|
if (!newAtlas)
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_systemFontDirty = false;
|
||||||
|
|
||||||
|
_currentLabelType = LabelType::TTF;
|
||||||
|
setFontAtlas(newAtlas,ttfConfig.distanceFieldEnabled,true);
|
||||||
|
|
||||||
|
_fontConfig = ttfConfig;
|
||||||
|
|
||||||
|
if (_fontConfig.outlineSize > 0)
|
||||||
|
{
|
||||||
|
_fontConfig.distanceFieldEnabled = false;
|
||||||
|
_useDistanceField = false;
|
||||||
|
_useA8Shader = false;
|
||||||
|
_currLabelEffect = LabelEffect::OUTLINE;
|
||||||
|
updateShaderProgram();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_currLabelEffect = LabelEffect::NORMAL;
|
||||||
|
updateShaderProgram();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Label::setBMFontSizeInternal(float fontSize)
|
||||||
|
{
|
||||||
|
if(_currentLabelType == LabelType::BMFONT){
|
||||||
|
this->setBMFontFilePath(_bmFontPath, Vec2::ZERO, fontSize);
|
||||||
|
_contentDirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Label::scaleFontSizeDown(float fontSize)
|
||||||
|
{
|
||||||
|
bool shouldUpdateContent = true;
|
||||||
|
if(_currentLabelType == LabelType::TTF){
|
||||||
|
auto ttfConfig = this->getTTFConfig();
|
||||||
|
ttfConfig.fontSize = fontSize;
|
||||||
|
this->setTTFConfigInternal(ttfConfig);
|
||||||
|
}else if(_currentLabelType == LabelType::BMFONT){
|
||||||
|
if (fabs(fontSize) < FLT_EPSILON) {
|
||||||
|
fontSize = 0.1f;
|
||||||
|
shouldUpdateContent = false;
|
||||||
|
}
|
||||||
|
this->setBMFontSizeInternal(fontSize);
|
||||||
|
}else if (_currentLabelType == LabelType::STRING_TEXTURE){
|
||||||
|
this->setSystemFontSize(fontSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldUpdateContent) {
|
||||||
|
this->updateContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Label::enableGlow(const Color4B& glowColor)
|
void Label::enableGlow(const Color4B& glowColor)
|
||||||
|
@ -1102,6 +1237,7 @@ void Label::updateContent()
|
||||||
|
|
||||||
CC_SAFE_RELEASE_NULL(_textSprite);
|
CC_SAFE_RELEASE_NULL(_textSprite);
|
||||||
CC_SAFE_RELEASE_NULL(_shadowNode);
|
CC_SAFE_RELEASE_NULL(_shadowNode);
|
||||||
|
bool updateFinished = true;
|
||||||
|
|
||||||
if (_fontAtlas)
|
if (_fontAtlas)
|
||||||
{
|
{
|
||||||
|
@ -1112,7 +1248,7 @@ void Label::updateContent()
|
||||||
}
|
}
|
||||||
|
|
||||||
computeHorizontalKernings(_utf16Text);
|
computeHorizontalKernings(_utf16Text);
|
||||||
alignText();
|
updateFinished = alignText();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1123,7 +1259,9 @@ void Label::updateContent()
|
||||||
createShadowSpriteForSystemFont(fontDef);
|
createShadowSpriteForSystemFont(fontDef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_contentDirty = false;
|
if(updateFinished){
|
||||||
|
_contentDirty = false;
|
||||||
|
}
|
||||||
|
|
||||||
#if CC_LABEL_DEBUG_DRAW
|
#if CC_LABEL_DEBUG_DRAW
|
||||||
_debugDrawNode->clear();
|
_debugDrawNode->clear();
|
||||||
|
@ -1138,6 +1276,17 @@ void Label::updateContent()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Label::setBMFontSize(float fontSize)
|
||||||
|
{
|
||||||
|
this->setBMFontSizeInternal(fontSize);
|
||||||
|
_originalFontSize = fontSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Label::getBMFontSize()const
|
||||||
|
{
|
||||||
|
return _bmFontSize;
|
||||||
|
}
|
||||||
|
|
||||||
void Label::onDrawShadow(GLProgram* glProgram)
|
void Label::onDrawShadow(GLProgram* glProgram)
|
||||||
{
|
{
|
||||||
if (_currentLabelType == LabelType::TTF)
|
if (_currentLabelType == LabelType::TTF)
|
||||||
|
@ -1381,6 +1530,7 @@ void Label::setSystemFontSize(float fontSize)
|
||||||
if (_systemFontSize != fontSize)
|
if (_systemFontSize != fontSize)
|
||||||
{
|
{
|
||||||
_systemFontSize = fontSize;
|
_systemFontSize = fontSize;
|
||||||
|
_originalFontSize = fontSize;
|
||||||
_systemFontDirty = true;
|
_systemFontDirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1463,21 +1613,21 @@ void Label::setLineHeight(float height)
|
||||||
float Label::getLineHeight() const
|
float Label::getLineHeight() const
|
||||||
{
|
{
|
||||||
CCASSERT(_currentLabelType != LabelType::STRING_TEXTURE, "Not supported system font!");
|
CCASSERT(_currentLabelType != LabelType::STRING_TEXTURE, "Not supported system font!");
|
||||||
return _textSprite ? 0.0f : _lineHeight;
|
return _textSprite ? 0.0f : _lineHeight * _bmfontScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Label::setLineSpacing(float height)
|
void Label::setLineSpacing(float height)
|
||||||
{
|
{
|
||||||
if (_lineSpacing != height)
|
if (_lineSpacing != height)
|
||||||
{
|
{
|
||||||
_lineSpacing = height;
|
_lineSpacing = height;
|
||||||
_contentDirty = true;
|
_contentDirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float Label::getLineSpacing() const
|
float Label::getLineSpacing() const
|
||||||
{
|
{
|
||||||
return _lineSpacing;
|
return _lineSpacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Label::setAdditionalKerning(float space)
|
void Label::setAdditionalKerning(float space)
|
||||||
|
@ -1753,4 +1903,99 @@ void Label::setGlobalZOrder(float globalZOrder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Label::getRenderingFontSize()const
|
||||||
|
{
|
||||||
|
float fontSize;
|
||||||
|
if (_currentLabelType == LabelType::BMFONT) {
|
||||||
|
fontSize = _bmFontSize;
|
||||||
|
}else if(_currentLabelType == LabelType::TTF){
|
||||||
|
fontSize = this->getTTFConfig().fontSize;
|
||||||
|
}else if(_currentLabelType == LabelType::STRING_TEXTURE){
|
||||||
|
fontSize = _systemFontSize;
|
||||||
|
}else{ //FIXME: find a way to caculate char map font size
|
||||||
|
fontSize = this->getLineHeight();
|
||||||
|
}
|
||||||
|
return fontSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Label::enableWrap(bool enable)
|
||||||
|
{
|
||||||
|
if(enable == _enableWrap || _overflow == Overflow::RESIZE_HEIGHT
|
||||||
|
|| _currentLabelType == LabelType::STRING_TEXTURE){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->_enableWrap = enable;
|
||||||
|
|
||||||
|
this->rescaleWithOriginalFontSize();
|
||||||
|
|
||||||
|
_contentDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Label::isWrapEnabled()const
|
||||||
|
{
|
||||||
|
return this->_enableWrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Label::setOverflow(Overflow overflow)
|
||||||
|
{
|
||||||
|
if(_overflow == overflow){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_currentLabelType == LabelType::CHARMAP) {
|
||||||
|
if (overflow == Overflow::SHRINK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_currentLabelType == LabelType::STRING_TEXTURE) {
|
||||||
|
if (overflow == Overflow::CLAMP || overflow == Overflow::SHRINK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(overflow == Overflow::RESIZE_HEIGHT){
|
||||||
|
this->setDimensions(_labelDimensions.width,0);
|
||||||
|
this->enableWrap(true);
|
||||||
|
}
|
||||||
|
_overflow = overflow;
|
||||||
|
|
||||||
|
this->rescaleWithOriginalFontSize();
|
||||||
|
|
||||||
|
_contentDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Label::rescaleWithOriginalFontSize()
|
||||||
|
{
|
||||||
|
auto renderingFontSize = this->getRenderingFontSize();
|
||||||
|
if (_originalFontSize - renderingFontSize >= 1) {
|
||||||
|
this->scaleFontSizeDown(_originalFontSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Label::Overflow Label::getOverflow()const
|
||||||
|
{
|
||||||
|
return _overflow;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Label::updateLetterSpriteScale(Sprite* sprite)
|
||||||
|
{
|
||||||
|
if (_currentLabelType == LabelType::BMFONT && _bmFontSize > 0)
|
||||||
|
{
|
||||||
|
sprite->setScale(_bmfontScale);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(fabs(_bmFontSize)<FLT_EPSILON)
|
||||||
|
{
|
||||||
|
sprite->setScale(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprite->setScale(1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -95,6 +95,23 @@ class EventListenerCustom;
|
||||||
class CC_DLL Label : public Node, public LabelProtocol, public BlendProtocol
|
class CC_DLL Label : public Node, public LabelProtocol, public BlendProtocol
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum class Overflow
|
||||||
|
{
|
||||||
|
//for keep back compatibility
|
||||||
|
NORMAL,
|
||||||
|
/**
|
||||||
|
* In SHRINK mode, the font size will change dynamically to adapt the content size.
|
||||||
|
*/
|
||||||
|
SHRINK,
|
||||||
|
/**
|
||||||
|
*In CLAMP mode, when label content goes out of the bounding box, it will be clipped.
|
||||||
|
*/
|
||||||
|
CLAMP,
|
||||||
|
/**
|
||||||
|
*In RESIZE_HEIGHT mode, you can only change the width of label and the height is changed automatically.
|
||||||
|
*/
|
||||||
|
RESIZE_HEIGHT
|
||||||
|
};
|
||||||
/// @name Creators
|
/// @name Creators
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
|
@ -221,7 +238,7 @@ public:
|
||||||
virtual const TTFConfig& getTTFConfig() const { return _fontConfig;}
|
virtual const TTFConfig& getTTFConfig() const { return _fontConfig;}
|
||||||
|
|
||||||
/** Sets a new bitmap font to Label */
|
/** Sets a new bitmap font to Label */
|
||||||
virtual bool setBMFontFilePath(const std::string& bmfontFilePath, const Vec2& imageOffset = Vec2::ZERO);
|
virtual bool setBMFontFilePath(const std::string& bmfontFilePath, const Vec2& imageOffset = Vec2::ZERO, float fontSize = 0);
|
||||||
|
|
||||||
/** Returns the bitmap font used by the Label.*/
|
/** Returns the bitmap font used by the Label.*/
|
||||||
const std::string& getBMFontFilePath() const { return _bmFontPath;}
|
const std::string& getBMFontFilePath() const { return _bmFontPath;}
|
||||||
|
@ -366,12 +383,55 @@ public:
|
||||||
*/
|
*/
|
||||||
void setMaxLineWidth(float maxLineWidth);
|
void setMaxLineWidth(float maxLineWidth);
|
||||||
float getMaxLineWidth() { return _maxLineWidth; }
|
float getMaxLineWidth() { return _maxLineWidth; }
|
||||||
|
/**
|
||||||
|
* Change font size of label type BMFONT
|
||||||
|
* Note: This function only scale the BMFONT letter to mimic the font size change effect.
|
||||||
|
*
|
||||||
|
* @param fontSize The desired font size in float.
|
||||||
|
*/
|
||||||
|
void setBMFontSize(float fontSize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the user define BMFont size.
|
||||||
|
*
|
||||||
|
* @return The BMFont size in float value.
|
||||||
|
*/
|
||||||
|
float getBMFontSize()const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle wrap option of the label.
|
||||||
|
* Note: System font doesn't support manually toggle wrap.
|
||||||
|
*
|
||||||
|
* @param enable Set true to enable wrap and false to disable wrap.
|
||||||
|
*/
|
||||||
|
void enableWrap(bool enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query the wrap is enabled or not.
|
||||||
|
* Note: System font will always return true.
|
||||||
|
*/
|
||||||
|
bool isWrapEnabled()const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the label's Overflow type, currently only TTF and BMFont support all the valid Overflow type.
|
||||||
|
* Char Map font supports all the Overflow type except for SHRINK, because we can't measure it's font size.
|
||||||
|
* System font only support Overflow::Normal and Overflow::RESIZE_HEIGHT.
|
||||||
|
*
|
||||||
|
* @param overflow see `Overflow`
|
||||||
|
*/
|
||||||
|
void setOverflow(Overflow overflow);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query the label's Overflow type.
|
||||||
|
*
|
||||||
|
* @return see `Overflow`
|
||||||
|
*/
|
||||||
|
Overflow getOverflow()const;
|
||||||
/**
|
/**
|
||||||
* Makes the Label exactly this untransformed width.
|
* Makes the Label exactly this untransformed width.
|
||||||
*
|
*
|
||||||
* The Label's width be used for text align if the value not equal zero.
|
* The Label's width be used for text align if the value not equal zero.
|
||||||
*/
|
*/
|
||||||
void setWidth(float width) { setDimensions(width,_labelHeight);}
|
void setWidth(float width) { setDimensions(width,_labelHeight);}
|
||||||
float getWidth() const { return _labelWidth; }
|
float getWidth() const { return _labelWidth; }
|
||||||
|
|
||||||
|
@ -508,21 +568,33 @@ protected:
|
||||||
|
|
||||||
bool multilineTextWrapByChar();
|
bool multilineTextWrapByChar();
|
||||||
bool multilineTextWrapByWord();
|
bool multilineTextWrapByWord();
|
||||||
|
bool multilineTextWrap(std::function<int(const std::u16string&, int, int)> lambda);
|
||||||
|
void shrinkLabelToContentSize(std::function<bool(void)> lambda);
|
||||||
|
bool isHorizontalClamp();
|
||||||
|
bool isVerticalClamp();
|
||||||
|
float getRenderingFontSize()const;
|
||||||
|
void rescaleWithOriginalFontSize();
|
||||||
|
|
||||||
void updateLabelLetters();
|
void updateLabelLetters();
|
||||||
virtual void alignText();
|
virtual bool alignText();
|
||||||
void computeAlignmentOffset();
|
void computeAlignmentOffset();
|
||||||
bool computeHorizontalKernings(const std::u16string& stringToRender);
|
bool computeHorizontalKernings(const std::u16string& stringToRender);
|
||||||
|
|
||||||
void recordLetterInfo(const cocos2d::Vec2& point, char16_t utf16Char, int letterIndex, int lineIndex);
|
void recordLetterInfo(const cocos2d::Vec2& point, char16_t utf16Char, int letterIndex, int lineIndex);
|
||||||
void recordPlaceholderInfo(int letterIndex, char16_t utf16Char);
|
void recordPlaceholderInfo(int letterIndex, char16_t utf16Char);
|
||||||
|
|
||||||
void updateQuads();
|
bool updateQuads();
|
||||||
|
|
||||||
void createSpriteForSystemFont(const FontDefinition& fontDef);
|
void createSpriteForSystemFont(const FontDefinition& fontDef);
|
||||||
void createShadowSpriteForSystemFont(const FontDefinition& fontDef);
|
void createShadowSpriteForSystemFont(const FontDefinition& fontDef);
|
||||||
|
|
||||||
virtual void updateShaderProgram();
|
virtual void updateShaderProgram();
|
||||||
|
void updateBMFontScale();
|
||||||
|
void scaleFontSizeDown(float fontSize);
|
||||||
|
bool setTTFConfigInternal(const TTFConfig& ttfConfig);
|
||||||
|
void setBMFontSizeInternal(float fontSize);
|
||||||
|
void restoreFontSize();
|
||||||
|
void updateLetterSpriteScale(Sprite* sprite);
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
@ -614,6 +686,12 @@ protected:
|
||||||
#if CC_LABEL_DEBUG_DRAW
|
#if CC_LABEL_DEBUG_DRAW
|
||||||
DrawNode* _debugDrawNode;
|
DrawNode* _debugDrawNode;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool _enableWrap;
|
||||||
|
float _bmFontSize;
|
||||||
|
float _bmfontScale;
|
||||||
|
Overflow _overflow;
|
||||||
|
float _originalFontSize;
|
||||||
private:
|
private:
|
||||||
CC_DISALLOW_COPY_AND_ASSIGN(Label);
|
CC_DISALLOW_COPY_AND_ASSIGN(Label);
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "base/ccUTF8.h"
|
#include "base/ccUTF8.h"
|
||||||
#include "base/CCDirector.h"
|
#include "base/CCDirector.h"
|
||||||
#include "2d/CCFontAtlas.h"
|
#include "2d/CCFontAtlas.h"
|
||||||
|
#include "2d/CCFontFNT.h"
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
@ -71,6 +72,11 @@ void Label::computeAlignmentOffset()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int getFirstCharLen(const std::u16string& utf16Text, int startIndex, int textLen)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int getFirstWordLen(const std::u16string& utf16Text, int startIndex, int textLen)
|
static int getFirstWordLen(const std::u16string& utf16Text, int startIndex, int textLen)
|
||||||
{
|
{
|
||||||
auto character = utf16Text[startIndex];
|
auto character = utf16Text[startIndex];
|
||||||
|
@ -93,22 +99,36 @@ static int getFirstWordLen(const std::u16string& utf16Text, int startIndex, int
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Label::multilineTextWrapByWord()
|
void Label::updateBMFontScale()
|
||||||
|
{
|
||||||
|
auto font = _fontAtlas->getFont();
|
||||||
|
if (_currentLabelType == LabelType::BMFONT) {
|
||||||
|
FontFNT *bmFont = (FontFNT*)font;
|
||||||
|
float originalFontSize = bmFont->getOriginalFontSize();
|
||||||
|
_bmfontScale = _bmFontSize * CC_CONTENT_SCALE_FACTOR() / originalFontSize;
|
||||||
|
}else{
|
||||||
|
_bmfontScale = 1.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Label::multilineTextWrap(std::function<int(const std::u16string&, int, int)> nextTokenLen)
|
||||||
{
|
{
|
||||||
int textLen = getStringLength();
|
int textLen = getStringLength();
|
||||||
int lineIndex = 0;
|
int lineIndex = 0;
|
||||||
float nextWordX = 0.f;
|
float nextTokenX = 0.f;
|
||||||
float nextWordY = 0.f;
|
float nextTokenY = 0.f;
|
||||||
float longestLine = 0.f;
|
float longestLine = 0.f;
|
||||||
float letterRight = 0.f;
|
float letterRight = 0.f;
|
||||||
|
|
||||||
auto contentScaleFactor = CC_CONTENT_SCALE_FACTOR();
|
auto contentScaleFactor = CC_CONTENT_SCALE_FACTOR();
|
||||||
float lineSpacing = _lineSpacing * contentScaleFactor;
|
float lineSpacing = _lineSpacing * contentScaleFactor;
|
||||||
float highestY = 0.f;
|
float highestY = 0.f;
|
||||||
float lowestY = 0.f;
|
float lowestY = 0.f;
|
||||||
FontLetterDefinition letterDef;
|
FontLetterDefinition letterDef;
|
||||||
Vec2 letterPosition;
|
Vec2 letterPosition;
|
||||||
|
|
||||||
|
this->updateBMFontScale();
|
||||||
|
|
||||||
for (int index = 0; index < textLen; )
|
for (int index = 0; index < textLen; )
|
||||||
{
|
{
|
||||||
auto character = _utf16Text[index];
|
auto character = _utf16Text[index];
|
||||||
|
@ -117,20 +137,20 @@ bool Label::multilineTextWrapByWord()
|
||||||
_linesWidth.push_back(letterRight);
|
_linesWidth.push_back(letterRight);
|
||||||
letterRight = 0.f;
|
letterRight = 0.f;
|
||||||
lineIndex++;
|
lineIndex++;
|
||||||
nextWordX = 0.f;
|
nextTokenX = 0.f;
|
||||||
nextWordY -= _lineHeight + lineSpacing;
|
nextTokenY -= _lineHeight*_bmfontScale + lineSpacing;
|
||||||
recordPlaceholderInfo(index, character);
|
recordPlaceholderInfo(index, character);
|
||||||
index++;
|
index++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto wordLen = getFirstWordLen(_utf16Text, index, textLen);
|
auto tokenLen = nextTokenLen(_utf16Text, index, textLen);
|
||||||
float wordHighestY = highestY;;
|
float tokenHighestY = highestY;;
|
||||||
float wordLowestY = lowestY;
|
float tokenLowestY = lowestY;
|
||||||
float wordRight = letterRight;
|
float tokenRight = letterRight;
|
||||||
float nextLetterX = nextWordX;
|
float nextLetterX = nextTokenX;
|
||||||
bool newLine = false;
|
bool newLine = false;
|
||||||
for (int tmp = 0; tmp < wordLen;++tmp)
|
for (int tmp = 0; tmp < tokenLen;++tmp)
|
||||||
{
|
{
|
||||||
int letterIndex = index + tmp;
|
int letterIndex = index + tmp;
|
||||||
character = _utf16Text[letterIndex];
|
character = _utf16Text[letterIndex];
|
||||||
|
@ -145,15 +165,15 @@ bool Label::multilineTextWrapByWord()
|
||||||
CCLOG("LabelTextFormatter error:can't find letter definition in font file for letter: %c", character);
|
CCLOG("LabelTextFormatter error:can't find letter definition in font file for letter: %c", character);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto letterX = (nextLetterX + letterDef.offsetX) / contentScaleFactor;
|
auto letterX = (nextLetterX + letterDef.offsetX * _bmfontScale) / contentScaleFactor;
|
||||||
if (_maxLineWidth > 0.f && nextWordX > 0.f && letterX + letterDef.width > _maxLineWidth)
|
if (_enableWrap && _maxLineWidth > 0.f && nextTokenX > 0.f && letterX + letterDef.width * _bmfontScale > _maxLineWidth)
|
||||||
{
|
{
|
||||||
_linesWidth.push_back(letterRight);
|
_linesWidth.push_back(letterRight);
|
||||||
letterRight = 0.f;
|
letterRight = 0.f;
|
||||||
lineIndex++;
|
lineIndex++;
|
||||||
nextWordX = 0.f;
|
nextTokenX = 0.f;
|
||||||
nextWordY -= _lineHeight + lineSpacing;
|
nextTokenY -= (_lineHeight*_bmfontScale + lineSpacing);
|
||||||
newLine = true;
|
newLine = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -161,42 +181,42 @@ bool Label::multilineTextWrapByWord()
|
||||||
{
|
{
|
||||||
letterPosition.x = letterX;
|
letterPosition.x = letterX;
|
||||||
}
|
}
|
||||||
letterPosition.y = (nextWordY - letterDef.offsetY) / contentScaleFactor;
|
letterPosition.y = (nextTokenY - letterDef.offsetY * _bmfontScale) / contentScaleFactor;
|
||||||
recordLetterInfo(letterPosition, character, letterIndex, lineIndex);
|
recordLetterInfo(letterPosition, character, letterIndex, lineIndex);
|
||||||
|
|
||||||
if (_horizontalKernings && letterIndex < textLen - 1)
|
if (_horizontalKernings && letterIndex < textLen - 1)
|
||||||
nextLetterX += _horizontalKernings[letterIndex + 1];
|
nextLetterX += _horizontalKernings[letterIndex + 1];
|
||||||
nextLetterX += letterDef.xAdvance + _additionalKerning;
|
nextLetterX += letterDef.xAdvance * _bmfontScale + _additionalKerning;
|
||||||
|
|
||||||
wordRight = letterPosition.x + letterDef.width;
|
tokenRight = letterPosition.x + letterDef.width * _bmfontScale;
|
||||||
|
|
||||||
if (wordHighestY < letterPosition.y)
|
if (tokenHighestY < letterPosition.y)
|
||||||
wordHighestY = letterPosition.y;
|
tokenHighestY = letterPosition.y;
|
||||||
if (wordLowestY > letterPosition.y - letterDef.height)
|
if (tokenLowestY > letterPosition.y - letterDef.height * _bmfontScale)
|
||||||
wordLowestY = letterPosition.y - letterDef.height;
|
tokenLowestY = letterPosition.y - letterDef.height * _bmfontScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newLine)
|
if (newLine)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
nextWordX = nextLetterX;
|
nextTokenX = nextLetterX;
|
||||||
letterRight = wordRight;
|
letterRight = tokenRight;
|
||||||
if (highestY < wordHighestY)
|
if (highestY < tokenHighestY)
|
||||||
highestY = wordHighestY;
|
highestY = tokenHighestY;
|
||||||
if (lowestY > wordLowestY)
|
if (lowestY > tokenLowestY)
|
||||||
lowestY = wordLowestY;
|
lowestY = tokenLowestY;
|
||||||
if (longestLine < letterRight)
|
if (longestLine < letterRight)
|
||||||
longestLine = letterRight;
|
longestLine = letterRight;
|
||||||
|
|
||||||
index += wordLen;
|
index += tokenLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
_linesWidth.push_back(letterRight);
|
_linesWidth.push_back(letterRight);
|
||||||
|
|
||||||
_numberOfLines = lineIndex + 1;
|
_numberOfLines = lineIndex + 1;
|
||||||
_textDesiredHeight = (_numberOfLines * _lineHeight) / contentScaleFactor;
|
_textDesiredHeight = (_numberOfLines * _lineHeight * _bmfontScale) / contentScaleFactor;
|
||||||
if (_numberOfLines > 1)
|
if (_numberOfLines > 1)
|
||||||
_textDesiredHeight += (_numberOfLines - 1) * _lineSpacing;
|
_textDesiredHeight += (_numberOfLines - 1) * _lineSpacing;
|
||||||
Size contentSize(_labelWidth, _labelHeight);
|
Size contentSize(_labelWidth, _labelHeight);
|
||||||
|
@ -205,111 +225,100 @@ bool Label::multilineTextWrapByWord()
|
||||||
if (_labelHeight <= 0.f)
|
if (_labelHeight <= 0.f)
|
||||||
contentSize.height = _textDesiredHeight;
|
contentSize.height = _textDesiredHeight;
|
||||||
setContentSize(contentSize);
|
setContentSize(contentSize);
|
||||||
|
|
||||||
_tailoredTopY = contentSize.height;
|
_tailoredTopY = contentSize.height;
|
||||||
_tailoredBottomY = 0.f;
|
_tailoredBottomY = 0.f;
|
||||||
if (highestY > 0.f)
|
if (highestY > 0.f)
|
||||||
_tailoredTopY = contentSize.height + highestY;
|
_tailoredTopY = contentSize.height + highestY;
|
||||||
if (lowestY < -_textDesiredHeight)
|
if (lowestY < -_textDesiredHeight)
|
||||||
_tailoredBottomY = _textDesiredHeight + lowestY;
|
_tailoredBottomY = _textDesiredHeight + lowestY;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Label::multilineTextWrapByWord()
|
||||||
|
{
|
||||||
|
return multilineTextWrap(std::bind(getFirstWordLen, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||||
|
}
|
||||||
|
|
||||||
bool Label::multilineTextWrapByChar()
|
bool Label::multilineTextWrapByChar()
|
||||||
{
|
{
|
||||||
int textLen = getStringLength();
|
return multilineTextWrap(std::bind(getFirstCharLen, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||||
int lineIndex = 0;
|
}
|
||||||
float nextLetterX = 0.f;
|
|
||||||
float nextLetterY = 0.f;
|
|
||||||
float longestLine = 0.f;
|
|
||||||
float letterRight = 0.f;
|
|
||||||
|
|
||||||
auto contentScaleFactor = CC_CONTENT_SCALE_FACTOR();
|
bool Label::isVerticalClamp()
|
||||||
float lineSpacing = _lineSpacing * contentScaleFactor;
|
{
|
||||||
float highestY = 0.f;
|
if (_textDesiredHeight > _contentSize.height)
|
||||||
float lowestY = 0.f;
|
|
||||||
FontLetterDefinition letterDef;
|
|
||||||
Vec2 letterPosition;
|
|
||||||
|
|
||||||
for (int index = 0; index < textLen; index++)
|
|
||||||
{
|
{
|
||||||
auto character = _utf16Text[index];
|
return true;
|
||||||
if (character == '\r')
|
}
|
||||||
{
|
else
|
||||||
recordPlaceholderInfo(index, character);
|
{
|
||||||
continue;
|
return false;
|
||||||
}
|
}
|
||||||
if (character == '\n')
|
}
|
||||||
{
|
|
||||||
_linesWidth.push_back(letterRight);
|
|
||||||
letterRight = 0.f;
|
|
||||||
lineIndex++;
|
|
||||||
nextLetterX = 0.f;
|
|
||||||
nextLetterY -= _lineHeight + lineSpacing;
|
|
||||||
recordPlaceholderInfo(index, character);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_fontAtlas->getLetterDefinitionForChar(character, letterDef) == false)
|
bool Label::isHorizontalClamp()
|
||||||
|
{
|
||||||
|
bool letterClamp = false;
|
||||||
|
for (int ctr = 0; ctr < _lengthOfString; ++ctr)
|
||||||
|
{
|
||||||
|
if (_lettersInfo[ctr].valid)
|
||||||
{
|
{
|
||||||
recordPlaceholderInfo(index, character);
|
auto& letterDef = _fontAtlas->_letterDefinitions[_lettersInfo[ctr].utf16Char];
|
||||||
CCLOG("LabelTextFormatter error:can't find letter definition in font file for letter: %c", character);
|
|
||||||
continue;
|
auto px = _lettersInfo[ctr].positionX + letterDef.width/2;
|
||||||
|
if(_labelWidth > 0.f){
|
||||||
|
if (px > _contentSize.width) {
|
||||||
|
letterClamp = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return letterClamp;
|
||||||
|
}
|
||||||
|
|
||||||
auto letterX = (nextLetterX + letterDef.offsetX) / contentScaleFactor;
|
void Label::shrinkLabelToContentSize(std::function<bool(void)> lambda)
|
||||||
if (_maxLineWidth > 0.f && nextLetterX > 0.f && letterX + letterDef.width > _maxLineWidth)
|
{
|
||||||
|
float fontSize = this->getRenderingFontSize();
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
auto letterDefinition = _fontAtlas->_letterDefinitions;
|
||||||
|
auto tempLetterDefinition = letterDefinition;
|
||||||
|
float originalLineHeight = _lineHeight;
|
||||||
|
bool flag = true;
|
||||||
|
while (lambda()) {
|
||||||
|
++i;
|
||||||
|
float newFontSize = fontSize - i;
|
||||||
|
flag = false;
|
||||||
|
if (newFontSize <= 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
float scale = newFontSize / fontSize;
|
||||||
|
std::swap(_fontAtlas->_letterDefinitions, tempLetterDefinition);
|
||||||
|
_fontAtlas->scaleFontLetterDefinition(scale);
|
||||||
|
this->setLineHeight(originalLineHeight * scale);
|
||||||
|
if (_maxLineWidth > 0.f && !_lineBreakWithoutSpaces)
|
||||||
{
|
{
|
||||||
_linesWidth.push_back(letterRight);
|
multilineTextWrapByWord();
|
||||||
letterRight = 0.f;
|
|
||||||
lineIndex++;
|
|
||||||
nextLetterX = 0.f;
|
|
||||||
nextLetterY -= _lineHeight + lineSpacing;
|
|
||||||
letterPosition.x = letterDef.offsetX / contentScaleFactor;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
letterPosition.x = letterX;
|
multilineTextWrapByChar();
|
||||||
}
|
}
|
||||||
letterPosition.y = (nextLetterY - letterDef.offsetY) / contentScaleFactor;
|
computeAlignmentOffset();
|
||||||
recordLetterInfo(letterPosition, character, index, lineIndex);
|
tempLetterDefinition = letterDefinition;
|
||||||
|
|
||||||
if (_horizontalKernings && index < textLen - 1)
|
|
||||||
nextLetterX += _horizontalKernings[index + 1];
|
|
||||||
nextLetterX += letterDef.xAdvance + _additionalKerning;
|
|
||||||
|
|
||||||
letterRight = letterPosition.x + letterDef.width;
|
|
||||||
|
|
||||||
if (highestY < letterPosition.y)
|
|
||||||
highestY = letterPosition.y;
|
|
||||||
if (lowestY > letterPosition.y - letterDef.height)
|
|
||||||
lowestY = letterPosition.y - letterDef.height;
|
|
||||||
if (longestLine < letterRight)
|
|
||||||
longestLine = letterRight;
|
|
||||||
}
|
}
|
||||||
|
this->setLineHeight(originalLineHeight);
|
||||||
|
std::swap(_fontAtlas->_letterDefinitions, letterDefinition);
|
||||||
|
|
||||||
_linesWidth.push_back(letterRight);
|
if (!flag) {
|
||||||
|
if (fontSize - i >= 0) {
|
||||||
_numberOfLines = lineIndex + 1;
|
this->scaleFontSizeDown(fontSize - i);
|
||||||
_textDesiredHeight = (_numberOfLines * _lineHeight) / contentScaleFactor;
|
}
|
||||||
if (_numberOfLines > 1)
|
}
|
||||||
_textDesiredHeight += (_numberOfLines - 1) * _lineSpacing;
|
|
||||||
Size contentSize(_labelWidth, _labelHeight);
|
|
||||||
if (_labelWidth <= 0.f)
|
|
||||||
contentSize.width = longestLine;
|
|
||||||
if (_labelHeight <= 0.f)
|
|
||||||
contentSize.height = _textDesiredHeight;
|
|
||||||
setContentSize(contentSize);
|
|
||||||
|
|
||||||
_tailoredTopY = contentSize.height;
|
|
||||||
_tailoredBottomY = 0.f;
|
|
||||||
if (highestY > 0.f)
|
|
||||||
_tailoredTopY = contentSize.height + highestY;
|
|
||||||
if (lowestY < -_textDesiredHeight)
|
|
||||||
_tailoredBottomY = _textDesiredHeight + lowestY;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Label::recordLetterInfo(const cocos2d::Vec2& point, char16_t utf16Char, int letterIndex, int lineIndex)
|
void Label::recordLetterInfo(const cocos2d::Vec2& point, char16_t utf16Char, int letterIndex, int lineIndex)
|
||||||
|
|
|
@ -1135,7 +1135,7 @@ std::string Sprite::getDescription() const
|
||||||
return StringUtils::format("<Sprite | Tag = %d, TextureID = %d>", _tag, texture_id );
|
return StringUtils::format("<Sprite | Tag = %d, TextureID = %d>", _tag, texture_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
PolygonInfo Sprite::getPolygonInfo() const
|
PolygonInfo& Sprite::getPolygonInfo()
|
||||||
{
|
{
|
||||||
return _polyInfo;
|
return _polyInfo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,6 +403,19 @@ public:
|
||||||
*/
|
*/
|
||||||
CC_DEPRECATED_ATTRIBUTE void setFlipY(bool flippedY) { setFlippedY(flippedY); };
|
CC_DEPRECATED_ATTRIBUTE void setFlipY(bool flippedY) { setFlippedY(flippedY); };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns a reference of the polygon information associated with this sprite
|
||||||
|
*
|
||||||
|
* @return a copy of PolygonInfo
|
||||||
|
*/
|
||||||
|
PolygonInfo& getPolygonInfo();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the sprite to use this new PolygonInfo
|
||||||
|
*
|
||||||
|
* @param PolygonInfo the polygon information object
|
||||||
|
*/
|
||||||
|
void setPolygonInfo(const PolygonInfo& info);
|
||||||
//
|
//
|
||||||
// Overrides
|
// Overrides
|
||||||
//
|
//
|
||||||
|
@ -564,20 +577,6 @@ CC_CONSTRUCTOR_ACCESS:
|
||||||
*/
|
*/
|
||||||
virtual bool initWithFile(const std::string& filename, const Rect& rect);
|
virtual bool initWithFile(const std::string& filename, const Rect& rect);
|
||||||
|
|
||||||
/**
|
|
||||||
* returns a copy of the polygon information associated with this sprite
|
|
||||||
* because this is a copy process it is slower than getting the reference, so use wisely
|
|
||||||
*
|
|
||||||
* @return a copy of PolygonInfo
|
|
||||||
*/
|
|
||||||
PolygonInfo getPolygonInfo() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* set the sprite to use this new PolygonInfo
|
|
||||||
*
|
|
||||||
* @param PolygonInfo the polygon information object
|
|
||||||
*/
|
|
||||||
void setPolygonInfo(const PolygonInfo& info);
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void updateColor() override;
|
void updateColor() override;
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
|
||||||
|
#ifndef __COCOSSTUDIOEXTENSION_H__
|
||||||
|
#define __COCOSSTUDIOEXTENSION_H__
|
||||||
|
|
||||||
|
#include "math/CCAffineTransform.h"
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
struct CC_DLL ResouceData
|
||||||
|
{
|
||||||
|
int type;
|
||||||
|
std::string file;
|
||||||
|
std::string plist;
|
||||||
|
|
||||||
|
ResouceData()
|
||||||
|
{
|
||||||
|
type = 0;
|
||||||
|
file = "";
|
||||||
|
plist = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
ResouceData(int iType, std::string sFile, std::string sPlist)
|
||||||
|
{
|
||||||
|
type = iType;
|
||||||
|
file = sFile;
|
||||||
|
plist = sPlist;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class CC_DLL NodeExtension
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NodeExtension();
|
||||||
|
~NodeExtension();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
NS_CC_END
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
@ -433,6 +433,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
|
||||||
<ClCompile Include="..\base\ccFPSImages.c" />
|
<ClCompile Include="..\base\ccFPSImages.c" />
|
||||||
<ClCompile Include="..\base\CCIMEDispatcher.cpp" />
|
<ClCompile Include="..\base\CCIMEDispatcher.cpp" />
|
||||||
<ClCompile Include="..\base\CCNinePatchImageParser.cpp" />
|
<ClCompile Include="..\base\CCNinePatchImageParser.cpp" />
|
||||||
|
<ClCompile Include="..\base\CCStencilStateManager.cpp" />
|
||||||
<ClCompile Include="..\base\CCNS.cpp" />
|
<ClCompile Include="..\base\CCNS.cpp" />
|
||||||
<ClCompile Include="..\base\CCProfiling.cpp" />
|
<ClCompile Include="..\base\CCProfiling.cpp" />
|
||||||
<ClCompile Include="..\base\CCProperties.cpp" />
|
<ClCompile Include="..\base\CCProperties.cpp" />
|
||||||
|
@ -652,6 +653,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
|
||||||
<ClCompile Include="..\ui\UIListView.cpp" />
|
<ClCompile Include="..\ui\UIListView.cpp" />
|
||||||
<ClCompile Include="..\ui\UILoadingBar.cpp" />
|
<ClCompile Include="..\ui\UILoadingBar.cpp" />
|
||||||
<ClCompile Include="..\ui\UIPageView.cpp" />
|
<ClCompile Include="..\ui\UIPageView.cpp" />
|
||||||
|
<ClCompile Include="..\ui\UIPageViewIndicator.cpp" />
|
||||||
<ClCompile Include="..\ui\UIRelativeBox.cpp" />
|
<ClCompile Include="..\ui\UIRelativeBox.cpp" />
|
||||||
<ClCompile Include="..\ui\UIRichText.cpp" />
|
<ClCompile Include="..\ui\UIRichText.cpp" />
|
||||||
<ClCompile Include="..\ui\UIScale9Sprite.cpp" />
|
<ClCompile Include="..\ui\UIScale9Sprite.cpp" />
|
||||||
|
@ -1014,6 +1016,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
|
||||||
<ClInclude Include="..\base\ccMacros.h" />
|
<ClInclude Include="..\base\ccMacros.h" />
|
||||||
<ClInclude Include="..\base\CCMap.h" />
|
<ClInclude Include="..\base\CCMap.h" />
|
||||||
<ClInclude Include="..\base\CCNinePatchImageParser.h" />
|
<ClInclude Include="..\base\CCNinePatchImageParser.h" />
|
||||||
|
<ClInclude Include="..\base\CCStencilStateManager.h" />
|
||||||
<ClInclude Include="..\base\CCNS.h" />
|
<ClInclude Include="..\base\CCNS.h" />
|
||||||
<ClInclude Include="..\base\CCProfiling.h" />
|
<ClInclude Include="..\base\CCProfiling.h" />
|
||||||
<ClInclude Include="..\base\CCProperties.h" />
|
<ClInclude Include="..\base\CCProperties.h" />
|
||||||
|
@ -1254,6 +1257,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
|
||||||
<ClInclude Include="..\storage\local-storage\LocalStorage.h" />
|
<ClInclude Include="..\storage\local-storage\LocalStorage.h" />
|
||||||
<ClInclude Include="..\ui\CocosGUI.h" />
|
<ClInclude Include="..\ui\CocosGUI.h" />
|
||||||
<ClInclude Include="..\ui\GUIExport.h" />
|
<ClInclude Include="..\ui\GUIExport.h" />
|
||||||
|
<ClInclude Include="..\ui\UIAbstractCheckButton.h" />
|
||||||
<ClInclude Include="..\ui\UIButton.h" />
|
<ClInclude Include="..\ui\UIButton.h" />
|
||||||
<ClInclude Include="..\ui\UICheckBox.h" />
|
<ClInclude Include="..\ui\UICheckBox.h" />
|
||||||
<ClInclude Include="..\ui\UIDeprecated.h" />
|
<ClInclude Include="..\ui\UIDeprecated.h" />
|
||||||
|
@ -1382,4 +1386,4 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="physics">
|
<Filter Include="physics">
|
||||||
|
@ -934,6 +934,9 @@
|
||||||
<ClCompile Include="..\ui\UIPageView.cpp">
|
<ClCompile Include="..\ui\UIPageView.cpp">
|
||||||
<Filter>ui\UIWidgets\ScrollWidget</Filter>
|
<Filter>ui\UIWidgets\ScrollWidget</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\ui\UIPageViewIndicator.cpp">
|
||||||
|
<Filter>ui\UIWidgets\ScrollWidget</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\ui\UIScrollView.cpp">
|
<ClCompile Include="..\ui\UIScrollView.cpp">
|
||||||
<Filter>ui\UIWidgets\ScrollWidget</Filter>
|
<Filter>ui\UIWidgets\ScrollWidget</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -1893,6 +1896,9 @@
|
||||||
<ClCompile Include="..\base\CCNinePatchImageParser.cpp">
|
<ClCompile Include="..\base\CCNinePatchImageParser.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\base\CCStencilStateManager.cpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\base\CCNinePatchImageParser.cpp" />
|
<ClCompile Include="..\base\CCNinePatchImageParser.cpp" />
|
||||||
<ClCompile Include="..\renderer\CCFrameBuffer.cpp">
|
<ClCompile Include="..\renderer\CCFrameBuffer.cpp">
|
||||||
<Filter>renderer</Filter>
|
<Filter>renderer</Filter>
|
||||||
|
@ -3725,6 +3731,9 @@
|
||||||
<ClInclude Include="..\base\CCNinePatchImageParser.h">
|
<ClInclude Include="..\base\CCNinePatchImageParser.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\base\CCStencilStateManager.h">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\base\CCNinePatchImageParser.h" />
|
<ClInclude Include="..\base\CCNinePatchImageParser.h" />
|
||||||
<ClInclude Include="..\renderer\CCFrameBuffer.h">
|
<ClInclude Include="..\renderer\CCFrameBuffer.h">
|
||||||
<Filter>renderer</Filter>
|
<Filter>renderer</Filter>
|
||||||
|
@ -3776,6 +3785,9 @@
|
||||||
<Filter>network\Header Files</Filter>
|
<Filter>network\Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\Light3DReader\Light3DReader.h" />
|
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\Light3DReader\Light3DReader.h" />
|
||||||
|
<ClInclude Include="..\ui\UIAbstractCheckButton.h">
|
||||||
|
<Filter>ui</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\math\Mat4.inl">
|
<None Include="..\math\Mat4.inl">
|
||||||
|
@ -3804,4 +3816,4 @@
|
||||||
<Filter>3d</Filter>
|
<Filter>3d</Filter>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||||
|
@ -286,6 +286,7 @@
|
||||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\ccMacros.h" />
|
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\ccMacros.h" />
|
||||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCMap.h" />
|
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCMap.h" />
|
||||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCNinePatchImageParser.h" />
|
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCNinePatchImageParser.h" />
|
||||||
|
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCStencilStateManager.h" />
|
||||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCNS.h" />
|
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCNS.h" />
|
||||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCProfiling.h" />
|
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCProfiling.h" />
|
||||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCProperties.h" />
|
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCProperties.h" />
|
||||||
|
@ -917,6 +918,7 @@
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCIMEDispatcher.cpp" />
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCIMEDispatcher.cpp" />
|
||||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCNinePatchImageParser.cpp" />
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCNinePatchImageParser.cpp" />
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCStencilStateManager.cpp" />
|
||||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCNS.cpp" />
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCNS.cpp" />
|
||||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCProfiling.cpp" />
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCProfiling.cpp" />
|
||||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCProperties.cpp" />
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCProperties.cpp" />
|
||||||
|
@ -1153,6 +1155,7 @@
|
||||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIListView.cpp" />
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIListView.cpp" />
|
||||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UILoadingBar.cpp" />
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UILoadingBar.cpp" />
|
||||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIPageView.cpp" />
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIPageView.cpp" />
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIPageViewIndicator.cpp" />
|
||||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIRelativeBox.cpp" />
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIRelativeBox.cpp" />
|
||||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIRichText.cpp" />
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIRichText.cpp" />
|
||||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIScale9Sprite.cpp" />
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIScale9Sprite.cpp" />
|
||||||
|
@ -1285,4 +1288,4 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Text Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CMakeLists.txt" />
|
<Text Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CMakeLists.txt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="$(MSBuildThisFileDirectory)targetver.h" />
|
<ClInclude Include="$(MSBuildThisFileDirectory)targetver.h" />
|
||||||
|
@ -1812,6 +1812,9 @@
|
||||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCNinePatchImageParser.h">
|
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCNinePatchImageParser.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCStencilStateManager.h">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DConstraint.h">
|
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DConstraint.h">
|
||||||
<Filter>physics3d</Filter>
|
<Filter>physics3d</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -2325,6 +2328,9 @@
|
||||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIPageView.cpp">
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIPageView.cpp">
|
||||||
<Filter>ui\UIWidgets\ScrollWidget</Filter>
|
<Filter>ui\UIWidgets\ScrollWidget</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIPageViewIndicator.cpp">
|
||||||
|
<Filter>ui\UIWidgets\ScrollWidget</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIScrollView.cpp">
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIScrollView.cpp">
|
||||||
<Filter>ui\UIWidgets\ScrollWidget</Filter>
|
<Filter>ui\UIWidgets\ScrollWidget</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -3522,6 +3528,9 @@
|
||||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCNinePatchImageParser.cpp">
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCNinePatchImageParser.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCStencilStateManager.cpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DDebugDrawer.cpp">
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DDebugDrawer.cpp">
|
||||||
<Filter>physics3d</Filter>
|
<Filter>physics3d</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -3976,4 +3985,4 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Text Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CMakeLists.txt" />
|
<Text Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CMakeLists.txt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Debug|ARM">
|
<ProjectConfiguration Include="Debug|ARM">
|
||||||
|
@ -415,6 +415,7 @@
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\base\CCIMEDispatcher.cpp" />
|
<ClCompile Include="..\..\base\CCIMEDispatcher.cpp" />
|
||||||
<ClCompile Include="..\..\base\CCNinePatchImageParser.cpp" />
|
<ClCompile Include="..\..\base\CCNinePatchImageParser.cpp" />
|
||||||
|
<ClCompile Include="..\..\base\CCStencilStateManager.cpp" />
|
||||||
<ClCompile Include="..\..\base\CCNS.cpp" />
|
<ClCompile Include="..\..\base\CCNS.cpp" />
|
||||||
<ClCompile Include="..\..\base\CCProfiling.cpp" />
|
<ClCompile Include="..\..\base\CCProfiling.cpp" />
|
||||||
<ClCompile Include="..\..\base\CCProperties.cpp" />
|
<ClCompile Include="..\..\base\CCProperties.cpp" />
|
||||||
|
@ -653,6 +654,7 @@
|
||||||
<ClCompile Include="..\..\ui\UIListView.cpp" />
|
<ClCompile Include="..\..\ui\UIListView.cpp" />
|
||||||
<ClCompile Include="..\..\ui\UILoadingBar.cpp" />
|
<ClCompile Include="..\..\ui\UILoadingBar.cpp" />
|
||||||
<ClCompile Include="..\..\ui\UIPageView.cpp" />
|
<ClCompile Include="..\..\ui\UIPageView.cpp" />
|
||||||
|
<ClCompile Include="..\..\ui\UIPageViewIndicator.cpp" />
|
||||||
<ClCompile Include="..\..\ui\UIRelativeBox.cpp" />
|
<ClCompile Include="..\..\ui\UIRelativeBox.cpp" />
|
||||||
<ClCompile Include="..\..\ui\UIRichText.cpp" />
|
<ClCompile Include="..\..\ui\UIRichText.cpp" />
|
||||||
<ClCompile Include="..\..\ui\UIScale9Sprite.cpp" />
|
<ClCompile Include="..\..\ui\UIScale9Sprite.cpp" />
|
||||||
|
@ -1012,6 +1014,7 @@
|
||||||
<ClInclude Include="..\..\base\ccMacros.h" />
|
<ClInclude Include="..\..\base\ccMacros.h" />
|
||||||
<ClInclude Include="..\..\base\CCMap.h" />
|
<ClInclude Include="..\..\base\CCMap.h" />
|
||||||
<ClInclude Include="..\..\base\CCNinePatchImageParser.h" />
|
<ClInclude Include="..\..\base\CCNinePatchImageParser.h" />
|
||||||
|
<ClInclude Include="..\..\base\CCStencilStateManager.h" />
|
||||||
<ClInclude Include="..\..\base\CCNS.h" />
|
<ClInclude Include="..\..\base\CCNS.h" />
|
||||||
<ClInclude Include="..\..\base\CCProfiling.h" />
|
<ClInclude Include="..\..\base\CCProfiling.h" />
|
||||||
<ClInclude Include="..\..\base\CCProperties.h" />
|
<ClInclude Include="..\..\base\CCProperties.h" />
|
||||||
|
@ -1672,4 +1675,4 @@
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="Resource Files">
|
<Filter Include="Resource Files">
|
||||||
|
@ -1689,6 +1689,9 @@
|
||||||
<ClCompile Include="..\..\ui\UIPageView.cpp">
|
<ClCompile Include="..\..\ui\UIPageView.cpp">
|
||||||
<Filter>ui\UIWidgets\ScrollWidget</Filter>
|
<Filter>ui\UIWidgets\ScrollWidget</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\ui\UIPageViewIndicator.cpp">
|
||||||
|
<Filter>ui\UIWidgets\ScrollWidget</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\ui\UIScrollView.cpp">
|
<ClCompile Include="..\..\ui\UIScrollView.cpp">
|
||||||
<Filter>ui\UIWidgets\ScrollWidget</Filter>
|
<Filter>ui\UIWidgets\ScrollWidget</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -1764,6 +1767,9 @@
|
||||||
<ClCompile Include="..\..\base\CCNinePatchImageParser.cpp">
|
<ClCompile Include="..\..\base\CCNinePatchImageParser.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\base\CCStencilStateManager.cpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\renderer\CCMaterial.cpp">
|
<ClCompile Include="..\..\renderer\CCMaterial.cpp">
|
||||||
<Filter>renderer</Filter>
|
<Filter>renderer</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -3632,6 +3638,9 @@
|
||||||
<ClInclude Include="..\..\base\CCNinePatchImageParser.h">
|
<ClInclude Include="..\..\base\CCNinePatchImageParser.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\base\CCStencilStateManager.h">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\renderer\CCMaterial.h">
|
<ClInclude Include="..\..\renderer\CCMaterial.h">
|
||||||
<Filter>renderer</Filter>
|
<Filter>renderer</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -4014,4 +4023,4 @@
|
||||||
<Filter>3d</Filter>
|
<Filter>3d</Filter>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -132,6 +132,8 @@ Mesh::Mesh()
|
||||||
, _visibleChanged(nullptr)
|
, _visibleChanged(nullptr)
|
||||||
, _blendDirty(true)
|
, _blendDirty(true)
|
||||||
, _force2DQueue(false)
|
, _force2DQueue(false)
|
||||||
|
, _texFile("")
|
||||||
|
, _enableCheckTexture(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -270,6 +272,7 @@ bool Mesh::isVisible() const
|
||||||
|
|
||||||
void Mesh::setTexture(const std::string& texPath)
|
void Mesh::setTexture(const std::string& texPath)
|
||||||
{
|
{
|
||||||
|
_texFile = texPath;
|
||||||
auto tex = Director::getInstance()->getTextureCache()->addImage(texPath);
|
auto tex = Director::getInstance()->getTextureCache()->addImage(texPath);
|
||||||
setTexture(tex, NTextureData::Usage::Diffuse);
|
setTexture(tex, NTextureData::Usage::Diffuse);
|
||||||
}
|
}
|
||||||
|
@ -304,6 +307,7 @@ void Mesh::setTexture(Texture2D* tex, NTextureData::Usage usage)
|
||||||
}
|
}
|
||||||
|
|
||||||
bindMeshCommand();
|
bindMeshCommand();
|
||||||
|
_texFile = tex->getPath();
|
||||||
}
|
}
|
||||||
else if (usage == NTextureData::Usage::Normal) // currently only diffuse and normal are supported
|
else if (usage == NTextureData::Usage::Normal) // currently only diffuse and normal are supported
|
||||||
{
|
{
|
||||||
|
@ -378,6 +382,8 @@ void Mesh::draw(Renderer* renderer, float globalZOrder, const Mat4& transform, u
|
||||||
if (isTransparent)
|
if (isTransparent)
|
||||||
flags |= Node::FLAGS_RENDER_AS_3D;
|
flags |= Node::FLAGS_RENDER_AS_3D;
|
||||||
|
|
||||||
|
if (_enableCheckTexture)
|
||||||
|
this->checkTexture();
|
||||||
|
|
||||||
_meshCommand.init(globalZ,
|
_meshCommand.init(globalZ,
|
||||||
_material,
|
_material,
|
||||||
|
@ -700,4 +706,39 @@ GLuint Mesh::getIndexBuffer() const
|
||||||
{
|
{
|
||||||
return _meshIndexData->getIndexBuffer()->getVBO();
|
return _meshIndexData->getIndexBuffer()->getVBO();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Mesh::checkTexture()
|
||||||
|
{
|
||||||
|
Texture2D* cacheTex = nullptr;
|
||||||
|
auto& texture = _textures[NTextureData::Usage::Diffuse];
|
||||||
|
if (Director::getInstance()->getTextureCache()->isDirty())
|
||||||
|
{
|
||||||
|
cacheTex = Director::getInstance()->getTextureCache()->getTextureForKey(_texFile);
|
||||||
|
if (cacheTex == nullptr)
|
||||||
|
{
|
||||||
|
cacheTex = getDummyTexture();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (texture != nullptr && !texture->isValid())
|
||||||
|
{
|
||||||
|
cacheTex = getDummyTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cacheTex != nullptr && texture != cacheTex)
|
||||||
|
{
|
||||||
|
CC_SAFE_RETAIN(cacheTex);
|
||||||
|
CC_SAFE_RELEASE(texture);
|
||||||
|
texture = cacheTex;
|
||||||
|
|
||||||
|
if (_material) {
|
||||||
|
auto technique = _material->_currentTechnique;
|
||||||
|
for (auto& pass : technique->_passes)
|
||||||
|
{
|
||||||
|
pass->setTexture(texture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bindMeshCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -224,6 +224,20 @@ public:
|
||||||
*/
|
*/
|
||||||
void setForce2DQueue(bool force2D) { _force2DQueue = force2D; }
|
void setForce2DQueue(bool force2D) { _force2DQueue = force2D; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check texture
|
||||||
|
*/
|
||||||
|
void checkTexture();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set enable check texture, check texture each frame if eanble is true. It is false by default
|
||||||
|
*/
|
||||||
|
void setEnableCheckTexture(bool enableCheckTexture) { _enableCheckTexture = enableCheckTexture; }
|
||||||
|
/**
|
||||||
|
* check texture each frame?
|
||||||
|
*/
|
||||||
|
bool enableCheckTexture() const { return _enableCheckTexture; }
|
||||||
|
|
||||||
CC_CONSTRUCTOR_ACCESS:
|
CC_CONSTRUCTOR_ACCESS:
|
||||||
|
|
||||||
Mesh();
|
Mesh();
|
||||||
|
@ -234,7 +248,6 @@ protected:
|
||||||
void setLightUniforms(Pass* pass, Scene* scene, const Vec4& color, unsigned int lightmask);
|
void setLightUniforms(Pass* pass, Scene* scene, const Vec4& color, unsigned int lightmask);
|
||||||
void bindMeshCommand();
|
void bindMeshCommand();
|
||||||
|
|
||||||
std::vector<Texture2D *> _textureList; //textures that submesh is using
|
|
||||||
std::map<NTextureData::Usage, Texture2D*> _textures; //textures that submesh is using
|
std::map<NTextureData::Usage, Texture2D*> _textures; //textures that submesh is using
|
||||||
MeshSkin* _skin; //skin
|
MeshSkin* _skin; //skin
|
||||||
bool _visible; // is the submesh visible
|
bool _visible; // is the submesh visible
|
||||||
|
@ -265,6 +278,9 @@ protected:
|
||||||
std::vector<float> _spotLightUniformInnerAngleCosValues;
|
std::vector<float> _spotLightUniformInnerAngleCosValues;
|
||||||
std::vector<float> _spotLightUniformOuterAngleCosValues;
|
std::vector<float> _spotLightUniformOuterAngleCosValues;
|
||||||
std::vector<float> _spotLightUniformRangeInverseValues;
|
std::vector<float> _spotLightUniformRangeInverseValues;
|
||||||
|
|
||||||
|
std::string _texFile;
|
||||||
|
bool _enableCheckTexture;
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of 3d group
|
// end of 3d group
|
||||||
|
|
|
@ -286,6 +286,7 @@ bool Sprite3D::init()
|
||||||
|
|
||||||
bool Sprite3D::initWithFile(const std::string& path)
|
bool Sprite3D::initWithFile(const std::string& path)
|
||||||
{
|
{
|
||||||
|
_aabbDirty = true;
|
||||||
_meshes.clear();
|
_meshes.clear();
|
||||||
_meshVertexDatas.clear();
|
_meshVertexDatas.clear();
|
||||||
CC_SAFE_RELEASE_NULL(_skeleton);
|
CC_SAFE_RELEASE_NULL(_skeleton);
|
||||||
|
|
|
@ -200,6 +200,11 @@ public:
|
||||||
*/
|
*/
|
||||||
void setForce2DQueue(bool force2D);
|
void setForce2DQueue(bool force2D);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get meshes used in sprite 3d
|
||||||
|
*/
|
||||||
|
const Vector<Mesh*>& getMeshes() const { return _meshes; }
|
||||||
|
|
||||||
CC_CONSTRUCTOR_ACCESS:
|
CC_CONSTRUCTOR_ACCESS:
|
||||||
|
|
||||||
Sprite3D();
|
Sprite3D();
|
||||||
|
|
|
@ -548,7 +548,7 @@ bool Terrain::getIntersectionPoint(const Ray & ray_, Vec3 & intersectionPoint) c
|
||||||
getWorldToNodeTransform().transformPoint(&(ray._origin));
|
getWorldToNodeTransform().transformPoint(&(ray._origin));
|
||||||
|
|
||||||
std::set<Chunk *> closeList;
|
std::set<Chunk *> closeList;
|
||||||
Vec2 start = Vec2(ray._origin.x,ray._origin.z);
|
Vec2 start = Vec2(ray_._origin.x,ray_._origin.z);
|
||||||
Vec2 dir = Vec2(ray._direction.x,ray._direction.z);
|
Vec2 dir = Vec2(ray._direction.x,ray._direction.z);
|
||||||
start = convertToTerrainSpace(start);
|
start = convertToTerrainSpace(start);
|
||||||
start.x /=(_terrainData._chunkSize.width+1);
|
start.x /=(_terrainData._chunkSize.width+1);
|
||||||
|
|
|
@ -177,7 +177,7 @@ private:
|
||||||
/*
|
/*
|
||||||
*terrain vertices internal data format
|
*terrain vertices internal data format
|
||||||
**/
|
**/
|
||||||
struct TerrainVertexData
|
struct CC_DLL TerrainVertexData
|
||||||
{
|
{
|
||||||
/*constructor*/
|
/*constructor*/
|
||||||
TerrainVertexData(){};
|
TerrainVertexData(){};
|
||||||
|
@ -192,7 +192,7 @@ private:
|
||||||
cocos2d::Vec3 _normal;
|
cocos2d::Vec3 _normal;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct QuadTree;
|
struct CC_DLL QuadTree;
|
||||||
/*
|
/*
|
||||||
*the terminal node of quad, use to subdivision terrain mesh and LOD
|
*the terminal node of quad, use to subdivision terrain mesh and LOD
|
||||||
**/
|
**/
|
||||||
|
@ -267,7 +267,7 @@ private:
|
||||||
*QuadTree
|
*QuadTree
|
||||||
* @breif use to hierarchically frustum culling and set LOD
|
* @breif use to hierarchically frustum culling and set LOD
|
||||||
**/
|
**/
|
||||||
struct QuadTree
|
struct CC_DLL QuadTree
|
||||||
{
|
{
|
||||||
/**constructor*/
|
/**constructor*/
|
||||||
QuadTree(int x, int y, int width, int height, Terrain * terrain);
|
QuadTree(int x, int y, int width, int height, Terrain * terrain);
|
||||||
|
|
|
@ -107,6 +107,7 @@ math/Vec2.cpp \
|
||||||
math/Vec3.cpp \
|
math/Vec3.cpp \
|
||||||
math/Vec4.cpp \
|
math/Vec4.cpp \
|
||||||
base/CCNinePatchImageParser.cpp \
|
base/CCNinePatchImageParser.cpp \
|
||||||
|
base/CCStencilStateManager.cpp \
|
||||||
base/CCAsyncTaskPool.cpp \
|
base/CCAsyncTaskPool.cpp \
|
||||||
base/CCAutoreleasePool.cpp \
|
base/CCAutoreleasePool.cpp \
|
||||||
base/CCConfiguration.cpp \
|
base/CCConfiguration.cpp \
|
||||||
|
|
|
@ -96,7 +96,7 @@ if(WINDOWS)
|
||||||
endforeach()
|
endforeach()
|
||||||
list(APPEND PLATFORM_SPECIFIC_LIBS ws2_32 winmm)
|
list(APPEND PLATFORM_SPECIFIC_LIBS ws2_32 winmm)
|
||||||
elseif(LINUX)
|
elseif(LINUX)
|
||||||
foreach(_pkg OPENGL GLEW GLFW3 FMODEX FONTCONFIG THREADS GTK3)
|
foreach(_pkg OPENGL GLEW GLFW3 FMOD FONTCONFIG THREADS GTK3)
|
||||||
cocos_use_pkg(cocos2d ${_pkg})
|
cocos_use_pkg(cocos2d ${_pkg})
|
||||||
endforeach()
|
endforeach()
|
||||||
elseif(MACOSX OR APPLE)
|
elseif(MACOSX OR APPLE)
|
||||||
|
|
|
@ -24,8 +24,6 @@
|
||||||
|
|
||||||
#include "platform/CCPlatformConfig.h"
|
#include "platform/CCPlatformConfig.h"
|
||||||
|
|
||||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
|
||||||
|
|
||||||
#include "audio/include/AudioEngine.h"
|
#include "audio/include/AudioEngine.h"
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
@ -40,6 +38,8 @@
|
||||||
#include "win32/AudioEngine-win32.h"
|
#include "win32/AudioEngine-win32.h"
|
||||||
#elif CC_TARGET_PLATFORM == CC_PLATFORM_WINRT
|
#elif CC_TARGET_PLATFORM == CC_PLATFORM_WINRT
|
||||||
#include "winrt/AudioEngine-winrt.h"
|
#include "winrt/AudioEngine-winrt.h"
|
||||||
|
#elif CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||||
|
#include "linux/AudioEngine-linux.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TIME_DELAY_PRECISION 0.0001
|
#define TIME_DELAY_PRECISION 0.0001
|
||||||
|
@ -538,5 +538,3 @@ void AudioEngine::addTask(const std::function<void()>& task)
|
||||||
s_threadPool->addTask(task);
|
s_threadPool->addTask(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -15,10 +15,9 @@ if(WINDOWS)
|
||||||
|
|
||||||
elseif(LINUX)
|
elseif(LINUX)
|
||||||
set(COCOS_AUDIO_PLATFORM_SRC
|
set(COCOS_AUDIO_PLATFORM_SRC
|
||||||
audio/linux/SimpleAudioEngineFMOD.cpp
|
audio/linux/SimpleAudioEngine.cpp
|
||||||
audio/linux/FmodAudioPlayer.cpp
|
audio/linux/AudioEngine-linux.h
|
||||||
audio/linux/FmodAudioPlayer.h
|
audio/linux/AudioEngine-linux.cpp
|
||||||
audio/linux/AudioPlayer.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
elseif(MACOSX)
|
elseif(MACOSX)
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "platform/CCPlatformConfig.h"
|
#include "platform/CCPlatformConfig.h"
|
||||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
|
||||||
|
|
||||||
#ifndef __AUDIO_ENGINE_H_
|
#ifndef __AUDIO_ENGINE_H_
|
||||||
#define __AUDIO_ENGINE_H_
|
#define __AUDIO_ENGINE_H_
|
||||||
|
@ -360,4 +359,3 @@ NS_CC_END
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
#endif // __AUDIO_ENGINE_H_
|
#endif // __AUDIO_ENGINE_H_
|
||||||
#endif
|
|
||||||
|
|
|
@ -0,0 +1,302 @@
|
||||||
|
/**
|
||||||
|
* @author cesarpachon
|
||||||
|
*/
|
||||||
|
#include <cstring>
|
||||||
|
#include "AudioEngine-linux.h"
|
||||||
|
#include "cocos2d.h"
|
||||||
|
using namespace cocos2d;
|
||||||
|
using namespace cocos2d::experimental;
|
||||||
|
|
||||||
|
AudioEngineImpl * g_AudioEngineImpl = nullptr;
|
||||||
|
|
||||||
|
void ERRCHECKWITHEXIT(FMOD_RESULT result) {
|
||||||
|
if (result != FMOD_OK) {
|
||||||
|
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ERRCHECK(FMOD_RESULT result) {
|
||||||
|
if (result != FMOD_OK) {
|
||||||
|
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
FMOD_RESULT F_CALLBACK channelCallback(FMOD_CHANNELCONTROL *channelcontrol,
|
||||||
|
FMOD_CHANNELCONTROL_TYPE controltype,
|
||||||
|
FMOD_CHANNELCONTROL_CALLBACK_TYPE callbacktype,
|
||||||
|
void *commandData1, void *commandData2)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(controltype == FMOD_CHANNELCONTROL_CHANNEL && callbacktype == FMOD_CHANNELCONTROL_CALLBACK_END){
|
||||||
|
g_AudioEngineImpl->onSoundFinished((FMOD::Channel *)channelcontrol);
|
||||||
|
}else{
|
||||||
|
}
|
||||||
|
return FMOD_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AudioEngineImpl::AudioEngineImpl(){
|
||||||
|
};
|
||||||
|
|
||||||
|
AudioEngineImpl::~AudioEngineImpl(){
|
||||||
|
FMOD_RESULT result;
|
||||||
|
result = pSystem->close();
|
||||||
|
ERRCHECKWITHEXIT(result);
|
||||||
|
result = pSystem->release();
|
||||||
|
ERRCHECKWITHEXIT(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
bool AudioEngineImpl::init(){
|
||||||
|
FMOD_RESULT result;
|
||||||
|
/*
|
||||||
|
Create a System object and initialize.
|
||||||
|
*/
|
||||||
|
result = FMOD::System_Create(&pSystem);
|
||||||
|
ERRCHECKWITHEXIT(result);
|
||||||
|
|
||||||
|
result = pSystem->setOutput(FMOD_OUTPUTTYPE_PULSEAUDIO);
|
||||||
|
ERRCHECKWITHEXIT(result);
|
||||||
|
|
||||||
|
result = pSystem->init(32, FMOD_INIT_NORMAL, 0);
|
||||||
|
ERRCHECKWITHEXIT(result);
|
||||||
|
|
||||||
|
mapChannelInfo.clear();
|
||||||
|
mapSound.clear();
|
||||||
|
|
||||||
|
auto scheduler = cocos2d::Director::getInstance()->getScheduler();
|
||||||
|
scheduler->schedule(schedule_selector(AudioEngineImpl::update), this, 0.05f, false);
|
||||||
|
|
||||||
|
g_AudioEngineImpl = this;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
int AudioEngineImpl::play2d(const std::string &fileFullPath ,bool loop ,float volume){
|
||||||
|
int id = preload(fileFullPath, nullptr);
|
||||||
|
if(id >= 0){
|
||||||
|
mapChannelInfo[id].loop=loop;
|
||||||
|
mapChannelInfo[id].channel->setPaused(true);
|
||||||
|
mapChannelInfo[id].volume = volume;
|
||||||
|
AudioEngine::_audioIDInfoMap[id].state = AudioEngine::AudioState::PAUSED;
|
||||||
|
resume(id);
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
};
|
||||||
|
|
||||||
|
void AudioEngineImpl::setVolume(int audioID,float volume){
|
||||||
|
try{
|
||||||
|
mapChannelInfo[audioID].channel->setVolume(volume);
|
||||||
|
}catch(const std::out_of_range& oor){
|
||||||
|
printf("AudioEngineImpl::setVolume: invalid audioID: %d\n", audioID);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void AudioEngineImpl::setLoop(int audioID, bool loop){
|
||||||
|
try{
|
||||||
|
mapChannelInfo[audioID].channel->setLoopCount(loop?-1:0);
|
||||||
|
}catch(const std::out_of_range& oor){
|
||||||
|
printf("AudioEngineImpl::setLoop: invalid audioID: %d\n", audioID);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
bool AudioEngineImpl::pause(int audioID){
|
||||||
|
try{
|
||||||
|
mapChannelInfo[audioID].channel->setPaused(true);
|
||||||
|
AudioEngine::_audioIDInfoMap[audioID].state = AudioEngine::AudioState::PAUSED;
|
||||||
|
return true;
|
||||||
|
}catch(const std::out_of_range& oor){
|
||||||
|
printf("AudioEngineImpl::pause: invalid audioID: %d\n", audioID);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
bool AudioEngineImpl::resume(int audioID){
|
||||||
|
try{
|
||||||
|
|
||||||
|
if(!mapChannelInfo[audioID].channel){
|
||||||
|
FMOD::Channel *channel = nullptr;
|
||||||
|
FMOD::ChannelGroup *channelgroup = nullptr;
|
||||||
|
//starts the sound in pause mode, use the channel to unpause
|
||||||
|
FMOD_RESULT result = pSystem->playSound(mapChannelInfo[audioID].sound, channelgroup, true, &channel);
|
||||||
|
if(ERRCHECK(result)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
channel->setMode(mapChannelInfo[audioID].loop?FMOD_LOOP_NORMAL:FMOD_LOOP_OFF);
|
||||||
|
channel->setLoopCount(mapChannelInfo[audioID].loop?-1:0);
|
||||||
|
channel->setVolume(mapChannelInfo[audioID].volume);
|
||||||
|
channel->setUserData((void *)mapChannelInfo[audioID].id);
|
||||||
|
mapChannelInfo[audioID].channel = channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
mapChannelInfo[audioID].channel->setPaused(false);
|
||||||
|
AudioEngine::_audioIDInfoMap[audioID].state = AudioEngine::AudioState::PLAYING;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}catch(const std::out_of_range& oor){
|
||||||
|
printf("AudioEngineImpl::resume: invalid audioID: %d\n", audioID);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
bool AudioEngineImpl::stop(int audioID){
|
||||||
|
try{
|
||||||
|
mapChannelInfo[audioID].channel->stop();
|
||||||
|
mapChannelInfo[audioID].channel = nullptr;
|
||||||
|
return true;
|
||||||
|
}catch(const std::out_of_range& oor){
|
||||||
|
printf("AudioEngineImpl::stop: invalid audioID: %d\n", audioID);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void AudioEngineImpl::stopAll(){
|
||||||
|
for (auto it = mapChannelInfo.begin(); it != mapChannelInfo.end(); ++it) {
|
||||||
|
ChannelInfo & audioRef = it->second;
|
||||||
|
audioRef.channel->stop();
|
||||||
|
audioRef.channel = nullptr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
float AudioEngineImpl::getDuration(int audioID){
|
||||||
|
try{
|
||||||
|
FMOD::Sound * sound = mapChannelInfo[audioID].sound;
|
||||||
|
unsigned int length;
|
||||||
|
FMOD_RESULT result = sound->getLength(&length, FMOD_TIMEUNIT_MS);
|
||||||
|
ERRCHECK(result);
|
||||||
|
float duration = (float)length / 1000.0f;
|
||||||
|
return duration;
|
||||||
|
}catch(const std::out_of_range& oor){
|
||||||
|
printf("AudioEngineImpl::getDuration: invalid audioID: %d\n", audioID);
|
||||||
|
return AudioEngine::TIME_UNKNOWN;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
float AudioEngineImpl::getCurrentTime(int audioID){
|
||||||
|
try{
|
||||||
|
unsigned int position;
|
||||||
|
FMOD_RESULT result = mapChannelInfo[audioID].channel->getPosition(&position, FMOD_TIMEUNIT_MS);
|
||||||
|
ERRCHECK(result);
|
||||||
|
float currenttime = position /1000.0f;
|
||||||
|
return currenttime;
|
||||||
|
}catch(const std::out_of_range& oor){
|
||||||
|
printf("AudioEngineImpl::getCurrentTime: invalid audioID: %d\n", audioID);
|
||||||
|
return AudioEngine::TIME_UNKNOWN;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
bool AudioEngineImpl::setCurrentTime(int audioID, float time){
|
||||||
|
try{
|
||||||
|
unsigned int position = (unsigned int)(time * 1000.0f);
|
||||||
|
FMOD_RESULT result = mapChannelInfo[audioID].channel->setPosition(position, FMOD_TIMEUNIT_MS);
|
||||||
|
ERRCHECK(result);
|
||||||
|
}catch(const std::out_of_range& oor){
|
||||||
|
printf("AudioEngineImpl::setCurrentTime: invalid audioID: %d\n", audioID);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void AudioEngineImpl::setFinishCallback(int audioID, const std::function<void (int, const std::string &)> &callback){
|
||||||
|
try{
|
||||||
|
FMOD::Channel * channel = mapChannelInfo[audioID].channel;
|
||||||
|
mapChannelInfo[audioID].callback = callback;
|
||||||
|
FMOD_RESULT result = channel->setCallback(channelCallback);
|
||||||
|
ERRCHECK(result);
|
||||||
|
}catch(const std::out_of_range& oor){
|
||||||
|
printf("AudioEngineImpl::setFinishCallback: invalid audioID: %d\n", audioID);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void AudioEngineImpl::onSoundFinished(FMOD::Channel * channel){
|
||||||
|
size_t id;
|
||||||
|
try{
|
||||||
|
void * data;
|
||||||
|
channel->getUserData(&data);
|
||||||
|
id = (size_t) data;
|
||||||
|
if(mapChannelInfo[id].callback){
|
||||||
|
mapChannelInfo[id].callback(id, mapChannelInfo[id].path);
|
||||||
|
}
|
||||||
|
mapChannelInfo[id].channel = nullptr;
|
||||||
|
}catch(const std::out_of_range& oor){
|
||||||
|
printf("AudioEngineImpl::onSoundFinished: invalid audioID: %d\n", id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void AudioEngineImpl::uncache(const std::string& path){
|
||||||
|
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(path);
|
||||||
|
std::map<std::string, FMOD::Sound *>::const_iterator it = mapSound.find(fullPath);
|
||||||
|
if(it!=mapSound.end()){
|
||||||
|
FMOD::Sound * sound = it->second;
|
||||||
|
if(sound){
|
||||||
|
sound->release();
|
||||||
|
}
|
||||||
|
mapSound.erase(it);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void AudioEngineImpl::uncacheAll(){
|
||||||
|
for (auto it = mapSound.cbegin(); it != mapSound.cend(); ++it) {
|
||||||
|
auto sound = it->second;
|
||||||
|
if(sound){
|
||||||
|
sound->release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mapSound.clear();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
int AudioEngineImpl::preload(const std::string& filePath, std::function<void(bool isSuccess)> callback){
|
||||||
|
FMOD::Sound * sound = findSound(filePath);
|
||||||
|
if(!sound){
|
||||||
|
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filePath);
|
||||||
|
FMOD_RESULT result = pSystem->createSound(fullPath.c_str(), FMOD_LOOP_OFF, 0, &sound);
|
||||||
|
if (ERRCHECK(result)){
|
||||||
|
printf("sound effect in %s could not be preload\n", filePath.c_str());
|
||||||
|
if(callback){
|
||||||
|
callback(false);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
mapSound[fullPath] = sound;
|
||||||
|
}
|
||||||
|
|
||||||
|
int id = mapChannelInfo.size() + 1;
|
||||||
|
auto& chanelInfo = mapChannelInfo[id];
|
||||||
|
chanelInfo.sound = sound;
|
||||||
|
chanelInfo.id = (size_t) id;
|
||||||
|
chanelInfo.channel = nullptr;
|
||||||
|
chanelInfo.callback = nullptr;
|
||||||
|
chanelInfo.path = filePath;
|
||||||
|
//we are going to use UserData to store pointer to Channel when playing
|
||||||
|
chanelInfo.sound->setUserData((void *)id);
|
||||||
|
|
||||||
|
if(callback){
|
||||||
|
callback(true);
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void AudioEngineImpl::update(float dt){
|
||||||
|
pSystem->update();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
FMOD::Sound * AudioEngineImpl::findSound(const std::string &path){
|
||||||
|
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(path);
|
||||||
|
std::map<std::string, FMOD::Sound *>::const_iterator it = mapSound.find(fullPath);
|
||||||
|
return (it!=mapSound.end())?(it->second):nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FMOD::Channel * AudioEngineImpl::getChannel(FMOD::Sound *sound){
|
||||||
|
size_t id;
|
||||||
|
void * data;
|
||||||
|
sound->getUserData(&data);
|
||||||
|
id = (size_t) data;
|
||||||
|
return mapChannelInfo[id].channel;
|
||||||
|
};
|
|
@ -0,0 +1,106 @@
|
||||||
|
/****************************************************************************
|
||||||
|
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 "platform/CCPlatformConfig.h"
|
||||||
|
|
||||||
|
#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||||
|
|
||||||
|
#ifndef __AUDIO_ENGINE_LINUX_H_
|
||||||
|
#define __AUDIO_ENGINE_LINUX_H_
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <iostream>
|
||||||
|
#include <map>
|
||||||
|
#include "fmod.hpp"
|
||||||
|
#include "fmod_errors.h"
|
||||||
|
#include "AudioEngine.h"
|
||||||
|
|
||||||
|
#include "base/CCRef.h"
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
namespace experimental{
|
||||||
|
#define MAX_AUDIOINSTANCES 32
|
||||||
|
|
||||||
|
class CC_DLL AudioEngineImpl : public cocos2d::Ref
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AudioEngineImpl();
|
||||||
|
~AudioEngineImpl();
|
||||||
|
|
||||||
|
bool init();
|
||||||
|
int play2d(const std::string &fileFullPath ,bool loop ,float volume);
|
||||||
|
void setVolume(int audioID,float volume);
|
||||||
|
void setLoop(int audioID, bool loop);
|
||||||
|
bool pause(int audioID);
|
||||||
|
bool resume(int audioID);
|
||||||
|
bool stop(int audioID);
|
||||||
|
void stopAll();
|
||||||
|
float getDuration(int audioID);
|
||||||
|
float getCurrentTime(int audioID);
|
||||||
|
bool setCurrentTime(int audioID, float time);
|
||||||
|
void setFinishCallback(int audioID, const std::function<void (int, const std::string &)> &callback);
|
||||||
|
|
||||||
|
void uncache(const std::string& filePath);
|
||||||
|
void uncacheAll();
|
||||||
|
|
||||||
|
|
||||||
|
int preload(const std::string& filePath, std::function<void(bool isSuccess)> callback);
|
||||||
|
|
||||||
|
void update(float dt);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* used internally by ffmod callback
|
||||||
|
*/
|
||||||
|
void onSoundFinished(FMOD::Channel * channel);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns null if a sound with the given path is not found
|
||||||
|
*/
|
||||||
|
FMOD::Sound * findSound(const std::string &path);
|
||||||
|
|
||||||
|
FMOD::Channel * getChannel(FMOD::Sound *);
|
||||||
|
|
||||||
|
struct ChannelInfo{
|
||||||
|
size_t id;
|
||||||
|
std::string path;
|
||||||
|
FMOD::Sound * sound;
|
||||||
|
FMOD::Channel * channel;
|
||||||
|
bool loop;
|
||||||
|
float volume;
|
||||||
|
std::function<void (int, const std::string &)> callback;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::map<int, ChannelInfo> mapChannelInfo;
|
||||||
|
|
||||||
|
std::map<std::string, FMOD::Sound *> mapSound;
|
||||||
|
|
||||||
|
FMOD::System* pSystem;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
NS_CC_END
|
||||||
|
#endif // __AUDIO_ENGINE_LINUX_H_
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,158 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
Copyright (c) 2011 Laschweinski
|
|
||||||
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.
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef AUDIOPLAYER_H_
|
|
||||||
#define AUDIOPLAYER_H_
|
|
||||||
|
|
||||||
namespace CocosDenshion {
|
|
||||||
|
|
||||||
class AudioPlayer {
|
|
||||||
public:
|
|
||||||
virtual void close() = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Preload background music
|
|
||||||
@param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo
|
|
||||||
*/
|
|
||||||
virtual void preloadBackgroundMusic(const char* pszFilePath) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Play background music
|
|
||||||
@param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo
|
|
||||||
@param bLoop Whether the background music loop or not
|
|
||||||
*/
|
|
||||||
virtual void playBackgroundMusic(const char* pszFilePath, bool bLoop = false) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Stop playing background music
|
|
||||||
@param bReleaseData If release the background music data or not.As default value is false
|
|
||||||
*/
|
|
||||||
virtual void stopBackgroundMusic(bool bReleaseData = false) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Pause playing background music
|
|
||||||
*/
|
|
||||||
virtual void pauseBackgroundMusic() = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Resume playing background music
|
|
||||||
*/
|
|
||||||
virtual void resumeBackgroundMusic() = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Rewind playing background music
|
|
||||||
*/
|
|
||||||
virtual void rewindBackgroundMusic() = 0;
|
|
||||||
|
|
||||||
virtual bool willPlayBackgroundMusic() = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Whether the background music is playing
|
|
||||||
@return If is playing return true,or return false
|
|
||||||
*/
|
|
||||||
virtual bool isBackgroundMusicPlaying() = 0;
|
|
||||||
|
|
||||||
// properties
|
|
||||||
/**
|
|
||||||
@brief The volume of the background music max value is 1.0,the min value is 0.0
|
|
||||||
*/
|
|
||||||
virtual float getBackgroundMusicVolume() = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief set the volume of background music
|
|
||||||
@param volume must be in 0.0~1.0
|
|
||||||
*/
|
|
||||||
virtual void setBackgroundMusicVolume(float volume) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief The volume of the effects max value is 1.0,the min value is 0.0
|
|
||||||
*/
|
|
||||||
virtual float getEffectsVolume() = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief set the volume of sound effecs
|
|
||||||
@param volume must be in 0.0~1.0
|
|
||||||
*/
|
|
||||||
virtual void setEffectsVolume(float volume) = 0;
|
|
||||||
|
|
||||||
// for sound effects
|
|
||||||
/**
|
|
||||||
@brief Play sound effect
|
|
||||||
@param pszFilePath The path of the effect file,or the FileName of T_SoundResInfo
|
|
||||||
@bLoop Whether to loop the effect playing, default value is false
|
|
||||||
*/
|
|
||||||
virtual unsigned int playEffect(const char* pszFilePath, bool bLoop,
|
|
||||||
float pitch, float pan, float gain) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Stop playing sound effect
|
|
||||||
@param nSoundId The return value of function playEffect
|
|
||||||
*/
|
|
||||||
virtual void stopEffect(unsigned int nSoundId) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief preload a compressed audio file
|
|
||||||
@details the compressed audio will be decode to wave, then write into an
|
|
||||||
internal buffer in SimpleaudioEngine
|
|
||||||
*/
|
|
||||||
virtual void preloadEffect(const char* pszFilePath) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief unload the preloaded effect from internal buffer
|
|
||||||
@param[in] pszFilePath The path of the effect file,or the FileName of T_SoundResInfo
|
|
||||||
*/
|
|
||||||
virtual void unloadEffect(const char* pszFilePath) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief pause an effect identified by sound id
|
|
||||||
@param[in] uSoundId sound id
|
|
||||||
*/
|
|
||||||
virtual void pauseEffect(unsigned int uSoundId) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief pause all playing effects
|
|
||||||
*/
|
|
||||||
virtual void pauseAllEffects() = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief resume an effect identified by sound id
|
|
||||||
@param[in] uSoundId sound id
|
|
||||||
*/
|
|
||||||
virtual void resumeEffect(unsigned int uSoundId) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief resume a effect identified by sound id
|
|
||||||
*/
|
|
||||||
virtual void resumeAllEffects() = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief stop all playing effects
|
|
||||||
*/
|
|
||||||
virtual void stopAllEffects() = 0;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* AUDIOPLAYER_H_ */
|
|
|
@ -1,477 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
Copyright (c) 2011 Laschweinski
|
|
||||||
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.
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "FmodAudioPlayer.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "stdlib.h"
|
|
||||||
#include "assert.h"
|
|
||||||
#include "string.h"
|
|
||||||
|
|
||||||
#define szMusicSuffix "|"
|
|
||||||
|
|
||||||
namespace CocosDenshion {
|
|
||||||
|
|
||||||
FmodAudioPlayer* FmodAudioPlayer::sharedPlayer() {
|
|
||||||
static FmodAudioPlayer s_SharedPlayer;
|
|
||||||
return &s_SharedPlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ERRCHECKWITHEXIT(FMOD_RESULT result) {
|
|
||||||
if (result != FMOD_OK) {
|
|
||||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
|
||||||
// exit(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ERRCHECK(FMOD_RESULT result) {
|
|
||||||
if (result != FMOD_OK) {
|
|
||||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
FmodAudioPlayer::FmodAudioPlayer() :
|
|
||||||
pMusic(0), pBGMChannel(0), iSoundChannelCount(0) {
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FmodAudioPlayer::init() {
|
|
||||||
//init
|
|
||||||
FMOD_RESULT result;
|
|
||||||
FMOD::ChannelGroup *masterChannelGroup;
|
|
||||||
|
|
||||||
/*
|
|
||||||
Create a System object and initialize.
|
|
||||||
*/
|
|
||||||
result = FMOD::System_Create(&pSystem);
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
|
|
||||||
result = pSystem->setOutput(FMOD_OUTPUTTYPE_ALSA);
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
|
|
||||||
result = pSystem->init(32, FMOD_INIT_NORMAL, 0);
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
|
|
||||||
result = pSystem->createChannelGroup("Channel Group", &pChannelGroup);
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
|
|
||||||
result = pSystem->getMasterChannelGroup(&masterChannelGroup);
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
|
|
||||||
result = masterChannelGroup->addGroup(pChannelGroup);
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
|
|
||||||
mapEffectSound.clear();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void FmodAudioPlayer::close() {
|
|
||||||
FMOD_RESULT result;
|
|
||||||
//BGM
|
|
||||||
if (pBGMChannel != NULL) {
|
|
||||||
result = pBGMChannel->stop();
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
pBGMChannel = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pMusic != NULL) {
|
|
||||||
result = pMusic->release();
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
pMusic = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = pChannelGroup->release();
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
sMusicPath.clear();
|
|
||||||
|
|
||||||
result = pSystem->close();
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
result = pSystem->release();
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
FmodAudioPlayer::~FmodAudioPlayer() {
|
|
||||||
FMOD_RESULT result;
|
|
||||||
//BGM
|
|
||||||
if (pBGMChannel != NULL) {
|
|
||||||
result = pBGMChannel->stop();
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pMusic != NULL) {
|
|
||||||
result = pMusic->release();
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
result = pChannelGroup->release();
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
|
|
||||||
result = pSystem->close();
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
result = pSystem->release();
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
// BGM
|
|
||||||
void FmodAudioPlayer::preloadBackgroundMusic(const char* pszFilePath) {
|
|
||||||
FMOD_RESULT result;
|
|
||||||
pSystem->update();
|
|
||||||
string sNewMusicPath = string(pszFilePath) + szMusicSuffix;
|
|
||||||
if (pMusic && sNewMusicPath != sMusicPath) {
|
|
||||||
//release old
|
|
||||||
result = pMusic->release();
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
|
|
||||||
sMusicPath = sNewMusicPath;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
result = pSystem->createSound(pszFilePath, FMOD_LOOP_NORMAL, 0, &pMusic);
|
|
||||||
ERRCHECK(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FmodAudioPlayer::playBackgroundMusic(const char* pszFilePath, bool bLoop) {
|
|
||||||
pSystem->update();
|
|
||||||
if (pMusic == NULL) {
|
|
||||||
//did not load it
|
|
||||||
//load the new music
|
|
||||||
FMOD_RESULT result = pSystem->createSound(pszFilePath, FMOD_LOOP_NORMAL,
|
|
||||||
0, &pMusic);
|
|
||||||
if (!ERRCHECK(result)) {
|
|
||||||
sMusicPath = string(pszFilePath) + szMusicSuffix;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
string sNewMusicPath = string(pszFilePath) + szMusicSuffix;
|
|
||||||
if (pBGMChannel) {
|
|
||||||
pBGMChannel->stop();
|
|
||||||
pBGMChannel = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sNewMusicPath != sMusicPath) {
|
|
||||||
|
|
||||||
pMusic->release();
|
|
||||||
//load the new music
|
|
||||||
FMOD_RESULT result = pSystem->createSound(pszFilePath,
|
|
||||||
FMOD_LOOP_NORMAL, 0, &pMusic);
|
|
||||||
|
|
||||||
if (!ERRCHECK(result)) {
|
|
||||||
sMusicPath = sNewMusicPath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
FMOD_RESULT result = pSystem->playSound(FMOD_CHANNEL_FREE, pMusic, true,
|
|
||||||
&pBGMChannel);
|
|
||||||
if (!ERRCHECK(result)) {
|
|
||||||
pBGMChannel->setLoopCount((bLoop) ? -1 : 0);
|
|
||||||
result = pBGMChannel->setPaused(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FmodAudioPlayer::stopBackgroundMusic(bool bReleaseData) {
|
|
||||||
FMOD_RESULT result;
|
|
||||||
pSystem->update();
|
|
||||||
|
|
||||||
if (pBGMChannel == NULL || pMusic == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (bReleaseData) {
|
|
||||||
result = pBGMChannel->stop();
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
result = pMusic->release();
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
pBGMChannel = 0;
|
|
||||||
pMusic = 0;
|
|
||||||
} else {
|
|
||||||
result = pBGMChannel->stop();
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
pBGMChannel = 0;
|
|
||||||
}
|
|
||||||
sMusicPath.clear();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void FmodAudioPlayer::pauseBackgroundMusic() {
|
|
||||||
if (pBGMChannel == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pSystem->update();
|
|
||||||
FMOD_RESULT result = pBGMChannel->setPaused(true);
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void FmodAudioPlayer::resumeBackgroundMusic() {
|
|
||||||
if (pBGMChannel == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pSystem->update();
|
|
||||||
FMOD_RESULT result = pBGMChannel->setPaused(false);
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FmodAudioPlayer::rewindBackgroundMusic() {
|
|
||||||
if (pBGMChannel == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pSystem->update();
|
|
||||||
FMOD_RESULT result = pBGMChannel->setPosition(0, FMOD_TIMEUNIT_MS);
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FmodAudioPlayer::willPlayBackgroundMusic() {
|
|
||||||
pSystem->update();
|
|
||||||
return false; //do it according to win
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FmodAudioPlayer::isBackgroundMusicPlaying() {
|
|
||||||
bool bPlaying;
|
|
||||||
if (pBGMChannel == NULL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
pSystem->update();
|
|
||||||
FMOD_RESULT result = pBGMChannel->isPlaying(&bPlaying);
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
return bPlaying;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
float FmodAudioPlayer::getBackgroundMusicVolume() {
|
|
||||||
float fVolumn;
|
|
||||||
if (pBGMChannel == NULL) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
pSystem->update();
|
|
||||||
FMOD_RESULT result = pBGMChannel->getVolume(&fVolumn);
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
return fVolumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FmodAudioPlayer::setBackgroundMusicVolume(float volume) {
|
|
||||||
if (pBGMChannel == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pSystem->update();
|
|
||||||
FMOD_RESULT result = pBGMChannel->setVolume(volume);
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
|
|
||||||
}
|
|
||||||
//~BGM
|
|
||||||
|
|
||||||
// for sound effects
|
|
||||||
float FmodAudioPlayer::getEffectsVolume() {
|
|
||||||
float fVolumn;
|
|
||||||
pSystem->update();
|
|
||||||
FMOD_RESULT result = pChannelGroup->getVolume(&fVolumn);
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
return fVolumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FmodAudioPlayer::setEffectsVolume(float volume) {
|
|
||||||
pSystem->update();
|
|
||||||
FMOD_RESULT result = pChannelGroup->setVolume(volume);
|
|
||||||
ERRCHECKWITHEXIT(result);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int FmodAudioPlayer::playEffect(const char* pszFilePath, bool bLoop,
|
|
||||||
float pitch, float pan, float gain) {
|
|
||||||
FMOD::Channel* pChannel;
|
|
||||||
FMOD::Sound* pSound = NULL;
|
|
||||||
|
|
||||||
do {
|
|
||||||
pSystem->update();
|
|
||||||
|
|
||||||
map<string, FMOD::Sound*>::iterator l_it = mapEffectSound.find(
|
|
||||||
string(pszFilePath));
|
|
||||||
if (l_it == mapEffectSound.end()) {
|
|
||||||
//no load it yet
|
|
||||||
preloadEffect(pszFilePath);
|
|
||||||
l_it = mapEffectSound.find(string(pszFilePath));
|
|
||||||
}
|
|
||||||
pSound = l_it->second;
|
|
||||||
if (pSound==NULL){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
FMOD_RESULT result = pSystem->playSound(FMOD_CHANNEL_FREE, pSound, true,
|
|
||||||
&pChannel);
|
|
||||||
|
|
||||||
if (ERRCHECK(result)) {
|
|
||||||
printf("sound effect in %s could not be played", pszFilePath);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
pChannel->setChannelGroup(pChannelGroup);
|
|
||||||
pChannel->setPan(pan);
|
|
||||||
float freq = 0;
|
|
||||||
pChannel->getFrequency(&freq);
|
|
||||||
pChannel->setFrequency(pitch * freq);
|
|
||||||
pChannel->setVolume(gain);
|
|
||||||
|
|
||||||
//set its loop
|
|
||||||
pChannel->setLoopCount((bLoop) ? -1 : 0);
|
|
||||||
result = pChannel->setPaused(false);
|
|
||||||
|
|
||||||
mapEffectSoundChannel[iSoundChannelCount] = pChannel;
|
|
||||||
return iSoundChannelCount++;
|
|
||||||
} while (0);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FmodAudioPlayer::stopEffect(unsigned int nSoundId) {
|
|
||||||
FMOD::Channel* pChannel;
|
|
||||||
pSystem->update();
|
|
||||||
|
|
||||||
map<unsigned int, FMOD::Channel*>::iterator l_it =
|
|
||||||
mapEffectSoundChannel.find(nSoundId);
|
|
||||||
if (l_it == mapEffectSoundChannel.end()) {
|
|
||||||
//no play yet
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pChannel = l_it->second;
|
|
||||||
//stop the channel;
|
|
||||||
pChannel->stop();
|
|
||||||
|
|
||||||
//delete from the map;
|
|
||||||
mapEffectSoundChannel.erase(nSoundId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FmodAudioPlayer::pauseEffect(unsigned int uSoundId) {
|
|
||||||
FMOD::Channel* pChannel;
|
|
||||||
pSystem->update();
|
|
||||||
|
|
||||||
map<unsigned int, FMOD::Channel*>::iterator l_it =
|
|
||||||
mapEffectSoundChannel.find(uSoundId);
|
|
||||||
if (l_it == mapEffectSoundChannel.end()) {
|
|
||||||
//no play yet
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pChannel = l_it->second;
|
|
||||||
//pause the channel;
|
|
||||||
pChannel->setPaused(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FmodAudioPlayer::pauseAllEffects() {
|
|
||||||
FMOD::Channel* pChannel;
|
|
||||||
pSystem->update();
|
|
||||||
|
|
||||||
map<unsigned int, FMOD::Channel*>::iterator l_it =
|
|
||||||
mapEffectSoundChannel.begin();
|
|
||||||
|
|
||||||
for (; l_it != mapEffectSoundChannel.end(); l_it++) {
|
|
||||||
pChannel = l_it->second;
|
|
||||||
//pause the channel;
|
|
||||||
pChannel->setPaused(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FmodAudioPlayer::resumeEffect(unsigned int uSoundId) {
|
|
||||||
FMOD::Channel* pChannel;
|
|
||||||
pSystem->update();
|
|
||||||
|
|
||||||
map<unsigned int, FMOD::Channel*>::iterator l_it =
|
|
||||||
mapEffectSoundChannel.find(uSoundId);
|
|
||||||
if (l_it == mapEffectSoundChannel.end()) {
|
|
||||||
//no play yet
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pChannel = l_it->second;
|
|
||||||
//resume the channel;
|
|
||||||
pChannel->setPaused(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FmodAudioPlayer::resumeAllEffects() {
|
|
||||||
FMOD::Channel* pChannel;
|
|
||||||
pSystem->update();
|
|
||||||
|
|
||||||
map<unsigned int, FMOD::Channel*>::iterator l_it =
|
|
||||||
mapEffectSoundChannel.begin();
|
|
||||||
|
|
||||||
for (; l_it != mapEffectSoundChannel.end(); l_it++) {
|
|
||||||
pChannel = l_it->second;
|
|
||||||
//resume the channel;
|
|
||||||
pChannel->setPaused(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FmodAudioPlayer::stopAllEffects() {
|
|
||||||
FMOD::Channel* pChannel;
|
|
||||||
pSystem->update();
|
|
||||||
|
|
||||||
map<unsigned int, FMOD::Channel*>::iterator l_it =
|
|
||||||
mapEffectSoundChannel.begin();
|
|
||||||
|
|
||||||
for (; l_it != mapEffectSoundChannel.end(); l_it++) {
|
|
||||||
pChannel = l_it->second;
|
|
||||||
//resume the channel;
|
|
||||||
pChannel->stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
mapEffectSoundChannel.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FmodAudioPlayer::preloadEffect(const char* pszFilePath) {
|
|
||||||
FMOD::Sound* pLoadSound;
|
|
||||||
|
|
||||||
pSystem->update();
|
|
||||||
FMOD_RESULT result = pSystem->createSound(pszFilePath, FMOD_LOOP_NORMAL, 0,
|
|
||||||
&pLoadSound);
|
|
||||||
if (ERRCHECK(result)){
|
|
||||||
printf("sound effect in %s could not be preload", pszFilePath);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mapEffectSound[string(pszFilePath)] = pLoadSound;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FmodAudioPlayer::unloadEffect(const char* pszFilePath) {
|
|
||||||
FMOD::Sound* pSound;
|
|
||||||
pSystem->update();
|
|
||||||
|
|
||||||
map<string, FMOD::Sound*>::iterator l_it = mapEffectSound.find(
|
|
||||||
string(pszFilePath));
|
|
||||||
if (l_it == mapEffectSound.end()) {
|
|
||||||
//no load yet
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pSound = l_it->second;
|
|
||||||
|
|
||||||
//release the sound;
|
|
||||||
pSound->release();
|
|
||||||
|
|
||||||
//delete from the map
|
|
||||||
mapEffectSound.erase(string(pszFilePath));
|
|
||||||
}
|
|
||||||
|
|
||||||
//~for sound effects
|
|
||||||
|
|
||||||
} /* namespace CocosDenshion */
|
|
|
@ -1,190 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
Copyright (c) 2011 Laschweinski
|
|
||||||
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.
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef FMODAUDIOPLAYER_H_
|
|
||||||
#define FMODAUDIOPLAYER_H_
|
|
||||||
|
|
||||||
#include "fmod.hpp"
|
|
||||||
#include "fmod_errors.h"
|
|
||||||
#include "AudioPlayer.h"
|
|
||||||
#include "string"
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
namespace CocosDenshion {
|
|
||||||
|
|
||||||
class FmodAudioPlayer : public AudioPlayer{
|
|
||||||
public:
|
|
||||||
FmodAudioPlayer();
|
|
||||||
virtual ~FmodAudioPlayer();
|
|
||||||
|
|
||||||
static FmodAudioPlayer* sharedPlayer();
|
|
||||||
|
|
||||||
virtual void close();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Preload background music
|
|
||||||
@param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo
|
|
||||||
*/
|
|
||||||
virtual void preloadBackgroundMusic(const char* pszFilePath);
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Play background music
|
|
||||||
@param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo
|
|
||||||
@param bLoop Whether the background music loop or not
|
|
||||||
*/
|
|
||||||
virtual void playBackgroundMusic(const char* pszFilePath, bool bLoop);
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Stop playing background music
|
|
||||||
@param bReleaseData If release the background music data or not.As default value is false
|
|
||||||
*/
|
|
||||||
virtual void stopBackgroundMusic(bool bReleaseData);
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Pause playing background music
|
|
||||||
*/
|
|
||||||
virtual void pauseBackgroundMusic();
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Resume playing background music
|
|
||||||
*/
|
|
||||||
virtual void resumeBackgroundMusic();
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Rewind playing background music
|
|
||||||
*/
|
|
||||||
virtual void rewindBackgroundMusic();
|
|
||||||
|
|
||||||
virtual bool willPlayBackgroundMusic();
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Whether the background music is playing
|
|
||||||
@return If is playing return true,or return false
|
|
||||||
*/
|
|
||||||
virtual bool isBackgroundMusicPlaying();
|
|
||||||
|
|
||||||
// properties
|
|
||||||
/**
|
|
||||||
@brief The volume of the background music max value is 1.0,the min value is 0.0
|
|
||||||
*/
|
|
||||||
virtual float getBackgroundMusicVolume();
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief set the volume of background music
|
|
||||||
@param volume must be in 0.0~1.0
|
|
||||||
*/
|
|
||||||
virtual void setBackgroundMusicVolume(float volume);
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief The volume of the effects max value is 1.0,the min value is 0.0
|
|
||||||
*/
|
|
||||||
virtual float getEffectsVolume();
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief set the volume of sound effecs
|
|
||||||
@param volume must be in 0.0~1.0
|
|
||||||
*/
|
|
||||||
virtual void setEffectsVolume(float volume);
|
|
||||||
|
|
||||||
// for sound effects
|
|
||||||
/**
|
|
||||||
@brief Play sound effect
|
|
||||||
@param pszFilePath The path of the effect file,or the FileName of T_SoundResInfo
|
|
||||||
@bLoop Whether to loop the effect playing, default value is false
|
|
||||||
*/
|
|
||||||
virtual unsigned int playEffect(const char* pszFilePath, bool bLoop,
|
|
||||||
float pitch, float pan, float gain);
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Stop playing sound effect
|
|
||||||
@param nSoundId The return value of function playEffect
|
|
||||||
*/
|
|
||||||
virtual void stopEffect(unsigned int nSoundId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief preload a compressed audio file
|
|
||||||
@details the compressed audio will be decode to wave, then write into an
|
|
||||||
internal buffer in SimpleaudioEngine
|
|
||||||
*/
|
|
||||||
virtual void preloadEffect(const char* pszFilePath);
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief unload the preloaded effect from internal buffer
|
|
||||||
@param[in] pszFilePath The path of the effect file,or the FileName of T_SoundResInfo
|
|
||||||
*/
|
|
||||||
virtual void unloadEffect(const char* pszFilePath);
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief pause an effect identified by sound id
|
|
||||||
@param[in] uSoundId sound id
|
|
||||||
*/
|
|
||||||
virtual void pauseEffect(unsigned int uSoundId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief pause all playing effects
|
|
||||||
*/
|
|
||||||
virtual void pauseAllEffects();
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief resume an effect identified by sound id
|
|
||||||
@param[in] uSoundId sound id
|
|
||||||
*/
|
|
||||||
virtual void resumeEffect(unsigned int uSoundId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief resume a effect identified by sound id
|
|
||||||
*/
|
|
||||||
virtual void resumeAllEffects();
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief stop all playing effects
|
|
||||||
*/
|
|
||||||
virtual void stopAllEffects();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
void init();
|
|
||||||
map<string, FMOD::Sound*> mapEffectSound;
|
|
||||||
map<unsigned int, FMOD::Channel*> mapEffectSoundChannel;
|
|
||||||
|
|
||||||
FMOD::System* pSystem;
|
|
||||||
FMOD::Sound* pMusic; //BGM
|
|
||||||
FMOD::Channel* pBGMChannel;
|
|
||||||
|
|
||||||
FMOD::ChannelGroup* pChannelGroup;
|
|
||||||
|
|
||||||
unsigned int iSoundChannelCount;
|
|
||||||
|
|
||||||
string sMusicPath;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
} /* namespace CocosDenshion */
|
|
||||||
#endif /* FMODAUDIOPLAYER_H_ */
|
|
|
@ -0,0 +1,211 @@
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "../include/SimpleAudioEngine.h"
|
||||||
|
#include "../include/AudioEngine.h"
|
||||||
|
|
||||||
|
using namespace CocosDenshion;
|
||||||
|
using namespace cocos2d;
|
||||||
|
using namespace cocos2d::experimental;
|
||||||
|
|
||||||
|
|
||||||
|
struct SimpleAudioEngineLinux{
|
||||||
|
SimpleAudioEngine * engine = nullptr;
|
||||||
|
int musicid;
|
||||||
|
float effectsvolume;
|
||||||
|
std::string musicpath;
|
||||||
|
};
|
||||||
|
|
||||||
|
SimpleAudioEngineLinux * g_SimpleAudioEngineLinux = nullptr;
|
||||||
|
|
||||||
|
|
||||||
|
SimpleAudioEngine* SimpleAudioEngine::getInstance(){
|
||||||
|
if(!g_SimpleAudioEngineLinux){
|
||||||
|
g_SimpleAudioEngineLinux = new SimpleAudioEngineLinux();
|
||||||
|
g_SimpleAudioEngineLinux->engine = new SimpleAudioEngine();
|
||||||
|
}
|
||||||
|
return g_SimpleAudioEngineLinux->engine;
|
||||||
|
};
|
||||||
|
|
||||||
|
void SimpleAudioEngine::end(){
|
||||||
|
if(g_SimpleAudioEngineLinux){
|
||||||
|
delete g_SimpleAudioEngineLinux->engine;
|
||||||
|
delete g_SimpleAudioEngineLinux;
|
||||||
|
}
|
||||||
|
g_SimpleAudioEngineLinux = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
SimpleAudioEngine::SimpleAudioEngine(){
|
||||||
|
g_SimpleAudioEngineLinux->musicid = -1;
|
||||||
|
g_SimpleAudioEngineLinux->effectsvolume = 1.0f;
|
||||||
|
};
|
||||||
|
|
||||||
|
SimpleAudioEngine::~SimpleAudioEngine(){
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
void SimpleAudioEngine::preloadBackgroundMusic(const char* filePath){
|
||||||
|
g_SimpleAudioEngineLinux->musicpath = filePath;
|
||||||
|
AudioEngine::preload(filePath);
|
||||||
|
};
|
||||||
|
|
||||||
|
void SimpleAudioEngine::playBackgroundMusic(const char* filePath, bool loop){
|
||||||
|
g_SimpleAudioEngineLinux->musicpath = filePath;
|
||||||
|
g_SimpleAudioEngineLinux->musicid = AudioEngine::play2d(filePath, loop);
|
||||||
|
};
|
||||||
|
|
||||||
|
void SimpleAudioEngine::stopBackgroundMusic(bool releaseData){
|
||||||
|
AudioEngine::stop(g_SimpleAudioEngineLinux->musicid);
|
||||||
|
if(releaseData){
|
||||||
|
AudioEngine::uncache(g_SimpleAudioEngineLinux->musicpath.c_str());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void SimpleAudioEngine::pauseBackgroundMusic(){
|
||||||
|
AudioEngine::pause(g_SimpleAudioEngineLinux->musicid);
|
||||||
|
};
|
||||||
|
|
||||||
|
void SimpleAudioEngine::resumeBackgroundMusic(){
|
||||||
|
AudioEngine::resume(g_SimpleAudioEngineLinux->musicid);
|
||||||
|
};
|
||||||
|
|
||||||
|
void SimpleAudioEngine::rewindBackgroundMusic(){
|
||||||
|
AudioEngine::setCurrentTime(g_SimpleAudioEngineLinux->musicid, 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
bool SimpleAudioEngine::willPlayBackgroundMusic(){
|
||||||
|
return g_SimpleAudioEngineLinux->musicid != -1;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool SimpleAudioEngine::isBackgroundMusicPlaying(){
|
||||||
|
return AudioEngine::getState(g_SimpleAudioEngineLinux->musicid) == AudioEngine::AudioState::PLAYING;
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// properties
|
||||||
|
//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The volume of the background music within the range of 0.0 as the minimum and 1.0 as the maximum.
|
||||||
|
* @js getMusicVolume
|
||||||
|
* @lua getMusicVolume
|
||||||
|
*/
|
||||||
|
float SimpleAudioEngine::getBackgroundMusicVolume(){
|
||||||
|
return AudioEngine::getVolume(g_SimpleAudioEngineLinux->musicid);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the volume of background music.
|
||||||
|
*
|
||||||
|
* @param volume must be within the range of 0.0 as the minimum and 1.0 as the maximum.
|
||||||
|
* @js setMusicVolume
|
||||||
|
* @lua setMusicVolume
|
||||||
|
*/
|
||||||
|
void SimpleAudioEngine::setBackgroundMusicVolume(float volume){
|
||||||
|
AudioEngine::setVolume(g_SimpleAudioEngineLinux->musicid, volume);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The volume of the effects within the range of 0.0 as the minimum and 1.0 as the maximum.
|
||||||
|
*/
|
||||||
|
float SimpleAudioEngine::getEffectsVolume(){
|
||||||
|
return g_SimpleAudioEngineLinux->effectsvolume;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the volume of sound effects.
|
||||||
|
*
|
||||||
|
* @param volume must be within the range of 0.0 as the minimum and 1.0 as the maximum.
|
||||||
|
*/
|
||||||
|
void SimpleAudioEngine::setEffectsVolume(float volume){
|
||||||
|
g_SimpleAudioEngineLinux->effectsvolume = volume;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Play sound effect with a file path, pitch, pan and gain.
|
||||||
|
*
|
||||||
|
* @param filePath The path of the effect file.
|
||||||
|
* @param loop Determines whether to loop the effect playing or not. The default value is false.
|
||||||
|
* @param pitch Frequency, normal value is 1.0. Will also change effect play time.
|
||||||
|
* @param pan Stereo effect, in the range of [-1..1] where -1 enables only left channel.
|
||||||
|
* @param gain Volume, in the range of [0..1]. The normal value is 1.
|
||||||
|
* @return The sound id.
|
||||||
|
*
|
||||||
|
* @note Full support is under development, now there are limitations:
|
||||||
|
* - no pitch effect on Samsung Galaxy S2 with OpenSL backend enabled;
|
||||||
|
* - no pitch/pan/gain on win32.
|
||||||
|
*/
|
||||||
|
unsigned int SimpleAudioEngine::playEffect(const char* filePath, bool loop, float pitch, float pan, float gain){
|
||||||
|
return AudioEngine::play2d(filePath, loop, gain);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pause playing sound effect.
|
||||||
|
*
|
||||||
|
* @param soundId The return value of function playEffect.
|
||||||
|
*/
|
||||||
|
void SimpleAudioEngine::pauseEffect(unsigned int soundId){
|
||||||
|
AudioEngine::pause(soundId);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pause all playing sound effect.
|
||||||
|
*/
|
||||||
|
void SimpleAudioEngine::pauseAllEffects(){
|
||||||
|
AudioEngine::pauseAll();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resume playing sound effect.
|
||||||
|
*
|
||||||
|
* @param soundId The return value of function playEffect.
|
||||||
|
*/
|
||||||
|
void SimpleAudioEngine::resumeEffect(unsigned int soundId){
|
||||||
|
AudioEngine::resume(soundId);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resume all playing sound effect.
|
||||||
|
*/
|
||||||
|
void SimpleAudioEngine::resumeAllEffects(){
|
||||||
|
AudioEngine::resumeAll();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop playing sound effect.
|
||||||
|
*
|
||||||
|
* @param soundId The return value of function playEffect.
|
||||||
|
*/
|
||||||
|
void SimpleAudioEngine::stopEffect(unsigned int soundId){
|
||||||
|
AudioEngine::stop(soundId);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop all playing sound effects.
|
||||||
|
*/
|
||||||
|
void SimpleAudioEngine::stopAllEffects(){
|
||||||
|
AudioEngine::stopAll();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preload a compressed audio file.
|
||||||
|
*
|
||||||
|
* The compressed audio will be decoded to wave, then written into an internal buffer in SimpleAudioEngine.
|
||||||
|
*
|
||||||
|
* @param filePath The path of the effect file.
|
||||||
|
* @js NA
|
||||||
|
*/
|
||||||
|
void SimpleAudioEngine::preloadEffect(const char* filePath){
|
||||||
|
AudioEngine::preload(filePath);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unload the preloaded effect from internal buffer.
|
||||||
|
*
|
||||||
|
* @param filePath The path of the effect file.
|
||||||
|
*/
|
||||||
|
void SimpleAudioEngine::unloadEffect(const char* filePath){
|
||||||
|
AudioEngine::uncache(filePath);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,168 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
Copyright (c) 2011 Laschweinski
|
|
||||||
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.
|
|
||||||
****************************************************************************/
|
|
||||||
#ifndef OPENAL
|
|
||||||
|
|
||||||
#include "audio/include/SimpleAudioEngine.h"
|
|
||||||
#include "FmodAudioPlayer.h"
|
|
||||||
#include "cocos2d.h"
|
|
||||||
USING_NS_CC;
|
|
||||||
|
|
||||||
namespace CocosDenshion {
|
|
||||||
|
|
||||||
static AudioPlayer* oAudioPlayer;
|
|
||||||
|
|
||||||
SimpleAudioEngine::SimpleAudioEngine() {
|
|
||||||
oAudioPlayer = FmodAudioPlayer::sharedPlayer();
|
|
||||||
}
|
|
||||||
|
|
||||||
SimpleAudioEngine::~SimpleAudioEngine() {
|
|
||||||
}
|
|
||||||
|
|
||||||
SimpleAudioEngine* SimpleAudioEngine::getInstance() {
|
|
||||||
static SimpleAudioEngine s_SharedEngine;
|
|
||||||
return &s_SharedEngine;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimpleAudioEngine::end() {
|
|
||||||
if(oAudioPlayer)
|
|
||||||
{
|
|
||||||
oAudioPlayer->close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
// BackgroundMusic
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath,
|
|
||||||
bool bLoop) {
|
|
||||||
// Changing file path to full path
|
|
||||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
|
|
||||||
oAudioPlayer->playBackgroundMusic(fullPath.c_str(), bLoop);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimpleAudioEngine::stopBackgroundMusic(bool bReleaseData) {
|
|
||||||
oAudioPlayer->stopBackgroundMusic(bReleaseData);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimpleAudioEngine::pauseBackgroundMusic() {
|
|
||||||
oAudioPlayer->pauseBackgroundMusic();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimpleAudioEngine::resumeBackgroundMusic() {
|
|
||||||
oAudioPlayer->resumeBackgroundMusic();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimpleAudioEngine::rewindBackgroundMusic() {
|
|
||||||
oAudioPlayer->rewindBackgroundMusic();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SimpleAudioEngine::willPlayBackgroundMusic() {
|
|
||||||
return oAudioPlayer->willPlayBackgroundMusic();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SimpleAudioEngine::isBackgroundMusicPlaying() {
|
|
||||||
return oAudioPlayer->isBackgroundMusicPlaying();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath) {
|
|
||||||
// Changing file path to full path
|
|
||||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
|
|
||||||
return oAudioPlayer->preloadBackgroundMusic(fullPath.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
// effect function
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
unsigned int SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop,
|
|
||||||
float pitch, float pan, float gain) {
|
|
||||||
// Changing file path to full path
|
|
||||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
|
|
||||||
return oAudioPlayer->playEffect(fullPath.c_str(), bLoop, pitch, pan, gain);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimpleAudioEngine::stopEffect(unsigned int nSoundId) {
|
|
||||||
return oAudioPlayer->stopEffect(nSoundId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimpleAudioEngine::preloadEffect(const char* pszFilePath) {
|
|
||||||
// Changing file path to full path
|
|
||||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
|
|
||||||
return oAudioPlayer->preloadEffect(fullPath.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimpleAudioEngine::unloadEffect(const char* pszFilePath) {
|
|
||||||
// Changing file path to full path
|
|
||||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
|
|
||||||
return oAudioPlayer->unloadEffect(fullPath.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimpleAudioEngine::pauseEffect(unsigned int uSoundId) {
|
|
||||||
oAudioPlayer->pauseEffect(uSoundId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimpleAudioEngine::pauseAllEffects() {
|
|
||||||
oAudioPlayer->pauseAllEffects();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimpleAudioEngine::resumeEffect(unsigned int uSoundId) {
|
|
||||||
oAudioPlayer->resumeEffect(uSoundId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimpleAudioEngine::resumeAllEffects() {
|
|
||||||
oAudioPlayer->resumeAllEffects();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimpleAudioEngine::stopAllEffects() {
|
|
||||||
oAudioPlayer->stopAllEffects();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
// volume interface
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
float SimpleAudioEngine::getBackgroundMusicVolume() {
|
|
||||||
return oAudioPlayer->getBackgroundMusicVolume();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimpleAudioEngine::setBackgroundMusicVolume(float volume) {
|
|
||||||
return oAudioPlayer->setBackgroundMusicVolume(volume);
|
|
||||||
}
|
|
||||||
|
|
||||||
float SimpleAudioEngine::getEffectsVolume() {
|
|
||||||
return oAudioPlayer->getEffectsVolume();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimpleAudioEngine::setEffectsVolume(float volume) {
|
|
||||||
return oAudioPlayer->setEffectsVolume(volume);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // end of namespace CocosDenshion
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -322,6 +322,7 @@ bool AudioEngineImpl::stop(int audioID)
|
||||||
_alSourceUsed[player._alSource] = false;
|
_alSourceUsed[player._alSource] = false;
|
||||||
if (player._streamingSource)
|
if (player._streamingSource)
|
||||||
{
|
{
|
||||||
|
player._ready = false;
|
||||||
player.notifyExitThread();
|
player.notifyExitThread();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -346,6 +347,7 @@ void AudioEngineImpl::stopAll()
|
||||||
auto& player = it->second;
|
auto& player = it->second;
|
||||||
if (player._streamingSource)
|
if (player._streamingSource)
|
||||||
{
|
{
|
||||||
|
player._ready = false;
|
||||||
player.notifyExitThread();
|
player.notifyExitThread();
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
@ -457,7 +459,7 @@ void AudioEngineImpl::update(float dt)
|
||||||
auto& player = it->second;
|
auto& player = it->second;
|
||||||
alGetSourcei(player._alSource, AL_SOURCE_STATE, &sourceState);
|
alGetSourcei(player._alSource, AL_SOURCE_STATE, &sourceState);
|
||||||
|
|
||||||
if (player._readForRemove)
|
if (player._readForRemove && !player._ready)
|
||||||
{
|
{
|
||||||
it = _audioPlayers.erase(it);
|
it = _audioPlayers.erase(it);
|
||||||
}
|
}
|
||||||
|
@ -472,6 +474,7 @@ void AudioEngineImpl::update(float dt)
|
||||||
|
|
||||||
if (player._streamingSource)
|
if (player._streamingSource)
|
||||||
{
|
{
|
||||||
|
player._ready = false;
|
||||||
player.notifyExitThread();
|
player.notifyExitThread();
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
|
|
@ -328,6 +328,9 @@ void Director::drawScene()
|
||||||
{
|
{
|
||||||
calculateMPF();
|
calculateMPF();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_textureCache != nullptr)
|
||||||
|
_textureCache->setDirty(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Director::calculateDeltaTime()
|
void Director::calculateDeltaTime()
|
||||||
|
|
|
@ -0,0 +1,309 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2010-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.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "CCStencilStateManager.hpp"
|
||||||
|
#include "base/CCDirector.h"
|
||||||
|
#include "renderer/CCGLProgramCache.h"
|
||||||
|
#include "renderer/ccGLStateCache.h"
|
||||||
|
#include "renderer/CCRenderer.h"
|
||||||
|
#include "renderer/CCRenderState.h"
|
||||||
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
|
||||||
|
#define CC_CLIPPING_NODE_OPENGLES 0
|
||||||
|
#else
|
||||||
|
#define CC_CLIPPING_NODE_OPENGLES 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
GLint StencilStateManager::s_layer = -1;
|
||||||
|
static GLint g_sStencilBits = -1;
|
||||||
|
|
||||||
|
StencilStateManager::StencilStateManager()
|
||||||
|
: _alphaThreshold(1.0f)
|
||||||
|
, _inverted(false)
|
||||||
|
, _currentStencilEnabled(GL_FALSE)
|
||||||
|
, _currentStencilWriteMask(~0)
|
||||||
|
, _currentStencilFunc(GL_ALWAYS)
|
||||||
|
, _currentStencilRef(0)
|
||||||
|
, _currentStencilValueMask(~0)
|
||||||
|
, _currentStencilFail(GL_KEEP)
|
||||||
|
, _currentStencilPassDepthFail(GL_KEEP)
|
||||||
|
, _currentStencilPassDepthPass(GL_KEEP)
|
||||||
|
, _currentDepthWriteMask(GL_TRUE)
|
||||||
|
, _currentAlphaTestEnabled(GL_FALSE)
|
||||||
|
, _currentAlphaTestFunc(GL_ALWAYS)
|
||||||
|
, _currentAlphaTestRef(1)
|
||||||
|
|
||||||
|
{
|
||||||
|
// get (only once) the number of bits of the stencil buffer
|
||||||
|
static bool once = true;
|
||||||
|
if (once)
|
||||||
|
{
|
||||||
|
glGetIntegerv(GL_STENCIL_BITS, &g_sStencilBits);
|
||||||
|
if (g_sStencilBits <= 0)
|
||||||
|
{
|
||||||
|
CCLOG("Stencil buffer is not enabled.");
|
||||||
|
}
|
||||||
|
once = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StencilStateManager::drawFullScreenQuadClearStencil()
|
||||||
|
{
|
||||||
|
Director* director = Director::getInstance();
|
||||||
|
CCASSERT(nullptr != director, "Director is null when setting matrix stack");
|
||||||
|
|
||||||
|
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||||
|
director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||||
|
|
||||||
|
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
||||||
|
director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
||||||
|
|
||||||
|
Vec2 vertices[] = {
|
||||||
|
Vec2(-1.0f, -1.0f),
|
||||||
|
Vec2(1.0f, -1.0f),
|
||||||
|
Vec2(1.0f, 1.0f),
|
||||||
|
Vec2(-1.0f, 1.0f)
|
||||||
|
};
|
||||||
|
|
||||||
|
auto glProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_U_COLOR);
|
||||||
|
|
||||||
|
int colorLocation = glProgram->getUniformLocation("u_color");
|
||||||
|
CHECK_GL_ERROR_DEBUG();
|
||||||
|
|
||||||
|
Color4F color(1, 1, 1, 1);
|
||||||
|
|
||||||
|
glProgram->use();
|
||||||
|
glProgram->setUniformsForBuiltins();
|
||||||
|
glProgram->setUniformLocationWith4fv(colorLocation, (GLfloat*) &color.r, 1);
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
|
||||||
|
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||||
|
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||||
|
|
||||||
|
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 4);
|
||||||
|
|
||||||
|
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
||||||
|
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void StencilStateManager::setAlphaThreshold(GLfloat alphaThreshold)
|
||||||
|
{
|
||||||
|
_alphaThreshold = alphaThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLfloat StencilStateManager::getAlphaThreshold()const
|
||||||
|
{
|
||||||
|
return _alphaThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StencilStateManager::setInverted(bool inverted)
|
||||||
|
{
|
||||||
|
_inverted = inverted;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool StencilStateManager::isInverted()const
|
||||||
|
{
|
||||||
|
return _inverted;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StencilStateManager::onBeforeVisit()
|
||||||
|
{
|
||||||
|
///////////////////////////////////
|
||||||
|
// INIT
|
||||||
|
|
||||||
|
// increment the current layer
|
||||||
|
s_layer++;
|
||||||
|
|
||||||
|
// mask of the current layer (ie: for layer 3: 00000100)
|
||||||
|
GLint mask_layer = 0x1 << s_layer;
|
||||||
|
// mask of all layers less than the current (ie: for layer 3: 00000011)
|
||||||
|
GLint mask_layer_l = mask_layer - 1;
|
||||||
|
// mask of all layers less than or equal to the current (ie: for layer 3: 00000111)
|
||||||
|
_mask_layer_le = mask_layer | mask_layer_l;
|
||||||
|
|
||||||
|
// manually save the stencil state
|
||||||
|
|
||||||
|
_currentStencilEnabled = glIsEnabled(GL_STENCIL_TEST);
|
||||||
|
glGetIntegerv(GL_STENCIL_WRITEMASK, (GLint *)&_currentStencilWriteMask);
|
||||||
|
glGetIntegerv(GL_STENCIL_FUNC, (GLint *)&_currentStencilFunc);
|
||||||
|
glGetIntegerv(GL_STENCIL_REF, &_currentStencilRef);
|
||||||
|
glGetIntegerv(GL_STENCIL_VALUE_MASK, (GLint *)&_currentStencilValueMask);
|
||||||
|
glGetIntegerv(GL_STENCIL_FAIL, (GLint *)&_currentStencilFail);
|
||||||
|
glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, (GLint *)&_currentStencilPassDepthFail);
|
||||||
|
glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, (GLint *)&_currentStencilPassDepthPass);
|
||||||
|
|
||||||
|
// enable stencil use
|
||||||
|
glEnable(GL_STENCIL_TEST);
|
||||||
|
// RenderState::StateBlock::_defaultState->setStencilTest(true);
|
||||||
|
|
||||||
|
// check for OpenGL error while enabling stencil test
|
||||||
|
CHECK_GL_ERROR_DEBUG();
|
||||||
|
|
||||||
|
// all bits on the stencil buffer are readonly, except the current layer bit,
|
||||||
|
// this means that operation like glClear or glStencilOp will be masked with this value
|
||||||
|
glStencilMask(mask_layer);
|
||||||
|
// RenderState::StateBlock::_defaultState->setStencilWrite(mask_layer);
|
||||||
|
|
||||||
|
// manually save the depth test state
|
||||||
|
|
||||||
|
glGetBooleanv(GL_DEPTH_WRITEMASK, &_currentDepthWriteMask);
|
||||||
|
|
||||||
|
// disable depth test while drawing the stencil
|
||||||
|
//glDisable(GL_DEPTH_TEST);
|
||||||
|
// disable update to the depth buffer while drawing the stencil,
|
||||||
|
// as the stencil is not meant to be rendered in the real scene,
|
||||||
|
// it should never prevent something else to be drawn,
|
||||||
|
// only disabling depth buffer update should do
|
||||||
|
glDepthMask(GL_FALSE);
|
||||||
|
RenderState::StateBlock::_defaultState->setDepthWrite(false);
|
||||||
|
|
||||||
|
///////////////////////////////////
|
||||||
|
// CLEAR STENCIL BUFFER
|
||||||
|
|
||||||
|
// manually clear the stencil buffer by drawing a fullscreen rectangle on it
|
||||||
|
// setup the stencil test func like this:
|
||||||
|
// for each pixel in the fullscreen rectangle
|
||||||
|
// never draw it into the frame buffer
|
||||||
|
// if not in inverted mode: set the current layer value to 0 in the stencil buffer
|
||||||
|
// if in inverted mode: set the current layer value to 1 in the stencil buffer
|
||||||
|
glStencilFunc(GL_NEVER, mask_layer, mask_layer);
|
||||||
|
glStencilOp(!_inverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP);
|
||||||
|
|
||||||
|
// draw a fullscreen solid rectangle to clear the stencil buffer
|
||||||
|
//ccDrawSolidRect(Vec2::ZERO, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1));
|
||||||
|
drawFullScreenQuadClearStencil();
|
||||||
|
|
||||||
|
///////////////////////////////////
|
||||||
|
// DRAW CLIPPING STENCIL
|
||||||
|
|
||||||
|
// setup the stencil test func like this:
|
||||||
|
// for each pixel in the stencil node
|
||||||
|
// never draw it into the frame buffer
|
||||||
|
// if not in inverted mode: set the current layer value to 1 in the stencil buffer
|
||||||
|
// if in inverted mode: set the current layer value to 0 in the stencil buffer
|
||||||
|
glStencilFunc(GL_NEVER, mask_layer, mask_layer);
|
||||||
|
// RenderState::StateBlock::_defaultState->setStencilFunction(RenderState::STENCIL_NEVER, mask_layer, mask_layer);
|
||||||
|
|
||||||
|
glStencilOp(!_inverted ? GL_REPLACE : GL_ZERO, GL_KEEP, GL_KEEP);
|
||||||
|
// RenderState::StateBlock::_defaultState->setStencilOperation(
|
||||||
|
// !_inverted ? RenderState::STENCIL_OP_REPLACE : RenderState::STENCIL_OP_ZERO,
|
||||||
|
// RenderState::STENCIL_OP_KEEP,
|
||||||
|
// RenderState::STENCIL_OP_KEEP);
|
||||||
|
|
||||||
|
|
||||||
|
// enable alpha test only if the alpha threshold < 1,
|
||||||
|
// indeed if alpha threshold == 1, every pixel will be drawn anyways
|
||||||
|
if (_alphaThreshold < 1) {
|
||||||
|
#if !CC_CLIPPING_NODE_OPENGLES
|
||||||
|
// manually save the alpha test state
|
||||||
|
_currentAlphaTestEnabled = glIsEnabled(GL_ALPHA_TEST);
|
||||||
|
glGetIntegerv(GL_ALPHA_TEST_FUNC, (GLint *)&_currentAlphaTestFunc);
|
||||||
|
glGetFloatv(GL_ALPHA_TEST_REF, &_currentAlphaTestRef);
|
||||||
|
// enable alpha testing
|
||||||
|
glEnable(GL_ALPHA_TEST);
|
||||||
|
// check for OpenGL error while enabling alpha test
|
||||||
|
CHECK_GL_ERROR_DEBUG();
|
||||||
|
// pixel will be drawn only if greater than an alpha threshold
|
||||||
|
glAlphaFunc(GL_GREATER, _alphaThreshold);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
//Draw _stencil
|
||||||
|
}
|
||||||
|
|
||||||
|
void StencilStateManager::onAfterDrawStencil()
|
||||||
|
{
|
||||||
|
// restore alpha test state
|
||||||
|
if (_alphaThreshold < 1)
|
||||||
|
{
|
||||||
|
#if CC_CLIPPING_NODE_OPENGLES
|
||||||
|
// FIXME: we need to find a way to restore the shaders of the stencil node and its children
|
||||||
|
#else
|
||||||
|
// manually restore the alpha test state
|
||||||
|
glAlphaFunc(_currentAlphaTestFunc, _currentAlphaTestRef);
|
||||||
|
if (!_currentAlphaTestEnabled)
|
||||||
|
{
|
||||||
|
glDisable(GL_ALPHA_TEST);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// restore the depth test state
|
||||||
|
glDepthMask(_currentDepthWriteMask);
|
||||||
|
RenderState::StateBlock::_defaultState->setDepthWrite(_currentDepthWriteMask != 0);
|
||||||
|
|
||||||
|
//if (currentDepthTestEnabled) {
|
||||||
|
// glEnable(GL_DEPTH_TEST);
|
||||||
|
//}
|
||||||
|
|
||||||
|
///////////////////////////////////
|
||||||
|
// DRAW CONTENT
|
||||||
|
|
||||||
|
// setup the stencil test function like this:
|
||||||
|
// for each pixel of this node and its children
|
||||||
|
// if all layers less than or equals to the current are set to 1 in the stencil buffer
|
||||||
|
// draw the pixel and keep the current layer in the stencil buffer
|
||||||
|
// else
|
||||||
|
// do not draw the pixel but keep the current layer in the stencil buffer
|
||||||
|
glStencilFunc(GL_EQUAL, _mask_layer_le, _mask_layer_le);
|
||||||
|
// RenderState::StateBlock::_defaultState->setStencilFunction(RenderState::STENCIL_EQUAL, _mask_layer_le, _mask_layer_le);
|
||||||
|
|
||||||
|
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
||||||
|
// RenderState::StateBlock::_defaultState->setStencilOperation(RenderState::STENCIL_OP_KEEP, RenderState::STENCIL_OP_KEEP, RenderState::STENCIL_OP_KEEP);
|
||||||
|
|
||||||
|
// draw (according to the stencil test function) this node and its children
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void StencilStateManager::onAfterVisit()
|
||||||
|
{
|
||||||
|
///////////////////////////////////
|
||||||
|
// CLEANUP
|
||||||
|
|
||||||
|
// manually restore the stencil state
|
||||||
|
glStencilFunc(_currentStencilFunc, _currentStencilRef, _currentStencilValueMask);
|
||||||
|
// RenderState::StateBlock::_defaultState->setStencilFunction((RenderState::StencilFunction)_currentStencilFunc, _currentStencilRef, _currentStencilValueMask);
|
||||||
|
|
||||||
|
glStencilOp(_currentStencilFail, _currentStencilPassDepthFail, _currentStencilPassDepthPass);
|
||||||
|
// RenderState::StateBlock::_defaultState->setStencilOperation((RenderState::StencilOperation)_currentStencilFail,
|
||||||
|
// (RenderState::StencilOperation)_currentStencilPassDepthFail,
|
||||||
|
// (RenderState::StencilOperation)_currentStencilPassDepthPass);
|
||||||
|
|
||||||
|
glStencilMask(_currentStencilWriteMask);
|
||||||
|
if (!_currentStencilEnabled)
|
||||||
|
{
|
||||||
|
glDisable(GL_STENCIL_TEST);
|
||||||
|
// RenderState::StateBlock::_defaultState->setStencilTest(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// we are done using this layer, decrement
|
||||||
|
s_layer--;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NS_CC_END
|
|
@ -0,0 +1,79 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2010-2012 cocos2d-x.org
|
||||||
|
Copyright (c) 2013-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 StencilStateManager_hpp
|
||||||
|
#define StencilStateManager_hpp
|
||||||
|
#include "base/ccConfig.h"
|
||||||
|
#include "platform/CCPlatformMacros.h"
|
||||||
|
#include "platform/CCGL.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup base
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
class CC_DLL StencilStateManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
StencilStateManager();
|
||||||
|
void onBeforeVisit();
|
||||||
|
void onAfterDrawStencil();
|
||||||
|
void onAfterVisit();
|
||||||
|
void setAlphaThreshold(GLfloat alphaThreshold);
|
||||||
|
void setInverted(bool inverted);
|
||||||
|
bool isInverted()const;
|
||||||
|
GLfloat getAlphaThreshold()const;
|
||||||
|
private:
|
||||||
|
CC_DISALLOW_COPY_AND_ASSIGN(StencilStateManager);
|
||||||
|
static GLint s_layer;
|
||||||
|
/**draw fullscreen quad to clear stencil bits
|
||||||
|
*/
|
||||||
|
void drawFullScreenQuadClearStencil();
|
||||||
|
|
||||||
|
|
||||||
|
GLfloat _alphaThreshold;
|
||||||
|
bool _inverted;
|
||||||
|
|
||||||
|
GLboolean _currentStencilEnabled;
|
||||||
|
GLuint _currentStencilWriteMask;
|
||||||
|
GLenum _currentStencilFunc;
|
||||||
|
GLint _currentStencilRef;
|
||||||
|
GLuint _currentStencilValueMask;
|
||||||
|
GLenum _currentStencilFail;
|
||||||
|
GLenum _currentStencilPassDepthFail;
|
||||||
|
GLenum _currentStencilPassDepthPass;
|
||||||
|
GLboolean _currentDepthWriteMask;
|
||||||
|
|
||||||
|
GLboolean _currentAlphaTestEnabled;
|
||||||
|
GLenum _currentAlphaTestFunc;
|
||||||
|
GLclampf _currentAlphaTestRef;
|
||||||
|
|
||||||
|
GLint _mask_layer_le;
|
||||||
|
};
|
||||||
|
|
||||||
|
NS_CC_END
|
||||||
|
// end of base group
|
||||||
|
/** @} */
|
||||||
|
#endif /* StencilStateManager_hpp */
|
|
@ -45,6 +45,7 @@ set(COCOS_BASE_SRC
|
||||||
base/CCUserDefault.cpp
|
base/CCUserDefault.cpp
|
||||||
base/CCValue.cpp
|
base/CCValue.cpp
|
||||||
base/ObjectFactory.cpp
|
base/ObjectFactory.cpp
|
||||||
|
base/CCStencilStateManager.cpp
|
||||||
base/TGAlib.cpp
|
base/TGAlib.cpp
|
||||||
base/ZipUtils.cpp
|
base/ZipUtils.cpp
|
||||||
base/allocator/CCAllocatorDiagnostics.cpp
|
base/allocator/CCAllocatorDiagnostics.cpp
|
||||||
|
|
|
@ -30,10 +30,12 @@ THE SOFTWARE.
|
||||||
#include "base/CCDirector.h"
|
#include "base/CCDirector.h"
|
||||||
#include "base/CCAsyncTaskPool.h"
|
#include "base/CCAsyncTaskPool.h"
|
||||||
#include "base/CCEventDispatcher.h"
|
#include "base/CCEventDispatcher.h"
|
||||||
|
#include "base/base64.h"
|
||||||
#include "renderer/CCCustomCommand.h"
|
#include "renderer/CCCustomCommand.h"
|
||||||
#include "renderer/CCRenderer.h"
|
#include "renderer/CCRenderer.h"
|
||||||
#include "platform/CCImage.h"
|
#include "platform/CCImage.h"
|
||||||
#include "platform/CCFileUtils.h"
|
#include "platform/CCFileUtils.h"
|
||||||
|
#include "2d/CCSprite.h"
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
@ -263,7 +265,28 @@ Rect getCascadeBoundingBox(Node *node)
|
||||||
|
|
||||||
return cbb;
|
return cbb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Sprite* createSpriteFromBase64(const char* base64String)
|
||||||
|
{
|
||||||
|
unsigned char* decoded;
|
||||||
|
int length = base64Decode((const unsigned char*) base64String, (unsigned int) strlen(base64String), &decoded);
|
||||||
|
|
||||||
|
Image *image = new Image();
|
||||||
|
bool imageResult = image->initWithImageData(decoded, length);
|
||||||
|
CCASSERT(imageResult, "Failed to create image from base64!");
|
||||||
|
free(decoded);
|
||||||
|
|
||||||
|
Texture2D *texture = new Texture2D();
|
||||||
|
texture->initWithImage(image);
|
||||||
|
texture->setAliasTexParameters();
|
||||||
|
image->release();
|
||||||
|
|
||||||
|
Sprite* sprite = Sprite::createWithTexture(texture);
|
||||||
|
texture->release();
|
||||||
|
|
||||||
|
return sprite;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -52,6 +52,8 @@ Examples:
|
||||||
|
|
||||||
int ccNextPOT(int value);
|
int ccNextPOT(int value);
|
||||||
|
|
||||||
|
class Sprite;
|
||||||
|
|
||||||
namespace utils
|
namespace utils
|
||||||
{
|
{
|
||||||
/** Capture the entire screen.
|
/** Capture the entire screen.
|
||||||
|
@ -100,6 +102,14 @@ namespace utils
|
||||||
* @return Returns unionof bounding box of a node and its children.
|
* @return Returns unionof bounding box of a node and its children.
|
||||||
*/
|
*/
|
||||||
Rect CC_DLL getCascadeBoundingBox(Node *node);
|
Rect CC_DLL getCascadeBoundingBox(Node *node);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a sprite instance from base64 encoded image.
|
||||||
|
|
||||||
|
* @return Returns an instance of sprite
|
||||||
|
*/
|
||||||
|
Sprite* createSpriteFromBase64(const char* base64String);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -31,7 +31,7 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
CC_DLL const char* cocos2dVersion()
|
CC_DLL const char* cocos2dVersion()
|
||||||
{
|
{
|
||||||
return "cocos2d-x-3.9beta0";
|
return "cocos2d-x-3.9";
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -30,7 +30,7 @@ THE SOFTWARE.
|
||||||
|
|
||||||
// 0x00 HI ME LO
|
// 0x00 HI ME LO
|
||||||
// 00 03 08 00
|
// 00 03 08 00
|
||||||
#define COCOS2D_VERSION 0x00030800
|
#define COCOS2D_VERSION 0x00030900
|
||||||
|
|
||||||
//
|
//
|
||||||
// all cocos2d include files
|
// all cocos2d include files
|
||||||
|
|
|
@ -139,7 +139,6 @@ ActionTimeline* ActionTimelineCache::createAction(const std::string& filename)
|
||||||
std::string path = filename;
|
std::string path = filename;
|
||||||
size_t pos = path.find_last_of('.');
|
size_t pos = path.find_last_of('.');
|
||||||
std::string suffix = path.substr(pos + 1, path.length());
|
std::string suffix = path.substr(pos + 1, path.length());
|
||||||
CCLOG("suffix = %s", suffix.c_str());
|
|
||||||
|
|
||||||
ActionTimelineCache* cache = ActionTimelineCache::getInstance();
|
ActionTimelineCache* cache = ActionTimelineCache::getInstance();
|
||||||
|
|
||||||
|
@ -507,7 +506,6 @@ Timeline* ActionTimelineCache::loadTimelineWithFlatBuffers(const flatbuffers::Ti
|
||||||
if(property == "")
|
if(property == "")
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
CCLOG("property = %s", property.c_str());
|
|
||||||
|
|
||||||
if(property != "")
|
if(property != "")
|
||||||
{
|
{
|
||||||
|
|
|
@ -618,20 +618,44 @@ void InnerActionFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
||||||
|
|
||||||
void InnerActionFrame::setStartFrameIndex(int frameIndex)
|
void InnerActionFrame::setStartFrameIndex(int frameIndex)
|
||||||
{
|
{
|
||||||
|
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
|
||||||
|
if (_enterWithName)
|
||||||
|
{
|
||||||
|
CCLOG(" cannot set start when enter frame with name. setEnterWithName false firstly!");
|
||||||
|
throw std::exception();
|
||||||
|
}
|
||||||
|
#else
|
||||||
CCASSERT(!_enterWithName, " cannot setStartFrameIndex when enterWithName is set");
|
CCASSERT(!_enterWithName, " cannot setStartFrameIndex when enterWithName is set");
|
||||||
|
#endif
|
||||||
_startFrameIndex = frameIndex;
|
_startFrameIndex = frameIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InnerActionFrame::setEndFrameIndex(int frameIndex)
|
void InnerActionFrame::setEndFrameIndex(int frameIndex)
|
||||||
{
|
{
|
||||||
|
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
|
||||||
|
if (_enterWithName)
|
||||||
|
{
|
||||||
|
CCLOG(" cannot set end when enter frame with name. setEnterWithName false firstly!");
|
||||||
|
throw std::exception();
|
||||||
|
}
|
||||||
|
#else
|
||||||
CCASSERT(!_enterWithName, " cannot setEndFrameIndex when enterWithName is set");
|
CCASSERT(!_enterWithName, " cannot setEndFrameIndex when enterWithName is set");
|
||||||
|
#endif
|
||||||
_endFrameIndex = frameIndex;
|
_endFrameIndex = frameIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerActionFrame::setAnimationName(const std::string& animationName)
|
void InnerActionFrame::setAnimationName(const std::string& animationName)
|
||||||
{
|
{
|
||||||
|
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
|
||||||
|
if (!_enterWithName)
|
||||||
|
{
|
||||||
|
CCLOG(" cannot set aniamtioname when enter frame with index. setEnterWithName true firstly!");
|
||||||
|
throw std::exception();
|
||||||
|
}
|
||||||
|
#else
|
||||||
CCASSERT(_enterWithName, " cannot set aniamtioname when enter frame with index. setEnterWithName true firstly!");
|
CCASSERT(_enterWithName, " cannot set aniamtioname when enter frame with index. setEnterWithName true firstly!");
|
||||||
|
#endif
|
||||||
_animationName = animationName;
|
_animationName = animationName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -264,7 +264,6 @@ Node* CSLoader::createNode(const std::string& filename)
|
||||||
std::string path = filename;
|
std::string path = filename;
|
||||||
size_t pos = path.find_last_of('.');
|
size_t pos = path.find_last_of('.');
|
||||||
std::string suffix = path.substr(pos + 1, path.length());
|
std::string suffix = path.substr(pos + 1, path.length());
|
||||||
CCLOG("suffix = %s", suffix.c_str());
|
|
||||||
|
|
||||||
CSLoader* load = CSLoader::getInstance();
|
CSLoader* load = CSLoader::getInstance();
|
||||||
|
|
||||||
|
@ -285,7 +284,6 @@ Node* CSLoader::createNode(const std::string &filename, const ccNodeLoadCallback
|
||||||
std::string path = filename;
|
std::string path = filename;
|
||||||
size_t pos = path.find_last_of('.');
|
size_t pos = path.find_last_of('.');
|
||||||
std::string suffix = path.substr(pos + 1, path.length());
|
std::string suffix = path.substr(pos + 1, path.length());
|
||||||
CCLOG("suffix = %s", suffix.c_str());
|
|
||||||
|
|
||||||
CSLoader* load = CSLoader::getInstance();
|
CSLoader* load = CSLoader::getInstance();
|
||||||
|
|
||||||
|
@ -335,7 +333,6 @@ std::string CSLoader::getExtentionName(const std::string& name)
|
||||||
ActionTimeline* CSLoader::createTimeline(const std::string &filename)
|
ActionTimeline* CSLoader::createTimeline(const std::string &filename)
|
||||||
{
|
{
|
||||||
std::string suffix = getExtentionName(filename);
|
std::string suffix = getExtentionName(filename);
|
||||||
CCLOG("suffix = %s", suffix.c_str());
|
|
||||||
|
|
||||||
ActionTimelineCache* cache = ActionTimelineCache::getInstance();
|
ActionTimelineCache* cache = ActionTimelineCache::getInstance();
|
||||||
|
|
||||||
|
@ -354,7 +351,6 @@ ActionTimeline* CSLoader::createTimeline(const std::string &filename)
|
||||||
ActionTimeline* CSLoader::createTimeline(const Data data, const std::string& filename)
|
ActionTimeline* CSLoader::createTimeline(const Data data, const std::string& filename)
|
||||||
{
|
{
|
||||||
std::string suffix = getExtentionName(filename);
|
std::string suffix = getExtentionName(filename);
|
||||||
CCLOG("suffix = %s", suffix.c_str());
|
|
||||||
|
|
||||||
ActionTimelineCache* cache = ActionTimelineCache::getInstance();
|
ActionTimelineCache* cache = ActionTimelineCache::getInstance();
|
||||||
|
|
||||||
|
@ -982,7 +978,6 @@ Node* CSLoader::nodeWithFlatBuffersFile(const std::string &fileName, const ccNod
|
||||||
// decode plist
|
// decode plist
|
||||||
auto textures = csparsebinary->textures();
|
auto textures = csparsebinary->textures();
|
||||||
int textureSize = textures->size();
|
int textureSize = textures->size();
|
||||||
CCLOG("textureSize = %d", textureSize);
|
|
||||||
for (int i = 0; i < textureSize; ++i)
|
for (int i = 0; i < textureSize; ++i)
|
||||||
{
|
{
|
||||||
SpriteFrameCache::getInstance()->addSpriteFramesWithFile(textures->Get(i)->c_str());
|
SpriteFrameCache::getInstance()->addSpriteFramesWithFile(textures->Get(i)->c_str());
|
||||||
|
@ -1007,7 +1002,6 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree, const
|
||||||
Node* node = nullptr;
|
Node* node = nullptr;
|
||||||
|
|
||||||
std::string classname = nodetree->classname()->c_str();
|
std::string classname = nodetree->classname()->c_str();
|
||||||
CCLOG("classname = %s", classname.c_str());
|
|
||||||
|
|
||||||
auto options = nodetree->options();
|
auto options = nodetree->options();
|
||||||
|
|
||||||
|
@ -1016,7 +1010,6 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree, const
|
||||||
auto reader = ProjectNodeReader::getInstance();
|
auto reader = ProjectNodeReader::getInstance();
|
||||||
auto projectNodeOptions = (ProjectNodeOptions*)options->data();
|
auto projectNodeOptions = (ProjectNodeOptions*)options->data();
|
||||||
std::string filePath = projectNodeOptions->fileName()->c_str();
|
std::string filePath = projectNodeOptions->fileName()->c_str();
|
||||||
CCLOG("filePath = %s", filePath.c_str());
|
|
||||||
|
|
||||||
cocostudio::timeline::ActionTimeline* action = nullptr;
|
cocostudio::timeline::ActionTimeline* action = nullptr;
|
||||||
if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath))
|
if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath))
|
||||||
|
@ -1079,7 +1072,6 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree, const
|
||||||
{
|
{
|
||||||
_callbackHandlers.pushBack(node);
|
_callbackHandlers.pushBack(node);
|
||||||
_rootNode = _callbackHandlers.back();
|
_rootNode = _callbackHandlers.back();
|
||||||
CCLOG("after push back _rootNode name = %s", _rootNode->getName().c_str());
|
|
||||||
}
|
}
|
||||||
/**/
|
/**/
|
||||||
// _loadingNodeParentHierarchy.push_back(node);
|
// _loadingNodeParentHierarchy.push_back(node);
|
||||||
|
@ -1093,12 +1085,10 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree, const
|
||||||
|
|
||||||
auto children = nodetree->children();
|
auto children = nodetree->children();
|
||||||
int size = children->size();
|
int size = children->size();
|
||||||
CCLOG("size = %d", size);
|
|
||||||
for (int i = 0; i < size; ++i)
|
for (int i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
auto subNodeTree = children->Get(i);
|
auto subNodeTree = children->Get(i);
|
||||||
Node* child = nodeWithFlatBuffers(subNodeTree, callback);
|
Node* child = nodeWithFlatBuffers(subNodeTree, callback);
|
||||||
CCLOG("child = %p", child);
|
|
||||||
if (child)
|
if (child)
|
||||||
{
|
{
|
||||||
PageView* pageView = dynamic_cast<PageView*>(node);
|
PageView* pageView = dynamic_cast<PageView*>(node);
|
||||||
|
@ -1356,7 +1346,6 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nod
|
||||||
Node* node = nullptr;
|
Node* node = nullptr;
|
||||||
|
|
||||||
std::string classname = nodetree->classname()->c_str();
|
std::string classname = nodetree->classname()->c_str();
|
||||||
CCLOG("classname = %s", classname.c_str());
|
|
||||||
|
|
||||||
auto options = nodetree->options();
|
auto options = nodetree->options();
|
||||||
|
|
||||||
|
@ -1365,7 +1354,6 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nod
|
||||||
auto reader = ProjectNodeReader::getInstance();
|
auto reader = ProjectNodeReader::getInstance();
|
||||||
auto projectNodeOptions = (ProjectNodeOptions*)options->data();
|
auto projectNodeOptions = (ProjectNodeOptions*)options->data();
|
||||||
std::string filePath = projectNodeOptions->fileName()->c_str();
|
std::string filePath = projectNodeOptions->fileName()->c_str();
|
||||||
CCLOG("filePath = %s", filePath.c_str());
|
|
||||||
|
|
||||||
cocostudio::timeline::ActionTimeline* action = nullptr;
|
cocostudio::timeline::ActionTimeline* action = nullptr;
|
||||||
if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath))
|
if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath))
|
||||||
|
@ -1431,12 +1419,10 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nod
|
||||||
|
|
||||||
auto children = nodetree->children();
|
auto children = nodetree->children();
|
||||||
int size = children->size();
|
int size = children->size();
|
||||||
CCLOG("size = %d", size);
|
|
||||||
for (int i = 0; i < size; ++i)
|
for (int i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
auto subNodeTree = children->Get(i);
|
auto subNodeTree = children->Get(i);
|
||||||
Node* child = nodeWithFlatBuffersForSimulator(subNodeTree);
|
Node* child = nodeWithFlatBuffersForSimulator(subNodeTree);
|
||||||
CCLOG("child = %p", child);
|
|
||||||
if (child)
|
if (child)
|
||||||
{
|
{
|
||||||
PageView* pageView = dynamic_cast<PageView*>(node);
|
PageView* pageView = dynamic_cast<PageView*>(node);
|
||||||
|
|
|
@ -63,7 +63,6 @@ void ActionManagerEx::initWithDictionary(const char* jsonName,const rapidjson::V
|
||||||
std::string path = jsonName;
|
std::string path = jsonName;
|
||||||
ssize_t pos = path.find_last_of("/");
|
ssize_t pos = path.find_last_of("/");
|
||||||
std::string fileName = path.substr(pos+1,path.length());
|
std::string fileName = path.substr(pos+1,path.length());
|
||||||
CCLOG("filename == %s",fileName.c_str());
|
|
||||||
cocos2d::Vector<ActionObject*> actionList;
|
cocos2d::Vector<ActionObject*> actionList;
|
||||||
int actionCount = DICTOOL->getArrayCount_json(dic, "actionlist");
|
int actionCount = DICTOOL->getArrayCount_json(dic, "actionlist");
|
||||||
for (int i=0; i<actionCount; i++) {
|
for (int i=0; i<actionCount; i++) {
|
||||||
|
@ -84,7 +83,6 @@ void ActionManagerEx::initWithDictionary(const char* jsonName,const rapidjson::V
|
||||||
std::string path = file;
|
std::string path = file;
|
||||||
ssize_t pos = path.find_last_of("/");
|
ssize_t pos = path.find_last_of("/");
|
||||||
std::string fileName = path.substr(pos+1,path.length());
|
std::string fileName = path.substr(pos+1,path.length());
|
||||||
CCLOG("filename == %s",fileName.c_str());
|
|
||||||
cocos2d::Vector<ActionObject*> actionList;
|
cocos2d::Vector<ActionObject*> actionList;
|
||||||
|
|
||||||
stExpCocoNode *stChildArray = pCocoNode->GetChildArray(cocoLoader);
|
stExpCocoNode *stChildArray = pCocoNode->GetChildArray(cocoLoader);
|
||||||
|
@ -118,7 +116,6 @@ ActionObject* ActionManagerEx::getActionByName(const char* jsonName,const char*
|
||||||
std::string path = jsonName;
|
std::string path = jsonName;
|
||||||
ssize_t pos = path.find_last_of("/");
|
ssize_t pos = path.find_last_of("/");
|
||||||
std::string fileName = path.substr(pos+1,path.length());
|
std::string fileName = path.substr(pos+1,path.length());
|
||||||
CCLOG("find filename == %s",fileName.c_str());
|
|
||||||
auto iterator = _actionDic.find(fileName);
|
auto iterator = _actionDic.find(fileName);
|
||||||
if (iterator == _actionDic.end())
|
if (iterator == _actionDic.end())
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,6 +26,7 @@ THE SOFTWARE.
|
||||||
#include "cocostudio/CCActionFrameEasing.h"
|
#include "cocostudio/CCActionFrameEasing.h"
|
||||||
#include "ui/UIWidget.h"
|
#include "ui/UIWidget.h"
|
||||||
#include "ui/UIHelper.h"
|
#include "ui/UIHelper.h"
|
||||||
|
#include "ui/UILayout.h"
|
||||||
#include "cocostudio/CocoLoader.h"
|
#include "cocostudio/CocoLoader.h"
|
||||||
#include "base/ccUtils.h"
|
#include "base/ccUtils.h"
|
||||||
|
|
||||||
|
@ -73,7 +74,14 @@ ActionNode::~ActionNode()
|
||||||
|
|
||||||
void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root)
|
void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root)
|
||||||
{
|
{
|
||||||
|
Widget * rw = dynamic_cast<Widget *>(root);
|
||||||
|
if (nullptr == rw)
|
||||||
|
return;
|
||||||
|
|
||||||
setActionTag(DICTOOL->getIntValue_json(dic, "ActionTag"));
|
setActionTag(DICTOOL->getIntValue_json(dic, "ActionTag"));
|
||||||
|
Widget* node = Helper::seekActionWidgetByActionTag(rw, getActionTag());
|
||||||
|
bool positionOffset = node && (nullptr == (dynamic_cast<Layout *>(node)));
|
||||||
|
|
||||||
int actionFrameCount = DICTOOL->getArrayCount_json(dic, "actionframelist");
|
int actionFrameCount = DICTOOL->getArrayCount_json(dic, "actionframelist");
|
||||||
for (int i=0; i<actionFrameCount; i++)
|
for (int i=0; i<actionFrameCount; i++)
|
||||||
{
|
{
|
||||||
|
@ -97,6 +105,12 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root)
|
||||||
{
|
{
|
||||||
float positionX = DICTOOL->getFloatValue_json(actionFrameDic, "positionx");
|
float positionX = DICTOOL->getFloatValue_json(actionFrameDic, "positionx");
|
||||||
float positionY = DICTOOL->getFloatValue_json(actionFrameDic, "positiony");
|
float positionY = DICTOOL->getFloatValue_json(actionFrameDic, "positiony");
|
||||||
|
if (positionOffset && (nullptr != node->getParent()))
|
||||||
|
{
|
||||||
|
Vec2 AnchorPointIn = node->getParent()->getAnchorPointInPoints();
|
||||||
|
positionX += AnchorPointIn.x;
|
||||||
|
positionY += AnchorPointIn.y;
|
||||||
|
}
|
||||||
ActionMoveFrame* actionFrame = new (std::nothrow) ActionMoveFrame();
|
ActionMoveFrame* actionFrame = new (std::nothrow) ActionMoveFrame();
|
||||||
actionFrame->setFrameIndex(frameInex);
|
actionFrame->setFrameIndex(frameInex);
|
||||||
actionFrame->setEasingType(frameTweenType);
|
actionFrame->setEasingType(frameTweenType);
|
||||||
|
|
|
@ -250,7 +250,7 @@ const cocos2d::Map<std::string, TextureData*>& ArmatureDataManager::getTextureDa
|
||||||
return _textureDatas;
|
return _textureDatas;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCArmatureDataManager::addRelativeData(const std::string& configFilePath)
|
void ArmatureDataManager::addRelativeData(const std::string& configFilePath)
|
||||||
{
|
{
|
||||||
if (_relativeDatas.find(configFilePath) == _relativeDatas.end())
|
if (_relativeDatas.find(configFilePath) == _relativeDatas.end())
|
||||||
{
|
{
|
||||||
|
@ -258,7 +258,7 @@ void CCArmatureDataManager::addRelativeData(const std::string& configFilePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RelativeData *CCArmatureDataManager::getRelativeData(const std::string& configFilePath)
|
RelativeData *ArmatureDataManager::getRelativeData(const std::string& configFilePath)
|
||||||
{
|
{
|
||||||
return &_relativeDatas[configFilePath];
|
return &_relativeDatas[configFilePath];
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,6 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName,
|
||||||
{
|
{
|
||||||
pCom = createComponent(comName);
|
pCom = createComponent(comName);
|
||||||
}
|
}
|
||||||
CCLOG("classname = %s", comName);
|
|
||||||
if (pCom != nullptr)
|
if (pCom != nullptr)
|
||||||
{
|
{
|
||||||
data->_rData = nullptr;
|
data->_rData = nullptr;
|
||||||
|
@ -270,7 +269,6 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par
|
||||||
}
|
}
|
||||||
const char *comName = DICTOOL->getStringValue_json(subDict, "classname");
|
const char *comName = DICTOOL->getStringValue_json(subDict, "classname");
|
||||||
Component *com = this->createComponent(comName);
|
Component *com = this->createComponent(comName);
|
||||||
CCLOG("classname = %s", comName);
|
|
||||||
SerData *data = new (std::nothrow) SerData();
|
SerData *data = new (std::nothrow) SerData();
|
||||||
if (com != nullptr)
|
if (com != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -388,7 +386,6 @@ cocos2d::Node* SceneReader::createObject(CocoLoader *cocoLoader, stExpCocoNode *
|
||||||
{
|
{
|
||||||
pCom = createComponent(comName);
|
pCom = createComponent(comName);
|
||||||
}
|
}
|
||||||
CCLOG("classname = %s", comName);
|
|
||||||
if (pCom != nullptr)
|
if (pCom != nullptr)
|
||||||
{
|
{
|
||||||
data->_rData = nullptr;
|
data->_rData = nullptr;
|
||||||
|
|
|
@ -165,7 +165,7 @@ void ArmatureNodeReader::setPropsWithFlatBuffers(cocos2d::Node *node,
|
||||||
|
|
||||||
cocos2d::Node* ArmatureNodeReader::createNodeWithFlatBuffers(const flatbuffers::Table *nodeOptions)
|
cocos2d::Node* ArmatureNodeReader::createNodeWithFlatBuffers(const flatbuffers::Table *nodeOptions)
|
||||||
{
|
{
|
||||||
auto node = CCArmature::create();
|
auto node = Armature::create();
|
||||||
|
|
||||||
// self
|
// self
|
||||||
auto options = (flatbuffers::CSArmatureNodeOption*)nodeOptions;
|
auto options = (flatbuffers::CSArmatureNodeOption*)nodeOptions;
|
||||||
|
|
|
@ -43,6 +43,7 @@ namespace cocos2d { namespace network {
|
||||||
|
|
||||||
static int sTaskCounter;
|
static int sTaskCounter;
|
||||||
static int sDownloaderCounter;
|
static int sDownloaderCounter;
|
||||||
|
static bool _registered = false;
|
||||||
|
|
||||||
struct DownloadTaskAndroid : public IDownloadTask
|
struct DownloadTaskAndroid : public IDownloadTask
|
||||||
{
|
{
|
||||||
|
@ -53,7 +54,6 @@ namespace cocos2d { namespace network {
|
||||||
}
|
}
|
||||||
virtual ~DownloadTaskAndroid()
|
virtual ~DownloadTaskAndroid()
|
||||||
{
|
{
|
||||||
|
|
||||||
DLLOG("Destruct DownloadTaskAndroid: %p", this);
|
DLLOG("Destruct DownloadTaskAndroid: %p", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,8 +65,6 @@ namespace cocos2d { namespace network {
|
||||||
: _id(++sDownloaderCounter)
|
: _id(++sDownloaderCounter)
|
||||||
, _impl(nullptr)
|
, _impl(nullptr)
|
||||||
{
|
{
|
||||||
// use local static variable make sure native methods registered once
|
|
||||||
static bool _registered = _registerNativeMethods(JniHelper::getEnv());
|
|
||||||
DLLOG("Construct DownloaderAndroid: %p", this);
|
DLLOG("Construct DownloaderAndroid: %p", this);
|
||||||
JniMethodInfo methodInfo;
|
JniMethodInfo methodInfo;
|
||||||
if (JniHelper::getStaticMethodInfo(methodInfo,
|
if (JniHelper::getStaticMethodInfo(methodInfo,
|
||||||
|
@ -163,6 +161,7 @@ namespace cocos2d { namespace network {
|
||||||
}
|
}
|
||||||
DownloadTaskAndroid *coTask = iter->second;
|
DownloadTaskAndroid *coTask = iter->second;
|
||||||
string str = (errStr ? errStr : "");
|
string str = (errStr ? errStr : "");
|
||||||
|
_taskMap.erase(iter);
|
||||||
onTaskFinish(*coTask->task,
|
onTaskFinish(*coTask->task,
|
||||||
errStr ? DownloadTask::ERROR_IMPL_INTERNAL : DownloadTask::ERROR_NO_ERROR,
|
errStr ? DownloadTask::ERROR_IMPL_INTERNAL : DownloadTask::ERROR_NO_ERROR,
|
||||||
errCode,
|
errCode,
|
||||||
|
@ -170,7 +169,15 @@ namespace cocos2d { namespace network {
|
||||||
data
|
data
|
||||||
);
|
);
|
||||||
coTask->task.reset();
|
coTask->task.reset();
|
||||||
_taskMap.erase(iter);
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void _preloadJavaDownloaderClass()
|
||||||
|
{
|
||||||
|
if(!_registered)
|
||||||
|
{
|
||||||
|
_registered = _registerNativeMethods(JniHelper::getEnv());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace cocos2d::network
|
} // namespace cocos2d::network
|
||||||
|
|
|
@ -50,5 +50,8 @@ namespace cocos2d { namespace network
|
||||||
std::unordered_map<int, DownloadTaskAndroid*> _taskMap;
|
std::unordered_map<int, DownloadTaskAndroid*> _taskMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Load java downloader class from main thread, to void addImageAsync function
|
||||||
|
// perform in sub-thread cause java downloader unusable
|
||||||
|
void _preloadJavaDownloaderClass();
|
||||||
}} // namespace cocos2d::network
|
}} // namespace cocos2d::network
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,18 @@
|
||||||
/// @cond
|
/// @cond
|
||||||
@interface HttpAsynConnection : NSObject <NSURLConnectionDelegate, NSURLConnectionDataDelegate>
|
@interface HttpAsynConnection : NSObject <NSURLConnectionDelegate, NSURLConnectionDataDelegate>
|
||||||
{
|
{
|
||||||
|
NSString *srcURL;
|
||||||
|
NSString *sslFile;
|
||||||
|
NSDictionary *responseHeader;
|
||||||
|
NSMutableData *responseData;
|
||||||
|
NSInteger getDataTime;
|
||||||
|
NSInteger responseCode;
|
||||||
|
NSString *statusString;
|
||||||
|
NSError *responseError;
|
||||||
|
NSError *connError;
|
||||||
|
NSURLConnection *conn;
|
||||||
|
bool finish;
|
||||||
|
NSRunLoop *runLoop;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The original URL to download. Due to redirects the actual content may come from another URL
|
// The original URL to download. Due to redirects the actual content may come from another URL
|
||||||
|
|
|
@ -35,18 +35,18 @@
|
||||||
|
|
||||||
@implementation HttpAsynConnection
|
@implementation HttpAsynConnection
|
||||||
|
|
||||||
@synthesize srcURL;
|
@synthesize srcURL = srcURL;
|
||||||
@synthesize sslFile;
|
@synthesize sslFile = sslFile;
|
||||||
@synthesize responseHeader;
|
@synthesize responseHeader = responseHeader;
|
||||||
@synthesize responseData;
|
@synthesize responseData = responseData;
|
||||||
@synthesize getDataTime;
|
@synthesize getDataTime = getDataTime;
|
||||||
@synthesize responseCode;
|
@synthesize responseCode = responseCode;
|
||||||
@synthesize statusString;
|
@synthesize statusString = statusString;
|
||||||
@synthesize responseError;
|
@synthesize responseError = responseError;
|
||||||
@synthesize connError;
|
@synthesize connError = connError;
|
||||||
@synthesize conn;
|
@synthesize conn = conn;
|
||||||
@synthesize finish;
|
@synthesize finish = finish;
|
||||||
@synthesize runLoop;
|
@synthesize runLoop = runLoop;
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
|
|
|
@ -242,7 +242,7 @@ public:
|
||||||
*/
|
*/
|
||||||
CC_DEPRECATED_ATTRIBUTE inline void setResponseCallback(Ref* pTarget, SEL_CallFuncND pSelector)
|
CC_DEPRECATED_ATTRIBUTE inline void setResponseCallback(Ref* pTarget, SEL_CallFuncND pSelector)
|
||||||
{
|
{
|
||||||
setResponseCallback(pTarget, (SEL_HttpResponse) pSelector);
|
doSetResponseCallback(pTarget, (SEL_HttpResponse)pSelector);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -252,15 +252,9 @@ public:
|
||||||
* @param pTarget the target object pointer.
|
* @param pTarget the target object pointer.
|
||||||
* @param pSelector the SEL_HttpResponse function.
|
* @param pSelector the SEL_HttpResponse function.
|
||||||
*/
|
*/
|
||||||
CC_DEPRECATED_ATTRIBUTE inline void setResponseCallback(Ref* pTarget, SEL_HttpResponse pSelector)
|
inline void setResponseCallback(Ref* pTarget, SEL_HttpResponse pSelector)
|
||||||
{
|
{
|
||||||
_pTarget = pTarget;
|
doSetResponseCallback(pTarget, pSelector);
|
||||||
_pSelector = pSelector;
|
|
||||||
|
|
||||||
if (_pTarget)
|
|
||||||
{
|
|
||||||
_pTarget->retain();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Set response callback function of HttpRequest object.
|
* Set response callback function of HttpRequest object.
|
||||||
|
@ -342,6 +336,22 @@ public:
|
||||||
return _headers;
|
return _headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
inline void doSetResponseCallback(Ref* pTarget, SEL_HttpResponse pSelector)
|
||||||
|
{
|
||||||
|
if (_pTarget)
|
||||||
|
{
|
||||||
|
_pTarget->release();
|
||||||
|
}
|
||||||
|
|
||||||
|
_pTarget = pTarget;
|
||||||
|
_pSelector = pSelector;
|
||||||
|
if (_pTarget)
|
||||||
|
{
|
||||||
|
_pTarget->retain();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// properties
|
// properties
|
||||||
Type _requestType; /// kHttpRequestGet, kHttpRequestPost or other enums
|
Type _requestType; /// kHttpRequestGet, kHttpRequestPost or other enums
|
||||||
|
|
|
@ -76,6 +76,7 @@ PhysicsBody::PhysicsBody()
|
||||||
, _recordScaleX(1.f)
|
, _recordScaleX(1.f)
|
||||||
, _recordScaleY(1.f)
|
, _recordScaleY(1.f)
|
||||||
{
|
{
|
||||||
|
_name = COMPONENT_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicsBody::~PhysicsBody()
|
PhysicsBody::~PhysicsBody()
|
||||||
|
|
|
@ -826,10 +826,6 @@ void PhysicsWorld::update(float delta, bool userCall/* = false*/)
|
||||||
if (userCall)
|
if (userCall)
|
||||||
{
|
{
|
||||||
cpSpaceStep(_cpSpace, delta);
|
cpSpaceStep(_cpSpace, delta);
|
||||||
for (auto& body : _bodies)
|
|
||||||
{
|
|
||||||
body->update(delta);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -840,10 +836,6 @@ void PhysicsWorld::update(float delta, bool userCall/* = false*/)
|
||||||
for (int i = 0; i < _substeps; ++i)
|
for (int i = 0; i < _substeps; ++i)
|
||||||
{
|
{
|
||||||
cpSpaceStep(_cpSpace, dt);
|
cpSpaceStep(_cpSpace, dt);
|
||||||
for (auto& body : _bodies)
|
|
||||||
{
|
|
||||||
body->update(dt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_updateRateCount = 0;
|
_updateRateCount = 0;
|
||||||
_updateTime = 0.0f;
|
_updateTime = 0.0f;
|
||||||
|
|
|
@ -136,6 +136,13 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual Platform getTargetPlatform() = 0;
|
virtual Platform getTargetPlatform() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Get application version.
|
||||||
|
* @js NA
|
||||||
|
* @lua NA
|
||||||
|
*/
|
||||||
|
virtual std::string getVersion() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Open url in default browser.
|
@brief Open url in default browser.
|
||||||
@param String with url to open.
|
@param String with url to open.
|
||||||
|
|
|
@ -131,6 +131,7 @@ public:
|
||||||
inline MipmapInfo* getMipmaps() { return _mipmaps; }
|
inline MipmapInfo* getMipmaps() { return _mipmaps; }
|
||||||
inline bool hasPremultipliedAlpha() { return _hasPremultipliedAlpha; }
|
inline bool hasPremultipliedAlpha() { return _hasPremultipliedAlpha; }
|
||||||
CC_DEPRECATED_ATTRIBUTE inline bool isPremultipliedAlpha() { return _hasPremultipliedAlpha; }
|
CC_DEPRECATED_ATTRIBUTE inline bool isPremultipliedAlpha() { return _hasPremultipliedAlpha; }
|
||||||
|
inline std::string getFilePath() const { return _filePath; }
|
||||||
|
|
||||||
int getBitPerPixel();
|
int getBitPerPixel();
|
||||||
bool hasAlpha();
|
bool hasAlpha();
|
||||||
|
|
|
@ -200,6 +200,11 @@ Application::Platform Application::getTargetPlatform()
|
||||||
return Platform::OS_ANDROID;
|
return Platform::OS_ANDROID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Application::getVersion()
|
||||||
|
{
|
||||||
|
return getVersionJNI();
|
||||||
|
}
|
||||||
|
|
||||||
bool Application::openURL(const std::string &url)
|
bool Application::openURL(const std::string &url)
|
||||||
{
|
{
|
||||||
return openURLJNI(url.c_str());
|
return openURLJNI(url.c_str());
|
||||||
|
|
|
@ -84,6 +84,11 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual Platform getTargetPlatform();
|
virtual Platform getTargetPlatform();
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Get application version.
|
||||||
|
*/
|
||||||
|
virtual std::string getVersion() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Open url in default browser
|
@brief Open url in default browser
|
||||||
@param String with url to open.
|
@param String with url to open.
|
||||||
|
|
|
@ -50,46 +50,6 @@ import javax.microedition.khronos.egl.EGL10;
|
||||||
import javax.microedition.khronos.egl.EGLConfig;
|
import javax.microedition.khronos.egl.EGLConfig;
|
||||||
import javax.microedition.khronos.egl.EGLDisplay;
|
import javax.microedition.khronos.egl.EGLDisplay;
|
||||||
|
|
||||||
class ResizeLayout extends FrameLayout{
|
|
||||||
private boolean mEnableForceDoLayout = false;
|
|
||||||
|
|
||||||
public ResizeLayout(Context context){
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResizeLayout(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnableForceDoLayout(boolean flag){
|
|
||||||
mEnableForceDoLayout = flag;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
|
||||||
super.onLayout(changed, l, t, r, b);
|
|
||||||
if(mEnableForceDoLayout){
|
|
||||||
/*This is a hot-fix for some android devices which don't do layout when the main window
|
|
||||||
* is paned. We refersh the layout in 24 frames per seconds.
|
|
||||||
* When the editBox is lose focus or when user begin to type, the do layout is disabled.
|
|
||||||
*/
|
|
||||||
final Handler handler = new Handler();
|
|
||||||
handler.postDelayed(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
//Do something after 100ms
|
|
||||||
requestLayout();
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
}, 1000 / 24);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelperListener {
|
public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelperListener {
|
||||||
// ===========================================================
|
// ===========================================================
|
||||||
// Constants
|
// Constants
|
||||||
|
|
|
@ -212,6 +212,15 @@ public class Cocos2dxHelper {
|
||||||
sVibrateService.vibrate((long)(duration * 1000));
|
sVibrateService.vibrate((long)(duration * 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getVersion() {
|
||||||
|
try {
|
||||||
|
String version = Cocos2dxActivity.getContext().getPackageManager().getPackageInfo(Cocos2dxActivity.getContext().getPackageName(), 0).versionName;
|
||||||
|
return version;
|
||||||
|
} catch(Exception e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean openURL(String url) {
|
public static boolean openURL(String url) {
|
||||||
boolean ret = false;
|
boolean ret = false;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2010-2013 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.
|
||||||
|
****************************************************************************/
|
||||||
|
package org.cocos2dx.lib;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
|
public class ResizeLayout extends FrameLayout {
|
||||||
|
private boolean mEnableForceDoLayout = false;
|
||||||
|
|
||||||
|
public ResizeLayout(Context context){
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResizeLayout(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnableForceDoLayout(boolean flag){
|
||||||
|
mEnableForceDoLayout = flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||||
|
super.onLayout(changed, l, t, r, b);
|
||||||
|
if(mEnableForceDoLayout){
|
||||||
|
/*This is a hot-fix for some android devices which don't do layout when the main window
|
||||||
|
* is paned. We refersh the layout in 24 frames per seconds.
|
||||||
|
* When the editBox is lose focus or when user begin to type, the do layout is disabled.
|
||||||
|
*/
|
||||||
|
final Handler handler = new Handler();
|
||||||
|
handler.postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
//Do something after 100ms
|
||||||
|
requestLayout();
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
}, 1000 / 24);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -36,6 +36,7 @@ THE SOFTWARE.
|
||||||
#include "renderer/ccGLStateCache.h"
|
#include "renderer/ccGLStateCache.h"
|
||||||
#include "2d/CCDrawingPrimitives.h"
|
#include "2d/CCDrawingPrimitives.h"
|
||||||
#include "platform/android/jni/JniHelper.h"
|
#include "platform/android/jni/JniHelper.h"
|
||||||
|
#include "network/CCDownloader-android.h"
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
|
|
||||||
|
@ -81,6 +82,7 @@ JNIEXPORT void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, j
|
||||||
director->getEventDispatcher()->dispatchEvent(&recreatedEvent);
|
director->getEventDispatcher()->dispatchEvent(&recreatedEvent);
|
||||||
director->setGLDefaultValues();
|
director->setGLDefaultValues();
|
||||||
}
|
}
|
||||||
|
cocos2d::network::_preloadJavaDownloaderClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jintArray Java_org_cocos2dx_lib_Cocos2dxActivity_getGLContextAttrs(JNIEnv* env, jobject thiz)
|
JNIEXPORT jintArray Java_org_cocos2dx_lib_Cocos2dxActivity_getGLContextAttrs(JNIEnv* env, jobject thiz)
|
||||||
|
|
|
@ -205,6 +205,19 @@ void vibrateJni(float duration) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string getVersionJNI() {
|
||||||
|
JniMethodInfo t;
|
||||||
|
std::string ret("");
|
||||||
|
|
||||||
|
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getVersion", "()Ljava/lang/String;")) {
|
||||||
|
jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID);
|
||||||
|
t.env->DeleteLocalRef(t.classID);
|
||||||
|
ret = JniHelper::jstring2string(str);
|
||||||
|
t.env->DeleteLocalRef(str);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
extern bool openURLJNI(const char* url) {
|
extern bool openURLJNI(const char* url) {
|
||||||
JniMethodInfo t;
|
JniMethodInfo t;
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ extern void disableAccelerometerJni();
|
||||||
extern void setAccelerometerIntervalJni(float interval);
|
extern void setAccelerometerIntervalJni(float interval);
|
||||||
extern void setKeepScreenOnJni(bool value);
|
extern void setKeepScreenOnJni(bool value);
|
||||||
extern void vibrateJni(float duration);
|
extern void vibrateJni(float duration);
|
||||||
|
extern std::string getVersionJNI();
|
||||||
extern bool openURLJNI(const char* url);
|
extern bool openURLJNI(const char* url);
|
||||||
// functions for UserDefault
|
// functions for UserDefault
|
||||||
extern bool getBoolForKeyJNI(const char* key, bool defaultValue);
|
extern bool getBoolForKeyJNI(const char* key, bool defaultValue);
|
||||||
|
|
|
@ -67,31 +67,36 @@ public:
|
||||||
@brief Callback by Director for limit FPS.
|
@brief Callback by Director for limit FPS.
|
||||||
@param interval The time, expressed in seconds, between current frame and next.
|
@param interval The time, expressed in seconds, between current frame and next.
|
||||||
*/
|
*/
|
||||||
virtual void setAnimationInterval(float interval);
|
virtual void setAnimationInterval(float interval) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get current language config
|
@brief Get current language config
|
||||||
@return Current language config
|
@return Current language config
|
||||||
*/
|
*/
|
||||||
virtual LanguageType getCurrentLanguage();
|
virtual LanguageType getCurrentLanguage() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get current language iso 639-1 code
|
@brief Get current language iso 639-1 code
|
||||||
@return Current language iso 639-1 code
|
@return Current language iso 639-1 code
|
||||||
*/
|
*/
|
||||||
virtual const char * getCurrentLanguageCode();
|
virtual const char * getCurrentLanguageCode() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get target platform
|
@brief Get target platform
|
||||||
*/
|
*/
|
||||||
virtual Platform getTargetPlatform();
|
virtual Platform getTargetPlatform() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Get application version.
|
||||||
|
*/
|
||||||
|
virtual std::string getVersion() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Open url in default browser
|
@brief Open url in default browser
|
||||||
@param String with url to open.
|
@param String with url to open.
|
||||||
@return true if the resource located by the URL was successfully opened; otherwise false.
|
@return true if the resource located by the URL was successfully opened; otherwise false.
|
||||||
*/
|
*/
|
||||||
virtual bool openURL(const std::string &url);
|
virtual bool openURL(const std::string &url) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief This function will be called when the application screen size is changed.
|
@brief This function will be called when the application screen size is changed.
|
||||||
|
|
|
@ -139,6 +139,14 @@ Application::Platform Application::getTargetPlatform()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Application::getVersion() {
|
||||||
|
NSString* version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
|
||||||
|
if (version) {
|
||||||
|
return [version UTF8String];
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
bool Application::openURL(const std::string &url)
|
bool Application::openURL(const std::string &url)
|
||||||
{
|
{
|
||||||
NSString* msg = [NSString stringWithCString:url.c_str() encoding:NSUTF8StringEncoding];
|
NSString* msg = [NSString stringWithCString:url.c_str() encoding:NSUTF8StringEncoding];
|
||||||
|
|
|
@ -377,9 +377,8 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
|
||||||
|
|
||||||
for(UIView* view in subviews)
|
for(UIView* view in subviews)
|
||||||
{
|
{
|
||||||
if([view isKindOfClass:NSClassFromString(@"CCCustomUITextField")] ||
|
if([view isKindOfClass:NSClassFromString(@"UITextView")] ||
|
||||||
[view isKindOfClass:NSClassFromString(@"UISingleLineTextField")] ||
|
[view isKindOfClass:NSClassFromString(@"UITextField")])
|
||||||
[view isKindOfClass:NSClassFromString(@"UIMultilineTextField")])
|
|
||||||
{
|
{
|
||||||
if ([view isFirstResponder])
|
if ([view isFirstResponder])
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,16 +58,16 @@ public:
|
||||||
static int _depthFormat;
|
static int _depthFormat;
|
||||||
|
|
||||||
/** sets the content scale factor */
|
/** sets the content scale factor */
|
||||||
bool setContentScaleFactor(float contentScaleFactor) override;
|
virtual bool setContentScaleFactor(float contentScaleFactor) override;
|
||||||
|
|
||||||
/** returns the content scale factor */
|
/** returns the content scale factor */
|
||||||
float getContentScaleFactor() const override;
|
virtual float getContentScaleFactor() const override;
|
||||||
|
|
||||||
/** returns whether or not the view is in Retina Display mode */
|
/** returns whether or not the view is in Retina Display mode */
|
||||||
bool isRetinaDisplay() const override { return getContentScaleFactor() == 2.0; }
|
virtual bool isRetinaDisplay() const override { return getContentScaleFactor() == 2.0; }
|
||||||
|
|
||||||
/** returns the objective-c CCEAGLView instance */
|
/** returns the objective-c CCEAGLView instance */
|
||||||
void* getEAGLView() const override { return _eaglview; }
|
virtual void* getEAGLView() const override { return _eaglview; }
|
||||||
|
|
||||||
// overrides
|
// overrides
|
||||||
virtual bool isOpenGLReady() override;
|
virtual bool isOpenGLReady() override;
|
||||||
|
|
|
@ -136,6 +136,11 @@ Application::Platform Application::getTargetPlatform()
|
||||||
return Platform::OS_LINUX;
|
return Platform::OS_LINUX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Application::getVersion()
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
bool Application::openURL(const std::string &url)
|
bool Application::openURL(const std::string &url)
|
||||||
{
|
{
|
||||||
std::string op = std::string("open ").append(url);
|
std::string op = std::string("open ").append(url);
|
||||||
|
|
|
@ -78,6 +78,11 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual const char * getCurrentLanguageCode();
|
virtual const char * getCurrentLanguageCode();
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Get application version
|
||||||
|
*/
|
||||||
|
virtual std::string getVersion() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Open url in default browser
|
@brief Open url in default browser
|
||||||
@param String with url to open.
|
@param String with url to open.
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
@brief Callback by Director for limit FPS.
|
@brief Callback by Director for limit FPS.
|
||||||
@param interval The time, which expressed in second in second, between current frame and next.
|
@param interval The time, which expressed in second in second, between current frame and next.
|
||||||
*/
|
*/
|
||||||
virtual void setAnimationInterval(float interval);
|
virtual void setAnimationInterval(float interval) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get status bar rectangle in GLView window.
|
@brief Get status bar rectangle in GLView window.
|
||||||
|
@ -78,25 +78,30 @@ public:
|
||||||
@brief Get current language config
|
@brief Get current language config
|
||||||
@return Current language config
|
@return Current language config
|
||||||
*/
|
*/
|
||||||
virtual LanguageType getCurrentLanguage();
|
virtual LanguageType getCurrentLanguage() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get current language iso 639-1 code
|
@brief Get current language iso 639-1 code
|
||||||
@return Current language iso 639-1 code
|
@return Current language iso 639-1 code
|
||||||
*/
|
*/
|
||||||
virtual const char * getCurrentLanguageCode();
|
virtual const char * getCurrentLanguageCode() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get target platform
|
@brief Get target platform
|
||||||
*/
|
*/
|
||||||
virtual Platform getTargetPlatform();
|
virtual Platform getTargetPlatform() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Get application version.
|
||||||
|
*/
|
||||||
|
virtual std::string getVersion() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Open url in default browser
|
@brief Open url in default browser
|
||||||
@param String with url to open.
|
@param String with url to open.
|
||||||
@return true if the resource located by the URL was successfully opened; otherwise false.
|
@return true if the resource located by the URL was successfully opened; otherwise false.
|
||||||
*/
|
*/
|
||||||
virtual bool openURL(const std::string &url);
|
virtual bool openURL(const std::string &url) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the Resource root path.
|
* Sets the Resource root path.
|
||||||
|
|
|
@ -118,6 +118,14 @@ Application::Platform Application::getTargetPlatform()
|
||||||
return Platform::OS_MAC;
|
return Platform::OS_MAC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Application::getVersion() {
|
||||||
|
NSString* version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
|
||||||
|
if (version) {
|
||||||
|
return [version UTF8String];
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// static member function
|
// static member function
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -217,6 +217,11 @@ Application::Platform Application::getTargetPlatform()
|
||||||
return Platform::OS_WINDOWS;
|
return Platform::OS_WINDOWS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Application::getVersion()
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
bool Application::openURL(const std::string &url)
|
bool Application::openURL(const std::string &url)
|
||||||
{
|
{
|
||||||
WCHAR *temp = new WCHAR[url.size() + 1];
|
WCHAR *temp = new WCHAR[url.size() + 1];
|
||||||
|
|
|
@ -75,6 +75,11 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual Platform getTargetPlatform();
|
virtual Platform getTargetPlatform();
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Get application version
|
||||||
|
*/
|
||||||
|
virtual std::string getVersion() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Open url in default browser
|
@brief Open url in default browser
|
||||||
@param String with url to open.
|
@param String with url to open.
|
||||||
|
|
|
@ -136,8 +136,9 @@ static void _checkPath()
|
||||||
{
|
{
|
||||||
if (s_resourcePath.empty())
|
if (s_resourcePath.empty())
|
||||||
{
|
{
|
||||||
WCHAR *pUtf16ExePath = nullptr;
|
WCHAR utf16Path[CC_MAX_PATH] = { 0 };
|
||||||
_get_wpgmptr(&pUtf16ExePath);
|
GetModuleFileNameW(NULL, utf16Path, CC_MAX_PATH - 1);
|
||||||
|
WCHAR *pUtf16ExePath = &(utf16Path[0]);
|
||||||
|
|
||||||
// We need only directory part without exe
|
// We need only directory part without exe
|
||||||
WCHAR *pUtf16DirEnd = wcsrchr(pUtf16ExePath, L'\\');
|
WCHAR *pUtf16DirEnd = wcsrchr(pUtf16ExePath, L'\\');
|
||||||
|
|
|
@ -36,6 +36,7 @@ using namespace Windows::Foundation;
|
||||||
#include "platform/CCFileUtils.h"
|
#include "platform/CCFileUtils.h"
|
||||||
#include "CCWinRTUtils.h"
|
#include "CCWinRTUtils.h"
|
||||||
#include "platform/CCApplication.h"
|
#include "platform/CCApplication.h"
|
||||||
|
#include "tinyxml2/tinyxml2.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief This function change the PVRFrame show/hide setting in register.
|
@brief This function change the PVRFrame show/hide setting in register.
|
||||||
|
@ -225,6 +226,25 @@ Application::Platform Application::getTargetPlatform()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Application::getVersion()
|
||||||
|
{
|
||||||
|
std::string r("");
|
||||||
|
std::string s = FileUtils::getInstance()->getStringFromFile("WMAppManifest.xml");
|
||||||
|
if (!s.empty()) {
|
||||||
|
tinyxml2::XMLDocument doc;
|
||||||
|
if (!doc.Parse(s.c_str())) {
|
||||||
|
tinyxml2::XMLElement *app = doc.RootElement()->FirstChildElement("App");
|
||||||
|
if (app) {
|
||||||
|
const char* version = app->Attribute("Version");
|
||||||
|
if (version) {
|
||||||
|
r = version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
bool Application::openURL(const std::string &url)
|
bool Application::openURL(const std::string &url)
|
||||||
{
|
{
|
||||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT
|
#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT
|
||||||
|
|
|
@ -63,6 +63,11 @@ public:
|
||||||
@brief Get target platform
|
@brief Get target platform
|
||||||
*/
|
*/
|
||||||
virtual Platform getTargetPlatform() override;
|
virtual Platform getTargetPlatform() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Get application version
|
||||||
|
*/
|
||||||
|
virtual std::string getVersion() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Open url in default browser
|
@brief Open url in default browser
|
||||||
|
|
|
@ -436,6 +436,7 @@ Texture2D::Texture2D()
|
||||||
, _shaderProgram(nullptr)
|
, _shaderProgram(nullptr)
|
||||||
, _antialiasEnabled(true)
|
, _antialiasEnabled(true)
|
||||||
, _ninePatchInfo(nullptr)
|
, _ninePatchInfo(nullptr)
|
||||||
|
, _valid(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,7 +731,7 @@ bool Texture2D::initWithImage(Image *image, PixelFormat format)
|
||||||
|
|
||||||
int imageWidth = image->getWidth();
|
int imageWidth = image->getWidth();
|
||||||
int imageHeight = image->getHeight();
|
int imageHeight = image->getHeight();
|
||||||
|
this->_filePath = image->getFilePath();
|
||||||
Configuration *conf = Configuration::getInstance();
|
Configuration *conf = Configuration::getInstance();
|
||||||
|
|
||||||
int maxTextureSize = conf->getMaxTextureSize();
|
int maxTextureSize = conf->getMaxTextureSize();
|
||||||
|
@ -756,6 +757,9 @@ bool Texture2D::initWithImage(Image *image, PixelFormat format)
|
||||||
|
|
||||||
initWithMipmaps(image->getMipmaps(), image->getNumberOfMipmaps(), image->getRenderFormat(), imageWidth, imageHeight);
|
initWithMipmaps(image->getMipmaps(), image->getNumberOfMipmaps(), image->getRenderFormat(), imageWidth, imageHeight);
|
||||||
|
|
||||||
|
// set the premultiplied tag
|
||||||
|
_hasPremultipliedAlpha = image->hasPremultipliedAlpha();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (image->isCompressed())
|
else if (image->isCompressed())
|
||||||
|
@ -766,6 +770,10 @@ bool Texture2D::initWithImage(Image *image, PixelFormat format)
|
||||||
}
|
}
|
||||||
|
|
||||||
initWithData(tempData, tempDataLen, image->getRenderFormat(), imageWidth, imageHeight, imageSize);
|
initWithData(tempData, tempDataLen, image->getRenderFormat(), imageWidth, imageHeight, imageSize);
|
||||||
|
|
||||||
|
// set the premultiplied tag
|
||||||
|
_hasPremultipliedAlpha = image->hasPremultipliedAlpha();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -406,6 +406,11 @@ public:
|
||||||
/** Get a shader program from the texture.*/
|
/** Get a shader program from the texture.*/
|
||||||
GLProgram* getGLProgram() const;
|
GLProgram* getGLProgram() const;
|
||||||
|
|
||||||
|
/** Set if the texture is valid, when it been set as false, it will display as default "file missing texture" */
|
||||||
|
void setValid(bool valid) { _valid = valid; }
|
||||||
|
|
||||||
|
bool isValid() const { return _valid; }
|
||||||
|
std::string getPath()const { return _filePath; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Get pixel info map, the key-value pairs is PixelFormat and PixelFormatInfo.*/
|
/** Get pixel info map, the key-value pairs is PixelFormat and PixelFormatInfo.*/
|
||||||
|
@ -540,6 +545,9 @@ protected:
|
||||||
friend class SpriteFrameCache;
|
friend class SpriteFrameCache;
|
||||||
friend class TextureCache;
|
friend class TextureCache;
|
||||||
friend class ui::Scale9Sprite;
|
friend class ui::Scale9Sprite;
|
||||||
|
|
||||||
|
bool _valid;
|
||||||
|
std::string _filePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ TextureCache::TextureCache()
|
||||||
: _loadingThread(nullptr)
|
: _loadingThread(nullptr)
|
||||||
, _needQuit(false)
|
, _needQuit(false)
|
||||||
, _asyncRefCount(0)
|
, _asyncRefCount(0)
|
||||||
|
, _dirty(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,7 +494,8 @@ void TextureCache::removeTexture(Texture2D* texture)
|
||||||
|
|
||||||
for( auto it=_textures.cbegin(); it!=_textures.cend(); /* nothing */ ) {
|
for( auto it=_textures.cbegin(); it!=_textures.cend(); /* nothing */ ) {
|
||||||
if( it->second == texture ) {
|
if( it->second == texture ) {
|
||||||
texture->release();
|
texture->setValid(false);
|
||||||
|
texture->autorelease();
|
||||||
_textures.erase(it++);
|
_textures.erase(it++);
|
||||||
break;
|
break;
|
||||||
} else
|
} else
|
||||||
|
@ -512,7 +514,8 @@ void TextureCache::removeTextureForKey(const std::string &textureKeyName)
|
||||||
}
|
}
|
||||||
|
|
||||||
if( it != _textures.end() ) {
|
if( it != _textures.end() ) {
|
||||||
(it->second)->release();
|
it->second->setValid(false);
|
||||||
|
(it->second)->autorelease();
|
||||||
_textures.erase(it);
|
_textures.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -598,6 +601,36 @@ std::string TextureCache::getCachedTextureInfo() const
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextureCache::renameTextureWithKey(const std::string srcName, const std::string dstName)
|
||||||
|
{
|
||||||
|
std::string key = srcName;
|
||||||
|
auto it = _textures.find(key);
|
||||||
|
|
||||||
|
if( it == _textures.end() ) {
|
||||||
|
key = FileUtils::getInstance()->fullPathForFilename(srcName);
|
||||||
|
it = _textures.find(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( it != _textures.end() ) {
|
||||||
|
std::string fullpath = FileUtils::getInstance()->fullPathForFilename(dstName);
|
||||||
|
Texture2D* tex = it->second;
|
||||||
|
|
||||||
|
Image* image = new Image();
|
||||||
|
if (image)
|
||||||
|
{
|
||||||
|
bool ret = image->initWithImageFile(dstName);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
tex->initWithImage(image);
|
||||||
|
_textures.insert(std::make_pair(fullpath, tex));
|
||||||
|
_textures.erase(it);
|
||||||
|
this->setDirty(true);
|
||||||
|
}
|
||||||
|
CC_SAFE_DELETE(image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||||
|
|
||||||
std::list<VolatileTexture*> VolatileTextureMgr::_textures;
|
std::list<VolatileTexture*> VolatileTextureMgr::_textures;
|
||||||
|
|
|
@ -204,6 +204,20 @@ public:
|
||||||
*/
|
*/
|
||||||
const std::string getTextureFilePath(Texture2D* texture)const;
|
const std::string getTextureFilePath(Texture2D* texture)const;
|
||||||
|
|
||||||
|
void setDirty(bool dirty) { _dirty = dirty; }
|
||||||
|
bool isDirty() const { return _dirty; }
|
||||||
|
|
||||||
|
/** Reload texuture from a new file.
|
||||||
|
* This function is mainly for editor, won't suggest use it in game for performance reason.
|
||||||
|
*
|
||||||
|
* @param srcName Original texture file name.
|
||||||
|
* @param dstName New texture file name.
|
||||||
|
*
|
||||||
|
* @since v3.10
|
||||||
|
*/
|
||||||
|
void renameTextureWithKey(const std::string srcName, const std::string dstName);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addImageAsyncCallBack(float dt);
|
void addImageAsyncCallBack(float dt);
|
||||||
void loadImage();
|
void loadImage();
|
||||||
|
@ -228,6 +242,8 @@ protected:
|
||||||
int _asyncRefCount;
|
int _asyncRefCount;
|
||||||
|
|
||||||
std::unordered_map<std::string, Texture2D*> _textures;
|
std::unordered_map<std::string, Texture2D*> _textures;
|
||||||
|
|
||||||
|
bool _dirty;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||||
|
|
|
@ -1329,11 +1329,11 @@ jsb.Terrain = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method initHeightMap
|
* @method initHeightMap
|
||||||
* @param {char} arg0
|
* @param {String} arg0
|
||||||
* @return {bool}
|
* @return {bool}
|
||||||
*/
|
*/
|
||||||
initHeightMap : function (
|
initHeightMap : function (
|
||||||
char
|
str
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -1373,10 +1373,10 @@ map
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method resetHeightMap
|
* @method resetHeightMap
|
||||||
* @param {char} arg0
|
* @param {String} arg0
|
||||||
*/
|
*/
|
||||||
resetHeightMap : function (
|
resetHeightMap : function (
|
||||||
char
|
str
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
},
|
},
|
||||||
|
|
|
@ -474,6 +474,18 @@ removeAllListener : function (
|
||||||
{
|
{
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method initSystem
|
||||||
|
* @param {String} arg0
|
||||||
|
* @return {bool}
|
||||||
|
*/
|
||||||
|
initSystem : function (
|
||||||
|
str
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method setDefaultDepth
|
* @method setDefaultDepth
|
||||||
* @param {float} arg0
|
* @param {float} arg0
|
||||||
|
|
|
@ -11963,6 +11963,16 @@ getBlendFunc : function (
|
||||||
return cc.BlendFunc;
|
return cc.BlendFunc;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method enableWrap
|
||||||
|
* @param {bool} arg0
|
||||||
|
*/
|
||||||
|
enableWrap : function (
|
||||||
|
bool
|
||||||
|
)
|
||||||
|
{
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method setWidth
|
* @method setWidth
|
||||||
* @param {float} arg0
|
* @param {float} arg0
|
||||||
|
@ -11973,6 +11983,16 @@ float
|
||||||
{
|
{
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method getBMFontSize
|
||||||
|
* @return {float}
|
||||||
|
*/
|
||||||
|
getBMFontSize : function (
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method getMaxLineWidth
|
* @method getMaxLineWidth
|
||||||
* @return {float}
|
* @return {float}
|
||||||
|
@ -12027,11 +12047,13 @@ str
|
||||||
* @method setBMFontFilePath
|
* @method setBMFontFilePath
|
||||||
* @param {String} arg0
|
* @param {String} arg0
|
||||||
* @param {vec2_object} arg1
|
* @param {vec2_object} arg1
|
||||||
|
* @param {float} arg2
|
||||||
* @return {bool}
|
* @return {bool}
|
||||||
*/
|
*/
|
||||||
setBMFontFilePath : function (
|
setBMFontFilePath : function (
|
||||||
str,
|
str,
|
||||||
vec2
|
vec2,
|
||||||
|
float
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -12057,6 +12079,16 @@ float
|
||||||
{
|
{
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method setOverflow
|
||||||
|
* @param {cc.Label::Overflow} arg0
|
||||||
|
*/
|
||||||
|
setOverflow : function (
|
||||||
|
overflow
|
||||||
|
)
|
||||||
|
{
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method getLineSpacing
|
* @method getLineSpacing
|
||||||
* @return {float}
|
* @return {float}
|
||||||
|
@ -12245,6 +12277,18 @@ color4b
|
||||||
{
|
{
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method getLetter
|
||||||
|
* @param {int} arg0
|
||||||
|
* @return {cc.Sprite}
|
||||||
|
*/
|
||||||
|
getLetter : function (
|
||||||
|
int
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return cc.Sprite;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method setHeight
|
* @method setHeight
|
||||||
* @param {float} arg0
|
* @param {float} arg0
|
||||||
|
@ -12276,15 +12320,13 @@ color4b
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method getLetter
|
* @method getOverflow
|
||||||
* @param {int} arg0
|
* @return {cc.Label::Overflow}
|
||||||
* @return {cc.Sprite}
|
|
||||||
*/
|
*/
|
||||||
getLetter : function (
|
getOverflow : function (
|
||||||
int
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return cc.Sprite;
|
return 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12347,6 +12389,16 @@ texthalignment
|
||||||
{
|
{
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method isWrapEnabled
|
||||||
|
* @return {bool}
|
||||||
|
*/
|
||||||
|
isWrapEnabled : function (
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method setAlignment
|
* @method setAlignment
|
||||||
* @param {cc.TextHAlignment|cc.TextHAlignment} texthalignment
|
* @param {cc.TextHAlignment|cc.TextHAlignment} texthalignment
|
||||||
|
@ -12367,6 +12419,16 @@ requestSystemFontRefresh : function (
|
||||||
{
|
{
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method setBMFontSize
|
||||||
|
* @param {float} arg0
|
||||||
|
*/
|
||||||
|
setBMFontSize : function (
|
||||||
|
float
|
||||||
|
)
|
||||||
|
{
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method createWithBMFont
|
* @method createWithBMFont
|
||||||
* @param {String} arg0
|
* @param {String} arg0
|
||||||
|
@ -13451,6 +13513,16 @@ isSelected : function (
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method setCallback
|
||||||
|
* @param {function} arg0
|
||||||
|
*/
|
||||||
|
setCallback : function (
|
||||||
|
func
|
||||||
|
)
|
||||||
|
{
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method unselected
|
* @method unselected
|
||||||
*/
|
*/
|
||||||
|
@ -20948,18 +21020,6 @@ char
|
||||||
*/
|
*/
|
||||||
cc.Application = {
|
cc.Application = {
|
||||||
|
|
||||||
/**
|
|
||||||
* @method openURL
|
|
||||||
* @param {String} arg0
|
|
||||||
* @return {bool}
|
|
||||||
*/
|
|
||||||
openURL : function (
|
|
||||||
str
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method getTargetPlatform
|
* @method getTargetPlatform
|
||||||
* @return {cc.ApplicationProtocol::Platform}
|
* @return {cc.ApplicationProtocol::Platform}
|
||||||
|
@ -20980,6 +21040,28 @@ getCurrentLanguage : function (
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method openURL
|
||||||
|
* @param {String} arg0
|
||||||
|
* @return {bool}
|
||||||
|
*/
|
||||||
|
openURL : function (
|
||||||
|
str
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method getVersion
|
||||||
|
* @return {String}
|
||||||
|
*/
|
||||||
|
getVersion : function (
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method getInstance
|
* @method getInstance
|
||||||
* @return {cc.Application}
|
* @return {cc.Application}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue