diff --git a/include/eepp/system/inifile.hpp b/include/eepp/system/inifile.hpp index 9850fd6be..3d9e9f771 100755 --- a/include/eepp/system/inifile.hpp +++ b/include/eepp/system/inifile.hpp @@ -112,9 +112,7 @@ class EE_API IniFile { int getValueI ( std::string const keyname, std::string const valuename, int const defValue = 0 ) const; /** Gets the value as boolean */ - bool getValueB ( std::string const keyname, std::string const valuename, bool const defValue = false ) const { - return 0 != ( getValueI ( keyname, valuename, int ( defValue ) ) ); - } + bool getValueB ( std::string const keyname, std::string const valuename, bool const defValue = false ) const; /** Gets the value as double */ double getValueF ( std::string const keyname, std::string const valuename, double const defValue = 0.0 ) const; diff --git a/src/eepp/system/inifile.cpp b/src/eepp/system/inifile.cpp index e9df05a4f..f34845866 100755 --- a/src/eepp/system/inifile.cpp +++ b/src/eepp/system/inifile.cpp @@ -353,6 +353,12 @@ int IniFile::getValueI ( std::string const keyname, std::string const valuename, return atoi ( getValue ( keyname, valuename, svalue ).c_str() ); } +bool IniFile::getValueB(const std::string keyname, const std::string valuename, const bool defValue) const { + std::string val = getValue ( keyname, valuename, defValue ? "1" : "0" ); + char fist = !val.empty() ? val[0] : '0'; + return fist == '1' || fist == 't' || fist == 'y' || fist == 'T' || fist == 'Y'; +} + double IniFile::getValueF ( std::string const keyname, std::string const valuename, double const defValue ) const { char svalue[MAX_VALUEDATA]; diff --git a/src/examples/fonts/fonts.cpp b/src/examples/fonts/fonts.cpp index 4ca3ef31e..d82ec3b31 100644 --- a/src/examples/fonts/fonts.cpp +++ b/src/examples/fonts/fonts.cpp @@ -44,14 +44,14 @@ EE_MAIN_FUNC int main (int argc, char * argv []) { // Check if created if ( win->isOpen() ) { - // Get the application path - std::string AppPath = Sys::getProcessPath(); + // Set the application current directory path + FileSystem::changeWorkingDirectory( Sys::getProcessPath() ); // Create a new text string String Txt( "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." ); fontTest = FontTrueType::New( "DejaVuSansMono" ); - fontTest->loadFromFile( AppPath + "assets/fonts/DejaVuSansMono.ttf" ); + fontTest->loadFromFile( "assets/fonts/DejaVuSansMono.ttf" ); text.setFont( fontTest ); text.setCharacterSize( 24 ); @@ -68,7 +68,7 @@ EE_MAIN_FUNC int main (int argc, char * argv []) { } fontTest2 = FontTrueType::New( "NotoSans-Regular" ); - fontTest2->loadFromFile( AppPath + "assets/fonts/NotoSans-Regular.ttf" ); + fontTest2->loadFromFile( "assets/fonts/NotoSans-Regular.ttf" ); text2.setFont( fontTest2 ); text2.setString( "Lorem ipsum dolor sit amet, consectetur adipisicing elit." ); diff --git a/src/examples/sound/sound.cpp b/src/examples/sound/sound.cpp index de2cb4b75..417687ad9 100644 --- a/src/examples/sound/sound.cpp +++ b/src/examples/sound/sound.cpp @@ -1,15 +1,12 @@ #include -// Get the process path to be used to load the sounds ( it is safer ) -std::string AppPath = Sys::getProcessPath(); - /// Play a sound void playSound() { // The sound manager class simplyfies the load of a SoundBuffer and the creation of the Sound // It manages the sound playing, if the sound channel is already playing, it will open a new channel to play the sound SoundManager SoundManager; - if ( SoundManager.loadFromFile( "sound", AppPath + "assets/sounds/sound.ogg" ) ) { + if ( SoundManager.loadFromFile( "sound", "assets/sounds/sound.ogg" ) ) { // Get the sound buffer to display the buffer information SoundBuffer& buffer = SoundManager.getBuffer( "sound" ); @@ -29,7 +26,7 @@ void playMusic() { // Load an ogg music file Music music; - if (!music.openFromFile( AppPath + "assets/sounds/music.ogg" ) ) + if (!music.openFromFile( "assets/sounds/music.ogg" ) ) return; // Display music informations @@ -57,6 +54,9 @@ void playMusic() { /// Entry point of application EE_MAIN_FUNC int main (int argc, char * argv []) { + // Set the application current directory path + FileSystem::changeWorkingDirectory( Sys::getProcessPath() ); + // Play a sound playSound(); diff --git a/src/examples/sprites/sprites.cpp b/src/examples/sprites/sprites.cpp index baa10a936..4ac2bc01c 100644 --- a/src/examples/sprites/sprites.cpp +++ b/src/examples/sprites/sprites.cpp @@ -95,15 +95,15 @@ EE_MAIN_FUNC int main (int argc, char * argv []) // Check if created if ( win->isOpen() ) { - // Get the application path - std::string AppPath = Sys::getProcessPath(); + // Set the application current directory path + FileSystem::changeWorkingDirectory( Sys::getProcessPath() ); // Load the rock texture - Uint32 PlanetId = TextureFactory::instance()->loadFromFile( AppPath + "assets/sprites/7.png" ); - Uint32 RockId = TextureFactory::instance()->loadFromFile( AppPath + "assets/sprites/5.png" ); + Uint32 PlanetId = TextureFactory::instance()->loadFromFile( "assets/sprites/7.png" ); + Uint32 RockId = TextureFactory::instance()->loadFromFile( "assets/sprites/5.png" ); // Load a previously generated texture atlas that contains the SubTextures needed to load an animated sprite - TextureAtlasLoader Blindies( AppPath + "assets/atlases/bnb.eta" ); + TextureAtlasLoader Blindies( "assets/atlases/bnb.eta" ); // Create the animated rock spriteR // Load the rock frames from the texture, adding the frames manually diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index 15a3fe7b5..1ae84a588 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -120,7 +120,9 @@ void EETest::init() { mTerrainUp = true; relLay = NULL; - MyPath = Sys::getProcessPath() + "assets/"; + MyPath = "assets/"; + + FileSystem::changeWorkingDirectory( Sys::getProcessPath() ); IniFile Ini( MyPath + "ee.ini" );