当前位置: 首页>>代码示例>>C++>>正文


C++ CConfigFile::load方法代码示例

本文整理汇总了C++中CConfigFile::load方法的典型用法代码示例。如果您正苦于以下问题:C++ CConfigFile::load方法的具体用法?C++ CConfigFile::load怎么用?C++ CConfigFile::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CConfigFile的用法示例。


在下文中一共展示了CConfigFile::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: load

	// -----------------------------------------------------------------------
	bool load (const string &sFilename)
	{
		FILE * f = fopen (sFilename.c_str(), "rt");
		if (f == NULL)
			return false;
		else 
			fclose (f);

		try
		{			
			CConfigFile cf;

			cf.load (sFilename);

			// Out
			CConfigFile::CVar &cvOutputIGDir = cf.getVar("OutputIGDir");
			OutputIGDir = cvOutputIGDir.asString();

			// In
			CConfigFile::CVar &cvInputIGDir = cf.getVar("InputIGDir");
			InputIGDir = cvInputIGDir.asString();

			CConfigFile::CVar &cvCellSize = cf.getVar("CellSize");
			CellSize = cvCellSize.asFloat();

			CConfigFile::CVar &cvHeightMapFile1 = cf.getVar("HeightMapFile1");
			HeightMapFile1 = cvHeightMapFile1.asString();

			CConfigFile::CVar &cvZFactor1 = cf.getVar("ZFactor1");
			ZFactor1 = cvZFactor1.asFloat();

			CConfigFile::CVar &cvHeightMapFile2 = cf.getVar("HeightMapFile2");
			HeightMapFile2 = cvHeightMapFile2.asString();

			CConfigFile::CVar &cvZFactor2 = cf.getVar("ZFactor2");
			ZFactor2 = cvZFactor2.asFloat();

			CConfigFile::CVar &cvLandFile = cf.getVar("LandFile");
			LandFile = cvLandFile.asString();
		}
		catch (const EConfigFile &e)
		{
			string sTmp = string("ERROR : Error in config file : ") + e.what() + "\n";
			outString (sTmp);
			return false;
		}
		return true;
	}
开发者ID:sythaeryn,项目名称:pndrpg,代码行数:49,代码来源:main.cpp

示例2: LoadKeyCfg

void LoadKeyCfg ()
{
	// Path of the dll
	HMODULE hModule = hInstance;
	if (hModule)
	{
		char sModulePath[256];
		int res=GetModuleFileName(hModule, sModulePath, 256);
		if (res)
		{
			// split path
			char drive[256];
			char dir[256];
			_splitpath (sModulePath, drive, dir, NULL, NULL);

			// Make a new path
			char cgfPath[256];
			_makepath (cgfPath, drive, dir, "keys", ".cfg");

	
			CConfigFile cf;

			// Load and parse "test.txt" file
			cf.load (cgfPath);
			
			// For each keys
			for (uint key=0; key<KeyCounter; key++)
			{
				// go
				try
				{
					// Get the foo variable (suppose it's a string variable)
					CConfigFile::CVar &value= cf.getVar (PainterKeysName[key]);

					// Get value
					PainterKeys[key]=value.asInt ();
				}
				catch (EConfigFile &e)
				{
					// Something goes wrong... catch that
					const char* what=e.what();
				}
			}
		}
	}
}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:46,代码来源:paint_ui.cpp

示例3: loadConfigFile

void loadConfigFile ()
{
	FILE *fp = fopen ("client.cfg", "rt");
	if (fp == NULL)
	{
		createConfigFile();
	}
	else
	{
		fclose (fp);
	}

	ConfigFile.load ("client.cfg");

	// set internet simulation values
	CUdpSimSock::setSimValues (ConfigFile);

	ServerAddr = ConfigFile.getVar("ServerAddress").asString();

	ConnectionName = ConfigFile.getVar("ConnectionName").asString();

	if (ConnectionName.empty())
	{
		InfoLog->displayRawNL ("Please, enter a connection name");
		InfoLog->displayRawNL ("(only alphanumeric character limited to 30 character, no space)");
		InfoLog->displayRawNL ("For example enter your name and/or your location (ie: \"AceHome\"),");
		InfoLog->displayRawNL ("It'll be use to find your stat file easier:");
		char cn[128];
		if (fgets (cn, 127, stdin) == NULL)
		{
			exit ("Error during the keyboard scanning");
		}
		ConnectionName = cn;
		checkConnectionName ();
		ConfigFile.getVar ("ConnectionName").setAsString(ConnectionName);
		ConfigFile.save ();
	}
	else
	{
		checkConnectionName ();
	}
}
开发者ID:mixxit,项目名称:solinia,代码行数:42,代码来源:client.cpp

示例4: getenv

