Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fied the translation and translation update for names contained withi…

…n global scripts.

This fixes skills, items, status effects, ... names and description when displayed
in another language than english.
  • Loading branch information...
commit 1559c6c204a2cd7b6780168ce99276e916aa999c 1 parent 7b1549a
Yohann Ferreira authored
10 src/common/global/global.cpp
View
@@ -91,6 +91,10 @@ GameGlobal::~GameGlobal()
ClearAllData();
+ _CloseGlobalScripts();
+} // GameGlobal::~GameGlobal()
+
+void GameGlobal::_CloseGlobalScripts() {
// Close all persistent script files
_global_script.CloseFile();
@@ -130,9 +134,9 @@ GameGlobal::~GameGlobal()
_map_sprites_script.CloseFile();
_map_objects_script.CloseFile();
_map_treasures_script.CloseFile();
-} // GameGlobal::~GameGlobal()
+}
-bool GameGlobal::SingletonInitialize()
+bool GameGlobal::_LoadGlobalScripts()
{
// Open up the persistent script files
if(_global_script.OpenFile("dat/global.lua") == false) {
@@ -202,7 +206,7 @@ bool GameGlobal::SingletonInitialize()
return false;
return true;
-} // bool GameGlobal::SingletonInitialize()
+}
void GameGlobal::ClearAllData()
{
13 src/common/global/global.h
View
@@ -158,7 +158,12 @@ class GameGlobal : public hoa_utils::Singleton<GameGlobal>
public:
~GameGlobal();
- bool SingletonInitialize();
+ bool SingletonInitialize()
+ { return _LoadGlobalScripts(); }
+
+ //! Reloads the persistent scripts. Used when changing the language for instance.
+ bool ReloadGlobalScripts()
+ { _CloseGlobalScripts(); return _LoadGlobalScripts(); }
/** \brief Deletes all data stored within the GameGlobal class object
*** This function is meant to be called when the user quits the current game instance
@@ -795,6 +800,12 @@ class GameGlobal : public hoa_utils::Singleton<GameGlobal>
*** \param group_name The name of the event group to load
**/
void _LoadEvents(hoa_script::ReadScriptDescriptor &file, const std::string &group_name);
+
+ //! Loads every persistent scripts, used at the global initialization time.
+ bool _LoadGlobalScripts();
+
+ //! Unloads every persistent scripts by closing their files.
+ void _CloseGlobalScripts();
}; // class GameGlobal : public hoa_utils::Singleton<GameGlobal>
//-----------------------------------------------------------------------------
2  src/engine/script/script_write.cpp
View
@@ -260,7 +260,6 @@ void WriteScriptDescriptor::WriteString(const int32 key, const std::string &valu
// WriteUString can not use the _WriteData helper because it needs to do additional
// checking and add quotation marks around its value.
-// TODO: Write strings with a call to the gettext library to retrieve translated strings
void WriteScriptDescriptor::WriteUString(const std::string &key, const std::string &value)
{
WriteString(key, value);
@@ -387,7 +386,6 @@ void WriteScriptDescriptor::WriteStringVector(const int32 key, std::vector<std::
// WriteUString can not use the _WriteData helper because it needs to do additional
// checking and add quotation marks around its value.
-// TODO: Write strings with a call to the gettext library to retrieve translated strings
void WriteScriptDescriptor::WriteUStringVector(const std::string &key, std::vector<std::string>& vect)
{
WriteStringVector(key, vect);
2  src/engine/system.cpp
View
@@ -303,7 +303,7 @@ void Reinitl10n()
}
-void SystemEngine::SetLanguage(std::string lang)
+void SystemEngine::SetLanguage(const std::string& lang)
{
Reinitl10n();
4 src/engine/system.h
View
@@ -430,14 +430,14 @@ class SystemEngine : public hoa_utils::Singleton<SystemEngine>
/** \brief Used to determine what language the game is running in.
*** \return The language that the game is running in.
**/
- std::string GetLanguage() const {
+ const std::string& GetLanguage() const {
return _language;
}
/** \brief Sets the language that the game should use.
*** \param lang A two-character string representing the language to execute the game in
**/
- void SetLanguage(std::string lang);
+ void SetLanguage(const std::string& lang);
/** \brief Determines whether the user is done with the game.
*** \return False if the user would like to exit the game.
11 src/main.cpp
View
@@ -288,8 +288,6 @@ void InitializeEngine() throw(Exception)
GUIManager = GUISystem::SingletonCreate();
GlobalManager = GameGlobal::SingletonCreate();
- // TODO: Open the user setting's file and apply those settings
-
if(VideoManager->SingletonInitialize() == false) {
throw Exception("ERROR: unable to initialize VideoManager", __FILE__, __LINE__, __FUNCTION__);
}
@@ -315,9 +313,6 @@ void InitializeEngine() throw(Exception)
if(ModeManager->SingletonInitialize() == false) {
throw Exception("ERROR: unable to initialize ModeManager", __FILE__, __LINE__, __FUNCTION__);
}
- if(GlobalManager->SingletonInitialize() == false) {
- throw Exception("ERROR: unable to initialize GlobalManager", __FILE__, __LINE__, __FUNCTION__);
- }
// Set the window icon
#ifdef _WIN32
@@ -369,6 +364,12 @@ void InitializeEngine() throw(Exception)
throw Exception("ERROR: unable to initialize GUIManager", __FILE__, __LINE__, __FUNCTION__);
}
+ // This loads the game global script, once everything is ready,
+ // and will permit to load skills, items and other translatable strings
+ // using the correct settings language.
+ if(!GlobalManager->SingletonInitialize())
+ throw Exception("ERROR: unable to initialize GlobalManager", __FILE__, __LINE__, __FUNCTION__);
+
SystemManager->InitializeTimers();
} // void InitializeEngine()
3  src/modes/boot/boot.cpp
View
@@ -910,6 +910,9 @@ void BootMode::_OnLanguageSelect()
// Reload all the translatable text in the boot menus.
_ReloadTranslatableMenus();
+
+ // Reloads the global scripts to update their inner translatable strings
+ GlobalManager->ReloadGlobalScripts();
}
Please sign in to comment.
Something went wrong with that request. Please try again.