本文整理汇总了C++中CConfigFile::getVar方法的典型用法代码示例。如果您正苦于以下问题:C++ CConfigFile::getVar方法的具体用法?C++ CConfigFile::getVar怎么用?C++ CConfigFile::getVar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CConfigFile
的用法示例。
在下文中一共展示了CConfigFile::getVar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 ();
}
}
示例2: 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 ());
}
}
示例3: 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;
}
示例4: 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();
}
}
}
}
}
示例5: 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 &)
{
}
}
示例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 //
示例7: initViewerConfig
/****************************************************************\
init()
\****************************************************************/
void initViewerConfig(const char * configFileName)
{
FILE * f = fopen(configFileName,"rt");
if(f==NULL)
{
nlwarning("'%s' not found, default values used", configFileName);
writeConfigFile(configFileName);
}
else fclose (f);
try
{
CConfigFile cf;
cf.load(configFileName);
CConfigFile::CVar &cvFullScreen = cf.getVar("FullScreen");
ViewerCfg.Windowed = cvFullScreen.asInt() ? false : true;
CConfigFile::CVar &cvWidth = cf.getVar("Width");
ViewerCfg.Width = cvWidth.asInt();
CConfigFile::CVar &cvHeight = cf.getVar("Height");
ViewerCfg.Height = cvHeight.asInt();
CConfigFile::CVar &cvDepth = cf.getVar("Depth");
ViewerCfg.Depth = cvDepth.asInt();
CConfigFile::CVar &cvPosition = cf.getVar("Position");
nlassert(cvPosition.size()==3);
ViewerCfg.Position.x = cvPosition.asFloat(0);
ViewerCfg.Position.y = cvPosition.asFloat(1);
ViewerCfg.Position.z = cvPosition.asFloat(2);
CConfigFile::CVar &cvEyesHeight = cf.getVar("EyesHeight");
ViewerCfg.EyesHeight = CVector(0,0,cvEyesHeight.asFloat());
CConfigFile::CVar &cvBackColor = cf.getVar("Background");
nlassert(cvBackColor.size()==3);
ViewerCfg.Background.R = cvBackColor.asInt(0);
ViewerCfg.Background.G = cvBackColor.asInt(1);
ViewerCfg.Background.B = cvBackColor.asInt(2);
CConfigFile::CVar &cvZFar = cf.getVar("ZFar");
ViewerCfg.ZFar = cvZFar.asFloat();
CConfigFile::CVar &cvAutoLight = cf.getVar("AutoLight");
ViewerCfg.AutoLight = cvAutoLight.asInt() ? true : false;
CConfigFile::CVar &cvLightDir = cf.getVar("LightDir");
nlassert(cvLightDir.size()==3);
ViewerCfg.LightDir.x = cvLightDir.asFloat(0);
ViewerCfg.LightDir.y = cvLightDir.asFloat(1);
ViewerCfg.LightDir.z = cvLightDir.asFloat(2);
CConfigFile::CVar &cvLandscapeTileNear = cf.getVar("LandscapeTileNear");
ViewerCfg.LandscapeTileNear = cvLandscapeTileNear.asFloat();
CConfigFile::CVar &cvLandscapeThreshold = cf.getVar("LandscapeThreshold");
ViewerCfg.LandscapeThreshold = cvLandscapeThreshold.asFloat();
CConfigFile::CVar &cvLandscapeNoise = cf.getVar("LandscapeNoise");
ViewerCfg.LandscapeNoise = cvLandscapeNoise.asInt() != 0;
CConfigFile::CVar &cvBanksPath = cf.getVar("BanksPath");
ViewerCfg.BanksPath = cvBanksPath.asString();
CConfigFile::CVar &cvTilesPath = cf.getVar("TilesPath");
ViewerCfg.TilesPath = cvTilesPath.asString();
CConfigFile::CVar &cvUseDDS = cf.getVar("UseDDS");
ViewerCfg.UseDDS = cvUseDDS.asInt() ? true : false;
CConfigFile::CVar &cvAllPathRelative = cf.getVar("AllPathRelative");
ViewerCfg.AllPathRelative = cvAllPathRelative.asInt() ? true : false;
CConfigFile::CVar &cvBank = cf.getVar("Bank");
ViewerCfg.Bank = cvBank.asString();
CConfigFile::CVar &cvZonesPath = cf.getVar("ZonesPath");
ViewerCfg.ZonesPath = cvZonesPath.asString();
CPath::addSearchPath(cvZonesPath.asString());
CConfigFile::CVar &cvIgPath = cf.getVar("IgPath");
ViewerCfg.IgPath = cvIgPath.asString();
CPath::addSearchPath(cvIgPath.asString());
CConfigFile::CVar &cvShapePath = cf.getVar("ShapePath");
ViewerCfg.ShapePath = cvShapePath.asString();
CPath::addSearchPath(cvShapePath.asString());
CConfigFile::CVar &cvMapsPath = cf.getVar("MapsPath");
ViewerCfg.MapsPath = cvMapsPath.asString();
CPath::addSearchPath(cvMapsPath.asString());
CConfigFile::CVar &cvFontPath = cf.getVar("FontPath");
ViewerCfg.FontPath = cvFontPath.asString();
//.........这里部分代码省略.........
示例8: 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;
}
示例9: 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);
}
示例10: 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);
//.........这里部分代码省略.........
示例11: 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 ());
}
//.........这里部分代码省略.........
示例12:
string getString(CConfigFile &cf, const string &varName)
{
CConfigFile::CVar &var = cf.getVar(varName);
return var.asString();
}
示例13: 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 &)
{
}
}
}
}
示例14: Exception
int main(int argc, char *argv[])
{
uint i;
// Avoid warnings.
NLMISC::createDebug();
DebugLog->addNegativeFilter("Exception will be launched");
WarningLog->addNegativeFilter("Exception will be launched");
InfoLog->addNegativeFilter("FEHTIMER>");
InfoLog->addNegativeFilter("adding the path");
// Init serial
registerSerial3d();
if(argc<4)
{
puts("Usage: build_clod_bank path_file.cfg config_file.cfg destfile.clodbank [bakeFrameRate=20] ");
return 0;
}
try
{
// The bank to fill
CLodCharacterShapeBank lodShapeBank;
// Read the frameRate to process bake of anims
float bakeFrameRate= 20;
if(argc>=5)
{
bakeFrameRate= (float)atof(argv[4]);
if(bakeFrameRate<=1)
{
nlwarning("bad bakeFrameRate value, use a default of 20");
bakeFrameRate= 20;
}
}
// parse the path file.
//==================
// try to load the config file.
CConfigFile pathConfig;
pathConfig.load (argv[1]);
// Get the search pathes
CConfigFile::CVar &search_pathes = pathConfig.getVar ("search_pathes");
for (i = 0; i < (uint)search_pathes.size(); i++)
{
// Add to search path
CPath::addSearchPath (search_pathes.asString(i));
}
// parse the config file.
//==================
// try to load the config file.
CConfigFile config;
config.load (argv[2]);
// For all .clod to process
//==================
CConfigFile::CVar &clod_list = config.getVar ("clod_list");
uint lodId;
for (lodId = 0; lodId < (uint)clod_list.size(); lodId++)
{
string lodName= clod_list.asString(lodId);
printf("Process LOD: %s\n", lodName.c_str());
// Search the variable with this name.
try
{
CIFile iFile;
// get the anim list.
CConfigFile::CVar &clod_anim_list = config.getVar (lodName);
// Correct format?
if(clod_anim_list.size()<3)
{
nlwarning("%s skipped. Must have at least the skeleton file name, the lod file name, and one animation", lodName.c_str());
// go to next.
continue;
}
// Init lod shape process
//===========================
// The first variable is the name of the skeleton.
string skeletonName= clod_anim_list.asString(0);
CSmartPtr<CSkeletonShape> skeletonShape;
// Load it.
iFile.open(CPath::lookup(skeletonName));
CShapeStream strShape;
strShape.serial(iFile);
iFile.close();
//.........这里部分代码省略.........
示例15: main
int main(int argc, char* argv[])
{
// Filter addSearchPath
NLMISC::createDebug();
InfoLog->addNegativeFilter ("adding the path");
// Register 3d
registerSerial3d ();
// Good number of args ?
if (argc<5)
{
// Help message
printf ("%s [zonein.zonel] [igout.ig] [parameter_file] [dependancy_file]\n", argv[0]);
}
else
{
// Ok, read the zone
CIFile inputFile;
// Get extension
string ext=getExt (argv[1]);
string dir=getDir (argv[1]);
// Open it for reading
if (inputFile.open (argv[1]))
{
// Zone name
string zoneName=toLower (string ("zone_"+getName (argv[1])));
// Load the zone
try
{
// Read the config file
CConfigFile parameter;
// Load and parse the parameter file
parameter.load (argv[3]);
// **********
// *** Build the lighter descriptor
// **********
CInstanceLighter::CLightDesc lighterDesc;
// Light direction
CConfigFile::CVar &sun_direction = parameter.getVar ("sun_direction");
lighterDesc.LightDirection.x=sun_direction.asFloat(0);
lighterDesc.LightDirection.y=sun_direction.asFloat(1);
lighterDesc.LightDirection.z=sun_direction.asFloat(2);
lighterDesc.LightDirection.normalize ();
// Grid size
CConfigFile::CVar &quad_grid_size = parameter.getVar ("quad_grid_size");
lighterDesc.GridSize=quad_grid_size.asInt();
// Grid size
CConfigFile::CVar &quad_grid_cell_size = parameter.getVar ("quad_grid_cell_size");
lighterDesc.GridCellSize=quad_grid_cell_size.asFloat();
// Shadows enabled ?
CConfigFile::CVar &shadow = parameter.getVar ("shadow");
lighterDesc.Shadow=shadow.asInt ()!=0;
// OverSampling
CConfigFile::CVar &ig_oversampling = parameter.getVar ("ig_oversampling");
lighterDesc.OverSampling= ig_oversampling.asInt ();
// validate value: 0, 2, 4, 8, 16
lighterDesc.OverSampling= raiseToNextPowerOf2(lighterDesc.OverSampling);
clamp(lighterDesc.OverSampling, 0U, 16U);
if(lighterDesc.OverSampling<2)
lighterDesc.OverSampling= 0;
// For ig of Zones, never disable Sun contrib !!!
lighterDesc.DisableSunContribution= false;
// Get the search pathes
CConfigFile::CVar &search_pathes = parameter.getVar ("search_pathes");
uint path;
for (path = 0; path < (uint)search_pathes.size(); path++)
{
// Add to search path
CPath::addSearchPath (search_pathes.asString(path));
}
// A landscape allocated with new: it is not delete because destruction take 3 secondes more!
CLandscape *landscape=new CLandscape;
landscape->init();
// A zone lighter
CMyIgZoneLighter lighter;
lighter.init ();
// A vector of zone id
vector<uint> listZoneId;
// The zone
CZone zone;
// List of ig
//.........这里部分代码省略.........