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-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
GuiBanner::GuiBanner( const char *tplfilepath )
|
|
|
|
{
|
|
|
|
memory = NULL;
|
|
|
|
tplfilesize = 0;
|
2010-01-19 11:48:50 +01:00
|
|
|
width = 0;
|
|
|
|
height = 0;
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
FILE *tplfp = fopen( tplfilepath, "rb" );
|
2010-01-19 11:48:50 +01:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( tplfp != NULL )
|
|
|
|
{
|
2010-01-19 11:48:50 +01:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
unsigned short heighttemp = 0;
|
|
|
|
unsigned short widthtemp = 0;
|
2010-01-19 11:48:50 +01:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
fseek( tplfp , 0x14, SEEK_SET );
|
|
|
|
fread( ( void* )&heighttemp, 1, 2, tplfp );
|
|
|
|
fread( ( void* )&widthtemp, 1, 2, tplfp );
|
|
|
|
fseek ( tplfp , 0 , SEEK_END );
|
|
|
|
tplfilesize = ftell ( tplfp );
|
|
|
|
rewind ( tplfp );
|
|
|
|
memory = memalign( 32, tplfilesize );
|
|
|
|
if ( !memory )
|
|
|
|
{
|
|
|
|
fclose( tplfp );
|
2010-01-19 11:48:50 +01:00
|
|
|
return;
|
|
|
|
}
|
2010-09-19 01:16:05 +02:00
|
|
|
fread( memory, 1, tplfilesize, tplfp );
|
|
|
|
fclose( tplfp );
|
2010-01-19 11:48:50 +01:00
|
|
|
|
|
|
|
TPLFile tplfile;
|
|
|
|
int ret;
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = TPL_OpenTPLFromMemory( &tplfile, memory, tplfilesize );
|
|
|
|
if ( ret < 0 )
|
|
|
|
{
|
|
|
|
free( memory );
|
2010-01-19 11:48:50 +01:00
|
|
|
memory = NULL;
|
|
|
|
return;
|
|
|
|
}
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = TPL_GetTexture( &tplfile, 0, &texObj );
|
|
|
|
if ( ret < 0 )
|
|
|
|
{
|
|
|
|
free( memory );
|
2010-01-19 11:48:50 +01:00
|
|
|
memory = NULL;
|
|
|
|
return;
|
|
|
|
}
|
2010-09-19 01:16:05 +02:00
|
|
|
TPL_CloseTPLFile( &tplfile );
|
2010-01-19 11:48:50 +01:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
width = widthtemp;
|
|
|
|
height = heighttemp;
|
|
|
|
widescreen = 0;
|
|
|
|
filecheck = true;
|
2010-01-19 11:48:50 +01:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
filecheck = false;
|
|
|
|
fclose( tplfp );
|
2010-01-19 11:48:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
GuiBanner::GuiBanner( void *mem, u32 len, int w, int h )
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( !mem || !len )
|
2010-01-19 11:48:50 +01:00
|
|
|
return;
|
|
|
|
memory = mem;
|
|
|
|
tplfilesize = len;
|
|
|
|
width = w;
|
|
|
|
height = h;
|
|
|
|
|
|
|
|
TPLFile tplfile;
|
|
|
|
|
|
|
|
int ret;
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = TPL_OpenTPLFromMemory( &tplfile, memory, tplfilesize );
|
|
|
|
if ( ret < 0 )
|
|
|
|
{
|
|
|
|
free( memory );
|
2010-01-19 11:48:50 +01:00
|
|
|
memory = NULL;
|
|
|
|
return;
|
|
|
|
}
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = TPL_GetTexture( &tplfile, 0, &texObj );
|
|
|
|
if ( ret < 0 )
|
|
|
|
{
|
|
|
|
free( memory );
|
2010-01-19 11:48:50 +01:00
|
|
|
memory = NULL;
|
|
|
|
return;
|
|
|
|
}
|
2010-09-19 01:16:05 +02:00
|
|
|
TPL_CloseTPLFile( &tplfile );
|
2010-01-19 11:48:50 +01:00
|
|
|
|
|
|
|
filecheck = true;
|
|
|
|
}
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
GuiBanner::~GuiBanner()
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( memory != NULL )
|
|
|
|
{
|
|
|
|
free( memory );
|
2010-01-19 11:48:50 +01:00
|
|
|
memory = NULL;
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
}
|
2010-01-19 11:48:50 +01:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
void GuiBanner::Draw()
|
|
|
|
{
|
|
|
|
LOCK( this );
|
|
|
|
if ( !filecheck || !this->IsVisible() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
float currScale = this->GetScale();
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
|
|
|
this->UpdateEffects();
|
|
|
|
}
|