2009-07-14 16:28:17 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* USB Loader GX Team
|
|
|
|
* gui_banner.cpp
|
|
|
|
*
|
|
|
|
* Shows TPL Banner images
|
|
|
|
***************************************************************************/
|
2009-07-13 02:57:30 +02:00
|
|
|
#include "gui_banner.h"
|
2010-02-09 11:59:55 +01:00
|
|
|
|
|
|
|
GuiBanner::GuiBanner(const char *tplfilepath)
|
|
|
|
{
|
|
|
|
memory = NULL;
|
|
|
|
tplfilesize = 0;
|
2010-01-19 11:48:50 +01:00
|
|
|
width = 0;
|
|
|
|
height = 0;
|
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
FILE *tplfp = fopen(tplfilepath,"rb");
|
2010-01-19 11:48:50 +01:00
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
if(tplfp !=NULL) {
|
2010-01-19 11:48:50 +01:00
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
unsigned short heighttemp = 0;
|
|
|
|
unsigned short widthtemp = 0;
|
2010-01-19 11:48:50 +01:00
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
fseek(tplfp , 0x14, SEEK_SET);
|
|
|
|
fread((void*)&heighttemp,1,2,tplfp);
|
|
|
|
fread((void*)&widthtemp,1,2,tplfp);
|
|
|
|
fseek (tplfp , 0 , SEEK_END);
|
2010-01-19 11:48:50 +01:00
|
|
|
tplfilesize = ftell (tplfp);
|
|
|
|
rewind (tplfp);
|
|
|
|
memory = memalign(32, tplfilesize);
|
2010-02-09 11:59:55 +01:00
|
|
|
if(!memory) {
|
2010-01-19 11:48:50 +01:00
|
|
|
fclose(tplfp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fread(memory, 1, tplfilesize, tplfp);
|
2010-02-09 11:59:55 +01:00
|
|
|
fclose(tplfp);
|
2010-01-19 11:48:50 +01:00
|
|
|
|
|
|
|
TPLFile tplfile;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = TPL_OpenTPLFromMemory(&tplfile, memory, tplfilesize);
|
2010-02-09 11:59:55 +01:00
|
|
|
if(ret < 0) {
|
2010-01-19 11:48:50 +01:00
|
|
|
free(memory);
|
|
|
|
memory = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ret = TPL_GetTexture(&tplfile,0,&texObj);
|
2010-02-09 11:59:55 +01:00
|
|
|
if(ret < 0) {
|
2010-01-19 11:48:50 +01:00
|
|
|
free(memory);
|
|
|
|
memory = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
TPL_CloseTPLFile(&tplfile);
|
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
width = widthtemp;
|
|
|
|
height = heighttemp;
|
|
|
|
widescreen = 0;
|
|
|
|
filecheck = true;
|
2010-01-19 11:48:50 +01:00
|
|
|
|
|
|
|
} else {
|
2010-02-09 11:59:55 +01:00
|
|
|
filecheck = false;
|
|
|
|
fclose(tplfp);
|
2010-01-19 11:48:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
GuiBanner::GuiBanner(void *mem, u32 len, int w, int h)
|
|
|
|
{
|
|
|
|
if(!mem || !len)
|
2010-01-19 11:48:50 +01:00
|
|
|
return;
|
|
|
|
memory = mem;
|
|
|
|
tplfilesize = len;
|
|
|
|
width = w;
|
|
|
|
height = h;
|
|
|
|
|
|
|
|
TPLFile tplfile;
|
|
|
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = TPL_OpenTPLFromMemory(&tplfile, memory, tplfilesize);
|
2010-02-09 11:59:55 +01:00
|
|
|
if(ret < 0) {
|
2010-01-19 11:48:50 +01:00
|
|
|
free(memory);
|
|
|
|
memory = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ret = TPL_GetTexture(&tplfile,0,&texObj);
|
2010-02-09 11:59:55 +01:00
|
|
|
if(ret < 0) {
|
2010-01-19 11:48:50 +01:00
|
|
|
free(memory);
|
|
|
|
memory = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
TPL_CloseTPLFile(&tplfile);
|
|
|
|
|
|
|
|
filecheck = true;
|
|
|
|
}
|
2010-02-09 11:59:55 +01:00
|
|
|
|
|
|
|
GuiBanner::~GuiBanner()
|
|
|
|
{
|
|
|
|
if(memory != NULL) {
|
2010-01-19 11:48:50 +01:00
|
|
|
free(memory);
|
|
|
|
memory = NULL;
|
2010-02-09 11:59:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiBanner::Draw()
|
|
|
|
{
|
|
|
|
LOCK(this);
|
|
|
|
if(!filecheck ||!this->IsVisible())
|
|
|
|
return;
|
|
|
|
|
|
|
|
float currScale = this->GetScale();
|
2010-01-19 11:48:50 +01:00
|
|
|
|
|
|
|
Menu_DrawTPLImg(this->GetLeft(), this->GetTop(), 0, width, height, &texObj, imageangle, widescreen ? currScale*0.80 : currScale, currScale, this->GetAlpha(), xx1,yy1,xx2,yy2,xx3,yy3,xx4,yy4);
|
2010-02-09 11:59:55 +01:00
|
|
|
|
|
|
|
this->UpdateEffects();
|
|
|
|
}
|