diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk
index fa26f984f8..deda4158da 100644
--- a/cocos2dx/Android.mk
+++ b/cocos2dx/Android.mk
@@ -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 \
diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp
index e88c53478d..220e383f31 100644
--- a/cocos2dx/CCDirector.cpp
+++ b/cocos2dx/CCDirector.cpp
@@ -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"
diff --git a/cocos2dx/include/cocos2d.h b/cocos2dx/include/cocos2d.h
index 9736560d52..de8cdcf09f 100755
--- a/cocos2dx/include/cocos2d.h
+++ b/cocos2dx/include/cocos2d.h
@@ -221,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"
diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java
index 6688c1630b..d89cbcba23 100644
--- a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java
+++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java
@@ -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
diff --git a/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp
index 17c9006c2a..5229a9e0ef 100644
--- a/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp
+++ b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp
@@ -183,4 +183,160 @@ extern "C" {
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;
+ }
+
+ const char* getStringForKeyJNI(const char* pKey)
+ {
+ JniMethodInfo t;
+
+ 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);
+ CCString *ret = new CCString(JniHelper::jstring2string(str).c_str());
+ ret->autorelease();
+
+ t.env->DeleteLocalRef(t.classID);
+ t.env->DeleteLocalRef(stringArg);
+ t.env->DeleteLocalRef(str);
+
+ return ret->getCString();
+ }
+
+ return 0;
+ }
+
+ 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);
+ }
+ }
}
diff --git a/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h
index 118b08dde6..884385d7d8 100644
--- a/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h
+++ b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h
@@ -39,6 +39,17 @@ extern "C" {
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 const char* 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
diff --git a/cocos2dx/proj.ios/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2dx/proj.ios/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id
index 376b9db90a..08c377d20c 100644
--- a/cocos2dx/proj.ios/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id
+++ b/cocos2dx/proj.ios/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id
@@ -1 +1 @@
-502d05073a521dc7f534fb881b225d1ad5c8fde6
\ No newline at end of file
+c7e210f8b33a816358feec83a71bfe927820a395
\ No newline at end of file
diff --git a/cocos2dx/proj.marmalade/cocos2dx.mkf b/cocos2dx/proj.marmalade/cocos2dx.mkf
index 7ea9c89697..3ffc26dccb 100644
--- a/cocos2dx/proj.marmalade/cocos2dx.mkf
+++ b/cocos2dx/proj.marmalade/cocos2dx.mkf
@@ -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")
diff --git a/cocos2dx/proj.nacl/Makefile b/cocos2dx/proj.nacl/Makefile
index a59a264802..c7722b765c 100644
--- a/cocos2dx/proj.nacl/Makefile
+++ b/cocos2dx/proj.nacl/Makefile
@@ -81,7 +81,7 @@ SOURCES = ../actions/CCAction.cpp \
../support/tinyxml2/tinyxml2.cpp \
../support/CCPointExtension.cpp \
../support/CCProfiling.cpp \
-../support/CCUserDefault.cpp \
+../support/user_default/CCUserDefault.cpp \
../support/TransformUtils.cpp \
../support/base64.cpp \
../support/ccUtils.cpp \
diff --git a/cocos2dx/proj.win32/cocos2d.vcxproj b/cocos2dx/proj.win32/cocos2d.vcxproj
index e04a6488e5..2dcf7b5514 100644
--- a/cocos2dx/proj.win32/cocos2d.vcxproj
+++ b/cocos2dx/proj.win32/cocos2d.vcxproj
@@ -214,7 +214,6 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
-
@@ -222,6 +221,7 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
+
@@ -366,7 +366,6 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
-
@@ -376,6 +375,7 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
+
diff --git a/cocos2dx/proj.win32/cocos2d.vcxproj.filters b/cocos2dx/proj.win32/cocos2d.vcxproj.filters
index f80eba0d96..1b1dacc681 100644
--- a/cocos2dx/proj.win32/cocos2d.vcxproj.filters
+++ b/cocos2dx/proj.win32/cocos2d.vcxproj.filters
@@ -97,6 +97,9 @@
{cc25bb83-527d-4218-8d68-ebf963ce7698}
+
+ {c45b97e8-fa1f-4e58-8ec5-d46371c2dd26}
+
@@ -291,9 +294,6 @@
support
-
- support
-
support
@@ -446,13 +446,18 @@
platform
-
platform\win32
support
+
+ support\user_default
+
+
+ support\tinyxml2
+
@@ -692,9 +697,6 @@
support
-
- support
-
support
@@ -903,9 +905,14 @@
platform\win32
-
support
+
+ support\user_default
+
+
+ support\tinyxml2
+
\ No newline at end of file
diff --git a/cocos2dx/support/CCUserDefault.cpp b/cocos2dx/support/user_default/CCUserDefault.cpp
similarity index 97%
rename from cocos2dx/support/CCUserDefault.cpp
rename to cocos2dx/support/user_default/CCUserDefault.cpp
index b7af4382e0..e158f0599a 100644
--- a/cocos2dx/support/CCUserDefault.cpp
+++ b/cocos2dx/support/user_default/CCUserDefault.cpp
@@ -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)
diff --git a/cocos2dx/support/CCUserDefault.h b/cocos2dx/support/user_default/CCUserDefault.h
similarity index 100%
rename from cocos2dx/support/CCUserDefault.h
rename to cocos2dx/support/user_default/CCUserDefault.h
diff --git a/cocos2dx/support/user_default/CCUserDefault.mm b/cocos2dx/support/user_default/CCUserDefault.mm
new file mode 100644
index 0000000000..71af2bbeac
--- /dev/null
+++ b/cocos2dx/support/user_default/CCUserDefault.mm
@@ -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
+#import
+#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)
diff --git a/cocos2dx/support/user_default/CCUserDefaultAndroid.cpp b/cocos2dx/support/user_default/CCUserDefaultAndroid.cpp
new file mode 100644
index 0000000000..4f5e8de1b4
--- /dev/null
+++ b/cocos2dx/support/user_default/CCUserDefaultAndroid.cpp
@@ -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)
diff --git a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp
index 4e5ae910e4..c35aa26044 100644
--- a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp
+++ b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp
@@ -1,6 +1,6 @@
#include "CCConfiguration.h"
#include "RenderTextureTest.h"
-#include "testBasic.h"
+#include "../testBasic.h"
// Test #1 by Jason Booth (slipster216)
// Test #3 by David Deaco (ddeaco)
diff --git a/template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist.REMOVED.git-id b/template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist.REMOVED.git-id
index c47deb835d..6b03c2c30c 100644
--- a/template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist.REMOVED.git-id
+++ b/template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist.REMOVED.git-id
@@ -1 +1 @@
-102d501a7f1d29f475195b763dba313301ecdf00
\ No newline at end of file
+86979b53e58b440028511140775967bd9e65d985
\ No newline at end of file
diff --git a/tools/xcode4_template_generator/run_generator.sh b/tools/xcode4_template_generator/run_generator.sh
index 97d4a435ab..0f60334eff 100755
--- a/tools/xcode4_template_generator/run_generator.sh
+++ b/tools/xcode4_template_generator/run_generator.sh
@@ -2,28 +2,28 @@ pushd ../../
echo "generating libcocos2dx"
mkdir -p template/xcode4/lib_cocos2dx.xctemplate
-python ./tools/xcode4_template_generator/template_generator.py --directory cocos2dx --identifier libcocos2dx --prefix libs --exclude "android win32 blackberry linux marmalade CCImage.cpp CCThread.cpp proj.ios CCImageCommon_cpp.h Android.mk mac" > ./template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist
+python ./tools/xcode4_template_generator/template_generator.py --directory cocos2dx --identifier libcocos2dx --prefix libs --exclude "android win32 nacl blackberry linux marmalade CCImage.cpp CCThread.cpp proj.ios CCImageCommon_cpp.h Android.mk mac CCUserDefault.cpp CCUserDefaultAndroid.cpp" > ./template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist
echo "generating libcocosdenshion"
mkdir -p template/xcode4/lib_cocosdenshion.xctemplate
-python ./tools/xcode4_template_generator/template_generator.py --directory CocosDenshion --identifier libcocosdenshion --prefix libs --exclude "android win32 blackberry linux marmalade proj.android proj.win32 proj.blackberry proj.linux proj.marmalade third_party Android.mk mac" > ./template/xcode4/lib_cocosdenshion.xctemplate/TemplateInfo.plist
+python ./tools/xcode4_template_generator/template_generator.py --directory CocosDenshion --identifier libcocosdenshion --prefix libs --exclude "android win32 blackberry linux marmalade proj.android proj.win32 proj.nacl proj.blackberry proj.linux proj.marmalade third_party Android.mk mac" > ./template/xcode4/lib_cocosdenshion.xctemplate/TemplateInfo.plist
echo "generating libbox2d"
mkdir -p template/xcode4/lib_box2d.xctemplate
pushd external
-python ../tools/xcode4_template_generator/template_generator.py --directory Box2D --identifier libbox2d --prefix libs --exclude "proj.android proj.win32 proj.blackberry proj.linux proj.marmalade Android.mk" > ../template/xcode4/lib_box2d.xctemplate/TemplateInfo.plist
+python ../tools/xcode4_template_generator/template_generator.py --directory Box2D --identifier libbox2d --prefix libs --exclude "proj.android proj.win32 proj.nacl proj.blackberry proj.linux proj.marmalade Android.mk" > ../template/xcode4/lib_box2d.xctemplate/TemplateInfo.plist
popd
echo "generating libchipmunk"
mkdir -p template/xcode4/lib_chipmunk.xctemplate
pushd external
-python ../tools/xcode4_template_generator/template_generator.py --directory chipmunk --identifier libchipmunk --prefix libs --exclude "proj.android proj.win32 proj.blackberry proj.linux proj.marmalade Android.mk CMakeFiles Makefile" > ../template/xcode4/lib_chipmunk.xctemplate/TemplateInfo.plist
+python ../tools/xcode4_template_generator/template_generator.py --directory chipmunk --identifier libchipmunk --prefix libs --exclude "proj.android proj.nacl proj.win32 proj.blackberry proj.linux proj.marmalade Android.mk CMakeFiles Makefile" > ../template/xcode4/lib_chipmunk.xctemplate/TemplateInfo.plist
popd
echo "generating liblua"
mkdir -p template/xcode4/lib_lua.xctemplate
pushd scripting
-python ../tools/xcode4_template_generator/template_generator.py --directory lua --identifier liblua --prefix libs --append ../tools/xcode4_template_generator/template_lua_patch.txt --exclude "proj.android proj.win32 proj.blackberry proj.linux proj.marmalade Makefile CMakeFiles" > ../template/xcode4/lib_lua.xctemplate/TemplateInfo.plist
+python ../tools/xcode4_template_generator/template_generator.py --directory lua --identifier liblua --prefix libs --append ../tools/xcode4_template_generator/template_lua_patch.txt --exclude "proj.android proj.win32 proj.blackberry proj.linux proj.nacl proj.marmalade Makefile CMakeFiles" > ../template/xcode4/lib_lua.xctemplate/TemplateInfo.plist
popd
@@ -41,7 +41,7 @@ popd
echo "generating libextensions"
-python ./tools/xcode4_template_generator/template_generator.py --directory extensions --identifier libextensions --prefix libs --exclude "proj.win32 proj.blackberry proj.linux Android.mk CCEditBoxImplAndroid.cpp CCEditBoxImplAndroid.h" > ./template/xcode4/lib_extensions.xctemplate/TemplateInfo.plist
+python ./tools/xcode4_template_generator/template_generator.py --directory extensions --identifier libextensions --prefix libs --exclude "proj.win32 proj.nacl proj.blackberry proj.linux Android.mk CCEditBoxImplAndroid.cpp CCEditBoxImplAndroid.h" > ./template/xcode4/lib_extensions.xctemplate/TemplateInfo.plist
echo "done"