bool PaymentTstoreCommand::handleRecieve(cocos2d::CCDictionary *dict) { if (dict->valueForKey("cmd")->compare(PAYMENT_TSTORE_COMMAND) != 0) return false; PayController::getInstance()->setGoldExchangeSaleBoughtFlag(m_itemId, false); CCDictionary *params = _dict(dict->objectForKey("params")); if (m_orderId.compare(params->valueForKey("orderId")->getCString()) != 0) { return false; } if (params->objectForKey("errorCode")) { callFail(NetResult::createWithFail(params)); return true; } int status = params->valueForKey("status")->intValue(); if(CCCommonUtils::payParseData(params)) { auto ret = CCDictionary::create(); ret->setObject(CCInteger::create(status), "status"); ret->setObject(CCString::create(m_orderId), "orderId"); callSuccess(NetResult::createWithSuccess(ret)); } return true; }
void TroopInfoPanel::onCallBackClick(cocos2d::CCObject *pSender, Control::EventType pCCControlEvent){ //getButton(2)->setEnabled(false); SoundController::sharedSound()->playEffects(Music_Sfx_click_button); auto &marchInfos = WorldController::getInstance()->m_marchInfo; auto it = marchInfos.find(m_marchId); if (it == marchInfos.end()) { return; } auto &info = it->second; if (info.stateType == StateOccupy) { auto dict = CCDictionary::create(); dict->setObject(CCString::create(info.uuid), "marchId"); WorldMapView::instance()->afterMarchCancel(dict); }else if (info.marchType == MethodRally){ auto dict = CCDictionary::create(); dict->setObject(CCString::create(info.uuid), "marchId"); PopupViewController::getInstance()->addPopupInView(UseToolView::create(USE_TOOL_MARCH_CANCEL_RALLY,dict)); }else { auto dict = CCDictionary::create(); dict->setObject(CCString::create(info.uuid), "marchId"); PopupViewController::getInstance()->addPopupInView(UseToolView::create(USE_TOOL_MARCH_CANCEL,dict)); } this->closeThis(); }
void StatusPush::handleResponse(__Dictionary* dict) { if (!dict) { return; } __Dictionary* params = _dict(dict->objectForKey("params")); if (params->objectForKey("oldStatus")) {//删除该状态的作用 int reStatusId = params->valueForKey("oldStatus")->intValue(); if (GlobalData::shared()->statusMap.find(reStatusId) != GlobalData::shared()->statusMap.end()) { GlobalData::shared()->statusMap[reStatusId] = 0; } } // int tempTime = 0; if (params->objectForKey("effectState")) { auto stateDict = _dict(params->objectForKey("effectState")); CCDictElement* element; CCDICT_FOREACH(stateDict, element) { string key = element->getStrKey(); // int effectId = atoi(key.c_str()); double time = stateDict->valueForKey(key)->doubleValue()/1000; if (time>0) { time = GlobalData::shared()->changeTime(time); } if (key!="startTime") { GlobalData::shared()->statusMap[atoi(key.c_str())] = -1;//time; // tempTime = time; } map<int, CCDictionary* >::iterator it = ToolController::getInstance()->m_statusItems.find(100); CCObject* obj = element->getObject(); CCString* str = (CCString*)obj; if(it!=ToolController::getInstance()->m_statusItems.end()){ auto dic = it->second; if(!dic->objectForKey("startTime")){ dic->setObject(CCString::create(CC_ITOA(WorldController::getInstance()->getTime())), "startTime"); }else if(key!="" && key!="startTime"){ dic->setObject(CCString::create(str->getCString()), "endTime"); }else if(key=="startTime"){ dic->setObject(CCString::create(str->getCString()), "startTime"); } ToolController::getInstance()->m_statusItems[100] = dic; }else{ auto infoDic = CCDictionary::create(); infoDic->retain(); if(key!="" && key!="startTime"){ infoDic->setObject(CCString::create(str->getCString()), "endTime"); }else if(key=="startTime"){ infoDic->setObject(CCString::create(str->getCString()), "startTime"); } ToolController::getInstance()->m_statusItems[100] = infoDic; } ToolController::getInstance()->checkMaincityCustom(); }
bool AllianceLeaderTransCommand::handleRecieve(cocos2d::CCDictionary *dict) { if (dict->valueForKey("cmd")->compare(ALLIANCE_AL_LEADER_TRANS) != 0) return false; CCDictionary *params=_dict(dict->objectForKey("params")); if (!params) { return false; } const CCString *pStr = params->valueForKey("errorCode"); if (pStr->compare("")!=0) { CCCommonUtils::flyText(pStr->getCString()); }else{ CCDictionary *alliance=_dict(params->objectForKey("alliance")); GlobalData::shared()->playerInfo.allianceInfo.updateAllianceInfo(alliance); std::string playerId = params->valueForKey("oldLeaderId")->getCString(); int oldRank = params->valueForKey("oldLeaderRank")->intValue(); auto dic = CCDictionary::create(); dic->setObject(CCString::create(CC_ITOA(oldRank)), "rank"); dic->setObject(CCString::create(playerId.c_str()), "playerId"); CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(MSG_ALLIANCE_LEADER_CHANGE,dic); callSuccess(NetResult::create(Error_OK, params)); } return true; }
void HelloWorld:: testDic(){ //打印字符串 std::string a="ddddd"; log("a=%s",a.c_str()); char b[10]; log("%lu",sizeof(b)); //拼接 int i=20; sprintf(b, "%d.png",i); printf("%s",b); auto pDic=__Dictionary::create(); auto pValue1=__String::create("100"); auto pValue2=__String::create("120"); auto pValue3=__Integer::create(200); pDic->setObject(pValue1, "key1"); pDic->setObject(pValue2, "key2"); pDic->setObject(pValue3, "key3"); auto pStr1=(__String *)pDic->objectForKey("key1"); log("{key1:%s}",pStr1->getCString()); auto pInteger=(__Integer*)pDic->objectForKey("key3"); log("{key3:%d}",pInteger->getValue()); auto name=__String::create("zhangsan"); auto pass=__String::create("password"); auto dic=__Dictionary::create(); dic->setObject(name, "NAME"); dic->setObject(pass, "PWD"); }
void BlankTile::confirmed(CCObject* obj){ auto dict = CCDictionary::create(); dict->setObject(CCString::createWithFormat("%d",0), "point"); auto& info = ToolController::getInstance()->getToolInfoById(ITEM_NEW_BEGINNER_MOVE); if (info.getCNT() > 0) { dict->setObject(CCString::create(info.uuid), "goodsId"); if (GlobalData::shared()->trans_res_forbidden_swith == 1) { bool flag = ActivityController::getInstance()->checkServerCanJoin(GlobalData::shared()->playerInfo.currentServerId); if (!flag && (GlobalData::shared()->resourceInfo.lFood > GlobalData::shared()->trans_res_limit || GlobalData::shared()->resourceInfo.lWood > GlobalData::shared()->trans_res_limit)) { CCCallFuncO* fun = CCCallFuncO::create(this, callfuncO_selector(BlankTile::alertShow), dict); YesNoDialog::marchAlertShow(_lang_1("104959", CC_ITOA(GlobalData::shared()->trans_res_limit)), fun, NULL); } else { WorldMapView::instance()->afterCrossCityMove(dict); this->closeSelf(); } } else { WorldMapView::instance()->afterCrossCityMove(dict); this->closeSelf(); } } else { closeSelf(); } return; }
bool PythonQtObjectPtr::fromVariant(const QVariant& variant) { if (!variant.isNull()) { setObject(qVariantValue<PythonQtObjectPtr>(variant)); return true; } else { setObject(0); return false; } }
bool OSDictionary::initWithObjects(const OSObject *objects[], const OSSymbol *keys[], unsigned int theCount, unsigned int theCapacity) { unsigned int newCapacity = theCount; if (!objects || !keys) return false; if ( theCapacity ) { if (theCount > theCapacity) return false; newCapacity = theCapacity; } if (!initWithCapacity(newCapacity)) return false; for (unsigned int i = 0; i < theCount; i++) { const OSMetaClassBase *newObject = *objects++; if (!newObject || !keys[i] || !setObject(keys[i], newObject)) return false; } return true; }
Rectangle::Rectangle( const Falcon::CoreClass* gen, const GdkRectangle* rect ) : Gtk::VoidObject( gen ) { if ( rect ) setObject( rect ); }
void ArrayIter::objInit(ObjectData *obj) { assert(obj); setObject(obj); if (incRef) { obj->incRefCount(); } if (!obj->isCollection()) { assert(obj->o_instanceof(s_Iterator)); obj->o_invoke(s_rewind, Array()); } else { if (hasVector()) { c_Vector* vec = getVector(); m_versionNumber = vec->getVersionNumber(); m_pos = 0; } else if (hasMap()) { c_Map* mp = getMap(); m_versionNumber = mp->getVersionNumber(); m_pos = mp->iter_begin(); } else if (hasStableMap()) { c_StableMap* smp = getStableMap(); m_versionNumber = smp->getVersionNumber(); m_pos = smp->iter_begin(); } else { assert(false); } } }
WebGLShader::WebGLShader(WebGLRenderingContext* ctx, GC3Denum type) : WebGLSharedObject(ctx) , m_type(type) , m_source("") { setObject(ctx->graphicsContext3D()->createShader(type)); }
WebGLRenderbuffer::WebGLRenderbuffer(WebGLRenderingContext* ctx) : WebGLObject(ctx) , m_internalFormat(GraphicsContext3D::RGBA4) , m_initialized(false) { setObject(context()->graphicsContext3D()->createRenderbuffer()); }
bool OSSet::initWithObjects(const OSObject *inObjects[], unsigned int inCount, unsigned int inCapacity) { unsigned int capacity = inCount; if ( inCapacity ) { if ( inCount > inCapacity ) return false; capacity = inCapacity; } if (!inObjects || !initWithCapacity(capacity)) return false; for ( unsigned int i = 0; i < inCount; i++ ) { // xx-review: no test here for failure of setObject() if (members->getCount() < inCapacity) setObject(inObjects[i]); else return false; } return true; }
void FacebookInviteView::delayShowData(float t){ if( !getParent() ) return; CCCommonUtils::flyHint("", "", _lang("105552")); m_data->removeAllObjects(); int result = CCUserDefault::sharedUserDefault()->getIntegerForKey(FB_RequestResult, -1); //1成功 2错误 3取消 if(true){//result==1 int num = m_srcData->count(); for (int i=0; i<num; i++) { auto dic = _dict(m_srcData->objectAtIndex(i)); if (dic!=NULL) { string flag = dic->valueForKey("flag")->getCString(); if (flag=="0") { if(m_data->count()>=50){ break; } dic->setObject(CCString::create("1"), "flag"); m_data->addObject(dic); } } } if(m_inviteNum!=0){ CCArray* p = CCArray::create(); p->addObject(CCInteger::create(m_inviteNum)); CCArray* d = CCArray::create(); DataRecordCommand *cmd = new DataRecordCommand(FB_INVITE_FRIEND, p, d); cmd->sendAndRelease(); } m_tip->setVisible(m_data->count()<=0); } m_tabView->reloadData(); }
WebGLBuffer::WebGLBuffer(WebGLRenderingContext* ctx) : WebGLSharedObject(ctx) , m_target(0) { ScriptWrappable::init(this); setObject(ctx->graphicsContext3D()->createBuffer()); }
//============================================================================= // METHOD : SPELLwsListDataHandler::read() //============================================================================= void SPELLwsListDataHandler::read() { // Load the number of items unsigned int numItems = getStorage()->loadLong(); // Create a list PyObject* listObject = PyList_New(numItems); for( unsigned int index = 0; index < numItems; index++) { // Load the item code SPELLwsData::Code code = loadDataCode(); // Create an appropriate handler SPELLwsDataHandler* handler = SPELLwsDataHandlerFactory::createDataHandler(code); handler->setStorage(getStorage()); // Read the data handler->read(); // Add the item to the list PyList_SetItem(listObject, index, handler->getObject()); delete handler; } // Set it as associated object setObject( listObject ); }
//============================================================================= // METHOD : SPELLwsClassDataHandler::read() //============================================================================= void SPELLwsClassDataHandler::read() { // Store the class name SPELLwsObjectDataHandler nameHandler( NULL ); nameHandler.setStorage(getStorage()); SPELLwsDictDataHandler dictHandler( NULL ); dictHandler.setStorage(getStorage()); // Read the data DEBUG("[CDH] Reading name"); nameHandler.read(); DEBUG("[CDH] Name read: " + PYREPR(nameHandler.getObject())); PyObject* classObject = NULL; if ( PYSTR(nameHandler.getObject()) == "__FAILED_WS_CLASS__" ) { classObject = PyClass_New( NULL, PyDict_New(), nameHandler.getObject() ); std::string msg = "Detected failed WS class, assuming error during marshal process"; LOG_ERROR(msg); std::cerr << msg << std::endl; } else { DEBUG("[CDH] Reading dictionary"); dictHandler.read(); DEBUG("[CDH] Dictionary read: " + PYREPR(dictHandler.getObject())); // Create the class object classObject = PyClass_New( NULL, dictHandler.getObject(), nameHandler.getObject() ); } // Set it as associated object setObject( classObject ); }
void ArrayIter::objInit(ObjectData *obj, bool rewind /* = true */) { ASSERT(obj); setObject(obj); if (incRef) { obj->incRefCount(); } if (!obj->isCollection()) { ASSERT(obj->o_instanceof(s_Iterator)); if (rewind) { obj->o_invoke(s_rewind, Array()); } // If it is from IteratorAggregate, there is no need to rewind. } else { if (hasVector()) { c_Vector* vec = getVector(); m_versionNumber = vec->getVersionNumber(); m_pos = 0; } else if (hasMap()) { c_Map* mp = getMap(); m_versionNumber = mp->getVersionNumber(); m_pos = mp->iter_begin(); } else if (hasStableMap()) { c_StableMap* smp = getStableMap(); m_versionNumber = smp->getVersionNumber(); m_pos = smp->iter_begin(); } else { ASSERT(false); } } }
// Returns true on success, false on an error condition. bool OSDictionary::merge(const OSDictionary *srcDict) { const OSSymbol * sym; OSCollectionIterator * iter; if ( !OSDynamicCast(OSDictionary, srcDict) ) return false; iter = OSCollectionIterator::withCollection(const_cast<OSDictionary *>(srcDict)); if ( !iter ) return false; while ( (sym = (const OSSymbol *)iter->getNextObject()) ) { const OSMetaClassBase * obj; obj = srcDict->getObject(sym); if ( !setObject(sym, obj) ) { iter->release(); return false; } } iter->release(); return true; }
Camera::Camera(GameWorld* world) : c(glhckCameraNew()), Object(world, nullptr), Entity(world), Updatable(world) { setObject(glhckCameraGetObject(c)); }
/*! * \ru * Позиционирует указатель в БД на запись, соотвествующую объекту * с указанным идентификатором. * \param id - Идентификатор объекта. * \return возвращает код ошибки или 0 в случае успеха. * \_ru */ ERR_Code aObject::select( qulonglong id ) { aDataTable * t = table(); if ( !t ) return err_notable; setSelected (false); long otype = db->uidType( id ); // debug_message("otype=%li\n",otype); if ( !otype ) return err_objnotfound; if ( concrete && ( otype != t->getMdObjId() ) ) return err_incorrecttype; if ( !concrete ) { aCfgItem tmpObj = md->find( otype ); if ( tmpObj.isNull() ) return err_objnotfound; setObject ( tmpObj ); } if ( t->select( QString("id=%1").arg(id), false ) ) if ( t->first() ) { // t->primeUpdate(); setSelected (true); // t->printRecord(); return err_noerror; } else return err_notselected; return err_selecterror; }
WebGLFramebuffer::WebGLFramebuffer(WebGLRenderingContext* ctx) : WebGLContextObject(ctx) , m_hasEverBeenBound(false) { ScriptWrappable::init(this); setObject(ctx->graphicsContext3D()->createFramebuffer()); }
void Object::set (std::string const& k, Json::Value const& v) { auto t = v.type(); switch (t) { case Json::nullValue: return set (k, nullptr); case Json::intValue: return set (k, v.asInt()); case Json::uintValue: return set (k, v.asUInt()); case Json::realValue: return set (k, v.asDouble()); case Json::stringValue: return set (k, v.asString()); case Json::booleanValue: return set (k, v.asBool()); case Json::objectValue: { auto object = setObject (k); copyFrom (object, v); return; } case Json::arrayValue: { auto array = setArray (k); for (auto& item: v) array.append (item); return; } } assert (false); // Can't get here. }
WebGLProgram::WebGLProgram(WebGLRenderingContext* ctx) : WebGLObject(ctx) , m_linkStatus(false) , m_linkCount(0) { setObject(context()->graphicsContext3D()->createProgram()); }
//============================================================================= // METHOD : SPELLwsTimeDataHandler::read() //============================================================================= void SPELLwsTimeDataHandler::read() { // Load the number of seconds int seconds = getStorage()->loadLong(); // Load number of milliseconds int msec = getStorage()->loadLong(); // Load delta flag int delta = getStorage()->loadLong(); SPELLtime theTime; theTime.set( seconds, msec, (delta == 1) ); DEBUG("[TIMEDH] Loaded time: " + theTime.toTIMEString() ); // CREATE TIME PyObject* timeObject = SPELLpythonHelper::instance().pythonTime(theTime); if (timeObject == NULL) { THROW_EXCEPTION("Cannot load TIME", "Unable to create instance", SPELL_ERROR_WSTART); } setObject(timeObject); DEBUG("[TIMEDH] Load database items"); }
void ObjectPropertiesView::queryFinished() { if (!m_client || !m_query) return; QDeclarativeDebugObjectReference obj = m_query->object(); QDeclarativeDebugWatch *watch = m_client->addWatch(obj, this); if (watch->state() == QDeclarativeDebugWatch::Dead) { delete watch; watch = 0; } else { if (m_watch) { m_client->removeWatch(m_watch); delete m_watch; } m_watch = watch; QObject::connect(watch, SIGNAL(valueChanged(QByteArray,QVariant)), this, SLOT(valueChanged(QByteArray,QVariant))); } delete m_query; m_query = 0; setObject(obj); }
void ObjectPropertiesView::toggleGroupingByItemType() { m_groupByItemType = !m_groupByItemType; m_tree->setRootIsDecorated(m_groupByItemType); m_toggleGroupByItemTypeAction->setChecked(m_groupByItemType); setObject(m_object); }
WebGLFramebuffer::WebGLFramebuffer(WebGLRenderingContext* ctx) : WebGLContextObject(ctx) , m_hasEverBeenBound(false) , m_texTarget(0) , m_texLevel(-1) { setObject(ctx->graphicsContext3D()->createFramebuffer()); }
void JavaUpload::load(const QDomNode& map) { setObject(getXMLProperty(map, "jplugin_source")); m_nDone = getXMLProperty(map, "jplugin_done").toLongLong(); loadVars(map); Transfer::load(map); }
WebGLShader::WebGLShader(WebGLRenderingContext* ctx, GC3Denum type) : WebGLSharedObject(ctx) , m_type(type) , m_source("") { ScriptWrappable::init(this); setObject(ctx->graphicsContext3D()->createShader(type)); }