From c0975dd80d9e976ad0edfdc62bf4cc555a737b02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=C2=ADn=20Lucas=20Golini?= Date: Fri, 17 Mar 2017 23:17:21 -0300 Subject: [PATCH] Code clean up and refactoring. Removed HaikuTTF from the project. --HG-- branch : dev --- include/eepp/system/translator.hpp | 6 +- include/eepp/window/engine.hpp | 9 - include/eepp/window/inputfinger.hpp | 6 +- include/eepp/window/joystickmanager.hpp | 2 +- premake4.lua | 10 - src/eepp/gaming/tilemap.cpp | 2 +- src/eepp/graphics/particlesystem.cpp | 2 +- src/eepp/graphics/sprite.cpp | 2 +- src/eepp/helper/haikuttf/haikuttf.hpp | 9 - src/eepp/helper/haikuttf/hkbase.hpp | 94 ---- src/eepp/helper/haikuttf/hkfont.cpp | 521 --------------------- src/eepp/helper/haikuttf/hkfont.hpp | 113 ----- src/eepp/helper/haikuttf/hkfontmanager.cpp | 189 -------- src/eepp/helper/haikuttf/hkfontmanager.hpp | 52 -- src/eepp/helper/haikuttf/hkglyph.cpp | 111 ----- src/eepp/helper/haikuttf/hkglyph.hpp | 67 --- src/eepp/helper/haikuttf/hkmutex.cpp | 82 ---- src/eepp/helper/haikuttf/hkmutex.hpp | 24 - src/eepp/physics/space.cpp | 2 +- src/eepp/ui/uimanager.cpp | 2 +- src/eepp/window/engine.cpp | 21 - src/eepp/window/input.cpp | 6 +- src/eepp/window/inputfinger.cpp | 10 +- src/eepp/window/joystickmanager.cpp | 4 +- src/examples/sprites/sprites.cpp | 2 +- src/test/eetest.cpp | 15 +- 26 files changed, 30 insertions(+), 1333 deletions(-) delete mode 100644 src/eepp/helper/haikuttf/haikuttf.hpp delete mode 100644 src/eepp/helper/haikuttf/hkbase.hpp delete mode 100644 src/eepp/helper/haikuttf/hkfont.cpp delete mode 100644 src/eepp/helper/haikuttf/hkfont.hpp delete mode 100644 src/eepp/helper/haikuttf/hkfontmanager.cpp delete mode 100644 src/eepp/helper/haikuttf/hkfontmanager.hpp delete mode 100644 src/eepp/helper/haikuttf/hkglyph.cpp delete mode 100644 src/eepp/helper/haikuttf/hkglyph.hpp delete mode 100644 src/eepp/helper/haikuttf/hkmutex.cpp delete mode 100644 src/eepp/helper/haikuttf/hkmutex.hpp diff --git a/include/eepp/system/translator.hpp b/include/eepp/system/translator.hpp index 2e1ce4854..43c34aaa0 100644 --- a/include/eepp/system/translator.hpp +++ b/include/eepp/system/translator.hpp @@ -14,9 +14,6 @@ class Pack; class Translator { public: - typedef std::map StringDictionary; - typedef std::map StringLocaleDictionary; - Translator( const std::locale& locale = std::locale() ); void loadFromDirectory( std::string dirPath, std::string ext = "xml" ); @@ -45,6 +42,9 @@ class Translator { void setCurrentLanguage( const std::string& currentLanguage ); protected: + typedef std::map StringDictionary; + typedef std::map StringLocaleDictionary; + std::string mDefaultLanguage; std::string mCurrentLanguage; StringLocaleDictionary mDictionary; diff --git a/include/eepp/window/engine.hpp b/include/eepp/window/engine.hpp index e8a363ae4..6178db1ea 100755 --- a/include/eepp/window/engine.hpp +++ b/include/eepp/window/engine.hpp @@ -39,15 +39,6 @@ class EE_API Engine { /** @return If any window is created. */ bool isRunning() const; - /** @return The current window elapsed time. */ - Time getElapsed() const; - - /** @return The current window width. */ - const Uint32& getWidth() const; - - /** @return The current window height */ - const Uint32& getHeight() const; - /** @return If the window instance is inside the window list. */ bool existsWindow( EE::Window::Window * window ); diff --git a/include/eepp/window/inputfinger.hpp b/include/eepp/window/inputfinger.hpp index 09acfa8c3..67e24a012 100644 --- a/include/eepp/window/inputfinger.hpp +++ b/include/eepp/window/inputfinger.hpp @@ -20,15 +20,15 @@ class InputFinger { float ydelta; Int32 last_x; Int32 last_y; - float last_pressure; + float lastPressure; bool down; - bool was_down; + bool wasDown; /** @return If is currently pressed */ bool isDown(); /** @return If was down in the last update */ - bool wasDown(); + bool getWasDown(); /** @return The current position of the finger */ Vector2i getPos(); diff --git a/include/eepp/window/joystickmanager.hpp b/include/eepp/window/joystickmanager.hpp index 830780896..6b3c796e9 100644 --- a/include/eepp/window/joystickmanager.hpp +++ b/include/eepp/window/joystickmanager.hpp @@ -14,7 +14,7 @@ class EE_API JoystickManager { virtual ~JoystickManager(); /** @return The number of joysticks attached to the system */ - virtual Uint32 count(); + virtual Uint32 getCount(); /** Update the states of all joysticks */ virtual void update() = 0; diff --git a/premake4.lua b/premake4.lua index 4786ee012..84dd148fb 100644 --- a/premake4.lua +++ b/premake4.lua @@ -493,8 +493,6 @@ function add_static_links() end end - links { "haikuttf-static" } - if _OPTIONS["with-static-freetype"] or not os_findlib("freetype") then print("Enabled static freetype") links { "freetype-static" } @@ -854,14 +852,6 @@ solution "eepp" includedirs { "include/eepp/helper/chipmunk" } build_base_configuration( "chipmunk" ) - project "haikuttf-static" - kind "StaticLib" - language "C++" - set_targetdir("libs/" .. os.get_real() .. "/helpers/") - files { "src/eepp/helper/haikuttf/*.cpp" } - includedirs { "src/eepp/helper/freetype2/include" } - build_base_cpp_configuration( "haikuttf" ) - project "jpeg-compressor-static" kind "StaticLib" language "C++" diff --git a/src/eepp/gaming/tilemap.cpp b/src/eepp/gaming/tilemap.cpp index fd88a36db..072c9a774 100644 --- a/src/eepp/gaming/tilemap.cpp +++ b/src/eepp/gaming/tilemap.cpp @@ -449,7 +449,7 @@ void TileMap::update() { mLightManager->update(); for ( Uint32 i = 0; i < mLayerCount; i++ ) - mLayers[i]->update( Engine::instance()->getElapsed() ); + mLayers[i]->update( mWindow->getElapsed() ); if ( mUpdateCb.IsSet() ) mUpdateCb(); diff --git a/src/eepp/graphics/particlesystem.cpp b/src/eepp/graphics/particlesystem.cpp index d124017e3..82796c71e 100755 --- a/src/eepp/graphics/particlesystem.cpp +++ b/src/eepp/graphics/particlesystem.cpp @@ -363,7 +363,7 @@ void ParticleSystem::draw() { } void ParticleSystem::update() { - update( Engine::instance()->getElapsed() ); + update( Engine::instance()->getCurrentWindow()->getElapsed() ); } void ParticleSystem::update( const System::Time& time ) { diff --git a/src/eepp/graphics/sprite.cpp b/src/eepp/graphics/sprite.cpp index e71e7ed73..548f8edae 100755 --- a/src/eepp/graphics/sprite.cpp +++ b/src/eepp/graphics/sprite.cpp @@ -482,7 +482,7 @@ bool Sprite::addSubFrame(const Uint32& TexId, const unsigned int& NumFrame, cons } void Sprite::update() { - update( Engine::instance()->getElapsed() ); + update( Engine::instance()->getCurrentWindow()->getElapsed() ); } void Sprite::update( const Time& ElapsedTime ) { diff --git a/src/eepp/helper/haikuttf/haikuttf.hpp b/src/eepp/helper/haikuttf/haikuttf.hpp deleted file mode 100644 index e14a49912..000000000 --- a/src/eepp/helper/haikuttf/haikuttf.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef HAIKUTTF_HPP -#define HAIKUTTF_HPP - -#include "hkbase.hpp" -#include "hkglyph.hpp" -#include "hkfont.hpp" -#include "hkfontmanager.hpp" - -#endif diff --git a/src/eepp/helper/haikuttf/hkbase.hpp b/src/eepp/helper/haikuttf/hkbase.hpp deleted file mode 100644 index ba2fb1e94..000000000 --- a/src/eepp/helper/haikuttf/hkbase.hpp +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef HAIKUTTF_HKBASE_HPP -#define HAIKUTTF_HKBASE_HPP - -namespace HaikuTTF { -typedef signed char s8; -typedef unsigned char u8; -typedef signed short s16; -typedef unsigned short u16; -typedef signed int s32; -typedef unsigned int u32; -} - -#define HK_PLATFORM_WIN (1) -#define HK_PLATFORM_LINUX (2) -#define HK_PLATFORM_MACOSX (3) -#define HK_PLATFORM_BSD (4) -#define HK_PLATFORM_SOLARIS (5) -#define HK_PLATFORM_HAIKU (6) - -#if defined( __WIN32__ ) || defined( _WIN32 ) || defined( _WIN64 ) - #define HK_PLATFORM HK_PLATFORM_WIN -#elif defined( __APPLE_CC__ ) || defined ( __APPLE__ ) - #define HK_PLATFORM HK_PLATFORM_MACOSX -#elif defined ( linux ) || defined( __linux__ ) - #define HK_PLATFORM HK_PLATFORM_LINUX -#elif defined( __FreeBSD__ ) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined( __DragonFly__ ) - #define HK_PLATFORM HK_PLATFORM_BSD -#elif defined( __SVR4 ) - #define HK_PLATFORM HK_PLATFORM_SOLARIS -#elif defined( __HAIKU__ ) || defined( __BEOS__ ) - #define HK_PLATFORM HK_PLATFORM_HAIKU -#endif - -#if defined ( linux ) || defined( __linux__ ) || defined( __FreeBSD__ ) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined( __DragonFly__ ) || defined( __SVR4 ) || defined( __APPLE_CC__ ) || defined ( __APPLE__ ) || defined( __HAIKU__ ) || defined( __BEOS__ ) || defined( __emscripten__ ) || defined( EMSCRIPTEN ) - #define HK_PLATFORM_POSIX -#endif - -#define NUM_GRAYS 256 - -#define FT_FLOOR(X) ( ( X & -64 ) / 64 ) -#define FT_CEIL(X) ( ( ( X + 63) & -64 ) / 64 ) - -#define CACHED_METRICS 0x10 -#define CACHED_BITMAP 0x01 -#define CACHED_PIXMAP 0x02 - -#define HK_TTF_STYLE_NORMAL (0x00) -#define HK_TTF_STYLE_BOLD (0x01) -#define HK_TTF_STYLE_ITALIC (0x02) -#define HK_TTF_STYLE_UNDERLINE (0x04) -#define HK_TTF_STYLE_STRIKETHROUGH (0x08) - -#define HK_TTF_HINTING_NORMAL (0) -#define HK_TTF_HINTING_LIGHT (1) -#define HK_TTF_HINTING_MONO (2) -#define HK_TTF_HINTING_NONE (3) - -#define HK_TTF_HANDLE_STYLE_BOLD(font) ( ( (font)->style() & HK_TTF_STYLE_BOLD ) && !( (font)->faceStyle() & HK_TTF_STYLE_BOLD ) ) -#define HK_TTF_HANDLE_STYLE_ITALIC(font) ( ( (font)->style() & HK_TTF_STYLE_ITALIC ) && !( (font)->faceStyle() & HK_TTF_STYLE_ITALIC ) ) -#define HK_TTF_HANDLE_STYLE_UNDERLINE(font) ( (font)->style() & HK_TTF_STYLE_UNDERLINE ) -#define HK_TTF_HANDLE_STYLE_STRIKETHROUGH(font) ( (font)->style() & HK_TTF_STYLE_STRIKETHROUGH ) - -#define HK_TTF_STYLE_NO_GLYPH_CHANGE ( HK_TTF_STYLE_UNDERLINE | HK_TTF_STYLE_STRIKETHROUGH ) - -#ifndef hkNew -#define hkNew( classType, constructor ) new classType constructor -#endif - -#ifndef hkNewArray -#define hkNewArray( classType, amount ) new classType [ amount ] -#endif - -#ifndef hkMalloc -#define hkMalloc( amount ) malloc( amount ) -#endif - -#ifndef hkDelete -#define hkDelete( data ) delete data; -#endif - -#ifndef hkDeleteArray -#define hkDeleteArray( data ) delete [] data; -#endif - -#ifndef hkFree -#define hkFree( data ) free(data); -#endif - -#define hkARRAY_SIZE(__array) ( sizeof(__array) / sizeof(__array[0]) ) -#define hkSAFE_DELETE(p) { if(p) { hkDelete (p); (p)=NULL; } } -#define hkSAFE_FREE(p) { if(p) { hkFree (p); (p)=NULL; } } -#define hkSAFE_DELETE_ARRAY(p) { if(p) { hkDeleteArray(p); (p)=NULL; } } - -#endif diff --git a/src/eepp/helper/haikuttf/hkfont.cpp b/src/eepp/helper/haikuttf/hkfont.cpp deleted file mode 100644 index f93c76bf7..000000000 --- a/src/eepp/helper/haikuttf/hkfont.cpp +++ /dev/null @@ -1,521 +0,0 @@ -#include "hkfont.hpp" -#include "hkfontmanager.hpp" -#include - -namespace HaikuTTF { - -hkFont::hkFont( hkFontManager * FontManager, unsigned int CacheSize ) : - mFm( FontManager ), - mCache(NULL), - mFace(NULL), - mHeight(0), - mAscent(0), - mDescent(0), - mLineSkip(0), - mFaceStyle(0), - mKerning(0), - mGlyphOverhang(0), - mGlyphItalics(0), - mUnderlineOffset(0), - mUnderlineHeight(0), - mCurrent(NULL), - mFontSizeFamily(0), - mStyle(0), - mOutline(0), - mHinting(0) -{ - mCacheSize = CacheSize; - mCache = hkNewArray( hkGlyph, mCacheSize ); -} - -hkFont::~hkFont() { - cacheFlush(); - - if ( NULL != mFace ) { - FT_Done_Face( mFace ); - mFace = NULL; - } - - hkSAFE_DELETE_ARRAY( mCache ); -} - -void hkFont::outline( int outline ) { - mOutline = outline; - cacheFlush(); -} - -void hkFont::hinting( int hinting ) { - if ( hinting == HK_TTF_HINTING_LIGHT ) - mHinting = FT_LOAD_TARGET_LIGHT; - else if ( hinting == HK_TTF_HINTING_MONO ) - mHinting= FT_LOAD_TARGET_MONO; - else if ( hinting == HK_TTF_HINTING_NONE ) - mHinting = FT_LOAD_NO_HINTING; - else - mHinting = 0; - - cacheFlush(); -} - -void hkFont::style( int style ) { - int prev_style = mFaceStyle; - mStyle = style | mFaceStyle; - - if ( ( mStyle | HK_TTF_STYLE_NO_GLYPH_CHANGE ) != ( prev_style | HK_TTF_STYLE_NO_GLYPH_CHANGE ) ) - cacheFlush(); -} - -int hkFont::underlineTopRow() { - return mAscent - mUnderlineOffset - 1; -} - -int hkFont::strikeThroughTopRow() { - return mHeight / 2; -} - -void hkFont::cacheFlush() { - for( int i = 0; i < (int)mCacheSize; ++i ) { - if( mCache[i].cached() ) - mCache[i].flush(); - } - - if( mScratch.cached() ) - mScratch.flush(); -} - -FT_Error hkFont::findGlyph(u32 ch, int want ) { - int retval = 0; - - if( ch < mCacheSize ) { - mCurrent = &mCache[ch]; - } else { - if ( mScratch.cached() != ch ) - mScratch.flush(); - - mCurrent = &mScratch; - } - - if ( ( mCurrent->stored() & want) != want ) - retval = loadGlyph( ch, mCurrent, want ); - - return retval; -} - -FT_Error hkFont::loadGlyph(u32 ch, hkGlyph * cached, int want ) { - FT_Face face; - FT_Error error; - FT_GlyphSlot glyph; - FT_Glyph_Metrics* metrics; - FT_Outline* outline; - - if ( NULL == mFace ) - return FT_Err_Invalid_Handle; - - face = mFace; - - mFm->mutexLock(); - - if ( !cached->index() ) - cached->index( FT_Get_Char_Index( face, ch ) ); - - error = FT_Load_Glyph( face, cached->index(), FT_LOAD_DEFAULT | mHinting ); - - if( error ) - return error; - - glyph = face->glyph; - metrics = &glyph->metrics; - outline = &glyph->outline; - - if ( ( want & CACHED_METRICS ) && !( cached->stored() & CACHED_METRICS ) ) { - if ( FT_IS_SCALABLE( face ) ) { - cached->minX( FT_FLOOR( metrics->horiBearingX ) ); - cached->maxX( cached->minX() + FT_CEIL( metrics->width ) ); - cached->maxY( FT_FLOOR( metrics->horiBearingY ) ); - cached->minY( cached->maxY() - FT_CEIL( metrics->height ) ); - cached->offsetY( mAscent - cached->maxY() ); - cached->advance( FT_CEIL( metrics->horiAdvance ) ); - } else { - cached->minX( FT_FLOOR( metrics->horiBearingX ) ); - cached->maxX( cached->minX() + FT_CEIL( metrics->horiAdvance ) ); - cached->maxY( FT_FLOOR( metrics->horiBearingY ) ); - cached->minY( cached->maxY() - FT_CEIL( face->available_sizes[ mFontSizeFamily ].height ) ); - cached->offsetY( 0 ); - cached->advance( FT_CEIL( metrics->horiAdvance ) ); - } - - if( HK_TTF_HANDLE_STYLE_BOLD(this) ) - cached->maxX( cached->maxX() + mGlyphOverhang ); - - if( HK_TTF_HANDLE_STYLE_ITALIC(this) ) - cached->maxX( cached->maxX() + (int)ceil( mGlyphItalics ) ); - - cached->stored( cached->stored() | CACHED_METRICS ); - } - - if ( ( want & CACHED_PIXMAP ) && !( cached->stored() & CACHED_PIXMAP) ) { - int mono = ( want & CACHED_BITMAP ); - int i; - FT_Bitmap* src; - FT_Bitmap* dst; - FT_Glyph bitmap_glyph = NULL; - - if( HK_TTF_HANDLE_STYLE_ITALIC(this) ) { - FT_Matrix shear; - - shear.xx = 1 << 16; - shear.xy = (int) ( mGlyphItalics * ( 1 << 16 ) ) / mHeight; - shear.yx = 0; - shear.yy = 1 << 16; - - FT_Outline_Transform( outline, &shear ); - } - - if( ( mOutline > 0 ) && glyph->format != FT_GLYPH_FORMAT_BITMAP ) { - FT_Stroker stroker; - FT_Get_Glyph( glyph, &bitmap_glyph ); - - error = FT_Stroker_New( mFm->getLibrary(), &stroker ); - - if( error ) - return error; - - FT_Stroker_Set( stroker, mOutline * 64, FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0 ); - FT_Glyph_Stroke( &bitmap_glyph, stroker, 1 ); - FT_Stroker_Done( stroker ); - - error = FT_Glyph_To_Bitmap( &bitmap_glyph, mono ? ft_render_mode_mono : ft_render_mode_normal, 0, 1 ); - - if( error ) { - FT_Done_Glyph( bitmap_glyph ); - return error; - } - - src = &((FT_BitmapGlyph)bitmap_glyph)->bitmap; - } else { - error = FT_Render_Glyph( glyph, mono ? ft_render_mode_mono : ft_render_mode_normal ); - - if( error ) - return error; - - src = &glyph->bitmap; - } - - dst = cached->pixmap(); - - memcpy( dst, src, sizeof( *dst ) ); - - if( HK_TTF_HANDLE_STYLE_BOLD(this) ) { - int bump = mGlyphOverhang; - dst->pitch += bump; - dst->width += bump; - } - - if( HK_TTF_HANDLE_STYLE_ITALIC(this) ) { - int bump = (int)ceil( mGlyphItalics ); - dst->pitch += bump; - dst->width += bump; - } - - if (dst->rows != 0) { - dst->buffer = (unsigned char*)hkMalloc( dst->pitch * dst->rows ); - - if( !dst->buffer ) { - return FT_Err_Out_Of_Memory; - } - memset( dst->buffer, 0, dst->pitch * dst->rows ); - - for( i = 0; i < src->rows; i++ ) { - int soffset = i * src->pitch; - int doffset = i * dst->pitch; - - memcpy( dst->buffer+doffset, src->buffer+soffset, src->pitch ); - } - } - - if ( HK_TTF_HANDLE_STYLE_BOLD(this) ) { - int row; - int col; - int offset; - int pixel; - u8* pixmap; - - for( row = dst->rows - 1; row >= 0; --row ) { - pixmap = (u8*) dst->buffer + row * dst->pitch; - - for( offset=1; offset <= mGlyphOverhang; ++offset ) { - for( col = dst->width - 1; col > 0; --col ) { - pixel = (pixmap[col] + pixmap[col-1]); - - if( pixel > NUM_GRAYS - 1 ) { - pixel = NUM_GRAYS - 1; - } - - pixmap[col] = (u8) pixel; - } - } - } - } - - cached->stored( cached->stored() | CACHED_PIXMAP ); - - if( bitmap_glyph ) { - FT_Done_Glyph( bitmap_glyph ); - } - } - - mFm->mutexUnlock(); - - cached->cached( ch ); - - return 0; -} - -unsigned char * hkFont::renderGlyph(u32 ch, u32 fg ) { - unsigned char * textbuf = NULL; - int row; - FT_Error error; - hkGlyph *glyph; - FT_Bitmap * bitmap; - - error = findGlyph( ch, CACHED_METRICS | CACHED_PIXMAP ); - - if ( error ) - return(NULL); - - glyph = mCurrent; - bitmap = glyph->pixmap(); - - textbuf = hkNewArray( unsigned char, bitmap->width * bitmap->rows * 4 ); - - if ( NULL == textbuf ) - return NULL; - - u32 * buffu32 = reinterpret_cast ( &textbuf[0] ); - - memset( buffu32, fg, bitmap->width * bitmap->rows * 4 ); - - const u8* pixels = bitmap->buffer; - u32 index; - - for ( int y = 0; y < bitmap->rows; y++ ) { - for ( int x = 0; x < bitmap->width; x++ ) { - index = (x + y * bitmap->width) * 4 + 3; - - textbuf[ index ] = pixels[ x ]; - } - - pixels += bitmap->pitch; - } - - if( HK_TTF_HANDLE_STYLE_UNDERLINE(this) ) { - row = underlineTopRow(); - drawLine( textbuf, row, fg, bitmap ); - } - - if( HK_TTF_HANDLE_STYLE_STRIKETHROUGH(this) ) { - row = strikeThroughTopRow(); - drawLine( textbuf, row, fg, bitmap ); - } - - return textbuf; -} - -int hkFont::getGlyphMetrics(u32 ch, int* minx, int* maxx, int* miny, int* maxy, int* advance ) { - FT_Error error; - - error = findGlyph( ch, CACHED_METRICS ); - - if ( error ) - return -1; - - if ( NULL != minx ) - *minx = mCurrent->minX() - mOutline; - - if ( NULL !=maxx ) { - *maxx = mCurrent->maxX() + mOutline; - - if( HK_TTF_HANDLE_STYLE_BOLD(this) ) - *maxx += mGlyphOverhang; - } - - if ( NULL !=miny ) - *miny = mCurrent->minY() - mOutline; - - if ( NULL !=maxy ) - *maxy = mCurrent->maxY() + mOutline; - - if ( NULL != advance ) { - *advance = mCurrent->advance() + mOutline; - - if( HK_TTF_HANDLE_STYLE_BOLD(this) ) - *advance += mGlyphOverhang; - } - - return 0; -} - -void hkFont::initLineMectrics( const unsigned char * textbuf, const int row, u8 **pdst, int *pheight, FT_Bitmap * bitmap ) { - u8 *dst; - int height; - - dst = (u8 *)textbuf; - - if( row > 0 ) - dst += row * bitmap->pitch; - - height = mUnderlineHeight; - - if( mOutline > 0 ) - height += mOutline * 2; - - *pdst = dst; - *pheight = height; -} - -void hkFont::drawLine( const unsigned char * textbuf, const int row, const u32 color, FT_Bitmap * bitmap ) { - int line; - u32 * dst_check = (u32*)textbuf + bitmap->pitch / 4 * bitmap->rows; - u8 * dst8; /* destination, byte version */ - u32 * dst; - int height; - int col; - - u32 pixel = color | 0xFF000000; - - initLineMectrics( textbuf, row, &dst8, &height, bitmap ); - dst = (u32 *) dst8; - - for ( line = height; line > 0 && dst < dst_check; --line ) { - for ( col = 0; col < bitmap->width; ++col ) - dst[col] = pixel; - - dst += bitmap->pitch / 4; - } -} - -void hkFont::face( FT_Face face ) { - mFace = face; -} - -FT_Face hkFont::face() { - return mFace; -} - -void hkFont::height( int height ) { - mHeight = height; -} - -int hkFont::height() { - return mHeight + mOutline; -} - -void hkFont::ascent( int ascent ) { - mAscent = ascent; -} - -int hkFont::ascent() { - return mAscent; -} - -void hkFont::descent( int descent ) { - mDescent = descent; -} - -int hkFont::descent() { - return mDescent; -} - -void hkFont::lineSkip( int lineskip ) { - mLineSkip = lineskip; -} - -int hkFont::lineSkip() { - return mLineSkip; -} - -void hkFont::faceStyle( int facestyle ) { - mFaceStyle = facestyle; -} - -int hkFont::faceStyle() { - return mFaceStyle; -} - -void hkFont::kerning( int kerning ) { - mKerning = kerning; -} - -int hkFont::kerning() { - return mKerning; -} - -void hkFont::glyphOverhang( int glyphoverhang ) { - mGlyphOverhang = glyphoverhang; -} - -int hkFont::glyphOverhang() { - return mGlyphOverhang; -} - -void hkFont::glyphItalics( float glyphitalics ) { - mGlyphItalics = glyphitalics; -} - -float hkFont::glyphItalics() { - return mGlyphItalics; -} - -void hkFont::underlineOffset( int underlineoffset ) { - mUnderlineOffset = underlineoffset; -} - -int hkFont::underlineOffset() { - return mUnderlineOffset; -} - -void hkFont::underlineHeight( int underlineheight ) { - mUnderlineHeight = underlineheight; -} - -int hkFont::underlineHeight() { - return mUnderlineHeight; -} - -void hkFont::current( hkGlyph * current ) { - mCurrent = current; -} - -hkGlyph * hkFont::current() { - return mCurrent; -} - -void hkFont::scratch( hkGlyph scratch ) { - mScratch = scratch; -} - -hkGlyph hkFont::scratch() { - return mScratch; -} - -void hkFont::fontSizeFamily( int fontsizefamily ) { - mFontSizeFamily = fontsizefamily; -} - -int hkFont::fontSizeFamily() { - return mFontSizeFamily; -} - -int hkFont::outline() const { - return mOutline; -} - -int hkFont::hinting() const { - return mHinting; -} - -int hkFont::style() { - return mStyle; -} - -} diff --git a/src/eepp/helper/haikuttf/hkfont.hpp b/src/eepp/helper/haikuttf/hkfont.hpp deleted file mode 100644 index 102ca62c2..000000000 --- a/src/eepp/helper/haikuttf/hkfont.hpp +++ /dev/null @@ -1,113 +0,0 @@ -#ifndef HAIKUTTF_HKFONT_HPP -#define HAIKUTTF_HKFONT_HPP - -#include "hkbase.hpp" -#include "hkglyph.hpp" - -namespace HaikuTTF { - -class hkFontManager; - -class hkFont { - public: - hkFont( hkFontManager * FontManager, unsigned int CacheSize = 256 ); - - ~hkFont(); - - void face( FT_Face face ); - FT_Face face(); - - void height( int height ); - int height(); - - void ascent( int ascent ); - int ascent(); - - void descent( int descent ); - int descent(); - - void lineSkip( int lineskip ); - int lineSkip(); - - void faceStyle( int facestyle ); - int faceStyle(); - - void kerning( int kerning ); - int kerning(); - - void glyphOverhang( int glyphoverhang ); - int glyphOverhang(); - - void glyphItalics( float glyphitalics ); - float glyphItalics(); - - void underlineOffset( int underlineoffset ); - int underlineOffset(); - - void underlineHeight( int underlineheight ); - int underlineHeight(); - - void current( hkGlyph * current ); - hkGlyph * current(); - - void scratch( hkGlyph scratch ); - hkGlyph scratch(); - - void fontSizeFamily( int fontsizefamily ); - int fontSizeFamily(); - - void outline( int outline ); - int outline() const; - - void hinting( int hinting ); - int hinting() const; - - void style( int style ); - int style(); - - FT_Error findGlyph( u32 ch, int want ); - - FT_Error loadGlyph( u32 ch, hkGlyph * cached, int want ); - - unsigned char * renderGlyph( u32 ch, u32 fg = 0x00000000 ); - - int getGlyphMetrics( u32 ch, int* minx, int* maxx, int* miny, int* maxy, int* advance ); - - void cacheFlush(); - protected: - friend class hkFontManager; - - hkFontManager * mFm; - hkGlyph * mCache; - unsigned int mCacheSize; - - FT_Face mFace; - int mHeight; - int mAscent; - int mDescent; - int mLineSkip; - int mFaceStyle; - int mKerning; - int mGlyphOverhang; - float mGlyphItalics; - int mUnderlineOffset; - int mUnderlineHeight; - hkGlyph * mCurrent; - hkGlyph mScratch; - int mFontSizeFamily; - int mStyle; - int mOutline; - int mHinting; - - int underlineTopRow(); - - int strikeThroughTopRow(); - - void drawLine( const unsigned char * textbuf, const int row, const u32 color, FT_Bitmap * bitmap ); - - void initLineMectrics( const unsigned char * textbuf, const int row, u8 **pdst, int *pheight, FT_Bitmap * bitmap ); -}; - -} - -#endif diff --git a/src/eepp/helper/haikuttf/hkfontmanager.cpp b/src/eepp/helper/haikuttf/hkfontmanager.cpp deleted file mode 100644 index ccb6b4719..000000000 --- a/src/eepp/helper/haikuttf/hkfontmanager.cpp +++ /dev/null @@ -1,189 +0,0 @@ -#include "hkfontmanager.hpp" - -namespace HaikuTTF { - -hkFontManager * hkFontManager::mSingleton = NULL; - -hkFontManager * hkFontManager::exists() { - return mSingleton; -} - -hkFontManager * hkFontManager::instance() { - if ( mSingleton == NULL ) { - mSingleton = hkNew( hkFontManager, () ); - } - - return mSingleton; -} - -void hkFontManager::destroySingleton() { - hkSAFE_DELETE( mSingleton ); -} - -hkFontManager::hkFontManager() : - mLibrary(NULL), - mInitialized(0) -{ - init(); -} - -hkFontManager::~hkFontManager() { - destroy(); -} - -int hkFontManager::init() { - int status = 0; - - if ( !mInitialized ) { - FT_Error error = FT_Init_FreeType( &mLibrary ); - - if ( error ) - status = -1; - } - - if ( status == 0 ) - ++mInitialized; - - return status; -} - -void hkFontManager::destroy() { - if ( mInitialized ) { - if ( --mInitialized == 0 ) { - FT_Done_FreeType( mLibrary ); - } - } -} - -int hkFontManager::wasInit() { - return mInitialized; -} - -void hkFontManager::closeFont( hkFont * Font ) { - hkSAFE_DELETE( Font ); -} - -hkFont * hkFontManager::openFromMemory( const u8* data, unsigned long size, int ptsize, long index, unsigned int glyphCacheSize ) { - if ( init() != 0 ) - return NULL; - - FT_Face face = NULL; - - mutexLock(); - - if ( FT_New_Memory_Face( mLibrary, reinterpret_cast(data), static_cast(size), index, &face ) != 0 ) - return NULL; - - if ( FT_Select_Charmap( face, FT_ENCODING_UNICODE ) != 0 ) - return NULL; - - mutexUnlock(); - - hkFont * Font = hkNew( hkFont, ( this, glyphCacheSize ) ); - - Font->face( face ); - - return fontPrepare( Font, ptsize ); -} - -hkFont * hkFontManager::openFromFile( const char* filename, int ptsize, long index, unsigned int glyphCacheSize ) { - if ( init() != 0 ) - return NULL; - - FT_Face face; - - mutexLock(); - - if ( FT_New_Face( mLibrary, filename, index, &face ) != 0 ) - return NULL; - - if ( FT_Select_Charmap(face, FT_ENCODING_UNICODE) != 0 ) - return NULL; - - mutexUnlock(); - - hkFont * Font = hkNew( hkFont, ( this, glyphCacheSize ) ); - - Font->face( face ); - - return fontPrepare( Font, ptsize ); -} - -hkFont * hkFontManager::fontPrepare( hkFont * font, int ptsize ) { - FT_Error error; - FT_Face face; - FT_Fixed scale; - - face = font->face(); - - if ( FT_IS_SCALABLE( face ) ) { - mutexLock(); - - error = FT_Set_Char_Size( font->face(), 0, ptsize * 64, 0, 0 ); - - if( error ) { - closeFont( font ); - - mutexUnlock(); - - return NULL; - } - - mutexUnlock(); - - scale = face->size->metrics.y_scale; - font->ascent( FT_CEIL( FT_MulFix( face->ascender, scale) ) ); - font->descent( FT_CEIL( FT_MulFix( face->descender, scale ) ) ); - font->height( font->ascent() - font->descent() + 1 ); - font->lineSkip( FT_CEIL( FT_MulFix( face->height, scale ) ) ); - font->underlineOffset( FT_FLOOR( FT_MulFix( face->underline_position, scale ) ) ); - font->underlineHeight( FT_FLOOR( FT_MulFix( face->underline_thickness, scale ) ) ); - } else { - if ( ptsize >= face->num_fixed_sizes ) - ptsize = face->num_fixed_sizes - 1; - - font->fontSizeFamily( ptsize ); - error = FT_Set_Pixel_Sizes( face, face->available_sizes[ptsize].height, face->available_sizes[ptsize].width ); - - font->ascent( face->available_sizes[ptsize].height ); - font->descent( 0 ); - font->height( face->available_sizes[ptsize].height ); - font->lineSkip( FT_CEIL( font->ascent() ) ); - font->underlineOffset( FT_FLOOR( face->underline_position ) ); - font->underlineHeight( FT_FLOOR( face->underline_thickness ) ); - } - - if ( font->underlineHeight() < 1 ) - font->underlineHeight( 1 ); - - font->faceStyle( HK_TTF_STYLE_NORMAL ); - - if ( face->style_flags & FT_STYLE_FLAG_BOLD ) - font->faceStyle( font->faceStyle() | HK_TTF_STYLE_BOLD ); - - if ( face->style_flags & FT_STYLE_FLAG_ITALIC ) - font->faceStyle( font->faceStyle() | HK_TTF_STYLE_ITALIC ); - - font->style( font->faceStyle() ); - font->outline( 0 ); - font->kerning( 1 ); - font->glyphOverhang( face->size->metrics.y_ppem / 10 ); - font->glyphItalics( 0.207f ); - font->glyphItalics( font->glyphItalics() * font->height() ); - - return font; -} - -void hkFontManager::mutexLock() { - lock(); -} - -void hkFontManager::mutexUnlock() { - unlock(); -} - -FT_Library hkFontManager::getLibrary() const { - return mLibrary; -} - -} diff --git a/src/eepp/helper/haikuttf/hkfontmanager.hpp b/src/eepp/helper/haikuttf/hkfontmanager.hpp deleted file mode 100644 index c36035315..000000000 --- a/src/eepp/helper/haikuttf/hkfontmanager.hpp +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef HAIKUTTF_HKFONTMANAGER_HPP -#define HAIKUTTF_HKFONTMANAGER_HPP - -#include "hkbase.hpp" -#include "hkglyph.hpp" -#include "hkfont.hpp" -#include "hkmutex.hpp" - -namespace HaikuTTF { - -class hkFontManager : private hkMutex { - static hkFontManager * mSingleton; - public: - static hkFontManager * exists(); - - static hkFontManager * instance(); - - static void destroySingleton(); - - hkFontManager(); - - ~hkFontManager(); - - int init(); - - void destroy(); - - int wasInit(); - - void closeFont( hkFont * Font ); - - hkFont * openFromMemory( const u8* data, unsigned long size, int ptsize, long index = 0, unsigned int glyphCacheSize = 256 ); - - hkFont * openFromFile( const char* filename, int ptsize, long index = 0, unsigned int glyphCacheSize = 256 ); - - FT_Library getLibrary() const; - protected: - friend class hkFont; - - FT_Library mLibrary; - int mInitialized; - - hkFont * fontPrepare( hkFont * font, int ptsize ); - - void mutexLock(); - - void mutexUnlock(); -}; - -} - -#endif diff --git a/src/eepp/helper/haikuttf/hkglyph.cpp b/src/eepp/helper/haikuttf/hkglyph.cpp deleted file mode 100644 index 1d687fd18..000000000 --- a/src/eepp/helper/haikuttf/hkglyph.cpp +++ /dev/null @@ -1,111 +0,0 @@ -#include "hkglyph.hpp" - -namespace HaikuTTF { - -hkGlyph::hkGlyph() : - mStored(0), - mIndex(0), - mMinX(0), - mMaxX(0), - mMinY(0), - mMaxY(0), - mOffsetY(0), - mAdvance(0), - mCached(0) -{ - memset( &mPixmap, 0, sizeof(mPixmap) ); -} - -hkGlyph::~hkGlyph() { - flush(); -} - -void hkGlyph::flush() { - mStored = 0; - mIndex = 0; - mCached = 0; - - hkSAFE_FREE( mPixmap.buffer ); -} - -int hkGlyph::stored() const { - return mStored; -} - -void hkGlyph::stored( int stored ) { - mStored = stored; -} - -FT_UInt hkGlyph::index() const { - return mIndex; -} - -void hkGlyph::index( FT_UInt index ) { - mIndex = index; -} - -FT_Bitmap * hkGlyph::pixmap() { - return &mPixmap; -} - -void hkGlyph::pixmap( const FT_Bitmap& pixmap ) { - mPixmap = pixmap; -} - -int hkGlyph::minX() const { - return mMinX; -} - -void hkGlyph::minX( int minx ) { - mMinX = minx; -} - -int hkGlyph::minY() const { - return mMinY; -} - -void hkGlyph::minY( int miny ) { - mMinY = miny; -} - -int hkGlyph::maxX() const { - return mMaxX; -} - -void hkGlyph::maxX( int maxx ) { - mMaxX = maxx; -} - -int hkGlyph::maxY() const { - return mMaxY; -} - -void hkGlyph::maxY( int maxy ) { - mMaxY = maxy; -} - -int hkGlyph::offsetY() const { - return mOffsetY; -} - -void hkGlyph::offsetY( int offsety ) { - mOffsetY = offsety; -} - -int hkGlyph::advance() const { - return mAdvance; -} - -void hkGlyph::advance( int advance ) { - mAdvance = advance; -} - -u16 hkGlyph::cached() const { - return mCached; -} - -void hkGlyph::cached( u16 cached ) { - mCached = cached; -} - -} diff --git a/src/eepp/helper/haikuttf/hkglyph.hpp b/src/eepp/helper/haikuttf/hkglyph.hpp deleted file mode 100644 index 64e4bdb2f..000000000 --- a/src/eepp/helper/haikuttf/hkglyph.hpp +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef HAIKUTTF_HKGLYPH_HPP -#define HAIKUTTF_HKGLYPH_HPP - -#include "hkbase.hpp" - -#include -#include FT_FREETYPE_H -#include FT_OUTLINE_H -#include FT_STROKER_H -#include FT_GLYPH_H -#include FT_TRUETYPE_IDS_H - -namespace HaikuTTF { - -class hkGlyph { - public: - hkGlyph(); - - ~hkGlyph(); - - int stored() const; - void stored( int stored ); - - FT_UInt index() const; - void index( FT_UInt index ); - - FT_Bitmap * pixmap(); - void pixmap( const FT_Bitmap& pixmap ); - - int minX() const; - void minX( int minx ); - - int minY() const; - void minY( int miny ); - - int maxX() const; - void maxX( int maxx ); - - int maxY() const; - void maxY( int maxy ); - - int offsetY() const; - void offsetY( int offsety ); - - int advance() const; - void advance( int advance ); - - u16 cached() const; - void cached( u16 cached ); - - void flush(); - protected: - int mStored; - FT_UInt mIndex; - FT_Bitmap mPixmap; - int mMinX; - int mMaxX; - int mMinY; - int mMaxY; - int mOffsetY; - int mAdvance; - u16 mCached; -}; - -} - -#endif diff --git a/src/eepp/helper/haikuttf/hkmutex.cpp b/src/eepp/helper/haikuttf/hkmutex.cpp deleted file mode 100644 index 3ebd8dd62..000000000 --- a/src/eepp/helper/haikuttf/hkmutex.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "hkmutex.hpp" - -namespace HaikuTTF { - -#if HK_PLATFORM == HK_PLATFORM_WIN - -#ifndef WIN32_LEAN_AND_MEAN - #define WIN32_LEAN_AND_MEAN -#endif -#ifndef NOMINMAX - #define NOMINMAX -#endif -#include - -class hkMutexImpl { - public: - hkMutexImpl() { - InitializeCriticalSection(&mMutex); - } - - ~hkMutexImpl() { - DeleteCriticalSection(&mMutex); - } - - void Lock() { - EnterCriticalSection(&mMutex); - } - - void Unlock() { - LeaveCriticalSection(&mMutex); - } - protected: - CRITICAL_SECTION mMutex; -}; - -#elif defined( HK_PLATFORM_POSIX ) - -#include -class hkMutexImpl { - public: - hkMutexImpl() { - pthread_mutex_init(&mMutex, NULL); - } - - ~hkMutexImpl() { - pthread_mutex_destroy(&mMutex); - } - - void Lock() { - pthread_mutex_lock(&mMutex); - } - - void Unlock() { - pthread_mutex_unlock(&mMutex); - } - protected: - pthread_mutex_t mMutex; -}; - -#endif - -hkMutex::hkMutex() : - mImpl( hkNew( hkMutexImpl, () ) ) -{ -} - -hkMutex::~hkMutex() { - hkSAFE_DELETE( mImpl ) -} - -void hkMutex::lock() { - mImpl->Lock(); -} - -void hkMutex::unlock() { - mImpl->Unlock(); -} - -} - - - diff --git a/src/eepp/helper/haikuttf/hkmutex.hpp b/src/eepp/helper/haikuttf/hkmutex.hpp deleted file mode 100644 index e9e4e25c8..000000000 --- a/src/eepp/helper/haikuttf/hkmutex.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef HAIKUTTF_HKMUTEX_HPP -#define HAIKUTTF_HKMUTEX_HPP - -#include "hkbase.hpp" - -namespace HaikuTTF { - -class hkMutexImpl; - -class hkMutex { - public: - hkMutex(); - - ~hkMutex(); - - void lock(); - - void unlock(); - protected: - hkMutexImpl * mImpl; -}; - -} -#endif diff --git a/src/eepp/physics/space.cpp b/src/eepp/physics/space.cpp index fc8b4388c..873bd92b0 100644 --- a/src/eepp/physics/space.cpp +++ b/src/eepp/physics/space.cpp @@ -64,7 +64,7 @@ void Space::step( const cpFloat& dt ) { void Space::update() { #ifdef PHYSICS_RENDERER_ENABLED - step( Window::Engine::instance()->getElapsed().asSeconds() ); + step( Window::Engine::instance()->getCurrentWindow()->getElapsed().asSeconds() ); #else Step( 1 / 60 ); #endif diff --git a/src/eepp/ui/uimanager.cpp b/src/eepp/ui/uimanager.cpp index 0a409279b..0b09ffb61 100644 --- a/src/eepp/ui/uimanager.cpp +++ b/src/eepp/ui/uimanager.cpp @@ -58,7 +58,7 @@ void UIManager::init( Uint32 Flags, EE::Window::Window * window ) { mControl = UIWindow::New(); mControl->setFlags( UI_REPORT_SIZE_CHANGE_TO_CHILDS ); mControl->setStyleConfig( windowStyleConfig ); - mControl->setSize( (Float)Engine::instance()->getWidth() / PixelDensity::getPixelDensity(), (Float)Engine::instance()->getHeight() / PixelDensity::getPixelDensity() ); + mControl->setSize( (Float)mWindow->getWidth() / PixelDensity::getPixelDensity(), (Float)mWindow->getHeight() / PixelDensity::getPixelDensity() ); mControl->setVisible( true ); mControl->setEnabled( true ); mControl->getContainer()->setEnabled( false ); diff --git a/src/eepp/window/engine.cpp b/src/eepp/window/engine.cpp index e6ce1fd00..3c2a22b53 100755 --- a/src/eepp/window/engine.cpp +++ b/src/eepp/window/engine.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -69,8 +68,6 @@ Engine::~Engine() { Log::destroySingleton(); - HaikuTTF::hkFontManager::destroySingleton(); - #ifdef EE_SSL_SUPPORT Network::SSL::SSLSocket::end(); #endif @@ -215,24 +212,6 @@ bool Engine::isRunning() const { return NULL != mWindow; } -Time Engine::getElapsed() const { - eeASSERT( isRunning() ); - - return mWindow->getElapsed(); -} - -const Uint32& Engine::getWidth() const { - eeASSERT( isRunning() ); - - return mWindow->getWidth(); -} - -const Uint32& Engine::getHeight() const { - eeASSERT( isRunning() ); - - return mWindow->getHeight(); -} - Uint32 Engine::getDefaultBackend() const { #if DEFAULT_BACKEND == BACKEND_SDL2 return WindowBackend::SDL2; diff --git a/src/eepp/window/input.cpp b/src/eepp/window/input.cpp index 6e0dcf876..1a8257b43 100644 --- a/src/eepp/window/input.cpp +++ b/src/eepp/window/input.cpp @@ -157,7 +157,7 @@ void Input::processEvent( InputEvent * Event ) { Finger->y = (Uint16)( Event->finger.y * (Float)mWindow->getHeight() ); Finger->pressure = Event->finger.pressure; Finger->down = false; - Finger->was_down = true; + Finger->wasDown = true; Finger->xdelta = Event->finger.dx; Finger->ydelta = Event->finger.dy; @@ -222,7 +222,7 @@ InputFinger * Input::getFingerId( const Int64 &fingerId ) { void Input::resetFingerWasDown() { for ( Uint32 i = 0; i < EE_MAX_FINGERS; i++ ) { - mFingers[i].was_down = false; + mFingers[i].wasDown = false; } } @@ -429,7 +429,7 @@ std::list Input::getFingersWasDown() { std::list fDown; for ( Uint32 i = 0; i < EE_MAX_FINGERS; i++ ) { - if ( mFingers[i].was_down ) { + if ( mFingers[i].wasDown ) { fDown.push_back( &mFingers[i] ); } } diff --git a/src/eepp/window/inputfinger.cpp b/src/eepp/window/inputfinger.cpp index 98052259e..5b643e385 100644 --- a/src/eepp/window/inputfinger.cpp +++ b/src/eepp/window/inputfinger.cpp @@ -11,9 +11,9 @@ InputFinger::InputFinger() : ydelta(0), last_x(0), last_y(0), - last_pressure(0), + lastPressure(0), down(false), - was_down(false) + wasDown(false) { } @@ -21,8 +21,8 @@ bool InputFinger::isDown() { return down; } -bool InputFinger::wasDown() { - return was_down; +bool InputFinger::getWasDown() { + return wasDown; } Vector2i InputFinger::getPos() { @@ -32,7 +32,7 @@ Vector2i InputFinger::getPos() { void InputFinger::writeLast() { last_x = x; last_y = y; - last_pressure = pressure; + lastPressure = pressure; } }} diff --git a/src/eepp/window/joystickmanager.cpp b/src/eepp/window/joystickmanager.cpp index dbac85325..48e27f545 100644 --- a/src/eepp/window/joystickmanager.cpp +++ b/src/eepp/window/joystickmanager.cpp @@ -13,13 +13,13 @@ JoystickManager::JoystickManager() : } JoystickManager::~JoystickManager() { - for ( Uint32 i = 0; i < count(); i++ ) + for ( Uint32 i = 0; i < getCount(); i++ ) eeSAFE_DELETE( mJoysticks[i] ); close(); } -Uint32 JoystickManager::count() { +Uint32 JoystickManager::getCount() { return mCount; } diff --git a/src/examples/sprites/sprites.cpp b/src/examples/sprites/sprites.cpp index ebcec868a..d52f2d54e 100644 --- a/src/examples/sprites/sprites.cpp +++ b/src/examples/sprites/sprites.cpp @@ -137,7 +137,7 @@ EE_MAIN_FUNC int main (int argc, char * argv []) P.setFillMode( DRAW_LINE ); // Set the sprites position to the screen center - Vector2i ScreenCenter( Engine::instance()->getWidth() / 2, Engine::instance()->getHeight() / 2 ); + Vector2i ScreenCenter( Engine::instance()->getCurrentWindow()->getWidth() / 2, Engine::instance()->getCurrentWindow()->getHeight() / 2 ); Planet.setPosition( ScreenCenter.x - Planet.getAABB().getSize().getWidth() / 2, ScreenCenter.y - Planet.getAABB().getSize().getHeight() / 2 ); diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index f6cd75894..67709d687 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -508,7 +508,6 @@ void EETest::createUI() { void EETest::createNewUI() { std::vector str = getTestStringArr(); - /* UIRadioButton * ctrl = UIRadioButton::New(); ctrl->setPosition( 50, 100 )->setSize( 200, 32 ); ctrl->setBackgroundFillEnabled( true )->setColor( 0x33333333 ); @@ -522,7 +521,7 @@ void EETest::createNewUI() { cbox->setBorderEnabled( true )->setColor( 0x66666666 ); cbox->setText( "Happy CheckBox :)" ); cbox->setFontColor( 0x000000FF ); - + /* UIImage * gfx = UIImage::New(); gfx->setPosition( 50, 140 )->setSize( 16, 16 ); gfx->setBackgroundFillEnabled( true )->setColor( 0x33333333 ); @@ -641,7 +640,7 @@ void EETest::createNewUI() { TabWidget->add( "Tab 2", UIWidget::New()->setThemeControl( "winback" ), mTheme->getIconByName( "go-up" ) ); TabWidget->add( "Tab 3", UIWidget::New()->setThemeControl( "winback" ), mTheme->getIconByName( "add" ) ); - /**/ + */ /* UIWindow * win = UIWindow::New(); win->setSize( 500, 500 ); @@ -689,7 +688,7 @@ void EETest::createNewUI() { drop->getListBox()->addListBoxItems( { "Car", "Bus", "Plane", "Submarine" } ); drop->getListBox()->setSelected(0); win->show(); - /**/ + */ /* UIWindow * win2 = UIWindow::New(); @@ -709,7 +708,7 @@ void EETest::createNewUI() { ->setLayoutPositionRule( LEFT_OF, ofBut )->setParent( rlay ); win2->show(); - /**/ + UIManager::instance()->loadLayoutFromString( "" @@ -730,7 +729,7 @@ void EETest::createNewUI() { " " "" ); - + */ } void EETest::createMapEditor() { @@ -1593,8 +1592,8 @@ void EETest::input() { nmX = eemax( nmX, 0 ); nmY = eemax( nmY, 0 ); - nmX = eemin( nmX, (Float)EE->getWidth() ); - nmY = eemin( nmY, (Float)EE->getHeight() ); + nmX = eemin( nmX, (Float)EE->getCurrentWindow()->getWidth() ); + nmY = eemin( nmY, (Float)EE->getCurrentWindow()->getHeight() ); KM->injectMousePos( (Int32)nmX, (Int32)nmY );