2009-10-01 01:10:58 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* libwiigui
|
|
|
|
*
|
|
|
|
* Tantric 2009
|
|
|
|
*
|
|
|
|
* gui_image.cpp
|
|
|
|
*
|
|
|
|
* GUI class definitions
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include "gui.h"
|
2011-02-25 19:18:57 +01:00
|
|
|
#include "settings/CSettings.h"
|
2009-10-01 01:10:58 +02:00
|
|
|
/**
|
|
|
|
* Constructor for the GuiImage class.
|
|
|
|
*/
|
2010-02-09 11:59:55 +01:00
|
|
|
GuiImage::GuiImage()
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
image = NULL;
|
|
|
|
width = 0;
|
|
|
|
height = 0;
|
|
|
|
imageangle = 0;
|
2011-06-14 19:53:19 +02:00
|
|
|
tileHorizontal = -1;
|
|
|
|
tileVertical = -1;
|
2010-09-19 01:16:05 +02:00
|
|
|
stripe = 0;
|
|
|
|
widescreen = 0;
|
|
|
|
xx1 = 0;
|
|
|
|
yy1 = 0;
|
|
|
|
xx2 = 0;
|
|
|
|
yy2 = 0;
|
|
|
|
xx3 = 0;
|
|
|
|
yy3 = 0;
|
|
|
|
xx4 = 0;
|
|
|
|
yy4 = 0;
|
|
|
|
imgType = IMAGE_DATA;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
GuiImage::GuiImage(GuiImageData * img)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (img)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
image = img->GetImage();
|
|
|
|
width = img->GetWidth();
|
|
|
|
height = img->GetHeight();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
image = NULL;
|
|
|
|
width = 0;
|
|
|
|
height = 0;
|
|
|
|
}
|
|
|
|
imageangle = 0;
|
2011-06-14 19:53:19 +02:00
|
|
|
tileHorizontal = -1;
|
|
|
|
tileVertical = -1;
|
2010-09-19 01:16:05 +02:00
|
|
|
stripe = 0;
|
|
|
|
widescreen = 0;
|
|
|
|
parentangle = true;
|
|
|
|
xx1 = 0;
|
|
|
|
yy1 = 0;
|
|
|
|
xx2 = 0;
|
|
|
|
yy2 = 0;
|
|
|
|
xx3 = 0;
|
|
|
|
yy3 = 0;
|
|
|
|
xx4 = 0;
|
|
|
|
yy4 = 0;
|
|
|
|
imgType = IMAGE_DATA;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
GuiImage::GuiImage(u8 * img, int w, int h)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2009-10-01 01:10:58 +02:00
|
|
|
image = img;
|
2010-09-19 01:16:05 +02:00
|
|
|
width = w;
|
|
|
|
height = h;
|
2010-09-24 02:48:03 +02:00
|
|
|
imageangle = 0;
|
2011-06-14 19:53:19 +02:00
|
|
|
tileHorizontal = -1;
|
|
|
|
tileVertical = -1;
|
2010-09-19 01:16:05 +02:00
|
|
|
stripe = 0;
|
|
|
|
widescreen = 0;
|
|
|
|
parentangle = true;
|
|
|
|
xx1 = 0;
|
|
|
|
yy1 = 0;
|
|
|
|
xx2 = 0;
|
|
|
|
yy2 = 0;
|
|
|
|
xx3 = 0;
|
|
|
|
yy3 = 0;
|
|
|
|
xx4 = 0;
|
|
|
|
yy4 = 0;
|
|
|
|
imgType = IMAGE_TEXTURE;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
GuiImage::GuiImage(int w, int h, GXColor c)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
image = (u8 *) memalign(32, w * h * 4);
|
2010-09-19 01:16:05 +02:00
|
|
|
width = w;
|
|
|
|
height = h;
|
|
|
|
imageangle = 0;
|
2011-06-14 19:53:19 +02:00
|
|
|
tileHorizontal = -1;
|
|
|
|
tileVertical = -1;
|
2010-09-19 01:16:05 +02:00
|
|
|
stripe = 0;
|
|
|
|
widescreen = 0;
|
|
|
|
parentangle = true;
|
|
|
|
xx1 = 0;
|
|
|
|
yy1 = 0;
|
|
|
|
xx2 = 0;
|
|
|
|
yy2 = 0;
|
|
|
|
xx3 = 0;
|
|
|
|
yy3 = 0;
|
|
|
|
xx4 = 0;
|
|
|
|
yy4 = 0;
|
|
|
|
imgType = IMAGE_COLOR;
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (!image) return;
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
int x, y;
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
for (y = 0; y < h; y++)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
for (x = 0; x < w; x++)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
this->SetPixel(x, y, c);
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
int len = w * h * 4;
|
2010-09-24 02:48:03 +02:00
|
|
|
if (len % 32) len += (32 - len % 32);
|
|
|
|
DCFlushRange(image, len);
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
GuiImage::GuiImage(GuiImage &srcimage) :
|
|
|
|
GuiElement()
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
width = srcimage.GetWidth();
|
|
|
|
height = srcimage.GetHeight();
|
2009-10-01 01:10:58 +02:00
|
|
|
int len = width * height * 4;
|
2010-09-24 02:48:03 +02:00
|
|
|
if (len % 32) len += (32 - len % 32);
|
|
|
|
image = (u8 *) memalign(32, len);
|
|
|
|
memcpy(image, srcimage.GetImage(), len);
|
|
|
|
DCFlushRange(image, len);
|
|
|
|
imageangle = srcimage.GetAngle();
|
2011-06-14 19:53:19 +02:00
|
|
|
tileHorizontal = -1;
|
|
|
|
tileVertical = -1;
|
2010-09-19 01:16:05 +02:00
|
|
|
stripe = 0;
|
|
|
|
widescreen = 0;
|
|
|
|
parentangle = true;
|
|
|
|
xx1 = 0;
|
|
|
|
yy1 = 0;
|
|
|
|
xx2 = 0;
|
|
|
|
yy2 = 0;
|
|
|
|
xx3 = 0;
|
|
|
|
yy3 = 0;
|
|
|
|
xx4 = 0;
|
|
|
|
yy4 = 0;
|
|
|
|
imgType = IMAGE_COPY;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
GuiImage::GuiImage(GuiImage *srcimage) :
|
|
|
|
GuiElement()
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
width = srcimage->GetWidth();
|
|
|
|
height = srcimage->GetHeight();
|
2009-10-01 01:10:58 +02:00
|
|
|
int len = width * height * 4;
|
2010-09-24 02:48:03 +02:00
|
|
|
if (len % 32) len += (32 - len % 32);
|
|
|
|
image = (u8 *) memalign(32, len);
|
|
|
|
memcpy(image, srcimage->GetImage(), len);
|
|
|
|
DCFlushRange(image, len);
|
|
|
|
imageangle = srcimage->GetAngle();
|
2011-06-14 19:53:19 +02:00
|
|
|
tileHorizontal = -1;
|
|
|
|
tileVertical = -1;
|
2010-09-19 01:16:05 +02:00
|
|
|
stripe = 0;
|
|
|
|
widescreen = 0;
|
|
|
|
parentangle = true;
|
|
|
|
xx1 = 0;
|
|
|
|
yy1 = 0;
|
|
|
|
xx2 = 0;
|
|
|
|
yy2 = 0;
|
|
|
|
xx3 = 0;
|
|
|
|
yy3 = 0;
|
|
|
|
xx4 = 0;
|
|
|
|
yy4 = 0;
|
|
|
|
imgType = IMAGE_COPY;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
GuiImage &GuiImage::operator=(GuiImage & srcimage)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if ((imgType == IMAGE_COLOR || imgType == IMAGE_COPY) && image)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
free(image);
|
2009-10-01 01:10:58 +02:00
|
|
|
image = NULL;
|
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
width = srcimage.GetWidth();
|
|
|
|
height = srcimage.GetHeight();
|
2009-10-01 01:10:58 +02:00
|
|
|
int len = width * height * 4;
|
2010-09-24 02:48:03 +02:00
|
|
|
if (len % 32) len += (32 - len % 32);
|
|
|
|
image = (u8 *) memalign(32, len);
|
|
|
|
memcpy(image, srcimage.GetImage(), len);
|
|
|
|
DCFlushRange(image, len);
|
2010-09-19 01:16:05 +02:00
|
|
|
imageangle = srcimage.GetAngle();
|
2011-06-14 19:53:19 +02:00
|
|
|
tileHorizontal = -1;
|
|
|
|
tileVertical = -1;
|
2010-09-19 01:16:05 +02:00
|
|
|
stripe = 0;
|
|
|
|
widescreen = 0;
|
|
|
|
parentangle = true;
|
|
|
|
xx1 = 0;
|
|
|
|
yy1 = 0;
|
|
|
|
xx2 = 0;
|
|
|
|
yy2 = 0;
|
|
|
|
xx3 = 0;
|
|
|
|
yy3 = 0;
|
|
|
|
xx4 = 0;
|
|
|
|
yy4 = 0;
|
|
|
|
imgType = IMAGE_COPY;
|
|
|
|
return *this;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor for the GuiImage class.
|
|
|
|
*/
|
2010-02-09 11:59:55 +01:00
|
|
|
GuiImage::~GuiImage()
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if ((imgType == IMAGE_COLOR || imgType == IMAGE_COPY) && image)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
free(image);
|
2009-10-01 01:10:58 +02:00
|
|
|
image = NULL;
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
u8 * GuiImage::GetImage()
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
return image;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void GuiImage::SetImage(GuiImageData * img)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
2010-09-24 02:48:03 +02:00
|
|
|
if ((imgType == IMAGE_COLOR || imgType == IMAGE_COPY) && image)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
free(image);
|
2010-09-19 01:16:05 +02:00
|
|
|
image = NULL;
|
|
|
|
}
|
|
|
|
|
2011-01-02 10:23:44 +01:00
|
|
|
image = NULL;
|
2011-01-09 11:45:29 +01:00
|
|
|
width = 0;
|
|
|
|
height = 0;
|
2010-09-19 01:16:05 +02:00
|
|
|
imgType = IMAGE_DATA;
|
2011-01-02 10:23:44 +01:00
|
|
|
|
|
|
|
if(img)
|
|
|
|
{
|
|
|
|
image = img->GetImage();
|
|
|
|
width = img->GetWidth();
|
|
|
|
height = img->GetHeight();
|
|
|
|
}
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void GuiImage::SetImage(u8 * img, int w, int h)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
2010-09-24 02:48:03 +02:00
|
|
|
if ((imgType == IMAGE_COLOR || imgType == IMAGE_COPY) && image)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
free(image);
|
2010-09-19 01:16:05 +02:00
|
|
|
image = NULL;
|
|
|
|
}
|
|
|
|
image = img;
|
|
|
|
width = w;
|
|
|
|
height = h;
|
|
|
|
imgType = IMAGE_TEXTURE;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void GuiImage::SetAngle(float a)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
|
|
|
imageangle = a;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
2010-02-09 11:59:55 +01:00
|
|
|
float GuiImage::GetAngle()
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
return imageangle;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2011-06-14 19:53:19 +02:00
|
|
|
void GuiImage::SetTileHorizontal(int t)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
2011-06-14 19:53:19 +02:00
|
|
|
tileHorizontal = t;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiImage::SetTileVertical(int t)
|
|
|
|
{
|
|
|
|
LOCK( this );
|
|
|
|
tileVertical = t;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void GuiImage::SetWidescreen(bool w)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
|
|
|
widescreen = w;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
void GuiImage::SetParentAngle(bool a)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
2009-10-01 01:10:58 +02:00
|
|
|
parentangle = a;
|
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
GXColor GuiImage::GetPixel(int x, int y)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (!image || this->GetWidth() <= 0 || x < 0 || y < 0) return ( GXColor )
|
|
|
|
{ 0, 0, 0, 0};
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
u32 offset = (((y >> 2) << 4) * this->GetWidth()) + ((x >> 2) << 6) + (((y % 4 << 2) + x % 4) << 1);
|
2010-09-19 01:16:05 +02:00
|
|
|
GXColor color;
|
2010-09-24 02:48:03 +02:00
|
|
|
color.a = *(image + offset);
|
|
|
|
color.r = *(image + offset + 1);
|
|
|
|
color.g = *(image + offset + 32);
|
|
|
|
color.b = *(image + offset + 33);
|
2010-09-19 01:16:05 +02:00
|
|
|
return color;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void GuiImage::SetPixel(int x, int y, GXColor color)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
2010-09-24 02:48:03 +02:00
|
|
|
if (!image || this->GetWidth() <= 0 || x < 0 || y < 0) return;
|
|
|
|
|
|
|
|
u32 offset = (((y >> 2) << 4) * this->GetWidth()) + ((x >> 2) << 6) + (((y % 4 << 2) + x % 4) << 1);
|
|
|
|
*(image + offset) = color.a;
|
|
|
|
*(image + offset + 1) = color.r;
|
|
|
|
*(image + offset + 32) = color.g;
|
|
|
|
*(image + offset + 33) = color.b;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void GuiImage::SetGrayscale(void)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
2009-10-01 01:10:58 +02:00
|
|
|
GXColor color;
|
|
|
|
u32 offset, gray;
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int x = 0; x < width; x++)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int y = 0; y < height; y++)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
offset = (((y >> 2) << 4) * width) + ((x >> 2) << 6) + (((y % 4 << 2) + x % 4) << 1);
|
|
|
|
color.r = *(image + offset + 1);
|
|
|
|
color.g = *(image + offset + 32);
|
|
|
|
color.b = *(image + offset + 33);
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
gray = (77 * color.r + 150 * color.g + 28 * color.b) / 255;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
*(image + offset + 1) = gray;
|
|
|
|
*(image + offset + 32) = gray;
|
|
|
|
*(image + offset + 33) = gray;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
}
|
2009-10-17 09:24:14 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
int len = width * height * 4;
|
2010-09-24 02:48:03 +02:00
|
|
|
if (len % 32) len += (32 - len % 32);
|
|
|
|
DCFlushRange(image, len);
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void GuiImage::SetStripe(int s)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
|
|
|
stripe = s;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void GuiImage::SetSkew(int XX1, int YY1, int XX2, int YY2, int XX3, int YY3, int XX4, int YY4)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
xx1 = XX1;
|
|
|
|
yy1 = YY1;
|
|
|
|
xx2 = XX2;
|
|
|
|
yy2 = YY2;
|
|
|
|
xx3 = XX3;
|
|
|
|
yy3 = YY3;
|
|
|
|
xx4 = XX4;
|
|
|
|
yy4 = YY4;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
void GuiImage::SetSkew(int *skew)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
xx1 = *skew++;
|
|
|
|
yy1 = *skew++;
|
|
|
|
xx2 = *skew++;
|
|
|
|
yy2 = *skew++;
|
|
|
|
xx3 = *skew++;
|
|
|
|
yy3 = *skew++;
|
|
|
|
xx4 = *skew++;
|
|
|
|
yy4 = *skew;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void GuiImage::ColorStripe(int shift)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
|
|
|
int x, y;
|
|
|
|
GXColor color;
|
|
|
|
int alt = 0;
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
for (y = 0; y < this->GetHeight(); y++)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (y % 3 == 0) alt ^= 1;
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
for (x = 0; x < this->GetWidth(); x++)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
color = GetPixel(x, y);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (alt)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (color.r < 255 - shift)
|
2010-09-19 01:16:05 +02:00
|
|
|
color.r += shift;
|
2010-09-24 02:48:03 +02:00
|
|
|
else color.r = 255;
|
|
|
|
if (color.g < 255 - shift)
|
2010-09-19 01:16:05 +02:00
|
|
|
color.g += shift;
|
2010-09-24 02:48:03 +02:00
|
|
|
else color.g = 255;
|
|
|
|
if (color.b < 255 - shift)
|
2010-09-19 01:16:05 +02:00
|
|
|
color.b += shift;
|
2010-09-24 02:48:03 +02:00
|
|
|
else color.b = 255;
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
color.a = 255;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (color.r > shift)
|
2010-09-19 01:16:05 +02:00
|
|
|
color.r -= shift;
|
2010-09-24 02:48:03 +02:00
|
|
|
else color.r = 0;
|
|
|
|
if (color.g > shift)
|
2010-09-19 01:16:05 +02:00
|
|
|
color.g -= shift;
|
2010-09-24 02:48:03 +02:00
|
|
|
else color.g = 0;
|
|
|
|
if (color.b > shift)
|
2010-09-19 01:16:05 +02:00
|
|
|
color.b -= shift;
|
2010-09-24 02:48:03 +02:00
|
|
|
else color.b = 0;
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
color.a = 255;
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
SetPixel(x, y, color);
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int len = width * height * 4;
|
2010-09-24 02:48:03 +02:00
|
|
|
if (len % 32) len += (32 - len % 32);
|
|
|
|
DCFlushRange(image, len);
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw the button on screen
|
|
|
|
*/
|
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
void GuiImage::Draw()
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
2011-06-14 19:53:19 +02:00
|
|
|
if (!image || !this->IsVisible() || tileHorizontal == 0) return;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
float currScale = this->GetScale();
|
|
|
|
int currLeft = this->GetLeft();
|
2009-10-01 01:10:58 +02:00
|
|
|
|
|
|
|
float currAngleDyn = this->GetAngleDyn();
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (currAngleDyn && parentangle) imageangle = currAngleDyn;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2011-06-14 19:53:19 +02:00
|
|
|
if (tileHorizontal > 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2011-06-14 19:53:19 +02:00
|
|
|
for (int i = 0; i < tileHorizontal; i++)
|
2010-09-24 02:48:03 +02:00
|
|
|
Menu_DrawImg(currLeft + width * i, this->GetTop(), zoffset, width, height, image, imageangle,
|
2011-06-14 19:53:19 +02:00
|
|
|
widescreen ? currScale * Settings.WSFactor : currScale, currScale, this->GetAlpha(), xx1,
|
|
|
|
yy1, xx2, yy2, xx3, yy3, xx4, yy4);
|
|
|
|
}
|
|
|
|
else if(tileVertical > 0)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < tileVertical; i++)
|
|
|
|
Menu_DrawImg(currLeft, this->GetTop() + height * i, zoffset, width, height, image, imageangle,
|
|
|
|
widescreen ? currScale * Settings.WSFactor : currScale, currScale, this->GetAlpha(), xx1,
|
|
|
|
yy1, xx2, yy2, xx3, yy3, xx4, yy4);
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// temporary (maybe), used to correct offset for scaled images
|
2010-09-24 02:48:03 +02:00
|
|
|
if (scale != 1) currLeft = currLeft - width / 2 + (width * scale) / 2;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2011-02-25 19:18:57 +01:00
|
|
|
Menu_DrawImg(currLeft, this->GetTop(), zoffset, width, height, image, imageangle, widescreen ? currScale * Settings.WSFactor
|
2010-09-24 02:48:03 +02:00
|
|
|
: currScale, currScale, this->GetAlpha(), xx1, yy1, xx2, yy2, xx3, yy3, xx4, yy4);
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (stripe > 0) for (int y = 0; y < this->GetHeight(); y += 6)
|
|
|
|
Menu_DrawRectangle(currLeft, this->GetTop() + y, this->GetWidth(), 3, ( GXColor )
|
|
|
|
{ 0, 0, 0, stripe}, 1);
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
this->UpdateEffects();
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|