mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2025-01-11 19:39:09 +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_OFFSET 0x40
|
||||||
#define IMET_SIGNATURE 0x494d4554
|
#define IMET_SIGNATURE 0x494d4554
|
||||||
|
|
||||||
Banner::Banner(u8 *bnr, u64 title)
|
Banner::Banner(u8 *bnr, u32 bnr_size, u64 title)
|
||||||
{
|
{
|
||||||
this->title = title;
|
this->title = title;
|
||||||
opening = bnr;
|
opening = bnr;
|
||||||
|
opening_size = bnr_size;
|
||||||
imet = NULL;
|
imet = NULL;
|
||||||
|
|
||||||
if (opening == NULL) return;
|
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)
|
Banner * Banner::GetBanner(u64 title, char *appname, bool isfs, bool imetOnly)
|
||||||
{
|
{
|
||||||
void *buf = NULL;
|
void *buf = NULL;
|
||||||
|
u32 size = 0;
|
||||||
if (isfs)
|
if (isfs)
|
||||||
{
|
{
|
||||||
u32 size = 0;
|
|
||||||
|
|
||||||
buf = ISFS_GetFile((u8 *)appname, &size, imetOnly ? sizeof(IMET) + IMET_OFFSET : 0);
|
buf = ISFS_GetFile((u8 *)appname, &size, imetOnly ? sizeof(IMET) + IMET_OFFSET : 0);
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
{
|
{
|
||||||
@ -165,8 +165,9 @@ Banner * Banner::GetBanner(u64 title, char *appname, bool isfs, bool imetOnly)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
FILE *fp = fopen(appname, "rb");
|
FILE *fp = fopen(appname, "rb");
|
||||||
if (fp == NULL) return NULL;
|
if(fp == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
u32 size = sizeof(IMET) + IMET_OFFSET;
|
u32 size = sizeof(IMET) + IMET_OFFSET;
|
||||||
if (!imetOnly)
|
if (!imetOnly)
|
||||||
{
|
{
|
||||||
@ -183,5 +184,5 @@ Banner * Banner::GetBanner(u64 title, char *appname, bool isfs, bool imetOnly)
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Banner((u8 *)buf, title);
|
return new Banner((u8 *)buf, size, title);
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ typedef struct
|
|||||||
class Banner
|
class Banner
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Banner(u8 *bnr, u64 title = 0);
|
Banner(u8 *bnr, u32 bnr_size, u64 title = 0);
|
||||||
~Banner();
|
~Banner();
|
||||||
|
|
||||||
bool IsValid();
|
bool IsValid();
|
||||||
@ -68,11 +68,13 @@ class Banner
|
|||||||
bool GetName(u8 *name, int language);
|
bool GetName(u8 *name, int language);
|
||||||
bool GetName(wchar_t *name, int language);
|
bool GetName(wchar_t *name, int language);
|
||||||
const u8 *GetFile(char *name, u32 *size);
|
const u8 *GetFile(char *name, u32 *size);
|
||||||
|
|
||||||
static Banner *GetBanner(u64 title, char *appname, bool isfs, bool imetOnly = false);
|
static Banner *GetBanner(u64 title, char *appname, bool isfs, bool imetOnly = false);
|
||||||
|
u8 *GetBannerFile() { return opening; }
|
||||||
|
u32 GetBannerFileSize() { return opening_size; }
|
||||||
private:
|
private:
|
||||||
u8 *opening;
|
u8 *opening;
|
||||||
|
u32 opening_size;
|
||||||
u64 title;
|
u64 title;
|
||||||
IMET *imet;
|
IMET *imet;
|
||||||
|
|
||||||
|
@ -255,15 +255,15 @@ static Banner *_extractChannelBnr(const u64 chantitle)
|
|||||||
|
|
||||||
static Banner *_extractBnr(dir_discHdr *hdr)
|
static Banner *_extractBnr(dir_discHdr *hdr)
|
||||||
{
|
{
|
||||||
|
u32 size = 0;
|
||||||
Banner *banner = NULL;
|
Banner *banner = NULL;
|
||||||
wbfs_disc_t *disc = WBFS_OpenDisc((u8 *) &hdr->id, (char *) hdr->path);
|
wbfs_disc_t *disc = WBFS_OpenDisc((u8 *) &hdr->id, (char *) hdr->path);
|
||||||
if (disc != NULL)
|
if (disc != NULL)
|
||||||
{
|
{
|
||||||
void *bnr = NULL;
|
void *bnr = NULL;
|
||||||
if (wbfs_extract_file(disc, (char *) "opening.bnr", &bnr) > 0)
|
size = wbfs_extract_file(disc, (char *) "opening.bnr", &bnr);
|
||||||
{
|
if(size > 0)
|
||||||
banner = new Banner((u8 *) bnr);
|
banner = new Banner((u8 *)bnr, size);
|
||||||
}
|
|
||||||
WBFS_CloseDisc(disc);
|
WBFS_CloseDisc(disc);
|
||||||
}
|
}
|
||||||
return banner;
|
return banner;
|
||||||
@ -1493,6 +1493,7 @@ void CMenu::_gameSoundThread(CMenu *m)
|
|||||||
m->m_gamesound_changed = true;
|
m->m_gamesound_changed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
bool custom = false;
|
||||||
|
|
||||||
u8 *custom_bnr_file = NULL;
|
u8 *custom_bnr_file = NULL;
|
||||||
u32 custom_bnr_size = 0;
|
u32 custom_bnr_size = 0;
|
||||||
@ -1513,6 +1514,8 @@ void CMenu::_gameSoundThread(CMenu *m)
|
|||||||
}
|
}
|
||||||
if(fp)
|
if(fp)
|
||||||
{
|
{
|
||||||
|
custom = true;
|
||||||
|
gprintf("Custom Banner detected for: %s\n", m->m_cf.getHdr()->id);
|
||||||
fseek(fp, 0, SEEK_END);
|
fseek(fp, 0, SEEK_END);
|
||||||
custom_bnr_size = ftell(fp);
|
custom_bnr_size = ftell(fp);
|
||||||
fseek(fp, 0, SEEK_SET);
|
fseek(fp, 0, SEEK_SET);
|
||||||
@ -1525,7 +1528,7 @@ void CMenu::_gameSoundThread(CMenu *m)
|
|||||||
m->m_gamesound_changed = false;
|
m->m_gamesound_changed = false;
|
||||||
u32 sndSize = 0;
|
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 ?
|
(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));
|
_extractChannelBnr(TITLE_ID(m->m_gameSoundHdr->settings[0],m->m_gameSoundHdr->settings[1])) : NULL));
|
||||||
m->m_gameSoundHdr = NULL;
|
m->m_gameSoundHdr = NULL;
|
||||||
@ -1537,6 +1540,14 @@ void CMenu::_gameSoundThread(CMenu *m)
|
|||||||
delete banner;
|
delete banner;
|
||||||
return;
|
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()));
|
_extractBannerTitle(banner, GetLanguage(m->m_loc.getString(m->m_curLanguage, "gametdb_code", "EN").c_str()));
|
||||||
|
|
||||||
extern SmartBuf m_wbf1_font;
|
extern SmartBuf m_wbf1_font;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user