Merge pull request #3 from cocos2d/master

merge from cocos2d-x
This commit is contained in:
Bite 2013-03-08 23:59:56 -08:00
commit ef809da4a5
199 changed files with 6502 additions and 2312 deletions

17
.gitignore vendored
View File

@ -1,6 +1,7 @@
#ignore thumbnails created by windows
# Ignore thumbnails created by windows
Thumbs.db
#Ignore files build by Visual Studio
# Ignore files build by Visual Studio
*.obj
*.exe
*.pdb
@ -36,13 +37,15 @@ bin/
obj/
gen/
assets/
#.classpath
#.project
#.cproject
local.properties
# Ignore files build by linux
*.o
# Ignore files built by NaCl
samples/Cpp/HelloCpp/proj.nacl/Resources/
samples/Cpp/TestCpp/proj.nacl/Resources/
samples/Cpp/TestCpp/proj.nacl/out/
samples/Cpp/SimpleGame/proj.nacl/Resources/
samples/Lua/HelloLua/proj.nacl/Resources/
samples/Lua/TestLua/proj.nacl/Resources/
# Ignore python compiled files
*.pyc

50
AUTHORS
View File

@ -12,6 +12,15 @@ Developers:
Rolando Abarca
Javascript Binding and testjs
Jimmy Sambuo
fix the bug that SimpleAudioEngine::playEffect() and playBackgroundMusic() play twice on linux
DarraghCoy
fix for loading custom fonts on iOS when referenced from a CCB file
Waiter
fix an error that OpenSLEngine can't load resources from SD card
billy1380
make CCLens3d support concave effect
@ -61,7 +70,7 @@ Developers:
Weeds (Andre Rudlaff)
Used fontconfig to enhance font rendering on linux.
Fixed a bug about missing horizontal alignment for Custom TTF fonts on linux.
Fixed a bug that the truetype fonts from resource directory can't be found on linux.
Fixed a bug that the truetype fonts from resource directory can't be found on linux.
Nat Weiss (iphonegamekit.com)
author of Mac port
@ -70,7 +79,7 @@ Developers:
XiaoLong Zhang (Chukong Inc)
Mike McGary (Zynga)
Di Wu (Zynga China)
CCBReader and cpp reflection mechanic
CCBReader and cpp reflection mechanic
Angus Comrie
contributes cocos2d-x port of CCControlExtension.
@ -86,13 +95,13 @@ Developers:
fixed CCDirector to use CCLabelBMFont instead of CCLabelTTF
added CCBReader (CCBI format)
Added cleanup and reset methods to ScriptingCore.
Rohan Kuruvilla (rohankuruvilla, Zynga)
Improvements to JS Bindings.
Jianfeng Zhou (NetGragon Inc)
Jianfeng Zou (NetDragon Inc)
contributes CCListView and CCTextureWatcher.
dducharme
author of blackberry port
@ -101,8 +110,8 @@ Developers:
HuaXu Cai (Kongzhong Corporation)
author of linux port
ciaranj
ciaranj
add a build file that correctly generates LuaCocos2d.cpp
add a lua template
add particle systems to lua bindings
@ -118,7 +127,7 @@ Developers:
improvements to CCUserDefaults
ZhuoShi Shun
contribute the lua binding of CocosDenshion
contribute the lua binding of CocosDenshion
Jirka Fajfr
Chris Calm
@ -138,16 +147,16 @@ Developers:
Mat Hopwood( Marmalade official engineer )
Marmalade support for gles20 branch
Carlos Sessa
implement the accelerometer module for Android port
implement the accelerometer module for Android port
James Chen(dumganhar)
author of Bada port
Erawppa
implement CCNotificationCenter
YuLei Liao(dualface)
contribute the factor of lua binding
@ -183,11 +192,11 @@ Developers:
fixed compilation errors after adding support of webp image format.
Tomoaki Shimizu (tks2shimizu)
Adding randomObject to CCDictionary.
Adding randomObject to CCDictionary.
Igor Zavorotkin (ivzave)
Adding lua support for linux platform.
Jozef Prídavok (jpridavok)
Adding CCEditBox implementation for Mac OSX.
@ -216,19 +225,26 @@ Developers:
neokim
Adds 'setFont' and 'setAnchorPoint' to CCEditBox.
Sam Clegg (sbc100)
Author of Native Client port.
Refactor linux build system and fix many warnings.
Peter Young (young40)
Implements setVisible() for CCEditBox
Retired Core Developers:
WenSheng Yang
Author of windows port, CCTextField,
Designer of CCApplication/CCEGLView/platform structure.
Author of windows port, CCTextField,
Designer of CCApplication/CCEGLView/platform structure.
He's working together with 2dx core team but leading FishingJoy game
Bin Zhang
core-team member but put himself in FishingJoy game since 2012.
core-team member but put himself in FishingJoy game since 2012.
RongHong Huang (flyingpaper)
Author of cocos2d-xna and spent all his time on wp7.
Cocos2d-x can not grow so fast without the active community.
Thanks to all developers who report & trace bugs, discuss the engine usage in forum & QQ groups!
Special thanks to Ricardo Quesada for giving us lots of guidances & suggestions.

View File

@ -216,7 +216,7 @@ int getFileDescriptor(const char * filename, off_t & start, off_t & length)
AAsset* Asset = AAssetManager_open(mgr, filename, AASSET_MODE_UNKNOWN);
if (NULL == Asset)
{
LOGD("file not found! Stop preload file: %s", filename);
//LOGD("file not found! Stop preload file: %s", filename);
return FILE_NOT_FOUND;
}
@ -285,6 +285,14 @@ bool initAudioPlayer(AudioPlayer* player, const char* filename)
int fd = getFileDescriptor(filename, start, length);
if (FILE_NOT_FOUND == fd)
{
FILE* fp = fopen(filename , "rb");
if(fp){
SLDataLocator_URI loc_fd = {SL_DATALOCATOR_URI , (SLchar*)filename};
SLDataFormat_MIME format_mime = {SL_DATAFORMAT_MIME, NULL, SL_CONTAINERTYPE_UNSPECIFIED};
(player->audioSrc) = {&loc_fd, &format_mime};
return createAudioPlayerBySource(player);
}
LOGD("file not found! Stop preload file: %s", filename);
return false;
}
SLDataLocator_AndroidFD loc_fd = {SL_DATALOCATOR_ANDROIDFD, fd, start, length};

View File

@ -208,7 +208,6 @@ namespace CocosDenshion
ALenum format;
int result;
int section;
int err;
unsigned int size = 0;
if (ov_fopen(pszFilePath, &ogg_file) < 0)

View File

