Check texture cache before adding an icon button's disabled texture
This commit is contained in:
parent
ee49604856
commit
9b57d76a79
@ -289,27 +289,37 @@ const video::ITexture* IconButtonWidget::getTexture()
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
video::ITexture* IconButtonWidget::getDeactivatedTexture(video::ITexture* texture)
|
video::ITexture* IconButtonWidget::getDeactivatedTexture(video::ITexture* texture)
|
||||||
{
|
{
|
||||||
SColor c;
|
video::ITexture* t;
|
||||||
u32 g;
|
|
||||||
|
|
||||||
video::IVideoDriver* driver = irr_driver->getVideoDriver();
|
std::string name = texture->getName().getPath().c_str();
|
||||||
std::auto_ptr<video::IImage> image (driver->createImageFromData (texture->getColorFormat(),
|
name += "_disabled";
|
||||||
texture->getSize(), texture->lock(), false));
|
t = irr_driver->getTexture(name);
|
||||||
texture->unlock();
|
if (t == NULL)
|
||||||
|
|
||||||
//Turn the image into grayscale
|
|
||||||
for (u32 x = 0; x < image->getDimension().Width; x++)
|
|
||||||
{
|
{
|
||||||
for (u32 y = 0; y < image->getDimension().Height; y++)
|
SColor c;
|
||||||
|
u32 g;
|
||||||
|
|
||||||
|
video::IVideoDriver* driver = irr_driver->getVideoDriver();
|
||||||
|
std::auto_ptr<video::IImage> image (driver->createImageFromData (texture->getColorFormat(),
|
||||||
|
texture->getSize(), texture->lock(), false));
|
||||||
|
texture->unlock();
|
||||||
|
|
||||||
|
//Turn the image into grayscale
|
||||||
|
for (u32 x = 0; x < image->getDimension().Width; x++)
|
||||||
{
|
{
|
||||||
c = image->getPixel(x, y);
|
for (u32 y = 0; y < image->getDimension().Height; y++)
|
||||||
g = ((c.getRed() + c.getGreen() + c.getBlue()) / 3);
|
{
|
||||||
c.set(std::max (0, (int)c.getAlpha() - 120), g, g, g);
|
c = image->getPixel(x, y);
|
||||||
image->setPixel(x, y, c);
|
g = ((c.getRed() + c.getGreen() + c.getBlue()) / 3);
|
||||||
|
c.set(std::max (0, (int)c.getAlpha() - 120), g, g, g);
|
||||||
|
image->setPixel(x, y, c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t = driver->addTexture(name.c_str(), image.get ());
|
||||||
}
|
}
|
||||||
|
|
||||||
return driver->addTexture(texture->getName().getPath() + "_disabled", image.get ());
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user