diff --git a/include/eepp/graphics/fonttruetypeloader.hpp b/include/eepp/graphics/fonttruetypeloader.hpp index 30c59da8d..e5fa68274 100644 --- a/include/eepp/graphics/fonttruetypeloader.hpp +++ b/include/eepp/graphics/fonttruetypeloader.hpp @@ -74,12 +74,6 @@ class EE_API FontTrueTypeLoader : public ObjectLoader { std::string mFontName; std::string mFilepath; - unsigned int mSize; - Uint16 mNumCharsToGen; - RGB mFontColor; - Uint8 mOutlineSize; - RGB mOutlineColor; - bool mAddPixelSeparator; Pack * mPack; Uint8 * mData; unsigned int mDataSize; diff --git a/include/eepp/system/inifile.hpp b/include/eepp/system/inifile.hpp index c02ae2276..69d64558c 100755 --- a/include/eepp/system/inifile.hpp +++ b/include/eepp/system/inifile.hpp @@ -17,6 +17,7 @@ #define CINIFILE_H #include +#include #define MAX_KEYNAME 128 #define MAX_VALUENAME 128 @@ -39,6 +40,9 @@ class EE_API IniFile { /** Initialize and load the ini file from a pack file */ IniFile (Pack * Pack, std::string iniPackPath, const bool& shouldReadFile = true ); + /** Initialize and load the ini file from a stream */ + IniFile (IOStream& stream, const bool& shouldReadFile = true ); + virtual ~IniFile() {} /** Loads an ini file from path */ @@ -50,6 +54,9 @@ class EE_API IniFile { /** Loads an ini file from a pack file */ bool loadFromPack( Pack * Pack, std::string iniPackPath ); + /** Loads an ini file from a stream */ + bool loadFromStream( IOStream& stream ); + /** Sets whether or not keynames and valuenames should be case sensitive. ** The default is case insensitive. */ void caseSensitive() {mCaseInsensitive = false;} diff --git a/include/eepp/window/window.hpp b/include/eepp/window/window.hpp index b0c5cadd1..59671e51b 100644 --- a/include/eepp/window/window.hpp +++ b/include/eepp/window/window.hpp @@ -217,6 +217,9 @@ class EE_API Window { /** @return The window size */ virtual Sizei getSize(); + /** @return The window center point */ + Vector2f getCenter(); + /** @return The resolutions that support the video card */ virtual std::vector getDisplayModes() const = 0; @@ -287,13 +290,13 @@ class EE_API Window { const View& getDefaultView() const; /** This will set the default rendering states and view to render in 2D mode */ - void setup2D( const bool& KeepView = false ); + void setup2D( const bool& KeepView = true ); /** Set a new 2D projection matrix */ void set2DProjection( const Uint32& Width, const Uint32& Height ); /** Set the current Viewport ( and creates a new ortho proyection if needed ) */ - void setViewport( const Int32& x, const Int32& y, const Uint32& Width, const Uint32& Height, const bool& UpdateProjectionMatrix = true ); + void setViewport( const Int32& x, const Int32& y, const Uint32& Width, const Uint32& Height ); /** Set the window background color */ void setClearColor( const RGB& Color ); diff --git a/projects/linux/ee.includes b/projects/linux/ee.includes index 606425468..630938ff1 100644 --- a/projects/linux/ee.includes +++ b/projects/linux/ee.includes @@ -2,5 +2,3 @@ ../../include/ ../../src/thirdparty ../../include/eepp/thirdparty -../../src/eepp/system -../../include/eepp/system diff --git a/src/eepp/graphics/fonttruetypeloader.cpp b/src/eepp/graphics/fonttruetypeloader.cpp index 35ffda543..a3f325df2 100644 --- a/src/eepp/graphics/fonttruetypeloader.cpp +++ b/src/eepp/graphics/fonttruetypeloader.cpp @@ -40,7 +40,7 @@ FontTrueTypeLoader::FontTrueTypeLoader( const std::string& FontName, Uint8* TTFD FontTrueTypeLoader::FontTrueTypeLoader( const std::string& FontName, IOStream& stream ) : ObjectLoader( FontLoader ), - mLoadType( TTF_LT_MEM ), + mLoadType( TTF_LT_STREAM ), mFontName( FontName ), mIOStream( &stream ), mFontLoaded( false ) diff --git a/src/eepp/system/inifile.cpp b/src/eepp/system/inifile.cpp index ac1b9a93e..66cb1db92 100755 --- a/src/eepp/system/inifile.cpp +++ b/src/eepp/system/inifile.cpp @@ -44,6 +44,16 @@ IniFile::IniFile( Pack * Pack, std::string iniPackPath, const bool& shouldReadFi readFile(); } +IniFile::IniFile( IOStream& stream, const bool& shouldReadFile ) : + mCaseInsensitive( true ), + mIniReaded( false ) +{ + loadFromStream( stream ); + + if ( shouldReadFile ) + readFile(); +} + bool IniFile::loadFromPack( Pack * Pack, std::string iniPackPath ) { if ( NULL != Pack && Pack->isOpen() && -1 != Pack->exists( iniPackPath ) ) { SafeDataPointer PData; @@ -56,9 +66,13 @@ bool IniFile::loadFromPack( Pack * Pack, std::string iniPackPath ) { return false; } -bool IniFile::loadFromMemory( const Uint8* RAWData, const Uint32& size ) { - std::string myfile; - myfile.assign( reinterpret_cast (RAWData), size ); +bool IniFile::loadFromStream( IOStream& stream ) { + if ( !stream.isOpen() ) + return false; + + std::string myfile( (size_t)stream.getSize(), '\0' ); + + stream.read( (char*)&myfile[0], stream.getSize() ); clear(); mLines.clear(); @@ -67,24 +81,17 @@ bool IniFile::loadFromMemory( const Uint8* RAWData, const Uint32& size ) { return true; } +bool IniFile::loadFromMemory( const Uint8* RAWData, const Uint32& size ) { + IOStreamMemory f( reinterpret_cast( RAWData ), size ); + return loadFromStream( f ); +} + bool IniFile::loadFromFile( const std::string& iniPath ) { path ( iniPath ); if ( FileSystem::fileExists( iniPath ) ) { IOStreamFile f( mPath ); - - if ( !f.isOpen() ) - return false; - - std::string myfile( (size_t)f.getSize(), '\0' ); - - f.read( (char*)&myfile[0], f.getSize() ); - - clear(); - mLines.clear(); - mLines = String::split( myfile ); - - return true; + return loadFromStream( f ); } else if ( PackManager::instance()->isFallbackToPacksActive() ) { std::string tPath( iniPath ); diff --git a/src/eepp/window/window.cpp b/src/eepp/window/window.cpp index c2d31eda5..f3da23da5 100644 --- a/src/eepp/window/window.cpp +++ b/src/eepp/window/window.cpp @@ -66,6 +66,10 @@ Sizei Window::getSize() { return Sizei( mWindow.WindowConfig.Width, mWindow.WindowConfig.Height ); } +Vector2f Window::getCenter() { + return Sizef( mWindow.WindowConfig.Width, mWindow.WindowConfig.Height ) * 0.5f; +} + const Uint32& Window::getWidth() const { return mWindow.WindowConfig.Width; } @@ -100,19 +104,18 @@ void Window::set2DProjection( const Uint32& Width, const Uint32& Height ) { GLi->loadIdentity(); } -void Window::setViewport( const Int32& x, const Int32& y, const Uint32& Width, const Uint32& Height, const bool& UpdateProjectionMatrix ) { +void Window::setViewport(const Int32& x, const Int32& y, const Uint32& Width, const Uint32& Height ) { GLi->viewport( x, getHeight() - ( y + Height ), Width, Height ); - - if ( UpdateProjectionMatrix ) { - set2DProjection( Width, Height ); - } } void Window::setView( const View& View ) { mCurrentView = &View; Rect RView = mCurrentView->getView(); + setViewport( RView.Left, RView.Top, RView.Right, RView.Bottom ); + + set2DProjection( RView.Right, RView.Bottom ); } const View& Window::getDefaultView() const {