Skip to content
Permalink
Browse files

Fix bug when changing languages without reloading game (old language …

…would stick around).

This should hopefully put an end to mods not correctly falling back to English when no translation is available. As long as you support en-US everything should be fine.
  • Loading branch information
SupSuper committed Nov 22, 2018
1 parent f0be2ee commit efa947e1e3336669245462a34de48231aa663ad7
Showing with 9 additions and 9 deletions.
  1. +2 −2 src/Engine/Game.cpp
  2. +4 −4 src/Engine/Game.h
  3. +1 −1 src/Menu/OptionsBaseState.cpp
  4. +1 −1 src/Menu/OptionsDefaultsState.cpp
  5. +1 −1 src/Menu/StartState.cpp
@@ -557,10 +557,10 @@ bool Game::isQuitting() const
}

/**
* Loads the most appropriate language
* Loads the most appropriate languages
* given current system and game options.
*/
void Game::defaultLanguage()
void Game::loadLanguages()
{
const std::string defaultLang = "en-US";
std::string currentLang = defaultLang;
@@ -55,6 +55,8 @@ class Game
int _timeUntilNextFrame;
static const double VOLUME_GRADIENT;

/// Loads a new language for the game.
void loadLanguage(const std::string &filename);
public:
/// Creates a new game and initializes SDL.
Game(const std::string &title);
@@ -82,8 +84,6 @@ class Game
void popState();
/// Gets the currently loaded language.
Language *getLanguage() const;
/// Loads a new language for the game.
void loadLanguage(const std::string &filename);
/// Gets the currently loaded saved game.
SavedGame *getSavedGame() const;
/// Sets a new saved game for the game.
@@ -98,8 +98,8 @@ class Game
bool isState(State *state) const;
/// Returns whether the game is shutting down.
bool isQuitting() const;
/// Sets up the default language.
void defaultLanguage();
/// Loads the default and current language.
void loadLanguages();
/// Sets up the audio.
void initAudio();
};
@@ -203,7 +203,7 @@ void OptionsBaseState::btnOkClick(Action *)
{
Options::mapResources();
}
_game->loadLanguage(Options::language);
_game->loadLanguages();
SDL_WM_GrabInput(Options::captureMouse);
_game->getScreen()->resetDisplay();
_game->setVolume(Options::soundVolume, Options::musicVolume, Options::uiVolume);
@@ -93,7 +93,7 @@ void OptionsDefaultsState::btnYesClick(Action *action)
{
std::vector< std::pair<std::string, bool> > prevMods(Options::mods);
Options::resetDefault();
_game->defaultLanguage();
_game->loadLanguages();

if (_origin == OPT_MENU && prevMods != Options::mods)
{
@@ -285,7 +285,7 @@ int StartState::load(void *game_ptr)
game->loadMods();
Log(LOG_INFO) << "Data loaded successfully.";
Log(LOG_INFO) << "Loading language...";
game->defaultLanguage();
game->loadLanguages();
Log(LOG_INFO) << "Language loaded successfully.";
loading = LOADING_SUCCESSFUL;
}

0 comments on commit efa947e

Please sign in to comment.
You can’t perform that action at this time.