From 64ebda0ab958ccd7b9046d833db79ce366395717 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Fri, 3 May 2013 21:34:10 +0200 Subject: Added creating ini file with default values --- src/app/app.cpp | 66 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 30 deletions(-) (limited to 'src/app/app.cpp') diff --git a/src/app/app.cpp b/src/app/app.cpp index 6231eb6..2d2df2b 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -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,38 +367,30 @@ 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(); + #ifdef OPENAL_SOUND + m_sound = static_cast(new ALSound()); + #else + 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 - m_sound = static_cast(new ALSound()); - #else - GetLogger()->Info("No sound support.\n"); - 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)); - } + 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 = "\nPlease see the console output or log file\n" "to get more information on the source of error"; @@ -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; } -- cgit v1.2.3-1-g7c22