@ -45,7 +45,6 @@ void FmodAudioPlayer::init() {
FMOD_RESULT result;
FMOD::ChannelGroup *masterChannelGroup;
unsigned int version;
/*
Create a System object and initialize.
*/
@ -173,7 +172,7 @@ void FmodAudioPlayer::playBackgroundMusic(const char* pszFilePath, bool bLoop) {
FMOD_RESULT result = pSystem->playSound(FMOD_CHANNEL_FREE, pMusic, true,
&pBGMChannel);
if (!ERRCHECK(result)) {
pBGMChannel->setLoopCount((bLoop) ? -1 : 1);
pBGMChannel->setLoopCount((bLoop) ? -1 : 0);
result = pBGMChannel->setPaused(false);
}
}
@ -274,6 +273,7 @@ float FmodAudioPlayer::getEffectsVolume() {
pSystem->update();
FMOD_RESULT result = pChannelGroup->getVolume(&fVolumn);
ERRCHECKWITHEXIT(result);
return fVolumn;
}
void FmodAudioPlayer::setEffectsVolume(float volume) {
@ -313,7 +313,7 @@ unsigned int FmodAudioPlayer::playEffect(const char* pszFilePath, bool bLoop) {
pChannel->setChannelGroup(pChannelGroup);
//set its loop
pChannel->setLoopCount((bLoop) ? -1 : 1);
pChannel->setLoopCount((bLoop) ? -1 : 0);
result = pChannel->setPaused(false);
mapEffectSoundChannel[iSoundChannelCount] = pChannel;

View File

@ -126,7 +126,7 @@ void SimpleAudioEngine::setBackgroundMusicVolume(float volume) {
}
float SimpleAudioEngine::getEffectsVolume() {
return oAudioPlayer->getBackgroundMusicVolume();
return oAudioPlayer->getEffectsVolume();
}
void SimpleAudioEngine::setEffectsVolume(float volume) {

View File

@ -1,69 +1,27 @@
CC = gcc
CXX = g++
TARGET = libcocosdenshion.so
CCFLAGS = -Wall -fPIC
CXXFLAGS = -Wall -fPIC
VISIBILITY =
TARGET = libcocosdenshion.so
COCOS2DX_PATH = ../../cocos2dx
LBITS := $(shell getconf LONG_BIT)
ifeq ($(LBITS),64)
INCLUDES = -I.. \
-I../include \
-I../third_party/fmod/lib64/api/inc
else
INCLUDES = -I.. \
-I../include \
-I../third_party/fmod/api/inc
endif
INCLUDES += -I$(COCOS2DX_PATH) \
-I$(COCOS2DX_PATH)/platform/third_party/linux \
-I$(COCOS2DX_PATH)/platform/third_party/linux/libfreetype2 \
-I$(COCOS2DX_PATH)/cocoa \
-I$(COCOS2DX_PATH)/include \
-I$(COCOS2DX_PATH)/platform \
-I$(COCOS2DX_PATH)/platform/linux \
-I$(COCOS2DX_PATH)/kazmath/include \
-I$(COCOS2DX_PATH)/platform/third_party/linux/libxml2 \
-I$(COCOS2DX_PATH)/platform/third_party/linux/libjpeg
DEFINES = -DLINUX
OBJECTS = ../linux/FmodAudioPlayer.o \
../linux/SimpleAudioEngine.o \
STATICLIBS =
INCLUDES += -I.. -I../include
ifeq ($(LBITS),64)
SHAREDLIBS_DIR = ../third_party/fmod/lib64/api/lib
SHAREDLIBS = -L$(SHAREDLIBS_DIR) -lfmodex64
INCLUDES += -I../third_party/fmod/lib64/api/inc
else
SHAREDLIBS_DIR = ../third_party/fmod/api/lib
SHAREDLIBS = -L$(SHAREDLIBS_DIR) -lfmodex
INCLUDES += -I../third_party/fmod/api/inc
endif
debug: CCFLAGS += -g3 -O0
debug: CXXFLAGS += -g3 -O0
debug: DEFINES += -DDEBUG
debug: $(TARGET)
SOURCES = ../linux/FmodAudioPlayer.cpp \
../linux/SimpleAudioEngine.cpp \
release: CCFLAGS += -O3
release: CXXFLAGS += -O3
release: DEFINES += -DNDEBUG
release: $(TARGET)
COCOS_ROOT = ../..
include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk
####### Build rules
$(TARGET): $(OBJECTS)
$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(OBJECTS) -shared -o $(TARGET) $(SHAREDLIBS) $(STATICLIBS)
TARGET := $(LIB_DIR)/$(TARGET)
####### Compile
%.o: %.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@
all: $(TARGET)
%.o: %.c
$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@
$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -shared -o $(TARGET) $(SHAREDLIBS) $(STATICLIBS)
clean:
rm -f $(OBJECTS) $(TARGET) core
$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@

View File

@ -0,0 +1,19 @@
COCOS_ROOT = ../..
INCLUDES = -I../include
SOURCES = ../blackberry/SimpleAudioEngine.cpp
include $(COCOS_ROOT)/cocos2dx/proj.nacl/cocos2dx.mk
TARGET = $(LIB_DIR)/libcocosdenshion.a
all: $(TARGET)
$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_AR)$(NACL_AR) $(ARFLAGS) $(TARGET) $(OBJECTS)
$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_CXX)$(NACL_CXX) -MMD $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@

22
Makefile Normal file
View File

@ -0,0 +1,22 @@
PLATFORM = linux
define MAKE_TARGET
+$(MAKE) -C external/chipmunk/proj.$(PLATFORM) $@
+$(MAKE) -C external/Box2D/proj.$(PLATFORM) $@
+$(MAKE) -C CocosDenshion/proj.$(PLATFORM) $@
+$(MAKE) -C extensions/proj.$(PLATFORM) $@
+$(MAKE) -C cocos2dx/proj.$(PLATFORM) $@
+$(MAKE) -C scripting/lua/proj.$(PLATFORM) $@
+$(MAKE) -C samples/Cpp/HelloCpp/proj.$(PLATFORM) $@
+$(MAKE) -C samples/Cpp/TestCpp/proj.$(PLATFORM) $@
+$(MAKE) -C samples/Lua/HelloLua/proj.$(PLATFORM) $@
+$(MAKE) -C samples/Lua/TestLua/proj.$(PLATFORM) $@
endef
all:
$(call MAKE_TARGET,all)
clean:
$(call MAKE_TARGET,clean)
.PHONY: all clean

View File

@ -12,6 +12,7 @@ Supported Platforms
* Bada: cocos2d-x v1.x supports Bada SDK 1.0 & 2.0. Bada support was deprecated since cocos2d-x v2.0.
* BlackBerry: stable, contribued by staffs in RIM, supports Playbook & BB10.
* Marmalade: stable since cocos2d-x v0.11.0, contributed by Marmalade's staff.
* Native Client (NaCl): contributed by the Native Client authors.
* Windows: stable, well tested on WinXP/Vista/Win7. Please upgrde the drive of your video card if you meet problems on OpenGL functions
* Linux: support but not very stable.

42
build-nacl.sh Executable file
View File

@ -0,0 +1,42 @@
#!/bin/bash
# Build script to build all components for Native Client.
#
# By default this script will only build debug versions.
# Pass "all" as an argument to build clean and also build
# release config.
#
# Before running this script you need to set NACL_SDK_ROOT
# and add the NaCl compiler bin folder to your path.
#
# There are several libraries from naclports that are
# prerequisite for building cocos2dx on NaCl. The simplest
# way to build them is to checkout naclports and run:
# $ make png tiff freetype xml2 freealut jpeg vorbis ogg
if [ -z "$NACL_SDK_ROOT" ]; then
echo "Please set \$NACL_SDK_ROOT"
exit 1
fi
SCRIPT_DIR=$(dirname ${BASH_SOURCE})
OUTPUT_DEBUG=lib/nacl/Debug/
OUTPUT_RELEASE=lib/nacl/Release/
set -e
set -x
cd $SCRIPT_DIR
mkdir -p $OUTPUT_DEBUG
mkdir -p $OUTPUT_RELEASE
export MAKEFLAGS="-j10 PLATFORM=nacl"
if [ "$1" = "clean" ]; then
make DEBUG=1 clean
make DEBUG=0 clean
exit 0
fi
make DEBUG=1 all
make DEBUG=0 all

View File

@ -1,8 +1,8 @@
@echo off
echo./*
echo.* Check VC++ environment...
echo.*/
echo. * Check VC++ environment...
echo. */
echo.
if defined VS110COMNTOOLS (
@ -26,13 +26,13 @@ if not defined VSVARS (
)
echo./*
echo.* Building cocos2d-x library binary, please wait a while...
echo.*/
echo. * Building cocos2d-x library binary, please wait a while...
echo. */
echo.
call %VSVARS%
if %VC_VER%==100 (
msbuild cocos2d-win32.vc2010.sln /p:Configuration="Debug"
msbuild cocos2d-win32.vc2010.sln /p:Configuration="Debug"
msbuild cocos2d-win32.vc2010.sln /p:Configuration="Release"
) else if %VC_VER%==110 (
msbuild cocos2d-win32.vc2012.sln /t:Clean
@ -44,11 +44,11 @@ if %VC_VER%==100 (
)
echo./*
echo.* Check the cocos2d-win32 application "TestCpp.exe" ...
echo.*/
echo. * Check the cocos2d-win32 application "TestCpp.exe" ...
echo. */
echo.
cd ".\Release.win32\"
pushd ".\Release.win32\"
set CC_TEST_BIN=TestCpp.exe
@ -65,8 +65,8 @@ set CC_WATERMELONWITHME_RES=..\samples\Javascript\Shared\games\WatermelonWithMe
echo./*
echo.* Run cocos2d-win32 tests.exe and view Cocos2d-x Application Wizard for Visual Studio User Guide.
echo.*/
echo. * Run cocos2d-win32 tests.exe and view Cocos2d-x Application Wizard for Visual Studio User Guide.
echo. */
echo.
xcopy /E /Y /Q "%CC_TEST_RES%" .
xcopy /E /Y /Q "%CC_HELLOWORLD_RES%" .
@ -85,6 +85,7 @@ if not exist "%CC_TEST_BIN%" (
)
call "%CC_TEST_BIN%"
popd
start http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Cocos2d-x_Application_Wizard_for_Visual_Studio_User_Guide
goto EOF

View File

@ -111,7 +111,7 @@ support/CCNotificationCenter.cpp \
support/CCProfiling.cpp \
support/CCPointExtension.cpp \
support/TransformUtils.cpp \
support/CCUserDefault.cpp \
support/user_default/CCUserDefault.cpp \
support/base64.cpp \
support/ccUtils.cpp \
support/CCVertex.cpp \

View File

@ -37,13 +37,13 @@ CCConfiguration* CCConfiguration::s_gSharedConfiguration = NULL;
CCConfiguration::CCConfiguration(void)
: m_nMaxTextureSize(0)
, m_nMaxModelviewStackDepth(0)
, m_nMaxTextureUnits(0)
, m_bSupportsPVRTC(false)
, m_bSupportsNPOT(false)
, m_bSupportsBGRA8888(false)
, m_bSupportsShareableVAO(false)
, m_bSupportsDiscardFramebuffer(false)
, m_bSupportsShareableVAO(false)
, m_nMaxSamplesAllowed(0)
, m_nMaxTextureUnits(0)
, m_pGlExtensions(NULL)
{
}
@ -77,14 +77,13 @@ bool CCConfiguration::init(void)
CCLOG("cocos2d: GL supports discard_framebuffer: %s", (m_bSupportsDiscardFramebuffer ? "YES" : "NO"));
CCLOG("cocos2d: GL supports shareable VAO: %s", (m_bSupportsShareableVAO ? "YES" : "NO") );
bool bEnableProfilers = false;
bool CC_UNUSED bEnableProfilers = false;
#if CC_ENABLE_PROFILERS
bEnableProfilers = true;
#else
bEnableProfilers = false;
bEnableProfilers = false;
#endif
CCLOG("cocos2d: compiled with Profiling Support: %s",
bEnableProfilers ? "YES - *** Disable it when you finish profiling ***" : "NO");

View File

@ -50,7 +50,7 @@ THE SOFTWARE.
#include "CCAccelerometer.h"
#include "sprite_nodes/CCAnimationCache.h"
#include "touch_dispatcher/CCTouch.h"
#include "support/CCUserDefault.h"
#include "support/user_default/CCUserDefault.h"
#include "shaders/ccGLStateCache.h"
#include "shaders/CCShaderCache.h"
#include "kazmath/kazmath.h"
@ -198,7 +198,7 @@ void CCDirector::setGLDefaultValues(void)
setAlphaBlending(true);
// XXX: Fix me, should enable/disable depth test according the depth format as cocos2d-iphone did
// [self setDepthTest: view_.depthFormat];
setDepthTest(true);
setDepthTest(false);
setProjection(m_eProjection);
// set other opengl default values

View File

@ -71,15 +71,15 @@ typedef struct _hashSelectorEntry
// implementation CCTimer
CCTimer::CCTimer()
: m_pfnSelector(NULL)
, m_fInterval(0.0f)
, m_pTarget(NULL)
: m_pTarget(NULL)
, m_fElapsed(-1)
, m_bRunForever(false)
, m_bUseDelay(false)
, m_uTimesExecuted(0)
, m_uRepeat(0)
, m_fDelay(0.0f)
, m_fInterval(0.0f)
, m_pfnSelector(NULL)
, m_nScriptHandler(0)
{
}
@ -243,8 +243,8 @@ CCScheduler::CCScheduler(void)
, m_pHashForTimers(NULL)
, m_pCurrentTarget(NULL)
, m_bCurrentTargetSalvaged(false)
, m_pScriptHandlerEntries(NULL)
, m_bUpdateHashLocked(false)
, m_pScriptHandlerEntries(NULL)
{
}
@ -635,7 +635,7 @@ void CCScheduler::unscheduleScriptEntry(unsigned int uScheduleScriptEntryID)
for (int i = m_pScriptHandlerEntries->count() - 1; i >= 0; i--)
{
CCSchedulerScriptHandlerEntry* pEntry = static_cast<CCSchedulerScriptHandlerEntry*>(m_pScriptHandlerEntries->objectAtIndex(i));
if (pEntry->getEntryId() == uScheduleScriptEntryID)
if (pEntry->getEntryId() == (int)uScheduleScriptEntryID)
{
pEntry->markedForDeletion();
break;

View File

@ -261,8 +261,8 @@ CCCardinalSplineTo::~CCCardinalSplineTo()
CCCardinalSplineTo::CCCardinalSplineTo()
: m_pPoints(NULL)
, m_fTension(0.f)
, m_fDeltaT(0.f)
, m_fTension(0.f)
{
}

View File

@ -342,7 +342,7 @@ void CCShuffleTiles::startWithTarget(CCNode *pTarget)
{
CCTiledGrid3DAction::startWithTarget(pTarget);
if (m_nSeed != -1)
if (m_nSeed != (unsigned int)-1)
{
srand(m_nSeed);
}
@ -699,7 +699,7 @@ void CCTurnOffTiles::startWithTarget(CCNode *pTarget)
CCTiledGrid3DAction::startWithTarget(pTarget);
if (m_nSeed != -1)
if (m_nSeed != (unsigned int)-1)
{
srand(m_nSeed);
}
@ -1060,4 +1060,4 @@ void CCSplitCols::update(float time)
}
}
NS_CC_END
NS_CC_END

View File

@ -52,42 +52,42 @@ NS_CC_BEGIN
static int s_globalOrderOfArrival = 1;
CCNode::CCNode(void)
: m_nZOrder(0)
, m_fVertexZ(0.0f)
, m_fRotationX(0.0f)
: m_fRotationX(0.0f)
, m_fRotationY(0.0f)
, m_fScaleX(1.0f)
, m_fScaleY(1.0f)
, m_fVertexZ(0.0f)
, m_obPosition(CCPointZero)
, m_fSkewX(0.0f)
, m_fSkewY(0.0f)
// children (lazy allocs)
, m_pChildren(NULL)
// lazy alloc
, m_pCamera(NULL)
, m_pGrid(NULL)
, m_bVisible(true)
, m_obAnchorPoint(CCPointZero)
, m_obAnchorPointInPoints(CCPointZero)
, m_obAnchorPoint(CCPointZero)
, m_obContentSize(CCSizeZero)
, m_bRunning(false)
, m_sAdditionalTransform(CCAffineTransformMakeIdentity())
, m_pCamera(NULL)
// children (lazy allocs)
// lazy alloc
, m_pGrid(NULL)
, m_nZOrder(0)
, m_pChildren(NULL)
, m_pParent(NULL)
// "whole screen" objects. like Scenes and Layers, should set m_bIgnoreAnchorPointForPosition to false
, m_bIgnoreAnchorPointForPosition(false)
, m_nTag(kCCNodeTagInvalid)
// userData is always inited as nil
, m_pUserData(NULL)
, m_pUserObject(NULL)
, m_pShaderProgram(NULL)
, m_eGLServerState(ccGLServerState(0))
, m_uOrderOfArrival(0)
, m_bRunning(false)
, m_bTransformDirty(true)
, m_bInverseDirty(true)
, m_bAdditionalTransformDirty(false)
, m_bVisible(true)
, m_bIgnoreAnchorPointForPosition(false)
, m_bReorderChildDirty(false)
, m_nScriptHandler(0)
, m_nUpdateScriptHandler(0)
, m_pShaderProgram(NULL)
, m_uOrderOfArrival(0)
, m_eGLServerState(ccGLServerState(0))
, m_bReorderChildDirty(false)
, m_sAdditionalTransform(CCAffineTransformMakeIdentity())
, m_bAdditionalTransformDirty(false)
{
// set default scheduler and actionManager
CCDirector *director = CCDirector::sharedDirector();

View File

@ -38,9 +38,9 @@ CCObject* CCCopying::copyWithZone(CCZone *pZone)
}
CCObject::CCObject(void)
:m_uAutoReleaseCount(0)
,m_uReference(1) // when the object is created, the reference count of it is 1
,m_nLuaID(0)
: m_nLuaID(0)
, m_uReference(1) // when the object is created, the reference count of it is 1
, m_uAutoReleaseCount(0)
{
static unsigned int uObjectCount = 0;

View File

@ -191,6 +191,13 @@ THE SOFTWARE.
#include "platform/Marmalade/CCStdC.h"
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
#if (CC_TARGET_PLATFORM == CC_PLATFORM_NACL)
#include "platform/nacl/CCAccelerometer.h"
#include "platform/nacl/CCApplication.h"
#include "platform/nacl/CCEGLView.h"
#include "platform/nacl/CCGL.h"
#include "platform/nacl/CCStdC.h"
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
// script_support
#include "script_support/CCScriptSupport.h"
@ -214,7 +221,7 @@ THE SOFTWARE.
#include "support/CCNotificationCenter.h"
#include "support/CCPointExtension.h"
#include "support/CCProfiling.h"
#include "support/CCUserDefault.h"
#include "support/user_default/CCUserDefault.h"
#include "support/CCVertex.h"
#include "support/tinyxml2/tinyxml2.h"

View File

@ -25,7 +25,7 @@
#define __NEON_MATRIX_IMPL_H__
#ifdef __arm__
#if defined(__QNX__) || defined(ANDROID) || defined(I3D_ARCH_ARM) // MARMALADE CHANGE: Added for Marmalade support
#if defined(__QNX__) || defined(ANDROID) || defined(I3D_ARCH_ARM) || defined(__native_client__) // MARMALADE CHANGE: Added for Marmalade support
// blackberry and android don't have arm/arch.h but it defines __arm__
#else
#include "arm/arch.h"

View File

@ -518,17 +518,17 @@ bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile, f
}
CCLabelBMFont::CCLabelBMFont()
: m_cDisplayedOpacity(255)
: m_sString(NULL)
, m_pConfiguration(NULL)
, m_bLineBreakWithoutSpaces(false)
, m_tImageOffset(CCPointZero)
, m_cDisplayedOpacity(255)
, m_cRealOpacity(255)
, m_tDisplayedColor(ccWHITE)
, m_tRealColor(ccWHITE)
, m_bCascadeOpacityEnabled(true)
, m_bCascadeColorEnabled(true)
, m_bCascadeOpacityEnabled(true)
, m_bIsOpacityModifyRGB(false)
, m_pConfiguration(NULL)
, m_sString(NULL)
, m_bLineBreakWithoutSpaces(false)
, m_tImageOffset(CCPointZero)
{
}

View File

@ -275,9 +275,12 @@ protected:
CCSprite *m_pReusedChar;
// texture RGBA
GLubyte m_cDisplayedOpacity, m_cRealOpacity;
ccColor3B m_tDisplayedColor, m_tRealColor;
bool m_bCascadeColorEnabled, m_bCascadeOpacityEnabled;
GLubyte m_cDisplayedOpacity;
GLubyte m_cRealOpacity;
ccColor3B m_tDisplayedColor;
ccColor3B m_tRealColor;
bool m_bCascadeColorEnabled;
bool m_bCascadeOpacityEnabled;
/** conforms to CCRGBAProtocol protocol */
bool m_bIsOpacityModifyRGB;

View File

@ -46,11 +46,11 @@ CCLayer::CCLayer()
: m_bTouchEnabled(false)
, m_bAccelerometerEnabled(false)
, m_bKeypadEnabled(false)
,m_pScriptTouchHandlerEntry(NULL)
,m_pScriptKeypadHandlerEntry(NULL)
,m_pScriptAccelerateHandlerEntry(NULL)
, m_eTouchMode(kCCTouchesAllAtOnce)
, m_pScriptTouchHandlerEntry(NULL)
, m_pScriptKeypadHandlerEntry(NULL)
, m_pScriptAccelerateHandlerEntry(NULL)
, m_nTouchPriority(0)
, m_eTouchMode(kCCTouchesAllAtOnce)
{
m_bIgnoreAnchorPointForPosition = true;
setAnchorPoint(ccp(0.5f, 0.5f));
@ -494,8 +494,8 @@ CCLayerRGBA::CCLayerRGBA()
, _realOpacity (255)
, _displayedColor(ccWHITE)
, _realColor(ccWHITE)
, _cascadeColorEnabled(false)
, _cascadeOpacityEnabled(false)
, _cascadeColorEnabled(false)
{}
CCLayerRGBA::~CCLayerRGBA() {}
@ -711,7 +711,7 @@ bool CCLayerColor::initWithColor(const ccColor4B& color, GLfloat w, GLfloat h)
_displayedColor.b = _realColor.b = color.b;
_displayedOpacity = color.a;
for (int i = 0; i<sizeof(m_pSquareVertices) / sizeof( m_pSquareVertices[0]); i++ )
for (size_t i = 0; i<sizeof(m_pSquareVertices) / sizeof( m_pSquareVertices[0]); i++ )
{
m_pSquareVertices[i].x = 0.0f;
m_pSquareVertices[i].y = 0.0f;

View File

@ -163,8 +163,10 @@ private:
int excuteScriptTouchHandler(int nEventType, CCSet *pTouches);
};
#ifdef __apple__
#pragma mark -
#pragma mark CCLayerRGBA
#endif
/** CCLayerRGBA is a subclass of CCLayer that implements the CCRGBAProtocol protocol using a solid color as the background.

View File

@ -51,8 +51,8 @@ static void setProgram(CCNode *n, CCGLProgram *p)
CCClippingNode::CCClippingNode()
: m_pStencil(NULL)
, m_bInverted(false)
, m_fAlphaThreshold(0.0f)
, m_bInverted(false)
{}
CCClippingNode::~CCClippingNode()

View File

@ -36,6 +36,7 @@ NS_CC_BEGIN
CCMotionStreak::CCMotionStreak()
: m_bFastMode(false)
, m_bStartingPositionInitialized(false)
, m_pTexture(NULL)
, m_tPositionR(CCPointZero)
, m_fStroke(0.0f)
@ -49,7 +50,6 @@ CCMotionStreak::CCMotionStreak()
, m_pVertices(NULL)
, m_pColorPointer(NULL)
, m_pTexCoords(NULL)
, m_bStartingPositionInitialized(false)
{
m_tBlendFunc.src = GL_SRC_ALPHA;
m_tBlendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;

View File

@ -82,40 +82,40 @@ NS_CC_BEGIN
//
CCParticleSystem::CCParticleSystem()
:m_sPlistFile("")
,m_fElapsed(0)
,m_pParticles(NULL)
,m_fEmitCounter(0)
,m_uParticleIdx(0)
,m_bIsActive(true)
,m_uParticleCount(0)
,m_fDuration(0)
,m_tSourcePosition(CCPointZero)
,m_tPosVar(CCPointZero)
,m_fLife(0)
,m_fLifeVar(0)
,m_fAngle(0)
,m_fAngleVar(0)
,m_fStartSize(0)
,m_fStartSizeVar(0)
,m_fEndSize(0)
,m_fEndSizeVar(0)
,m_fStartSpin(0)
,m_fStartSpinVar(0)
,m_fEndSpin(0)
,m_fEndSpinVar(0)
,m_fEmissionRate(0)
,m_uTotalParticles(0)
,m_pTexture(NULL)
,m_bOpacityModifyRGB(false)
,m_bIsBlendAdditive(false)
,m_ePositionType(kCCPositionTypeFree)
,m_bIsAutoRemoveOnFinish(false)
,m_nEmitterMode(kCCParticleModeGravity)
,m_pBatchNode(NULL)
,m_uAtlasIndex(0)
,m_bTransformSystemDirty(false)
,m_uAllocatedParticles(0)
: m_sPlistFile("")
, m_fElapsed(0)
, m_pParticles(NULL)
, m_fEmitCounter(0)
, m_uParticleIdx(0)
, m_pBatchNode(NULL)
, m_uAtlasIndex(0)
, m_bTransformSystemDirty(false)
, m_uAllocatedParticles(0)
, m_bIsActive(true)
, m_uParticleCount(0)
, m_fDuration(0)
, m_tSourcePosition(CCPointZero)
, m_tPosVar(CCPointZero)
, m_fLife(0)
, m_fLifeVar(0)
, m_fAngle(0)
, m_fAngleVar(0)
, m_fStartSize(0)
, m_fStartSizeVar(0)
, m_fEndSize(0)
, m_fEndSizeVar(0)
, m_fStartSpin(0)
, m_fStartSpinVar(0)
, m_fEndSpin(0)
, m_fEndSpinVar(0)
, m_fEmissionRate(0)
, m_uTotalParticles(0)
, m_pTexture(NULL)
, m_bOpacityModifyRGB(false)
, m_bIsBlendAdditive(false)
, m_ePositionType(kCCPositionTypeFree)
, m_bIsAutoRemoveOnFinish(false)
, m_nEmitterMode(kCCParticleModeGravity)
{
modeA.gravity = CCPointZero;
modeA.speed = 0;

View File

@ -12,6 +12,7 @@ enum TargetPlatform
kTargetIphone,
kTargetIpad,
kTargetBlackBerry,
kTargetNaCl,
};
/**

View File

@ -44,8 +44,8 @@ static void removeUsedIndexBit(int index)
CCEGLViewProtocol::CCEGLViewProtocol()
: m_pDelegate(NULL)
, m_fScaleY(1.0f)
, m_fScaleX(1.0f)
, m_fScaleY(1.0f)
, m_eResolutionPolicy(kResolutionUnKnown)
{
}

View File

@ -419,8 +419,7 @@ unsigned char* CCFileUtils::getFileDataFromZip(const char* pszZipFilePath, const
CC_BREAK_IF(UNZ_OK != nRet);
pBuffer = new unsigned char[FileInfo.uncompressed_size];
int nSize = 0;
nSize = unzReadCurrentFile(pFile, pBuffer, FileInfo.uncompressed_size);
int CC_UNUSED nSize = unzReadCurrentFile(pFile, pBuffer, FileInfo.uncompressed_size);
CCAssert(nSize == 0 || nSize == (int)FileInfo.uncompressed_size, "the file size is wrong");
*pSize = FileInfo.uncompressed_size;

View File

@ -24,7 +24,13 @@
#include "platform/CCImage.h"
#include "textures/CCTexture2D.h"
#ifdef __native_client__
// TODO(sbc): I'm pretty sure all platforms should be including
// webph headers in this way.
#include "webp/decode.h"
#else
#include "decode.h"
#endif
#include "ccMacros.h"
#include <stdlib.h>
#include <stdio.h>

View File

@ -370,7 +370,7 @@ bool CCImage::_initWithPngData(void * pData, int nDatalen)
info_ptr = png_create_info_struct(png_ptr);
CC_BREAK_IF(!info_ptr);
#if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA)
#if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA && CC_TARGET_PLATFORM != CC_PLATFORM_NACL)
CC_BREAK_IF(setjmp(png_jmpbuf(png_ptr)));
#endif
@ -527,22 +527,22 @@ static uint64 _tiffSeekProc(thandle_t fd, uint64 off, int whence)
{
if (whence == SEEK_SET)
{
CC_BREAK_IF(off > isource->size-1);
CC_BREAK_IF(off >= (uint64)isource->size);
ret = isource->offset = (uint32)off;
}
else if (whence == SEEK_CUR)
{
CC_BREAK_IF(isource->offset + off > isource->size-1);
CC_BREAK_IF(isource->offset + off >= (uint64)isource->size);
ret = isource->offset += (uint32)off;
}
else if (whence == SEEK_END)
{
CC_BREAK_IF(off > isource->size-1);
CC_BREAK_IF(off >= (uint64)isource->size);
ret = isource->offset = (uint32)(isource->size-1 - off);
}
else
{
CC_BREAK_IF(off > isource->size-1);
CC_BREAK_IF(off >= (uint64)isource->size);
ret = isource->offset = (uint32)off;
}
} while (0);
@ -620,11 +620,11 @@ bool CCImage::_initWithTiffData(void* pData, int nDataLen)
{
if (TIFFReadRGBAImageOriented(tif, w, h, raster, ORIENTATION_TOPLEFT, 0))
{
/* the raster data is pre-multiplied by the alpha component
after invoking TIFFReadRGBAImageOriented
unsigned char* src = (unsigned char*)raster;
unsigned int* tmp = (unsigned int*)m_pData;
/* the raster data is pre-multiplied by the alpha component
after invoking TIFFReadRGBAImageOriented
for(int j = 0; j < m_nWidth * m_nHeight * 4; j += 4)
{
*tmp++ = CC_RGB_PREMULTIPLY_ALPHA( src[j], src[j + 1],
@ -738,7 +738,7 @@ bool CCImage::_saveImageToPNG(const char * pszFilePath, bool bIsToRGB)
png_destroy_write_struct(&png_ptr, NULL);
break;
}
#if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA)
#if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA && CC_TARGET_PLATFORM != CC_PLATFORM_NACL)
if (setjmp(png_jmpbuf(png_ptr)))
{
fclose(fp);

View File

@ -43,6 +43,7 @@ Config of cocos2d-x project, per target platform.
#define CC_PLATFORM_BADA 6
#define CC_PLATFORM_BLACKBERRY 7
#define CC_PLATFORM_MAC 8
#define CC_PLATFORM_NACL 9
// Determine target platform by compile environment macro.
#define CC_TARGET_PLATFORM CC_PLATFORM_UNKNOWN
@ -96,6 +97,12 @@ Config of cocos2d-x project, per target platform.
#define CC_TARGET_PLATFORM CC_PLATFORM_BLACKBERRY
#endif
// native client
#if defined(__native_client__)
#undef CC_TARGET_PLATFORM
#define CC_TARGET_PLATFORM CC_PLATFORM_NACL
#endif
//////////////////////////////////////////////////////////////////////////
// post configure

View File

@ -244,4 +244,10 @@ public: virtual void set##funName(varType var) \
#define CC_DEPRECATED_ATTRIBUTE
#endif
#ifdef __GNUC__
#define CC_UNUSED __attribute__ ((unused))
#else
#define CC_UNUSED
#endif
#endif // __CC_PLATFORM_MACROS_H__

View File

@ -63,7 +63,8 @@ CCApplication* CCApplication::sharedApplication()
ccLanguageType CCApplication::getCurrentLanguage()
{
const char *pLanguageName = getCurrentLanguageJNI();
std::string languageName = getCurrentLanguageJNI();
const char* pLanguageName = languageName.c_str();
ccLanguageType ret = kLanguageEnglish;
if (0 == strcmp("zh", pLanguageName))

View File

@ -158,9 +158,9 @@ string CCFileUtilsAndroid::getWritablePath()
// Fix for Nexus 10 (Android 4.2 multi-user environment)
// the path is retrieved through Java Context.getCacheDir() method
string dir("");
const char *tmp = getFileDirectoryJNI();
string tmp = getFileDirectoryJNI();
if (tmp)
if (tmp.length() > 0)
{
dir.append(tmp).append("/");

View File

@ -1,5 +1,5 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2010-2013 cocos2d-x.org
http://www.cocos2d-x.org
@ -23,16 +23,15 @@ THE SOFTWARE.
****************************************************************************/
package org.cocos2dx.lib;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.Locale;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.res.AssetManager;
import android.os.Build;
import android.os.Environment;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;
@ -41,6 +40,7 @@ public class Cocos2dxHelper {
// ===========================================================
// Constants
// ===========================================================
private static final String PREFS_NAME = "Cocos2dxPrefsFile";
// ===========================================================
// Fields
@ -270,6 +270,67 @@ public class Cocos2dxHelper {
}
return -1;
}
// ===========================================================
// Functions for CCUserDefault
// ===========================================================
public static boolean getBoolForKey(String key) {
SharedPreferences settings = ((Activity)sContext).getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0);
return settings.getBoolean(key, false);
}
public static int getIntegerForKey(String key) {
SharedPreferences settings = ((Activity)sContext).getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0);
return settings.getInt(key, 0);
}
public static float getFloatForKey(String key) {
SharedPreferences settings = ((Activity)sContext).getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0);
return settings.getFloat(key, 0);
}
public static double getDoubleForKey(String key) {
// SharedPreferences doesn't support saving float value
SharedPreferences settings = ((Activity)sContext).getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0);
return settings.getFloat(key, 0);
}
public static String getStringForKey(String key) {
SharedPreferences settings = ((Activity)sContext).getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0);
return settings.getString(key, "");
}
public static void setBoolForKey(String key, boolean value) {
SharedPreferences settings = ((Activity)sContext).getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean(key, value);
}
public static void setIntegerForKey(String key, int value) {
SharedPreferences settings = ((Activity)sContext).getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putInt(key, value);
}
public static void setFloatForKey(String key, float value) {
SharedPreferences settings = ((Activity)sContext).getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putFloat(key, value);
}
public static void setDoubleForKey(String key, double value) {
// SharedPreferences doesn't support recording double value
SharedPreferences settings = ((Activity)sContext).getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putFloat(key, (float)value);
}
public static void setStringForKey(String key, String value) {
SharedPreferences settings = ((Activity)sContext).getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString(key, value);
}
// ===========================================================
// Inner and Anonymous Classes

View File

@ -129,8 +129,10 @@ public class Cocos2dxSound {
// unload effect
final Integer soundID = this.mPathSoundIDMap.get(pPath);
this.mSoundPool.unload(soundID);
this.mPathSoundIDMap.remove(pPath);
if(soundID != null){
this.mSoundPool.unload(soundID);
this.mPathSoundIDMap.remove(pPath);
}
}
public int playEffect(final String pPath, final boolean pLoop) {

View File

@ -9,40 +9,40 @@
using namespace cocos2d;
extern "C" {
int getFontSizeAccordingHeightJni(int height) {
int ret = 0;
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxBitmap", "getFontSizeAccordingHeight", "(I)I")) {
ret = t.env->CallStaticIntMethod(t.classID, t.methodID, height);
t.env->DeleteLocalRef(t.classID);
}
int getFontSizeAccordingHeightJni(int height) {
int ret = 0;
return ret;
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxBitmap", "getFontSizeAccordingHeight", "(I)I")) {
ret = t.env->CallStaticIntMethod(t.classID, t.methodID, height);
t.env->DeleteLocalRef(t.classID);
}
std::string getStringWithEllipsisJni(const char* pszText, float width, float fontSize) {
std::string ret;
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxBitmap", "getStringWithEllipsis", "(Ljava/lang/String;FF)Ljava/lang/String;")) {
jstring stringArg1;
if (!pszText) {
stringArg1 = t.env->NewStringUTF("");
} else {
stringArg1 = t.env->NewStringUTF(pszText);
}
jstring retFromJava = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID, stringArg1, width, fontSize);
const char* str = t.env->GetStringUTFChars(retFromJava, 0);
ret = str;
t.env->ReleaseStringUTFChars(retFromJava, str);
t.env->DeleteLocalRef(stringArg1);
t.env->DeleteLocalRef(t.classID);
}
return ret;
}
return ret;
}
std::string getStringWithEllipsisJni(const char* pszText, float width, float fontSize) {
std::string ret;
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxBitmap", "getStringWithEllipsis", "(Ljava/lang/String;FF)Ljava/lang/String;")) {
jstring stringArg1;
if (!pszText) {
stringArg1 = t.env->NewStringUTF("");
} else {
stringArg1 = t.env->NewStringUTF(pszText);
}
jstring retFromJava = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID, stringArg1, width, fontSize);
const char* str = t.env->GetStringUTFChars(retFromJava, 0);
ret = str;
t.env->ReleaseStringUTFChars(retFromJava, str);
t.env->DeleteLocalRef(stringArg1);
t.env->DeleteLocalRef(t.classID);
}
return ret;
}

View File

@ -26,22 +26,7 @@ THE SOFTWARE.
#include <string>
typedef void (*EditBoxCallback)(const char* pText, void* ctx);
extern "C"
{
void showEditBoxDialogJni(const char* pszTitle,
const char* pszContent,
int nInputMode,
int nInputFlag,
int nReturnType,
int nMaxLength,
EditBoxCallback pfEditBoxCB,
void* ctx);
int getFontSizeAccordingHeightJni(int height);
std::string getStringWithEllipsisJni(const char* pszText, float width, float fontSize);
} // end of extern "C"
#endif // __EDITBOX_JNI_H__

View File

@ -18,69 +18,14 @@ static void* s_ctx = NULL;
using namespace cocos2d;
using namespace std;
string g_apkPath;
extern "C" {
string g_apkPath;
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetApkPath(JNIEnv* env, jobject thiz, jstring apkPath) {
g_apkPath = JniHelper::jstring2string(apkPath);
}
const char * getApkPath() {
return g_apkPath.c_str();
}
void showDialogJNI(const char * pszMsg, const char * pszTitle) {
if (!pszMsg) {
return;
}
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "showDialog", "(Ljava/lang/String;Ljava/lang/String;)V")) {
jstring stringArg1;
if (!pszTitle) {
stringArg1 = t.env->NewStringUTF("");
} else {
stringArg1 = t.env->NewStringUTF(pszTitle);
}
jstring stringArg2 = t.env->NewStringUTF(pszMsg);
t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg1, stringArg2);
t.env->DeleteLocalRef(stringArg1);
t.env->DeleteLocalRef(stringArg2);
t.env->DeleteLocalRef(t.classID);
}
}
void showEditTextDialogJNI(const char* pszTitle, const char* pszMessage, int nInputMode, int nInputFlag, int nReturnType, int nMaxLength, EditTextCallback pfEditTextCallback, void* ctx) {
if (pszMessage == NULL) {
return;
}
s_pfEditTextCallback = pfEditTextCallback;
s_ctx = ctx;
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "showEditTextDialog", "(Ljava/lang/String;Ljava/lang/String;IIII)V")) {
jstring stringArg1;
if (!pszTitle) {
stringArg1 = t.env->NewStringUTF("");
} else {
stringArg1 = t.env->NewStringUTF(pszTitle);
}
jstring stringArg2 = t.env->NewStringUTF(pszMessage);
t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg1, stringArg2, nInputMode, nInputFlag, nReturnType, nMaxLength);
t.env->DeleteLocalRef(stringArg1);
t.env->DeleteLocalRef(stringArg2);
t.env->DeleteLocalRef(t.classID);
}
}
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetEditTextDialogResult(JNIEnv * env, jobject obj, jbyteArray text) {
jsize size = env->GetArrayLength(text);
@ -100,87 +45,291 @@ extern "C" {
}
}
void terminateProcessJNI() {
JniMethodInfo t;
}
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "terminateProcess", "()V")) {
t.env->CallStaticVoidMethod(t.classID, t.methodID);
t.env->DeleteLocalRef(t.classID);
}
const char * getApkPath() {
return g_apkPath.c_str();
}
void showDialogJNI(const char * pszMsg, const char * pszTitle) {
if (!pszMsg) {
return;
}
const char* getPackageNameJNI() {
JniMethodInfo t;
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "showDialog", "(Ljava/lang/String;Ljava/lang/String;)V")) {
jstring stringArg1;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getCocos2dxPackageName", "()Ljava/lang/String;")) {
jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID);
t.env->DeleteLocalRef(t.classID);
CCString *ret = new CCString(JniHelper::jstring2string(str).c_str());
ret->autorelease();
t.env->DeleteLocalRef(str);
return ret->m_sString.c_str();
if (!pszTitle) {
stringArg1 = t.env->NewStringUTF("");
} else {
stringArg1 = t.env->NewStringUTF(pszTitle);
}
return 0;
}
jstring stringArg2 = t.env->NewStringUTF(pszMsg);
t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg1, stringArg2);
const char * getFileDirectoryJNI() {
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getCocos2dxWritablePath", "()Ljava/lang/String;")) {
jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID);
t.env->DeleteLocalRef(t.classID);
CCString *ret = new CCString(JniHelper::jstring2string(str).c_str());
ret->autorelease();
t.env->DeleteLocalRef(str);
return ret->m_sString.c_str();
}
return 0;
}
const char* getCurrentLanguageJNI() {
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getCurrentLanguage", "()Ljava/lang/String;")) {
jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID);
t.env->DeleteLocalRef(t.classID);
CCString *ret = new CCString(JniHelper::jstring2string(str).c_str());
ret->autorelease();
t.env->DeleteLocalRef(str);
return ret->m_sString.c_str();
}
return 0;
}
void enableAccelerometerJNI() {
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "enableAccelerometer", "()V")) {
t.env->CallStaticVoidMethod(t.classID, t.methodID);
t.env->DeleteLocalRef(t.classID);
}
}
void setAccelerometerIntervalJNI(float interval) {
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setAccelerometerInterval", "(I)V")) {
t.env->CallStaticVoidMethod(t.classID, t.methodID, interval);
t.env->DeleteLocalRef(t.classID);
}
}
void disableAccelerometerJNI() {
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "disableAccelerometer", "()V")) {
t.env->CallStaticVoidMethod(t.classID, t.methodID);
t.env->DeleteLocalRef(t.classID);
}
t.env->DeleteLocalRef(stringArg1);
t.env->DeleteLocalRef(stringArg2);
t.env->DeleteLocalRef(t.classID);
}
}
void showEditTextDialogJNI(const char* pszTitle, const char* pszMessage, int nInputMode, int nInputFlag, int nReturnType, int nMaxLength, EditTextCallback pfEditTextCallback, void* ctx) {
if (pszMessage == NULL) {
return;
}
s_pfEditTextCallback = pfEditTextCallback;
s_ctx = ctx;
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "showEditTextDialog", "(Ljava/lang/String;Ljava/lang/String;IIII)V")) {
jstring stringArg1;
if (!pszTitle) {
stringArg1 = t.env->NewStringUTF("");
} else {
stringArg1 = t.env->NewStringUTF(pszTitle);
}
jstring stringArg2 = t.env->NewStringUTF(pszMessage);
t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg1, stringArg2, nInputMode, nInputFlag, nReturnType, nMaxLength);
t.env->DeleteLocalRef(stringArg1);
t.env->DeleteLocalRef(stringArg2);
t.env->DeleteLocalRef(t.classID);
}
}
void terminateProcessJNI() {
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "terminateProcess", "()V")) {
t.env->CallStaticVoidMethod(t.classID, t.methodID);
t.env->DeleteLocalRef(t.classID);
}
}
std::string getPackageNameJNI() {
JniMethodInfo t;
std::string ret("");
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getCocos2dxPackageName", "()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;
}
std::string getFileDirectoryJNI() {
JniMethodInfo t;
std::string ret("");
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getCocos2dxWritablePath", "()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;
}
std::string getCurrentLanguageJNI() {
JniMethodInfo t;
std::string ret("");
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getCurrentLanguage", "()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;
}
void enableAccelerometerJNI() {
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "enableAccelerometer", "()V")) {
t.env->CallStaticVoidMethod(t.classID, t.methodID);
t.env->DeleteLocalRef(t.classID);
}
}
void setAccelerometerIntervalJNI(float interval) {
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setAccelerometerInterval", "(I)V")) {
t.env->CallStaticVoidMethod(t.classID, t.methodID, interval);
t.env->DeleteLocalRef(t.classID);
}
}
void disableAccelerometerJNI() {
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "disableAccelerometer", "()V")) {
t.env->CallStaticVoidMethod(t.classID, t.methodID);
t.env->DeleteLocalRef(t.classID);
}
}
// functions for CCUserDefault
bool getBoolForKeyJNI(const char* pKey)
{
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getBoolForKey", "(Ljava/lang/String;)Z")) {
jstring stringArg = t.env->NewStringUTF(pKey);
jboolean ret = t.env->CallStaticBooleanMethod(t.classID, t.methodID, stringArg);
t.env->DeleteLocalRef(t.classID);
t.env->DeleteLocalRef(stringArg);
return ret;
}
return false;
}
int getIntegerForKeyJNI(const char* pKey)
{
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getIntegerForKey", "(Ljava/lang/String;)I")) {
jstring stringArg = t.env->NewStringUTF(pKey);
jint ret = t.env->CallStaticIntMethod(t.classID, t.methodID, stringArg);
t.env->DeleteLocalRef(t.classID);
t.env->DeleteLocalRef(stringArg);
return ret;
}
return 0;
}
float getFloatForKeyJNI(const char* pKey)
{
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getFloatForKey", "(Ljava/lang/String;)F")) {
jstring stringArg = t.env->NewStringUTF(pKey);
jfloat ret = t.env->CallStaticFloatMethod(t.classID, t.methodID, stringArg);
t.env->DeleteLocalRef(t.classID);
t.env->DeleteLocalRef(stringArg);
return ret;
}
return 0;
}
double getDoubleForKeyJNI(const char* pKey)
{
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getDoubleForKey", "(Ljava/lang/String;)D")) {
jstring stringArg = t.env->NewStringUTF(pKey);
jdouble ret = t.env->CallStaticDoubleMethod(t.classID, t.methodID, stringArg);
t.env->DeleteLocalRef(t.classID);
t.env->DeleteLocalRef(stringArg);
return ret;
}
return 0;
}
std::string getStringForKeyJNI(const char* pKey)
{
JniMethodInfo t;
std::string ret("");
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getStringForKey", "(Ljava/lang/String;)Ljava/lang/String;")) {
jstring stringArg = t.env->NewStringUTF(pKey);
jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID, stringArg);
ret = JniHelper::jstring2string(str);
t.env->DeleteLocalRef(t.classID);
t.env->DeleteLocalRef(stringArg);
t.env->DeleteLocalRef(str);
}
return ret;
}
void setBoolForKeyJNI(const char* pKey, bool value)
{
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setBoolForKey", "(Ljava/lang/String;Z)V")) {
jstring stringArg = t.env->NewStringUTF(pKey);
t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg, value);
t.env->DeleteLocalRef(t.classID);
t.env->DeleteLocalRef(stringArg);
}
}
void setIntegerForKeyJNI(const char* pKey, int value)
{
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setIntegerForKey", "(Ljava/lang/String;I)V")) {
jstring stringArg = t.env->NewStringUTF(pKey);
t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg, value);
t.env->DeleteLocalRef(t.classID);
t.env->DeleteLocalRef(stringArg);
}
}
void setFloatForKeyJNI(const char* pKey, float value)
{
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setFloatForKey", "(Ljava/lang/String;F)V")) {
jstring stringArg = t.env->NewStringUTF(pKey);
t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg, value);
t.env->DeleteLocalRef(t.classID);
t.env->DeleteLocalRef(stringArg);
}
}
void setDoubleForKeyJNI(const char* pKey, double value)
{
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setDoubleForKey", "(Ljava/lang/String;D)V")) {
jstring stringArg = t.env->NewStringUTF(pKey);
t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg, value);
t.env->DeleteLocalRef(t.classID);
t.env->DeleteLocalRef(stringArg);
}
}
void setStringForKeyJNI(const char* pKey, const char* value)
{
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setStringForKeyKey", "(Ljava/lang/String;Ljava/lang/String;)V")) {
jstring stringArg1 = t.env->NewStringUTF(pKey);
jstring stringArg2 = t.env->NewStringUTF(value);
t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg1, stringArg2);
t.env->DeleteLocalRef(t.classID);
t.env->DeleteLocalRef(stringArg1);
t.env->DeleteLocalRef(stringArg2);
}
}

View File

@ -28,17 +28,26 @@ THE SOFTWARE.
typedef void (*EditTextCallback)(const char* pText, void* ctx);
extern "C" {
extern const char * getApkPath();
extern void showDialogJNI(const char * pszMsg, const char * pszTitle);
extern void showEditTextDialogJNI(const char* pszTitle, const char* pszContent, int nInputMode, int nInputFlag, int nReturnType, int nMaxLength, EditTextCallback pfEditTextCallback, void* ctx);
extern void terminateProcessJNI();
extern const char * getCurrentLanguageJNI();
extern const char * getPackageNameJNI();
extern const char * getFileDirectoryJNI();
extern void enableAccelerometerJNI();
extern void disableAccelerometerJNI();
extern void setAccelerometerIntervalJNI(float interval);
}
extern const char * getApkPath();
extern void showDialogJNI(const char * pszMsg, const char * pszTitle);
extern void showEditTextDialogJNI(const char* pszTitle, const char* pszContent, int nInputMode, int nInputFlag, int nReturnType, int nMaxLength, EditTextCallback pfEditTextCallback, void* ctx);
extern void terminateProcessJNI();
extern std::string getCurrentLanguageJNI();
extern std::string getPackageNameJNI();
extern std::string getFileDirectoryJNI();
extern void enableAccelerometerJNI();
extern void disableAccelerometerJNI();
extern void setAccelerometerIntervalJNI(float interval);
// functions for CCUserDefault
extern bool getBoolForKeyJNI(const char* pKey);
extern int getIntegerForKeyJNI(const char* pKey);
extern float getFloatForKeyJNI(const char* pKey);
extern double getDoubleForKeyJNI(const char* pKey);
extern std::string getStringForKeyJNI(const char* pKey);
extern void setBoolForKeyJNI(const char* pKey, bool value);
extern void setIntegerForKeyJNI(const char* pKey, int value);
extern void setFloatForKeyJNI(const char* pKey, float value);
extern void setDoubleForKeyJNI(const char* pKey, double value);
extern void setStringForKeyJNI(const char* pKey, const char* value);
#endif
#endif /* __Java_org_cocos2dx_lib_Cocos2dxHelper_H__ */

View File

@ -23,6 +23,7 @@ THE SOFTWARE.
****************************************************************************/
#import "CCImage.h"
#import "CCFileUtils.h"
#import "CCCommon.h"
#import <string>
#import <Foundation/Foundation.h>
@ -211,19 +212,30 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl
constrainSize.width = pInfo->width;
constrainSize.height = pInfo->height;
// On iOS custom fonts must be listed beforehand in the App info.plist (in order to be usable) and referenced only the by the font family name itself when
// calling [UIFont fontWithName]. Therefore even if the developer adds 'SomeFont.ttf' or 'fonts/SomeFont.ttf' to the App .plist, the font must
// be referenced as 'SomeFont' when calling [UIFont fontWithName]. Hence we strip out the folder path components and the extension here in order to get just
// the font family name itself. This stripping step is required especially for references to user fonts stored in CCB files; CCB files appear to store
// the '.ttf' extensions when referring to custom fonts.
fntName = [[fntName lastPathComponent] stringByDeletingPathExtension];
// create the font
id font;
font = [UIFont fontWithName:fntName size:nSize];
id font = [UIFont fontWithName:fntName size:nSize];
if (font)
{
dim = _calculateStringSize(str, font, &constrainSize);
}
}
else
{
fntName = _isValidFontName(pFontName) ? fntName : @"MarkerFelt-Wide";
font = [UIFont fontWithName:fntName size:nSize];
if (! font)
if (!_isValidFontName(pFontName))
{
// Attempted to load a non system font. Attempt this fallback first before the default system font:
CCLOGERROR("Error! Failed to load the custom font '%s'! A default font will be used instead.", pFontName);
font = [UIFont fontWithName: @"MarkerFelt-Wide" size:nSize];
}
if (!font)
{
font = [UIFont systemFontOfSize:nSize];
}
@ -231,7 +243,7 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl
if (font)
{
dim = _calculateStringSize(str, font, &constrainSize);
}
}
}
CC_BREAK_IF(! font);

View File

