From f7fca167dcc74928bda2d404887b9ddcc3ff48c0 Mon Sep 17 00:00:00 2001 From: Jannik Vogel Date: Wed, 10 Aug 2016 19:15:10 +0200 Subject: [PATCH] Allow language selection in config --- rwgame/GameConfig.cpp | 5 +++++ rwgame/GameConfig.hpp | 4 ++++ rwgame/RWGame.cpp | 3 +-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/rwgame/GameConfig.cpp b/rwgame/GameConfig.cpp index 69f79f8a..7e9a62f2 100644 --- a/rwgame/GameConfig.cpp +++ b/rwgame/GameConfig.cpp @@ -79,6 +79,11 @@ int GameConfig::handler(void* user, { self->m_gamePath = value; } + else if (MATCH("game", "language")) + { + // @todo Don't allow path seperators and relative directories + self->m_gameLanguage = value; + } else if (MATCH("input", "invert_y")) { self->m_inputInvertY = atoi(value) > 0; diff --git a/rwgame/GameConfig.hpp b/rwgame/GameConfig.hpp index 2cf4dd95..f7624efa 100644 --- a/rwgame/GameConfig.hpp +++ b/rwgame/GameConfig.hpp @@ -24,6 +24,7 @@ public: bool isValid(); const std::string& getGameDataPath() const { return m_gamePath; } + const std::string& getGameLanguage() const { return m_gameLanguage; } bool getInputInvertY() const { return m_inputInvertY; } private: @@ -40,6 +41,9 @@ private: /// Path to the game data std::string m_gamePath; + /// Language for game + std::string m_gameLanguage = "american"; + /// Invert the y axis for camera control. bool m_inputInvertY; }; diff --git a/rwgame/RWGame.cpp b/rwgame/RWGame.cpp index f0e7a4c6..c4dfc97f 100644 --- a/rwgame/RWGame.cpp +++ b/rwgame/RWGame.cpp @@ -126,8 +126,7 @@ RWGame::RWGame(int argc, char* argv[]) data->loadDynamicObjects(config.getGameDataPath() + "/data/object.dat"); - /// @TODO language choices. - data->loadGXT("american.gxt"); + data->loadGXT(config.getGameLanguage() + ".gxt"); getRenderer()->water.setWaterTable(data->waterHeights, 48, data->realWater, 128*128);