summaryrefslogtreecommitdiffstats
path: root/src/app/app.cpp
diff options
context:
space:
mode:
authorkrzys-h <krzys_h@interia.pl>2013-05-03 21:34:10 +0200
committerkrzys-h <krzys_h@interia.pl>2013-05-03 21:35:33 +0200
commit64ebda0ab958ccd7b9046d833db79ce366395717 (patch)
treef105cda6c66c9dbf2be48a4ea8ad21c27a5c473d /src/app/app.cpp
parent5a31a936105a070856740b3e2431350d97214b1d (diff)
downloadcolobot-64ebda0ab958ccd7b9046d833db79ce366395717.tar.gz
colobot-64ebda0ab958ccd7b9046d833db79ce366395717.tar.bz2
colobot-64ebda0ab958ccd7b9046d833db79ce366395717.zip
Added creating ini file with default values
Diffstat (limited to 'src/app/app.cpp')
-rw-r--r--src/app/app.cpp66
1 files changed, 36 insertions, 30 deletions
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<CSoundInterface *>(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<CSoundInterface *>(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;
}