@ -56,7 +56,7 @@ public:
iMaxLineHeight = 0;
//Free all text lines
size_t size = vLines.size();
for (int i=0; i<size; ++i) {
for (size_t i=0; i<size; ++i) {
TextLine line = vLines[i];
free(line.text);
}
@ -106,7 +106,7 @@ public:
oTempLine.text = text;
//get last glyph
int iError = FT_Load_Char(face, cLastChar, FT_LOAD_DEFAULT);
FT_Load_Char(face, cLastChar, FT_LOAD_DEFAULT);
oTempLine.iLineWidth = iCurXCursor;// - SHIFT6((face->glyph->metrics.horiAdvance + face->glyph->metrics.horiBearingX - face->glyph->metrics.width))/*-iInterval*/;//TODO interval
iMaxLineWidth = MAX(iMaxLineWidth, oTempLine.iLineWidth);
@ -116,7 +116,7 @@ public:
bool divideString(FT_Face face, const char* sText, int iMaxWidth, int iMaxHeight) {
int iError = 0;
int iCurXCursor, iCurYCursor;
int iCurXCursor;
const char* pText = sText;
FT_UInt unicode = utf8((char**)&pText);
@ -131,7 +131,7 @@ public:
pText = sText;
size_t text_len = 0;
wchar_t* text_buf = (wchar_t*) malloc(sizeof(wchar_t) * strlen(sText));
while (unicode=utf8((char**)&pText)) {
while ((unicode=utf8((char**)&pText))) {
if (unicode == '\n') {
buildLine(text_buf, text_len, face, iCurXCursor, cLastCh);
text_len = 0;

View File

@ -0,0 +1,48 @@
/****************************************************************************
Copyright (c) 2013 The Chromium Authors
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 __CCACCELEROMETER_H__
#define __CCACCELEROMETER_H__
#include "platform/CCAccelerometerDelegate.h"
namespace cocos2d {
class CCAccelerometer
{
public:
CCAccelerometer(){}
~CCAccelerometer(){}
static CCAccelerometer* sharedAccelerometer() { return NULL; };
void removeDelegate(CCAccelerometerDelegate* pDelegate) {CC_UNUSED_PARAM(pDelegate);};
void addDelegate(CCAccelerometerDelegate* pDelegate) {CC_UNUSED_PARAM(pDelegate);};
void setDelegate(CCAccelerometerDelegate* pDelegate) {CC_UNUSED_PARAM(pDelegate);};
void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);};
};
}
#endif /* __CCACCELEROMETER_H__ */

View File

@ -0,0 +1,110 @@
/****************************************************************************
Copyright (c) 2013 The Chromium Authors
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 "CCApplication.h"
#include "CCEGLView.h"
#include <unistd.h>
#include <sys/time.h>
#include <string>
#include "CCDirector.h"
NS_CC_BEGIN
CCApplication* CCApplication::sm_pSharedApplication = 0;
bool CCApplication::s_running = false;
/*
static long getCurrentMillSecond()
{
long lLastTime;
struct timeval stCurrentTime;
gettimeofday(&stCurrentTime,NULL);
// millseconds
lLastTime = stCurrentTime.tv_sec * 1000 + stCurrentTime.tv_usec * 0.001;
return lLastTime;
}
*/
CCApplication::CCApplication()
{
CC_ASSERT(!sm_pSharedApplication);
sm_pSharedApplication = this;
setAnimationInterval(1.0f/60.0f);
}
CCApplication::~CCApplication()
{
CC_ASSERT(this == sm_pSharedApplication);
sm_pSharedApplication = NULL;
}
int CCApplication::run()
{
// Initialize instance and cocos2d.
if (!applicationDidFinishLaunching())
return 0;
s_running = true;
for (;;)
{
//long iLastTime = getCurrentMillSecond();
CCDirector::sharedDirector()->mainLoop();
CCEGLView::sharedOpenGLView()->ProcessEventQueue();
//long iCurTime = getCurrentMillSecond();
/*
if (iCurTime-iLastTime<m_nAnimationInterval)
{
usleep((m_nAnimationInterval - iCurTime+iLastTime)*1000);
}
*/
}
s_running = false;
return -1;
}
void CCApplication::setAnimationInterval(double interval)
{
m_nAnimationInterval = interval * 1000.0f;
}
TargetPlatform CCApplication::getTargetPlatform()
{
return kTargetNaCl;
}
CCApplication* CCApplication::sharedApplication()
{
CC_ASSERT(sm_pSharedApplication);
return sm_pSharedApplication;
}
ccLanguageType CCApplication::getCurrentLanguage()
{
ccLanguageType ret = kLanguageEnglish;
return ret;
}
NS_CC_END

View File

@ -0,0 +1,75 @@
/****************************************************************************
Copyright (c) 2013 The Chromium Authors
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 __CCAPLICATION_H__
#define __CCAPLICATION_H__
#include "platform/CCCommon.h"
#include "platform/CCApplicationProtocol.h"
NS_CC_BEGIN
class CCRect;
class CCApplication : public CCApplicationProtocol
{
public:
CCApplication();
virtual ~CCApplication();
/**
@brief Callback by CCDirector for limit FPS.
@interval The time, which expressed in second in second, between current frame and next.
*/
void setAnimationInterval(double interval);
/**
@brief Run the message loop.
*/
int run();
/**
@brief Get current applicaiton instance.
@return Current application instance pointer.
*/
static CCApplication* sharedApplication();
/* override functions */
virtual ccLanguageType getCurrentLanguage();
/**
@brief Get target platform
*/
virtual TargetPlatform getTargetPlatform();
static bool isRunning() { return s_running; }
protected:
long m_nAnimationInterval; // microseconds
static bool s_running; // is the application running
static CCApplication* sm_pSharedApplication;
};
NS_CC_END
#endif /* __CCAPLICATION_H__ */

View File

@ -0,0 +1,54 @@
/****************************************************************************
Copyright (c) 2013 The Chromium Authors
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/CCCommon.h"
#include "CCStdC.h"
NS_CC_BEGIN
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
void CCLog(const char * pszFormat, ...)
{
char szBuf[MAX_LEN];
va_list ap;
va_start(ap, pszFormat);
vsnprintf( szBuf, MAX_LEN, pszFormat, ap);
va_end(ap);
fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf);
}
void CCMessageBox(const char * pszMsg, const char * pszTitle)
{
CCLog("%s: %s", pszTitle, pszMsg);
}
void CCLuaLog(const char * pszFormat)
{
CCLog(pszFormat);
}
NS_CC_END

View File

@ -0,0 +1,35 @@
/****************************************************************************
Copyright (c) 2013 The Chromium Authors
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/CCDevice.h"
NS_CC_BEGIN
int CCDevice::getDPI()
{
//TODO(sbc):
return 160;
}
NS_CC_END

View File

@ -0,0 +1,334 @@
/****************************************************************************
Copyright (c) 2013 The Chromium Authors
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 "CCEGLView.h"
#include "CCGL.h"
#include "ccMacros.h"
#include "CCDirector.h"
#include "CCInstance.h"
#include "touch_dispatcher/CCTouch.h"
#include "touch_dispatcher/CCTouchDispatcher.h"
#include "text_input_node/CCIMEDispatcher.h"
#include "ppapi/c/ppb_opengles2.h"
#include "ppapi/cpp/graphics_3d.h"
#include "ppapi/cpp/graphics_3d_client.h"
#include "ppapi/cpp/size.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/completion_callback.h"
#include "ppapi/gles2/gl2ext_ppapi.h"
class OpenGLContext : public pp::Graphics3DClient
{
public:
OpenGLContext(pp::Instance* instance, pp::Size size);
~OpenGLContext();
virtual void Graphics3DContextLost()
{
assert(!"Unexpectedly lost graphics context");
}
bool MakeContextCurrent();
void InvalidateContext();
void ResizeContext(int width, int height);
void FlushContext();
pp::Size GetSize() { return m_size; }
private:
pp::Size m_size;
pp::Graphics3D m_graphics3d;
const struct PPB_OpenGLES2* m_gles2_interface;
pp::Instance* m_instance;
};
OpenGLContext::OpenGLContext(pp::Instance* instance, pp::Size size) :
pp::Graphics3DClient(instance), m_size(size), m_instance(instance)
{
pp::Module* module = pp::Module::Get();
assert(module);
m_gles2_interface = static_cast<const struct PPB_OpenGLES2*>(
module->GetBrowserInterface(PPB_OPENGLES2_INTERFACE));
assert(m_gles2_interface);
}
OpenGLContext::~OpenGLContext()
{
CCLOG("OpenGLContext::~OpenGLContext");
glSetCurrentContextPPAPI(0);
}
bool OpenGLContext::MakeContextCurrent()
{
CCLOG("OpenGLContext::MakeContextCurrent %dx%d",
m_size.width(), m_size.height());
// Lazily create the Pepper context.
if (m_graphics3d.is_null())
{
int32_t attribs[] = {
PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8,
PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 24,
PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 8,
PP_GRAPHICS3DATTRIB_SAMPLES, 0,
PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS, 0,
PP_GRAPHICS3DATTRIB_WIDTH, m_size.width(),
PP_GRAPHICS3DATTRIB_HEIGHT, m_size.height(),
PP_GRAPHICS3DATTRIB_NONE
};
m_graphics3d = pp::Graphics3D(m_instance, pp::Graphics3D(), attribs);
if (m_graphics3d.is_null())
{
glSetCurrentContextPPAPI(0);
return false;
}
bool rtn = m_instance->BindGraphics(m_graphics3d);
assert(rtn && "BindGraphics failed");
if (!rtn)
return false;
}
CCLOG("glSetCurrentContextPPAPI: %p", m_graphics3d.pp_resource());
glSetCurrentContextPPAPI(m_graphics3d.pp_resource());
return true;
}
void OpenGLContext::InvalidateContext()
{
CCLOG("InvalidateContext");
glSetCurrentContextPPAPI(0);
}
void OpenGLContext::ResizeContext(int width, int height)
{
CCLOG("OpenGLContext::ResizeContext %dx%d", width, height);
m_size.SetSize(width, height);
if (!m_graphics3d.is_null())
{
m_graphics3d.ResizeBuffers(width, height);
}
}
void OpenGLContext::FlushContext()
{
//CCLOG("OpenGLContext::FlushContext");
m_graphics3d.SwapBuffers(pp::BlockUntilComplete());
}
NS_CC_BEGIN
CCEGLView::CCEGLView() : bIsInit(false), bIsMouseDown(false), m_fFrameZoomFactor(1.0f), m_context(NULL)
{
CCLOG("CCEGLView::CCEGLView");
pthread_mutex_init(&m_mutex, NULL);
initGL();
}
CCEGLView::~CCEGLView()
{
}
void CCEGLView::setFrameSize(float width, float height)
{
CCEGLViewProtocol::setFrameSize(width, height);
if (m_context)
m_context->ResizeContext(width, height);
}
void CCEGLView::setViewPortInPoints(float x , float y , float w , float h)
{
glViewport((GLint)(x * m_fScaleX * m_fFrameZoomFactor+ m_obViewPortRect.origin.x * m_fFrameZoomFactor),
(GLint)(y * m_fScaleY * m_fFrameZoomFactor + m_obViewPortRect.origin.y * m_fFrameZoomFactor),
(GLsizei)(w * m_fScaleX * m_fFrameZoomFactor),
(GLsizei)(h * m_fScaleY * m_fFrameZoomFactor));
}
void CCEGLView::setScissorInPoints(float x , float y , float w , float h)
{
glScissor((GLint)(x * m_fScaleX * m_fFrameZoomFactor + m_obViewPortRect.origin.x * m_fFrameZoomFactor),
(GLint)(y * m_fScaleY * m_fFrameZoomFactor + m_obViewPortRect.origin.y * m_fFrameZoomFactor),
(GLsizei)(w * m_fScaleX * m_fFrameZoomFactor),
(GLsizei)(h * m_fScaleY * m_fFrameZoomFactor));
}
bool CCEGLView::isOpenGLReady()
{
return bIsInit;
}
void CCEGLView::end()
{
delete this;
exit(0);
}
void CCEGLView::swapBuffers()
{
if (!bIsInit)
return;
m_context->FlushContext();
}
void CCEGLView::setIMEKeyboardState(bool bOpen)
{
}
bool CCEGLView::initGL()
{
CCLOG("initGL: instance=%p", g_instance);
assert(g_instance);
assert(!m_context);
const pp::Size& size = g_instance->Size();
setFrameSize(size.width(), size.height());
m_context = new OpenGLContext(g_instance, size);
CCLOG("initGL: m_context=%p", m_context);
bool rtn = m_context->MakeContextCurrent();
CCLOG("MakeContextCurrent returned: %d", rtn);
assert(rtn == true && "MakeContextCurrent failed");
if (!rtn)
return false;
bIsInit = true;
return true;
}
void CCEGLView::destroyGL()
{
delete m_context;
bIsInit = false;
CCLOG("destroyGL");
}
CCEGLView* CCEGLView::sharedOpenGLView()
{
static CCEGLView* s_pEglView = NULL;
if (s_pEglView == NULL)
{
CCLOG("creating CCEGLView");
s_pEglView = new CCEGLView();
}
return s_pEglView;
}
void CCEGLView::HandleMouseEvent(const pp::MouseInputEvent* event)
{
pp::Point pos = event->GetPosition();
float x = pos.x();
float y = pos.y();
int touchID = 1;
// Clamp event position to be within cocos2dx window size
CCSize frame_size = getFrameSize();
float max_y = frame_size.height;
float max_x = frame_size.width;
if (x < 0)
x = 0;
if (y < 0)
y = 0;
if (y > max_y)
y = max_y;
if (x > max_x)
x = max_x;
switch (event->GetType())
{
case PP_INPUTEVENT_TYPE_MOUSEDOWN:
handleTouchesBegin(1, &touchID, &x, &y);
bIsMouseDown = true;
break;
case PP_INPUTEVENT_TYPE_MOUSEUP:
handleTouchesEnd(1, &touchID, &x, &y);
bIsMouseDown = false;
break;
case PP_INPUTEVENT_TYPE_MOUSEMOVE:
if (bIsMouseDown)
handleTouchesMove(1, &touchID, &x, &y);
break;
default:
break;
}
}
void CCEGLView::ProcessEventQueue()
{
const pp::Size& size = g_instance->Size();
// If the size of the global instance has changed then
// we need to update our GL frame size accordingly
if (size != m_context->GetSize())
{
setFrameSize(size.width(), size.height());
}
pthread_mutex_lock(&m_mutex);
while (m_event_queue.size())
{
pp::InputEvent event = m_event_queue.front();
m_event_queue.pop();
PP_InputEvent_Type type = event.GetType();
switch (type)
{
case PP_INPUTEVENT_TYPE_KEYDOWN:
CCLOG("got KEYDOWN");
break;
case PP_INPUTEVENT_TYPE_KEYUP:
CCLOG("got KEYUP");
break;
case PP_INPUTEVENT_TYPE_CHAR:
CCLOG("got KEYCHAR");
break;
case PP_INPUTEVENT_TYPE_MOUSEENTER:
CCLOG("got MOUSEENTER");
break;
case PP_INPUTEVENT_TYPE_MOUSELEAVE:
CCLOG("got MOUSELEAVE");
break;
case PP_INPUTEVENT_TYPE_MOUSEDOWN:
case PP_INPUTEVENT_TYPE_MOUSEUP:
case PP_INPUTEVENT_TYPE_MOUSEMOVE:
{
const pp::MouseInputEvent* mevent =
reinterpret_cast<const pp::MouseInputEvent*>(&event);
HandleMouseEvent(mevent);
break;
}
default:
CCLOG("unhandled event type: %d", type);
break;
}
}
pthread_mutex_unlock(&m_mutex);
}
void CCEGLView::AddEvent(const pp::InputEvent& event)
{
pthread_mutex_lock(&m_mutex);
m_event_queue.push(event);
pthread_mutex_unlock(&m_mutex);
}
CocosPepperInstance* CCEGLView::g_instance;
NS_CC_END

View File

@ -0,0 +1,89 @@
/****************************************************************************
Copyright (c) 2013 The Chromium Authors
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 __CCEGLVIEW_H__
#define __CCEGLVIEW_H__
#include "platform/CCCommon.h"
#include "cocoa/CCGeometry.h"
#include "platform/CCEGLViewProtocol.h"
#include "ppapi/cpp/input_event.h"
#include <pthread.h>
#include <queue>
bool initExtensions();
class OpenGLContext;
class CocosPepperInstance;
NS_CC_BEGIN
class CCEGLView : public CCEGLViewProtocol
{
public:
CCEGLView();
virtual ~CCEGLView();
/**
* iPixelWidth, height: the window's size
* iWidth ,height: the point size, which may scale.
* iDepth is not the buffer depth of opengl, it indicate how may bits for a pixel
*/
virtual void setFrameSize(float width, float height);
virtual void setViewPortInPoints(float x , float y , float w , float h);
virtual void setScissorInPoints(float x , float y , float w , float h);
/*
* Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
*/
virtual bool isOpenGLReady();
virtual void end();
virtual void swapBuffers();
virtual void setIMEKeyboardState(bool bOpen);
void addEvent();
void ProcessEventQueue();
void AddEvent(const pp::InputEvent& event);
/**
@brief get the shared main open gl window
*/
static CCEGLView* sharedOpenGLView();
static CocosPepperInstance* g_instance;
private:
void HandleMouseEvent(const pp::MouseInputEvent* event);
bool initGL();
void destroyGL();
bool bIsInit;
bool bIsMouseDown;
float m_fFrameZoomFactor;
OpenGLContext* m_context;
std::queue<pp::InputEvent> m_event_queue;
pthread_mutex_t m_mutex;
};
NS_CC_END
#endif /* __CCEGLVIEW_H__ */

View File

@ -0,0 +1,61 @@
/****************************************************************************
Copyright (c) 2013 The Chromium Authors
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 "CCFileUtilsNaCl.h"
#include <sys/stat.h>
using namespace std;
NS_CC_BEGIN
CCFileUtils* CCFileUtils::sharedFileUtils()
{
if (s_sharedFileUtils == NULL)
{
s_sharedFileUtils = new CCFileUtilsNaCl();
s_sharedFileUtils->init();
}
return s_sharedFileUtils;
}
std::string CCFileUtilsNaCl::getWritablePath()
{
//return current resource path
return "";
}
bool CCFileUtilsNaCl::isFileExist(const std::string& strFilePath)
{
std::string strPath = strFilePath;
if (!isAbsolutePath(strPath))
{ // Not absolute path, add the default root path at the beginning.
strPath.insert(0, m_strDefaultResRootPath);
}
struct stat sts;
return (stat(strPath.c_str(), &sts) != -1) ? true : false;
}
NS_CC_END

View File

@ -0,0 +1,57 @@
/****************************************************************************
Copyright (c) 2013 The Chromium Authors
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 __CC_FILEUTILS_NACL_H__
#define __CC_FILEUTILS_NACL_H__
#include "platform/CCFileUtils.h"
#include "ccTypes.h"
#include <string>
NS_CC_BEGIN
/**
* @addtogroup platform
* @{
*/
//! @brief Helper class to handle file operations
class CC_DLL CCFileUtilsNaCl : public CCFileUtils
{
private:
friend class CCFileUtils;
CCFileUtilsNaCl() {}
public:
/* override funtions */
bool init() { return true; }
virtual std::string getWritablePath();
virtual bool isFileExist(const std::string& strFilePath);
};
// end of platform group
/// @}
NS_CC_END
#endif // __CC_FILEUTILS_NACL_H__

View File

@ -0,0 +1,36 @@
/****************************************************************************
Copyright (c) 2013 The Chromium Authors
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 __CCGL_H__
#define __CCGL_H__
#define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
#define GL_WRITE_ONLY GL_WRITE_ONLY_OES
#define glClearDepth glClearDepthf
#define GL_BGRA GL_BGRA_EXT
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#endif // __CCGL_H__

View File

@ -0,0 +1,533 @@
/****************************************************************************
Copyright (c) 2013 The Chromium Authors
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 <string.h>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include "platform/CCFileUtils.h"
#include "platform/CCPlatformMacros.h"
#define __CC_PLATFORM_IMAGE_CPP__
#include "platform/CCImageCommon_cpp.h"
#include "platform/CCImage.h"
#include "platform/linux/CCApplication.h"
#include "ft2build.h"
#include "CCStdC.h"
#include FT_FREETYPE_H
#define szFont_kenning 2
#define SHIFT6(num) (num>>6)
using namespace std;
struct TextLine {
int iLineWidth;
wchar_t* text;
};
NS_CC_BEGIN
class BitmapDC
{
public:
BitmapDC() : m_pData(NULL), m_cachedSize(0), m_cachedFont(NULL)
{
libError = FT_Init_FreeType(&m_library);
iInterval = szFont_kenning;
reset();
}
~BitmapDC()
{
if (m_cachedFont)
FT_Done_Face(m_cachedFont);
FT_Done_FreeType(m_library);
reset();
}
void reset()
{
iMaxLineWidth = 0;
iMaxLineHeight = 0;
//Free all text lines
size_t size = vLines.size();
for (size_t i=0; i<size; ++i)
{
TextLine line = vLines[i];
free(line.text);
}
vLines.clear();
}
int utf8(char **p)
{
if ((**p & 0x80) == 0x00)
{
int a = *((*p)++);
return a;
}
if ((**p & 0xE0) == 0xC0)
{
int a = *((*p)++) & 0x1F;
int b = *((*p)++) & 0x3F;
return (a << 6) | b;
}
if ((**p & 0xF0) == 0xE0)
{
int a = *((*p)++) & 0x0F;
int b = *((*p)++) & 0x3F;
int c = *((*p)++) & 0x3F;
return (a << 12) | (b << 6) | c;
}
if ((**p & 0xF8) == 0xF0)
{
int a = *((*p)++) & 0x07;
int b = *((*p)++) & 0x3F;
int c = *((*p)++) & 0x3F;
int d = *((*p)++) & 0x3F;
return (a << 18) | (b << 12) | (c << 8) | d;
}
return 0;
}
void buildLine(wchar_t* buf, size_t buf_len, FT_Face face, int iCurXCursor, FT_UInt cLastChar)
{
TextLine oTempLine;
wchar_t* text = (wchar_t*)malloc(sizeof(wchar_t) * (buf_len+1));
memcpy(text, buf, sizeof(wchar_t) * buf_len);
text[buf_len] = '\0';
oTempLine.text = text;
//get last glyph
FT_Load_Char(face, cLastChar, FT_LOAD_DEFAULT);
oTempLine.iLineWidth = iCurXCursor;// - SHIFT6((face->glyph->metrics.horiAdvance + face->glyph->metrics.horiBearingX - face->glyph->metrics.width))/*-iInterval*/;//TODO interval
iMaxLineWidth = MAX(iMaxLineWidth, oTempLine.iLineWidth);
vLines.push_back(oTempLine);
}
bool divideString(FT_Face face, const char* sText, int iMaxWidth, int iMaxHeight)
{
int iError = 0;
const char* pText = sText;
FT_UInt unicode = utf8((char**)&pText);
iError = FT_Load_Char(face, unicode, FT_LOAD_DEFAULT);
if (iError)
return false;
int iCurXCursor = -SHIFT6(face->glyph->metrics.horiBearingX);
FT_UInt cLastCh = 0;
pText = sText;
size_t text_len = 0;
wchar_t* text_buf = (wchar_t*) malloc(sizeof(wchar_t) * strlen(sText));
while ((unicode=utf8((char**)&pText)))
{
if (unicode == '\n')
{
buildLine(text_buf, text_len, face, iCurXCursor, cLastCh);
text_len = 0;
iError = FT_Load_Char(face, unicode, FT_LOAD_DEFAULT);
if (iError) {
free(text_buf);
return false;
}
iCurXCursor = -SHIFT6(face->glyph->metrics.horiBearingX);
continue;
}
iError = FT_Load_Char(face, unicode, FT_LOAD_DEFAULT);
if (iError) {
free(text_buf);
return false;
}
//check its width
//divide it when exceeding
if ((iMaxWidth > 0
&& iCurXCursor + SHIFT6(face->glyph->metrics.width)
> iMaxWidth)) {
buildLine(text_buf, text_len, face , iCurXCursor, cLastCh);
text_len = 0;
iCurXCursor = -SHIFT6(face->glyph->metrics.horiBearingX);
}
cLastCh = unicode;
text_buf[text_len] = unicode;
++text_len;
iCurXCursor += SHIFT6(face->glyph->metrics.horiAdvance) + iInterval;
}
if (iError)
{
free(text_buf);
return false;
}
buildLine(text_buf, text_len, face, iCurXCursor, cLastCh);
free(text_buf);
return true;
}
/**
* compute the start pos of every line
*
* return >0 represent the start x pos of the line
* while -1 means fail
*
*/
int computeLineStart(FT_Face face, CCImage::ETextAlign eAlignMask, FT_UInt unicode,
int iLineIndex)
{
int iRet;
int iError = FT_Load_Char(face, unicode, FT_LOAD_DEFAULT);
if (iError) {
return -1;
}
if (eAlignMask == CCImage::kAlignCenter) {
iRet = (iMaxLineWidth - vLines[iLineIndex].iLineWidth) / 2
- SHIFT6(face->glyph->metrics.horiBearingX );
} else if (eAlignMask == CCImage::kAlignRight) {
iRet = (iMaxLineWidth - vLines[iLineIndex].iLineWidth)
- SHIFT6(face->glyph->metrics.horiBearingX );
} else {
// left or other situation
iRet = -SHIFT6(face->glyph->metrics.horiBearingX );
}
return iRet;
}
int computeLineStartY(FT_Face face, CCImage::ETextAlign eAlignMask, int txtHeight, int borderHeight)
{
int iRet = 0;
if (eAlignMask == CCImage::kAlignCenter || eAlignMask == CCImage::kAlignLeft ||
eAlignMask == CCImage::kAlignRight ) {
//vertical center
iRet = (borderHeight - txtHeight)/2;
} else if (eAlignMask == CCImage::kAlignBottomRight ||
eAlignMask == CCImage::kAlignBottom ||
eAlignMask == CCImage::kAlignBottomLeft ) {
//vertical bottom
iRet = borderHeight - txtHeight;
}
iRet += SHIFT6(face->size->metrics.ascender);
return iRet;
}
bool renderLine(FT_Face face, const wchar_t* text_ptr, int* iCurXCursor, int iCurYCursor)
{
assert(iCurYCursor > 0);
size_t text_len = wcslen(text_ptr);
for (size_t i=0; i<text_len; ++i)
{
int iError = FT_Load_Char(face, text_ptr[i], FT_LOAD_RENDER);
if (iError)
return false;
// convert glyph to bitmap with 256 gray
// and get the bitmap
FT_Bitmap& bitmap = face->glyph->bitmap;
int yoffset = iCurYCursor - SHIFT6(face->glyph->metrics.horiBearingY);
int xoffset = *iCurXCursor + SHIFT6(face->glyph->metrics.horiBearingX);
for (int i = 0; i < bitmap.rows; ++i)
{
for (int j = 0; j < bitmap.width; ++j)
{
unsigned char cTemp = bitmap.buffer[i * bitmap.width + j];
if (cTemp == 0) continue;
// if it has gray>0 we set show it as 1, o otherwise
int iY = yoffset + i;
int iX = xoffset + j;
if (iY < 0)
{
//truncate if drawing below first line
assert(iY >= -1);
continue;
}
if (iY >= iMaxLineHeight)
{
//exceed the height truncate
assert(iY <= iMaxLineHeight + 1);
continue;
}
int iTemp = cTemp << 24 | cTemp << 16 | cTemp << 8 | cTemp;
int data_offset = iY * iMaxLineWidth + iX;
assert(data_offset >= 0);
assert(data_offset < m_DataSize);
m_pData[data_offset] = iTemp;
}
}
//step to next glyph
*iCurXCursor += SHIFT6(face->glyph->metrics.horiAdvance) + iInterval;
}
return true;
}
bool renderLines(FT_Face face, CCImage::ETextAlign eAlignMask, int iCurYCursor)
{
size_t lines = vLines.size();
for (size_t i = 0; i < lines; i++)
{
const wchar_t* text_ptr = vLines[i].text;
// initialize the origin cursor
int iCurXCursor = computeLineStart(face, eAlignMask, text_ptr[0], i);
if (!renderLine(face, text_ptr, &iCurXCursor, iCurYCursor))
return false;
iCurYCursor += SHIFT6(face->size->metrics.ascender) -
SHIFT6(face->size->metrics.descender);
}
return true;
}
bool getBitmap(const char *text, int nWidth, int nHeight, CCImage::ETextAlign eAlignMask, const char * pFontName, float fontSize)
{
FT_Error iError;
if (libError)
return false;
std::string fontfile = pFontName;
std::string fontfileOrig = std::string(fontfile);
std::string ext = fileNameExtension(fontfile);
if (ext.empty() || (ext != "ttf" && ext != "TTF"))
{
fontfile += ".ttf" ;
}
iError = openFont(fontfile, fontSize, fontfileOrig);
// try with fonts prefixed
if (iError && !startsWith(fontfile,"fonts/") )
{
fontfile = std::string("fonts/") + fontfile;
iError = openFont(fontfile, fontSize, fontfileOrig);
}
if (iError)
{
// try lowercase version
std::transform(fontfile.begin(), fontfile.end(), fontfile.begin(), ::tolower);
iError = openFont(fontfile, fontSize, fontfileOrig);
if (iError)
{
// try default font
CCLOG("font missing (%s) falling back to default font", fontfileOrig.c_str());
iError = openFont("fonts/Marker Felt.ttf", fontSize, fontfileOrig);
if (iError)
CCLOG("default font missing (fonts/Marker Felt.ttf)");
}
}
if (iError)
return false;
FT_Face face = m_cachedFont;
//select utf8 charmap
iError = FT_Select_Charmap(face,FT_ENCODING_UNICODE);
if (iError)
return false;
iError = FT_Set_Pixel_Sizes(face, fontSize, fontSize);
if (iError)
return false;
if (!divideString(face, text, nWidth, nHeight))
return false;
//compute the final line width
iMaxLineWidth = MAX(iMaxLineWidth, nWidth);
iMaxLineHeight = SHIFT6(face->size->metrics.ascender) - SHIFT6(face->size->metrics.descender);
iMaxLineHeight *= vLines.size();
int txtHeight = iMaxLineHeight;
//compute the final line height
iMaxLineHeight = MAX(iMaxLineHeight, nHeight);
// create m_pData as render target
m_DataSize = iMaxLineWidth * iMaxLineHeight;
m_pData = new int[m_DataSize];
memset(m_pData, 0, m_DataSize*sizeof(*m_pData));
//iCurYCursor = SHIFT6(face->size->metrics.ascender);
int iCurYCursor = computeLineStartY(face, eAlignMask, txtHeight, iMaxLineHeight);
if (!renderLines(face, eAlignMask, iCurYCursor))
return false;
// success;
return true;
}
public:
FT_Library m_library;
int *m_pData;
// size of m_pData in words
int m_DataSize;
int libError;
vector<TextLine> vLines;
int iInterval;
int iMaxLineWidth;
int iMaxLineHeight;
private:
bool startsWith(const std::string& str, const std::string& what);
/**
* Attempt to open font file, and cache it if successful.
*/
int openFont(const std::string& fontName, uint fontSize, const std::string& fontNameOrig);
std::string fileNameExtension(const std::string& pathName);
uint m_cachedSize;
FT_Face m_cachedFont;
std::string m_cachedFontname;
std::string m_cachedFontnameOrig;
};
static BitmapDC& sharedBitmapDC()
{
static BitmapDC s_BmpDC;
return s_BmpDC;
}
bool CCImage::initWithString(
const char * pText,
int nWidth/* = 0*/,
int nHeight/* = 0*/,
ETextAlign eAlignMask/* = kAlignCenter*/,
const char * pFontName/* = nil*/,
int nSize/* = 0*/)
{
bool bRet = false;
do
{
CC_BREAK_IF(! pText);
BitmapDC &dc = sharedBitmapDC();
//const char* pFullFontName = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pFontName);
CC_BREAK_IF(! dc.getBitmap(pText, nWidth, nHeight, eAlignMask, pFontName, nSize));
// assign the dc.m_pData to m_pData in order to save time
m_pData = (unsigned char*)dc.m_pData;
CC_BREAK_IF(! m_pData);
m_nWidth = (short)dc.iMaxLineWidth;
m_nHeight = (short)dc.iMaxLineHeight;
m_bHasAlpha = true;
m_bPreMulti = true;
m_nBitsPerComponent = 8;
bRet = true;
dc.reset();
} while (0);
if (!bRet)
CCLOG("CCImage::initWithString failed");
//do nothing
return bRet;
}
std::string BitmapDC::fileNameExtension(const std::string& pathName)
{
std::string ext ;
std::string::size_type pos = pathName.find_last_of(".") ;
if (pos != std::string::npos && pos != pathName.size()-1 )
{
ext = pathName.substr(pos+1) ;
}
return ext ;
}
bool BitmapDC::startsWith(const std::string& str, const std::string& what)
{
bool result = false ;
if (what.size() <= str.size())
{
result = (str.substr(0, what.size()) == what);
}
return result ;
}
int BitmapDC::openFont(const std::string& fontName, uint fontSize, const std::string& fontNameOrig)
{
// try to satisfy request based on currently cached font.
if (m_cachedSize == fontSize)
{
if (fontNameOrig == m_cachedFontnameOrig)
return 0;
if (fontName == m_cachedFontname)
return 0;
}
FT_Face face;
int iError = FT_New_Face(m_library, fontName.c_str(), 0, &face);
if (iError)
return iError;
// free existing cached font
if (m_cachedFont)
FT_Done_Face(m_cachedFont);
// cache newly loaded font
m_cachedFontnameOrig = fontNameOrig;
m_cachedFontname = fontName;
m_cachedFont = face;
m_cachedSize = fontSize;
return 0;
}
NS_CC_END

View File

@ -0,0 +1,113 @@
/****************************************************************************
Copyright (c) 2013 The Chromium Authors
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/CCCommon.h"
#include "CCInstance.h"
#include "CCApplication.h"
#include "CCEGLView.h"
#include <ppapi/cpp/instance.h>
#include <ppapi/cpp/module.h>
#ifndef OLD_NACL_MOUNTS
#include "nacl_io/nacl_io.h"
#endif
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
USING_NS_CC;
CocosPepperInstance::CocosPepperInstance(PP_Instance instance) : pp::Instance(instance),
#ifdef OLD_NACL_MOUNTS
m_runner(NULL),
#endif
m_running(false)
{
RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD);
}
void CocosPepperInstance::DidChangeView(const pp::View& view)
{
pp::Rect position = view.GetRect();
if (m_size == position.size())
{
// Size did not change.
return;
}
if (m_running)
{
CCLOG("DidChangeView (%dx%d) while cocos thread already running",
position.size().width(), position.size().height());
return;
}
m_size = position.size();
assert(!CCEGLView::g_instance);
CCEGLView::g_instance = this;
CCLOG("DidChangeView %dx%d", m_size.width(), m_size.height());
pthread_create(&m_cocos_thread, NULL, cocos_main, this);
m_running = true;
}
bool CocosPepperInstance::Init(uint32_t argc, const char* argn[], const char* argv[])
{
CCLog("CocosPepperInstance::Init");
#ifdef OLD_NACL_MOUNTS
m_runner = new MainThreadRunner(this);
#else
CCLOG("%p %p", pp_instance(), pp::Module::Get()->get_browser_interface());
nacl_io_init_ppapi(pp_instance(), pp::Module::Get()->get_browser_interface());
CCLOG("done nacl_mounts_init_ppapi");
umount("/");
int rtn = mount("Resources", /* source. Use relative URL */
"/", /* target */
"httpfs", /* filesystemtype */
0, /* mountflags */
""); /* data */
if (rtn != 0)
{
CCLOG("mount failed: %d %s", errno, strerror(errno));
return false;
}
#endif
return true;
}
bool CocosPepperInstance::HandleInputEvent(const pp::InputEvent& event)
{
if (!CCApplication::isRunning())
return false;
CCEGLView::sharedOpenGLView()->AddEvent(event);
return true;
}

