- reworked code for custom backgrounds. should be better.

This commit is contained in:
Fledge68 2019-11-23 17:54:38 -06:00
parent 02f1d4ba8d
commit d2c23240e7
6 changed files with 63 additions and 30 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 MiB

After

Width:  |  Height:  |  Size: 3.6 MiB

View File

@ -82,6 +82,7 @@ CMenu::CMenu()
cacheCovers = false;
SF_cacheCovers = true;
m_snapshot_loaded = false;
curCustBg = 1;
/* Explorer stuff */
m_txt_view = false;
m_txt_path = NULL;
@ -505,8 +506,8 @@ void CMenu::_Theme_Cleanup(void)
m_nextBg = NULL;
TexHandle.Cleanup(m_curBg);
m_lqBg = NULL;
TexHandle.Cleanup(sfbgimg);
TexHandle.Cleanup(m_mainAltBg);
TexHandle.Cleanup(m_mainCustomBg[0]);
TexHandle.Cleanup(m_mainCustomBg[1]);
/* Buttons */
TexHandle.Cleanup(theme.btnTexL);
TexHandle.Cleanup(theme.btnTexR);
@ -1822,10 +1823,10 @@ void CMenu::_mainLoopCommon(bool withCF, bool adjusting)
#endif
}
void CMenu::_setBg(const TexData &bgTex, const TexData &bglqTex, bool force_change)
void CMenu::_setBg(const TexData &bgTex, const TexData &bglqTex)
{
/* Not setting same bg again */
if(!force_change && m_nextBg == &bgTex)
if(m_nextBg == &bgTex)
return;
m_lqBg = &bglqTex;
/* before setting new next bg set previous */

View File

@ -66,6 +66,7 @@ private:
bool CFLocked;
bool Auto_hide_icons;
bool m_snapshot_loaded;
bool customBg;
vector<dir_discHdr> m_gameList;
vector<string> tiers;
vector<string> sm_numbers;
@ -103,6 +104,7 @@ private:
u8 m_numCFVersions;
u8 m_numPlugins;
u8 m_max_source_btn;
u8 curCustBg;
char cf_domain[16];
bool m_use_source;// source_menu.ini found & ok to use source menu/flow
bool m_sourceflow;// in sourceflow view
@ -184,10 +186,7 @@ private:
const TexData *m_lqBg;
u8 m_bgCrossFade;
//
TexData sfbgimg;
TexData m_mainAltBg;
TexData m_errorBg;
TexData m_mainBg;
TexData m_configBg;
TexData m_config3Bg;
TexData m_configScreenBg;
@ -197,14 +196,16 @@ private:
TexData m_cheatBg;
TexData m_downloadBg;
TexData m_gameinfoBg;
TexData m_gameBg;
TexData m_codeBg;
TexData m_aboutBg;
TexData m_systemBg;
TexData m_wbfsBg;
TexData m_gameSettingsBg;
TexData m_gameBg;
TexData m_gameBgLQ;
TexData m_mainBg;
TexData m_mainBgLQ;
TexData m_mainCustomBg[2];
//Main Coverflow
s16 m_mainBtnCategories;
@ -1059,8 +1060,9 @@ private:
void _updateCheckboxes(void);
void _getGameCategories(void);
void _setGameCategories(void);
void _getCustomBgTex(void);
void _setMainBg(void);
void _setBg(const TexData &bgTex, const TexData &bglqTex, bool force_change = false);
void _setBg(const TexData &bgTex, const TexData &bglqTex);
void _updateBg(void);
void _drawBg(void);
void _updateText(void);

View File

@ -11,7 +11,7 @@ extern const u32 gc_ogg_size;
bool m_zoom_banner = false;
bool m_banner_loaded = false;
bool m_set_bg = false;
bool m_setMainBg = false;
s16 m_gameBtnPlayFull;
s16 m_gameBtnBackFull;
s16 m_gameBtnToggle;
@ -280,13 +280,17 @@ void CMenu::_showGame(void)
m_fa.getBackground(bg, bglq);
_setBg(*bg, *bglq);
CoverFlow.hideCover();
m_setMainBg = true;
}
else if(m_set_bg)
else if(m_setMainBg)
{
CoverFlow.showCover();
_setMainBg();
if(customBg)
_setBg(m_mainCustomBg[curCustBg], m_mainCustomBg[curCustBg]);
else
_setBg(m_gameBg, m_gameBgLQ);
m_setMainBg = false;
}
m_set_bg = true;
}
void CMenu::_cleanupBanner(bool gamechange)
@ -379,7 +383,7 @@ bool CMenu::_startVideo()
void CMenu::_game(bool launch)
{
m_banner_loaded = false;
m_set_bg = false;
m_setMainBg = true;
bool coverFlipped = false;
int cf_version = 1;
string domain;
@ -434,7 +438,11 @@ void CMenu::_game(bool launch)
{
m_fa.unload();
CoverFlow.showCover();
_setMainBg();
if(customBg)
_setBg(m_mainCustomBg[curCustBg], m_mainCustomBg[curCustBg]);
else
_setBg(m_gameBg, m_gameBgLQ);
m_setMainBg = false;
}
else //loop fanart
m_fa.reset();
@ -505,6 +513,7 @@ void CMenu::_game(bool launch)
_hideGame();
m_banner.SetShowBanner(false);
_gameinfo();
m_setMainBg = true;
_showGame();
m_banner.SetShowBanner(true);
}
@ -541,6 +550,7 @@ void CMenu::_game(bool launch)
m_fa.unload();
CoverFlow.showCover();
_setMainBg();
m_setMainBg = false;
continue;
}
/* delete button */
@ -566,6 +576,7 @@ void CMenu::_game(bool launch)
startGameSound = -10;
}
}
m_setMainBg = true;
_showGame();
m_banner.SetShowBanner(true);
}
@ -587,6 +598,7 @@ void CMenu::_game(bool launch)
m_banner.ToggleGameSettings();//reset brightness
m_banner.ToggleZoom();//de zoom to small
}
m_setMainBg = true;
_showGame();
}
else if(m_btnMgr.selected(m_gameBtnFavoriteOn) || m_btnMgr.selected(m_gameBtnFavoriteOff))
@ -616,6 +628,7 @@ void CMenu::_game(bool launch)
m_banner.ToggleGameSettings();//reset brightness
m_banner.ToggleZoom();//de zoom to small
}
m_setMainBg = true;
_showGame();
if(m_newGame)
startGameSound = -10;
@ -642,6 +655,7 @@ void CMenu::_game(bool launch)
{
error(_t("errgame19", L"Can't launch in Wii virtual console mode!"));
launch = false;
m_setMainBg = true;
_showGame();
}
else

