Fixed IniFile::getValueB.

Added FileSystem::changeWorkingDirectory( Sys::getProcessPath() ); in demos.

--HG--
branch : dev
This commit is contained in:
Martín Lucas Golini
2017-12-29 22:35:43 -03:00
parent e28f606f38
commit f907d89367
6 changed files with 24 additions and 18 deletions

View File

@@ -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;

View File

@@ -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];

View File

@@ -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." );

View File

@@ -1,15 +1,12 @@
#include <eepp/ee.hpp>
// 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();

View File

@@ -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

View File

@@ -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" );