void	init()
{
	registerSerial3d();

	try
	{
#ifdef NL_OS_UNIX
	        std::string homeDir = getenv("HOME");
        	NLMISC::CPath::addSearchPath( homeDir + "/.nel");
#endif // NL_OS_UNIX

	        NLMISC::CPath::addSearchPath(NL_BIB_CFG);

		CConfigFile cf;
		uint			i;
	
		cf.load("build_ig_boxes.cfg");
	
		Output = getString(cf, "Output");
		// nlinfo("Output=%s", Output.c_str());

		CConfigFile::CVar &cvIGs = cf.getVar("IGs");
		for (i=0; i<cvIGs.size(); i++)
		{
			IGs.push_back(cvIGs.asString(i));
		}

		CConfigFile::CVar &cvPathes = cf.getVar("Pathes");
		for (i=0; i<cvPathes.size(); ++i)
		{
			nlinfo("Using search path %s", cvPathes.asString(i).c_str());
			CPath::addSearchPath(cvPathes.asString(i));
		}
	}
	catch (EConfigFile &e)
	{
		printf ("Problem in config file : %s\n", e.what ());
	}
}
开发者ID:mixxit,项目名称:solinia,代码行数:39,代码来源:main.cpp

示例5: main

///=========================================================
int main (int argc, char* argv[])
{
	// Filter addSearchPath
	NLMISC::createDebug();
	InfoLog->addNegativeFilter ("adding the path");

	TShapeMap shapeMap;

	// Check number of args
	if (argc<5)
	{
		// Help message
		printf ("zone_dependencies [properties.cfg] [firstZone.zone] [lastzone.zone] [output_dependencies.cfg]\n");
	}
	else
	{
		NL3D::registerSerial3d();
		// Light direction
		CVector lightDirection;

		// Config file handler
		try
		{
			// Read the properties file
			CConfigFile properties;
			
			// Load and parse the properties file
			properties.load (argv[1]);

			// Get the light direction
			CConfigFile::CVar &sun_direction = properties.getVar ("sun_direction");
			lightDirection.set (sun_direction.asFloat(0), sun_direction.asFloat(1), sun_direction.asFloat(2));
			lightDirection.normalize();


			// Get the search pathes
			CConfigFile::CVar &search_pathes = properties.getVar ("search_pathes");
			uint path;
			for (path = 0; path < (uint)search_pathes.size(); path++)
			{
				// Add to search path
				CPath::addSearchPath (search_pathes.asString(path));
			}
/*
			CConfigFile::CVar &ig_path = properties.getVar ("ig_path");
			NLMISC::CPath::addSearchPath(ig_path.asString(), true, true);

			CConfigFile::CVar &shapes_path = properties.getVar ("shapes_path");
			NLMISC::CPath::addSearchPath(shapes_path.asString(), true, true);
*/
			CConfigFile::CVar &compute_dependencies_with_igs = properties.getVar ("compute_dependencies_with_igs");
			bool computeDependenciesWithIgs = compute_dependencies_with_igs.asInt() != 0;								


			// Get the file extension
			string ext=getExt (argv[2]);

			// Get the file directory
			string dir=getDir (argv[2]);

			// Get output extension
			string outExt=getExt (argv[4]);

			// Get output directory
			string outDir=getDir (argv[4]);

			// Get the first and last name
			string firstName=getName (argv[2]);
			string lastName=getName (argv[3]);

			// Get the coordinates
			uint16 firstX, firstY;
			uint16 lastX, lastY;
			if (getZoneCoordByName (firstName.c_str(), firstX, firstY))
			{
				// Last zone
				if (getZoneCoordByName (lastName.c_str(), lastX, lastY))
				{
					// Take care
					if (lastX<firstX)
					{
						uint16 tmp=firstX;
						firstX=lastX;
						lastX=firstX;
					}
					if (lastY<firstY)
					{
						uint16 tmp=firstY;
						firstY=lastY;
						lastY=firstY;
					}

					// Min z
					float minZ=FLT_MAX;

					// Make a quad grid
					CQuadGrid<CZoneDescriptorBB>	quadGrid;
					quadGrid.create (256, 100);

//.........这里部分代码省略.........
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:101,代码来源:zone_dependencies.cpp

示例6: main

//-----------------------------------------------
//	MAIN
//
//-----------------------------------------------
int main( int argc, char ** argv )
{
	// get the output filename
	if( argc > 1 )
	{
		displayHelp();
		return EXIT_FAILURE;
	}
	
	// load the cfg
	CConfigFile configFile;
	string configFileName = "make_alias_file.cfg";
	if(!CFile::fileExists(configFileName))
	{
		nlwarning("Config file %s not found",configFileName.c_str());
		return 1;
	}
	configFile.load(configFileName);

	
	// read the sheet paths
	vector<string> sheetPaths;
	try
	{
		CConfigFile::CVar& cvSheetPaths = configFile.getVar("SheetPaths");
		sint i;
		for( i = 0; i< (sint)cvSheetPaths.size(); ++i)
		{
			sheetPaths.push_back( cvSheetPaths.asString(i) );
		}
	}
	catch(const EUnknownVar &) 
	{
		nlwarning("var 'SheetPaths' not found");
	}

	// add the sheet paths
	cout<<"adding the sheet paths ..."<<endl;
	vector<string>::iterator itPath;
	for( itPath = sheetPaths.begin(); itPath != sheetPaths.end(); ++itPath )
	{
		CPath::addSearchPath(*itPath,true,false);
	}

	// read the name that will be used for packed file
	string aliasFilename = "alias.packed_sheets";
	try
	{
		CConfigFile::CVar &cvAliasFilename = configFile.getVar("AliasFilename");
		aliasFilename = cvAliasFilename.asString();
	}
	catch(const EUnknownVar &) 
	{
		nlwarning("var 'AliasFilename' not found");
	}
	
	// read the extensions list of sheets to read
	vector<string> extensions;
	try
	{
		CConfigFile::CVar& cvExtensions = configFile.getVar("Extensions");
		sint i;
		for( i = 0; i< (sint)cvExtensions.size(); ++i)
		{
			extensions.push_back( cvExtensions.asString(i) );
		}
	}
	catch(const EUnknownVar &) 
	{
		nlwarning("var 'Extensions' not found");
	}

	// load form and create packed sheets
	cout<<"reading the sheets ..."<<endl;
	map<CSheetId, CSheet> sheetMap;
	bool updatePackedSheet = true;
	createDebug(); // needed to init WarningLog
	loadForm (extensions, aliasFilename, sheetMap, updatePackedSheet);
	cout<<"finished."<<endl;

	// display the content of the map
	/*
	map<CSheetId, CSheet>::iterator itAlias;
	for( itAlias = sheetMap.begin(); itAlias != sheetMap.end(); ++itAlias )
	{
		nlinfo("sheet %s  alias = %s",(*itAlias).first.toString().c_str(),(*itAlias).second.Alias.c_str());
	}
	*/

	return EXIT_SUCCESS;

} // main //
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:96,代码来源:make_alias_file.cpp

示例7: InitInstance

BOOL CData_mirrorApp::InitInstance()
{
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

	try
	{
		// Get the module
		CConfigFile	cf;
		string exePath = GetCommandLine ();
		if (exePath.size()>0)
		{
			if (exePath[0] == '\"')
			{
				uint end=exePath.find ('\"', 1);
				if (end != string::npos)
				{
					exePath = exePath.substr (1, end-1);
				}
				else
				{
					nlassert (0);	// no!
				}
			}
			else
			{
				uint end=exePath.find (' ', 1);
				exePath = exePath.substr (0, end);
			}
		}

		// Register it
		string temp = "\"" + exePath;
		temp = temp+"\" \"%1\"";
		nlverify (RegisterDirectoryAppCommand ("NeLDataMirror", "&Sync Mirror", temp.c_str ()));

		// Get the app directory
		string path = NLMISC::CFile::getPath (exePath)+"config.cfg";

		cf.load (path);
		MainDirectory = cf.getVar ("MainDirectory").asString ();
		MainDirectory = strlwr (CPath::standardizePath (MainDirectory));
		
		MirrorDirectory = cf.getVar ("MirrorDirectory").asString ();
		MirrorDirectory = strlwr (CPath::standardizePath (MirrorDirectory));
		
		LogDirectory = cf.getVar ("LogDirectory").asString ();
		LogDirectory = strlwr (CPath::standardizePath (LogDirectory));
		
		IgnoreDirectory = cf.getVar ("IgnoreDirectory").asString ();
		IgnoreDirectory = strlwr (CPath::standardizePath (IgnoreDirectory));
		if (IgnoreDirectory.empty())
			IgnoreDirectory = MainDirectory;

		string sBinaryCompare = cf.getVar ("BinaryCompare").asString ();
		sBinaryCompare = strlwr (sBinaryCompare);
		BinaryCompare = false;
		if ((sBinaryCompare == "true") || (sBinaryCompare=="1"))
			BinaryCompare = true;

		CurrentDir = m_lpCmdLine;
		// Remove 
		if (CurrentDir.size ()>=2)
		{
			if (CurrentDir[0] == '"')
				CurrentDir = CurrentDir.substr (1, CurrentDir.size ()-1);
			if (CurrentDir[CurrentDir.size ()-1] == '"')
				CurrentDir = CurrentDir.substr (0, CurrentDir.size ()-1);
		}
		if (CurrentDir.empty ())
			return FALSE;


		// File or directory ?
		bool directory;
		if (NLMISC::CFile::isDirectory (CurrentDir))
		{
			directory = true;
			CurrentDir = strlwr (CPath::standardizePath (CurrentDir));
		}
		else if (NLMISC::CFile::fileExists (CurrentDir))
		{
			directory = false;
			CurrentDir = strlwr (CPath::standardizePath (NLMISC::CFile::getPath (CurrentDir)));
		}
		else
		{
			MessageBox (NULL, (CurrentDir+" is not a directory nor a file.").c_str (), "NeL Data Mirror", MB_OK|MB_ICONEXCLAMATION);
			return FALSE;
		}

		// Get relative dir
		if (CurrentDir.substr (0, MainDirectory.size ()) == MainDirectory)
		{
			CurrentDir = CurrentDir.substr (MainDirectory.size (), CurrentDir.size () - MainDirectory.size ());
		}
//.........这里部分代码省略.........
开发者ID:mixxit,项目名称:solinia,代码行数:101,代码来源:data_mirror.cpp

示例8: OnClear

void CBug_reportDlg::OnClear()
{
	set(IDC_LANGUAGE, "english");
	set(IDC_SUBJECT, "");
	set(IDC_CLIENTVERSION, "");
	set(IDC_SHARDNAME, "Beta");
	set(IDC_SHARDVERSION, "");
	set(IDC_SKU, "Beta2");
	set(IDC_CLASS, "");
	set(IDC_CATEGORY, "");
	set(IDC_FREQUENCY, "Once");
	set(IDC_DESCRIPTION, "");
	set(IDC_REPRODUCESTEPS, "");
	set(IDC_QUEUE, "ryzom");
	set(IDC_ATTACHEDFILE, "");

/*
/////// TEMP pre fill entries
	set(IDC_LANGUAGE, "english");
	set(IDC_SUBJECT, "subject");
	set(IDC_CLIENTVERSION, "0.8.0.360");
	set(IDC_SHARDNAME, "OFFLINE");
	set(IDC_SHARDVERSION, "0.8.0.360");
	set(IDC_SKU, "Beta2");
	set(IDC_CLASS, "A");
	set(IDC_CATEGORY, "Hardware");
	set(IDC_FREQUENCY, "always");
	set(IDC_DESCRIPTION, "description");
	set(IDC_REPRODUCESTEPS, "reproduction steps");
	set(IDC_QUEUE, "zz-ryzom-dummy");
	set(IDC_ATTACHEDFILE, "C:\\Documents and Settings\\nouveau\\Desktop\\pez.bmp");
/////// END TEMP
*/

	if (!NLMISC::CFile::fileExists("bug_report.cfg"))
	{
		createConfigFile ();
	}

	try
	{
		// try to get the client version from the client config file
		CConfigFile cf;
		cf.load ("client.cfg");

		set(IDC_CLIENTVERSION, cf.getVar ("ClientVersion").asString ());
		set(IDC_SHARDVERSION, cf.getVar ("ClientVersion").asString ());
	}
	catch (Exception &)
	{
		nlwarning ("Can't find ClientVersion variable in client.cfg");
	}

	try
	{
		CConfigFile cf;
		cf.load ("bug_report.cfg");

		set(IDC_REQUESTOR, cf.getVar ("FromEMail").asString ());

		SMTPServer = cf.getVar ("SMTPServer").asString ();
		ToEmail = cf.getVar ("ToEMail").asString ();
	}
	catch (Exception &e)
	{
		MessageBox (e.what(), "Error");
		exit (0);
	}

	setDumpFilename("");

	setFocus (IDC_SUBJECT);
}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:73,代码来源:bug_reportDlg.cpp

示例9: regsiterOVPath

void regsiterOVPath ()
{
// must test it first, because NL_DEBUG_FAST and NL_DEBUG are declared at same time.
//#ifdef NL_DEBUG_FAST
//	HMODULE hModule = GetModuleHandle("object_viewer_dll_df.dll");
#if defined (NL_DEBUG)
	HMODULE hModule = GetModuleHandle("object_viewer_dll_d.dll");
//#elif defined (NL_RELEASE_DEBUG)
//	HMODULE hModule = GetModuleHandle("object_viewer_dll_rd.dll");
#else
	HMODULE hModule = GetModuleHandle("object_viewer_dll_r.dll");
#endif
	if (!hModule) { ::MessageBox(NULL, "'hModule' failed at '" __FUNCTION__ "' in file '" __FILE__ " on line " NL_MACRO_TO_STR(__LINE__), "NeL Export", MB_OK | MB_ICONERROR); return; }
	char sModulePath[256];
	int res = GetModuleFileName(hModule, sModulePath, 256);
	if (!res) { ::MessageBox(NULL, "'res' failed at '" __FUNCTION__ "' in file '" __FILE__ " on line " NL_MACRO_TO_STR(__LINE__), "NeL Export", MB_OK | MB_ICONERROR); return; }
	char SDrive[512];
	char SDir[512];
	_splitpath (sModulePath, SDrive, SDir, NULL, NULL);
	_makepath (sModulePath, SDrive, SDir, "object_viewer", ".cfg");

	// Load the config file
	CConfigFile cf;
	cf.load (sModulePath);

	try
	{
		// Add search pathes
		CConfigFile::CVar &search_pathes = cf.getVar ("search_pathes");
		for (uint i=0; i<(uint)search_pathes.size(); i++)
			CPath::addSearchPath (search_pathes.asString(i));
	}
	catch(EUnknownVar &)
	{}

	try
	{
		// Add recusrive search pathes
		CConfigFile::CVar &recursive_search_pathes = cf.getVar ("recursive_search_pathes");
		for (uint i=0; i<(uint)recursive_search_pathes.size(); i++)
			CPath::addSearchPath (recursive_search_pathes.asString(i), true, false);
	}
	catch(EUnknownVar &)
	{}

	// Add extension remapping
	try
	{
		CConfigFile::CVar &extensions_remapping = cf.getVar ("extensions_remapping");
		if (extensions_remapping.size()%2 != 0)
		{
			nlwarning ("extensions_remapping must have a multiple of 2 entries (ex: extensions_remapping={\"dds\",\"tga\"};)");
		}
		else
		{
			for (uint i=0; i<(uint)extensions_remapping.size(); i+=2)
				CPath::remapExtension(extensions_remapping.asString(i), extensions_remapping.asString(i+1), true);
		}
	}
	catch (EUnknownVar &)
	{
	}
}
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:63,代码来源:nel_export_view.cpp

示例10: if

/*
 * CSV -> Georges
 */
void	convertCsvFile( const string &file, bool generate, const string& sheetType )
{
	const uint			BUFFER_SIZE = 16*1024;
	char			lineBuffer[BUFFER_SIZE];
	FILE			*s;

	vector<string>	fields;
	vector<string>	args;

	if ((s = fopen(file.c_str(), "r")) == NULL)
	{
		fprintf(stderr, "Can't find file %s to convert\n", file.c_str());
		return;
	}

	loadSheetPath();

	UFormLoader *formLoader = UFormLoader::createLoader ();
	NLMISC::CSmartPtr<CForm> form;
	NLMISC::CSmartPtr<UFormDfn> formDfn;


	fgets(lineBuffer, BUFFER_SIZE, s);
	explode(std::string(lineBuffer), std::string(SEPARATOR), fields);

	vector<bool> activeFields( fields.size(), true );

	// Load DFN (generation only)
	set<CDfnField>	dfnFields;
	if ( generate )
	{
		formDfn = formLoader->loadFormDfn( (sheetType + ".dfn").c_str() );
		if ( ! formDfn )
			nlerror( "Can't find DFN for %s", sheetType.c_str() );
		fillFromDFN( formLoader, dfnFields, formDfn, "", sheetType );

		// Display missing fields and check fields against DFN
		uint i;
		for ( i=1; i!=fields.size(); ++i )
		{
			eraseCarriageReturnsAndMakeBlankNonAsciiChars( fields[i] );
			if ( fields[i].empty() )
			{
				nlinfo( "Skipping field #%u (empty)", i );
				activeFields[i] = false;
			}
			else if ( nlstricmp( fields[i], "parent" ) == 0 )
			{
				strlwr( fields[i] ); // non-const version
			}
			else
			{
				set<CDfnField>::iterator ist = dfnFields.find( CDfnField(fields[i]) );
				if ( ist == dfnFields.end() )
				{
					nlinfo( "Skipping field #%u (%s, not found in %s DFN)", i, fields[i].c_str(), sheetType.c_str() );
					activeFields[i] = false;
				}
			}
		}
		for ( i=1; i!=fields.size(); ++i )
		{
			if ( activeFields[i] )
				nlinfo( "Selected field: %s", fields[i].c_str() );
		}
	}

	string addExtension = "." + sheetType;
	uint dirmapLetterIndex = ~0;
	bool dirmapLetterBackward = false;
	vector<string> dirmapDirs;
	string dirmapSheetCode;
	bool WriteEmptyProperties = false, WriteSheetsToDisk = true;
	bool ForceInsertParents = false;

	if ( generate )
	{
		// Get the directory mapping
		try
		{
			CConfigFile dirmapcfg;
			dirmapcfg.load( sheetType + "_dirmap.cfg" );

			if ( OutputPath.empty() )
			{
				CConfigFile::CVar *path = dirmapcfg.getVarPtr( "OutputPath" );
				if ( path )
					OutputPath = path->asString();
				if ( ! OutputPath.empty() )
				{
					if ( OutputPath[OutputPath.size()-1] != '/' )
						OutputPath += '/';
					else if ( ! CFile::isDirectory( OutputPath ) )
						nlwarning( "Output path does not exist" );
				}
			}

//.........这里部分代码省略.........
开发者ID:mixxit,项目名称:solinia,代码行数:101,代码来源:georges2csv.cpp

示例11: extractNewSheetNames

// ***************************************************************************
int extractNewSheetNames(int argc, char *argv[])
{
	// **** read the parameters
	for (int i=2; i<argc; ++i)
	{
		string s = argv[i];
		if (s == "-r")
		{
			// active remove mode
			RemoveOlds = true;
		}
		else
		{
			nlwarning("Unknow option '%s'", argv[i]);
			return -1;
		}
	}
	
	// **** avoid some flood
	NLMISC::createDebug();
	NLMISC::DebugLog->addNegativeFilter("numCol changed to");
	NLMISC::InfoLog->addNegativeFilter("CPath::addSearchPath");
	

	// **** read the configuration file
	CConfigFile	cf;
	cf.load("bin/translation_tools.cfg");
	CConfigFile::CVar &paths = cf.getVar("Paths");
	CConfigFile::CVar &pathNoRecurse= cf.getVar("PathsNoRecurse");
	CConfigFile::CVar &ligoClassFile= cf.getVar("LigoClassFile");

	// parse path
	for (uint i=0; i<paths.size(); ++i)
	{
		CPath::addSearchPath(paths.asString(i), true, false);
	}
	for (uint i=0; i<pathNoRecurse.size(); ++i)
	{
		CPath::addSearchPath(pathNoRecurse.asString(i), false, false);
	}
	
	// init ligo config once
	string ligoPath = CPath::lookup(ligoClassFile.asString(), true, true);
	LigoConfig.readPrimitiveClass(ligoPath.c_str(), false);
	NLLIGO::Register();
	CPrimitiveContext::instance().CurrentLigoConfig = &LigoConfig;
	
	
	
	// **** Parse all the different type of sheets
	const char	*sheetDefs[]=
	{
		// 1st is the name of the worksheet file. 
		// 2nd is the Key column identifier. 
		// 3rd is the sheet extension
		// 4th is the directory where to find new sheets
		"work/item_words_wk.txt",		"item ID",		"sitem",		"l:/leveldesign/game_element/sitem",
		"work/creature_words_wk.txt",	"creature ID",	"creature",		"l:/leveldesign/game_elem/creature/fauna",	// take fauna only because other are special
		"work/sbrick_words_wk.txt",		"sbrick ID",	"sbrick",		"l:/leveldesign/game_element/sbrick",
		"work/sphrase_words_wk.txt",	"sphrase ID",	"sphrase",		"l:/leveldesign/game_element/sphrase",
	};
	uint	numSheetDefs= sizeof(sheetDefs) / (4*sizeof(sheetDefs[0]));
	
	// For all different type of sheet
	for(uint i=0;i<numSheetDefs;i++)
	{
		CSheetWordListBuilder	builder;
		builder.SheetExt= sheetDefs[i*4+2];
		builder.SheetPath= sheetDefs[i*4+3];
		extractNewWords(sheetDefs[i*4+0], sheetDefs[i*4+1], builder);
	}


	// **** Parse place and region names
	{
		// build place names
		CRegionPrimWordListBuilder	builder;
		builder.PrimPath= "l:/primitives";
		builder.PrimFilter.push_back("region_*.primitive");
		builder.PrimFilter.push_back("indoors_*.primitive");
		extractNewWords("work/place_words_wk.txt", "placeId", builder);
	}


	return 0;
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:87,代码来源:extract_new_sheet_names.cpp

示例12: main

// ***************************************************************************
int main(int argc, char* argv[])
{
	// Register 3d
	registerSerial3d ();

	// Avoid some stupids warnings.
	NLMISC::createDebug();
	skipLog("variable \"RootConfigFilename\"");
	skipLog("variable \"anim_low_precision_tracks\"");
	skipLog("variable \"anim_sample_rate\"");
	InfoLog->addNegativeFilter("FEHTIMER>");
	InfoLog->addNegativeFilter("adding the path");


	// Good number of args ?
	if (argc<4)
	{
		// Help message
		printf ("anim_builder [directoryIn] [pathOut] [parameter_file] \n");
	}
	else
	{
		try
		{
			string	directoryIn= argv[1];
			string	pathOut= argv[2];
			string	paramFile= argv[3];

			// Verify directoryIn.
			directoryIn= CPath::standardizePath(directoryIn);
			if( !CFile::isDirectory(directoryIn) )
			{
				printf("DirectoryIn %s is not a directory", directoryIn.c_str());
				return -1;
			}
			// Verify pathOut.
			pathOut= CPath::standardizePath(pathOut);
			if( !CFile::isDirectory(pathOut) )
			{
				printf("PathOut %s is not a directory", pathOut.c_str());
				return -1;
			}

			// Our Animation optimizer.
			//=================
			CAnimationOptimizer		animationOptimizer;
			// Leave thresholds as default.
			animationOptimizer.clearLowPrecisionTracks();


			// Load and setup configFile.
			//=================
			CConfigFile parameter;
			// Load and parse the param file
			parameter.load (paramFile);

			// Get the Low Precision Track Key Names
			try
			{
				CConfigFile::CVar &anim_low_precision_tracks = parameter.getVar ("anim_low_precision_tracks");
				uint lpt;
				for (lpt = 0; lpt < (uint)anim_low_precision_tracks.size(); lpt++)
				{
					animationOptimizer.addLowPrecisionTrack(anim_low_precision_tracks.asString(lpt));
				}
			}
			catch(EUnknownVar &)
			{
				nlwarning("\"anim_low_precision_tracks\" not found in the parameter file. Add \"Finger\" and \"Ponytail\" by default");
				animationOptimizer.addLowPrecisionTrack("Finger");
				animationOptimizer.addLowPrecisionTrack("Ponytail");
			}

			// Sample Rate.
			try
			{
				CConfigFile::CVar &anim_sample_rate = parameter.getVar ("anim_sample_rate");
				float	sr= anim_sample_rate.asFloat(0);
				// Consider values > 1000 as error values.
				if(sr<=0 || sr>1000)
				{
					nlwarning("Bad \"anim_sample_rate\" value. Use Default of 30 fps.");
					animationOptimizer.setSampleFrameRate(30);
				}
				else
				{
					animationOptimizer.setSampleFrameRate(sr);
				}
			}
			catch(EUnknownVar &)
			{
				nlwarning("\"anim_sample_rate\" not found in the parameter file. Use Default of 30 fps.");
				animationOptimizer.setSampleFrameRate(30);
			}


			// Scan and load all files .ig in directories
			//=================
			uint		numSkipped= 0;
//.........这里部分代码省略.........
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:101,代码来源:anim_builder.cpp

示例13: main

//****************************************************************************************************************************
int main(int argc, char* argv[])
{
	if (argc < 2)
	{
		nlwarning("Usage : %s config_file_name.cfg", argv[0]);
		return -1;
	}
	CConfigFile cf;
	try
	{	
		cf.load(argv[1]);
	}
	catch(const NLMISC::EConfigFile &)
	{
		nlwarning("Error in config file %s", argv[1]);
		return -1;
	}	
	catch(...)
	{
		nlwarning("Can't read config file %s", argv[1]);
		return -1;
	}
	// output for sheets
	std::string outputPath;
	CConfigFile::CVar *outputPathVar = cf.getVarPtr("output_path");
	if (outputPathVar)
	{
		outputPath = outputPathVar->asString() + "/";
	}
	// output for 'levels' parents
	std::string levelParentsPath;
	CConfigFile::CVar *levelParentsPathVar = cf.getVarPtr("level_parents");
	if (levelParentsPathVar)
	{
		levelParentsPath = levelParentsPathVar->asString() + "/";
	}
	// output for projectile parents
	std::string projectileParentsPath;
	CConfigFile::CVar *projectileParentsPathVar = cf.getVarPtr("projectile_base");
	if (projectileParentsPathVar)
	{
		projectileParentsPath= projectileParentsPathVar->asString() + "/";
	}	
	// output for 'projectile by level and mode' parents
	std::string projectileByLevelAndModeParentsPath;
	CConfigFile::CVar *projectileByLevelAndModeParentsPathVar = cf.getVarPtr("projectile_by_level_and_mode_parents");
	if (projectileByLevelAndModeParentsPathVar)
	{
		projectileByLevelAndModeParentsPath = projectileByLevelAndModeParentsPathVar->asString() + "/";
	}
	// output for 'base spells' parents
	std::string baseSpellPath;
	CConfigFile::CVar *baseSpellPathVar = cf.getVarPtr("spell_base");
	if (baseSpellPathVar)
	{
		baseSpellPath = baseSpellPathVar->asString() + "/";
	}
	// output for 'spell by levels' parents
	std::string spellByLevelParentsPath;
	CConfigFile::CVar *spellByLevelParentsPathVar = cf.getVarPtr("spell_by_level_parents");
	if (spellByLevelParentsPathVar)
	{
		spellByLevelParentsPath = spellByLevelParentsPathVar->asString() + "/";
	}
	// output for 'final spell'
	std::string finalSpellPath;
	CConfigFile::CVar *finalSpellPathVar = cf.getVarPtr("final_spells");
	if (finalSpellPathVar)
	{
		finalSpellPath = finalSpellPathVar->asString() + "/";
	}
	


	// read number of levels
	CConfigFile::CVar *numLevelVar = cf.getVarPtr("num_levels");
	if (!numLevelVar)
	{
		nlwarning("Can't read number of spell levels");
		return -1;
	}
	uint numSpellLevels = numLevelVar->asInt();

	std::vector<CUserParams> userParams(numSpellLevels);

	// read user params set for each level
	for(uint level = 0; level < numSpellLevels; ++level)
	{
		std::string varName = toString("user_params_level%d", (int) (level + 1));
		CConfigFile::CVar *up = cf.getVarPtr(varName);
		if (!up)
		{
			nlwarning("Can't read var %s", varName.c_str());
		}
		else
		{
			for(uint k = 0; k < CUserParams::NumUserParams; ++k)
			{
				userParams[level].UserParam[k] = up->asString(k);
//.........这里部分代码省略.........
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:101,代码来源:build_spell_sheet.cpp

示例14: LoadVarCfg

void LoadVarCfg ()
{
	// Path of the dll
	HMODULE hModule = hInstance;
	if (hModule)
	{
		char sModulePath[256];
		int res=GetModuleFileName(hModule, sModulePath, 256);
		if (res)
		{
			// split path
			char drive[256];
			char dir[256];
			_splitpath (sModulePath, drive, dir, NULL, NULL);

			// Make a new path
			char cgfPath[256];
			_makepath (cgfPath, drive, dir, "keys", ".cfg");
	
			CConfigFile cf;

			// Load and parse "test.txt" file
			cf.load (cgfPath);
			
			// go
			try
			{
				// Get the light direction variable
				CConfigFile::CVar &light_direction= cf.getVar ("LightDirection");
				if (light_direction.size () == 3)
				{
					// Copy the light direction
					LightDirection.x = light_direction.asFloat (0);
					LightDirection.y = light_direction.asFloat (1);
					LightDirection.z = light_direction.asFloat (2);
				}
			}
			catch (EConfigFile &)
			{
			}

			try
			{
				// Get the light diffuse part
				CConfigFile::CVar &light_diffuse= cf.getVar ("LightDiffuse");
				if (light_diffuse.size () == 3)
				{
					LightDiffuse.R = light_diffuse.asInt (0);
					LightDiffuse.G = light_diffuse.asInt (1);
					LightDiffuse.B = light_diffuse.asInt (2);
				}
			}
			catch (EConfigFile &)
			{
			}

			try
			{
				// Get the light ambiant part
				CConfigFile::CVar &light_ambiant= cf.getVar ("LightAmbiant");
				if (light_ambiant.size () == 3)
				{
					LightAmbiant.R = light_ambiant.asInt (0);
					LightAmbiant.G = light_ambiant.asInt (1);
					LightAmbiant.B = light_ambiant.asInt (2);
				}
			}
			catch (EConfigFile &)
			{
			}

			try
			{
				// Get the light mulitply part
				CConfigFile::CVar &light_multiply= cf.getVar ("LightMultiply");
				LightMultiply = light_multiply.asFloat ();
			}
			catch (EConfigFile &)
			{
			}

			try
			{
				// Get the zoom speed
				CConfigFile::CVar &zoom_speed= cf.getVar ("ZoomSpeed");
				ZoomSpeed = zoom_speed.asFloat ();
			}
			catch (EConfigFile &)
			{
			}
		}
	}
}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:93,代码来源:paint_ui.cpp

示例15: main

int main (int /* argc */, char ** /* argv */)
{

	// look at the debug example
	createDebug();

	// Add the data directory to the search path.
	CPath::addSearchPath(NL_SAMPLE_CFG);

	// load and parse the configfile
	cf.load (CPath::lookup("simpletest.txt"));

	// CConfigFile checks if the config file has been modified by an external program.
	// in this case, the configfile automatically reloads and reparses the file.
	// you can connect a callback function that will be called in this case if
	// you want, for example, reset variables
	
	// link a callback with this configfile.
	cf.setCallback (mainCallback);

	// link a callback with the var12. If and only if the var12 changed, this
	// callback will be called
	cf.setCallback ("var12", var12Callback);

	// display all variables
	cf.display(InfoLog);

	// get the value of var1 as int
	int var1 = cf.getVar ("var1").asInt();
	nlinfo("var1 (int) = %d", var1);

	// get the value of var1 as double, in this case, a conversion from int
	// to double will be done
	double var2 = cf.getVar ("var1").asDouble();
	nlinfo("var1 (double) = %lf", var2);

	// get the value of var2 as int, in this case, a conversion from string
	// to int will be done
	int var3 = cf.getVar ("var2").asInt();
	nlinfo("var2 = %d", var3);

	// if the variable is an array of values, you can access them putting the
	// index of the variable you want. Example, get and print all value of var12:
	for (uint i = 0; i < cf.getVar ("var12").size(); i++)
	{
		int val = cf.getVar ("var12").asInt(i);
		nlinfo("%d -> %d", i, val);
	}

	// if you try to access an unknown variable or if something goes wrong, an
	// exception will be called, you can catch them individually or all together in a try/catch block

	try
	{
		// try to access an unknown variable
		int val = cf.getVar ("unknown_variable").asInt();
		nlinfo("unknown_variable = %d", val);
	}
	catch (EConfigFile &e)
	{
		nlinfo("something goes wrong with configfile: %s", e.what());
	}

	cf.getVar ("var13").asInt (0);
	cf.getVar ("var13").asInt (1);
	cf.getVar ("var13").asInt (2);
	
	nlinfo("Try to modify the var12 in the configfile or any other variable.\n\nPress CTRL-C to exit\n");

	while(true)
	{
		CConfigFile::checkConfigFiles();
	}
	return EXIT_SUCCESS;
}
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:75,代码来源:main.cpp


注:本文中的CConfigFile::load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。