mirror of https://github.com/axmolengine/axmol.git
Merge pull request #3221 from natural-law/develop
Add ProtocolSocial for social SDKs in plugin
This commit is contained in:
commit
aef9d1f4ea
|
@ -0,0 +1,241 @@
|
||||||
|
/****************************************************************************
|
||||||
|
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.
|
||||||
|
****************************************************************************/
|
||||||
|
package org.cocos2dx.plugin;
|
||||||
|
|
||||||
|
import java.util.Hashtable;
|
||||||
|
|
||||||
|
import com.nd.commplatform.NdCallbackListener;
|
||||||
|
import com.nd.commplatform.NdCommplatform;
|
||||||
|
import com.nd.commplatform.NdErrorCode;
|
||||||
|
import com.nd.commplatform.NdMiscCallbackListener.OnLoginProcessListener;
|
||||||
|
import com.nd.commplatform.entry.NdAchieveUnlockInfo;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
public class SocialNd91 implements InterfaceSocial {
|
||||||
|
|
||||||
|
private static final String LOG_TAG = "UserNd91";
|
||||||
|
private static Activity mContext = null;
|
||||||
|
private static SocialNd91 mNd91 = null;
|
||||||
|
private static boolean bDebug = false;
|
||||||
|
private static NdCallbackListener<Object> submitListener = null;
|
||||||
|
private static NdCallbackListener<Object> unlockListener = null;
|
||||||
|
|
||||||
|
protected static void LogE(String msg, Exception e) {
|
||||||
|
Log.e(LOG_TAG, msg, e);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void LogD(String msg) {
|
||||||
|
if (bDebug) {
|
||||||
|
Log.d(LOG_TAG, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SocialNd91(Context context) {
|
||||||
|
mContext = (Activity) context;
|
||||||
|
mNd91 = this;
|
||||||
|
|
||||||
|
submitListener = new NdCallbackListener<Object>(){
|
||||||
|
@Override
|
||||||
|
public void callback(int arg0, Object arg1) {
|
||||||
|
int nRet = SocialWrapper.SOCIAL_SUBMITSCORE_FAILED;
|
||||||
|
String msg = "Unknow Error";
|
||||||
|
switch (arg0) {
|
||||||
|
case NdCommplatform.SCORE_SUBMIT_SUCCESS:
|
||||||
|
nRet = SocialWrapper.SOCIAL_SUBMITSCORE_SUCCESS;
|
||||||
|
msg = "Submit Success";
|
||||||
|
break;
|
||||||
|
case NdCommplatform.SCORE_SAVE_LOCAL:
|
||||||
|
nRet = SocialWrapper.SOCIAL_SUBMITSCORE_FAILED;
|
||||||
|
msg = "Score saved locally";
|
||||||
|
break;
|
||||||
|
case NdCommplatform.LEADERBOARD_NOT_EXIST:
|
||||||
|
nRet = SocialWrapper.SOCIAL_SUBMITSCORE_FAILED;
|
||||||
|
msg = "The leaderboard not exist";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
nRet = SocialWrapper.SOCIAL_SUBMITSCORE_FAILED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
SocialWrapper.onSocialResult(mNd91, nRet, msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
unlockListener = new NdCallbackListener<Object>(){
|
||||||
|
@Override
|
||||||
|
public void callback(int arg0, Object arg1) {
|
||||||
|
int nRet = SocialWrapper.SOCIAL_UNLOCKACH_FAILED;
|
||||||
|
String msg = "Unknow Error";
|
||||||
|
switch (arg0) {
|
||||||
|
case NdErrorCode.ND_COM_PLATFORM_SUCCESS:
|
||||||
|
nRet = SocialWrapper.SOCIAL_UNLOCKACH_SUCCESS;
|
||||||
|
msg = "Unlock Success";
|
||||||
|
break;
|
||||||
|
case NdErrorCode.ND_COM_PLATFORM_ERROR_SERVER_RETURN_ERROR:
|
||||||
|
nRet = SocialWrapper.SOCIAL_UNLOCKACH_FAILED;
|
||||||
|
msg = "Server return error";
|
||||||
|
break;
|
||||||
|
case NdErrorCode.ND_COM_PLATFORM_ERROR_ACHIEVEMENT_NO_EXIST:
|
||||||
|
nRet = SocialWrapper.SOCIAL_UNLOCKACH_FAILED;
|
||||||
|
msg = "Achievement not exist";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
nRet = SocialWrapper.SOCIAL_UNLOCKACH_FAILED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
SocialWrapper.onSocialResult(mNd91, nRet, msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configDeveloperInfo(Hashtable<String, String> cpInfo) {
|
||||||
|
LogD("initDeveloperInfo invoked " + cpInfo.toString());
|
||||||
|
final Hashtable<String, String> curCPInfo = cpInfo;
|
||||||
|
PluginWrapper.runOnMainThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
String appId = curCPInfo.get("Nd91AppId");
|
||||||
|
String appKey = curCPInfo.get("Nd91AppKey");
|
||||||
|
int id = Integer.parseInt(appId);
|
||||||
|
|
||||||
|
String orientation = curCPInfo.get("Nd91Orientation");
|
||||||
|
Nd91Wrapper.initSDK(mContext, id, appKey, orientation);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogE("Developer info is wrong!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void submitScore(String leaderboardID, long score) {
|
||||||
|
final String curID = leaderboardID;
|
||||||
|
final long curScore = score;
|
||||||
|
PluginWrapper.runOnMainThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
NdCommplatform.getInstance().ndSubmitScore(curID, (int) curScore, null, (Activity) mContext, submitListener);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showLeaderboard(String leaderboardID) {
|
||||||
|
final String curID = leaderboardID;
|
||||||
|
PluginWrapper.runOnMainThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (Nd91Wrapper.isLogined()) {
|
||||||
|
NdCommplatform.getInstance().ndOpenLeaderBoard(mContext, curID, 0);
|
||||||
|
} else {
|
||||||
|
Nd91Wrapper.userLogin(mContext, new OnLoginProcessListener() {
|
||||||
|
@Override
|
||||||
|
public void finishLoginProcess(int code) {
|
||||||
|
if (code == NdErrorCode.ND_COM_PLATFORM_SUCCESS) {
|
||||||
|
NdCommplatform.getInstance().ndOpenLeaderBoard(mContext, curID, 0);
|
||||||
|
} else {
|
||||||
|
LogD("User should login first");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unlockAchievement(Hashtable<String, String> achInfo) {
|
||||||
|
final Hashtable<String, String> curInfo = achInfo;
|
||||||
|
PluginWrapper.runOnMainThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
String achID = curInfo.get("AchievementID");
|
||||||
|
if (achID == null || TextUtils.isEmpty(achID))
|
||||||
|
{
|
||||||
|
SocialWrapper.onSocialResult(mNd91, SocialWrapper.SOCIAL_UNLOCKACH_FAILED, "Achievement info error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String displayText = curInfo.get("NDDisplayText");
|
||||||
|
String strScore = curInfo.get("NDScore");
|
||||||
|
long score = Long.parseLong(strScore);
|
||||||
|
NdAchieveUnlockInfo info = new NdAchieveUnlockInfo();
|
||||||
|
info.setAchievementId(achID);
|
||||||
|
info.setCurrentValue(score);
|
||||||
|
info.setDisplayText(displayText);
|
||||||
|
|
||||||
|
NdCommplatform.getInstance().ndUnlockAchievement(info, mContext, unlockListener);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogE("Unknown Error!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showAchievements() {
|
||||||
|
PluginWrapper.runOnMainThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (Nd91Wrapper.isLogined()) {
|
||||||
|
NdCommplatform.getInstance().ndOpenAchievement(mContext, 0);
|
||||||
|
} else {
|
||||||
|
Nd91Wrapper.userLogin(mContext, new OnLoginProcessListener() {
|
||||||
|
@Override
|
||||||
|
public void finishLoginProcess(int code) {
|
||||||
|
if (code == NdErrorCode.ND_COM_PLATFORM_SUCCESS) {
|
||||||
|
NdCommplatform.getInstance().ndOpenAchievement(mContext, 0);
|
||||||
|
} else {
|
||||||
|
LogD("User should login first");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDebugMode(boolean debug) {
|
||||||
|
bDebug = debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSDKVersion() {
|
||||||
|
return Nd91Wrapper.getSDKVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPluginVersion() {
|
||||||
|
return Nd91Wrapper.getPluginVersion();
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,7 +16,6 @@
|
||||||
<meta-data android:name="QHOPENSDK_APPID" android:value="Your app_id" />
|
<meta-data android:name="QHOPENSDK_APPID" android:value="Your app_id" />
|
||||||
<meta-data android:name="QHOPENSDK_APPKEY" android:value="Your app_key" />
|
<meta-data android:name="QHOPENSDK_APPKEY" android:value="Your app_key" />
|
||||||
<meta-data android:name="QHOPENSDK_PRIVATEKEY" android:value="Your app_private_key" />
|
<meta-data android:name="QHOPENSDK_PRIVATEKEY" android:value="Your app_private_key" />
|
||||||
<meta-data android:name="QHOPENSDK_CHANNEL" android:value="Your channel or delete this line" />
|
|
||||||
</applicationCfg>
|
</applicationCfg>
|
||||||
<permissionCfg>
|
<permissionCfg>
|
||||||
<uses-permission android:name="android.permission.SEND_SMS" />
|
<uses-permission android:name="android.permission.SEND_SMS" />
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
/****************************************************************************
|
||||||
|
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.
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef __CCX_PROTOCOL_SOCIAL_H__
|
||||||
|
#define __CCX_PROTOCOL_SOCIAL_H__
|
||||||
|
|
||||||
|
#include "PluginProtocol.h"
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace cocos2d { namespace plugin {
|
||||||
|
|
||||||
|
typedef std::map<std::string, std::string> TSocialDeveloperInfo;
|
||||||
|
typedef std::map<std::string, std::string> TAchievementInfo;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
// code for leaderboard feature
|
||||||
|
SCORE_SUBMIT_SUCCESS = 1,
|
||||||
|
SCORE_SUBMIT_FAILED,
|
||||||
|
|
||||||
|
// code for achievement feature
|
||||||
|
ACH_UNLOCK_SUCCESS,
|
||||||
|
ACH_UNLOCK_FAILED,
|
||||||
|
|
||||||
|
} SocialRetCode;
|
||||||
|
|
||||||
|
class SocialListener
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void onSocialResult(SocialRetCode code, const char* msg) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ProtocolSocial : public PluginProtocol
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ProtocolSocial();
|
||||||
|
virtual ~ProtocolSocial();
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief config the share developer info
|
||||||
|
@param devInfo This parameter is the info of developer,
|
||||||
|
different plugin have different format
|
||||||
|
@warning Must invoke this interface before other interfaces.
|
||||||
|
And invoked only once.
|
||||||
|
*/
|
||||||
|
void configDeveloperInfo(TSocialDeveloperInfo devInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief methods of leaderboard feature
|
||||||
|
*/
|
||||||
|
void submitScore(const char* leadboardID, long score);
|
||||||
|
void showLeaderboard(const char* leaderboardID);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief methods of achievement feature
|
||||||
|
*/
|
||||||
|
void unlockAchievement(TAchievementInfo achInfo);
|
||||||
|
void showAchievements();
|
||||||
|
|
||||||
|
inline void setListener(SocialListener* listener) {
|
||||||
|
_listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline SocialListener* getListener()
|
||||||
|
{
|
||||||
|
return _listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
SocialListener* _listener;
|
||||||
|
};
|
||||||
|
|
||||||
|
}} // namespace cocos2d { namespace plugin {
|
||||||
|
|
||||||
|
#endif /* ----- #ifndef __CCX_PROTOCOL_SOCIAL_H__ ----- */
|
|
@ -29,6 +29,7 @@ THE SOFTWARE.
|
||||||
#include "ProtocolIAP.h"
|
#include "ProtocolIAP.h"
|
||||||
#include "ProtocolShare.h"
|
#include "ProtocolShare.h"
|
||||||
#include "ProtocolUser.h"
|
#include "ProtocolUser.h"
|
||||||
|
#include "ProtocolSocial.h"
|
||||||
|
|
||||||
namespace cocos2d { namespace plugin {
|
namespace cocos2d { namespace plugin {
|
||||||
|
|
||||||
|
@ -38,6 +39,7 @@ enum {
|
||||||
kPluginIAP,
|
kPluginIAP,
|
||||||
kPluginShare,
|
kPluginShare,
|
||||||
kPluginUser,
|
kPluginUser,
|
||||||
|
kPluginSocial,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ANDROID_PLUGIN_PACKAGE_PREFIX "org/cocos2dx/plugin/"
|
#define ANDROID_PLUGIN_PACKAGE_PREFIX "org/cocos2dx/plugin/"
|
||||||
|
@ -134,6 +136,9 @@ PluginProtocol* PluginFactory::createPlugin(const char* name)
|
||||||
case kPluginUser:
|
case kPluginUser:
|
||||||
pRet = new ProtocolUser();
|
pRet = new ProtocolUser();
|
||||||
break;
|
break;
|
||||||
|
case kPluginSocial:
|
||||||
|
pRet = new ProtocolSocial();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,159 @@
|
||||||
|
/****************************************************************************
|
||||||
|
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.
|
||||||
|
****************************************************************************/
|
||||||
|
#include "ProtocolSocial.h"
|
||||||
|
#include "PluginJniHelper.h"
|
||||||
|
#include <android/log.h>
|
||||||
|
#include "PluginUtils.h"
|
||||||
|
#include "PluginJavaData.h"
|
||||||
|
|
||||||
|
namespace cocos2d { namespace plugin {
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
JNIEXPORT void JNICALL Java_org_cocos2dx_plugin_SocialWrapper_nativeOnSocialResult(JNIEnv* env, jobject thiz, jstring className, jint ret, jstring msg)
|
||||||
|
{
|
||||||
|
std::string strMsg = PluginJniHelper::jstring2string(msg);
|
||||||
|
std::string strClassName = PluginJniHelper::jstring2string(className);
|
||||||
|
PluginProtocol* pPlugin = PluginUtils::getPluginPtr(strClassName);
|
||||||
|
PluginUtils::outputLog("ProtocolSocial", "nativeOnSocialResult(), Get plugin ptr : %p", pPlugin);
|
||||||
|
if (pPlugin != NULL)
|
||||||
|
{
|
||||||
|
PluginUtils::outputLog("ProtocolSocial", "nativeOnSocialResult(), Get plugin name : %s", pPlugin->getPluginName());
|
||||||
|
ProtocolSocial* pSocial = dynamic_cast<ProtocolSocial*>(pPlugin);
|
||||||
|
if (pSocial != NULL)
|
||||||
|
{
|
||||||
|
SocialListener* pListener = pSocial->getListener();
|
||||||
|
if (NULL != pListener)
|
||||||
|
{
|
||||||
|
pListener->onSocialResult((SocialRetCode) ret, strMsg.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ProtocolSocial::ProtocolSocial()
|
||||||
|
: _listener(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ProtocolSocial::~ProtocolSocial()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProtocolSocial::configDeveloperInfo(TSocialDeveloperInfo devInfo)
|
||||||
|
{
|
||||||
|
if (devInfo.empty())
|
||||||
|
{
|
||||||
|
PluginUtils::outputLog("ProtocolSocial", "The developer info is empty!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PluginJavaData* pData = PluginUtils::getPluginJavaData(this);
|
||||||
|
PluginJniMethodInfo t;
|
||||||
|
if (PluginJniHelper::getMethodInfo(t
|
||||||
|
, pData->jclassName.c_str()
|
||||||
|
, "configDeveloperInfo"
|
||||||
|
, "(Ljava/util/Hashtable;)V"))
|
||||||
|
{
|
||||||
|
// generate the hashtable from map
|
||||||
|
jobject obj_Map = PluginUtils::createJavaMapObject(&devInfo);
|
||||||
|
|
||||||
|
// invoke java method
|
||||||
|
t.env->CallVoidMethod(pData->jobj, t.methodID, obj_Map);
|
||||||
|
t.env->DeleteLocalRef(obj_Map);
|
||||||
|
t.env->DeleteLocalRef(t.classID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProtocolSocial::submitScore(const char* leadboardID, long score)
|
||||||
|
{
|
||||||
|
PluginJavaData* pData = PluginUtils::getPluginJavaData(this);
|
||||||
|
PluginJniMethodInfo t;
|
||||||
|
if (PluginJniHelper::getMethodInfo(t
|
||||||
|
, pData->jclassName.c_str()
|
||||||
|
, "submitScore"
|
||||||
|
, "(Ljava/lang/String;J)V"))
|
||||||
|
{
|
||||||
|
jstring strID = PluginUtils::getEnv()->NewStringUTF(leadboardID);
|
||||||
|
|
||||||
|
// invoke java method
|
||||||
|
t.env->CallVoidMethod(pData->jobj, t.methodID, strID, score);
|
||||||
|
t.env->DeleteLocalRef(strID);
|
||||||
|
t.env->DeleteLocalRef(t.classID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProtocolSocial::showLeaderboard(const char* leaderboardID)
|
||||||
|
{
|
||||||
|
PluginJavaData* pData = PluginUtils::getPluginJavaData(this);
|
||||||
|
PluginJniMethodInfo t;
|
||||||
|
if (PluginJniHelper::getMethodInfo(t
|
||||||
|
, pData->jclassName.c_str()
|
||||||
|
, "showLeaderboard"
|
||||||
|
, "(Ljava/lang/String;)V"))
|
||||||
|
{
|
||||||
|
jstring strID = PluginUtils::getEnv()->NewStringUTF(leaderboardID);
|
||||||
|
|
||||||
|
// invoke java method
|
||||||
|
t.env->CallVoidMethod(pData->jobj, t.methodID, strID);
|
||||||
|
t.env->DeleteLocalRef(strID);
|
||||||
|
t.env->DeleteLocalRef(t.classID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProtocolSocial::unlockAchievement(TAchievementInfo achInfo)
|
||||||
|
{
|
||||||
|
if (achInfo.empty())
|
||||||
|
{
|
||||||
|
PluginUtils::outputLog("ProtocolSocial", "The achievement info is empty!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PluginJavaData* pData = PluginUtils::getPluginJavaData(this);
|
||||||
|
PluginJniMethodInfo t;
|
||||||
|
if (PluginJniHelper::getMethodInfo(t
|
||||||
|
, pData->jclassName.c_str()
|
||||||
|
, "unlockAchievement"
|
||||||
|
, "(Ljava/util/Hashtable;)V"))
|
||||||
|
{
|
||||||
|
// generate the hashtable from map
|
||||||
|
jobject obj_Map = PluginUtils::createJavaMapObject(&achInfo);
|
||||||
|
|
||||||
|
// invoke java method
|
||||||
|
t.env->CallVoidMethod(pData->jobj, t.methodID, obj_Map);
|
||||||
|
t.env->DeleteLocalRef(obj_Map);
|
||||||
|
t.env->DeleteLocalRef(t.classID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProtocolSocial::showAchievements()
|
||||||
|
{
|
||||||
|
PluginUtils::callJavaFunctionWithName(this, "showAchievements");
|
||||||
|
}
|
||||||
|
|
||||||
|
}} // namespace cocos2d { namespace plugin {
|
|
@ -0,0 +1,36 @@
|
||||||
|
/****************************************************************************
|
||||||
|
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.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
@protocol InterfaceSocial <NSObject>
|
||||||
|
|
||||||
|
- (void) configDeveloperInfo : (NSMutableDictionary*) cpInfo;
|
||||||
|
- (void) submitScore: (NSString*) leaderboardID withScore: (long) score;
|
||||||
|
- (void) showLeaderboard: (NSString*) leaderboardID;
|
||||||
|
- (void) unlockAchievement: (NSMutableDictionary*) achInfo;
|
||||||
|
- (void) showAchievements;
|
||||||
|
- (void) setDebugMode: (BOOL) debug;
|
||||||
|
- (NSString*) getSDKVersion;
|
||||||
|
- (NSString*) getPluginVersion;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,115 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2012-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.
|
||||||
|
****************************************************************************/
|
||||||
|
#include "ProtocolSocial.h"
|
||||||
|
#include "PluginUtilsIOS.h"
|
||||||
|
#import "InterfaceSocial.h"
|
||||||
|
|
||||||
|
namespace cocos2d { namespace plugin {
|
||||||
|
|
||||||
|
ProtocolSocial::ProtocolSocial()
|
||||||
|
: _listener(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ProtocolSocial::~ProtocolSocial()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProtocolSocial::configDeveloperInfo(TSocialDeveloperInfo devInfo)
|
||||||
|
{
|
||||||
|
if (devInfo.empty())
|
||||||
|
{
|
||||||
|
PluginUtilsIOS::outputLog("The developer info is empty for %s!", this->getPluginName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);
|
||||||
|
assert(pData != NULL);
|
||||||
|
|
||||||
|
id ocObj = pData->obj;
|
||||||
|
if ([ocObj conformsToProtocol:@protocol(InterfaceSocial)]) {
|
||||||
|
NSObject<InterfaceSocial>* curObj = ocObj;
|
||||||
|
NSMutableDictionary* pDict = PluginUtilsIOS::createDictFromMap(&devInfo);
|
||||||
|
[curObj configDeveloperInfo:pDict];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProtocolSocial::submitScore(const char* leadboardID, long score)
|
||||||
|
{
|
||||||
|
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);
|
||||||
|
assert(pData != NULL);
|
||||||
|
|
||||||
|
id ocObj = pData->obj;
|
||||||
|
if ([ocObj conformsToProtocol:@protocol(InterfaceSocial)]) {
|
||||||
|
NSObject<InterfaceSocial>* curObj = ocObj;
|
||||||
|
|
||||||
|
NSString* pID = [NSString stringWithUTF8String:leadboardID];
|
||||||
|
[curObj submitScore:pID withScore:score];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProtocolSocial::showLeaderboard(const char* leaderboardID)
|
||||||
|
{
|
||||||
|
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);
|
||||||
|
assert(pData != NULL);
|
||||||
|
|
||||||
|
id ocObj = pData->obj;
|
||||||
|
if ([ocObj conformsToProtocol:@protocol(InterfaceSocial)]) {
|
||||||
|
NSObject<InterfaceSocial>* curObj = ocObj;
|
||||||
|
|
||||||
|
NSString* pID = [NSString stringWithUTF8String:leaderboardID];
|
||||||
|
[curObj showLeaderboard:pID];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProtocolSocial::unlockAchievement(TAchievementInfo achInfo)
|
||||||
|
{
|
||||||
|
if (achInfo.empty())
|
||||||
|
{
|
||||||
|
PluginUtilsIOS::outputLog("ProtocolSocial", "The achievement info is empty!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);
|
||||||
|
assert(pData != NULL);
|
||||||
|
|
||||||
|
id ocObj = pData->obj;
|
||||||
|
if ([ocObj conformsToProtocol:@protocol(InterfaceSocial)]) {
|
||||||
|
NSObject<InterfaceSocial>* curObj = ocObj;
|
||||||
|
|
||||||
|
NSMutableDictionary* pDict = PluginUtilsIOS::createDictFromMap(&achInfo);
|
||||||
|
[curObj unlockAchievement:pDict];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProtocolSocial::showAchievements()
|
||||||
|
{
|
||||||
|
PluginUtilsIOS::callOCFunctionWithName(this, "showAchievements");
|
||||||
|
}
|
||||||
|
|
||||||
|
}} // namespace cocos2d { namespace plugin {
|
|
@ -0,0 +1,42 @@
|
||||||
|
/****************************************************************************
|
||||||
|
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 <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
kSubmitScoreSuccess = 1,
|
||||||
|
kSubmitScoreFailed,
|
||||||
|
|
||||||
|
kUnlockAchiSuccess,
|
||||||
|
kUnlockAchiFailed,
|
||||||
|
} SocialResult;
|
||||||
|
|
||||||
|
@interface SocialWrapper : NSObject
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void) onSocialResult:(id) obj withRet:(SocialResult) ret withMsg:(NSString*) msg;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,50 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2012+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 "SocialWrapper.h"
|
||||||
|
#include "PluginUtilsIOS.h"
|
||||||
|
#include "ProtocolSocial.h"
|
||||||
|
|
||||||
|
using namespace cocos2d::plugin;
|
||||||
|
|
||||||
|
@implementation SocialWrapper
|
||||||
|
|
||||||
|
+ (void) onSocialResult:(id) obj withRet:(SocialResult) ret withMsg:(NSString*) msg
|
||||||
|
{
|
||||||
|
PluginProtocol* pPlugin = PluginUtilsIOS::getPluginPtr(obj);
|
||||||
|
ProtocolSocial* pSocial = dynamic_cast<ProtocolSocial*>(pPlugin);
|
||||||
|
if (pSocial) {
|
||||||
|
SocialListener* pListener = pSocial->getListener();
|
||||||
|
if (NULL != pListener)
|
||||||
|
{
|
||||||
|
const char* chMsg = [msg UTF8String];
|
||||||
|
SocialRetCode cRet = (SocialRetCode) ret;
|
||||||
|
pListener->onSocialResult(cRet, chMsg);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
PluginUtilsIOS::outputLog("Can't find the C++ object of the Social plugin");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -17,6 +17,7 @@ $(addprefix ../../platform/android/, \
|
||||||
ProtocolAds.cpp \
|
ProtocolAds.cpp \
|
||||||
ProtocolShare.cpp \
|
ProtocolShare.cpp \
|
||||||
ProtocolUser.cpp \
|
ProtocolUser.cpp \
|
||||||
|
ProtocolSocial.cpp \
|
||||||
) \
|
) \
|
||||||
../../PluginManager.cpp \
|
../../PluginManager.cpp \
|
||||||
../../PluginParam.cpp
|
../../PluginParam.cpp
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2012-2013 cocos2d-x.org
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
package org.cocos2dx.plugin;
|
||||||
|
|
||||||
|
import java.util.Hashtable;
|
||||||
|
|
||||||
|
public interface InterfaceSocial {
|
||||||
|
public final int PluginType = 6;
|
||||||
|
|
||||||
|
public void configDeveloperInfo(Hashtable<String, String> cpInfo);
|
||||||
|
public void submitScore(String leaderboardID, long score);
|
||||||
|
public void showLeaderboard(String leaderboardID);
|
||||||
|
public void unlockAchievement(Hashtable<String, String> achInfo);
|
||||||
|
public void showAchievements();
|
||||||
|
public void setDebugMode(boolean debug);
|
||||||
|
public String getSDKVersion();
|
||||||
|
public String getPluginVersion();
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2012-2013 cocos2d-x.org
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
package org.cocos2dx.plugin;
|
||||||
|
|
||||||
|
public class SocialWrapper {
|
||||||
|
public static final int SOCIAL_SUBMITSCORE_SUCCESS = 1;
|
||||||
|
public static final int SOCIAL_SUBMITSCORE_FAILED = 2;
|
||||||
|
public static final int SOCIAL_UNLOCKACH_SUCCESS = 3;
|
||||||
|
public static final int SOCIAL_UNLOCKACH_FAILED = 4;
|
||||||
|
|
||||||
|
public static void onSocialResult(InterfaceSocial obj, int ret, String msg) {
|
||||||
|
final int curRet = ret;
|
||||||
|
final String curMsg = msg;
|
||||||
|
final InterfaceSocial curAdapter = obj;
|
||||||
|
PluginWrapper.runOnGLThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
String name = curAdapter.getClass().getName();
|
||||||
|
name = name.replace('.', '/');
|
||||||
|
nativeOnSocialResult(name, curRet, curMsg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
private static native void nativeOnSocialResult(String className, int ret, String msg);
|
||||||
|
}
|
|
@ -21,6 +21,8 @@
|
||||||
FAC2A7FA1777F8C200035D22 /* ShareWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAC2A7F81777F8C200035D22 /* ShareWrapper.mm */; };
|
FAC2A7FA1777F8C200035D22 /* ShareWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAC2A7F81777F8C200035D22 /* ShareWrapper.mm */; };
|
||||||
FAD55520177D1FA900968F54 /* ProtocolUser.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAD5551D177D1FA900968F54 /* ProtocolUser.mm */; };
|
FAD55520177D1FA900968F54 /* ProtocolUser.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAD5551D177D1FA900968F54 /* ProtocolUser.mm */; };
|
||||||
FAD55521177D1FA900968F54 /* UserWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAD5551F177D1FA900968F54 /* UserWrapper.mm */; };
|
FAD55521177D1FA900968F54 /* UserWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAD5551F177D1FA900968F54 /* UserWrapper.mm */; };
|
||||||
|
FADBF89B179E509500F59B1D /* ProtocolSocial.mm in Sources */ = {isa = PBXBuildFile; fileRef = FADBF898179E509500F59B1D /* ProtocolSocial.mm */; };
|
||||||
|
FADBF89C179E509500F59B1D /* SocialWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = FADBF89A179E509500F59B1D /* SocialWrapper.mm */; };
|
||||||
FADC44CA176EABCF00B2D5ED /* AdsWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = FADC44C9176EABCF00B2D5ED /* AdsWrapper.mm */; };
|
FADC44CA176EABCF00B2D5ED /* AdsWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = FADC44C9176EABCF00B2D5ED /* AdsWrapper.mm */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
@ -70,6 +72,11 @@
|
||||||
FAD5551E177D1FA900968F54 /* UserWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserWrapper.h; sourceTree = "<group>"; };
|
FAD5551E177D1FA900968F54 /* UserWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserWrapper.h; sourceTree = "<group>"; };
|
||||||
FAD5551F177D1FA900968F54 /* UserWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UserWrapper.mm; sourceTree = "<group>"; };
|
FAD5551F177D1FA900968F54 /* UserWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UserWrapper.mm; sourceTree = "<group>"; };
|
||||||
FAD55522177D213F00968F54 /* ProtocolUser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProtocolUser.h; sourceTree = "<group>"; };
|
FAD55522177D213F00968F54 /* ProtocolUser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProtocolUser.h; sourceTree = "<group>"; };
|
||||||
|
FADBF896179E504B00F59B1D /* ProtocolSocial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProtocolSocial.h; sourceTree = "<group>"; };
|
||||||
|
FADBF897179E509500F59B1D /* InterfaceSocial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InterfaceSocial.h; sourceTree = "<group>"; };
|
||||||
|
FADBF898179E509500F59B1D /* ProtocolSocial.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProtocolSocial.mm; sourceTree = "<group>"; };
|
||||||
|
FADBF899179E509500F59B1D /* SocialWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocialWrapper.h; sourceTree = "<group>"; };
|
||||||
|
FADBF89A179E509500F59B1D /* SocialWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SocialWrapper.mm; sourceTree = "<group>"; };
|
||||||
FADC44C8176EABCF00B2D5ED /* AdsWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdsWrapper.h; sourceTree = "<group>"; };
|
FADC44C8176EABCF00B2D5ED /* AdsWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdsWrapper.h; sourceTree = "<group>"; };
|
||||||
FADC44C9176EABCF00B2D5ED /* AdsWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AdsWrapper.mm; sourceTree = "<group>"; };
|
FADC44C9176EABCF00B2D5ED /* AdsWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AdsWrapper.mm; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
@ -119,6 +126,7 @@
|
||||||
FA09A336168ADC05008C1C7B /* include */ = {
|
FA09A336168ADC05008C1C7B /* include */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
FADBF896179E504B00F59B1D /* ProtocolSocial.h */,
|
||||||
FAD55522177D213F00968F54 /* ProtocolUser.h */,
|
FAD55522177D213F00968F54 /* ProtocolUser.h */,
|
||||||
FAC2A7F41777F88700035D22 /* ProtocolShare.h */,
|
FAC2A7F41777F88700035D22 /* ProtocolShare.h */,
|
||||||
FAB6DF931755D7D100C90D89 /* PluginFactory.h */,
|
FAB6DF931755D7D100C90D89 /* PluginFactory.h */,
|
||||||
|
@ -136,6 +144,10 @@
|
||||||
FA0CB8B5168D3CC200E36B11 /* ios */ = {
|
FA0CB8B5168D3CC200E36B11 /* ios */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
FADBF897179E509500F59B1D /* InterfaceSocial.h */,
|
||||||
|
FADBF898179E509500F59B1D /* ProtocolSocial.mm */,
|
||||||
|
FADBF899179E509500F59B1D /* SocialWrapper.h */,
|
||||||
|
FADBF89A179E509500F59B1D /* SocialWrapper.mm */,
|
||||||
FAD5551C177D1FA900968F54 /* InterfaceUser.h */,
|
FAD5551C177D1FA900968F54 /* InterfaceUser.h */,
|
||||||
FAD5551D177D1FA900968F54 /* ProtocolUser.mm */,
|
FAD5551D177D1FA900968F54 /* ProtocolUser.mm */,
|
||||||
FAD5551E177D1FA900968F54 /* UserWrapper.h */,
|
FAD5551E177D1FA900968F54 /* UserWrapper.h */,
|
||||||
|
@ -226,6 +238,8 @@
|
||||||
FAC2A7FA1777F8C200035D22 /* ShareWrapper.mm in Sources */,
|
FAC2A7FA1777F8C200035D22 /* ShareWrapper.mm in Sources */,
|
||||||
FAD55520177D1FA900968F54 /* ProtocolUser.mm in Sources */,
|
FAD55520177D1FA900968F54 /* ProtocolUser.mm in Sources */,
|
||||||
FAD55521177D1FA900968F54 /* UserWrapper.mm in Sources */,
|
FAD55521177D1FA900968F54 /* UserWrapper.mm in Sources */,
|
||||||
|
FADBF89B179E509500F59B1D /* ProtocolSocial.mm in Sources */,
|
||||||
|
FADBF89C179E509500F59B1D /* SocialWrapper.mm in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "TestIAPScene.h"
|
#include "TestIAPScene.h"
|
||||||
#include "TestIAPOnlineScene.h"
|
#include "TestIAPOnlineScene.h"
|
||||||
#include "TestUserScene.h"
|
#include "TestUserScene.h"
|
||||||
|
#include "TestSocialScene.h"
|
||||||
|
|
||||||
USING_NS_CC;
|
USING_NS_CC;
|
||||||
|
|
||||||
|
@ -16,6 +17,7 @@ std::string g_testCases[] = {
|
||||||
"Test IAP",
|
"Test IAP",
|
||||||
"Test IAP Online",
|
"Test IAP Online",
|
||||||
"Test User",
|
"Test User",
|
||||||
|
"Test Social",
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -57,22 +59,22 @@ bool HelloWorld::init()
|
||||||
"CloseSelected.png",
|
"CloseSelected.png",
|
||||||
CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
|
CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
|
||||||
|
|
||||||
pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
|
pCloseItem->setPosition(Point(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
|
||||||
origin.y + pCloseItem->getContentSize().height/2));
|
origin.y + pCloseItem->getContentSize().height/2));
|
||||||
|
|
||||||
// create menu, it's an autorelease object
|
// create menu, it's an autorelease object
|
||||||
Menu* pMenu = Menu::create(pCloseItem, NULL);
|
Menu* pMenu = Menu::create(pCloseItem, NULL);
|
||||||
pMenu->setPosition(PointZero);
|
pMenu->setPosition(Point::ZERO);
|
||||||
this->addChild(pMenu, 1);
|
this->addChild(pMenu, 1);
|
||||||
|
|
||||||
Point beginPos = ccp(origin.x + visibleSize.width / 2, origin.y + visibleSize.height - 50);
|
Point beginPos = Point(origin.x + visibleSize.width / 2, origin.y + visibleSize.height - 50);
|
||||||
float step = 60.0f;
|
float step = 60.0f;
|
||||||
int nCaseCount = sizeof(g_testCases) / sizeof(std::string);
|
int nCaseCount = sizeof(g_testCases) / sizeof(std::string);
|
||||||
for (int i = 0; i < nCaseCount; ++i) {
|
for (int i = 0; i < nCaseCount; ++i) {
|
||||||
std::string caseName = g_testCases[i];
|
std::string caseName = g_testCases[i];
|
||||||
MenuItemFont *pItem = MenuItemFont::create(caseName.c_str(), CC_CALLBACK_1(HelloWorld::menuCallback, this));
|
MenuItemFont *pItem = MenuItemFont::create(caseName.c_str(), CC_CALLBACK_1(HelloWorld::menuCallback, this));
|
||||||
pItem->setTag(i);
|
pItem->setTag(i);
|
||||||
pItem->setPosition(ccp(beginPos.x, beginPos.y - i * step));
|
pItem->setPosition(Point(beginPos.x, beginPos.y - i * step));
|
||||||
pMenu->addChild(pItem);
|
pMenu->addChild(pItem);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -101,6 +103,8 @@ void HelloWorld::menuCallback(Object* pSender)
|
||||||
case 5:
|
case 5:
|
||||||
newScene = TestUser::scene();
|
newScene = TestUser::scene();
|
||||||
break;
|
break;
|
||||||
|
case 6:
|
||||||
|
newScene = TestSocial::scene();
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ bool TestAds::init()
|
||||||
|
|
||||||
// create menu, it's an autorelease object
|
// create menu, it's an autorelease object
|
||||||
Menu* pMenu = Menu::create(pBackItem, NULL);
|
Menu* pMenu = Menu::create(pBackItem, NULL);
|
||||||
pMenu->setPosition( PointZero );
|
pMenu->setPosition( Point::ZERO );
|
||||||
|
|
||||||
LabelTTF* label1 = LabelTTF::create("ShowAds", "Arial", 24);
|
LabelTTF* label1 = LabelTTF::create("ShowAds", "Arial", 24);
|
||||||
MenuItemLabel* pItemShow = MenuItemLabel::create(label1, CC_CALLBACK_1(TestAds::testShow, this));
|
MenuItemLabel* pItemShow = MenuItemLabel::create(label1, CC_CALLBACK_1(TestAds::testShow, this));
|
||||||
|
|
|
@ -102,7 +102,7 @@ bool TestAnalytics::init()
|
||||||
|
|
||||||
// create menu, it's an autorelease object
|
// create menu, it's an autorelease object
|
||||||
Menu* pMenu = Menu::create(pBackItem, NULL);
|
Menu* pMenu = Menu::create(pBackItem, NULL);
|
||||||
pMenu->setPosition( PointZero );
|
pMenu->setPosition( Point::ZERO );
|
||||||
this->addChild(pMenu, 1);
|
this->addChild(pMenu, 1);
|
||||||
|
|
||||||
float yPos = 0;
|
float yPos = 0;
|
||||||
|
|
|
@ -87,7 +87,7 @@ bool TestIAP::init()
|
||||||
|
|
||||||
// create menu, it's an autorelease object
|
// create menu, it's an autorelease object
|
||||||
Menu* pMenu = Menu::create(pBackItem, NULL);
|
Menu* pMenu = Menu::create(pBackItem, NULL);
|
||||||
pMenu->setPosition( PointZero );
|
pMenu->setPosition( Point::ZERO );
|
||||||
this->addChild(pMenu, 1);
|
this->addChild(pMenu, 1);
|
||||||
|
|
||||||
Point posStep = ccp(220, -150);
|
Point posStep = ccp(220, -150);
|
||||||
|
|
|
@ -81,21 +81,21 @@ bool TestIAPOnline::init()
|
||||||
// you may modify it.
|
// you may modify it.
|
||||||
|
|
||||||
EGLView* pEGLView = EGLView::getInstance();
|
EGLView* pEGLView = EGLView::getInstance();
|
||||||
Point posBR = ccp(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width, pEGLView->getVisibleOrigin().y);
|
Point posBR = Point(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width, pEGLView->getVisibleOrigin().y);
|
||||||
Point posTL = ccp(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height);
|
Point posTL = Point(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height);
|
||||||
|
|
||||||
// add a "close" icon to exit the progress. it's an autorelease object
|
// add a "close" icon to exit the progress. it's an autorelease object
|
||||||
MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestIAPOnline::menuBackCallback, this));
|
MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestIAPOnline::menuBackCallback, this));
|
||||||
Size backSize = pBackItem->getContentSize();
|
Size backSize = pBackItem->getContentSize();
|
||||||
pBackItem->setPosition(ccpAdd(posBR, ccp(- backSize.width / 2, backSize.height / 2)));
|
pBackItem->setPosition(posBR + Point(- backSize.width / 2, backSize.height / 2));
|
||||||
|
|
||||||
// create menu, it's an autorelease object
|
// create menu, it's an autorelease object
|
||||||
Menu* pMenu = Menu::create(pBackItem, NULL);
|
Menu* pMenu = Menu::create(pBackItem, NULL);
|
||||||
pMenu->setPosition( PointZero );
|
pMenu->setPosition( Point::ZERO );
|
||||||
this->addChild(pMenu, 1);
|
this->addChild(pMenu, 1);
|
||||||
|
|
||||||
Point posStep = ccp(220, -150);
|
Point posStep = Point(220, -150);
|
||||||
Point beginPos = ccpAdd(posTL, ccpMult(posStep, 0.5f));
|
Point beginPos = posTL + (posStep * 0.5f);
|
||||||
int line = 0;
|
int line = 0;
|
||||||
int row = 0;
|
int row = 0;
|
||||||
for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) {
|
for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) {
|
||||||
|
@ -103,13 +103,13 @@ bool TestIAPOnline::init()
|
||||||
CC_CALLBACK_1(TestIAPOnline::eventMenuCallback, this));
|
CC_CALLBACK_1(TestIAPOnline::eventMenuCallback, this));
|
||||||
pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag);
|
pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag);
|
||||||
|
|
||||||
Point pos = ccpAdd(beginPos, ccp(posStep.x * row, posStep.y * line));
|
Point pos = beginPos + Point(posStep.x * row, posStep.y * line);
|
||||||
Size itemSize = pMenuItem->getContentSize();
|
Size itemSize = pMenuItem->getContentSize();
|
||||||
if ((pos.x + itemSize.width / 2) > posBR.x)
|
if ((pos.x + itemSize.width / 2) > posBR.x)
|
||||||
{
|
{
|
||||||
line += 1;
|
line += 1;
|
||||||
row = 0;
|
row = 0;
|
||||||
pos = ccpAdd(beginPos, ccp(posStep.x * row, posStep.y * line));
|
pos = beginPos + Point(posStep.x * row, posStep.y * line);
|
||||||
}
|
}
|
||||||
row += 1;
|
row += 1;
|
||||||
pMenuItem->setPosition(pos);
|
pMenuItem->setPosition(pos);
|
||||||
|
|
|
@ -77,34 +77,34 @@ bool TestShare::init()
|
||||||
// you may modify it.
|
// you may modify it.
|
||||||
|
|
||||||
EGLView* pEGLView = EGLView::getInstance();
|
EGLView* pEGLView = EGLView::getInstance();
|
||||||
Point posBR = ccp(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width, pEGLView->getVisibleOrigin().y);
|
Point posBR = Point(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width, pEGLView->getVisibleOrigin().y);
|
||||||
Point posTL = ccp(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height);
|
Point posTL = Point(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height);
|
||||||
|
|
||||||
// add a "close" icon to exit the progress. it's an autorelease object
|
// add a "close" icon to exit the progress. it's an autorelease object
|
||||||
MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestShare::menuBackCallback, this));
|
MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestShare::menuBackCallback, this));
|
||||||
Size backSize = pBackItem->getContentSize();
|
Size backSize = pBackItem->getContentSize();
|
||||||
pBackItem->setPosition(ccpAdd(posBR, ccp(- backSize.width / 2, backSize.height / 2)));
|
pBackItem->setPosition(posBR + Point(- backSize.width / 2, backSize.height / 2));
|
||||||
|
|
||||||
// create menu, it's an autorelease object
|
// create menu, it's an autorelease object
|
||||||
Menu* pMenu = Menu::create(pBackItem, NULL);
|
Menu* pMenu = Menu::create(pBackItem, NULL);
|
||||||
pMenu->setPosition( PointZero );
|
pMenu->setPosition( Point::ZERO );
|
||||||
this->addChild(pMenu, 1);
|
this->addChild(pMenu, 1);
|
||||||
|
|
||||||
Point posStep = ccp(150, -150);
|
Point posStep = Point(150, -150);
|
||||||
Point beginPos = ccpAdd(posTL, ccpMult(posStep, 0.5f));
|
Point beginPos = posTL + (posStep * 0.5f);
|
||||||
int line = 0;
|
int line = 0;
|
||||||
int row = 0;
|
int row = 0;
|
||||||
for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) {
|
for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) {
|
||||||
MenuItemImage* pMenuItem = MenuItemImage::create(s_EventMenuItem[i].id.c_str(), s_EventMenuItem[i].id.c_str(), CC_CALLBACK_1(TestShare::eventMenuCallback, this));
|
MenuItemImage* pMenuItem = MenuItemImage::create(s_EventMenuItem[i].id.c_str(), s_EventMenuItem[i].id.c_str(), CC_CALLBACK_1(TestShare::eventMenuCallback, this));
|
||||||
pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag);
|
pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag);
|
||||||
|
|
||||||
Point pos = ccpAdd(beginPos, ccp(posStep.x * row, posStep.y * line));
|
Point pos = beginPos + Point(posStep.x * row, posStep.y * line);
|
||||||
Size itemSize = pMenuItem->getContentSize();
|
Size itemSize = pMenuItem->getContentSize();
|
||||||
if ((pos.x + itemSize.width / 2) > posBR.x)
|
if ((pos.x + itemSize.width / 2) > posBR.x)
|
||||||
{
|
{
|
||||||
line += 1;
|
line += 1;
|
||||||
row = 0;
|
row = 0;
|
||||||
pos = ccpAdd(beginPos, ccp(posStep.x * row, posStep.y * line));
|
pos = beginPos + Point(posStep.x * row, posStep.y * line);
|
||||||
}
|
}
|
||||||
row += 1;
|
row += 1;
|
||||||
pMenuItem->setPosition(pos);
|
pMenuItem->setPosition(pos);
|
||||||
|
|
|
@ -0,0 +1,170 @@
|
||||||
|
/****************************************************************************
|
||||||
|
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.
|
||||||
|
****************************************************************************/
|
||||||
|
#include "MySocialManager.h"
|
||||||
|
#include "PluginManager.h"
|
||||||
|
#include "cocos2d.h"
|
||||||
|
|
||||||
|
using namespace cocos2d::plugin;
|
||||||
|
using namespace cocos2d;
|
||||||
|
|
||||||
|
MySocialManager* MySocialManager::s_pManager = NULL;
|
||||||
|
|
||||||
|
MySocialManager::MySocialManager()
|
||||||
|
: _pNd91(NULL)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
MySocialManager::~MySocialManager()
|
||||||
|
{
|
||||||
|
unloadPlugins();
|
||||||
|
}
|
||||||
|
|
||||||
|
MySocialManager* MySocialManager::sharedManager()
|
||||||
|
{
|
||||||
|
if (s_pManager == NULL) {
|
||||||
|
s_pManager = new MySocialManager();
|
||||||
|
}
|
||||||
|
return s_pManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MySocialManager::purgeManager()
|
||||||
|
{
|
||||||
|
if (s_pManager)
|
||||||
|
{
|
||||||
|
delete s_pManager;
|
||||||
|
s_pManager = NULL;
|
||||||
|
}
|
||||||
|
PluginManager::end();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MySocialManager::loadPlugins()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
_pNd91 = dynamic_cast<ProtocolSocial*>(PluginManager::getInstance()->loadPlugin("SocialNd91"));
|
||||||
|
if (NULL != _pNd91)
|
||||||
|
{
|
||||||
|
TSocialDeveloperInfo pNdInfo;
|
||||||
|
pNdInfo["Nd91AppId"] = "100010";
|
||||||
|
pNdInfo["Nd91AppKey"] = "C28454605B9312157C2F76F27A9BCA2349434E546A6E9C75";
|
||||||
|
pNdInfo["Nd91Orientation"] = "landscape";
|
||||||
|
if (pNdInfo.empty()) {
|
||||||
|
char msg[256] = { 0 };
|
||||||
|
sprintf(msg, "Developer info is empty. PLZ fill your Nd91 info in %s(nearby line %d)", __FILE__, __LINE__);
|
||||||
|
MessageBox(msg, "Nd91 Warning");
|
||||||
|
}
|
||||||
|
_pNd91->configDeveloperInfo(pNdInfo);
|
||||||
|
_pNd91->setDebugMode(true);
|
||||||
|
_pNd91->setListener(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MySocialManager::submitScore(MySocialMode mode, const char* leaderboardID, long score)
|
||||||
|
{
|
||||||
|
ProtocolSocial* pSocial = NULL;
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case eNd91:
|
||||||
|
pSocial = _pNd91;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL != pSocial)
|
||||||
|
{
|
||||||
|
pSocial->submitScore(leaderboardID, score);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MySocialManager::showLeaderboard(MySocialMode mode, const char* leaderboardID)
|
||||||
|
{
|
||||||
|
ProtocolSocial* pSocial = NULL;
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case eNd91:
|
||||||
|
pSocial = _pNd91;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL != pSocial)
|
||||||
|
{
|
||||||
|
pSocial->showLeaderboard(leaderboardID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MySocialManager::unlockAchievement(MySocialMode mode, TAchievementInfo info)
|
||||||
|
{
|
||||||
|
ProtocolSocial* pSocial = NULL;
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case eNd91:
|
||||||
|
pSocial = _pNd91;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL != pSocial)
|
||||||
|
{
|
||||||
|
pSocial->unlockAchievement(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MySocialManager::showAchievement(MySocialMode mode)
|
||||||
|
{
|
||||||
|
ProtocolSocial* pSocial = NULL;
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case eNd91:
|
||||||
|
pSocial = _pNd91;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL != pSocial)
|
||||||
|
{
|
||||||
|
pSocial->showAchievements();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MySocialManager::unloadPlugins()
|
||||||
|
{
|
||||||
|
if (_pNd91)
|
||||||
|
{
|
||||||
|
PluginManager::getInstance()->unloadPlugin("SocialNd91");
|
||||||
|
_pNd91 = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MySocialManager::onSocialResult(SocialRetCode code, const char* msg)
|
||||||
|
{
|
||||||
|
char socialStatus[1024] = { 0 };
|
||||||
|
sprintf(socialStatus, "Social code %d", code);
|
||||||
|
MessageBox(msg, socialStatus);
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
/****************************************************************************
|
||||||
|
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.
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef __MY_SOCIAL_MANAGER_H__
|
||||||
|
#define __MY_SOCIAL_MANAGER_H__
|
||||||
|
|
||||||
|
#include "ProtocolSocial.h"
|
||||||
|
|
||||||
|
class MySocialManager : public cocos2d::plugin::SocialListener
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static MySocialManager* sharedManager();
|
||||||
|
static void purgeManager();
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
eNoneMode = 0,
|
||||||
|
eNd91,
|
||||||
|
} MySocialMode;
|
||||||
|
|
||||||
|
void unloadPlugins();
|
||||||
|
void loadPlugins();
|
||||||
|
|
||||||
|
void submitScore(MySocialMode mode, const char* leaderboardID, long score);
|
||||||
|
void showLeaderboard(MySocialMode mode, const char* leaderboardID);
|
||||||
|
void unlockAchievement(MySocialMode mode, cocos2d::plugin::TAchievementInfo info);
|
||||||
|
void showAchievement(MySocialMode mode);
|
||||||
|
|
||||||
|
virtual void onSocialResult(cocos2d::plugin::SocialRetCode code, const char* msg);
|
||||||
|
|
||||||
|
private:
|
||||||
|
MySocialManager();
|
||||||
|
virtual ~MySocialManager();
|
||||||
|
|
||||||
|
static MySocialManager* s_pManager;
|
||||||
|
|
||||||
|
cocos2d::plugin::ProtocolSocial* _pNd91;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __MY_SOCIAL_MANAGER_H__
|
|
@ -0,0 +1,152 @@
|
||||||
|
/****************************************************************************
|
||||||
|
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.
|
||||||
|
****************************************************************************/
|
||||||
|
#include "TestSocialScene.h"
|
||||||
|
#include "PluginManager.h"
|
||||||
|
#include "AppDelegate.h"
|
||||||
|
#include "MySocialManager.h"
|
||||||
|
#include "HelloWorldScene.h"
|
||||||
|
|
||||||
|
using namespace cocos2d;
|
||||||
|
using namespace cocos2d::plugin;
|
||||||
|
|
||||||
|
const std::string s_aTestCases[] = {
|
||||||
|
"Nd91",
|
||||||
|
};
|
||||||
|
|
||||||
|
Scene* TestSocial::scene()
|
||||||
|
{
|
||||||
|
// 'scene' is an autorelease object
|
||||||
|
Scene *scene = Scene::create();
|
||||||
|
|
||||||
|
// 'layer' is an autorelease object
|
||||||
|
TestSocial *layer = TestSocial::create();
|
||||||
|
|
||||||
|
// add layer as a child to scene
|
||||||
|
scene->addChild(layer);
|
||||||
|
|
||||||
|
// return the scene
|
||||||
|
return scene;
|
||||||
|
}
|
||||||
|
|
||||||
|
// on "init" you need to initialize your instance
|
||||||
|
bool TestSocial::init()
|
||||||
|
{
|
||||||
|
//////////////////////////////
|
||||||
|
// 1. super init first
|
||||||
|
if ( !Layer::init() )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
MySocialManager::sharedManager()->loadPlugins();
|
||||||
|
|
||||||
|
Size visibleSize = Director::getInstance()->getVisibleSize();
|
||||||
|
Point origin = Director::getInstance()->getVisibleOrigin();
|
||||||
|
Point posMid = Point(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2);
|
||||||
|
Point posBR = Point(origin.x + visibleSize.width, origin.y);
|
||||||
|
|
||||||
|
MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestSocial::menuBackCallback, this));
|
||||||
|
Size backSize = pBackItem->getContentSize();
|
||||||
|
pBackItem->setPosition(posBR + Point(- backSize.width / 2, backSize.height / 2));
|
||||||
|
|
||||||
|
// create menu, it's an autorelease object
|
||||||
|
Menu* pMenu = Menu::create(pBackItem, NULL);
|
||||||
|
pMenu->setPosition( Point::ZERO );
|
||||||
|
|
||||||
|
LabelTTF* label1 = LabelTTF::create("Submit Score", "Arial", 28);
|
||||||
|
MenuItemLabel* pItemSubmit = MenuItemLabel::create(label1, CC_CALLBACK_1(TestSocial::testSubmit, this));
|
||||||
|
pItemSubmit->setAnchorPoint(Point(0.5f, 0));
|
||||||
|
pMenu->addChild(pItemSubmit, 0);
|
||||||
|
pItemSubmit->setPosition(posMid + Point(-140, -60));
|
||||||
|
|
||||||
|
LabelTTF* label2 = LabelTTF::create("Unlock Achievement", "Arial", 28);
|
||||||
|
MenuItemLabel* pItemUnlock = MenuItemLabel::create(label2, CC_CALLBACK_1(TestSocial::testUnlock, this));
|
||||||
|
pItemUnlock->setAnchorPoint(Point(0.5f, 0));
|
||||||
|
pMenu->addChild(pItemUnlock, 0);
|
||||||
|
pItemUnlock->setPosition(posMid + Point(140, -60));
|
||||||
|
|
||||||
|
LabelTTF* label3 = LabelTTF::create("Show Leaderboard", "Arial", 28);
|
||||||
|
MenuItemLabel* pItemLeader = MenuItemLabel::create(label3, CC_CALLBACK_1(TestSocial::testLeaderboard, this));
|
||||||
|
pItemLeader->setAnchorPoint(Point(0.5f, 0));
|
||||||
|
pMenu->addChild(pItemLeader, 0);
|
||||||
|
pItemLeader->setPosition(posMid + Point(-140, -120));
|
||||||
|
|
||||||
|
LabelTTF* label4 = LabelTTF::create("Show Achievement", "Arial", 28);
|
||||||
|
MenuItemLabel* pItemAchi = MenuItemLabel::create(label4, CC_CALLBACK_1(TestSocial::testAchievement, this));
|
||||||
|
pItemAchi->setAnchorPoint(Point(0.5f, 0));
|
||||||
|
pMenu->addChild(pItemAchi, 0);
|
||||||
|
pItemAchi->setPosition(posMid + Point(140, -120));
|
||||||
|
|
||||||
|
// create optional menu
|
||||||
|
// cases item
|
||||||
|
_caseItem = MenuItemToggle::createWithCallback(NULL,
|
||||||
|
MenuItemFont::create( s_aTestCases[0].c_str() ),
|
||||||
|
NULL );
|
||||||
|
int caseLen = sizeof(s_aTestCases) / sizeof(std::string);
|
||||||
|
for (int i = 1; i < caseLen; ++i)
|
||||||
|
{
|
||||||
|
_caseItem->getSubItems()->addObject( MenuItemFont::create( s_aTestCases[i].c_str() ) );
|
||||||
|
}
|
||||||
|
_caseItem->setPosition(posMid + Point(0, 120));
|
||||||
|
pMenu->addChild(_caseItem);
|
||||||
|
|
||||||
|
this->addChild(pMenu, 1);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestSocial::testSubmit(Object* pSender)
|
||||||
|
{
|
||||||
|
int nIdx = _caseItem->getSelectedIndex();
|
||||||
|
MySocialManager::sharedManager()->submitScore((MySocialManager::MySocialMode)(nIdx + 1), "0", 30000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestSocial::testUnlock(Object* pSender)
|
||||||
|
{
|
||||||
|
int nIdx = _caseItem->getSelectedIndex();
|
||||||
|
TAchievementInfo info;
|
||||||
|
info["AchievementID"] = "MyAchiID";
|
||||||
|
info["NDDisplayText"] = "Fighter";
|
||||||
|
info["NDScore"] = "100";
|
||||||
|
MySocialManager::sharedManager()->unlockAchievement((MySocialManager::MySocialMode)(nIdx + 1), info);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestSocial::testLeaderboard(Object* pSender)
|
||||||
|
{
|
||||||
|
int nIdx = _caseItem->getSelectedIndex();
|
||||||
|
MySocialManager::sharedManager()->showLeaderboard((MySocialManager::MySocialMode)(nIdx + 1), "0");
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestSocial::testAchievement(Object* pSender)
|
||||||
|
{
|
||||||
|
int nIdx = _caseItem->getSelectedIndex();
|
||||||
|
MySocialManager::sharedManager()->showAchievement((MySocialManager::MySocialMode)(nIdx + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestSocial::menuBackCallback(Object* pSender)
|
||||||
|
{
|
||||||
|
MySocialManager::purgeManager();
|
||||||
|
Scene* newScene = HelloWorld::scene();
|
||||||
|
Director::getInstance()->replaceScene(newScene);
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
/****************************************************************************
|
||||||
|
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.
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef __TEST_SOCIAL_SCENE_H__
|
||||||
|
#define __TEST_SOCIAL_SCENE_H__
|
||||||
|
|
||||||
|
#include "cocos2d.h"
|
||||||
|
|
||||||
|
class TestSocial : public cocos2d::Layer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
|
||||||
|
virtual bool init();
|
||||||
|
|
||||||
|
// there's no 'id' in cpp, so we recommand to return the exactly class pointer
|
||||||
|
static cocos2d::Scene* scene();
|
||||||
|
|
||||||
|
// a selector callback
|
||||||
|
void menuBackCallback(Object* pSender);
|
||||||
|
void testSubmit(Object* pSender);
|
||||||
|
void testUnlock(Object* pSender);
|
||||||
|
void testLeaderboard(Object* pSender);
|
||||||
|
void testAchievement(Object* pSender);
|
||||||
|
|
||||||
|
// implement the "static node()" method manually
|
||||||
|
CREATE_FUNC(TestSocial);
|
||||||
|
|
||||||
|
private:
|
||||||
|
cocos2d::MenuItemToggle* _caseItem;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __TEST_SOCIAL_SCENE_H__
|
|
@ -1,3 +1,26 @@
|
||||||
|
/****************************************************************************
|
||||||
|
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.
|
||||||
|
****************************************************************************/
|
||||||
#include "TestUserScene.h"
|
#include "TestUserScene.h"
|
||||||
#include "MyUserManager.h"
|
#include "MyUserManager.h"
|
||||||
#include "HelloWorldScene.h"
|
#include "HelloWorldScene.h"
|
||||||
|
@ -40,8 +63,8 @@ bool TestUser::init()
|
||||||
MyUserManager::sharedManager()->loadPlugin();
|
MyUserManager::sharedManager()->loadPlugin();
|
||||||
Size visibleSize = Director::getInstance()->getVisibleSize();
|
Size visibleSize = Director::getInstance()->getVisibleSize();
|
||||||
Point origin = Director::getInstance()->getVisibleOrigin();
|
Point origin = Director::getInstance()->getVisibleOrigin();
|
||||||
Point posMid = ccp(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2);
|
Point posMid = Point(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2);
|
||||||
Point posBR = ccp(origin.x + visibleSize.width, origin.y);
|
Point posBR = Point(origin.x + visibleSize.width, origin.y);
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// 2. add a menu item with "X" image, which is clicked to quit the program
|
// 2. add a menu item with "X" image, which is clicked to quit the program
|
||||||
|
@ -50,23 +73,23 @@ bool TestUser::init()
|
||||||
// add a "close" icon to exit the progress. it's an autorelease object
|
// add a "close" icon to exit the progress. it's an autorelease object
|
||||||
MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestUser::menuBackCallback, this));
|
MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestUser::menuBackCallback, this));
|
||||||
Size backSize = pBackItem->getContentSize();
|
Size backSize = pBackItem->getContentSize();
|
||||||
pBackItem->setPosition(ccpAdd(posBR, ccp(- backSize.width / 2, backSize.height / 2)));
|
pBackItem->setPosition(posBR + Point(- backSize.width / 2, backSize.height / 2));
|
||||||
|
|
||||||
// create menu, it's an autorelease object
|
// create menu, it's an autorelease object
|
||||||
Menu* pMenu = Menu::create(pBackItem, NULL);
|
Menu* pMenu = Menu::create(pBackItem, NULL);
|
||||||
pMenu->setPosition(PointZero);
|
pMenu->setPosition(Point::ZERO);
|
||||||
|
|
||||||
LabelTTF* label1 = LabelTTF::create("Login", "Arial", 32);
|
LabelTTF* label1 = LabelTTF::create("Login", "Arial", 32);
|
||||||
MenuItemLabel* pItemLogin = MenuItemLabel::create(label1, CC_CALLBACK_1(TestUser::testLogin, this));
|
MenuItemLabel* pItemLogin = MenuItemLabel::create(label1, CC_CALLBACK_1(TestUser::testLogin, this));
|
||||||
pItemLogin->setAnchorPoint(ccp(0.5f, 0));
|
pItemLogin->setAnchorPoint(Point(0.5f, 0));
|
||||||
pMenu->addChild(pItemLogin, 0);
|
pMenu->addChild(pItemLogin, 0);
|
||||||
pItemLogin->setPosition(ccpAdd(posMid, ccp(-100, -120)));
|
pItemLogin->setPosition(posMid + Point(-100, -120));
|
||||||
|
|
||||||
LabelTTF* label2 = LabelTTF::create("Logout", "Arial", 32);
|
LabelTTF* label2 = LabelTTF::create("Logout", "Arial", 32);
|
||||||
MenuItemLabel* pItemLogout = MenuItemLabel::create(label2, CC_CALLBACK_1(TestUser::testLogout, this));
|
MenuItemLabel* pItemLogout = MenuItemLabel::create(label2, CC_CALLBACK_1(TestUser::testLogout, this));
|
||||||
pItemLogout->setAnchorPoint(ccp(0.5f, 0));
|
pItemLogout->setAnchorPoint(Point(0.5f, 0));
|
||||||
pMenu->addChild(pItemLogout, 0);
|
pMenu->addChild(pItemLogout, 0);
|
||||||
pItemLogout->setPosition(ccpAdd(posMid, ccp(100, -120)));
|
pItemLogout->setPosition(posMid + Point(100, -120));
|
||||||
|
|
||||||
// create optional menu
|
// create optional menu
|
||||||
// cases item
|
// cases item
|
||||||
|
@ -78,7 +101,7 @@ bool TestUser::init()
|
||||||
{
|
{
|
||||||
_caseItem->getSubItems()->addObject( MenuItemFont::create( s_aTestCases[i].c_str() ) );
|
_caseItem->getSubItems()->addObject( MenuItemFont::create( s_aTestCases[i].c_str() ) );
|
||||||
}
|
}
|
||||||
_caseItem->setPosition(ccpAdd(posMid, ccp(0, 120)));
|
_caseItem->setPosition(posMid + Point(0, 120));
|
||||||
pMenu->addChild(_caseItem);
|
pMenu->addChild(_caseItem);
|
||||||
|
|
||||||
_selectedCase = 0;
|
_selectedCase = 0;
|
||||||
|
|
|
@ -1,3 +1,26 @@
|
||||||
|
/****************************************************************************
|
||||||
|
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.
|
||||||
|
****************************************************************************/
|
||||||
#ifndef __TEST_USER_SCENE_H__
|
#ifndef __TEST_USER_SCENE_H__
|
||||||
#define __TEST_USER_SCENE_H__
|
#define __TEST_USER_SCENE_H__
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,9 @@ LOCAL_SRC_FILES := hellocpp/main.cpp \
|
||||||
../../Classes/TestUser/TestUserScene.cpp \
|
../../Classes/TestUser/TestUserScene.cpp \
|
||||||
../../Classes/TestUser/MyUserManager.cpp \
|
../../Classes/TestUser/MyUserManager.cpp \
|
||||||
../../Classes/TestIAPOnline/TestIAPOnlineScene.cpp \
|
../../Classes/TestIAPOnline/TestIAPOnlineScene.cpp \
|
||||||
../../Classes/TestIAPOnline/MyIAPOLManager.cpp
|
../../Classes/TestIAPOnline/MyIAPOLManager.cpp \
|
||||||
|
../../Classes/TestSocial/TestSocialScene.cpp \
|
||||||
|
../../Classes/TestSocial/MySocialManager.cpp
|
||||||
|
|
||||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \
|
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \
|
||||||
$(LOCAL_PATH)/../../Classes/TestAds \
|
$(LOCAL_PATH)/../../Classes/TestAds \
|
||||||
|
@ -26,7 +28,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \
|
||||||
$(LOCAL_PATH)/../../Classes/TestIAP \
|
$(LOCAL_PATH)/../../Classes/TestIAP \
|
||||||
$(LOCAL_PATH)/../../Classes/TestShare \
|
$(LOCAL_PATH)/../../Classes/TestShare \
|
||||||
$(LOCAL_PATH)/../../Classes/TestUser \
|
$(LOCAL_PATH)/../../Classes/TestUser \
|
||||||
$(LOCAL_PATH)/../../Classes/TestIAPOnline
|
$(LOCAL_PATH)/../../Classes/TestIAPOnline \
|
||||||
|
$(LOCAL_PATH)/../../Classes/TestSocial
|
||||||
|
|
||||||
LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static \
|
LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static \
|
||||||
PluginProtocolStatic
|
PluginProtocolStatic
|
||||||
|
|
|
@ -57,6 +57,8 @@
|
||||||
FAD55528177D2C2000968F54 /* BtnND91.png in Resources */ = {isa = PBXBuildFile; fileRef = FAD55524177D2C2000968F54 /* BtnND91.png */; };
|
FAD55528177D2C2000968F54 /* BtnND91.png in Resources */ = {isa = PBXBuildFile; fileRef = FAD55524177D2C2000968F54 /* BtnND91.png */; };
|
||||||
FAD55529177D2C2000968F54 /* twitter.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = FAD55525177D2C2000968F54 /* twitter.jpeg */; };
|
FAD55529177D2C2000968F54 /* twitter.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = FAD55525177D2C2000968F54 /* twitter.jpeg */; };
|
||||||
FAD5552A177D2C2000968F54 /* weibo.png in Resources */ = {isa = PBXBuildFile; fileRef = FAD55526177D2C2000968F54 /* weibo.png */; };
|
FAD5552A177D2C2000968F54 /* weibo.png in Resources */ = {isa = PBXBuildFile; fileRef = FAD55526177D2C2000968F54 /* weibo.png */; };
|
||||||
|
FADBF8A2179E559900F59B1D /* MySocialManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADBF89E179E559900F59B1D /* MySocialManager.cpp */; };
|
||||||
|
FADBF8A3179E559900F59B1D /* TestSocialScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADBF8A0179E559900F59B1D /* TestSocialScene.cpp */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
|
@ -236,6 +238,10 @@
|
||||||
FAD55524177D2C2000968F54 /* BtnND91.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = BtnND91.png; sourceTree = "<group>"; };
|
FAD55524177D2C2000968F54 /* BtnND91.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = BtnND91.png; sourceTree = "<group>"; };
|
||||||
FAD55525177D2C2000968F54 /* twitter.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = twitter.jpeg; sourceTree = "<group>"; };
|
FAD55525177D2C2000968F54 /* twitter.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = twitter.jpeg; sourceTree = "<group>"; };
|
||||||
FAD55526177D2C2000968F54 /* weibo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = weibo.png; sourceTree = "<group>"; };
|
FAD55526177D2C2000968F54 /* weibo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = weibo.png; sourceTree = "<group>"; };
|
||||||
|
FADBF89E179E559900F59B1D /* MySocialManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MySocialManager.cpp; sourceTree = "<group>"; };
|
||||||
|
FADBF89F179E559900F59B1D /* MySocialManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MySocialManager.h; sourceTree = "<group>"; };
|
||||||
|
FADBF8A0179E559900F59B1D /* TestSocialScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestSocialScene.cpp; sourceTree = "<group>"; };
|
||||||
|
FADBF8A1179E559900F59B1D /* TestSocialScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestSocialScene.h; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
@ -289,6 +295,7 @@
|
||||||
15AA9C4015B7EC450033D6C2 /* Classes */ = {
|
15AA9C4015B7EC450033D6C2 /* Classes */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
FADBF89D179E559900F59B1D /* TestSocial */,
|
||||||
FA3D264717867219009B234A /* TestIAPOnline */,
|
FA3D264717867219009B234A /* TestIAPOnline */,
|
||||||
FAD5550E177D1EE900968F54 /* TestIAP */,
|
FAD5550E177D1EE900968F54 /* TestIAP */,
|
||||||
FAD55513177D1EE900968F54 /* TestUser */,
|
FAD55513177D1EE900968F54 /* TestUser */,
|
||||||
|
@ -464,6 +471,18 @@
|
||||||
path = ../Classes/TestUser;
|
path = ../Classes/TestUser;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
FADBF89D179E559900F59B1D /* TestSocial */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
FADBF89E179E559900F59B1D /* MySocialManager.cpp */,
|
||||||
|
FADBF89F179E559900F59B1D /* MySocialManager.h */,
|
||||||
|
FADBF8A0179E559900F59B1D /* TestSocialScene.cpp */,
|
||||||
|
FADBF8A1179E559900F59B1D /* TestSocialScene.h */,
|
||||||
|
);
|
||||||
|
name = TestSocial;
|
||||||
|
path = ../Classes/TestSocial;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
/* End PBXGroup section */
|
/* End PBXGroup section */
|
||||||
|
|
||||||
/* Begin PBXNativeTarget section */
|
/* Begin PBXNativeTarget section */
|
||||||
|
@ -662,6 +681,8 @@
|
||||||
FAD5551B177D1EE900968F54 /* TestUserScene.cpp in Sources */,
|
FAD5551B177D1EE900968F54 /* TestUserScene.cpp in Sources */,
|
||||||
FA3D264D17867219009B234A /* MyIAPOLManager.cpp in Sources */,
|
FA3D264D17867219009B234A /* MyIAPOLManager.cpp in Sources */,
|
||||||
FA3D264E17867219009B234A /* TestIAPOnlineScene.cpp in Sources */,
|
FA3D264E17867219009B234A /* TestIAPOnlineScene.cpp in Sources */,
|
||||||
|
FADBF8A2179E559900F59B1D /* MySocialManager.cpp in Sources */,
|
||||||
|
FADBF8A3179E559900F59B1D /* TestSocialScene.cpp in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue