From 7f6394fa360658059bfbc7fb4468cb65f7f1a587 Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Wed, 4 Jul 2012 13:45:39 +0000 Subject: [PATCH] -added custom banner support, to use just place *.bnr files which either got the ID3 or the ID6 as name into wiiflow/banners -removed security check for banners since some custom banners are poorly made and not 100% valid -on game switching just display blackscreen instead of the old banner in the time of switching --- source/banner/BannerWindow.cpp | 5 ++-- source/banner/BannerWindow.hpp | 2 +- source/channel/banner.cpp | 7 +++--- source/menu/menu.cpp | 3 +++ source/menu/menu.hpp | 2 +- source/menu/menu_game.cpp | 44 ++++++++++++++++++++++++++-------- 6 files changed, 46 insertions(+), 17 deletions(-) diff --git a/source/banner/BannerWindow.cpp b/source/banner/BannerWindow.cpp index f3b43246..d4a08056 100644 --- a/source/banner/BannerWindow.cpp +++ b/source/banner/BannerWindow.cpp @@ -47,9 +47,10 @@ void BannerWindow::LoadBanner(Banner *banner, CVideo *vid, u8 *font1, u8 *font2) changing = false; } -void BannerWindow::DeleteBanner() +void BannerWindow::DeleteBanner(bool gamechange) { - gameSelected = 0; + if(!gamechange) + gameSelected = 0; gameBanner->Clear(); } diff --git a/source/banner/BannerWindow.hpp b/source/banner/BannerWindow.hpp index ac8e50ee..f91104a6 100644 --- a/source/banner/BannerWindow.hpp +++ b/source/banner/BannerWindow.hpp @@ -31,7 +31,7 @@ class BannerWindow { public: BannerWindow(); - void DeleteBanner(); + void DeleteBanner(bool gamechange = false); void LoadBanner(Banner *banner, CVideo *vid, u8 *font1, u8 *font2); int GetSelectedGame() { return gameSelected; } bool GetZoomSetting() { return AnimZoom; } diff --git a/source/channel/banner.cpp b/source/channel/banner.cpp index 86d65d74..3373d08c 100644 --- a/source/channel/banner.cpp +++ b/source/channel/banner.cpp @@ -58,6 +58,7 @@ Banner::Banner(u8 *bnr, u64 title) if (imet->sig == IMET_SIGNATURE) { + /* unsigned char md5[16]; unsigned char imetmd5[16]; @@ -66,13 +67,13 @@ Banner::Banner(u8 *bnr, u64 title) MD5(md5, (unsigned char*)(imet), sizeof(IMET)); if (memcmp(imetmd5, md5, 16) == 0) - { + {*/ this->imet = imet; - } + /*} else { gprintf("Invalid md5, banner not valid for title %08x\n", title); - } + }*/ } else { diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index bd9b3c6a..9216c344 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -283,6 +283,7 @@ void CMenu::init(void) m_app_update_zip = sfmt("%s/update.zip", m_appDir.c_str()); m_data_update_zip = sfmt("%s/update.zip", m_dataDir.c_str()); + m_bannerDir = m_cfg.getString("GENERAL", "dir_banners", sfmt("%s/banners", m_dataDir.c_str())); m_pluginsDir = m_cfg.getString("GENERAL", "dir_plugins", sfmt("%s/plugins", m_dataDir.c_str())); m_cacheDir = m_cfg.getString("GENERAL", "dir_cache", sfmt("%s/cache", m_dataDir.c_str())); m_settingsDir = m_cfg.getString("GENERAL", "dir_settings", sfmt("%s/settings", m_dataDir.c_str())); @@ -346,6 +347,8 @@ void CMenu::init(void) fsop_MakeFolder((char *)m_wipDir.c_str()); fsop_MakeFolder((char *)m_listCacheDir.c_str()); fsop_MakeFolder((char *)m_helpDir.c_str()); + fsop_MakeFolder((char *)m_pluginsDir.c_str()); + fsop_MakeFolder((char *)m_bannerDir.c_str()); // INI files m_cat.load(fmt("%s/" CAT_FILENAME, m_settingsDir.c_str())); diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index caa6bd8f..e8984009 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -83,13 +83,13 @@ private: s16 m_showtimer; string m_curLanguage; string m_curGameId; - string m_curChanId; u8 m_numCFVersions; string m_themeDataDir; string m_appDir; string m_dataDir; + string m_bannerDir; string m_pluginsDir; string m_picDir; string m_boxPicDir; diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index 209a00cd..155b11bb 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -600,6 +600,7 @@ void CMenu::_game(bool launch) m_gameSound.Stop(); m_gameSelected = false; m_fa.unload(); + m_banner->DeleteBanner(true); _setBg(m_mainBg, m_mainBgLQ); } if(m_show_zone_game && !m_zoom_banner) @@ -1485,31 +1486,54 @@ unsigned int gameSoundThreadStackSize = (unsigned int)32768; void CMenu::_gameSoundThread(CMenu *m) { - if(m->m_cf.getHdr()->type == TYPE_GC_GAME) - { - m->m_gameSound.Load(gc_ogg, gc_ogg_size, false); - m->m_gamesound_changed = true; - return; - } - else if(m->m_cf.getHdr()->type == TYPE_PLUGIN) + if(m->m_cf.getHdr()->type == TYPE_PLUGIN) { + m_banner->DeleteBanner(); m->m_gameSound.Load(m->m_plugin.GetBannerSound(m->m_cf.getHdr()->settings[0]), m->m_plugin.GetBannerSoundSize(), false); m->m_gamesound_changed = true; return; } + u8 *custom_bnr_file = NULL; + u32 custom_bnr_size = 0; + 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, "rb"); + if(!fp) + { + snprintf(custom_banner, sizeof(custom_banner), "%s/%.3s.bnr", m->m_bannerDir.c_str(), m->m_cf.getHdr()->id); + fp = fopen(custom_banner, "rb"); + if(!fp && m->m_cf.getHdr()->type == TYPE_GC_GAME) + { + m_banner->DeleteBanner(); + m->m_gameSound.Load(gc_ogg, gc_ogg_size, false); + m->m_gamesound_changed = true; + return; + } + } + if(fp) + { + fseek(fp, 0, SEEK_END); + custom_bnr_size = ftell(fp); + fseek(fp, 0, SEEK_SET); + custom_bnr_file = (u8*)MEM2_alloc(custom_bnr_size); + fread(custom_bnr_file, 1, custom_bnr_size, fp); + fclose(fp); + } + m->m_gameSoundHdr = m->m_cf.getHdr(); m->m_gamesound_changed = false; u32 sndSize = 0; - Banner *banner = 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; + Banner *banner = custom_bnr_file != NULL ? new Banner((u8 *)custom_bnr_file) : + (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; if (banner == NULL || !banner->IsValid()) { gprintf("no valid banner found\n"); + m_banner->DeleteBanner(); delete banner; return; }