Removed most of "No such node" messages

dev-ui
krzys-h 2013-05-04 11:56:03 +02:00
parent c3e95d40a2
commit 6333d2d38e
6 changed files with 69 additions and 35 deletions

View File

@ -364,6 +364,8 @@ bool CApplication::Create()
return false; return false;
} }
GetProfile().SetLocalProfileString("Resources", "Data", m_dataPath);
SetLanguage(m_language); SetLanguage(m_language);
//Create the sound instance. //Create the sound instance.
@ -377,6 +379,11 @@ bool CApplication::Create()
m_sound->Create(true); m_sound->Create(true);
// Cache sound files // 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)) { if (GetProfile().GetLocalProfileString("Resources", "Sound", path)) {
m_sound->CacheAll(path); m_sound->CacheAll(path);
} else { } else {
@ -485,7 +492,7 @@ bool CApplication::Create()
m_modelManager = new Gfx::CModelManager(m_engine); m_modelManager = new Gfx::CModelManager(m_engine);
// Create the robot application. // Create the robot application.
m_robotMain = new CRobotMain(this); m_robotMain = new CRobotMain(this, !defaultValues);
if (defaultValues) m_robotMain->CreateIni(); if (defaultValues) m_robotMain->CreateIni();

View File

@ -39,21 +39,7 @@ CProfile::CProfile() :
CProfile::~CProfile() CProfile::~CProfile()
{ {
if (m_profileNeedSave) SaveCurrentDirectory();
{
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());
}
}
} }
@ -75,7 +61,26 @@ bool CProfile::InitCurrentDirectory()
return true; 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) bool CProfile::SetLocalProfileString(std::string section, std::string key, std::string value)
{ {

View File

@ -50,6 +50,11 @@ class CProfile : public CSingleton<CProfile>
*/ */
bool InitCurrentDirectory(); bool InitCurrentDirectory();
/** Saves colobot.ini to current directory
* \return return true on success
*/
bool SaveCurrentDirectory();
/** Sets string value in section under specified key /** Sets string value in section under specified key
* \param section * \param section
* \param key * \param key

View File

@ -606,7 +606,7 @@ bool rPoint(CBotVar* pThis, CBotVar* var, CBotVar* pResult, int& Exception)
//! Constructor of robot application //! Constructor of robot application
CRobotMain::CRobotMain(CApplication* app) CRobotMain::CRobotMain(CApplication* app, bool loadProfile)
{ {
m_app = app; m_app = app;
@ -709,22 +709,26 @@ CRobotMain::CRobotMain(CApplication* app)
float fValue; float fValue;
int iValue; int iValue;
if (GetProfile().GetLocalProfileFloat("Edit", "FontSize", fValue)) m_fontSize = fValue; if (loadProfile) {
if (GetProfile().GetLocalProfileFloat("Edit", "WindowPosX", fValue)) m_windowPos.x = fValue; if (GetProfile().GetLocalProfileFloat("Edit", "FontSize", fValue)) m_fontSize = fValue;
if (GetProfile().GetLocalProfileFloat("Edit", "WindowPosY", fValue)) m_windowPos.y = fValue; if (GetProfile().GetLocalProfileFloat("Edit", "WindowPosX", fValue)) m_windowPos.x = fValue;
if (GetProfile().GetLocalProfileFloat("Edit", "WindowDimX", fValue)) m_windowDim.x = fValue; if (GetProfile().GetLocalProfileFloat("Edit", "WindowPosY", fValue)) m_windowPos.y = fValue;
if (GetProfile().GetLocalProfileFloat("Edit", "WindowDimY", fValue)) m_windowDim.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_IOPublic = false;
m_IODim = Math::Point(320.0f/640.0f, (121.0f+18.0f*8)/480.0f); 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.x = (1.0f-m_IODim.x)/2.0f; // in the middle
m_IOPos.y = (1.0f-m_IODim.y)/2.0f; m_IOPos.y = (1.0f-m_IODim.y)/2.0f;
if (GetProfile().GetLocalProfileInt ("Edit", "IOPublic", iValue)) m_IOPublic = iValue; if (loadProfile) {
if (GetProfile().GetLocalProfileFloat("Edit", "IOPosX", fValue)) m_IOPos.x = fValue; if (GetProfile().GetLocalProfileInt ("Edit", "IOPublic", iValue)) m_IOPublic = iValue;
if (GetProfile().GetLocalProfileFloat("Edit", "IOPosY", fValue)) m_IOPos.y = fValue; if (GetProfile().GetLocalProfileFloat("Edit", "IOPosX", fValue)) m_IOPos.x = fValue;
if (GetProfile().GetLocalProfileFloat("Edit", "IODimX", fValue)) m_IODim.x = fValue; if (GetProfile().GetLocalProfileFloat("Edit", "IOPosY", fValue)) m_IOPos.y = fValue;
if (GetProfile().GetLocalProfileFloat("Edit", "IODimY", fValue)) m_IODim.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(); m_short->FlushShortcuts();
InitEye(); InitEye();
@ -741,10 +745,10 @@ CRobotMain::CRobotMain(CApplication* app)
g_unit = UNIT; g_unit = UNIT;
m_gamerName = ""; m_gamerName = "";
GetProfile().GetLocalProfileString("Gamer", "LastName", m_gamerName); if (loadProfile) GetProfile().GetLocalProfileString("Gamer", "LastName", m_gamerName);
SetGlobalGamerName(m_gamerName); SetGlobalGamerName(m_gamerName);
ReadFreeParam(); ReadFreeParam();
m_dialog->SetupRecall(); if (loadProfile) m_dialog->SetupRecall();
for (int i = 0; i < MAXSHOWLIMIT; i++) for (int i = 0; i < MAXSHOWLIMIT; i++)
{ {
@ -904,10 +908,20 @@ Ui::CDisplayText* CRobotMain::GetDisplayText()
//! Creates the file colobot.ini at the first time //! Creates the file colobot.ini at the first time
void CRobotMain::CreateIni() void CRobotMain::CreateIni()
{ {
int iValue; m_dialog->SetupMemorize();
// colobot.ini doesn't exist?
if (!GetProfile().GetLocalProfileInt("Setup", "TotoMode", iValue)) GetProfile().SetLocalProfileFloat("Edit", "FontSize", m_fontSize);
m_dialog->SetupMemorize(); 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() void CRobotMain::SetDefaultInputBindings()

View File

@ -191,7 +191,7 @@ const int AXIS_INVALID = -1;
class CRobotMain : public CSingleton<CRobotMain> class CRobotMain : public CSingleton<CRobotMain>
{ {
public: public:
CRobotMain(CApplication* app); CRobotMain(CApplication* app, bool loadProfile);
~CRobotMain(); ~CRobotMain();
Gfx::CCamera* GetCamera(); Gfx::CCamera* GetCamera();

View File

@ -5509,6 +5509,7 @@ void CMainDialog::SetupMemorize()
GetProfile().SetLocalProfileInt("Setup", "HimselfDamage", m_bHimselfDamage); GetProfile().SetLocalProfileInt("Setup", "HimselfDamage", m_bHimselfDamage);
GetProfile().SetLocalProfileInt("Setup", "CameraScroll", m_bCameraScroll); GetProfile().SetLocalProfileInt("Setup", "CameraScroll", m_bCameraScroll);
GetProfile().SetLocalProfileInt("Setup", "CameraInvertX", m_bCameraInvertX); GetProfile().SetLocalProfileInt("Setup", "CameraInvertX", m_bCameraInvertX);
GetProfile().SetLocalProfileInt("Setup", "CameraInvertY", m_bCameraInvertY);
GetProfile().SetLocalProfileInt("Setup", "InterfaceEffect", m_bEffect); GetProfile().SetLocalProfileInt("Setup", "InterfaceEffect", m_bEffect);
GetProfile().SetLocalProfileInt("Setup", "GroundShadow", m_engine->GetShadow()); GetProfile().SetLocalProfileInt("Setup", "GroundShadow", m_engine->GetShadow());
GetProfile().SetLocalProfileInt("Setup", "GroundSpot", m_engine->GetGroundSpot()); GetProfile().SetLocalProfileInt("Setup", "GroundSpot", m_engine->GetGroundSpot());
@ -5544,6 +5545,8 @@ void CMainDialog::SetupMemorize()
if ( pl != 0 ) { if ( pl != 0 ) {
GetProfile().SetLocalProfileInt("Setup", "Resolution", pl->GetSelect()); GetProfile().SetLocalProfileInt("Setup", "Resolution", pl->GetSelect());
} }
} else {
// TODO: Default value
} }
std::stringstream key; std::stringstream key;