From f7ffec103f83ffd277ca6801c3d2813949e0d79a Mon Sep 17 00:00:00 2001 From: spartanj Date: Sun, 19 Dec 2010 05:02:39 -0300 Subject: [PATCH] Removed eeRGB and eeRGBA from the projects, and removed the parameter ColorKey in favor to the use of CreateMaskFromColor or setting the color key manually in the cTextureLoader. Now the user can add new theme elements to search on the theme loading ( to be able to expand the themes without touching the source code of the library ). --- Makefile | 20 +++++- src/graphics/cconsole.cpp | 24 +++---- src/graphics/cconsole.hpp | 26 +++++--- src/graphics/cfont.cpp | 6 +- src/graphics/cscrollparallax.cpp | 4 +- src/graphics/cscrollparallax.hpp | 4 +- src/graphics/csprite.cpp | 2 +- src/graphics/csprite.hpp | 2 +- src/graphics/ctexture.cpp | 10 +-- src/graphics/ctexture.hpp | 11 +--- src/graphics/ctexturefactory.cpp | 25 ++++--- src/graphics/ctexturefactory.hpp | 13 ++-- src/graphics/ctextureloader.cpp | 22 ++++--- src/graphics/ctextureloader.hpp | 14 ++-- src/graphics/cttffont.cpp | 2 +- src/test/ee.cpp | 22 ++++--- src/ui/cuigfx.cpp | 9 +-- src/ui/cuigfx.hpp | 10 +-- src/ui/cuisprite.cpp | 6 +- src/ui/cuisprite.hpp | 4 +- src/ui/cuitheme.cpp | 109 +++++++++++++++++-------------- src/ui/cuitheme.hpp | 2 + src/utils/colors.hpp | 104 ----------------------------- src/window/cinput.cpp | 8 ++- src/window/cinput.hpp | 2 + 25 files changed, 193 insertions(+), 268 deletions(-) diff --git a/Makefile b/Makefile index 2cd5deee4..5dc252436 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ LIBSIV = -lX11 -lXcursor OTHERINC = -I/usr/include/freetype2 else ifeq ($(OS), darwin) -LIBS = -lfreetype -lSDL -lSDLmain -lsndfile -framework OpenGL -framework GLUT -framework OpenAL -framework Cocoa -framework CoreFoundation +LIBS = -lfreetype -lSDL -lSDLmain -lsndfile -framework OpenGL -framework GLUT -framework OpenAL -framework Cocoa -framework CoreFoundation -framework AGL LIBSIV = OTHERINC = -I/usr/include/freetype2 endif @@ -63,6 +63,7 @@ endif EXE = eetest-$(RELEASETYPE) EXEIV = eeiv-$(RELEASETYPE) +EXEFLUID = eefluid-$(RELEASETYPE) SRCGLEW = $(wildcard ./src/helper/glew/*.c) SRCSOIL = $(wildcard ./src/helper/SOIL/*.c) @@ -83,6 +84,7 @@ SRCWINDOW = $(wildcard ./src/window/*.cpp) SRCTEST = $(wildcard ./src/test/*.cpp) SRCEEIV = $(wildcard ./src/eeiv/*.cpp) +SRCFLUID = $(wildcard ./src/fluid/*.cpp) SRCHELPERS = $(SRCGLEW) $(SRCSOIL) $(SRCSTBVORBIS) $(SRCZLIB) $(SRCLIBZIP) SRCMODULES = $(SRCHAIKUTTF) $(SRCBASE) $(SRCAUDIO) $(SRCGAMING) $(SRCGRAPHICS) $(SRCMATH) $(SRCSYSTEM) $(SRCUI) $(SRCUTILS) $(SRCWINDOW) @@ -112,6 +114,7 @@ OBJMODULES = $(OBJHAIKUTTF) $(OBJBASE) $(OBJUTILS) $(OBJMATH) $(OBJSYSTEM) $(O OBJTEST = $(SRCTEST:.cpp=.o) OBJEEIV = $(SRCEEIV:.cpp=.o) +OBJFLUID = $(SRCFLUID:.cpp=.o) OBJDIR = obj/$(OS)/$(RELEASETYPE)/ @@ -120,8 +123,9 @@ FOBJMODULES = $(patsubst ./%, $(OBJDIR)%, $(OBJHAIKUTTF) $(OBJBASE) $(OBJUTILS FOBJTEST = $(patsubst ./%, $(OBJDIR)%, $(SRCTEST:.cpp=.o) ) FOBJEEIV = $(patsubst ./%, $(OBJDIR)%, $(SRCEEIV:.cpp=.o) ) +FOBJFLUID = $(patsubst ./%, $(OBJDIR)%, $(SRCFLUID:.cpp=.o) ) -FOBJEEPP = $(FOBJMODULES) $(FOBJTEST) $(FOBJEEIV) +FOBJEEPP = $(FOBJMODULES) $(FOBJTEST) $(FOBJEEIV) $(FOBJFLUID) FOBJALL = $(FOBJHELPERS) $(FOBJEEPP) DEPSEEPP = $(FOBJEEPP:.o=.d) @@ -148,6 +152,7 @@ dirs: @mkdir -p $(OBJDIR)/src/window @mkdir -p $(OBJDIR)/src/test @mkdir -p $(OBJDIR)/src/eeiv + @mkdir -p $(OBJDIR)/src/fluid lib: dirs $(LIB) @@ -157,7 +162,7 @@ $(FOBJMODULES): $(FOBJHELPERS): $(CC) -o $@ -c $(patsubst $(OBJDIR)%.o,%.c,$@) $(CFLAGSEXT) -DSTBI_FAILURE_USERMSG - @$(CC) -MT $@ -MM $(patsubst $(OBJDIR)%.o,%.c,$@) -DSTBI_FAILURE_USERMSG > $(patsubst %.o,%.d,$@) + @$(CC) -MT $@ -MM $(patsubst $(OBJDIR)%.o,%.c,$@) -DSTBI_FAILURE_USERMSG > $(patsubst %.o,%.d,$@) $(FOBJTEST): $(CPP) -o $@ -c $(patsubst $(OBJDIR)%.o,%.cpp,$@) $(CFLAGS) $(OTHERINC) @@ -167,6 +172,13 @@ $(FOBJEEIV): $(CPP) -o $@ -c $(patsubst $(OBJDIR)%.o,%.cpp,$@) $(CFLAGS) $(OTHERINC) @$(CPP) -MT $@ -MM $(patsubst $(OBJDIR)%.o,%.cpp,$@) $(OTHERINC) > $(patsubst %.o,%.d,$@) +$(FOBJFLUID): + $(CPP) -o $@ -c $(patsubst $(OBJDIR)%.o,%.cpp,$@) $(CFLAGS) $(OTHERINC) + @$(CPP) -MT $@ -MM $(patsubst $(OBJDIR)%.o,%.cpp,$@) $(OTHERINC) > $(patsubst %.o,%.d,$@) + +$(EXEFLUID): $(FOBJHELPERS) $(FOBJMODULES) $(FOBJFLUID) + $(CPP) -o ./$(EXEFLUID) $(FOBJHELPERS) $(FOBJMODULES) $(FOBJFLUID) $(LDFLAGS) $(LIBS) + $(EXEIV): $(FOBJHELPERS) $(FOBJMODULES) $(FOBJEEIV) $(CPP) -o ./$(EXEIV) $(FOBJHELPERS) $(FOBJMODULES) $(FOBJEEIV) $(LDFLAGS) $(LIBS) $(LIBSIV) @@ -186,6 +198,8 @@ test: dirs $(EXE) eeiv: dirs $(EXEIV) +fluid: dirs $(EXEFLUID) + docs: doxygen ./Doxyfile diff --git a/src/graphics/cconsole.cpp b/src/graphics/cconsole.cpp index b1ec7da35..4f8714d35 100755 --- a/src/graphics/cconsole.cpp +++ b/src/graphics/cconsole.cpp @@ -24,23 +24,11 @@ cConsole::~cConsole() { cInput::instance()->PopCallback( mMyCallback ); } -void cConsole::Create( cFont* Font, const bool& MakeDefaultCommands, const eeUint& MaxLogLines, const Uint32& TextureId, const eeRGBA& ConsoleColor, const eeRGBA& ConsoleLineColor, const eeRGBA& FontColor, const eeRGBA& FontLineColor ) { +void cConsole::Create( cFont* Font, const bool& MakeDefaultCommands, const eeUint& MaxLogLines, const Uint32& TextureId ) { mFont = Font; mFontSize = (eeFloat)mFont->GetFontSize(); - if ( !FontColor.voidRGB ) - mFontColor = FontColor; - - if ( !FontLineColor.voidRGB ) - mFontLineColor = FontLineColor; - - if ( !ConsoleColor.voidRGB ) - mConColor = ConsoleColor; - - if ( !ConsoleLineColor.voidRGB ) - mConLineColor = ConsoleLineColor; - if ( TextureId > 0 ) mTexId = TextureId; @@ -88,7 +76,7 @@ void cConsole::Draw() { mPri.SetColor( eeColorA( mConColor.R(), mConColor.G(), mConColor.B(), static_cast(mA) ) ); mPri.DrawRectangle( 0.0f, 0.0f, mWidth, mY ); } else { - eeRGBA C( mConColor.R(), mConColor.G(), mConColor.B(), static_cast(mA) ); + eeColorA C( mConColor.R(), mConColor.G(), mConColor.B(), static_cast(mA) ); cTexture * Tex = cTextureFactory::instance()->GetTexture( mTexId ); @@ -669,4 +657,12 @@ void cConsole::IgnoreCharOnPrompt( const Uint32& ch ) { mTBuf.PushIgnoredChar( ch ); } +const bool& cConsole::IsShowingFps() const { + return mShowFps; +} + +void cConsole::ShowFps( const bool& Show ) { + mShowFps = Show; +} + }} diff --git a/src/graphics/cconsole.hpp b/src/graphics/cconsole.hpp index dafb8735d..95cecb726 100755 --- a/src/graphics/cconsole.hpp +++ b/src/graphics/cconsole.hpp @@ -32,28 +32,28 @@ class EE_API cConsole{ Uint32 TextureId() const { return mTexId; } /** Set the Console Background Color */ - void BackgroundColor( const eeRGBA& BackColor ) { mConColor = BackColor; } + void BackgroundColor( const eeColorA& BackColor ) { mConColor = BackColor; } /** Get the Console Background Color */ - eeRGBA BackgroundColor() const { return mConColor; } + const eeColorA& BackgroundColor() const { return mConColor; } /** Set the Console Border Line Background Color */ - void BackgroundLineColor( const eeRGBA& BackColor ) { mConLineColor = BackColor; } + void BackgroundLineColor( const eeColorA& BackColor ) { mConLineColor = BackColor; } /** Get the Console Border Line Background Color */ - eeRGBA BackgroundLineColor() const { return mConLineColor; } + const eeColorA& BackgroundLineColor() const { return mConLineColor; } /** Set the Console Font Color */ - void FontColor( const eeRGBA& FntColor ) { mFontColor = FntColor; } + void FontColor( const eeColorA& FntColor ) { mFontColor = FntColor; } /** Get the Console Font Color */ - eeRGBA FontColor() const { return mFontColor; } + const eeColorA& FontColor() const { return mFontColor; } /** Set the Console Client Input ( Writeable Line ) Font Color */ - void FontLineColor( const eeRGBA& FntColor ) { mFontLineColor = FntColor; } + void FontLineColor( const eeColorA& FntColor ) { mFontLineColor = FntColor; } /** Get the Console Client Input ( Writeable Line ) Font Color */ - eeRGBA FontLineColor() const { return mFontLineColor; } + const eeColorA& FontLineColor() const { return mFontLineColor; } /** Toogle the console between visible and hided with Fade In or Fade Out effect. */ void Toggle(); @@ -89,7 +89,7 @@ class EE_API cConsole{ * @param FontColor The Console Font Color * @param FontLineColor The Console Line Font Color ( The Client Input ) */ - void Create( cFont* Font, const bool& MakeDefaultCommands = true, const eeUint& MaxLogLines = 1024, const Uint32& TextureId = 0, const eeRGBA& ConsoleColor = eeRGBA(true), const eeRGBA& ConsoleLineColor = eeRGBA(true), const eeRGBA& FontColor = eeRGBA(true), const eeRGBA& FontLineColor = eeRGBA(true) ); + void Create( cFont* Font, const bool& MakeDefaultCommands = true, const eeUint& MaxLogLines = 1024, const Uint32& TextureId = 0 ); /** Add Text to Console */ void PushText( const std::wstring& str ); @@ -120,6 +120,12 @@ class EE_API cConsole{ /** Use this if you need to ignore some char to activate the console, for example '~'. A common char to activate a console. */ void IgnoreCharOnPrompt( const Uint32& ch ); + + /** @return If the console is rendering the FPS count. */ + const bool& IsShowingFps() const; + + /** Activate/Deactive fps rendering */ + void ShowFps( const bool& Show ); protected: std::map < std::wstring, ConsoleCallback > mCallbacks; std::deque < std::wstring > mCmdLog; @@ -128,7 +134,7 @@ class EE_API cConsole{ eeInt mLastLogPos; bool mEnabled, mVisible, mFadeIn, mFadeOut, mExpand, mFading, mShowFps; - eeRGBA mConColor, mConLineColor, mFontColor, mFontLineColor; + eeColorA mConColor, mConLineColor, mFontColor, mFontLineColor; eeFloat mWidth, mHeight, mHeightMin, mCurHeight, mY, mA, mMaxAlpha, mTempY, mFontSize, mFadeSpeed; Uint32 mMyCallback, mEx, mMaxLogLines; diff --git a/src/graphics/cfont.cpp b/src/graphics/cfont.cpp index 7c4d940d9..a3ac122c0 100644 --- a/src/graphics/cfont.cpp +++ b/src/graphics/cfont.cpp @@ -25,8 +25,10 @@ cFont::~cFont() { void cFont::SetText( const std::wstring& Text ) { if ( mText.size() != Text.size() ) { - mRenderCoords.resize( Text.size() * EE_QUAD_VERTEX ); - mColors.resize( Text.size() * EE_QUAD_VERTEX, mColor ); + Int32 size = Text.size() * EE_QUAD_VERTEX; + + mRenderCoords.resize( size ); + mColors.resize( size, mColor ); } mText = Text; diff --git a/src/graphics/cscrollparallax.cpp b/src/graphics/cscrollparallax.cpp index 09f086238..992cbe18d 100755 --- a/src/graphics/cscrollparallax.cpp +++ b/src/graphics/cscrollparallax.cpp @@ -11,7 +11,7 @@ cScrollParallax::cScrollParallax() : cScrollParallax::~cScrollParallax() {} -cScrollParallax::cScrollParallax( cShape * Shape, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeVector2f& Speed, const eeRGBA& Color, const EE_PRE_BLEND_FUNC& Blend ) { +cScrollParallax::cScrollParallax( cShape * Shape, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeVector2f& Speed, const eeColorA& Color, const EE_PRE_BLEND_FUNC& Blend ) { Create( Shape, DestX, DestY, DestWidth, DestHeight, Speed, Color, Blend ); } @@ -39,7 +39,7 @@ void cScrollParallax::SetAABB() { mAABB = eeRectf( mInitPos.x, mInitPos.y, mInitPos.x + mSize.Width(), mInitPos.y + mSize.Height() ); } -bool cScrollParallax::Create( cShape * Shape, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeVector2f& Speed, const eeRGBA& Color, const EE_PRE_BLEND_FUNC& Blend ) { +bool cScrollParallax::Create( cShape * Shape, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeVector2f& Speed, const eeColorA& Color, const EE_PRE_BLEND_FUNC& Blend ) { mShape = Shape; mPos = eeVector2f( DestX, DestY ); mSize = eeSizef( DestWidth, DestHeight ); diff --git a/src/graphics/cscrollparallax.hpp b/src/graphics/cscrollparallax.hpp index fe8b58e61..1af09b361 100755 --- a/src/graphics/cscrollparallax.hpp +++ b/src/graphics/cscrollparallax.hpp @@ -13,7 +13,7 @@ class EE_API cScrollParallax { ~cScrollParallax(); /** Constructor that create's the Scroll Parallax */ - cScrollParallax( cShape * Shape, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeVector2f& Speed, const eeRGBA& Color = eeRGBA(255, 255, 255, 255), const EE_PRE_BLEND_FUNC& Blend = ALPHA_NORMAL ); + cScrollParallax( cShape * Shape, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeVector2f& Speed, const eeColorA& Color = eeColorA(), const EE_PRE_BLEND_FUNC& Blend = ALPHA_NORMAL ); /** Create's the Scroll Parallax * @param Shape The Shape to Draw @@ -26,7 +26,7 @@ class EE_API cScrollParallax { * @param Effect The Blend Mode ( default ALPHA_NORMAL ) * @return True if success */ - bool Create( cShape * Shape, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeVector2f& Speed, const eeRGBA& Color = eeRGBA(255, 255, 255, 255), const EE_PRE_BLEND_FUNC& Blend = ALPHA_NORMAL ); + bool Create( cShape * Shape, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeVector2f& Speed, const eeColorA& Color = eeColorA(), const EE_PRE_BLEND_FUNC& Blend = ALPHA_NORMAL ); /** Set the Color */ void Color( const eeColorA& Color ) { mColor = Color; } diff --git a/src/graphics/csprite.cpp b/src/graphics/csprite.cpp index 6b534ea21..5e326d074 100755 --- a/src/graphics/csprite.cpp +++ b/src/graphics/csprite.cpp @@ -226,7 +226,7 @@ void cSprite::DisableVertexColors() { eeSAFE_DELETE_ARRAY( mVertexColors ); } -void cSprite::Update( const eeFloat& x, const eeFloat& y, const eeFloat& Scale, const eeFloat& Angle, const Uint8& Alpha, const eeRGBA& Color ) { +void cSprite::Update( const eeFloat& x, const eeFloat& y, const eeFloat& Scale, const eeFloat& Angle, const Uint8& Alpha, const eeColorA& Color ) { mPos.x = x; mPos.y = y; mScale = Scale; diff --git a/src/graphics/csprite.hpp b/src/graphics/csprite.hpp index ce7ec5f0c..56dce5d58 100755 --- a/src/graphics/csprite.hpp +++ b/src/graphics/csprite.hpp @@ -160,7 +160,7 @@ class EE_API cSprite { * @param Alpha Set the Color Alpha * @param Color Set the Color */ - void Update( const eeFloat& x, const eeFloat& y, const eeFloat& Scale = 1.0f, const eeFloat& Angle = 0.0f, const Uint8& Alpha = 255, const eeRGBA& Color = eeRGBA(255,255,255,255) ); + void Update( const eeFloat& x, const eeFloat& y, const eeFloat& Scale = 1.0f, const eeFloat& Angle = 0.0f, const Uint8& Alpha = 255, const eeColorA& Color = eeColorA() ); /** Get the internal texture id from a frame number and a sub frame number * @param FrameNum The Frame Number diff --git a/src/graphics/ctexture.cpp b/src/graphics/ctexture.cpp index 5f06e009b..75d8fce5f 100755 --- a/src/graphics/ctexture.cpp +++ b/src/graphics/ctexture.cpp @@ -11,7 +11,6 @@ cTexture::cTexture() : mImgWidth(0), mImgHeight(0), mFlags(0), - mColorKey(eeRGB(true)), mClampMode( EE_CLAMP_TO_EDGE ), mFilter( TEX_FILTER_LINEAR ) { @@ -24,7 +23,6 @@ cTexture::cTexture( const cTexture& Copy ) : mImgWidth( Copy.mImgWidth ), mImgHeight( Copy.mImgHeight ), mFlags( Copy.mFlags ), - mColorKey( Copy.mColorKey ), mClampMode( Copy.mClampMode ), mFilter( Copy.mFilter ) { @@ -53,7 +51,6 @@ cTexture& cTexture::operator =(const cTexture& Other) { std::swap(mImgWidth, Temp.mImgWidth); std::swap(mImgHeight, Temp.mImgHeight); std::swap(mFlags, Temp.mFlags); - std::swap(mColorKey, Temp.mColorKey); std::swap(mFilter, Temp.mFilter); std::swap(mClampMode, Temp.mClampMode); @@ -74,11 +71,11 @@ void cTexture::DeleteTexture() { } } -cTexture::cTexture( const Uint32& texture, const eeUint& width, const eeUint& height, const eeUint& imgwidth, const eeUint& imgheight, const bool& UseMipmap, const eeUint& Channels, const std::string& filepath, const eeRGB& ColorKey, const EE_CLAMP_MODE& ClampMode, const bool& CompressedTexture, const Uint32& MemSize, const Uint8* data ) { - Create( texture, width, height, imgwidth, imgheight, UseMipmap, Channels, filepath, ColorKey, ClampMode, CompressedTexture, MemSize, data ); +cTexture::cTexture( const Uint32& texture, const eeUint& width, const eeUint& height, const eeUint& imgwidth, const eeUint& imgheight, const bool& UseMipmap, const eeUint& Channels, const std::string& filepath, const EE_CLAMP_MODE& ClampMode, const bool& CompressedTexture, const Uint32& MemSize, const Uint8* data ) { + Create( texture, width, height, imgwidth, imgheight, UseMipmap, Channels, filepath, ClampMode, CompressedTexture, MemSize, data ); } -void cTexture::Create( const Uint32& texture, const eeUint& width, const eeUint& height, const eeUint& imgwidth, const eeUint& imgheight, const bool& UseMipmap, const eeUint& Channels, const std::string& filepath, const eeRGB& ColorKey, const EE_CLAMP_MODE& ClampMode, const bool& CompressedTexture, const Uint32& MemSize, const Uint8* data ) { +void cTexture::Create( const Uint32& texture, const eeUint& width, const eeUint& height, const eeUint& imgwidth, const eeUint& imgheight, const bool& UseMipmap, const eeUint& Channels, const std::string& filepath, const EE_CLAMP_MODE& ClampMode, const bool& CompressedTexture, const Uint32& MemSize, const Uint8* data ) { mFilepath = filepath; mId = MakeHash( mFilepath ); mTexture = texture; @@ -88,7 +85,6 @@ void cTexture::Create( const Uint32& texture, const eeUint& width, const eeUint& mImgWidth = imgwidth; mImgHeight = imgheight; mSize = MemSize; - mColorKey = ColorKey; mClampMode = ClampMode; mFilter = TEX_FILTER_LINEAR; diff --git a/src/graphics/ctexture.hpp b/src/graphics/ctexture.hpp index d6d1496b9..f8aaed95e 100755 --- a/src/graphics/ctexture.hpp +++ b/src/graphics/ctexture.hpp @@ -16,7 +16,7 @@ class EE_API cTexture : public cImage { public: cTexture(); - cTexture( const Uint32& texture, const eeUint& width, const eeUint& height, const eeUint& imgwidth, const eeUint& imgheight, const bool& UseMipmap, const eeUint& Channels, const std::string& filepath, const eeRGB& ColorKey, const EE_CLAMP_MODE& ClampMode, const bool& CompressedTexture, const Uint32& MemSize = 0, const Uint8* data = NULL ); + cTexture( const Uint32& texture, const eeUint& width, const eeUint& height, const eeUint& imgwidth, const eeUint& imgheight, const bool& UseMipmap, const eeUint& Channels, const std::string& filepath, const EE_CLAMP_MODE& ClampMode, const bool& CompressedTexture, const Uint32& MemSize = 0, const Uint8* data = NULL ); cTexture( const cTexture& Copy ); @@ -38,7 +38,7 @@ class EE_API cTexture : public cImage { * @param CompressedTexture The Texture was compressed on loading * @param data The Texture (raw texture) */ - void Create( const Uint32& texture, const eeUint& width, const eeUint& height, const eeUint& imgwidth, const eeUint& imgheight, const bool& UseMipmap, const eeUint& Channels, const std::string& filepath, const eeRGB& ColorKey, const EE_CLAMP_MODE& ClampMode, const bool& CompressedTexture, const Uint32& MemSize = 0, const Uint8* data = NULL ); + void Create( const Uint32& texture, const eeUint& width, const eeUint& height, const eeUint& imgwidth, const eeUint& imgheight, const bool& UseMipmap, const eeUint& Channels, const std::string& filepath, const EE_CLAMP_MODE& ClampMode, const bool& CompressedTexture, const Uint32& MemSize = 0, const Uint8* data = NULL ); /** Set the OpenGL Texture Id (texture handle) */ void Handle( const Uint32& texture ) { mTexture = texture; } @@ -67,12 +67,6 @@ class EE_API cTexture : public cImage { /** @return If the texture use Mipmaps */ bool Mipmap() const; - /** Set the Texture Color Key */ - void ColorKey( const eeRGB& colorkey ) { mColorKey = colorkey; } - - /** @return The Texture Color Key */ - eeRGB ColorKey() const { return mColorKey; } - /** Set the Texture Clamp Mode */ void ClampMode( const EE_CLAMP_MODE& clampmode ); @@ -226,7 +220,6 @@ class EE_API cTexture : public cImage { eeUint mImgHeight; Uint32 mFlags; - eeRGB mColorKey; EE_CLAMP_MODE mClampMode; EE_TEX_FILTER mFilter; diff --git a/src/graphics/ctexturefactory.cpp b/src/graphics/ctexturefactory.cpp index 7d61b2fdd..e211b9882 100755 --- a/src/graphics/ctexturefactory.cpp +++ b/src/graphics/ctexturefactory.cpp @@ -23,34 +23,34 @@ cTextureFactory::~cTextureFactory() { Uint32 cTextureFactory::CreateEmptyTexture( const eeUint& Width, const eeUint& Height, const eeColorA& DefaultColor, const bool& Mipmap, const EE_CLAMP_MODE& ClampMode, const bool& CompressTexture, const bool& KeepLocalCopy ) { std::vector tmpTex( Width * Height, DefaultColor ); - return LoadFromPixels( reinterpret_cast ( &tmpTex[0] ), Width, Height, 4, Mipmap, eeRGB(true), ClampMode, CompressTexture, KeepLocalCopy ); + return LoadFromPixels( reinterpret_cast ( &tmpTex[0] ), Width, Height, 4, Mipmap, ClampMode, CompressTexture, KeepLocalCopy ); } -Uint32 cTextureFactory::LoadFromPixels( const unsigned char * Pixels, const eeUint& Width, const eeUint& Height, const eeUint& Channels, const bool& Mipmap, const eeRGB& ColorKey, const EE_CLAMP_MODE& ClampMode, const bool& CompressTexture, const bool& KeepLocalCopy, const std::string& FileName ) { - cTextureLoader myTex( Pixels, Width, Height, Channels, Mipmap, ColorKey, ClampMode, CompressTexture, KeepLocalCopy, FileName ); +Uint32 cTextureFactory::LoadFromPixels( const unsigned char * Pixels, const eeUint& Width, const eeUint& Height, const eeUint& Channels, const bool& Mipmap, const EE_CLAMP_MODE& ClampMode, const bool& CompressTexture, const bool& KeepLocalCopy, const std::string& FileName ) { + cTextureLoader myTex( Pixels, Width, Height, Channels, Mipmap, ClampMode, CompressTexture, KeepLocalCopy, FileName ); myTex.Load(); return myTex.Id(); } -Uint32 cTextureFactory::LoadFromPack( cPack* Pack, const std::string& FilePackPath, const bool& Mipmap, const eeRGB& ColorKey, const EE_CLAMP_MODE& ClampMode, const bool& CompressTexture, const bool& KeepLocalCopy ) { - cTextureLoader myTex( Pack, FilePackPath, Mipmap, ColorKey, ClampMode, CompressTexture, KeepLocalCopy ); +Uint32 cTextureFactory::LoadFromPack( cPack* Pack, const std::string& FilePackPath, const bool& Mipmap, const EE_CLAMP_MODE& ClampMode, const bool& CompressTexture, const bool& KeepLocalCopy ) { + cTextureLoader myTex( Pack, FilePackPath, Mipmap, ClampMode, CompressTexture, KeepLocalCopy ); myTex.Load(); return myTex.Id(); } -Uint32 cTextureFactory::LoadFromMemory( const unsigned char * ImagePtr, const eeUint& Size, const bool& Mipmap, const eeRGB& ColorKey, const EE_CLAMP_MODE& ClampMode, const bool& CompressTexture, const bool& KeepLocalCopy ) { - cTextureLoader myTex( ImagePtr, Size, Mipmap, ColorKey, ClampMode, CompressTexture, KeepLocalCopy ); +Uint32 cTextureFactory::LoadFromMemory( const unsigned char * ImagePtr, const eeUint& Size, const bool& Mipmap, const EE_CLAMP_MODE& ClampMode, const bool& CompressTexture, const bool& KeepLocalCopy ) { + cTextureLoader myTex( ImagePtr, Size, Mipmap, ClampMode, CompressTexture, KeepLocalCopy ); myTex.Load(); return myTex.Id(); } -Uint32 cTextureFactory::Load( const std::string& Filepath, const bool& Mipmap, const eeRGB& ColorKey, const EE_CLAMP_MODE& ClampMode, const bool& CompressTexture, const bool& KeepLocalCopy ) { - cTextureLoader myTex( Filepath, Mipmap, ColorKey, ClampMode, CompressTexture, KeepLocalCopy ); +Uint32 cTextureFactory::Load( const std::string& Filepath, const bool& Mipmap, const EE_CLAMP_MODE& ClampMode, const bool& CompressTexture, const bool& KeepLocalCopy ) { + cTextureLoader myTex( Filepath, Mipmap, ClampMode, CompressTexture, KeepLocalCopy ); myTex.Load(); return myTex.Id(); } -Uint32 cTextureFactory::PushTexture( const std::string& Filepath, const Uint32& TexId, const eeUint& Width, const eeUint& Height, const eeUint& ImgWidth, const eeUint& ImgHeight, const bool& Mipmap, const eeUint& Channels, const eeRGB& ColorKey, const EE_CLAMP_MODE& ClampMode, const bool& CompressTexture, const bool& LocalCopy, const Uint32& MemSize ) { +Uint32 cTextureFactory::PushTexture( const std::string& Filepath, const Uint32& TexId, const eeUint& Width, const eeUint& Height, const eeUint& ImgWidth, const eeUint& ImgHeight, const bool& Mipmap, const eeUint& Channels, const EE_CLAMP_MODE& ClampMode, const bool& CompressTexture, const bool& LocalCopy, const Uint32& MemSize ) { Lock(); cTexture * Tex = NULL; @@ -68,12 +68,9 @@ Uint32 cTextureFactory::PushTexture( const std::string& Filepath, const Uint32& Pos = FindFreeSlot(); Tex = mTextures[ Pos ] = eeNew( cTexture, () ); - Tex->Create( TexId, Width, Height, MyWidth, MyHeight, Mipmap, Channels, FPath, ColorKey, ClampMode, CompressTexture, MemSize ); + Tex->Create( TexId, Width, Height, MyWidth, MyHeight, Mipmap, Channels, FPath, ClampMode, CompressTexture, MemSize ); Tex->Id( Pos ); - if ( !ColorKey.voidRGB ) - Tex->CreateMaskFromColor( eeColor( ColorKey.R(), ColorKey.G(), ColorKey.B() ) , 0 ); - if ( LocalCopy ) { Tex->Lock(); Tex->Unlock( true, false ); diff --git a/src/graphics/ctexturefactory.hpp b/src/graphics/ctexturefactory.hpp index ac4b784d1..4fcf3c5c8 100755 --- a/src/graphics/ctexturefactory.hpp +++ b/src/graphics/ctexturefactory.hpp @@ -34,14 +34,13 @@ class EE_API cTextureFactory: public tSingleton, protected cMut * @param Height Texture Height * @param Channels Texture Number of Channels (in bytes) * @param Mipmap Create Mipmap? - * @param ColorKey Color key for the texture ( eeRGB(true) for none ) * @param ClampMode Defines the CLAMP MODE * @param CompressTexture If use the DXT compression on the texture loading ( if the card can display them, will convert RGB to DXT1, RGBA to DXT5 ) * @param KeepLocalCopy Keep the array data copy. ( usefull if want to reload the texture ) * @param FileName A filename to recognize the texture ( the path in case that was loaded from outside the texture factory ). * @return Internal Texture Id */ - Uint32 LoadFromPixels( const unsigned char * Pixels, const eeUint& Width, const eeUint& Height, const eeUint& Channels, const bool& Mipmap = false, const eeRGB& ColorKey = eeRGB(true), const EE_CLAMP_MODE& ClampMode = EE_CLAMP_TO_EDGE, const bool& CompressTexture = false, const bool& KeepLocalCopy = false, const std::string& FileName = std::string("") ); + Uint32 LoadFromPixels( const unsigned char * Pixels, const eeUint& Width, const eeUint& Height, const eeUint& Channels, const bool& Mipmap = false, const EE_CLAMP_MODE& ClampMode = EE_CLAMP_TO_EDGE, const bool& CompressTexture = false, const bool& KeepLocalCopy = false, const std::string& FileName = std::string("") ); /** Load a texture from Pack * @param Pack Pointer to the pack instance @@ -52,30 +51,28 @@ class EE_API cTextureFactory: public tSingleton, protected cMut * @param KeepLocalCopy Keep the array data copy. ( usefull if want to reload the texture ) * @return Internal Texture Id */ - Uint32 LoadFromPack( cPack* Pack, const std::string& FilePackPath, const bool& Mipmap = false, const eeRGB& ColorKey = eeRGB(true), const EE_CLAMP_MODE& ClampMode = EE_CLAMP_TO_EDGE, const bool& CompressTexture = false, const bool& KeepLocalCopy = false ); + Uint32 LoadFromPack( cPack* Pack, const std::string& FilePackPath, const bool& Mipmap = false, const EE_CLAMP_MODE& ClampMode = EE_CLAMP_TO_EDGE, const bool& CompressTexture = false, const bool& KeepLocalCopy = false ); /** Load a texture from memory (RGBA Format) * @param ImagePtr The image data in RAM just as if it were still in a file * @param Size The size of the texture ( Width * Height * BytesPerPixel ) * @param Mipmap Use mipmaps? - * @param ColorKey The ColorKey for the texture * @param ClampMode Defines the CLAMP MODE * @param CompressTexture If use the DXT compression on the texture loading ( if the card can display them, will convert RGB to DXT1, RGBA to DXT5 ) * @param KeepLocalCopy Keep the array data copy. ( usefull if want to reload the texture ) * @return The internal Texture Id */ - Uint32 LoadFromMemory( const unsigned char* ImagePtr, const eeUint& Size, const bool& Mipmap = false, const eeRGB& ColorKey = eeRGB(true), const EE_CLAMP_MODE& ClampMode = EE_CLAMP_TO_EDGE, const bool& CompressTexture = false, const bool& KeepLocalCopy = false ); + Uint32 LoadFromMemory( const unsigned char* ImagePtr, const eeUint& Size, const bool& Mipmap = false, const EE_CLAMP_MODE& ClampMode = EE_CLAMP_TO_EDGE, const bool& CompressTexture = false, const bool& KeepLocalCopy = false ); /** Load a Texture from a file path * @param filepath The path for the texture * @param mipmap Use mipmaps? - * @param ColorKey The ColorKey for the texture * @param ClampMode Defines the CLAMP MODE * @param CompressTexture If use the DXT compression on the texture loading ( if the card can display them, will convert RGB to DXT1, RGBA to DXT5 ) * @param KeepLocalCopy Keep the array data copy. ( usefull if want to reload the texture ) * @return The internal Texture Id */ - Uint32 Load( const std::string& Filepath, const bool& mipmap = false, const eeRGB& ColorKey = eeRGB(true), const EE_CLAMP_MODE& ClampMode = EE_CLAMP_TO_EDGE, const bool& CompressTexture = false, const bool& KeepLocalCopy = false ); + Uint32 Load( const std::string& Filepath, const bool& mipmap = false, const EE_CLAMP_MODE& ClampMode = EE_CLAMP_TO_EDGE, const bool& CompressTexture = false, const bool& KeepLocalCopy = false ); /** Remove and Unload the Texture Id * @param TexId @@ -196,7 +193,7 @@ class EE_API cTextureFactory: public tSingleton, protected cMut * @param LocalCopy If keep a local copy in memory of the texture * @param MemSize The size of the texture in memory ( just if you need to specify the real size in memory, just usefull to calculate the total texture memory ). */ - Uint32 PushTexture( const std::string& Filepath, const Uint32& TexId, const eeUint& Width, const eeUint& Height, const eeUint& ImgWidth, const eeUint& ImgHeight, const bool& Mipmap, const eeUint& Channels, const eeRGB& ColorKey, const EE_CLAMP_MODE& ClampMode, const bool& CompressTexture, const bool& LocalCopy = false, const Uint32& MemSize = 0 ); + Uint32 PushTexture( const std::string& Filepath, const Uint32& TexId, const eeUint& Width, const eeUint& Height, const eeUint& ImgWidth, const eeUint& ImgHeight, const bool& Mipmap, const eeUint& Channels, const EE_CLAMP_MODE& ClampMode, const bool& CompressTexture, const bool& LocalCopy = false, const Uint32& MemSize = 0 ); /** Return a texture by it file path name * @param Name File path name diff --git a/src/graphics/ctextureloader.cpp b/src/graphics/ctextureloader.cpp index 38f8d2290..f02f323ca 100644 --- a/src/graphics/ctextureloader.cpp +++ b/src/graphics/ctextureloader.cpp @@ -11,7 +11,6 @@ namespace EE { namespace Graphics { cTextureLoader::cTextureLoader( const std::string& Filepath, const bool& Mipmap, - const eeRGB& ColorKey, const EE_CLAMP_MODE& ClampMode, const bool& CompressTexture, const bool& KeepLocalCopy @@ -26,13 +25,13 @@ cTextureLoader::cTextureLoader( const std::string& Filepath, mHeight(0), mMipmap(Mipmap), mChannels(0), - mColorKey(ColorKey), mClampMode(ClampMode), mCompressTexture(CompressTexture), mLocalCopy(KeepLocalCopy), mPack(NULL), mImagePtr(NULL), mSize(0), + mColorKey(NULL), mTexLoaded(false), mIsDDS(false), mIsDDSCompressed(0) @@ -42,7 +41,6 @@ cTextureLoader::cTextureLoader( const std::string& Filepath, cTextureLoader::cTextureLoader( const unsigned char * ImagePtr, const eeUint& Size, const bool& Mipmap, - const eeRGB& ColorKey, const EE_CLAMP_MODE& ClampMode, const bool& CompressTexture, const bool& KeepLocalCopy @@ -57,13 +55,13 @@ cTextureLoader::cTextureLoader( const unsigned char * ImagePtr, mHeight(0), mMipmap(Mipmap), mChannels(0), - mColorKey(ColorKey), mClampMode(ClampMode), mCompressTexture(CompressTexture), mLocalCopy(KeepLocalCopy), mPack(NULL), mImagePtr(ImagePtr), mSize(Size), + mColorKey(NULL), mTexLoaded(false), mIsDDS(false), mIsDDSCompressed(0) @@ -73,7 +71,6 @@ cTextureLoader::cTextureLoader( const unsigned char * ImagePtr, cTextureLoader::cTextureLoader( cPack * Pack, const std::string& FilePackPath, const bool& Mipmap , - const eeRGB& ColorKey, const EE_CLAMP_MODE& ClampMode, const bool& CompressTexture, const bool& KeepLocalCopy @@ -88,13 +85,13 @@ cTextureLoader::cTextureLoader( cPack * Pack, mHeight(0), mMipmap(Mipmap), mChannels(0), - mColorKey(ColorKey), mClampMode(ClampMode), mCompressTexture(CompressTexture), mLocalCopy(KeepLocalCopy), mPack(Pack), mImagePtr(NULL), mSize(0), + mColorKey(NULL), mTexLoaded(false), mIsDDS(false), mIsDDSCompressed(0) @@ -106,7 +103,6 @@ cTextureLoader::cTextureLoader( const unsigned char * Pixels, const eeUint& Height, const eeUint& Channels, const bool& Mipmap, - const eeRGB& ColorKey, const EE_CLAMP_MODE& ClampMode, const bool& CompressTexture, const bool& KeepLocalCopy, @@ -122,13 +118,13 @@ cTextureLoader::cTextureLoader( const unsigned char * Pixels, mHeight(0), mMipmap(Mipmap), mChannels(Channels), - mColorKey(ColorKey), mClampMode(ClampMode), mCompressTexture(CompressTexture), mLocalCopy(KeepLocalCopy), mPack(NULL), mImagePtr(NULL), mSize(0), + mColorKey(NULL), mTexLoaded(false), mIsDDS(false), mIsDDSCompressed(0) @@ -234,7 +230,10 @@ void cTextureLoader::LoadFromPixels() { else mSize = mWidth * mHeight * mChannels; - mTexId = cTextureFactory::instance()->PushTexture( mFilepath, tTexId, mImgWidth, mImgHeight, width, height, mMipmap, mChannels, mColorKey, mClampMode, mCompressTexture || mIsDDSCompressed, mLocalCopy, mSize ); + mTexId = cTextureFactory::instance()->PushTexture( mFilepath, tTexId, mImgWidth, mImgHeight, width, height, mMipmap, mChannels, mClampMode, mCompressTexture || mIsDDSCompressed, mLocalCopy, mSize ); + + if ( NULL != mColorKey && 0 != mTexId ) + cTextureFactory::instance()->GetTexture( mTexId )->CreateMaskFromColor( eeColorA( mColorKey->R(), mColorKey->G(), mColorKey->B(), 255 ), 0 ); } if ( TEX_LT_PIXELS != mLoadType ) { @@ -262,5 +261,10 @@ const Uint32& cTextureLoader::Id() const { return mTexId; } +void cTextureLoader::SetColorKey( eeColor Color ) { + eeSAFE_DELETE( mColorKey ); + mColorKey = eeNew( eeColor, ( Color.R(), Color.G(), Color.B() ) ); +} + }} diff --git a/src/graphics/ctextureloader.hpp b/src/graphics/ctextureloader.hpp index 0bd467542..96e74242e 100644 --- a/src/graphics/ctextureloader.hpp +++ b/src/graphics/ctextureloader.hpp @@ -13,16 +13,18 @@ namespace EE { namespace Graphics { class EE_API cTextureLoader : public cObjectLoader { public: - cTextureLoader( const std::string& Filepath, const bool& Mipmap = false, const eeRGB& ColorKey = eeRGB(true), const EE_CLAMP_MODE& ClampMode = EE_CLAMP_TO_EDGE, const bool& CompressTexture = false, const bool& KeepLocalCopy = false ); + cTextureLoader( const std::string& Filepath, const bool& Mipmap = false, const EE_CLAMP_MODE& ClampMode = EE_CLAMP_TO_EDGE, const bool& CompressTexture = false, const bool& KeepLocalCopy = false ); - cTextureLoader( const unsigned char * ImagePtr, const eeUint& Size, const bool& Mipmap = false, const eeRGB& ColorKey = eeRGB(true), const EE_CLAMP_MODE& ClampMode = EE_CLAMP_TO_EDGE, const bool& CompressTexture = false, const bool& KeepLocalCopy = false ); + cTextureLoader( const unsigned char * ImagePtr, const eeUint& Size, const bool& Mipmap = false, const EE_CLAMP_MODE& ClampMode = EE_CLAMP_TO_EDGE, const bool& CompressTexture = false, const bool& KeepLocalCopy = false ); - cTextureLoader( cPack * Pack, const std::string& FilePackPath, const bool& Mipmap = false, const eeRGB& ColorKey = eeRGB(true), const EE_CLAMP_MODE& ClampMode = EE_CLAMP_TO_EDGE, const bool& CompressTexture = false, const bool& KeepLocalCopy = false ); + cTextureLoader( cPack * Pack, const std::string& FilePackPath, const bool& Mipmap = false, const EE_CLAMP_MODE& ClampMode = EE_CLAMP_TO_EDGE, const bool& CompressTexture = false, const bool& KeepLocalCopy = false ); - cTextureLoader( const unsigned char * Pixels, const eeUint& Width, const eeUint& Height, const eeUint& Channels, const bool& Mipmap = false, const eeRGB& ColorKey = eeRGB(true), const EE_CLAMP_MODE& ClampMode = EE_CLAMP_TO_EDGE, const bool& CompressTexture = false, const bool& KeepLocalCopy = false, const std::string& FileName = std::string("") ); + cTextureLoader( const unsigned char * Pixels, const eeUint& Width, const eeUint& Height, const eeUint& Channels, const bool& Mipmap = false, const EE_CLAMP_MODE& ClampMode = EE_CLAMP_TO_EDGE, const bool& CompressTexture = false, const bool& KeepLocalCopy = false, const std::string& FileName = std::string("") ); ~cTextureLoader(); + void SetColorKey( eeColor Color ); + void Update(); const std::string& Filepath() const { return mFilepath; } @@ -40,7 +42,6 @@ class EE_API cTextureLoader : public cObjectLoader { eeUint mHeight; bool mMipmap; Int32 mChannels; - eeRGB mColorKey; EE_CLAMP_MODE mClampMode; bool mCompressTexture; bool mLocalCopy; @@ -49,6 +50,8 @@ class EE_API cTextureLoader : public cObjectLoader { const Uint8 * mImagePtr; Uint32 mSize; + eeColor * mColorKey; + void Start(); private: bool mTexLoaded; @@ -64,4 +67,3 @@ class EE_API cTextureLoader : public cObjectLoader { }} #endif - diff --git a/src/graphics/cttffont.cpp b/src/graphics/cttffont.cpp index 068aaf2ca..21d252870 100755 --- a/src/graphics/cttffont.cpp +++ b/src/graphics/cttffont.cpp @@ -264,7 +264,7 @@ void cTTFFont::UpdateLoading() { if ( mTexReady && NULL != mPixels ) { std::string name( FileRemoveExtension( FileNameFromPath( mFilepath ) ) ); - mTexId = cTextureFactory::instance()->LoadFromPixels( reinterpret_cast ( &mPixels[0] ), (Uint32)mTexWidth, (Uint32)mTexHeight, 4, false, eeRGB(true), EE_CLAMP_TO_EDGE, false, false, name ); + mTexId = cTextureFactory::instance()->LoadFromPixels( reinterpret_cast ( &mPixels[0] ), (Uint32)mTexWidth, (Uint32)mTexHeight, 4, false, EE_CLAMP_TO_EDGE, false, false, name ); eeSAFE_DELETE_ARRAY( mPixels ); diff --git a/src/test/ee.cpp b/src/test/ee.cpp index c402ca10c..373cc5439 100644 --- a/src/test/ee.cpp +++ b/src/test/ee.cpp @@ -345,7 +345,10 @@ void cEETest::Init() { } void cEETest::LoadFonts() { - mFontLoader.Add( eeNew( cTextureFontLoader, ( "conchars", eeNew( cTextureLoader, ( &PAK, "conchars.png", false, eeRGB(0,0,0) ) ), (eeUint)32 ) ) ); + cTextureLoader * tl = eeNew( cTextureLoader, ( &PAK, "conchars.png" ) ); + tl->SetColorKey( eeColor(0,0,0) ); + + mFontLoader.Add( eeNew( cTextureFontLoader, ( "conchars", tl, (eeUint)32 ) ) ); mFontLoader.Add( eeNew( cTextureFontLoader, ( "ProggySquareSZ", eeNew( cTextureLoader, ( &PAK, "ProggySquareSZ.png" ) ), &PAK, "ProggySquareSZ.dat" ) ) ); mFontLoader.Add( eeNew( cTTFFontLoader, ( "arial", &PAK, "arial.ttf", 12, EE_TTF_STYLE_NORMAL, false, 256, eeColor(255,255,255) ) ) ); mFontLoader.Add( eeNew( cTTFFontLoader, ( "arialb", &PAK, "arial.ttf", 12, EE_TTF_STYLE_NORMAL, false, 256, eeColor(255,255,255), 1, eeColor(0,0,0), true ) ) ); @@ -780,7 +783,7 @@ void cEETest::LoadTextures() { TNP.resize(12); for ( i = 0; i <= 7; i++ ) { - TN[i] = TF->LoadFromPack( &PAK, "t" + toStr(i+1) + ".png", ( (i+1) == 7 ) ? true : false, eeRGB(true), ( (i+1) == 4 ) ? EE_CLAMP_REPEAT : EE_CLAMP_TO_EDGE ); + TN[i] = TF->LoadFromPack( &PAK, "t" + toStr(i+1) + ".png", ( (i+1) == 7 ) ? true : false, ( (i+1) == 4 ) ? EE_CLAMP_REPEAT : EE_CLAMP_TO_EDGE ); TNP[i] = TF->GetTexture( TN[i] ); } @@ -794,7 +797,8 @@ void cEETest::LoadTextures() { } Tiles[6] = SG->Add( TF->LoadFromPack( &PAK, "objects/1.png" ), "7" ); - Tiles[7] = SG->Add( TF->LoadFromPack( &PAK, "objects/2.png", false, eeColor(0,0,0) ), "8" ); + Tiles[7] = SG->Add( TF->LoadFromPack( &PAK, "objects/2.png" ), "8" ); + Tiles[7]->GetTexture()->CreateMaskFromColor( eeColorA(0,0,0,255), 0 ); eeInt w, h; @@ -842,7 +846,7 @@ void cEETest::LoadTextures() { CL1.Scale( 0.5f ); CL2.AddFrame(TN[0], 96, 96); - CL2.Color( eeRGBA( 255, 255, 255, 255 ) ); + CL2.Color( eeColorA( 255, 255, 255, 255 ) ); mTGL = eeNew( cTextureGroupLoader, ( MyPath + "data/bnb/bnb.etg" ) ); @@ -1019,15 +1023,15 @@ void cEETest::Screen2() { CL1.SetRenderType( RN_ISOMETRIC ); if (IntersectRectCircle( CL1.GetAABB(), Mousef.x, Mousef.y, 80.f )) - CL1.Color( eeRGBA(255, 0, 0, 200) ); + CL1.Color( eeColorA(255, 0, 0, 200) ); else - CL1.Color( eeRGBA(255, 255, 255, 200) ); + CL1.Color( eeColorA(255, 255, 255, 200) ); if ( IntersectQuad2( CL1.GetQuad() , CL2.GetQuad() ) ) { - CL1.Color( eeRGBA(0, 255, 0, 255) ); - CL2.Color( eeRGBA(0, 255, 0, 255) ); + CL1.Color( eeColorA(0, 255, 0, 255) ); + CL2.Color( eeColorA(0, 255, 0, 255) ); } else - CL2.Color( eeRGBA(255, 255, 255, 255) ); + CL2.Color( eeColorA(255, 255, 255, 255) ); CL1.Angle(ang); CL1.Scale(scale * 0.5f); diff --git a/src/ui/cuigfx.cpp b/src/ui/cuigfx.cpp index 1d32d5a8c..d2a3c838e 100644 --- a/src/ui/cuigfx.cpp +++ b/src/ui/cuigfx.cpp @@ -13,10 +13,7 @@ cUIGfx::cUIGfx( const cUIGfx::CreateParams& Params ) : if ( NULL != mShape && ( ( Flags() & UI_AUTO_SIZE ) || ( Params.Size.x == -1 && Params.Size.y == -1 ) ) ) Size( mShape->Size() ); - if ( mColor.voidRGB ) { - mColor.Alpha = (Uint8)mAlpha; - mColor.voidRGB = false; - } + mColor.Alpha = (Uint8)mAlpha; } cUIGfx::~cUIGfx() { @@ -52,11 +49,11 @@ cShape * cUIGfx::Shape() const { return mShape; } -const eeRGBA& cUIGfx::Color() const { +const eeColorA& cUIGfx::Color() const { return mColor; } -void cUIGfx::Color( const eeRGBA& color ) { +void cUIGfx::Color( const eeColorA& color ) { mColor = color; Alpha( color.A() ); } diff --git a/src/ui/cuigfx.hpp b/src/ui/cuigfx.hpp index 06cdef837..987dd30f8 100644 --- a/src/ui/cuigfx.hpp +++ b/src/ui/cuigfx.hpp @@ -11,14 +11,14 @@ class EE_API cUIGfx : public cUIControlAnim { public: inline CreateParams() : cUIControl::CreateParams() { Shape = NULL; - ShapeColor = eeRGBA( true ); + ShapeColor = eeColorA(); ShapeRender = RN_NORMAL; } inline ~CreateParams() {} cShape * Shape; - eeRGBA ShapeColor; + eeColorA ShapeColor; EE_RENDERTYPE ShapeRender; }; @@ -34,16 +34,16 @@ class EE_API cUIGfx : public cUIControlAnim { void Shape( cShape * shape ); - const eeRGBA& Color() const; + const eeColorA& Color() const; - void Color( const eeRGBA& color ); + void Color( const eeColorA& color ); const EE_RENDERTYPE& RenderType() const; void RenderType( const EE_RENDERTYPE& render ); protected: cShape * mShape; - eeRGBA mColor; + eeColorA mColor; EE_RENDERTYPE mRender; virtual void OnSizeChange(); diff --git a/src/ui/cuisprite.cpp b/src/ui/cuisprite.cpp index 1166730bd..967cc1bf6 100644 --- a/src/ui/cuisprite.cpp +++ b/src/ui/cuisprite.cpp @@ -48,14 +48,14 @@ cSprite * cUISprite::Sprite() const { return mSprite; } -eeRGBA cUISprite::Color() const { +eeColorA cUISprite::Color() const { if ( NULL != mSprite ) return mSprite->Color(); - return eeRGBA(); + return eeColorA(); } -void cUISprite::Color( const eeRGBA& color ) { +void cUISprite::Color( const eeColorA& color ) { if ( NULL != mSprite ) mSprite->Color( color ); diff --git a/src/ui/cuisprite.hpp b/src/ui/cuisprite.hpp index 16eccf64a..70c40dab8 100644 --- a/src/ui/cuisprite.hpp +++ b/src/ui/cuisprite.hpp @@ -32,9 +32,9 @@ class EE_API cUISprite : public cUIControlAnim { void Sprite( cSprite * sprite ); - eeRGBA Color() const; + eeColorA Color() const; - void Color( const eeRGBA& color ); + void Color( const eeColorA& color ); const EE_RENDERTYPE& RenderType() const; diff --git a/src/ui/cuitheme.cpp b/src/ui/cuitheme.cpp index eac69a81d..70ca04375 100644 --- a/src/ui/cuitheme.cpp +++ b/src/ui/cuitheme.cpp @@ -6,54 +6,65 @@ namespace EE { namespace UI { -static const char * UI_THEME_ELEMENTS[] = { - "control", - "button", - "textinput", - "checkbox", - "checkbox_active", - "checkbox_inactive", - "button", - "radiobutton", - "radiobutton_active", - "radiobutton_inactive", - "hslider", - "hslider_bg", - "hslider_button", - "vslider", - "vslider_bg", - "vslider_button", - "spinbox", - "spinbox_input", - "spinbox_btnup", - "spinbox_btndown", - "hscrollbar", - "hscrollbar_slider", - "hscrollbar_bg", - "hscrollbar_button", - "hscrollbar_btnup", - "hscrollbar_btndown", - "vscrollbar", - "vscrollbar_slider", - "vscrollbar_bg", - "vscrollbar_button", - "vscrollbar_btnup", - "vscrollbar_btndown", - "progressbar", - "progressbar_filler", - "listbox", - "listboxitem", - "dropdownlist", - "combobox", - "menu", - "menuitem", - "separator", - "menucheckbox_active", - "menucheckbox_inactive", - "menuarrow" -}; +static std::vector UI_THEME_ELEMENTS; + +static void LoadThemeElements() { + if ( !UI_THEME_ELEMENTS.size() ) { + UI_THEME_ELEMENTS.reserve( 50 ); + UI_THEME_ELEMENTS.push_back( "control" ); + UI_THEME_ELEMENTS.push_back( "button" ); + UI_THEME_ELEMENTS.push_back( "textinput" ); + UI_THEME_ELEMENTS.push_back( "checkbox" ); + UI_THEME_ELEMENTS.push_back( "checkbox_active" ); + UI_THEME_ELEMENTS.push_back( "checkbox_inactive" ); + UI_THEME_ELEMENTS.push_back( "button" ); + UI_THEME_ELEMENTS.push_back( "radiobutton" ); + UI_THEME_ELEMENTS.push_back( "radiobutton_active" ); + UI_THEME_ELEMENTS.push_back( "radiobutton_inactive" ); + UI_THEME_ELEMENTS.push_back( "hslider" ); + UI_THEME_ELEMENTS.push_back( "hslider_bg" ); + UI_THEME_ELEMENTS.push_back( "hslider_button" ); + UI_THEME_ELEMENTS.push_back( "vslider" ); + UI_THEME_ELEMENTS.push_back( "vslider_bg" ); + UI_THEME_ELEMENTS.push_back( "vslider_button" ); + UI_THEME_ELEMENTS.push_back( "spinbox" ); + UI_THEME_ELEMENTS.push_back( "spinbox_input" ); + UI_THEME_ELEMENTS.push_back( "spinbox_btnup" ); + UI_THEME_ELEMENTS.push_back( "spinbox_btndown" ); + UI_THEME_ELEMENTS.push_back( "hscrollbar" ); + UI_THEME_ELEMENTS.push_back( "hscrollbar_slider" ); + UI_THEME_ELEMENTS.push_back( "hscrollbar_bg" ); + UI_THEME_ELEMENTS.push_back( "hscrollbar_button" ); + UI_THEME_ELEMENTS.push_back( "hscrollbar_btnup" ); + UI_THEME_ELEMENTS.push_back( "hscrollbar_btndown" ); + UI_THEME_ELEMENTS.push_back( "vscrollbar" ); + UI_THEME_ELEMENTS.push_back( "vscrollbar_slider" ); + UI_THEME_ELEMENTS.push_back( "vscrollbar_bg" ); + UI_THEME_ELEMENTS.push_back( "vscrollbar_button" ); + UI_THEME_ELEMENTS.push_back( "vscrollbar_btnup" ); + UI_THEME_ELEMENTS.push_back( "vscrollbar_btndown" ); + UI_THEME_ELEMENTS.push_back( "progressbar" ); + UI_THEME_ELEMENTS.push_back( "progressbar_filler" ); + UI_THEME_ELEMENTS.push_back( "listbox" ); + UI_THEME_ELEMENTS.push_back( "listboxitem" ); + UI_THEME_ELEMENTS.push_back( "dropdownlist" ); + UI_THEME_ELEMENTS.push_back( "combobox" ); + UI_THEME_ELEMENTS.push_back( "menu" ); + UI_THEME_ELEMENTS.push_back( "menuitem" ); + UI_THEME_ELEMENTS.push_back( "separator" ); + UI_THEME_ELEMENTS.push_back( "menucheckbox_active" ); + UI_THEME_ELEMENTS.push_back( "menucheckbox_inactive" ); + UI_THEME_ELEMENTS.push_back( "menuarrow" ); + } +} + +void cUITheme::AddThemeElement( const std::string& Element ) { + UI_THEME_ELEMENTS.push_back( Element ); +} cUITheme * cUITheme::LoadFromPath( const std::string& Path, const std::string& Name, const std::string& NameAbbr, const std::string ImgExt ) { + LoadThemeElements(); + Uint32 i; bool Found; std::string Element; @@ -71,7 +82,7 @@ cUITheme * cUITheme::LoadFromPath( const std::string& Path, const std::string& N cUITheme * tTheme = eeNew( cUITheme, ( Name, NameAbbr ) ); - Uint32 Count = eeARRAY_SIZE( UI_THEME_ELEMENTS ); + Uint32 Count = UI_THEME_ELEMENTS.size(); for ( i = 0; i < Count; i++ ) { Uint32 IsComplex = 0; @@ -102,6 +113,8 @@ cUITheme * cUITheme::LoadFromPath( const std::string& Path, const std::string& N } cUITheme * cUITheme::LoadFromShapeGroup( cShapeGroup * ShapeGroup, const std::string& Name, const std::string NameAbbr ) { + LoadThemeElements(); + Uint32 i; bool Found; std::string Element; @@ -110,7 +123,7 @@ cUITheme * cUITheme::LoadFromShapeGroup( cShapeGroup * ShapeGroup, const std::st cUITheme * tTheme = eeNew( cUITheme, ( Name, NameAbbr ) ); - Uint32 Count = eeARRAY_SIZE( UI_THEME_ELEMENTS ); + Uint32 Count = UI_THEME_ELEMENTS.size(); for ( i = 0; i < Count; i++ ) { Uint32 IsComplex = 0; diff --git a/src/ui/cuitheme.hpp b/src/ui/cuitheme.hpp index 0aaa2ef9e..17de0e0ec 100644 --- a/src/ui/cuitheme.hpp +++ b/src/ui/cuitheme.hpp @@ -14,6 +14,8 @@ class EE_API cUITheme : public tResourceManager { static cUITheme * LoadFromShapeGroup( cShapeGroup * ShapeGroup, const std::string& Name, const std::string NameAbbr ); + static void AddThemeElement( const std::string& Element ); + cUITheme( const std::string& Name, const std::string& Abbr, cFont * DefaultFont = NULL ); virtual ~cUITheme(); diff --git a/src/utils/colors.hpp b/src/utils/colors.hpp index d758ef1f6..7df82e616 100755 --- a/src/utils/colors.hpp +++ b/src/utils/colors.hpp @@ -135,114 +135,10 @@ bool tColorA::operator!= ( const tColorA& Col ) const { return !( Red == Col.R() && Green == Col.G() && Blue == Col.B() && Alpha == Col.A() ); } -template -class cColor : public tColor { - public: - using tColor::Red; - using tColor::Green; - using tColor::Blue; - bool voidRGB; - - cColor(); - cColor( T r, T g, T b ); - cColor( bool voidrgb ); - cColor( const tColor& Col ); - - bool operator==(cColor& Col); - bool operator!=(cColor& Col); -}; - -template -cColor::cColor( bool voidrgb ) : tColor(), voidRGB(voidrgb) {} - -template -cColor::cColor() : tColor(), voidRGB(false) {} - -template -cColor::cColor(T r, T g, T b) : tColor(r, g, b), voidRGB(false) {} - -template -cColor::cColor( const tColor& Col ) { - Red = Col.R(); Green = Col.G(); Blue = Col.B(); voidRGB = false; -} - -template -bool cColor::operator== (cColor& Col) { - return ( Red == Col.R() && Green == Col.G() && Blue == Col.B() ); -} - -template -bool cColor::operator!= (cColor& Col) { - return !( Red == Col.R() && Green == Col.G() && Blue == Col.B() ); -} - -template -class cColorA : public tColorA { - public: - using tColorA::Red; - using tColorA::Green; - using tColorA::Blue; - using tColorA::Alpha; - bool voidRGB; - - cColorA(); - cColorA( T r, T g, T b, T a) ; - cColorA( const tColor& Col ); - cColorA( const tColorA& Col ); - cColorA( const bool& voidrgb ); - cColorA( const Uint32& Color ); - - bool operator==( cColorA& Col ); - bool operator!=( cColorA& Col ); - - static const cColorA Black; ///< Black predefined color -}; - -template -const cColorA cColorA::Black = cColorA(0,0,0,0); - -template -cColorA::cColorA( const Uint32& Color ) : tColorA( Color ) { - voidRGB = false; -} - -template -cColorA::cColorA( const bool& voidrgb ) : tColorA() { - voidRGB = voidrgb; -} - -template -cColorA::cColorA() : tColorA(), voidRGB(false) {} - -template -cColorA::cColorA(T r, T g, T b, T a) : tColorA(r, g, b, a), voidRGB(false) {} - -template -cColorA::cColorA( const tColor& Col ) { - Red = Col.R(); Green = Col.G(); Blue = Col.B(); Alpha = 255; -} - -template -cColorA::cColorA( const tColorA& Col ) { - Red = Col.R(); Green = Col.G(); Blue = Col.B(); Alpha = Col.A(); -} - -template -bool cColorA::operator== (cColorA& Col) { - return ( Red == Col.R() && Green == Col.G() && Blue == Col.B() && Alpha == Col.A() ); -} - -template -bool cColorA::operator!= (cColorA& Col) { - return !( Red == Col.R() && Green == Col.G() && Blue == Col.B() && Alpha == Col.A() ); -} - typedef tColor eeColor; typedef tColor eeColorf; typedef tColorA eeColorA; typedef tColorA eeColorAf; -typedef cColor eeRGB; -typedef cColorA eeRGBA; }} diff --git a/src/window/cinput.cpp b/src/window/cinput.cpp index 700fc2357..3aecabcbf 100644 --- a/src/window/cinput.cpp +++ b/src/window/cinput.cpp @@ -218,8 +218,7 @@ void cInput::Update() { case SDL_VIDEORESIZE: EE->ChangeRes(mEvent.resize.w, mEvent.resize.h, EE->Windowed() ); - if ( mVRCall.IsSet() ) - mVRCall(); + CallVideoResize(); break; case SDL_QUIT: @@ -233,6 +232,11 @@ void cInput::Update() { } } +void cInput::CallVideoResize() { + if ( mVRCall.IsSet() ) + mVRCall(); +} + bool cInput::GetKey( Uint8 * Key, Uint8 Pos ) { if ( ( * Key ) & ( 1 << Pos ) ) return true; diff --git a/src/window/cinput.hpp b/src/window/cinput.hpp index 43a254355..1920f7af1 100755 --- a/src/window/cinput.hpp +++ b/src/window/cinput.hpp @@ -429,6 +429,8 @@ class EE_API cInput : public tSingleton { void DoubleClickInterval( const Uint32& Interval ); ~cInput(); + + void CallVideoResize(); protected: cInput();