void MPLoadMap::seedFromFile( const char* pFileName )
{
	FullPathFileName path;
	path.init( missionPath, pFileName, ".csv" );

	CSVFile file;
	if ( NO_ERR != file.open( path ) )
	{
		Assert( 0, 0, "couldn't open multiplayer mission .csv file" );
		return;
	}

	int i = 1; 
	char fileName[255];
	while( true )
	{
		if ( NO_ERR != file.readString( i, 1, fileName, 255 ) )
			break;

		path.init( missionPath, fileName, ".fit" );
		if ( fileExists( path ) )
		{		
			addFile( fileName, false );
		}

		i++;
	}
}
Exemple #2
0
void ShareGM::parseData()
{
	if (m_dataMap.size()>0)
	{
		return;
	}

	CSVFile* file = (CSVFile*)FileUtils::sharedFileUtils()->loadCSVFile(CSV_ROOT("shareFb.csv"));
	if(!file)
	{
		return;
	}
	int row = file->getRowNum();
	for(int i = 1; i < row; ++i)
	{
		int id = atoi(file->get(i,0));		
		ShareMap::iterator iter = m_dataMap.find(id);
		if(iter != m_dataMap.end())
		{
			delete iter->second;
			m_dataMap.erase(iter);
		}
		ShareData* cfg = new ShareData();
		cfg->id = id;
		cfg->desc = file->get(i,1);
		cfg->url = file->get(i,2);
		m_dataMap[id] = cfg;
	}
	FileUtils::sharedFileUtils()->releaseFile(CSV_ROOT("shareFb.csv"));
}
void CSVConverter::convertColon(const QString& filename)
{
    CSVFile file;
    if (!file.read(filename))
    {
        return;
    }

    // skip header line
    file.parseNextLine();
    while (!file.atEnd())
    {
        QList<QVariant> data = file.parseNextLine();
        if (data.size() < 10 || data.first().toString().isEmpty())
            continue;
        Patient pat;
        pat.surname = data[0].toString();
        pat.firstName = data[1].toString();
        pat.dateOfBirth = data[2].toDate();
        pat.gender = (data[3].toInt() == 1) ? Patient::Male : Patient::Female;
        QList<Patient::Ptr> ps = PatientManager::instance()->findPatients(pat);
        if (!ps.isEmpty())
        {
            continue;
        }
    }
}
void CSVConverter::readTNM(const QString& filename)
{
    CSVFile file;
    if (!file.read(filename))
    {
        return;
    }

    while (!file.atEnd())
    {
        QList<QVariant> data = file.parseNextLine();
        if (data.size() < 4 || data.first().toString().isEmpty())
        {
            qDebug() << "TNM Reader: Invalid line" << data;
            continue;
        }
        Patient pat;
        pat.surname = data[0].toString();
        pat.firstName = data[1].toString();
        pat.dateOfBirth = data[2].toDate();
        pat.gender = Patient::UnknownGender;
        QList<Patient::Ptr> ps = PatientManager::instance()->findPatients(pat);
        if (ps.isEmpty())
        {
            qDebug() << "TNM Reader: Patient not found" << pat.surname << pat.firstName << pat.dateOfBirth;
            continue;
        }
        Patient::Ptr p = ps.first();
        if (p->diseases.isEmpty())
        {
            qDebug() << "TNM Reader: Patient"<< pat.surname << pat.firstName << pat.dateOfBirth << "has no disease";
        }
        if (p->diseases.size() > 1)
        {
            qDebug() << "TNM Reader: Patient"<< pat.surname << pat.firstName << pat.dateOfBirth << "has multiple diseases, taking first";
        }
        Disease& dis = p->firstDisease();
        dis.initialTNM.setTNM(data[3].toString());
        //PatientManager::instance()->updateData(p, PatientManager::ChangedDiseaseMetadata);
    }
}
Exemple #5
0
	void LoadScene::loadResouceEnd()
	{
		CSVFile* tFine = (CSVFile*)FileUtils::sharedFileUtils()->getFile(CSV_ROOT("preloadRes.csv"));
		if (mAsynLoadNum < mResourceVec.size() && mCurrIndex < (tFine->getRowNum() + 600))		//当预加载10秒后还没跳转界面则执行强制跳转处理
			return ;
		if (mCurrIndex >= (tFine->getRowNum() + 600))
			CCLOG("[ *ERROR ] LoadScene::loadResouceEnd");
		for (int i=0; i<mResourceVec.size();++i)
		{
			LoadResourceInfo &res = mResourceVec.at(i);
			if (res.Loadtype>sLoadType::eEffect)
				continue;
			CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(res.FilePath.c_str());//将plist文件加载进入缓存
			CCLOG("ProgressEnd addSpriteFramesWithFile mode1 %s ",res.FileName.c_str());
			if(res.Loadtype == sLoadType::eFrameAnimation)
				AnimationManager::sharedAction()->ParseAnimation(res.FileName.c_str(),eFrameRole);
			else if(res.Loadtype == sLoadType::eEffect)
				AnimationManager::sharedAction()->ParseAnimation(res.FileName.c_str());
		}
		this->unscheduleAllSelectors();
		CSceneManager::sharedSceneManager()->replaceScene(GETSCENE(CMainScene), 1.0f);
	}