View File

@ -42,13 +42,16 @@ void CMenu::_hideMain(bool instant)
m_btnMgr.hide(m_mainLblUser[i], instant);
}
void CMenu::_setMainBg()
void CMenu::_getCustomBgTex()
{
curCustBg += 1;
if(curCustBg == 2)
curCustBg = 0;
if(m_sourceflow)
_setSrcFlowBg();
else
{
TexHandle.Cleanup(m_mainAltBg);
TexHandle.Cleanup(m_mainCustomBg[curCustBg]);
string fn = "";
if(m_platform.loaded())
{
@ -83,27 +86,35 @@ void CMenu::_setMainBg()
}
if(fn.length() > 0)
{
if(TexHandle.fromImageFile(m_mainAltBg, fmt("%s/%s/%s.png", m_bckgrndsDir.c_str(), m_themeName.c_str(), fn.c_str())) != TE_OK)
if(TexHandle.fromImageFile(m_mainCustomBg[curCustBg], fmt("%s/%s/%s.png", m_bckgrndsDir.c_str(), m_themeName.c_str(), fn.c_str())) != TE_OK)
{
if(TexHandle.fromImageFile(m_mainAltBg, fmt("%s/%s/%s.jpg", m_bckgrndsDir.c_str(), m_themeName.c_str(), fn.c_str())) != TE_OK)
if(TexHandle.fromImageFile(m_mainCustomBg[curCustBg], fmt("%s/%s/%s.jpg", m_bckgrndsDir.c_str(), m_themeName.c_str(), fn.c_str())) != TE_OK)
{
if(TexHandle.fromImageFile(m_mainAltBg, fmt("%s/%s.png", m_bckgrndsDir.c_str(), fn.c_str())) != TE_OK)
if(TexHandle.fromImageFile(m_mainCustomBg[curCustBg], fmt("%s/%s.png", m_bckgrndsDir.c_str(), fn.c_str())) != TE_OK)
{
if(TexHandle.fromImageFile(m_mainAltBg, fmt("%s/%s.jpg", m_bckgrndsDir.c_str(), fn.c_str())) != TE_OK)
if(TexHandle.fromImageFile(m_mainCustomBg[curCustBg], fmt("%s/%s.jpg", m_bckgrndsDir.c_str(), fn.c_str())) != TE_OK)
{
_setBg(m_mainBg, m_mainBgLQ);
customBg = false;
return;
}
}
}
}
_setBg(m_mainAltBg, m_mainAltBg, true);
customBg = true;
}
else
_setBg(m_mainBg, m_mainBgLQ);
customBg = false;
}
}
void CMenu::_setMainBg()
{
if(customBg)
_setBg(m_mainCustomBg[curCustBg], m_mainCustomBg[curCustBg]);
else
_setBg(m_mainBg, m_mainBgLQ);
}
void CMenu::_showMain()
{
_setMainBg();
@ -376,6 +387,7 @@ int CMenu::main(void)
gprintf("Bootup completed!\n");
m_refreshGameList = true;
_getCustomBgTex();
_showMain();
if(show_mem)
{
@ -407,6 +419,7 @@ int CMenu::main(void)
m_cfg.setString(SOURCEFLOW_DOMAIN, "numbers", sm_numbers_backup);// restore if no source chosen
m_cfg.setString(SOURCEFLOW_DOMAIN, "tiers", sm_tiers_backup);
m_sourceflow = false;// if not back a tier then exit sourceflow
_getCustomBgTex();
_setMainBg();
}
_showCF(true);
@ -420,7 +433,7 @@ int CMenu::main(void)
sm_numbers_backup = m_cfg.getString(SOURCEFLOW_DOMAIN, "numbers");//backup for possible restore later
sm_tiers_backup = m_cfg.getString(SOURCEFLOW_DOMAIN, "tiers");
m_sourceflow = true;
_setSrcFlowBg();
_getCustomBgTex();
_showCF(true);
}
else //show source menu
@ -443,6 +456,7 @@ int CMenu::main(void)
m_cfg.setString(SOURCEFLOW_DOMAIN, "numbers", sm_numbers_backup);// restore if no source chosen
m_cfg.setString(SOURCEFLOW_DOMAIN, "tiers", sm_tiers_backup);
m_sourceflow = false;
_getCustomBgTex();
_setMainBg();
}
_showCF(true);
@ -498,6 +512,7 @@ int CMenu::main(void)
m_source_cnt = 1;
m_cfg.setUInt("GENERAL", "sources", m_current_view);
m_catStartPage = 1;
_getCustomBgTex();
_setMainBg();
_showCF(true);
}
@ -586,6 +601,7 @@ int CMenu::main(void)
if(m_sourceflow)
{
_sourceFlow();// set the source selected
_getCustomBgTex();
_setMainBg();
_showCF(true);
continue;

View File

@ -208,7 +208,7 @@ bool CMenu::_srcTierBack(bool home)
srcDomain = m_source.nextDomain().c_str();
}
if(m_sourceflow)
_setSrcFlowBg();
_getCustomBgTex();
else
{
curPage = stoi(sm_numbers[sm_numbers.size() - 1]) / 12 + 1;
@ -220,19 +220,19 @@ bool CMenu::_srcTierBack(bool home)
/* set custom sourceflow background image if available */
void CMenu::_setSrcFlowBg(void)
{
TexHandle.Cleanup(sfbgimg);
TexHandle.Cleanup(m_mainCustomBg[curCustBg]);
string fn = m_source.getString("general", "background", "");
if(fn.length() > 0)
{
if(TexHandle.fromImageFile(sfbgimg, fmt("%s/backgrounds/%s/%s", m_sourceDir.c_str(), m_themeName.c_str(), fn.c_str())) != TE_OK)
if(TexHandle.fromImageFile(m_mainCustomBg[curCustBg], fmt("%s/backgrounds/%s/%s", m_sourceDir.c_str(), m_themeName.c_str(), fn.c_str())) != TE_OK)
{
if(TexHandle.fromImageFile(sfbgimg, fmt("%s/backgrounds/%s", m_sourceDir.c_str(), fn.c_str())) != TE_OK)
if(TexHandle.fromImageFile(m_mainCustomBg[curCustBg], fmt("%s/backgrounds/%s", m_sourceDir.c_str(), fn.c_str())) != TE_OK)
{
_setBg(m_mainBg, m_mainBgLQ);
return;
}
}
_setBg(sfbgimg, sfbgimg, true);
_setBg(m_mainCustomBg[curCustBg], m_mainCustomBg[curCustBg]);
}
else
_setBg(m_mainBg, m_mainBgLQ);