View File

@ -0,0 +1,67 @@
/****************************************************************************
Copyright (c) 2013 The Chromium Authors
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 __CC_INSTANCE_H__
#define __CC_INSTANCE_H__
#include <ppapi/cpp/instance.h>
#include <ppapi/cpp/input_event.h>
#include <pthread.h>
#ifdef OLD_NACL_MOUNTS
#include "nacl-mounts/base/MainThreadRunner.h"
#endif
extern "C" void* cocos_main(void* arg);
class CocosPepperInstance : public pp::Instance {
public:
explicit CocosPepperInstance(PP_Instance instance);
virtual ~CocosPepperInstance()
{
#ifdef OLD_NACL_MOUNTS
if (m_runner)
delete m_runner;
#endif
}
virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]);
void DidChangeView(const pp::View& view);
bool HandleInputEvent(const pp::InputEvent& event);
pp::Size Size() { return m_size; }
#ifdef OLD_NACL_MOUNTS
MainThreadRunner* m_runner;
#endif
private:
pp::Size m_size;
pthread_t m_cocos_thread;
bool m_running;
};
#endif /* __CC_INSTANCE_H__ */

View File

@ -0,0 +1,49 @@
/****************************************************************************
Copyright (c) 2013 The Chromium Authors
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 __CC_MODULE_H__
#define __CC_MODULE_H__
#include <ppapi/cpp/module.h>
#include "ppapi/gles2/gl2ext_ppapi.h"
class CocosPepperModule : public pp::Module
{
public:
CocosPepperModule() : pp::Module() {}
virtual bool Init()
{
return glInitializePPAPI(get_browser_interface()) == GL_TRUE;
}
virtual ~CocosPepperModule() {}
virtual pp::Instance* CreateInstance(PP_Instance instance)
{
return new CocosPepperInstance(instance);
}
};
#endif /* __CC_INSTANCE_H__ */

View File

@ -0,0 +1,50 @@
/****************************************************************************
Copyright (c) 2013 The Chromium Authors
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 __CCPLATFORMDEFINE_H__
#define __CCPLATFORMDEFINE_H__
#include <string.h>
#include <time.h>
#if defined(_USRDLL)
#define CC_DLL __attribute__ ((visibility ("default")))
#else /* use a DLL library */
#define CC_DLL __attribute__ ((visibility ("default")))
#endif
#include <assert.h>
#define CC_ASSERT(cond) assert(cond)
#define CC_UNUSED_PARAM(unusedparam) (void)unusedparam
/* Define NULL pointer value */
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
#endif /* __CCPLATFORMDEFINE_H__*/

View File

@ -0,0 +1,54 @@
/****************************************************************************
Copyright (c) 2013 The Chromium Authors
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 __CC_STD_C_H__
#define __CC_STD_C_H__
#include "platform/CCPlatformMacros.h"
#include <float.h>
#include <math.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <stdint.h>
#ifndef MIN
#define MIN(x,y) (((x) > (y)) ? (y) : (x))
#endif // MIN
#ifndef MAX
#define MAX(x,y) (((x) < (y)) ? (y) : (x))
#endif // MAX
// some function linux do not have
#define tanf tan
#define sqrtf sqrt
#define cosf cos
#define sinf sin
#endif // __CC_STD_C_H__

View File

@ -0,0 +1,24 @@
/****************************************************************************
Copyright (c) 2013 The Chromium Authors
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.
****************************************************************************/
// placeholder

View File

@ -37,7 +37,11 @@ NS_CC_BEGIN
struct CC_DLL cc_timeval
{
#ifdef __native_client__
time_t tv_sec; // seconds
#else
long tv_sec; // seconds
#endif
long tv_usec; // microSeconds
};

View File

@ -14,4 +14,4 @@ endif
include $(PREBUILT_STATIC_LIBRARY)
$(call import-module,cpufeatures)
$(call import-module, android/cpufeatures)

View File

@ -1 +1 @@
8e581cccdac41ebd5f1a9c26b08f02b948560fba
c7e210f8b33a816358feec83a71bfe927820a395

View File