Exemple #6
0
//---------------------------------------------------------------------------------
void WeaponEffects::init (char *effectCSVFileName)
{
	FullPathFileName effectsName;
	effectsName.init(objectPath,effectCSVFileName,".csv");
	
	CSVFile effectFile;
	long result = effectFile.open(effectsName);
	if (result != NO_ERR)
		STOP(("Unable to open Effects File %s",effectsName));
		
	numEffects = effectFile.getNumLines() - 1;	//Always subtract one for the column headers

	effects = (EffectData *)systemHeap->Malloc(sizeof(EffectData) * numEffects);
	gosASSERT(effects != NULL);
	
	for (long i=0;i<numEffects;i++)
	{
		effectFile.readString(i+2,2,effects[i].effectName,49);
		effectFile.readString(i+2,3,effects[i].muzzleFlashName,49);
		effectFile.readString(i+2,4,effects[i].hitEffectName,49);
		effectFile.readString(i+2,6,effects[i].missEffectName,49);
		effectFile.readLong(i+2,5,effects[i].effectObjNum);
	}
}
Exemple #7
0
	void LoadScene::loadResource(float fdetal)
	{
		CSVFile* tFile = (CSVFile*)FileUtils::sharedFileUtils()->getFile(CSV_ROOT("preloadRes.csv"));
		switch( atoi(tFile->get(mCurrIndex+1,0)) )
		{
		case LOAD_RES_MODEL:
			{
				//先判断是角色还是特效然后判断是否需要加载plist文件进缓存
				string str = tFile->get(mCurrIndex+1,1);
				int pos = str.find("plist");
				if (pos != string::npos)
				{
					string pngStr = str.substr(0,pos);
					pngStr = pngStr.append("png");
					CCTextureCache::sharedTextureCache()->addImageAsync(pngStr.c_str(),this,callfuncO_selector(LoadScene::loadAsyncImg));
					LoadResourceInfo tRes;
					tRes.FilePath = tFile->get(mCurrIndex+1,1);
					tRes.FileName = tFile->get(mCurrIndex+1,2);
					tRes.Loadtype = sLoadType::eEffect;
					mResourceVec.push_back(tRes);
				}
			}break;
		case LOAD_BACKGROUND_SND:
			{
				char str[30]={0};
#if BATTLE_TEST
				sprintf(str,"BGM/Test/%d.mp3",atoi(tFile->get(mCurrIndex+1,1)));
#else
				sprintf(str,"BGM/%d.ogg",atoi(tFile->get(mCurrIndex+1,1)));
#endif
				CCLOG("Load BGM %s",tFile->get(mCurrIndex+1,1));
				SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic(tFile->get(mCurrIndex+1,1));
			}break;
		case LOAD_EFFECT_SND:
			{
				char str[30]={0};
#if BATTLE_TEST
				sprintf(str,"SFX/Test/%d.mp3",atoi(tFile->get(mCurrIndex+1,1)));
#else
				sprintf(str,"SFX/%d.ogg",atoi(tFile->get(mCurrIndex+1,1)));
#endif
				CCLOG("Load SFX %s",tFile->get(mCurrIndex+1,1));
				SimpleAudioEngine::sharedEngine()->preloadEffect(tFile->get(mCurrIndex+1,1));
			}break;
		}
		++mCurrIndex;
		float tPercent = mCurrIndex*100.0f/(tFile->getRowNum() + 20);			//20是跑空帧
		mProgress->setValue(tPercent);		//进度条
		m_pZombieSprite->setPositionX(mProgress->getPositionX()+mProgress->getContentSize().width*(tPercent>100?100.0f:tPercent)/100-5);		//僵尸位置
		if (tPercent >= 100)
			loadResouceEnd();
	}
