// // internal functions // bool NotificationCenter::observerExisted(Object *target,const char *name) { Object* obj = NULL; CCARRAY_FOREACH(_observers, obj) { NotificationObserver* observer = (NotificationObserver*) obj; if (!observer) continue; if (!strcmp(observer->getName(),name) && observer->getTarget() == target) return true; }
// // internal functions // bool __NotificationCenter::observerExisted(Ref *target, const std::string& name, Ref *sender) { Ref* obj = nullptr; CCARRAY_FOREACH(_observers, obj) { NotificationObserver* observer = (NotificationObserver*) obj; if (!observer) continue; if (observer->getName() == name && observer->getTarget() == target && observer->getSender() == sender) return true; }
void CommonNotify::_onNotification(CCObject* object) { CCLOG("CommonNotify::_onNotification"); NotificationObserver* observer = (NotificationObserver*)object; string name(observer->getName()); if (name == kVCLevelUp) { if(UserProxy::shared()->userVO.level > UserProxy::shared()->mLastUserVO.level) { FRAMEWORK->popup("LevelUpDialog"); } } else if(name == kVCBuyMoney) { FRAMEWORK->popup("BuyMoneyDialog"); } else if (name == kNCVersionError) { AlertDialog::initContent(gls("185"), true, this, callfunc_selector(CommonNotify::_forceUpgrade)); FRAMEWORK->popup("AlertDialog"); } else if(name == kNCNetError) { NetError* netError = (NetError*)observer->getObject(); if(netError->errorCode == kNCErrorMoney) { if(netError->cmdName == kNCBuyEnergy) { FRAMEWORK->popup("BuyMoneyDialog"); } else { AlertDialog::initContent(gls("145")); FRAMEWORK->popup("AlertDialog"); } } else if(netError->errorCode == kNCErrorReceipt) { if(netError->cmdName == kNCBuyMoney) { FloatText::shared()->playAnim(gls("201")); } } else if(netError->errorCode == kNCErrorCoin) { AlertDialog::initContent(gls("146")); FRAMEWORK->popup("AlertDialog"); } else if(netError->errorCode == kNCErrorFreeTime) { AlertDialog::initContent(gls("147")); FRAMEWORK->popup("AlertDialog"); } else if(netError->errorCode == kNCErrorEnergyFull) { AlertDialog::initContent(gls("162")); FRAMEWORK->popup("AlertDialog"); } else if(netError->errorCode == kNCErrorEnergy) { AlertTitleDialog::initContent(gls("182"), fls("183", StaticShop::shared()->getSupplyCostCount(SUPPLY_TYPE_ENERGY)), false, this, callfunc_selector(CommonNotify::_buyEnergy), NULL, NULL, gls("133")); FRAMEWORK->popup("AlertTitleDialog"); } else if(netError->errorCode == kNCErrorLife) { int cost = StaticShop::shared()->getSupplyCostCount(SUPPLY_TYPE_LIFE); AlertDialog::initContent(fls("188",cost), false,this, callfunc_selector(CommonNotify::_buyLife)); FRAMEWORK->popup("AlertDialog"); } else if(netError->errorCode == kNCErrorBagFull) { AlertDialog::initContent(gls("190")); FRAMEWORK->popup("AlertDialog"); } else if(netError->errorCode == kNCErrorIntenfityLack) { xmlBuy& buyFusion = StaticShop::shared()->mBuyFusion[1]; AlertTitleDialog::initContent( gls("213"), fls("214", buyFusion.money, buyFusion.count), false, this, callfunc_selector(CommonNotify::_buyFusion), NULL, NULL, gls("133")); FRAMEWORK->popup("AlertTitleDialog"); } else { AlertDialog::initContent(fls("160",netError->cmdName.c_str(), netError->errorCode)); FRAMEWORK->popup("AlertDialog"); } } else if(name == kVCSellEquip) { AlertDialog::initContent(gls("170"), false, this, callfunc_selector(CommonNotify::_sellItem)); FRAMEWORK->popup("AlertDialog"); } else if(name == kNCSellEquipage) { FloatText::shared()->playAnim(gls("197")); } }