keep the frontend loaded

This commit is contained in:
GaryOderNichts 2021-01-29 22:05:55 +01:00
parent 1846d08365
commit 1ddf1834d2
3 changed files with 54 additions and 20 deletions

View File

@ -3576,8 +3576,14 @@ CMenuManager::InitialiseChangedLanguageSettings()
void
CMenuManager::LoadAllTextures()
{
#ifndef KEEP_FRONTEND_LOADED
if (m_bSpritesLoaded)
return;
#else
if (m_bFrontendLoaded)
return;
m_bFrontendLoaded = true;
#endif
CentreMousePointer();
DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND);
@ -3599,6 +3605,11 @@ CMenuManager::LoadAllTextures()
} else if (m_PrefsRadioStation > CHATTERBOX)
m_PrefsRadioStation = CGeneral::GetRandomNumber() % (CHATTERBOX + 1);
#ifdef KEEP_FRONTEND_LOADED
if (m_bSpritesLoaded)
return;
#endif
CFileMgr::SetDir("");
//CFileMgr::SetDir("");
CTimer::Stop();
@ -5673,29 +5684,41 @@ CMenuManager::SwitchMenuOnAndOff()
}
void
#ifdef KEEP_FRONTEND_LOADED
CMenuManager::UnloadTextures(bool forceUnload)
#else
CMenuManager::UnloadTextures()
{
if (!m_bSpritesLoaded)
return;
printf("REMOVE frontend\n");
for (int i = 0; i < ARRAY_SIZE(FrontendFilenames); ++i)
m_aFrontEndSprites[i].Delete();
int frontend = CTxdStore::FindTxdSlot("frontend");
CTxdStore::RemoveTxd(frontend);
printf("REMOVE menu textures\n");
for (int i = 0; i < ARRAY_SIZE(MenuFilenames); ++i)
m_aMenuSprites[i].Delete();
#ifdef MENU_MAP
for (int i = 0; i < ARRAY_SIZE(MapFilenames); ++i)
m_aMapSprites[i].Delete();
#endif
int menu = CTxdStore::FindTxdSlot("menu");
CTxdStore::RemoveTxd(menu);
{
#ifdef KEEP_FRONTEND_LOADED
if (forceUnload)
#endif
{
if (!m_bSpritesLoaded)
return;
m_bSpritesLoaded = false;
printf("REMOVE frontend\n");
for (int i = 0; i < ARRAY_SIZE(FrontendFilenames); ++i)
m_aFrontEndSprites[i].Delete();
int frontend = CTxdStore::FindTxdSlot("frontend");
CTxdStore::RemoveTxd(frontend);
printf("REMOVE menu textures\n");
for (int i = 0; i < ARRAY_SIZE(MenuFilenames); ++i)
m_aMenuSprites[i].Delete();
#ifdef MENU_MAP
for (int i = 0; i < ARRAY_SIZE(MapFilenames); ++i)
m_aMapSprites[i].Delete();
#endif
int menu = CTxdStore::FindTxdSlot("menu");
CTxdStore::RemoveTxd(menu);
m_bSpritesLoaded = false;
}
#ifdef KEEP_FRONTEND_LOADED
m_bFrontendLoaded = false;
#endif
}
void

View File

@ -601,6 +601,9 @@ public:
char field_455;
bool m_bStartWaitingForKeyBind;
bool m_bSpritesLoaded;
#ifdef KEEP_FRONTEND_LOADED
bool m_bFrontendLoaded;
#endif
CSprite2d m_aFrontEndSprites[NUM_FE_SPRITES];
CSprite2d m_aMenuSprites[NUM_MENU_SPRITES];
int32 field_518;
@ -769,7 +772,11 @@ public:
float StretchX(float);
float StretchY(float);
void SwitchMenuOnAndOff();
#ifdef KEEP_FRONTEND_LOADED
void UnloadTextures(bool forceUnload = false);
#else
void UnloadTextures();
#endif
void WaitForUserCD();
void PrintController();
int GetNumOptionsCntrlConfigScreens();

View File

@ -1301,6 +1301,10 @@ main(int argc, char *argv[])
#endif
}
#ifdef KEEP_FRONTEND_LOADED
// since we kept our frontend loaded free the textures now
FrontEndMenuManager.UnloadTextures(true);
#endif
#ifndef MASTER
if ( gbModelViewer )