Ejemplo n.º 1
0
void  PauseLayer::soundsButtonTapped(CCObject *sender) {
    CCUserDefault *defaults = CCUserDefault::sharedUserDefault();
    CCMenuItemToggle *toggleItem = (CCMenuItemToggle*)sender;
    if (toggleItem->selectedItem() == menuItemSoundOn) {
        defaults->setBoolForKey(kSoundsKey, true);
        Utility::changeVolume(1.0f);
    } else if (toggleItem->selectedItem() == menuItemSoundOff) {
        defaults->setBoolForKey(kSoundsKey, false);
        Utility::changeVolume(0.0f);
    }
}
Ejemplo n.º 2
0
void LocalData::writeRuntimeDataToLocal()
{
	CCUserDefault* userDefault = CCUserDefault::sharedUserDefault();
	userDefault->setBoolForKey("hasmusic", RunTimeData::getInstance()->hasMusic);
	userDefault->setBoolForKey("guiderecord", RunTimeData::getInstance()->isFirstTime);
	userDefault->setStringForKey("levelStarStr", RunTimeData::getInstance()->levelStars);
	userDefault->setIntegerForKey("passedLevelNum", RunTimeData::getInstance()->passedLevel);
	userDefault->setIntegerForKey("totalStarNum", RunTimeData::getInstance()->startNum);
	userDefault->setIntegerForKey("annihilator", RunTimeData::getInstance()->annihilatorNum);
	userDefault->setBoolForKey("isFirstTime", RunTimeData::getInstance()->isFirstTime);
	userDefault->flush();
}
Ejemplo n.º 3
0
void Config::flush() {
	CCUserDefault* ud = CCUserDefault::sharedUserDefault();
	ud->setBoolForKey(CONFIG_KEY_MUTE, m_mute);
	ud->setBoolForKey(CONFIG_KEY_HASSAVEDPUZZLE, m_hasSavedPuzzle);
	ud->setIntegerForKey(CONFIG_KEY_HIGHSCORE, m_highScore);
	ud->setIntegerForKey(CONFIG_KEY_HIGHLEVEL, m_highLevel);
	ud->setIntegerForKey(CONFIG_KEY_SAVEDSCORE, m_savedScore);
	ud->setIntegerForKey(CONFIG_KEY_SAVEDTARGET, m_savedTarget);
	ud->setIntegerForKey(CONFIG_KEY_SAVEDLEVEL, m_savedLevel);
	ud->setIntegerForKey(CONFIG_KEY_SAVEDROW, m_savedRow);
	ud->setIntegerForKey(CONFIG_KEY_SAVEDCOL, m_savedCol);
	ud->setStringForKey(CONFIG_KEY_SAVEDPUZZLE, m_savedPuzzle);
	ud->flush();
}
Ejemplo n.º 4
0
void GameConfig::save()
{
    std::string playerUID = PlayerData::getInstance()->player->uid;

    CCUserDefault* user = CCUserDefault::sharedUserDefault();

    user->setBoolForKey((playerUID + "_instance_stage").c_str(),
                        showInstanceStage);
    user->setBoolForKey((playerUID + "_soul_exchange").c_str(),
                        showSoulExchange);
    user->setBoolForKey((playerUID + "_shuffle_relation").c_str(),
                        showShuffleRelation);
    user->setBoolForKey((playerUID + "_first_time_neili").c_str(),
                        firstTimeNeili);
    user->setBoolForKey((playerUID + "_first_time_instance").c_str(),
                        firstTimeShowInstance);
    user->setBoolForKey((playerUID + "_first_time_zhuansheng").c_str(),
                        firstTimeZhuansheng);

    user->setIntegerForKey((playerUID + "_open_instance").c_str(), openInstanceStep);
    user->setBoolForKey((playerUID + "_open_jueding10").c_str(), openJueDing10);

    user->setBoolForKey((playerUID + "_show_drag_hint").c_str(), showDragHint);
    user->setBoolForKey((playerUID + "_show_attr_hint").c_str(), showAttrHint);

    user->flush();
}
Ejemplo n.º 5
0
void Config::setMute(bool mute) {
	m_mute = mute;
	CCUserDefault* ud = CCUserDefault::sharedUserDefault();
	ud->setBoolForKey(CONFIG_KEY_MUTE, m_mute);
	if (m_mute)
		CocosDenshion::SimpleAudioEngine::sharedEngine()->stopAllEffects();
}
Ejemplo n.º 6
0
void GameConfig::setAndroidHDEnabled(bool val)
{
    mEnableAndroidHD = val;
    CCUserDefault* user = CCUserDefault::sharedUserDefault();
    user->setBoolForKey(CONFIG_ANDROID_HD_KEY, mEnableAndroidHD);
    user->flush();
}
Ejemplo n.º 7
0
void GameConfig::setBGMEnabled(bool val)
{
    mEnableBGM = val;
    CCUserDefault* user = CCUserDefault::sharedUserDefault();
    user->setBoolForKey(CONFIG_BGM_KEY, mEnableBGM);
    user->flush();
}
Ejemplo n.º 8
0
void GameConfig::setSFXEnabled(bool val)
{
    mEnableSFX = val;
    CCUserDefault* user = CCUserDefault::sharedUserDefault();
    user->setBoolForKey(CONFIG_SFX_KEY, mEnableSFX);
    user->flush();
}
Ejemplo n.º 9
0
void GameData::saveSettings()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    CCUserDefault* write = CCUserDefault::sharedUserDefault();
    write->setBoolForKey("IsExisted", _isExisted);
    write->setIntegerForKey("HighScore", _highScore);
    write->flush();
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    JNI_setBool("IsExisted", _isExisted);
    JNI_setInt("HighScore", _highScore);