void Pilot::initPilots()
{
	CSVFile file;

	char path[256];
	strcpy( path, objectPath );
	strcat( path, "pilots.csv" );

	if ( NO_ERR != file.open( path ) )
	{
		STOP(( "couldn't find pilots.csv file" ));
		return;
	}

	char pilotFileName[256];
	strcpy(pilotFileName, "");

	PilotInfo* infos = s_GoodPilots;
	long* counter = &goodCount;

	for ( int i = 0; i < 2; i++ )
	{
		while( true )
		{
			int bytesRead = file.readLine( (BYTE*)pilotFileName, 256 );

			if ( bytesRead < 2 )
				break;

			CString postFix;
			if (0 == i)
			{
				if ((strlen(pilotFileName) > strlen("pmw"))
					&& (0 == strnicmp(pilotFileName, "pmw", strlen("pmw"))))
				{
					/*Good pilots that start with "pmw" are single-player pilots.*/
					CString tmpStr;
					tmpStr.LoadString(IDS_PILOT_SINGLE_PLAYER_VERSION);
					postFix = tmpStr.GetBuffer(0);
				}
				else if ((strlen(pilotFileName) > strlen("pmp_"))
					&& (0 == strnicmp(pilotFileName, "pmp_", strlen("pmp_"))))
				{
					/*Good pilots that start with "pmp_" are multi-player pilots.*/
					CString tmpStr;
					tmpStr.LoadString(IDS_PILOT_MULTIPLAYER_VERSION);
					postFix = tmpStr.GetBuffer(0);
				}
			}

			FitIniFile pilotFile;
			FullPathFileName tmpPath;
			tmpPath.init(warriorPath,pilotFileName,".fit");

			if ( NO_ERR != pilotFile.open( tmpPath ) )
			{
				char errorString[256];
				sprintf( errorString, "Couldn't open file %s", tmpPath);
				Assert( 0, 0, errorString );
				return;
			}

			infos[*counter].fileName = new char[strlen( pilotFileName ) + 1];
			strcpy( infos[*counter].fileName, pilotFileName );

			// if we got this far we have a file, make a pilot
			int result = pilotFile.seekBlock( "General" );
			gosASSERT( result == 0 );

			long tmp;
			result = pilotFile.readIdLong( "descIndex", tmp );
			gosASSERT( result == NO_ERR );

			cLoadString( tmp, pilotFileName, 64);
			strcat(pilotFileName, "  ");
			strncat(pilotFileName, postFix.GetBuffer(0), 64);

			infos[*counter].name = new char[strlen( pilotFileName  ) +1];
			strcpy( infos[*counter].name, pilotFileName );
			
			(*counter)++;

			if ( goodCount > MAX_PILOT )
				return;
		}

		file.close();
		FullPathFileName path;
		path.init(objectPath,"BadPilots",".csv");

		if ( NO_ERR != file.open( path ) )
		{
			STOP(( "couldn't find BadPilots.csv file" ));
			return;
		}

		infos = s_BadPilots;
		counter = &badCount;

	}
}
void CSVConverter::convertBestRx(const QString& filename)
{
    CSVFile file;
    if (!file.read(filename))
    {
        return;
    }

    // skip header line
    file.parseNextLine();
    while (!file.atEnd())
    {
        QList<QVariant> data = file.parseNextLine();
        if (data.size() < 40 || data.first().toString().isEmpty())
            continue;
        Patient pat;
        QStringList names = data[0].toString().split(',', QString::SkipEmptyParts);
        if (names.size() != 2)
        {
            qDebug() << "Failed to parse" << data[0];
            continue;
        }
        pat.surname = names.first().trimmed();
        pat.firstName = names.last().trimmed();
        pat.dateOfBirth = data[5].toDate();
        pat.gender = (data[10].toString() == "M") ? Patient::Male : Patient::Female;
        if (!pat.isValid())
        {
            qDebug() << "invalid patient" << pat.surname;
            continue;
        }

        QString entity = data[7].toString();
        Pathology path;

        path.context = PathologyContextInfo(PathologyContextInfo::BestRx).id;
        path.entity  = Pathology::Breast;
        QDate date;
        QList<int> fields;
        fields << 17 << 21 << 25;
        foreach (int f, fields)
        {
            if (data[f].isValid() && data[f].type() == QVariant::Date)
            {
                path.date = data[f].toDate();
                break;
            }
        }
        if (!path.date.isValid())
        {
            qDebug() << "Pathology date not available" << pat.surname;
            //continue;
        }

        QString sampleOrigin = data[35].toString();
        if (sampleOrigin.contains("Primär") || sampleOrigin.contains("Zytologie"))
        {
            path.sampleOrigin = Pathology::Primary;
        }
        else if (sampleOrigin == "LK")
        {
            path.sampleOrigin = Pathology::LocalLymphNode;
        }
        else if (sampleOrigin.contains("Metastase"))
        {
            path.sampleOrigin = Pathology::Metastasis;
        }
        else
        {
            qDebug() << "Unhandled sampleOrigin" << sampleOrigin;
        }

        // FGFR1
        if (data[23].toString().contains("amplified", Qt::CaseInsensitive))
        {
            bool fgfr1Amplified = data[18].toString() == "Amplified";
            path.properties << toProperty(PathologyPropertyInfo::Fish_FGFR1, fgfr1Amplified);
        }

        // PIK3Ca mut.
        if (data[22].toString().contains("Wild Type") || data[22].toString().contains("Mutant"))
        {
            bool pik3mutant = data[22].toString().contains("Mutant");
            QString mutation;
            if (pik3mutant)
            {
                mutation = data[22].toString().remove("Mutant").trimmed();
            }
            path.properties << toProperty(PathologyPropertyInfo::Mut_PIK3CA_10_21, pik3mutant, mutation);
        }

        // PIK3ca Ampl.
        if (data[23].toString().contains("Amplified", Qt::CaseInsensitive))
        {
            bool pik3Amplified = data[23].toString() == "Amplified";
            path.properties << toProperty(PathologyPropertyInfo::Fish_PIK3CA, pik3Amplified);
        }

        // PTEN
        if (data[29].toString().contains("PTEN staining", Qt::CaseInsensitive))
        {
            bool ptenLoss = data[29].toString().contains("PTEN loss");
            path.properties << toProperty(PathologyPropertyInfo::IHC_PTEN, !ptenLoss);
        }

        // ER, PR, Her2
        if (data[36].toString() == "+" || data[36].toString() == "-")
        {
            bool er = data[36].toString() == "+";
            path.properties << toProperty(PathologyPropertyInfo::IHC_ER, er);
        }
        if (data[37].toString() == "+" || data[37].toString() == "-")
        {
            bool pr = data[37].toString() == "+";
            path.properties << toProperty(PathologyPropertyInfo::IHC_PR, pr);
        }
        if (data[38].toString().contains("+") || data[38].toString() == "0")
        {
            int her2ihc = data[38].toString().remove("+").toInt();
            path.properties << toProperty(PathologyPropertyInfo::IHC_HER2_DAKO, her2ihc);
        }
        if (data[39].toString().contains("amplified", Qt::CaseInsensitive))
        {
            bool her2fish = data[39].toString() == "amplified";
            path.properties << toProperty(PathologyPropertyInfo::Fish_HER2, her2fish);
        }

        /*qDebug() << pat.surname << pat.firstName;
        foreach (const Property& prop, path.properties)
        {
            PathologyPropertyInfo info = PathologyPropertyInfo::info(prop.property);
            ValueTypeCategoryInfo catInfo(info);
            qDebug() << info.label << catInfo.toString(catInfo.toValue(prop.value)) << prop.detail;
        }*/

        QList<Patient::Ptr> ps = PatientManager::instance()->findPatients(pat);
        Patient::Ptr p;
        if (ps.isEmpty())
        {
            p = PatientManager::instance()->addPatient(pat);
        }
        else
        {
            p = ps.first();
        }

        if (!p->hasDisease())
        {
            p->diseases << Disease();
        }
        p->diseases.first().pathologies << path;
        if (!p->diseases.first().initialDiagnosis.isValid())
        {
            bool ok;
            int year = data[31].toInt(&ok);
            if (ok)
            {
                p->diseases.first().initialDiagnosis = QDate(year, 1, 1);
            }
        }

        PatientManager::instance()->updateData(p,
                                               PatientManager::ChangedPathologyData |
                                               PatientManager::ChangedDiseaseMetadata |
                                               PatientManager::ChangedPatientProperties);
    }
}
void CSVConverter::convertBGJ389(const QString& filename)
{
    CSVFile file;
    if (!file.read(filename))
    {
        return;
    }

    // skip header line
    file.parseNextLine();
    while (!file.atEnd())
    {
        QList<QVariant> data = file.parseNextLine();
        if (data.size() < 10 || data.first().type() != QVariant::Int)
            continue;
        Patient pat;
        pat.surname = data[2].toString();
        pat.firstName = data[3].toString();
        pat.dateOfBirth = data[5].toDate();
        pat.gender = (data[4].toString() == "m") ? Patient::Male : Patient::Female;
        if (!pat.isValid())
        {
            qDebug() << "invalid patient" << pat.surname;
            continue;
        }

        QString entity = data[7].toString();
        Pathology path;

        path.context = PathologyContextInfo(PathologyContextInfo::ScreeningBGJ398).id;

        if (entity == "NSCLC")
            path.entity = Pathology::PulmonarySquamous;
        else if (entity == "Mamma")
            path.entity = Pathology::Breast;
        else if (entity == "Bladder")
            path.entity = Pathology::TransitionalCell;
        else
        {
            qDebug() << "Unhandled entity" << entity;
            continue;
        }

        QString sampleOrigin = data[10].toString();
        if (sampleOrigin == "Primär")
        {
            path.sampleOrigin = Pathology::Primary;
        }
        else if (sampleOrigin == "LK")
        {
            path.sampleOrigin = Pathology::LocalLymphNode;
        }
        else if (sampleOrigin.contains("Metastase"))
        {
            path.sampleOrigin = Pathology::Metastasis;
        }
        else
        {
            qDebug() << "Unhandled sampleOrigin" << sampleOrigin;
            continue;
        }

        QString result = data[15].toString();

        bool hasAmplification;
        if (result.contains("neg"))
        {
            hasAmplification = false;
        }
        else if (result.contains("pos"))
        {
            hasAmplification = true;
        }
        else // "NA"
        {
            qDebug() << "invalid result" << result;
            continue;
        }

        Property prop;
        PathologyPropertyInfo info(PathologyPropertyInfo::Fish_FGFR1);
        ValueTypeCategoryInfo catInfo(info.valueType);
        prop.property = info.id;
        prop.value = catInfo.toPropertyValue(hasAmplification);
        path.properties << prop;

        //qDebug() << pat.surname << path.entity << path.sampleOrigin << hasAmplification;

        QList<Patient::Ptr> ps = PatientManager::instance()->findPatients(pat);
        Patient::Ptr p;
        if (ps.isEmpty())
        {
            p = PatientManager::instance()->addPatient(pat);
        }
        else
        {
            p = ps.first();
        }

        if (!p->hasDisease())
        {
            p->diseases << Disease();
        }
        p->diseases.first().pathologies << path;

        PatientManager::instance()->updateData(p,
                                               PatientManager::ChangedPathologyData |
                                               PatientManager::ChangedDiseaseMetadata |
                                               PatientManager::ChangedPatientProperties);
    }
}