mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-01 09:05:06 +01:00
-added banner caching (always enabled like cover cache)
This commit is contained in:
parent
a201479cb4
commit
dbd6bee944
@ -42,10 +42,11 @@
|
||||
#define IMET_OFFSET 0x40
|
||||
#define IMET_SIGNATURE 0x494d4554
|
||||
|
||||
Banner::Banner(u8 *bnr, u64 title)
|
||||
Banner::Banner(u8 *bnr, u32 bnr_size, u64 title)
|
||||
{
|
||||
this->title = title;
|
||||
opening = bnr;
|
||||
opening_size = bnr_size;
|
||||
imet = NULL;
|
||||
|
||||
if (opening == NULL) return;
|
||||
@ -150,10 +151,9 @@ const u8 *Banner::GetFile(char *name, u32 *size)
|
||||
Banner * Banner::GetBanner(u64 title, char *appname, bool isfs, bool imetOnly)
|
||||
{
|
||||
void *buf = NULL;
|
||||
u32 size = 0;
|
||||
if (isfs)
|
||||
{
|
||||
u32 size = 0;
|
||||
|
||||
buf = ISFS_GetFile((u8 *)appname, &size, imetOnly ? sizeof(IMET) + IMET_OFFSET : 0);
|
||||
if (size == 0)
|
||||
{
|
||||
@ -165,7 +165,8 @@ Banner * Banner::GetBanner(u64 title, char *appname, bool isfs, bool imetOnly)
|
||||
else
|
||||
{
|
||||
FILE *fp = fopen(appname, "rb");
|
||||
if (fp == NULL) return NULL;
|
||||
if(fp == NULL)
|
||||
return NULL;
|
||||
|
||||
u32 size = sizeof(IMET) + IMET_OFFSET;
|
||||
if (!imetOnly)
|
||||
@ -183,5 +184,5 @@ Banner * Banner::GetBanner(u64 title, char *appname, bool isfs, bool imetOnly)
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
return new Banner((u8 *)buf, title);
|
||||
return new Banner((u8 *)buf, size, title);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ typedef struct
|
||||
class Banner
|
||||
{
|
||||
public:
|
||||
Banner(u8 *bnr, u64 title = 0);
|
||||
Banner(u8 *bnr, u32 bnr_size, u64 title = 0);
|
||||
~Banner();
|
||||
|
||||
bool IsValid();
|
||||
@ -70,9 +70,11 @@ class Banner
|
||||
const u8 *GetFile(char *name, u32 *size);
|
||||
|
||||
static Banner *GetBanner(u64 title, char *appname, bool isfs, bool imetOnly = false);
|
||||
|
||||
u8 *GetBannerFile() { return opening; }
|
||||
u32 GetBannerFileSize() { return opening_size; }
|
||||
private:
|
||||
u8 *opening;
|
||||
u32 opening_size;
|
||||
u64 title;
|
||||
IMET *imet;
|
||||
|
||||
|
@ -255,15 +255,15 @@ static Banner *_extractChannelBnr(const u64 chantitle)
|
||||
|
||||
static Banner *_extractBnr(dir_discHdr *hdr)
|
||||
{
|
||||
u32 size = 0;
|
||||
Banner *banner = NULL;
|
||||
wbfs_disc_t *disc = WBFS_OpenDisc((u8 *) &hdr->id, (char *) hdr->path);
|
||||
if (disc != NULL)
|
||||
{
|
||||
void *bnr = NULL;
|
||||
if (wbfs_extract_file(disc, (char *) "opening.bnr", &bnr) > 0)
|
||||
{
|
||||
banner = new Banner((u8 *) bnr);
|
||||
}
|
||||
size = wbfs_extract_file(disc, (char *) "opening.bnr", &bnr);
|
||||
if(size > 0)
|
||||
banner = new Banner((u8 *)bnr, size);
|
||||
WBFS_CloseDisc(disc);
|
||||
}
|
||||
return banner;
|
||||
@ -1493,6 +1493,7 @@ void CMenu::_gameSoundThread(CMenu *m)
|
||||
m->m_gamesound_changed = true;
|
||||
return;
|
||||
}
|
||||
bool custom = false;
|
||||
|
||||
u8 *custom_bnr_file = NULL;
|
||||
u32 custom_bnr_size = 0;
|
||||
@ -1513,6 +1514,8 @@ void CMenu::_gameSoundThread(CMenu *m)
|
||||
}
|
||||
if(fp)
|
||||
{
|
||||
custom = true;
|
||||
gprintf("Custom Banner detected for: %s\n", m->m_cf.getHdr()->id);
|
||||
fseek(fp, 0, SEEK_END);
|
||||
custom_bnr_size = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
@ -1525,7 +1528,7 @@ void CMenu::_gameSoundThread(CMenu *m)
|
||||
m->m_gamesound_changed = false;
|
||||
u32 sndSize = 0;
|
||||
|
||||
Banner *banner = custom_bnr_file != NULL ? new Banner((u8 *)custom_bnr_file) :
|
||||
Banner *banner = custom_bnr_file != NULL ? new Banner((u8 *)custom_bnr_file, custom_bnr_size) :
|
||||
(m->m_gameSoundHdr->type == TYPE_WII_GAME ? _extractBnr(m->m_gameSoundHdr) : (m->m_gameSoundHdr->type == TYPE_CHANNEL ?
|
||||
_extractChannelBnr(TITLE_ID(m->m_gameSoundHdr->settings[0],m->m_gameSoundHdr->settings[1])) : NULL));
|
||||
m->m_gameSoundHdr = NULL;
|
||||
@ -1537,6 +1540,14 @@ void CMenu::_gameSoundThread(CMenu *m)
|
||||
delete banner;
|
||||
return;
|
||||
}
|
||||
else if(!custom)
|
||||
{
|
||||
char custom_banner[256];
|
||||
snprintf(custom_banner, sizeof(custom_banner), "%s/%.6s.bnr", m->m_bannerDir.c_str(), m->m_cf.getHdr()->id);
|
||||
FILE *fp = fopen(custom_banner, "wb");
|
||||
fwrite(banner->GetBannerFile(), 1, banner->GetBannerFileSize(), fp);
|
||||
fclose(fp);
|
||||
}
|
||||
_extractBannerTitle(banner, GetLanguage(m->m_loc.getString(m->m_curLanguage, "gametdb_code", "EN").c_str()));
|
||||
|
||||
extern SmartBuf m_wbf1_font;
|
||||
|
Loading…
Reference in New Issue
Block a user