@ -1,197 +1,158 @@
CC = gcc
CXX = g++
TARGET = libcocos2d.so
CCFLAGS = -Wall -fPIC
CXXFLAGS = -Wall -fPIC
VISIBILITY =
TARGET = libcocos2d.so
LIBS =
INCLUDES = -I.. \
INCLUDES += \
-I../platform/third_party/linux/libfreetype2 \
-I../cocoa \
-I../include \
-I../kazmath/include \
-I../../extensions \
-I../../extensions/CCBReader \
-I../../extensions/GUI/CCControlExtension \
-I../../extensions/GUI/CCControlExtension \
-I../../external/chipmunk/include/chipmunk \
-I../../external/chipmunk/include/chipmunk \
-I../../extensions/network \
-I../platform/linux \
-I../platform/third_party/linux/libpng \
-I../platform/third_party/linux/libjpeg \
-I../platform/third_party/linux/libtiff/include \
-I../platform/third_party/linux/libwebp
LBITS := $(shell getconf LONG_BIT)
ifeq ($(LBITS),64)
INCLUDES += -I$(COCOS2DX_PATH)/platform/third_party/linux/include64
else
INCLUDES += -I$(COCOS2DX_PATH)/platform/third_party/linux
endif
DEFINES = -DLINUX
DEFINES += -D__CC_PLATFORM_FILEUTILS_CPP__
DEFINES += -D__CC_PLATFORM_IMAGE_CPP__
DEFINES += -DCC_ENABLE_CHIPMUNK_INTEGRATION
OBJECTS = ../actions/CCAction.o \
../actions/CCActionCamera.o \
../actions/CCActionEase.o \
../actions/CCActionGrid.o \
../actions/CCActionGrid3D.o \
../actions/CCActionInstant.o \
../actions/CCActionInterval.o \
../actions/CCActionManager.o \
../actions/CCActionPageTurn3D.o \
../actions/CCActionProgressTimer.o \
../actions/CCActionTiledGrid.o \
../actions/CCActionCatmullRom.o \
../actions/CCActionTween.o \
../base_nodes/CCAtlasNode.o \
../base_nodes/CCNode.o \
../cocoa/CCAffineTransform.o \
../cocoa/CCAutoreleasePool.o \
../cocoa/CCGeometry.o \
../cocoa/CCNS.o \
../cocoa/CCObject.o \
../cocoa/CCSet.o \
../cocoa/CCZone.o \
../cocoa/CCArray.o \
../cocoa/CCDictionary.o \
../cocoa/CCString.o \
../draw_nodes/CCDrawingPrimitives.o \
../draw_nodes/CCDrawNode.o \
../effects/CCGrabber.o \
../effects/CCGrid.o \
../keypad_dispatcher/CCKeypadDelegate.o \
../keypad_dispatcher/CCKeypadDispatcher.o \
../label_nodes/CCLabelAtlas.o \
../label_nodes/CCLabelBMFont.o \
../label_nodes/CCLabelTTF.o \
../layers_scenes_transitions_nodes/CCLayer.o \
../layers_scenes_transitions_nodes/CCScene.o \
../layers_scenes_transitions_nodes/CCTransition.o \
../layers_scenes_transitions_nodes/CCTransitionPageTurn.o \
../layers_scenes_transitions_nodes/CCTransitionProgress.o \
../menu_nodes/CCMenu.o \
../menu_nodes/CCMenuItem.o \
../misc_nodes/CCMotionStreak.o \
../misc_nodes/CCProgressTimer.o \
../misc_nodes/CCClippingNode.o \
../misc_nodes/CCRenderTexture.o \
../particle_nodes/CCParticleExamples.o \
../particle_nodes/CCParticleSystem.o \
../particle_nodes/CCParticleSystemQuad.o \
../particle_nodes/CCParticleBatchNode.o \
../platform/CCSAXParser.o \
../platform/CCThread.o \
../platform/platform.o \
../platform/CCImageCommonWebp.o \
../platform/CCEGLViewProtocol.o \
../platform/CCFileUtils.o \
../platform/linux/CCStdC.o \
../platform/linux/CCFileUtilsLinux.o \
../platform/linux/CCCommon.o \
../platform/linux/CCApplication.o \
../platform/linux/CCEGLView.o \
../platform/linux/CCImage.o \
../platform/linux/CCDevice.o \
../script_support/CCScriptSupport.o \
../sprite_nodes/CCAnimation.o \
../sprite_nodes/CCAnimationCache.o \
../sprite_nodes/CCSprite.o \
../sprite_nodes/CCSpriteBatchNode.o \
../sprite_nodes/CCSpriteFrame.o \
../sprite_nodes/CCSpriteFrameCache.o \
../support/ccUTF8.o \
../support/CCPointExtension.o \
../support/CCProfiling.o \
../support/CCUserDefault.o \
../support/TransformUtils.o \
../support/base64.o \
../support/ccUtils.o \
../support/CCVertex.o \
../support/CCNotificationCenter.o \
../support/image_support/TGAlib.o \
../support/tinyxml2/tinyxml2.o \
../support/zip_support/ZipUtils.o \
../support/zip_support/ioapi.o \
../support/zip_support/unzip.o \
../support/data_support/ccCArray.o \
../text_input_node/CCIMEDispatcher.o \
../text_input_node/CCTextFieldTTF.o \
../textures/CCTexture2D.o \
../textures/CCTextureAtlas.o \
../textures/CCTextureCache.o \
../textures/CCTexturePVR.o \
../tilemap_parallax_nodes/CCParallaxNode.o \
../tilemap_parallax_nodes/CCTMXLayer.o \
../tilemap_parallax_nodes/CCTMXObjectGroup.o \
../tilemap_parallax_nodes/CCTMXTiledMap.o \
../tilemap_parallax_nodes/CCTMXXMLParser.o \
../tilemap_parallax_nodes/CCTileMapAtlas.o \
../touch_dispatcher/CCTouchDispatcher.o \
../touch_dispatcher/CCTouchHandler.o \
../touch_dispatcher/CCTouch.o \
../shaders/CCGLProgram.o \
../shaders/ccGLStateCache.o \
../shaders/CCShaderCache.o \
../shaders/ccShaders.o \
../kazmath/src/aabb.o \
../kazmath/src/plane.o \
../kazmath/src/vec2.o \
../kazmath/src/mat3.o \
../kazmath/src/quaternion.o \
../kazmath/src/vec3.o \
../kazmath/src/mat4.o \
../kazmath/src/ray2.o \
../kazmath/src/vec4.o \
../kazmath/src/neon_matrix_impl.o \
../kazmath/src/utility.o \
../kazmath/src/GL/mat4stack.o \
../kazmath/src/GL/matrix.o \
../CCCamera.o \
../CCConfiguration.o \
../CCDirector.o \
../CCScheduler.o \
../cocos2d.o
SOURCES = ../actions/CCAction.cpp \
../actions/CCActionCamera.cpp \
../actions/CCActionEase.cpp \
../actions/CCActionGrid.cpp \
../actions/CCActionGrid3D.cpp \
../actions/CCActionInstant.cpp \
../actions/CCActionInterval.cpp \
../actions/CCActionManager.cpp \
../actions/CCActionPageTurn3D.cpp \
../actions/CCActionProgressTimer.cpp \
../actions/CCActionTiledGrid.cpp \
../actions/CCActionCatmullRom.cpp \
../actions/CCActionTween.cpp \
../base_nodes/CCAtlasNode.cpp \
../base_nodes/CCNode.cpp \
../cocoa/CCAffineTransform.cpp \
../cocoa/CCAutoreleasePool.cpp \
../cocoa/CCGeometry.cpp \
../cocoa/CCNS.cpp \
../cocoa/CCObject.cpp \
../cocoa/CCSet.cpp \
../cocoa/CCZone.cpp \
../cocoa/CCArray.cpp \
../cocoa/CCDictionary.cpp \
../cocoa/CCString.cpp \
../draw_nodes/CCDrawingPrimitives.cpp \
../draw_nodes/CCDrawNode.cpp \
../effects/CCGrabber.cpp \
../effects/CCGrid.cpp \
../keypad_dispatcher/CCKeypadDelegate.cpp \
../keypad_dispatcher/CCKeypadDispatcher.cpp \
../label_nodes/CCLabelAtlas.cpp \
../label_nodes/CCLabelBMFont.cpp \
../label_nodes/CCLabelTTF.cpp \
../layers_scenes_transitions_nodes/CCLayer.cpp \
../layers_scenes_transitions_nodes/CCScene.cpp \
../layers_scenes_transitions_nodes/CCTransition.cpp \
../layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp \
../layers_scenes_transitions_nodes/CCTransitionProgress.cpp \
../menu_nodes/CCMenu.cpp \
../menu_nodes/CCMenuItem.cpp \
../misc_nodes/CCMotionStreak.cpp \
../misc_nodes/CCProgressTimer.cpp \
../misc_nodes/CCClippingNode.cpp \
../misc_nodes/CCRenderTexture.cpp \
../particle_nodes/CCParticleExamples.cpp \
../particle_nodes/CCParticleSystem.cpp \
../particle_nodes/CCParticleSystemQuad.cpp \
../particle_nodes/CCParticleBatchNode.cpp \
../platform/CCSAXParser.cpp \
../platform/CCThread.cpp \
../platform/platform.cpp \
../platform/CCImageCommonWebp.cpp \
../platform/CCEGLViewProtocol.cpp \
../platform/CCFileUtils.cpp \
../platform/linux/CCStdC.cpp \
../platform/linux/CCFileUtilsLinux.cpp \
../platform/linux/CCCommon.cpp \
../platform/linux/CCApplication.cpp \
../platform/linux/CCEGLView.cpp \
../platform/linux/CCImage.cpp \
../platform/linux/CCDevice.cpp \
../script_support/CCScriptSupport.cpp \
../sprite_nodes/CCAnimation.cpp \
../sprite_nodes/CCAnimationCache.cpp \
../sprite_nodes/CCSprite.cpp \
../sprite_nodes/CCSpriteBatchNode.cpp \
../sprite_nodes/CCSpriteFrame.cpp \
../sprite_nodes/CCSpriteFrameCache.cpp \
../support/ccUTF8.cpp \
../support/CCPointExtension.cpp \
../support/CCProfiling.cpp \
../support/user_default/CCUserDefault.cpp \
../support/TransformUtils.cpp \
../support/base64.cpp \
../support/ccUtils.cpp \
../support/CCVertex.cpp \
../support/CCNotificationCenter.cpp \
../support/image_support/TGAlib.cpp \
../support/tinyxml2/tinyxml2.cpp \
../support/zip_support/ZipUtils.cpp \
../support/zip_support/ioapi.cpp \
../support/zip_support/unzip.cpp \
../support/data_support/ccCArray.cpp \
../text_input_node/CCIMEDispatcher.cpp \
../text_input_node/CCTextFieldTTF.cpp \
../textures/CCTexture2D.cpp \
../textures/CCTextureAtlas.cpp \
../textures/CCTextureCache.cpp \
../textures/CCTexturePVR.cpp \
../tilemap_parallax_nodes/CCParallaxNode.cpp \
../tilemap_parallax_nodes/CCTMXLayer.cpp \
../tilemap_parallax_nodes/CCTMXObjectGroup.cpp \
../tilemap_parallax_nodes/CCTMXTiledMap.cpp \
../tilemap_parallax_nodes/CCTMXXMLParser.cpp \
../tilemap_parallax_nodes/CCTileMapAtlas.cpp \
../touch_dispatcher/CCTouchDispatcher.cpp \
../touch_dispatcher/CCTouchHandler.cpp \
../touch_dispatcher/CCTouch.cpp \
../shaders/CCGLProgram.cpp \
../shaders/ccGLStateCache.cpp \
../shaders/CCShaderCache.cpp \
../shaders/ccShaders.cpp \
../kazmath/src/aabb.c \
../kazmath/src/plane.c \
../kazmath/src/vec2.c \
../kazmath/src/mat3.c \
../kazmath/src/quaternion.c \
../kazmath/src/vec3.c \
../kazmath/src/mat4.c \
../kazmath/src/ray2.c \
../kazmath/src/vec4.c \
../kazmath/src/neon_matrix_impl.c \
../kazmath/src/utility.c \
../kazmath/src/GL/mat4stack.c \
../kazmath/src/GL/matrix.c \
../CCCamera.cpp \
../CCConfiguration.cpp \
../CCDirector.cpp \
../CCScheduler.cpp \
../cocos2d.cpp
COCOS_ROOT = ../..
ifeq ($(LBITS),64)
STATICLIBS_DIR = ../platform/third_party/linux/libraries/lib64
else
STATICLIBS_DIR = ../platform/third_party/linux/libraries
endif
STATICLIBS =
STATICLIBS = $(STATICLIBS_DIR)/libfreetype.a \
$(STATICLIBS_DIR)/libpng.a \
$(STATICLIBS_DIR)/libjpeg.a \
$(STATICLIBS_DIR)/libtiff.a \
$(STATICLIBS_DIR)/libwebp.a
include cocos2dx.mk
SHAREDLIBS = -lglfw -lcurl -lfontconfig -lGLEW
CXXFLAGS += -Wno-sequence-point
CCFLAGS += -Wno-sequence-point
debug: CCFLAGS += -g3 -O0
debug: CXXFLAGS += -g3 -O0
debug: DEFINES += -DDEBUG -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -DCOCOS2D_DEBUG=1
debug: $(TARGET)
TARGET := $(LIB_DIR)/$(TARGET)
release: CCFLAGS += -O3
release: CXXFLAGS += -O3
release: DEFINES += -DNDEBUG -DCC_ENABLE_CHIPMUNK_INTEGRATION=1
release: $(TARGET)
all: $(TARGET)
####### Build rules
$(TARGET): $(OBJECTS)
$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(OBJECTS) -shared -o $(TARGET) $(SHAREDLIBS) $(STATICLIBS) $(LIBS)
$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -shared -o $@ $(SHAREDLIBS) $(STATICLIBS) $(LIBS)
####### Compile
%.o: %.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@
$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@
%.o: %.c
$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@
clean:
rm -f $(OBJECTS) $(TARGET) core
$(OBJ_DIR)/%.o: ../%.c $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_CC)$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@

View File

@ -0,0 +1,101 @@
all:
CC = gcc
CXX = g++
CCFLAGS += -MMD -Wall -Werror -fPIC
CXXFLAGS += -MMD -Wall -Werror -fPIC
ARFLAGS = cr
DEFINES += -DLINUX
THIS_MAKEFILE := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
ifndef COCOS_ROOT
COCOS_ROOT ?= $(realpath $(dir $(THIS_MAKEFILE))/../..)
else
RPATH_REL = ../..
endif
COCOS_SRC = $(COCOS_ROOT)/cocos2dx
OBJ_DIR ?= obj
LIB_DIR = $(COCOS_SRC)/lib/linux
BIN_DIR = bin
INCLUDES += \
-I$(COCOS_SRC) \
-I$(COCOS_SRC)/cocoa \
-I$(COCOS_SRC)/include \
-I$(COCOS_SRC)/kazmath/include \
-I$(COCOS_SRC)/platform/linux \
-I$(COCOS_SRC)/platform/third_party/linux/libpng \
-I$(COCOS_SRC)/platform/third_party/linux/libjpeg \
-I$(COCOS_SRC)/platform/third_party/linux/libtiff/include \
-I$(COCOS_SRC)/platform/third_party/linux/libwebp
LBITS := $(shell getconf LONG_BIT)
ifeq ($(LBITS),64)
INCLUDES += -I$(COCOS_SRC)/platform/third_party/linux/include64
else
INCLUDES += -I$(COCOS_SRC)/platform/third_party/linux
endif
ifeq ($(DEBUG), 1)
CCFLAGS += -g3 -O0
CXXFLAGS += -g3 -O0
DEFINES += -DDEBUG -DCOCOS2D_DEBUG=1
OBJ_DIR := $(OBJ_DIR)/debug
LIB_DIR := $(LIB_DIR)/debug
BIN_DIR := $(BIN_DIR)/debug
else
CCFLAGS += -O3
CXXFLAGS += -O3
DEFINES += -DNDEBUG
OBJ_DIR := $(OBJ_DIR)/release
LIB_DIR := $(LIB_DIR)/release
BIN_DIR := $(BIN_DIR)/release
endif
ifndef V
LOG_CC = @echo " CC $@";
LOG_CXX = @echo " CXX $@";
LOG_AR = @echo " AR $@";
LOG_LINK = @echo " LINK $@";
endif
OBJECTS := $(SOURCES:.cpp=.o)
OBJECTS := $(OBJECTS:.c=.o)
OBJECTS := $(subst ../,,$(OBJECTS))
OBJECTS := $(subst $(COCOS_ROOT)/,,$(OBJECTS))
OBJECTS := $(addprefix $(OBJ_DIR)/, $(OBJECTS))
DEPS = $(OBJECTS:.o=.d)
CORE_MAKEFILE_LIST := $(MAKEFILE_LIST)
-include $(DEPS)
ifeq ($(LBITS),64)
STATICLIBS_DIR = $(COCOS_SRC)/platform/third_party/linux/libraries/lib64
else
STATICLIBS_DIR = $(COCOS_SRC)/platform/third_party/linux/libraries
endif
STATICLIBS = $(STATICLIBS_DIR)/libfreetype.a \
$(STATICLIBS_DIR)/libpng.a \
$(STATICLIBS_DIR)/libjpeg.a \
$(STATICLIBS_DIR)/libtiff.a \
$(STATICLIBS_DIR)/libwebp.a
ifeq ($(LBITS),64)
FMOD_LIBDIR = $(COCOS_ROOT)/CocosDenshion/third_party/fmod/lib64/api/lib
SHAREDLIBS += -lfmodex64
else
FMOD_LIBDIR = $(COCOS_ROOT)/CocosDenshion/third_party/fmod/api/lib
SHAREDLIBS += -lfmodex
endif
SHAREDLIBS += -lglfw -lGLEW -lfontconfig
SHAREDLIBS += -L$(FMOD_LIBDIR) -Wl,-rpath,$(RPATH_REL)/$(FMOD_LIBDIR)
SHAREDLIBS += -L$(LIB_DIR) -Wl,-rpath,$(RPATH_REL)/$(LIB_DIR)
LIBS = -lrt -lz
clean:
rm -rf $(OBJ_DIR)
rm -f $(TARGET) core
.PHONY: all clean

View File

@ -46,7 +46,8 @@ includepaths
"../script_support"
"../sprite_nodes"
"../support"
"../support/tinyxml2"
"../support/tinyxml2"
"../support/user_default/"
"../text_input_node"
"../textures"
"../tileMap_parallax_nodes"
@ -175,6 +176,11 @@ files
("../support/tinyxml2")
[support/tinyxml2]
"*.h"
"*.cpp"
("../support/user_default")
[support/user_default]
"*.h"
"*.cpp"
("../support/zip_support")

154
cocos2dx/proj.nacl/Makefile Normal file
View File

