summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorkrzys-h <krzys_h@interia.pl>2013-05-04 11:56:03 +0200
committerkrzys-h <krzys_h@interia.pl>2013-05-04 11:56:03 +0200
commit6333d2d38e9801f67925cae194b07abcf8f1260e (patch)
treef19554b9449afcd3f540f7a133d35cb043c65db7 /src
parentc3e95d40a2839fb8d00ff7b1c61aa513da0ebcea (diff)
downloadcolobot-6333d2d38e9801f67925cae194b07abcf8f1260e.tar.gz
colobot-6333d2d38e9801f67925cae194b07abcf8f1260e.tar.bz2
colobot-6333d2d38e9801f67925cae194b07abcf8f1260e.zip
Removed most of "No such node" messages
Diffstat (limited to 'src')
-rw-r--r--src/app/app.cpp9
-rw-r--r--src/common/profile.cpp37
-rw-r--r--src/common/profile.h5
-rw-r--r--src/object/robotmain.cpp48
-rw-r--r--src/object/robotmain.h2
-rw-r--r--src/ui/maindialog.cpp3
6 files changed, 69 insertions, 35 deletions
diff --git a/src/app/app.cpp b/src/app/app.cpp
index 79c00c9..616caf9 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -364,6 +364,8 @@ bool CApplication::Create()
return false;
}
+ GetProfile().SetLocalProfileString("Resources", "Data", m_dataPath);
+
SetLanguage(m_language);
//Create the sound instance.
@@ -377,6 +379,11 @@ bool CApplication::Create()
m_sound->Create(true);
// Cache sound files
+ if (defaultValues) {
+ GetProfile().SetLocalProfileString("Resources", "Sound", GetDataSubdirPath(DIR_SOUND));
+ GetProfile().SetLocalProfileString("Resources", "Music", GetDataSubdirPath(DIR_MUSIC));
+ }
+
if (GetProfile().GetLocalProfileString("Resources", "Sound", path)) {
m_sound->CacheAll(path);
} else {
@@ -485,7 +492,7 @@ bool CApplication::Create()
m_modelManager = new Gfx::CModelManager(m_engine);
// Create the robot application.
- m_robotMain = new CRobotMain(this);
+ m_robotMain = new CRobotMain(this, !defaultValues);
if (defaultValues) m_robotMain->CreateIni();
diff --git a/src/common/profile.cpp b/src/common/profile.cpp
index f165119..0bc40cf 100644
--- a/src/common/profile.cpp
+++ b/src/common/profile.cpp
@@ -39,21 +39,7 @@ CProfile::CProfile() :
CProfile::~CProfile()
{
- if (m_profileNeedSave)
- {
- try
- {
- #ifdef NDEBUG
- bp::ini_parser::write_ini(GetSystemUtils()->profileFileLocation(), m_propertyTree);
- #else
- bp::ini_parser::write_ini("colobot.ini", m_propertyTree);
- #endif
- }
- catch (std::exception & e)
- {
- GetLogger()->Error("Error on storing profile: %s\n", e.what());
- }
- }
+ SaveCurrentDirectory();
}
@@ -75,7 +61,26 @@ bool CProfile::InitCurrentDirectory()
return true;
}
-
+bool CProfile::SaveCurrentDirectory()
+{
+ if (m_profileNeedSave)
+ {
+ try
+ {
+ #ifdef NDEBUG
+ bp::ini_parser::write_ini(GetSystemUtils()->profileFileLocation(), m_propertyTree);
+ #else
+ bp::ini_parser::write_ini("colobot.ini", m_propertyTree);
+ #endif
+ }
+ catch (std::exception & e)
+ {
+ GetLogger()->Error("Error on storing profile: %s\n", e.what());
+ return false;
+ }
+ }
+ return true;
+}
bool CProfile::SetLocalProfileString(std::string section, std::string key, std::string value)
{
diff --git a/src/common/profile.h b/src/common/profile.h
index 7f99d81..ba797e9 100644
--- a/src/common/profile.h
+++ b/src/common/profile.h
@@ -50,6 +50,11 @@ class CProfile : public CSingleton<CProfile>
*/
bool InitCurrentDirectory();
+ /** Saves colobot.ini to current directory
+ * \return return true on success
+ */
+ bool SaveCurrentDirectory();
+
/** Sets string value in section under specified key
* \param section
* \param key
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index 1ca9e82..d291397 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -606,7 +606,7 @@ bool rPoint(CBotVar* pThis, CBotVar* var, CBotVar* pResult, int& Exception)
//! Constructor of robot application
-CRobotMain::CRobotMain(CApplication* app)
+CRobotMain::CRobotMain(CApplication* app, bool loadProfile)
{
m_app = app;
@@ -709,22 +709,26 @@ CRobotMain::CRobotMain(CApplication* app)
float fValue;
int iValue;
- if (GetProfile().GetLocalProfileFloat("Edit", "FontSize", fValue)) m_fontSize = fValue;
- if (GetProfile().GetLocalProfileFloat("Edit", "WindowPosX", fValue)) m_windowPos.x = fValue;
- if (GetProfile().GetLocalProfileFloat("Edit", "WindowPosY", fValue)) m_windowPos.y = fValue;
- if (GetProfile().GetLocalProfileFloat("Edit", "WindowDimX", fValue)) m_windowDim.x = fValue;
- if (GetProfile().GetLocalProfileFloat("Edit", "WindowDimY", fValue)) m_windowDim.y = fValue;
+ if (loadProfile) {
+ if (GetProfile().GetLocalProfileFloat("Edit", "FontSize", fValue)) m_fontSize = fValue;
+ if (GetProfile().GetLocalProfileFloat("Edit", "WindowPosX", fValue)) m_windowPos.x = fValue;
+ if (GetProfile().GetLocalProfileFloat("Edit", "WindowPosY", fValue)) m_windowPos.y = fValue;
+ if (GetProfile().GetLocalProfileFloat("Edit", "WindowDimX", fValue)) m_windowDim.x = fValue;
+ if (GetProfile().GetLocalProfileFloat("Edit", "WindowDimY", fValue)) m_windowDim.y = fValue;
+ }
m_IOPublic = false;
m_IODim = Math::Point(320.0f/640.0f, (121.0f+18.0f*8)/480.0f);
m_IOPos.x = (1.0f-m_IODim.x)/2.0f; // in the middle
m_IOPos.y = (1.0f-m_IODim.y)/2.0f;
- if (GetProfile().GetLocalProfileInt ("Edit", "IOPublic", iValue)) m_IOPublic = iValue;
- if (GetProfile().GetLocalProfileFloat("Edit", "IOPosX", fValue)) m_IOPos.x = fValue;
- if (GetProfile().GetLocalProfileFloat("Edit", "IOPosY", fValue)) m_IOPos.y = fValue;
- if (GetProfile().GetLocalProfileFloat("Edit", "IODimX", fValue)) m_IODim.x = fValue;
- if (GetProfile().GetLocalProfileFloat("Edit", "IODimY", fValue)) m_IODim.y = fValue;
+ if (loadProfile) {
+ if (GetProfile().GetLocalProfileInt ("Edit", "IOPublic", iValue)) m_IOPublic = iValue;
+ if (GetProfile().GetLocalProfileFloat("Edit", "IOPosX", fValue)) m_IOPos.x = fValue;
+ if (GetProfile().GetLocalProfileFloat("Edit", "IOPosY", fValue)) m_IOPos.y = fValue;
+ if (GetProfile().GetLocalProfileFloat("Edit", "IODimX", fValue)) m_IODim.x = fValue;
+ if (GetProfile().GetLocalProfileFloat("Edit", "IODimY", fValue)) m_IODim.y = fValue;
+ }
m_short->FlushShortcuts();
InitEye();
@@ -741,10 +745,10 @@ CRobotMain::CRobotMain(CApplication* app)
g_unit = UNIT;
m_gamerName = "";
- GetProfile().GetLocalProfileString("Gamer", "LastName", m_gamerName);
+ if (loadProfile) GetProfile().GetLocalProfileString("Gamer", "LastName", m_gamerName);
SetGlobalGamerName(m_gamerName);
ReadFreeParam();
- m_dialog->SetupRecall();
+ if (loadProfile) m_dialog->SetupRecall();
for (int i = 0; i < MAXSHOWLIMIT; i++)
{
@@ -904,10 +908,20 @@ Ui::CDisplayText* CRobotMain::GetDisplayText()
//! Creates the file colobot.ini at the first time
void CRobotMain::CreateIni()
{
- int iValue;
- // colobot.ini doesn't exist?
- if (!GetProfile().GetLocalProfileInt("Setup", "TotoMode", iValue))
- m_dialog->SetupMemorize();
+ m_dialog->SetupMemorize();
+
+ GetProfile().SetLocalProfileFloat("Edit", "FontSize", m_fontSize);
+ GetProfile().SetLocalProfileFloat("Edit", "WindowPosX", m_windowPos.x);
+ GetProfile().SetLocalProfileFloat("Edit", "WindowPosY", m_windowPos.y);
+ GetProfile().SetLocalProfileFloat("Edit", "WindowDimX", m_windowDim.x);
+ GetProfile().SetLocalProfileFloat("Edit", "WindowDimY", m_windowDim.y);
+ GetProfile().SetLocalProfileInt("Edit", "IOPublic", m_IOPublic);
+ GetProfile().SetLocalProfileFloat("Edit", "IOPosX", m_IOPos.x);
+ GetProfile().SetLocalProfileFloat("Edit", "IOPosY", m_IOPos.y);
+ GetProfile().SetLocalProfileFloat("Edit", "IODimX", m_IODim.x);
+ GetProfile().SetLocalProfileFloat("Edit", "IODimY", m_IODim.y);
+
+ GetProfile().SaveCurrentDirectory();
}
void CRobotMain::SetDefaultInputBindings()
diff --git a/src/object/robotmain.h b/src/object/robotmain.h
index adabf64..a459a59 100644
--- a/src/object/robotmain.h
+++ b/src/object/robotmain.h
@@ -191,7 +191,7 @@ const int AXIS_INVALID = -1;
class CRobotMain : public CSingleton<CRobotMain>
{
public:
- CRobotMain(CApplication* app);
+ CRobotMain(CApplication* app, bool loadProfile);
~CRobotMain();
Gfx::CCamera* GetCamera();
diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp
index 0b0b848..1b87a04 100644
--- a/src/ui/maindialog.cpp
+++ b/src/ui/maindialog.cpp
@@ -5509,6 +5509,7 @@ void CMainDialog::SetupMemorize()
GetProfile().SetLocalProfileInt("Setup", "HimselfDamage", m_bHimselfDamage);
GetProfile().SetLocalProfileInt("Setup", "CameraScroll", m_bCameraScroll);
GetProfile().SetLocalProfileInt("Setup", "CameraInvertX", m_bCameraInvertX);
+ GetProfile().SetLocalProfileInt("Setup", "CameraInvertY", m_bCameraInvertY);
GetProfile().SetLocalProfileInt("Setup", "InterfaceEffect", m_bEffect);
GetProfile().SetLocalProfileInt("Setup", "GroundShadow", m_engine->GetShadow());
GetProfile().SetLocalProfileInt("Setup", "GroundSpot", m_engine->GetGroundSpot());
@@ -5544,6 +5545,8 @@ void CMainDialog::SetupMemorize()
if ( pl != 0 ) {
GetProfile().SetLocalProfileInt("Setup", "Resolution", pl->GetSelect());
}
+ } else {
+ // TODO: Default value
}
std::stringstream key;