void MCBackpack::loadData() { CCUserDefault *userDefault = CCUserDefault::sharedUserDefault(); loadEffectiveItems(); if (! __icon_loaded) { loadIcons(); } if (MCGameState::sharedGameState()->isSaveFileExists()) { string data = userDefault->getStringForKey(kMCBackpackKey, kMCZero); if (data.size() > 0) { #if MC_DEBUG_SAVEDATA == 1 const char *output = data.c_str(); #else const char *input = data.c_str(); char *output; mc_size_t len = strlen(input); MCBase64Decode((mc_byte_t *) input, len, (mc_byte_t **) &output); #endif JsonBox::Value v; v.loadFromString(output); JsonBox::Object backpack = v.getObject(); /* 加载金钱 */ money_ = backpack[kMCMoneyKey].getInt(); } } else { money_ = 0; } }
KDvoid Ch3_SavingSimpleData::loadDifficulty ( KDvoid ) { // If a difficulty is set we use that, otherwise we choose Medium CCUserDefault* pDefaults = CCUserDefault::sharedUserDefault ( ); m_sDifficulty = pDefaults->getStringForKey ( "simple_data_difficulty", "Medium" ); this->setDifficultyFromValue ( ); }
void UpdateScene::update(float diff) { if(!updateYet) { updateYet = true; //不需要更新文件 CCUserDefault *def = CCUserDefault::sharedUserDefault(); if(def->getStringForKey("update") != "0") ap->updateFiles(); else { progress = 200; } } else { localcount = localcount+1; CCLog("progress to load main %d", progress); if(progress == 200 && localcount >= 50) { CCUserDefault *def = CCUserDefault::sharedUserDefault(); if(def->getStringForKey("update") != "0") { if(publicAssets != NULL) { publicAssets->updateVersion(); } } /* CCDictionary *dict = CCDictionary::create(); CCDictionary *ads = CCDictionary::create(); ads->setObject(CCString::create("AdsAdmob"), "name"); dict->setObject(ads, "ads"); MyPlugins::getInstance()->loadPlugins(dict); */ CCLuaEngine* pEngine = CCLuaEngine::defaultEngine(); std::string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("main.lua"); pEngine->executeScriptFile(path.c_str()); }else { loadPoint(progress); } } }
void Config::load() { CCUserDefault* ud = CCUserDefault::sharedUserDefault(); m_mute = ud->getBoolForKey(CONFIG_KEY_MUTE); m_hasSavedPuzzle = ud->getBoolForKey(CONFIG_KEY_HASSAVEDPUZZLE); m_highScore = ud->getIntegerForKey(CONFIG_KEY_HIGHSCORE); m_highLevel = ud->getIntegerForKey(CONFIG_KEY_HIGHLEVEL); if (m_hasSavedPuzzle) { m_savedScore = ud->getIntegerForKey(CONFIG_KEY_SAVEDSCORE); m_savedTarget = ud->getIntegerForKey(CONFIG_KEY_SAVEDTARGET); m_savedLevel = ud->getIntegerForKey(CONFIG_KEY_SAVEDLEVEL); m_savedRow = ud->getIntegerForKey(CONFIG_KEY_SAVEDROW); m_savedCol = ud->getIntegerForKey(CONFIG_KEY_SAVEDCOL); m_savedPuzzle = ud->getStringForKey(CONFIG_KEY_SAVEDPUZZLE); } }
void LocalData::readLocalDataToRunTime() { CCUserDefault* userDefault = CCUserDefault::sharedUserDefault(); RunTimeData::getInstance()->hasMusic = userDefault->getBoolForKey("hasmusic", true); std::string levelStr = userDefault->getStringForKey("levelStarStr", ""); RunTimeData::getInstance()->passedLevel = userDefault->getIntegerForKey("passedLevelNum", 1); RunTimeData::getInstance()->startNum = userDefault->getIntegerForKey("totalStarNum", 0); RunTimeData::getInstance()->annihilatorNum = userDefault->getIntegerForKey("annihilator", 0); RunTimeData::getInstance()->isFirstTime = userDefault->getBoolForKey("isFirstTime", true); if (levelStr.length() != 0){ strcpy(RunTimeData::getInstance()->levelStars, levelStr.c_str()); } RunTimeData::getInstance()->isFirstTime = userDefault->getBoolForKey("guiderecord", true); }
bool Memory::loadBasic() { CCUserDefault * def = CCUserDefault::sharedUserDefault(); std::string saved = def->getStringForKey("Memory_basic"); Json::Value val; Json::Reader reader; if (!reader.parse(saved, val)) { M_WARNING("error reading user default"); return false; } // _accountId = val["accountId"].asUInt(); // _passwordHashed = val["password"].asString(); // _lastServerId = val["lastServerId"].asUInt(); // _musicOn = val["musicOn"].asBool(); // _effectOn = val["effectOn"].asBool(); // _weibo_name = val["weiboName"].asString(); // _qq_name = val["qqName"].asString(); // _facebook_name =val["facebookName"].asString(); // // _weibo_id = val["weiboId"].asString(); // _facebook_id = val["facebookId"].asString(); // _qq_id = val["qqId"].asString(); // // _pendingTransactions.clear(); // auto val2 = val["pendingTransactions"]; // if (val2.isArray()) // { // for (auto v : val2) // { // MIAPTransaction tr; // tr.productId = v["p"].asString(); // tr.transactionId = v["t"].asString(); // tr.receipt = v["r"].asString(); // // _pendingTransactions.push_back(tr); // } // } // _userId = 0; return true; }
void MCBackpack::loadEffectiveItems() { MCItemManager *itemManager = MCItemManager::sharedItemManager(); CCUserDefault *userDefault = CCUserDefault::sharedUserDefault(); string data = userDefault->getStringForKey(kMCEffectiveItemsKey, ""); if (MCGameState::sharedGameState()->isSaveFileExists() && data.size() > 0) { #if MC_DEBUG_SAVEDATA == 1 const char *output = data.c_str(); #else const char *input = data.c_str(); char *output; mc_size_t len = strlen(input); MCBase64Decode((mc_byte_t *) input, len, (mc_byte_t **) &output); #endif JsonBox::Value v; v.loadFromString(output); JsonBox::Array effectiveItems = v.getArray(); healthPotion_->count = effectiveItems.at(0).getInt(); physicalPotion_->count = effectiveItems.at(1).getInt(); fireballTrapWide_->count = effectiveItems.at(2).getInt(); fireballTrapDamage_->count = effectiveItems.at(3).getInt(); curseTrapWide_->count = effectiveItems.at(4).getInt(); curseTrapDamage_->count = effectiveItems.at(5).getInt(); paralysisTrapWide_->count = effectiveItems.at(6).getInt(); paralysisTrapDamage_->count = effectiveItems.at(7).getInt(); fogTrapWide_->count = effectiveItems.at(8).getInt(); fogTrapDamage_->count = effectiveItems.at(9).getInt(); flashTrapWide_->count = effectiveItems.at(10).getInt(); flashTrapDamage_->count = effectiveItems.at(11).getInt(); #if MC_DEBUG_SAVEDATA != 1 delete []output; #endif } else { healthPotion_->count = 0; physicalPotion_->count = 0; fireballTrapWide_->count = 0; fireballTrapDamage_->count = 0; curseTrapWide_->count = 0; curseTrapDamage_->count = 0; paralysisTrapWide_->count = 0; paralysisTrapDamage_->count = 0; fogTrapWide_->count = 0; fogTrapDamage_->count = 0; flashTrapWide_->count = 0; flashTrapDamage_->count = 0; } /* load items */ healthPotion_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCHealthPotion]); healthPotion_->item->retain(); physicalPotion_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCPhysicalPotion]); physicalPotion_->item->retain(); fireballTrapWide_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCFireballWide]); fireballTrapWide_->item->retain(); fireballTrapDamage_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCFireballDamage]); fireballTrapDamage_->item->retain(); curseTrapWide_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCCurseWide]); curseTrapWide_->item->retain(); curseTrapDamage_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCCurseDamage]); curseTrapDamage_->item->retain(); paralysisTrapWide_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCParalysisWide]); paralysisTrapWide_->item->retain(); paralysisTrapDamage_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCParalysisDamage]); paralysisTrapDamage_->item->retain(); fogTrapWide_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCFogWide]); fogTrapWide_->item->retain(); fogTrapDamage_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCFogDamage]); fogTrapDamage_->item->retain(); flashTrapWide_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCFlashWide]); flashTrapWide_->item->retain(); flashTrapDamage_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCFlashDamage]); flashTrapDamage_->item->retain(); }
void SGWelComeLayer::initMsg() { //MMDEBUG: BEGIN #if SIMPLE_TEST ResourceManager* rm = ResourceManager::sharedInstance(); rm->bindTexture("sgserverlistlayer/sgserverlistlayer.plist",RES_TYPE_LAYER_UI ,sg_luaactivity); rm->bindTexture("sgrewardlayer/sgrewardlayer.plist",RES_TYPE_LAYER_UI ,sg_luaactivity); rm->bindTexture("sgfirstactivitylayer/sgfirstactivitylayer.plist",RES_TYPE_LAYER_UI ,sg_luaactivity); rm->bindTexture("animationFile/short.plist",RES_TYPE_LAYER_UI ,sg_luaactivity); rm->bindTexture("sanguobigpic/barrack_bg.plist",RES_TYPE_LAYER_UI ,sg_luaactivity); CCLuaEngine* pEngine = CCLuaEngine::defaultEngine(); pEngine->executeScriptFile("qingming.lua"); //这里更换为自己的xxx.lua,lua文件请直接放在ipad文件夹下。 return; #endif //MMDEBUG: END // CCFileUtils::sharedFileUtils()->fullPathForFilename("hello.lua"); ResourceManager::sharedInstance()->bindTexture("sgloginingbox/sgloginingbox.plist", RES_TYPE_LAYER_UI, sg_welComeLayer); ResourceManager::sharedInstance()->bindTexture("sgserverlistlayer/sgserverlistlayer.plist", RES_TYPE_LAYER_UI, sg_welComeLayer); CCUserDefault* ccud = CCUserDefault::sharedUserDefault(); std::string localResVer = ccud->getStringForKey(SGUM_LOCAL_RES_VER_KEY); float fontSize = 8.0f; CCLabelTTF *version = CCLabelTTF::create(CCString::createWithFormat("V%s.%s", BUNDLE_VERSION,localResVer.c_str())->getCString(), FONT_PENGYOU, FONTSIZE(fontSize)); version->setPosition(ccpAdd(SGLayout::getPoint(kBottomRight), ccp( -version->getContentSize().width * 0.6f, version->getContentSize().height * 0.5))); version->setColor(ccGREEN); this->addChild(version, 99999); //this->setTouchEnabled(true); //removed by cgp CCPoint center = SGLayout::getPoint(kMiddleCenter); ResourceManager::sharedInstance()->bindTexture("sanguobigpic/logo.plist", RES_TYPE_LAYER_UI, sg_welComeLayer); ResourceManager::sharedInstance()->bindTexture("sanguobigpic/login_ip5.plist", RES_TYPE_LAYER_UI, sg_welComeLayer); //removed by cgp for welcomelayer // logo = CCSprite::createWithSpriteFrameName("logo.png"); // this->addChild(logo,10); CCSprite *bg = CCSprite::createWithSpriteFrameName("login_ip5.png"); bg->setScaleY(CCDirector::sharedDirector()->getWinSize().height / bg->getContentSize().height); bg->setScaleX(CCDirector::sharedDirector()->getWinSize().width / bg->getContentSize().width); this->addChild(bg,-1); bg->setPosition(center); //logo->setPosition(ccpAdd(center, ccp(0, bg->getContentSize().height * 0.11))); CCSize winSize = CCDirector::sharedDirector()->getWinSize(); //m_blackColor = CCLayerColor::create(ccc4(0, 0, 0, 0), winSize.width, winSize.height); //m_blackColor = CCLayerColor::create(ccc4(0, 0, 0, 180), winSize.width, winSize.height); // m_blackColor->setTouchEnabled(false); // m_blackColor->setPosition(0,0); // SGButton *login_start = SGButton::createFromLocal("login_start.png", "", this, NULL, CCPointZero, FONT_BOXINFO, ccRED, 26, false, true); // this->addChild(login_start , 21); // login_start->setPosition(ccpAdd(SGLayout::getPoint(kBottomCenter), ccp(0, screenheight * 0.2))); // login_start->setTag(1); // login_start->runAction(CCRepeatForever::create(CCBlink::create(1.5, 1))); // EFFECT_PLAY(MUSIC_BTN); CCUserDefault::sharedUserDefault()->setBoolForKey("pvp_tran",false);//每次登入时取消pvp登入状态 SGStaticDataManager::shareStatic()->getOfficerById(1001); //added by cgp for battle of officer table loginstart(); }