@ -0,0 +1,154 @@
COCOS_ROOT = ../..
COCOS_SRC_ROOT = $(COCOS_ROOT)/cocos2dx
INCLUDES = \
-I$(COCOS_ROOT)/extensions \
-I$(COCOS_ROOT)/extensions/CCBReader \
-I$(COCOS_ROOT)/extensions/GUI/CCControlExtension \
-I$(COCOS_ROOT)/external/chipmunk/include/chipmunk \
-I$(COCOS_ROOT)/extensions/network \
-I$(NACL_SDK_ROOT)/include \
SOURCES = ../actions/CCAction.cpp \
../actions/CCActionCamera.cpp \
../actions/CCActionEase.cpp \
../actions/CCActionGrid.cpp \
../actions/CCActionGrid3D.cpp \
../actions/CCActionInstant.cpp \
../actions/CCActionInterval.cpp \
../actions/CCActionManager.cpp \
../actions/CCActionPageTurn3D.cpp \
../actions/CCActionProgressTimer.cpp \
../actions/CCActionTiledGrid.cpp \
../actions/CCActionCatmullRom.cpp \
../actions/CCActionTween.cpp \
../base_nodes/CCAtlasNode.cpp \
../base_nodes/CCNode.cpp \
../cocoa/CCAffineTransform.cpp \
../cocoa/CCAutoreleasePool.cpp \
../cocoa/CCGeometry.cpp \
../cocoa/CCNS.cpp \
../cocoa/CCObject.cpp \
../cocoa/CCSet.cpp \
../cocoa/CCZone.cpp \
../cocoa/CCArray.cpp \
../cocoa/CCDictionary.cpp \
../cocoa/CCString.cpp \
../draw_nodes/CCDrawingPrimitives.cpp \
../draw_nodes/CCDrawNode.cpp \
../effects/CCGrabber.cpp \
../effects/CCGrid.cpp \
../keypad_dispatcher/CCKeypadDelegate.cpp \
../keypad_dispatcher/CCKeypadDispatcher.cpp \
../label_nodes/CCLabelAtlas.cpp \
../label_nodes/CCLabelBMFont.cpp \
../label_nodes/CCLabelTTF.cpp \
../layers_scenes_transitions_nodes/CCLayer.cpp \
../layers_scenes_transitions_nodes/CCScene.cpp \
../layers_scenes_transitions_nodes/CCTransition.cpp \
../layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp \
../layers_scenes_transitions_nodes/CCTransitionProgress.cpp \
../menu_nodes/CCMenu.cpp \
../menu_nodes/CCMenuItem.cpp \
../misc_nodes/CCMotionStreak.cpp \
../misc_nodes/CCProgressTimer.cpp \
../misc_nodes/CCClippingNode.cpp \
../misc_nodes/CCRenderTexture.cpp \
../particle_nodes/CCParticleExamples.cpp \
../particle_nodes/CCParticleSystem.cpp \
../particle_nodes/CCParticleSystemQuad.cpp \
../particle_nodes/CCParticleBatchNode.cpp \
../platform/CCSAXParser.cpp \
../platform/CCThread.cpp \
../platform/platform.cpp \
../platform/CCImageCommonWebp.cpp \
../platform/CCEGLViewProtocol.cpp \
../platform/CCFileUtils.cpp \
../platform/nacl/CCCommon.cpp \
../platform/nacl/CCDevice.cpp \
../platform/nacl/CCFileUtilsNaCl.cpp \
../platform/nacl/CCApplication.cpp \
../platform/nacl/CCEGLView.cpp \
../platform/nacl/CCImage.cpp \
../platform/nacl/CCInstance.cpp \
../script_support/CCScriptSupport.cpp \
../sprite_nodes/CCAnimation.cpp \
../sprite_nodes/CCAnimationCache.cpp \
../sprite_nodes/CCSprite.cpp \
../sprite_nodes/CCSpriteBatchNode.cpp \
../sprite_nodes/CCSpriteFrame.cpp \
../sprite_nodes/CCSpriteFrameCache.cpp \
../support/tinyxml2/tinyxml2.cpp \
../support/CCPointExtension.cpp \
../support/CCProfiling.cpp \
../support/user_default/CCUserDefault.cpp \
../support/TransformUtils.cpp \
../support/base64.cpp \
../support/ccUtils.cpp \
../support/ccUTF8.cpp \
../support/CCVertex.cpp \
../support/CCNotificationCenter.cpp \
../support/image_support/TGAlib.cpp \
../support/zip_support/ZipUtils.cpp \
../support/zip_support/ioapi.cpp \
../support/zip_support/unzip.cpp \
../support/data_support/ccCArray.cpp \
../text_input_node/CCIMEDispatcher.cpp \
../text_input_node/CCTextFieldTTF.cpp \
../textures/CCTexture2D.cpp \
../textures/CCTextureAtlas.cpp \
../textures/CCTextureCache.cpp \
../textures/CCTexturePVR.cpp \
../tilemap_parallax_nodes/CCParallaxNode.cpp \
../tilemap_parallax_nodes/CCTMXLayer.cpp \
../tilemap_parallax_nodes/CCTMXObjectGroup.cpp \
../tilemap_parallax_nodes/CCTMXTiledMap.cpp \
../tilemap_parallax_nodes/CCTMXXMLParser.cpp \
../tilemap_parallax_nodes/CCTileMapAtlas.cpp \
../touch_dispatcher/CCTouchDispatcher.cpp \
../touch_dispatcher/CCTouchHandler.cpp \
../touch_dispatcher/CCTouch.cpp \
../shaders/CCGLProgram.cpp \
../shaders/ccGLStateCache.cpp \
../shaders/CCShaderCache.cpp \
../shaders/ccShaders.cpp \
../kazmath/src/aabb.c \
../kazmath/src/plane.c \
../kazmath/src/vec2.c \
../kazmath/src/mat3.c \
../kazmath/src/quaternion.cpp \
../kazmath/src/vec3.cpp \
../kazmath/src/mat4.cpp \
../kazmath/src/ray2.cpp \
../kazmath/src/vec4.cpp \
../kazmath/src/neon_matrix_impl.cpp \
../kazmath/src/utility.cpp \
../kazmath/src/GL/mat4stack.cpp \
../kazmath/src/GL/matrix.cpp \
../CCCamera.cpp \
../CCConfiguration.cpp \
../CCDirector.cpp \
../CCScheduler.cpp \
../cocos2d.cpp
include cocos2dx.mk
CXXFLAGS += -Wno-sequence-point
TARGET = $(LIB_DIR)/libcocos2d.a
DEFINES += -DCC_ENABLE_CHIPMUNK_INTEGRATION
all: $(TARGET)
$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_AR)$(NACL_AR) $(ARFLAGS) $@ $(OBJECTS)
$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_CXX)$(NACL_CXX) -MMD $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@
$(OBJ_DIR)/%.o: ../%.c $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_CC)$(NACL_CC) -MMD $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@

View File

@ -0,0 +1,112 @@
# This makefile is included by each of the cocos2d-x libraries and examples
# when building for Native Client. It defines a set of variables that all
# cocos2dx projects have in common.
all:
NACL_LIBC = newlib
NACL_ARCH ?= x86_64
NACL_AR ?= $(NACL_ARCH)-nacl-ar
NACL_CC ?= $(NACL_ARCH)-nacl-gcc
NACL_CXX ?= $(NACL_ARCH)-nacl-g++
CCFLAGS += -Wall -Werror
CXXFLAGS += -Wall -Werror
ARFLAGS = cr
THIS_MAKEFILE := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
# The top level of the cocos2dx-x source tree. The parent Makefile will
# often define this, but in case is doesn't we can find it relative to
# THIS_MAKEFILE
COCOS_ROOT ?= $(realpath $(dir $(THIS_MAKEFILE))/../..)
COCOS_SRC = $(COCOS_ROOT)/cocos2dx
ifeq ($(NACL_ARCH), i686)
ARCH_DIR=$(NACL_LIBC)_x86_32
else
ARCH_DIR=$(NACL_LIBC)_$(NACL_ARCH)
endif
NACLPORTS_ROOT ?= $(NACL_SDK_ROOT)/ports
NACLPORTS_INCLUDE ?= $(NACLPORTS_ROOT)/include
OUT_DIR ?= obj
OBJ_DIR ?= $(OUT_DIR)/$(NACL_ARCH)
LIB_DIR ?= $(COCOS_ROOT)/lib/nacl/$(ARCH_DIR)
INCLUDES += -I$(COCOS_SRC) \
-I$(COCOS_SRC)/cocoa \
-I$(COCOS_SRC)/include \
-I$(COCOS_SRC)/kazmath/include \
-I$(COCOS_SRC)/platform \
-I$(COCOS_SRC)/platform/nacl \
-I$(NACL_SDK_ROOT)/include \
-isystem $(NACLPORTS_INCLUDE) \
-isystem $(NACLPORTS_INCLUDE)/libxml2
ifeq ($(DEBUG), 1)
BIN_DIR = bin/debug
CCFLAGS += -g3 -O0
CXXFLAGS += -g3 -O0
LIB_DIR := $(LIB_DIR)/Debug
OBJ_DIR := $(OBJ_DIR)/Debug
MULTILIB_SUFFIX := $(ARCH_DIR)/Debug
DEFINES += -DDEBUG -DCOCOS2D_DEBUG=1
else
BIN_DIR = bin/release
CCFLAGS += -O3
CXXFLAGS += -O3
LIB_DIR := $(LIB_DIR)/Release
OBJ_DIR := $(OBJ_DIR)/Release
MULTILIB_SUFFIX := $(ARCH_DIR)/Release
DEFINES += -DNDEBUG
endif
ifndef V
LOG_CC = @echo " CC $@";
LOG_CXX = @echo " CXX $@";
LOG_AR = @echo " AR $@";
LOG_LINK = @echo " LINK $@";
endif
# The default library search path consists of the cocos2dx library path, the
# main nacl sdk library path and the naclports library path.
LDFLAGS += -L$(LIB_DIR)
LDFLAGS += -L$(NACL_SDK_ROOT)/lib/$(MULTILIB_SUFFIX)
LDFLAGS += -L$(NACLPORTS_ROOT)/lib/$(MULTILIB_SUFFIX)
# Some cococs sources use #pragma mark
CCFLAGS += -Wno-unknown-pragmas
CXXFLAGS += -Wno-unknown-pragmas
ifeq ($(NACL_ARCH),arm)
# Don't warn about mangling of 'va_list' on arm builds
CCFLAGS += -Wno-psabi
CXXFLAGS += -Wno-psabi
endif
ifdef NACL_MOUNTS
DEFINES += -DOLD_NACL_MOUNTS
STATICLIBS += -lnacl-mounts
else
STATICLIBS += -lnacl_io
endif
SOUNDLIBS := -lalut -lopenal -lvorbisfile -lvorbis -logg
STATICLIBS += $(SOUNDLIBS) -lfreetype -lxml2 -lwebp -lpng -ljpeg -ltiff -llua
STATICLIBS += -lppapi_gles2 -lppapi -lppapi_cpp -lnosys
SHAREDLIBS += -lpthread -lcocosdenshion -lcocos2d -lz
OBJECTS := $(SOURCES:.cpp=.o)
OBJECTS := $(OBJECTS:.c=.o)
OBJECTS := $(subst ../,,$(OBJECTS))
OBJECTS := $(subst $(COCOS_ROOT)/,,$(OBJECTS))
OBJECTS := $(addprefix $(OBJ_DIR)/, $(OBJECTS))
DEPS = $(OBJECTS:.o=.d)
CORE_MAKEFILE_LIST := $(MAKEFILE_LIST)
-include $(DEPS)
clean:
rm -rf $(OBJ_DIR)
rm -f $(TARGET) core
.PHONY: all clean

View File

@ -214,7 +214,6 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
<ClCompile Include="..\support\CCNotificationCenter.cpp" />
<ClCompile Include="..\support\CCPointExtension.cpp" />
<ClCompile Include="..\support\CCProfiling.cpp" />
<ClCompile Include="..\support\CCUserDefault.cpp" />
<ClCompile Include="..\support\ccUTF8.cpp" />
<ClCompile Include="..\support\ccUtils.cpp" />
<ClCompile Include="..\support\CCVertex.cpp" />
@ -222,6 +221,7 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
<ClCompile Include="..\support\TransformUtils.cpp" />
<ClCompile Include="..\support\data_support\ccCArray.cpp" />
<ClCompile Include="..\support\image_support\TGAlib.cpp" />
<ClCompile Include="..\support\user_default\CCUserDefault.cpp" />
<ClCompile Include="..\support\zip_support\ioapi.cpp" />
<ClCompile Include="..\support\zip_support\unzip.cpp" />
<ClCompile Include="..\support\zip_support\ZipUtils.cpp" />
@ -366,7 +366,6 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
<ClInclude Include="..\support\CCNotificationCenter.h" />
<ClInclude Include="..\support\CCPointExtension.h" />
<ClInclude Include="..\support\CCProfiling.h" />
<ClInclude Include="..\support\CCUserDefault.h" />
<ClInclude Include="..\support\ccUTF8.h" />
<ClInclude Include="..\support\ccUtils.h" />
<ClInclude Include="..\support\CCVertex.h" />
@ -376,6 +375,7 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
<ClInclude Include="..\support\data_support\uthash.h" />
<ClInclude Include="..\support\data_support\utlist.h" />
<ClInclude Include="..\support\image_support\TGAlib.h" />
<ClInclude Include="..\support\user_default\CCUserDefault.h" />
<ClInclude Include="..\support\zip_support\ioapi.h" />
<ClInclude Include="..\support\zip_support\unzip.h" />
<ClInclude Include="..\support\zip_support\ZipUtils.h" />

View File

@ -97,6 +97,9 @@
<Filter Include="support\tinyxml2">
<UniqueIdentifier>{cc25bb83-527d-4218-8d68-ebf963ce7698}</UniqueIdentifier>
</Filter>
<Filter Include="support\user_default">
<UniqueIdentifier>{c45b97e8-fa1f-4e58-8ec5-d46371c2dd26}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\base_nodes\CCAtlasNode.cpp">
@ -291,9 +294,6 @@
<ClCompile Include="..\support\CCProfiling.cpp">
<Filter>support</Filter>
</ClCompile>
<ClCompile Include="..\support\CCUserDefault.cpp">
<Filter>support</Filter>
</ClCompile>
<ClCompile Include="..\support\ccUtils.cpp">
<Filter>support</Filter>
</ClCompile>
@ -446,13 +446,18 @@
<ClCompile Include="..\platform\CCImageCommonWebp.cpp">
<Filter>platform</Filter>
</ClCompile>
<ClCompile Include="..\support\tinyxml2\tinyxml2.cpp" />
<ClCompile Include="..\platform\win32\CCDevice.cpp">
<Filter>platform\win32</Filter>
</ClCompile>
<ClCompile Include="..\support\ccUTF8.cpp">
<Filter>support</Filter>
</ClCompile>
<ClCompile Include="..\support\user_default\CCUserDefault.cpp">
<Filter>support\user_default</Filter>
</ClCompile>
<ClCompile Include="..\support\tinyxml2\tinyxml2.cpp">
<Filter>support\tinyxml2</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\base_nodes\CCAtlasNode.h">
@ -692,9 +697,6 @@
<ClInclude Include="..\support\CCProfiling.h">
<Filter>support</Filter>
</ClInclude>
<ClInclude Include="..\support\CCUserDefault.h">
<Filter>support</Filter>
</ClInclude>
<ClInclude Include="..\support\ccUtils.h">
<Filter>support</Filter>
</ClInclude>
@ -903,9 +905,14 @@
<ClInclude Include="..\platform\win32\CCFileUtilsWin32.h">
<Filter>platform\win32</Filter>
</ClInclude>
<ClInclude Include="..\support\tinyxml2\tinyxml2.h" />
<ClInclude Include="..\support\ccUTF8.h">
<Filter>support</Filter>
</ClInclude>
<ClInclude Include="..\support\user_default\CCUserDefault.h">
<Filter>support\user_default</Filter>
</ClInclude>
<ClInclude Include="..\support\tinyxml2\tinyxml2.h">
<Filter>support\tinyxml2</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -50,7 +50,9 @@ static GLuint s_uCurrentBoundTexture[kCCMaxActiveTexture] = {(GLuint)-1,(GLu
static GLenum s_eBlendingSource = -1;
static GLenum s_eBlendingDest = -1;
static int s_eGLServerState = 0;
#if CC_TEXTURE_ATLAS_USE_VAO
static GLuint s_uVAO = 0;
#endif
#endif // CC_ENABLE_GL_STATE_CACHE
// GL State Cache functions

View File

@ -294,8 +294,8 @@ CCSprite* CCSprite::initWithCGImage(CGImageRef pImage, const char *pszKey)
*/
CCSprite::CCSprite(void)
: m_pobTexture(NULL)
, m_bShouldBeHidden(false)
: m_bShouldBeHidden(false),
m_pobTexture(NULL)
{
}

View File

@ -121,24 +121,6 @@ static const char *const g_utf8_skip = utf8_skip_data;
#define cc_utf8_next_char(p) (char *)((p) + g_utf8_skip[*(unsigned char *)(p)])
/*
* @str: the string to search through.
* @c: the character to find.
*
* Returns the index of the first occurrence of the character, if found. Otherwise -1 is returned.
*
* Return value: the index of the first occurrence of the character if found or -1 otherwise.
* */
static unsigned int cc_utf8_find_char(std::vector<unsigned short> str, unsigned short c)
{
unsigned int len = str.size();
for (unsigned int i = 0; i < len; ++i)
if (str[i] == c) return i;
return -1;
}
/*
* @str: the string to search through.
* @c: the character to not look for.

View File

@ -24,7 +24,9 @@ THE SOFTWARE.
#include "CCUserDefault.h"
#include "platform/CCCommon.h"
#include "platform/CCFileUtils.h"
#include "tinyxml2/tinyxml2.h"
#include "../tinyxml2/tinyxml2.h"
#if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS && CC_PLATFORM != CC_PLATFORM_ANDROID)
// root name of xml
#define USERDEFAULT_ROOT_NAME "userDefaultRoot"
@ -441,3 +443,5 @@ void CCUserDefault::flush()
}
NS_CC_END
#endif // (CC_TARGET_PLATFORM != CC_PLATFORM_IOS && CC_PLATFORM != CC_PLATFORM_ANDROID)

View File

@ -0,0 +1,185 @@
/****************************************************************************
Copyright (c) 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.
****************************************************************************/
#import "CCUserDefault.h"
#import <string>
#import <UIKit/UIKit.h>
#import "platform/CCPlatformConfig.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
NS_CC_BEGIN
using namespace std;
/**
* implements of CCUserDefault
*/
CCUserDefault* CCUserDefault::m_spUserDefault = 0;
string CCUserDefault::m_sFilePath = string("");
bool CCUserDefault::m_sbIsFilePathInitialized = false;
/**
* If the user invoke delete CCUserDefault::sharedUserDefault(), should set m_spUserDefault
* to null to avoid error when he invoke CCUserDefault::sharedUserDefault() later.
*/
CCUserDefault::~CCUserDefault()
{
CC_SAFE_DELETE(m_spUserDefault);
m_spUserDefault = NULL;
}
CCUserDefault::CCUserDefault()
{
m_spUserDefault = NULL;
}
void CCUserDefault::purgeSharedUserDefault()
{
m_spUserDefault = NULL;
}
bool CCUserDefault::getBoolForKey(const char* pKey)
{
return getBoolForKey(pKey, false);
}
bool CCUserDefault::getBoolForKey(const char* pKey, bool defaultValue)
{
return[[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithUTF8String:pKey]];
}
int CCUserDefault::getIntegerForKey(const char* pKey)
{
return getIntegerForKey(pKey, 0);
}
int CCUserDefault::getIntegerForKey(const char* pKey, int defaultValue)
{
return [[NSUserDefaults standardUserDefaults] integerForKey: [NSString stringWithUTF8String:pKey]];
}
float CCUserDefault::getFloatForKey(const char* pKey)
{
return getFloatForKey(pKey, 0);
}
float CCUserDefault::getFloatForKey(const char* pKey, float defaultValue)
{
return [[NSUserDefaults standardUserDefaults] floatForKey: [NSString stringWithUTF8String:pKey]];
}
double CCUserDefault::getDoubleForKey(const char* pKey)
{
return [[NSUserDefaults standardUserDefaults] doubleForKey: [NSString stringWithUTF8String:pKey]];
}
double CCUserDefault::getDoubleForKey(const char* pKey, double defaultValue)
{
return getDoubleForKey(pKey, 0);
}
std::string CCUserDefault::getStringForKey(const char* pKey)
{
return getStringForKey(pKey, "");
}
string CCUserDefault::getStringForKey(const char* pKey, const std::string & defaultValue)
{
NSString *str = [[NSUserDefaults standardUserDefaults] stringForKey:[NSString stringWithUTF8String:pKey]];
if (! str)
{
return defaultValue;
}
else
{
return [str UTF8String];
}
}
void CCUserDefault::setBoolForKey(const char* pKey, bool value)
{
[[NSUserDefaults standardUserDefaults] setBool:value forKey:[NSString stringWithUTF8String:pKey]];
}
void CCUserDefault::setIntegerForKey(const char* pKey, int value)
{
[[NSUserDefaults standardUserDefaults] setInteger:value forKey:[NSString stringWithUTF8String:pKey]];
}
void CCUserDefault::setFloatForKey(const char* pKey, float value)
{
[[NSUserDefaults standardUserDefaults] setFloat:value forKey:[NSString stringWithUTF8String:pKey]];
}
void CCUserDefault::setDoubleForKey(const char* pKey, double value)
{
[[NSUserDefaults standardUserDefaults] setDouble:value forKey:[NSString stringWithUTF8String:pKey]];
}
void CCUserDefault::setStringForKey(const char* pKey, const std::string & value)
{
[[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithUTF8String:value.c_str()] forKey:[NSString stringWithUTF8String:pKey]];
}
CCUserDefault* CCUserDefault::sharedUserDefault()
{
if (! m_spUserDefault)
{
m_spUserDefault = new CCUserDefault();
}
return m_spUserDefault;
}
bool CCUserDefault::isXMLFileExist()
{
return false;
}
void CCUserDefault::initXMLFilePath()
{
}
// create new xml file
bool CCUserDefault::createXMLFile()
{
return false;
}
const string& CCUserDefault::getXMLFilePath()
{
return m_sFilePath;
}
void CCUserDefault::flush()
{
}
NS_CC_END
#endif // (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)

View File

@ -0,0 +1,179 @@
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCUserDefault.h"
#include "platform/CCPlatformConfig.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include "platform/android/jni/JniHelper.h"
// root name of xml
#define USERDEFAULT_ROOT_NAME "userDefaultRoot"
#define XML_FILE_NAME "UserDefault.xml"
using namespace std;
NS_CC_BEGIN
/**
* implements of CCUserDefault
*/
CCUserDefault* CCUserDefault::m_spUserDefault = 0;
string CCUserDefault::m_sFilePath = string("");
bool CCUserDefault::m_sbIsFilePathInitialized = false;
/**
* If the user invoke delete CCUserDefault::sharedUserDefault(), should set m_spUserDefault
* to null to avoid error when he invoke CCUserDefault::sharedUserDefault() later.
*/
CCUserDefault::~CCUserDefault()
{
CC_SAFE_DELETE(m_spUserDefault);
m_spUserDefault = NULL;
}
CCUserDefault::CCUserDefault()
{
m_spUserDefault = NULL;
}
void CCUserDefault::purgeSharedUserDefault()
{
m_spUserDefault = NULL;
}
bool CCUserDefault::getBoolForKey(const char* pKey)
{
return getBoolForKey(pKey, false);
}
bool CCUserDefault::getBoolForKey(const char* pKey, bool defaultValue)
{
}
int CCUserDefault::getIntegerForKey(const char* pKey)
{
return getIntegerForKey(pKey, 0);
}
int CCUserDefault::getIntegerForKey(const char* pKey, int defaultValue)
{
}
float CCUserDefault::getFloatForKey(const char* pKey)
{
return getFloatForKey(pKey, 0.0f);
}
float CCUserDefault::getFloatForKey(const char* pKey, float defaultValue)
{
float ret = (float)getDoubleForKey(pKey, (double)defaultValue);
return ret;
}
double CCUserDefault::getDoubleForKey(const char* pKey)
{
return getDoubleForKey(pKey, 0.0);
}
double CCUserDefault::getDoubleForKey(const char* pKey, double defaultValue)
{
}
std::string CCUserDefault::getStringForKey(const char* pKey)
{
return getStringForKey(pKey, "");
}
string CCUserDefault::getStringForKey(const char* pKey, const std::string & defaultValue)
{
}
void CCUserDefault::setBoolForKey(const char* pKey, bool value)
{
}
void CCUserDefault::setIntegerForKey(const char* pKey, int value)
{
}
void CCUserDefault::setFloatForKey(const char* pKey, float value)
{
}
void CCUserDefault::setDoubleForKey(const char* pKey, double value)
{
}
void CCUserDefault::setStringForKey(const char* pKey, const std::string & value)
{
}
CCUserDefault* CCUserDefault::sharedUserDefault()
{
if (! m_spUserDefault)
{
m_spUserDefault = new CCUserDefault();
}
return m_spUserDefault;
}
bool CCUserDefault::isXMLFileExist()
{
return false;
}
void CCUserDefault::initXMLFilePath()
{
}
// create new xml file
bool CCUserDefault::createXMLFile()
{
return false;
}
const string& CCUserDefault::getXMLFilePath()
{
return m_sFilePath;
}
void CCUserDefault::flush()
{
}
NS_CC_END
#endif // (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)

View File

@ -407,8 +407,7 @@ unsigned char *ZipFile::getFileData(const std::string &fileName, unsigned long *
CC_BREAK_IF(UNZ_OK != nRet);
pBuffer = new unsigned char[fileInfo.uncompressed_size];
int nSize = 0;
nSize = unzReadCurrentFile(m_data->zipFile, pBuffer, fileInfo.uncompressed_size);
int CC_UNUSED nSize = unzReadCurrentFile(m_data->zipFile, pBuffer, fileInfo.uncompressed_size);
CCAssert(nSize == 0 || nSize == (int)fileInfo.uncompressed_size, "the file size is wrong");
if (pSize)

View File

@ -111,7 +111,7 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename,
if ((filename!=NULL) && (mode_fopen != NULL))
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE || CC_TARGET_PLATFORM == CC_PLATFORM_BADA) || (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE || CC_TARGET_PLATFORM == CC_PLATFORM_BADA || CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY || CC_TARGET_PLATFORM == CC_PLATFORM_NACL)
file = NULL;
#else
file = fopen64((const char*)filename, mode_fopen);
@ -147,8 +147,8 @@ static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
{
ZPOS64_T ret;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE || CC_TARGET_PLATFORM == CC_PLATFORM_BADA) || (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY)
ret = NULL;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE || CC_TARGET_PLATFORM == CC_PLATFORM_BADA || CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY || CC_TARGET_PLATFORM == CC_PLATFORM_NACL)
ret = 0;
#else
ret = ftello64((FILE *)stream);
#endif
@ -180,8 +180,10 @@ static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offs
static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE || CC_TARGET_PLATFORM == CC_PLATFORM_BADA || CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY || CC_TARGET_PLATFORM == CC_PLATFORM_NACL)
return -1;
#else
int fseek_origin=0;
long ret;
switch (origin)
{
case ZLIB_FILEFUNC_SEEK_CUR :
@ -195,15 +197,10 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T
break;
default: return -1;
}
ret = 0;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE || CC_TARGET_PLATFORM == CC_PLATFORM_BADA) || (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY)
ret = -1;
#else
if(fseeko64((FILE *)stream, offset, fseek_origin) != 0)
ret = -1;
return -1;
return 0;
#endif
return ret;
}

