示例#1
0
void AppDelegate::setLivesMustRestore(int pIndex, bool pMust)
{
    char text[64];
    
    sprintf(text, "live_%d_restore_time", pIndex);
    
    if(pMust)
    {
        CCUserDefault::sharedUserDefault()->setIntegerForKey(text, Utils::millisecondNow());
        sprintf(text, "live_%d_restoring", pIndex);
        CCUserDefault::sharedUserDefault()->setBoolForKey(text, true);

        #if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
        callStaticVoidMethod("com/tooflya/projectbirds/notify/NotifyService", "setLivesMustRestore");
        #endif
    }
    else
    {
        CCUserDefault::sharedUserDefault()->setIntegerForKey(text, 0);
        sprintf(text, "live_%d_restoring", pIndex);
        CCUserDefault::sharedUserDefault()->setBoolForKey(text, false);
    }
    
    CCUserDefault::sharedUserDefault()->flush();
}
    void Nextpeer_Android::requestPauseRecording(const char* recordingPlayerId)
    {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
        JNIEnv* env = NULL;
        if (!Nextpeer_AndroidJNIHelper::getEnv(&env)) return;
        
        jstring playerId = (jstring)env->NewStringUTF(recordingPlayerId);
        
        callStaticVoidMethod("requestRecordingControlPauseRecording", "(Ljava/lang/String;)V", playerId);
        
        env->DeleteLocalRef(playerId);
#endif
    }
    void Nextpeer_Android::requestFastForwardRecording(const char* recordingPlayerId, uint32_t timeDelta)
    {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
        JNIEnv* env = NULL;
        if (!Nextpeer_AndroidJNIHelper::getEnv(&env)) return;
        
        jstring playerId = (jstring)env->NewStringUTF(recordingPlayerId);
        jint delta = (jint)(timeDelta > INT_MAX ? INT_MAX : timeDelta);
        
        callStaticVoidMethod("requestRecordingControlFastForwardRecording", "(Ljava/lang/String;I)V", playerId, timeDelta);
        
        env->DeleteLocalRef(playerId);
#endif
    }
    void Nextpeer_Android::reportScoreModifierForRecording(const char* recordingPlayerId, int32_t modifier)
    {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
        JNIEnv* env = NULL;
        if (!Nextpeer_AndroidJNIHelper::getEnv(&env)) return;
        
        jstring playerId = (jstring)env->NewStringUTF(recordingPlayerId);
        jint jModifier = (jint)(modifier > INT_MAX ? INT_MAX : modifier);
        
        callStaticVoidMethod("requestRecordingControlScoreModifier", "(Ljava/lang/String;I)V", playerId, jModifier);
        
        env->DeleteLocalRef(playerId);
#endif
    }
	void Nextpeer_Android::reportControlledTournamentOverWithScore(uint32_t score)
	{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
		callStaticVoidMethod("reportControlledTournamentOverWithScore", "(I)V", score);
#endif
	}
	void Nextpeer_Android::reportScoreForCurrentTournament(uint32_t score)
	{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
		callStaticVoidMethod("reportScoreForCurrentTournament", "(I)V", score);
#endif		
	}
	void Nextpeer_Android::launchDashboard()
	{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
		callStaticVoidMethod("launch", "()V");
#endif
	}
    void Nextpeer_Android::enableRankingDisplay(bool enableRankingDisplay) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
        callStaticVoidMethod("enableRankingDisplay", "(Z)V", enableRankingDisplay);
#endif
    }
	void Nextpeer_Android::reportForfeitForCurrentTournament()
	{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
		callStaticVoidMethod("reportForfeitForCurrentTournament", "()V");
#endif
	}