#endif
}
Ejemplo n.º 10
0
void GameData::saveSettings()
{
    
#if (ANDROIDSAVEBYUSERDEFAULT == 1 && CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    JNI_setBool("IsBeginner", gd_isBeginner);
    JNI_setInt("HighScore", gd_highScore);
    JNI_setInt("Gold", gd_gold);
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    CCUserDefault* write = CCUserDefault::sharedUserDefault();
    write->setBoolForKey("IsBeginner", gd_isBeginner);
    write->setIntegerForKey("HighScore", gd_highScore);
    write->setIntegerForKey("Gold", gd_gold);
    write->flush();
#endif
    
}
Ejemplo n.º 11
0
void SGWelComeLayer::requestFinished(int msgid, CCObject *data)
{
    CCLOG("收到数据");
    switch (msgid)
    {
        case MSG_HTTP_FAST_LOGIN:
        {
            std::string serverip = CCUserDefault::sharedUserDefault()->getStringForKey("serverip");
            short serverpost = (short)CCUserDefault::sharedUserDefault()->getIntegerForKey("serverpost");
            
            //记录服务器ip和端口号
            SGMainManager::shareMain()->setServerInfo(CCString::create(serverip.c_str()) , serverpost);
            
            //连接socket
            SGSocketClient::sharedSocketClient()->startConn(serverip.c_str() , serverpost);
            
        }
            break;
        case MSG_HTTP_LOGIN:
        {
            int isLogin = SGMainManager::shareMain()->getIsFBLogin();
            if (isLogin != 1 || !SGMainManager::shareMain()->getIsFbAutologin())
            {
                std::string serverip = CCUserDefault::sharedUserDefault()->getStringForKey("serverip");
                int serverpost = CCUserDefault::sharedUserDefault()->getIntegerForKey("serverpost");
                SGSocketClient::sharedSocketClient()->startConn(serverip.c_str() ,(short)serverpost);
            }
            else
            {
                SGMainManager::shareMain()->setIsFbAutologin(false);
            }
        }
            break;
        case MSg_HTTP_SERVERLIST:
        {
            SGServerListLayer *box = SGServerListLayer::create(this, (CCArray *)data, SGServerListLayerComeFromFirst);
            SGMainManager::shareMain()->showBox(box,false);

            
        }
            break;
        case MSG_HTTP_UPDATE_SERVER_STATE:
        {
            CCDictionary *dict = (CCDictionary*)data;
            CCString *serverIp = (CCString*)dict->objectForKey("serverIp");
            CCString *serverPost = (CCString*)dict->objectForKey("serverPost");
            CCString *serverId = (CCString*)dict->objectForKey("serverId");
            CCString *serverShowId = (CCString*)dict->objectForKey("serverShowId");
            CCString* serverName = (CCString*)dict->objectForKey("serverName");
            //保存即将登陆的服务器的描述
            serverDes = ((CCString * )dict->objectForKey("serverDes") )->m_sString;
            //save ip and post of server
            CCUserDefault::sharedUserDefault()->setIntegerForKey("serverid",serverId->intValue());
            CCUserDefault::sharedUserDefault()->setIntegerForKey("serverShowId", serverShowId->intValue());
            CCUserDefault::sharedUserDefault()->setStringForKey("serverip", serverIp->getCString());
            CCUserDefault::sharedUserDefault()->setIntegerForKey("serverpost", serverPost->intValue());
            CCUserDefault::sharedUserDefault()->setStringForKey("servername", serverName->getCString());
            CCUserDefault::sharedUserDefault()->flush();
            
            
            CCLog("最新服务器 ip=%s\n post=%s\n id=%s\n name=%s",serverIp->getCString(),serverPost->getCString(),serverId->getCString(),serverName->getCString());
            
            changeServerbtn->setFont(serverName->getCString());
            CCUserDefault::sharedUserDefault()->setStringForKey("servername", serverName->getCString());
            
            //如果是维护中 则不再登陆。
            short serverState = (short)(  ( (CCString *)dict->objectForKey("serverState") )->intValue() );
            if (1 != serverState)
            {
                ;
            }
            //提示不能登陆的详细信息。
            else
            {
                SGMainManager::shareMain()->showMessage(serverDes.c_str());
            }
            //MM: 即使维护中,也尝试登录,101用户会自动放过。
            this->realLogin();
        }
            break;

        case MSg_HTTP_LASTESTSERVER:
        {
            CCDictionary *dict = (CCDictionary*)data;
            CCString *serverIp = (CCString*)dict->objectForKey("serverIp");
            CCString *serverPost = (CCString*)dict->objectForKey("serverPost");
            CCString *serverId = (CCString*)dict->objectForKey("serverId");
            CCString* serverName = (CCString*)dict->objectForKey("serverName");
            //保存即将登陆的服务器的描述
            serverDes = ((CCString * )dict->objectForKey("serverDes") )->m_sString;
            //save ip and post of server
            CCUserDefault::sharedUserDefault()->setIntegerForKey("serverid",serverId->intValue());
            CCUserDefault::sharedUserDefault()->setStringForKey("serverip", serverIp->getCString());
            CCUserDefault::sharedUserDefault()->setIntegerForKey("serverpost", serverPost->intValue());
            CCUserDefault::sharedUserDefault()->setStringForKey("servername", serverName->getCString());
            CCUserDefault::sharedUserDefault()->flush();
            
            
            CCLog("最新服务器 ip=%s\n post=%s\n id=%s\n name=%s",serverIp->getCString(),serverPost->getCString(),serverId->getCString(),serverName->getCString());
            
            changeServerbtn->setFont(serverName->getCString());
            CCUserDefault::sharedUserDefault()->setStringForKey("servername", serverName->getCString());
            
        }
            break;
        case MSG_HTTP_GET_CHANNEL_USER_ID:
        {
            CCDictionary* dict = (CCDictionary*) data;
            CCUserDefault* ccud = CCUserDefault::sharedUserDefault();
            CCString* actId = (CCString*) dict->objectForKey("sdkAccountId");
            ccud->setStringForKey("userId", actId->m_sString);
            ccud->setStringForKey("username", actId->m_sString);
            ccud->setStringForKey("password", actId->m_sString);
            ccud->setIntegerForKey("channelId", GlobalConfig::gi()->getRealChannelId());
#if (GCCT_CHINA_UC_ADR_THIRD == GAME_CHANNEL_TYPE) //uc adr
            //MM: 将本次s_sid作为loginkey,登入使用。
            ccud->setStringForKey("loginKey", UCSdk::s_sid);
#elif (GCCT_CHINA_KUAIYONG_IOS_THIRD == GAME_CHANNEL_TYPE)
            //MM: 将快用的tokenKey作为loginkey,登入使用。
            ccud->setStringForKey("loginKey", ( (KuaiYongIosImp*) SdkController::gi()->getSdkImp() )->kyToken );
#else
            
#endif
            CCString* nickName = (CCString*) dict->objectForKey("sdkNickName");
            ccud->setStringForKey("sdk_user_nick_name", nickName->m_sString);
            //还有一个"sdkCreator"字段,但是未起作用,所以没有在这里添加。
            registerBtn->setFont(nickName->getCString()); //将按钮文本变为其uc账号昵称。

            ccud->setBoolForKey("isExist", true);
            ccud->setBoolForKey("isAccount", true);
            ccud->flush();
            //MMD: SDKIF SDK登陆成功!仅当21号http消息完成后,才设置SDK登陆成功标志,其他情况一概无视。
            ExtClassOfSDK::sharedSDKInstance()->setIsLoginSDK(true);
            //添加的针对非注册体系下的td数据设置,目前有uc在使用。
            ExtClassOfSDK::sharedSDKInstance()->setTdData(actId->m_sString, nickName->m_sString);
        }
            break;
        default:
            break;
    }
    SGMainManager::shareMain()->getMainScene()->plat->removeConnection();
}
Ejemplo n.º 12
0
bool LevelSelectScene::initWithPage(int pageNum)
{
     CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    // 初期化色を変更
    if (!CCLayerColor::initWithColor(ccc4(0xF8,0xEC,0xDE,0xFF))) //RGBA
    {
        return false;
    }
    
    this->page_num = pageNum;
    
    CCUserDefault* userDefault = CCUserDefault::sharedUserDefault();
    // is_tutorial
    string tutorialKey = ConstCommon::getTutorialKey();
    bool tutorClear = userDefault->getBoolForKey(tutorialKey.c_str());
    if( ! tutorClear){
        userDefault->setBoolForKey(tutorialKey.c_str(), true);
        userDefault->flush();
    }

    
    //start button
    CCArray* pLevelArr = new CCArray;
    
    //page1->1〜15 ... page2->16〜30
    for (int i=1 + ((page_num - 1)* 15); i <= 15 + ((page_num - 1)* 15); i++) {
        //create Level Button
        pLevelArr->addObject(createLevelImage(i));
    }

    CCMenu* pMenu = CCMenu::createWithArray(pLevelArr);
    pMenu->setPosition(CCPointZero);
    pMenu->setTag(tagLevelSelectMenuDialog);
    
    if(this->page_num != 2){
        CCMenuItemImage* nextItem = CCMenuItemImage::create("next.png","next.png.png" ,this, menu_selector(LevelSelectScene::showNextPage));
        nextItem->setPosition(ccp(winSize.width * 0.8, winSize.height * 0.2));
        nextItem->setScale(0.2);
        pMenu->addChild(nextItem);
    }
    
    if(this->page_num != 1){
        CCMenuItemImage* prevItem = CCMenuItemImage::create("prev.png","prev.png" ,this, menu_selector(LevelSelectScene::showPrevPage));
        prevItem->setPosition(ccp(winSize.width * 0.2, winSize.height * 0.2));
        prevItem->setScale(0.2);
        pMenu->addChild(prevItem);
    }
    
   
    
    this->addChild(pMenu);
    
   

    CCString* stageSelectStr = CCString::createWithFormat("STAGE SELECT");
    CCLabelTTF* stageSelectLabel = CCLabelTTF::create(stageSelectStr->getCString(), "Copperplate", 70.0);
    stageSelectLabel->setColor(ccc3(0, 0, 0));
    stageSelectLabel->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.95));
    this->addChild(stageSelectLabel);
    
    return true;
    
}