From 43a28f04fa3ddf4b612f58c25a896293a01567e3 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 15 Oct 2011 02:28:57 +0300 Subject: mobv2 --- src/tile.cpp | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) (limited to 'src/tile.cpp') diff --git a/src/tile.cpp b/src/tile.cpp index ac5965e9f..986d6bbf1 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -1054,6 +1054,120 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg, image->drop(); } } + /* + "[makealpha:R,G,B:filename.png" + Use an image with converting one color to transparent. + */ + else if(part_of_name.substr(0,11) == "[makealpha:") + { + if(baseimg != NULL) + { + dstream<<"WARNING: generate_image(): baseimg!=NULL " + <<"for part_of_name=\""<createImageFromFile(path.c_str()); + + if(image == NULL) + { + dstream<<"WARNING: generate_image(): Loading path \"" + < dim = image->getDimension(); + baseimg = driver->createImage(video::ECF_A8R8G8B8, dim); + + for(u32 y=0; ygetPixel(x,y); + u32 r = c.getRed(); + u32 g = c.getGreen(); + u32 b = c.getBlue(); + if(!(r == r1 && g == g1 && b == b1)) + continue; + c.setAlpha(0); + image->setPixel(x,y,c); + } + // Blit + image->copyTo(baseimg); + + image->drop(); + } + } + /* + "[makealpha2:R,G,B;R2,G2,B2:filename.png" + Use an image with converting two colors to transparent. + */ + else if(part_of_name.substr(0,12) == "[makealpha2:") + { + if(baseimg != NULL) + { + dstream<<"WARNING: generate_image(): baseimg!=NULL " + <<"for part_of_name=\""<createImageFromFile(path.c_str()); + + if(image == NULL) + { + dstream<<"WARNING: generate_image(): Loading path \"" + < dim = image->getDimension(); + baseimg = driver->createImage(video::ECF_A8R8G8B8, dim); + + for(u32 y=0; ygetPixel(x,y); + u32 r = c.getRed(); + u32 g = c.getGreen(); + u32 b = c.getBlue(); + if(!(r == r1 && g == g1 && b == b1) && + !(r == r2 && g == g2 && b == b2)) + continue; + c.setAlpha(0); + image->setPixel(x,y,c); + } + // Blit + image->copyTo(baseimg); + + image->drop(); + } + } /* [inventorycube{topimage{leftimage{rightimage In every subimage, replace ^ with &. -- cgit v1.2.3