Added creating ini file with default values
parent
5a31a93610
commit
64ebda0ab9
|
@ -337,8 +337,22 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
|
||||||
|
|
||||||
bool CApplication::Create()
|
bool CApplication::Create()
|
||||||
{
|
{
|
||||||
|
std::string path;
|
||||||
|
bool defaultValues = false;
|
||||||
|
|
||||||
GetLogger()->Info("Creating CApplication\n");
|
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);
|
boost::filesystem::path dataPath(m_dataPath);
|
||||||
if (! (boost::filesystem::exists(dataPath) && boost::filesystem::is_directory(dataPath)) )
|
if (! (boost::filesystem::exists(dataPath) && boost::filesystem::is_directory(dataPath)) )
|
||||||
{
|
{
|
||||||
|
@ -353,38 +367,30 @@ bool CApplication::Create()
|
||||||
SetLanguage(m_language);
|
SetLanguage(m_language);
|
||||||
|
|
||||||
//Create the sound instance.
|
//Create the sound instance.
|
||||||
if (!GetProfile().InitCurrentDirectory())
|
#ifdef OPENAL_SOUND
|
||||||
{
|
m_sound = static_cast<CSoundInterface *>(new ALSound());
|
||||||
GetLogger()->Warn("Config not found. Default values will be used!\n");
|
#else
|
||||||
m_sound = new CSoundInterface();
|
GetLogger()->Info("No sound support.\n");
|
||||||
|
m_sound = new CSoundInterface();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_sound->Create(true);
|
||||||
|
|
||||||
|
// Cache sound files
|
||||||
|
if (GetProfile().GetLocalProfileString("Resources", "Sound", path)) {
|
||||||
|
m_sound->CacheAll(path);
|
||||||
|
} else {
|
||||||
|
m_sound->CacheAll(GetDataSubdirPath(DIR_SOUND));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
std::string path;
|
|
||||||
if (GetProfile().GetLocalProfileString("Resources", "Data", path))
|
|
||||||
m_dataPath = path;
|
|
||||||
|
|
||||||
#ifdef OPENAL_SOUND
|
if (GetProfile().GetLocalProfileString("Resources", "Music", path)) {
|
||||||
m_sound = static_cast<CSoundInterface *>(new ALSound());
|
m_sound->AddMusicFiles(path);
|
||||||
#else
|
} else {
|
||||||
GetLogger()->Info("No sound support.\n");
|
m_sound->AddMusicFiles(GetDataSubdirPath(DIR_MUSIC));
|
||||||
m_sound = new CSoundInterface();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_sound->Create(true);
|
|
||||||
if (GetProfile().GetLocalProfileString("Resources", "Sound", path)) {
|
|
||||||
m_sound->CacheAll(path);
|
|
||||||
} else {
|
|
||||||
m_sound->CacheAll(GetDataSubdirPath(DIR_SOUND));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetProfile().GetLocalProfileString("Resources", "Music", path)) {
|
|
||||||
m_sound->AddMusicFiles(path);
|
|
||||||
} else {
|
|
||||||
m_sound->AddMusicFiles(GetDataSubdirPath(DIR_MUSIC));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GetLogger()->Info("CApplication created successfully\n");
|
||||||
|
|
||||||
std::string standardInfoMessage =
|
std::string standardInfoMessage =
|
||||||
"\nPlease see the console output or log file\n"
|
"\nPlease see the console output or log file\n"
|
||||||
"to get more information on the source of error";
|
"to get more information on the source of error";
|
||||||
|
@ -481,9 +487,9 @@ bool CApplication::Create()
|
||||||
// Create the robot application.
|
// Create the robot application.
|
||||||
m_robotMain = new CRobotMain(this);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue