Added creating ini file with default values

dev-ui
krzys-h 2013-05-03 21:34:10 +02:00
parent 5a31a93610
commit 64ebda0ab9
1 changed files with 36 additions and 30 deletions

View File

@ -337,8 +337,22 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
bool CApplication::Create()
{
std::string path;
bool defaultValues = false;
GetLogger()->Info("Creating CApplication\n");
if (!GetProfile().InitCurrentDirectory())
{
GetLogger()->Warn("Config not found. Default values will be used!\n");
defaultValues = true;
}
else
{
if (GetProfile().GetLocalProfileString("Resources", "Data", path))
m_dataPath = path;
}
boost::filesystem::path dataPath(m_dataPath);
if (! (boost::filesystem::exists(dataPath) && boost::filesystem::is_directory(dataPath)) )
{
@ -353,17 +367,6 @@ bool CApplication::Create()
SetLanguage(m_language);
//Create the sound instance.
if (!GetProfile().InitCurrentDirectory())
{
GetLogger()->Warn("Config not found. Default values will be used!\n");
m_sound = new CSoundInterface();
}
else
{
std::string path;
if (GetProfile().GetLocalProfileString("Resources", "Data", path))
m_dataPath = path;
#ifdef OPENAL_SOUND
m_sound = static_cast<CSoundInterface *>(new ALSound());
#else
@ -372,6 +375,8 @@ bool CApplication::Create()
#endif
m_sound->Create(true);
// Cache sound files
if (GetProfile().GetLocalProfileString("Resources", "Sound", path)) {
m_sound->CacheAll(path);
} else {
@ -383,7 +388,8 @@ bool CApplication::Create()
} else {
m_sound->AddMusicFiles(GetDataSubdirPath(DIR_MUSIC));
}
}
GetLogger()->Info("CApplication created successfully\n");
std::string standardInfoMessage =
"\nPlease see the console output or log file\n"
@ -481,9 +487,9 @@ bool CApplication::Create()
// Create the robot application.
m_robotMain = new CRobotMain(this);
m_robotMain->ChangePhase(PHASE_WELCOME1);
if (defaultValues) m_robotMain->CreateIni();
GetLogger()->Info("CApplication created successfully\n");
m_robotMain->ChangePhase(PHASE_WELCOME1);
return true;
}