浏览代码

Merge pull request #688 from Azaezel/alpha40/guibitmapbuttonColorModulation

adds colorization to GuiBitmapButtonCtrl
Brian Roberts 3 年之前
父节点
当前提交
346a84d16c
共有 2 个文件被更改,包括 5 次插入2 次删除
  1. 4 2
      Engine/source/gui/buttons/guiBitmapButtonCtrl.cpp
  2. 1 0
      Engine/source/gui/buttons/guiBitmapButtonCtrl.h

+ 4 - 2
Engine/source/gui/buttons/guiBitmapButtonCtrl.cpp

@@ -128,7 +128,7 @@ GuiBitmapButtonCtrl::GuiBitmapButtonCtrl()
    mUseStates = true;
    mUseStates = true;
    setExtent( 140, 30 );
    setExtent( 140, 30 );
    mMasked = false;
    mMasked = false;
-
+   mColor = ColorI::WHITE;
    INIT_ASSET(Bitmap);
    INIT_ASSET(Bitmap);
 }
 }
 
 
@@ -142,6 +142,7 @@ void GuiBitmapButtonCtrl::initPersistFields()
          "If useStates is false, this will be the file that renders on the control.  Otherwise, this will "
          "If useStates is false, this will be the file that renders on the control.  Otherwise, this will "
          "specify the default texture name to which the various state and modifier suffixes are appended "
          "specify the default texture name to which the various state and modifier suffixes are appended "
          "to find the per-state and per-modifier (if enabled) textures.");
          "to find the per-state and per-modifier (if enabled) textures.");
+      addField("color", TypeColorI, Offset(mColor, GuiBitmapButtonCtrl), "color mul");
 
 
       addField( "bitmapMode", TYPEID< BitmapMode >(), Offset( mBitmapMode, GuiBitmapButtonCtrl ),
       addField( "bitmapMode", TYPEID< BitmapMode >(), Offset( mBitmapMode, GuiBitmapButtonCtrl ),
          "Behavior for fitting the bitmap to the control extents.\n"
          "Behavior for fitting the bitmap to the control extents.\n"
@@ -545,7 +546,8 @@ void GuiBitmapButtonCtrl::onRender(Point2I offset, const RectI& updateRect)
 void GuiBitmapButtonCtrl::renderButton( GFXTexHandle &texture, const Point2I &offset, const RectI& updateRect )
 void GuiBitmapButtonCtrl::renderButton( GFXTexHandle &texture, const Point2I &offset, const RectI& updateRect )
 {
 {
    GFX->getDrawUtil()->clearBitmapModulation();
    GFX->getDrawUtil()->clearBitmapModulation();
-   
+   GFX->getDrawUtil()->setBitmapModulation(mColor);
+
    switch( mBitmapMode )
    switch( mBitmapMode )
    {
    {
       case BitmapStretched:
       case BitmapStretched:

+ 1 - 0
Engine/source/gui/buttons/guiBitmapButtonCtrl.h

@@ -126,6 +126,7 @@ class GuiBitmapButtonCtrl : public GuiButtonCtrl
       
       
       ///
       ///
       Textures mTextures[ NumModifiers ];
       Textures mTextures[ NumModifiers ];
+      ColorI   mColor;
       
       
       virtual void renderButton( GFXTexHandle &texture, const Point2I& offset, const RectI& updateRect );
       virtual void renderButton( GFXTexHandle &texture, const Point2I& offset, const RectI& updateRect );