View File

@ -61,14 +61,14 @@ static CCTexture2DPixelFormat g_defaultAlphaPixelFormat = kCCTexture2DPixelForma
static bool PVRHaveAlphaPremultiplied_ = false;
CCTexture2D::CCTexture2D()
: m_uPixelsWide(0)
: m_bPVRHaveAlphaPremultiplied(true)
, m_uPixelsWide(0)
, m_uPixelsHigh(0)
, m_uName(0)
, m_fMaxS(0.0)
, m_fMaxT(0.0)
, m_bHasPremultipliedAlpha(false)
, m_bHasMipmaps(false)
, m_bPVRHaveAlphaPremultiplied(true)
, m_pShaderProgram(NULL)
{
}
@ -445,6 +445,7 @@ bool CCTexture2D::initWithString(const char *text, const char *fontName, float f
else
{
CCAssert(false, "Not supported alignment format!");
return false;
}
do

View File

@ -225,16 +225,16 @@ typedef struct {
CCTexturePVR::CCTexturePVR()
: m_pPixelFormatInfo(NULL)
, m_uNumberOfMipmaps(0)
: m_uNumberOfMipmaps(0)
, m_uWidth(0)
, m_uHeight(0)
, m_bRetainName(false)
, m_bHasAlpha(false)
, m_uName(0)
, m_eFormat(kCCTexture2DPixelFormat_Default)
, m_bHasAlpha(false)
, m_bHasPremultipliedAlpha(false)
, m_bForcePremultipliedAlpha(false)
, m_bRetainName(false)
, m_eFormat(kCCTexture2DPixelFormat_Default)
, m_pPixelFormatInfo(NULL)
{
}
@ -265,10 +265,10 @@ bool CCTexturePVR::unpackPVRv2Data(unsigned char* data, unsigned int len)
//Make sure that tag is in correct formatting
pvrTag = CC_SWAP_INT32_LITTLE_TO_HOST(header->pvrTag);
if (gPVRTexIdentifier[0] != ((pvrTag >> 0) & 0xff) ||
gPVRTexIdentifier[1] != ((pvrTag >> 8) & 0xff) ||
gPVRTexIdentifier[2] != ((pvrTag >> 16) & 0xff) ||
gPVRTexIdentifier[3] != ((pvrTag >> 24) & 0xff))
if (gPVRTexIdentifier[0] != (char)(((pvrTag >> 0) & 0xff)) ||
gPVRTexIdentifier[1] != (char)(((pvrTag >> 8) & 0xff)) ||
gPVRTexIdentifier[2] != (char)(((pvrTag >> 16) & 0xff)) ||
gPVRTexIdentifier[3] != (char)(((pvrTag >> 24) & 0xff)))
{
return false;
}
@ -415,7 +415,7 @@ bool CCTexturePVR::unpackPVRv3Data(unsigned char* dataPointer, unsigned int data
bool infoValid = false;
for(int i = 0; i < PVR3_MAX_TABLE_ELEMENTS; i++)
for(unsigned int i = 0; i < PVR3_MAX_TABLE_ELEMENTS; i++)
{
if( v3_pixel_formathash[i].pixelFormat == pixelFormat )
{

View File

@ -517,7 +517,7 @@ void CCTMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
// Parse everything automatically
const char* pArray[] = {"name", "type", "width", "height", "gid"};
for( int i = 0; i < sizeof(pArray)/sizeof(pArray[0]); ++i )
for(size_t i = 0; i < sizeof(pArray)/sizeof(pArray[0]); ++i )
{
const char* key = pArray[i];
CCString* obj = new CCString(valueForKey(key, attributeDict));

View File

@ -34,12 +34,18 @@ CCPoint CCTouch::getLocationInView() const
return m_point;
}
// returns the current previous location in screen coordinates
// returns the previous touch location in screen coordinates
CCPoint CCTouch::getPreviousLocationInView() const
{
return m_prevPoint;
}
// returns the start touch location in screen coordinates
CCPoint CCTouch::getStartLocationInView() const
{
return m_startPoint;
}
// returns the current touch location in OpenGL coordinates
CCPoint CCTouch::getLocation() const
{
@ -52,6 +58,12 @@ CCPoint CCTouch::getPreviousLocation() const
return CCDirector::sharedDirector()->convertToGL(m_prevPoint);
}
// returns the start touch location in OpenGL coordinates
CCPoint CCTouch::getStartLocation() const
{
return CCDirector::sharedDirector()->convertToGL(m_startPoint);
}
// returns the delta position between the current location and the previous location in OpenGL coordinates
CCPoint CCTouch::getDelta() const
{

View File

@ -39,19 +39,24 @@ class CC_DLL CCTouch : public CCObject
{
public:
CCTouch()
: m_nId(0)
: m_nId(0),
m_startPointCaptured(false)
{}
/** returns the current touch location in OpenGL coordinates */
CCPoint getLocation() const;
/** returns the previous touch location in OpenGL coordinates */
CCPoint getPreviousLocation() const;
/** returns the start touch location in OpenGL coordinates */
CCPoint getStartLocation() const;
/** returns the delta of 2 current touches locations in screen coordinates */
CCPoint getDelta() const;
/** returns the current touch location in screen coordinates */
CCPoint getLocationInView() const;
/** returns the previous touch location in screen coordinates */
CCPoint getPreviousLocationInView() const;
/** returns the start touch location in screen coordinates */
CCPoint getStartLocationInView() const;
void setTouchInfo(int id, float x, float y)
{
@ -59,6 +64,11 @@ public:
m_prevPoint = m_point;
m_point.x = x;
m_point.y = y;
if (!m_startPointCaptured)
{
m_startPoint = m_point;
m_startPointCaptured = true;
}
}
int getID() const
@ -68,6 +78,8 @@ public:
private:
int m_nId;
bool m_startPointCaptured;
CCPoint m_startPoint;
CCPoint m_point;
CCPoint m_prevPoint;
};

View File

@ -64,13 +64,13 @@ CCBReader::CCBReader(CCNodeLoaderLibrary * pCCNodeLoaderLibrary, CCBMemberVariab
, mCurrentBit(-1)
, mOwner(NULL)
, mActionManager(NULL)
, mAnimatedProps(NULL)
, hasScriptingOwner(false)
, mActionManagers(NULL)
, mAnimatedProps(NULL)
, mOwnerOutletNodes(NULL)
, mNodesWithAnimationManagers(NULL)
, mAnimationManagersForNodes(NULL)
, mOwnerOutletNodes(NULL)
, mOwnerCallbackNodes(NULL)
, hasScriptingOwner(false)
{
this->mCCNodeLoaderLibrary = pCCNodeLoaderLibrary;
this->mCCNodeLoaderLibrary->retain();
@ -87,13 +87,13 @@ CCBReader::CCBReader(CCBReader * pCCBReader)
, mCurrentBit(-1)
, mOwner(NULL)
, mActionManager(NULL)
, mAnimatedProps(NULL)
, hasScriptingOwner(false)
, mActionManagers(NULL)
, mAnimatedProps(NULL)
, mOwnerOutletNodes(NULL)
, mNodesWithAnimationManagers(NULL)
, mAnimationManagersForNodes(NULL)
, mOwnerOutletNodes(NULL)
, mOwnerCallbackNodes(NULL)
, hasScriptingOwner(false)
{
this->mLoadedSpriteSheets = pCCBReader->mLoadedSpriteSheets;
this->mCCNodeLoaderLibrary = pCCBReader->mCCNodeLoaderLibrary;
@ -119,15 +119,14 @@ CCBReader::CCBReader()
, mCurrentBit(-1)
, mOwner(NULL)
, mActionManager(NULL)
, mActionManagers(NULL)
, mCCNodeLoaderLibrary(NULL)
, mCCNodeLoaderListener(NULL)
, mCCBMemberVariableAssigner(NULL)
, mCCBSelectorResolver(NULL)
, mAnimatedProps(NULL)
, hasScriptingOwner(false)
, mActionManagers(NULL)
, mNodesWithAnimationManagers(NULL)
, mAnimationManagersForNodes(NULL)
, hasScriptingOwner(false)
{
init();
}
@ -862,7 +861,7 @@ bool CCBReader::readSequences()
std::string CCBReader::lastPathComponent(const char* pPath) {
std::string path(pPath);
int slashPos = path.find_last_of("/");
size_t slashPos = path.find_last_of("/");
if(slashPos != std::string::npos) {
return path.substr(slashPos + 1, path.length() - slashPos);
}
@ -871,7 +870,7 @@ std::string CCBReader::lastPathComponent(const char* pPath) {
std::string CCBReader::deletePathExtension(const char* pPath) {
std::string path(pPath);
int dotPos = path.find_last_of(".");
size_t dotPos = path.find_last_of(".");
if(dotPos != std::string::npos) {
return path.substr(0, dotPos);
}

View File

@ -196,6 +196,7 @@ private:
std::vector<std::string> mOwnerCallbackNames;
CCArray* mOwnerCallbackNodes;
std::string mCCBRootPath;
bool hasScriptingOwner;
bool init();
public:
CCBReader(CCNodeLoaderLibrary *pCCNodeLoaderLibrary, CCBMemberVariableAssigner *pCCBMemberVariableAssigner = NULL, CCBSelectorResolver *pCCBSelectorResolver = NULL, CCNodeLoaderListener *pCCNodeLoaderListener = NULL);
@ -262,7 +263,6 @@ public:
static float getResolutionScale();
CCNode* readFileWithCleanUp(bool bCleanUp, CCDictionary* am);
bool hasScriptingOwner;
private:
void cleanUpNodeGraph(CCNode *pNode);

View File

@ -97,7 +97,7 @@ CCControl::~CCControl()
//Menu - Events
void CCControl::registerWithTouchDispatcher()
{
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, m_nDefaultTouchPriority, true);
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, getTouchPriority(), true);
}
void CCControl::onEnter()

View File

@ -55,8 +55,8 @@ CCControlButton::CCControlButton()
, m_titleColorDispatchTable(NULL)
, m_titleLabelDispatchTable(NULL)
, m_backgroundSpriteDispatchTable(NULL)
, m_marginH(CCControlButtonMarginLR)
, m_marginV(CCControlButtonMarginTB)
, m_marginH(CCControlButtonMarginLR)
{
}

View File

@ -31,11 +31,11 @@
NS_CC_EXT_BEGIN
CCControlPotentiometer::CCControlPotentiometer()
: m_fValue(0.0f)
: m_pThumbSprite(NULL)
, m_pProgressTimer(NULL)
, m_fValue(0.0f)
, m_fMinimumValue(0.0f)
, m_fMaximumValue(0.0f)
, m_pThumbSprite(NULL)
, m_pProgressTimer(NULL)
{
}

View File

@ -39,17 +39,17 @@ NS_CC_EXT_BEGIN
#define kAutorepeatIncreaseTimeIncrement 12
CCControlStepper::CCControlStepper()
: m_dValue(0.0)
: m_pMinusSprite(NULL)
, m_pPlusSprite(NULL)
, m_pMinusLabel(NULL)
, m_pPlusLabel(NULL)
, m_dValue(0.0)
, m_bContinuous(false)
, m_bAutorepeat(false)
, m_bWraps(false)
, m_dMinimumValue(0.0)
, m_dMaximumValue(0.0)
, m_dStepValue(0.0)
, m_pMinusSprite(NULL)
, m_pPlusSprite(NULL)
, m_pMinusLabel(NULL)
, m_pPlusLabel(NULL)
, m_bTouchInsideFlag(false)
, m_eTouchedPart(kCCControlStepperPartNone)
, m_nAutorepeatCount(0)

View File

@ -232,6 +232,15 @@ void CCEditBox::setPosition(const CCPoint& pos)
}
}
void CCEditBox::setVisible(bool visible)
{
CCControlButton::setVisible(visible);
if (m_pEditBoxImpl != NULL)
{
m_pEditBoxImpl->setVisible(visible);
}
}
void CCEditBox::setContentSize(const CCSize& size)
{
CCControlButton::setContentSize(size);

View File

@ -286,6 +286,7 @@ public:
/* override functions */
virtual void setPosition(const CCPoint& pos);
virtual void setVisible(bool visible);
virtual void setContentSize(const CCSize& size);
virtual void setAnchorPoint(const CCPoint& anchorPoint);
virtual void visit(void);

View File

@ -60,6 +60,7 @@ public:
virtual void closeKeyboard() = 0;
virtual void setPosition(const CCPoint& pos) = 0;
virtual void setVisible(bool visible) = 0;
virtual void setContentSize(const CCSize& size) = 0;
virtual void setAnchorPoint(const CCPoint& anchorPoint) = 0;
virtual void visit(void) = 0;

View File

@ -209,6 +209,11 @@ void CCEditBoxImplAndroid::setPosition(const CCPoint& pos)
}
void CCEditBoxImplAndroid::setVisible(bool visible)
{ // don't need to be implemented on android platform.
}
void CCEditBoxImplAndroid::setContentSize(const CCSize& size)
{ // don't need to be implemented on android platform.

View File

@ -59,6 +59,7 @@ public:
virtual const char* getText(void);
virtual void setPlaceHolder(const char* pText);
virtual void setPosition(const CCPoint& pos);
virtual void setVisible(bool visible);
virtual void setContentSize(const CCSize& size);
virtual void setAnchorPoint(const CCPoint& anchorPoint);
virtual void visit(void);

View File

@ -34,6 +34,7 @@
#include "CCEditBoxImpl.h"
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface CustomUITextField : UITextField
{
@ -89,6 +90,7 @@ public:
virtual const char* getText(void);
virtual void setPlaceHolder(const char* pText);
virtual void setPosition(const CCPoint& pos);
virtual void setVisible(bool visible);
virtual void setContentSize(const CCSize& size);
virtual void setAnchorPoint(const CCPoint& anchorPoint);
virtual void visit(void);

View File

@ -412,6 +412,11 @@ void CCEditBoxImplIOS::setPosition(const CCPoint& pos)
}
}
void CCEditBoxImplIOS::setVisible(bool visible)
{
m_systemControl.textField.hidden = !visible;
}
void CCEditBoxImplIOS::setContentSize(const CCSize& size)
{
m_tContentSize = size;

Some files were not shown because too many files have changed in this diff Show More