mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-06-02 19:46:29 +03:00
Minor clean up and fixes.
--HG-- branch : dev-2.1
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#define CINIFILE_H
|
||||
|
||||
#include <eepp/system/base.hpp>
|
||||
#include <eepp/system/iostream.hpp>
|
||||
|
||||
#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;}
|
||||
|
||||
@@ -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<DisplayMode> 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 );
|
||||
|
||||
@@ -2,5 +2,3 @@
|
||||
../../include/
|
||||
../../src/thirdparty
|
||||
../../include/eepp/thirdparty
|
||||
../../src/eepp/system
|
||||
../../include/eepp/system
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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<const char*> (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<const char*>( 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 );
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user