Skip to content

Commit

Permalink
Remove Game-specific Themes
Browse files Browse the repository at this point in the history
this was causing issues with changing themes and then changing themes and I didn't want to fix them so instead lets just simplify the issue because our game doesnt have game specific themes anyways and if you want to change to a Game and be on a specific theme you should do that yourself
  • Loading branch information
poco0317 committed Aug 21, 2020
1 parent 86d2926 commit d2e8d0d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 39 deletions.
37 changes: 6 additions & 31 deletions src/Etterna/Globals/GameLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,40 +190,15 @@ DoChangeGame()
ASSERT(g != nullptr);
GAMESTATE->SetCurGame(g);

bool theme_changing = false;
// The prefs allow specifying a different default theme to use for each
// game type. So if a theme name isn't passed in, fetch from the prefs.
if (g_NewTheme.empty()) {
g_NewTheme = PREFSMAN->m_sTheme.Get();
}
if (g_NewTheme != THEME->GetCurThemeName() &&
THEME->IsThemeSelectable(g_NewTheme)) {
theme_changing = true;
}

if (theme_changing) {
SAFE_DELETE(SCREENMAN);
TEXTUREMAN->DoDelayedDelete();
LUA->RegisterTypes();
THEME->SwitchThemeAndLanguage(
g_NewTheme, THEME->GetCurLanguage(), PREFSMAN->m_bPseudoLocalize);
PREFSMAN->m_sTheme.Set(g_NewTheme);
StepMania::ApplyGraphicOptions();
SCREENMAN = new ScreenManager();
}
// reset gamestate to deal with new Game
StepMania::ResetGame();

// point us to the new Screen to end up on after Game change
// either the initialscreen or something else
std::string new_screen = THEME->GetMetric("Common", "InitialScreen");
std::string after_screen;
if (theme_changing) {
SCREENMAN->ThemeChanged();
if (THEME->HasMetric("Common", "AfterGameAndThemeChangeScreen")) {
after_screen =
THEME->GetMetric("Common", "AfterGameAndThemeChangeScreen");
}
} else {
if (THEME->HasMetric("Common", "AfterGameChangeScreen")) {
after_screen = THEME->GetMetric("Common", "AfterGameChangeScreen");
}
if (THEME->HasMetric("Common", "AfterGameChangeScreen")) {
after_screen = THEME->GetMetric("Common", "AfterGameChangeScreen");
}
if (SCREENMAN->IsScreenNameValid(after_screen)) {
new_screen = after_screen;
Expand Down
2 changes: 2 additions & 0 deletions src/Etterna/Globals/StepMania.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ StepMania::ResetGame()
{
GAMESTATE->Reset();

// if somehow the current theme loaded does not exist anymore
// reset to a real one
if (!THEME->DoesThemeExist(THEME->GetCurThemeName())) {
std::string sGameName = GAMESTATE->GetCurrentGame()->m_szName;
if (!THEME->DoesThemeExist(sGameName))
Expand Down
6 changes: 0 additions & 6 deletions src/Etterna/Singletons/PrefsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ PrefsManager::StoreGamePrefs()
// save off old values
GamePrefs& gp = m_mapGameNameToGamePrefs[m_sCurrentGame.ToString()];
gp.m_sAnnouncer = m_sAnnouncer.Get();
gp.m_sTheme = m_sTheme.Get();
gp.m_sDefaultModifiers = m_sDefaultModifiers.Get();
}

Expand All @@ -296,7 +295,6 @@ PrefsManager::RestoreGamePrefs()
gp = iter->second;

m_sAnnouncer.Set(gp.m_sAnnouncer);
m_sTheme.Set(gp.m_sTheme);
m_sDefaultModifiers.Set(gp.m_sDefaultModifiers);

// give Static.ini a chance to clobber the saved game prefs
Expand All @@ -306,7 +304,6 @@ PrefsManager::RestoreGamePrefs()

PrefsManager::GamePrefs::GamePrefs()
: m_sAnnouncer("")
, m_sTheme(SpecialFiles::BASE_THEME_NAME)
, m_sDefaultModifiers("")
{
}
Expand Down Expand Up @@ -390,9 +387,7 @@ PrefsManager::ReadGamePrefsFromIni(const std::string& sIni)
section_name, section_name.length() - GAME_SECTION_PREFIX.length());
GamePrefs& gp = m_mapGameNameToGamePrefs[sGame];

// todo: read more prefs here? -aj
ini.GetValue(section_name, "Announcer", gp.m_sAnnouncer);
ini.GetValue(section_name, "Theme", gp.m_sTheme);
ini.GetValue(section_name, "DefaultModifiers", gp.m_sDefaultModifiers);
}
}
Expand Down Expand Up @@ -445,7 +440,6 @@ PrefsManager::SavePrefsToIni(IniFile& ini)

// todo: write more values here? -aj
ini.SetValue(sSection, "Announcer", iter.second.m_sAnnouncer);
ini.SetValue(sSection, "Theme", iter.second.m_sTheme);
ini.SetValue(
sSection, "DefaultModifiers", iter.second.m_sDefaultModifiers);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Etterna/Singletons/PrefsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ class PrefsManager
// Game-specific prefs. Copy these off and save them every time the game
// changes
Preference<std::string> m_sAnnouncer;
Preference<std::string> m_sTheme;
Preference<std::string> m_sDefaultModifiers;

protected:
Expand All @@ -119,12 +118,12 @@ class PrefsManager
GamePrefs();

std::string m_sAnnouncer;
std::string m_sTheme;
std::string m_sDefaultModifiers;
};
std::map<std::string, GamePrefs> m_mapGameNameToGamePrefs;

public:
Preference<std::string> m_sTheme;
Preference<bool> m_bWindowed;
Preference<std::string> m_sDisplayId;
Preference<int> m_iDisplayWidth;
Expand Down

0 comments on commit d2e8d0d

Please sign in to comment.