Added the necessary code to handle switching language live at runtime (not yet accessible in a nice way from the user interface, this will need to come later)
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7420 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
0ffb08e285
commit
ec543ae213
@ -22,6 +22,8 @@
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/screen.hpp"
|
||||
|
||||
/**
|
||||
* \ingroup guiengine
|
||||
@ -116,6 +118,25 @@ namespace GUIEngine
|
||||
/** \brief to be called after e.g. a resolution switch */
|
||||
void reshowTopMostMenu();
|
||||
|
||||
template<typename T>
|
||||
void hardResetAndGoToScreen()
|
||||
{
|
||||
if (m_game_mode != GAME) GUIEngine::getCurrentScreen()->tearDown();
|
||||
m_menu_stack.clear();
|
||||
|
||||
GUIEngine::clearScreenCache();
|
||||
|
||||
T* instance = T::getInstance();
|
||||
|
||||
m_menu_stack.push_back(instance->getName());
|
||||
setGameState(MENU);
|
||||
|
||||
switchToScreen(instance->getName().c_str());
|
||||
getCurrentScreen()->init();
|
||||
|
||||
onTopMostScreenChanged();
|
||||
}
|
||||
|
||||
/* ***********************************
|
||||
* methods to override in children *
|
||||
*********************************** */
|
||||
|
@ -719,6 +719,15 @@ namespace GUIEngine
|
||||
} // cleanForGame
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
void clearScreenCache()
|
||||
{
|
||||
g_loaded_screens.clearAndDeleteAll();
|
||||
g_current_screen = NULL;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
void switchToScreen(const char* screen_name)
|
||||
{
|
||||
needsUpdate.clearWithoutDeleting();
|
||||
|
@ -148,6 +148,8 @@ namespace GUIEngine
|
||||
*/
|
||||
inline AbstractStateManager* getStateManager() { return Private::g_state_manager; }
|
||||
|
||||
void clearScreenCache();
|
||||
|
||||
/**
|
||||
* \precondition GUIEngine::init must have been called first
|
||||
* \return the skin object used to render widgets
|
||||
|
@ -133,6 +133,21 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, cons
|
||||
|
||||
if (selection == "network")
|
||||
{
|
||||
delete translations;
|
||||
static int cycle = 0;
|
||||
cycle++;
|
||||
if (cycle > 5) cycle = 1;
|
||||
|
||||
if (cycle == 1) putenv("LANGUAGE=he");
|
||||
if (cycle == 2) putenv("LANGUAGE=zh_CN");
|
||||
if (cycle == 3) putenv("LANGUAGE=fr");
|
||||
if (cycle == 4) putenv("LANGUAGE=ru");
|
||||
if (cycle == 5) putenv("LANGUAGE=en");
|
||||
|
||||
translations = new Translations();
|
||||
GUIEngine::getStateManager()->hardResetAndGoToScreen<MainMenuScreen>();
|
||||
return;
|
||||
|
||||
FeatureUnlockedCutScene* scene = FeatureUnlockedCutScene::getInstance();
|
||||
|
||||
static int i = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user