コード例 #1
0
int _SaveWorks( R& arrayt, int startNum, NrpText (*func)(int), const NrpText& fileName, const NrpText saveFolder )
{
	IniFile sv( fileName );

	for( u32 i=0; i < arrayt.size(); i++ )
	{
		NrpText myFolder = OpFileSystem::CheckEndSlash( saveFolder ) + func( startNum );
		OpFileSystem::CreateDirectory( myFolder );
		NrpText workFile = arrayt[ i ]->Save( myFolder );

		sv.Set( SECTION_WORKS, CreateKeyType( startNum ), arrayt[ i ]->ObjectTypeName() );
		sv.Set( SECTION_WORKS, CreateKeyWork( startNum ), workFile );
		startNum++;
	}

	sv.Save();

	return startNum;
}
コード例 #2
0
NrpText CNrpLaborMarket::Save( const NrpText& folderName )
{
	assert( OpFileSystem::IsExist( folderName ) );

	NrpText fileName = OpFileSystem::CheckEndSlash( folderName ) + saveTemplate;

	INrpConfig::Save( fileName );

	IniFile sv( fileName );

	for( u32 i=0; i < _users.size(); i++ )
	{
		_users[ i ]->Save( _nrpApp[ SAVEDIR_USERS ] );
		sv.Set( SECTION_USERS, CreateKeyType(i), _users[ i ]->ObjectTypeName() );
		sv.Set( SECTION_USERS, CreateKeyUser(i), (NrpText)_users[ i ]->Param( NAME ) );
	}

	sv.Save();

	return fileName;
}
コード例 #3
0
void CNrpLaborMarket::_LoadUsers( const NrpText& fileName )
{
	IniFile sv( fileName );
	int maxUser = _self[ USERNUMBER ];
	for( int i=0; i < maxUser; i++ )
	{
		NrpText name = sv.Get( SECTION_USERS, CreateKeyUser(i), NrpText("") );
		NrpText className = sv.Get( SECTION_USERS, CreateKeyType(i), NrpText("") );

		NrpText fileName = (NrpText)_nrpApp[ SAVEDIR_USERS ] + name + ".user";

		if( !OpFileSystem::IsExist( fileName ) )
		{
			assert( false && "user config file not found" );
			continue;
		}

		CNrpUser* user = NULL;
		if( className == CNrpPlayer::ClassName() ) 
			user = new CNrpPlayer( fileName );
		else
		{
			if( className == CNrpAiUser::ClassName() )
				user = new CNrpAiUser( fileName );
			else
			{
				if( className == NrpTester::ClassName() )
					user = new NrpTester( name );
				else
					user = new CNrpUser( className, name );


				user->Load( fileName );
			}
		}

		assert( user );
		AddUser( user );
	}
}
コード例 #4
0
void CNrpPlant::Load( const NrpText& saveFolder )
{
	NrpText fileName = OpFileSystem::CheckEndSlash( saveFolder ) + "plant.ini";
	assert( OpFileSystem::IsExist( fileName ) );

	INrpConfig::Load( fileName );
	IniFile rv( fileName );

	int maxNumber = (int)Param( WORKNUMBER ) + (int)Param( REKLAMENUMBER );
	for( int k=0; k < maxNumber; k++ )
	{
		NrpText type = rv.Get( SECTION_WORKS, CreateKeyType( k ), NrpText("") );
		NrpText saveFile = rv.Get( SECTION_WORKS, CreateKeyWork( k ), NrpText("") );
		
		if( OpFileSystem::IsExist( saveFile ) )
		{
			if( type == CNrpPlantWork::ClassName() )
				AddWork( new CNrpPlantWork( saveFile, true ) );
			else if( type == CNrpReklameWork::ClassName() )
				AddReklame( CNrpReklameWork( saveFile ) );
		}
	}
}