From 6946155a5686f19a62157af00746f834bec47448 Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Fri, 14 Dec 2012 11:17:42 +0100 Subject: Inherit translation setting from environment. This ensures that users with a correctly-defined locale don't need to explicitely set the locale. - By dropping the setlocale content, it fixes the loading of translations. - Add a Debug log message to check what is put in the environment. --- src/app/app.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/app/app.cpp') diff --git a/src/app/app.cpp b/src/app/app.cpp index 81d874d..751ff21 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -132,7 +132,7 @@ CApplication::CApplication() m_dataPath = "./data"; - m_language = LANGUAGE_ENGLISH; + m_language = LANGUAGE_ENV; m_lowCPU = true; @@ -290,9 +290,14 @@ bool CApplication::Create() /* Gettext initialization */ - std::string locale = "C"; + std::string locale = ""; switch (m_language) { + default: + case LANGUAGE_ENV: + locale = ""; + break; + case LANGUAGE_ENGLISH: locale = "en_US.utf8"; break; @@ -314,7 +319,8 @@ bool CApplication::Create() langStr += locale; strcpy(S_LANGUAGE, langStr.c_str()); putenv(S_LANGUAGE); - setlocale(LC_ALL, locale.c_str()); + setlocale(LC_ALL, ""); + GetLogger()->Debug("Set locale to '%s'\n", locale.c_str()); std::string trPath = m_dataPath + "/" + m_dataDirs[DIR_I18N]; bindtextdomain("colobot", trPath.c_str()); -- cgit v1.2.3-1-g7c22 From c190c3efaec57dcb550a57a56538010ff5e2b532 Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Sun, 16 Dec 2012 21:29:13 +0100 Subject: Set a default datadir, in sync with the data installation path. --- src/app/app.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/app/app.cpp') diff --git a/src/app/app.cpp b/src/app/app.cpp index 751ff21..980ecc1 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -15,6 +15,7 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. +#include "common/config.h" #include "app/app.h" @@ -130,7 +131,7 @@ CApplication::CApplication() m_mouseButtonsState = 0; m_trackedKeys = 0; - m_dataPath = "./data"; + m_dataPath = CBOT_DEFAULT_DATADIR; m_language = LANGUAGE_ENV; -- cgit v1.2.3-1-g7c22 From a266692615e146246fd547c5b132a1fcc98b6a10 Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Sun, 16 Dec 2012 21:51:12 +0100 Subject: Use default installation paths for i18n. This finishes the work started in 19b75e174338f8e7be7486a7445d1e90e9795077 by actually using the translation where they are installed. --- src/app/app.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/app/app.cpp') diff --git a/src/app/app.cpp b/src/app/app.cpp index 751ff21..79c0e13 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -142,7 +142,6 @@ CApplication::CApplication() m_dataDirs[DIR_AI] = "ai"; m_dataDirs[DIR_FONT] = "fonts"; m_dataDirs[DIR_HELP] = "help"; - m_dataDirs[DIR_I18N] = "i18n"; m_dataDirs[DIR_ICON] = "icons"; m_dataDirs[DIR_LEVEL] = "levels"; m_dataDirs[DIR_MODEL] = "models"; @@ -322,8 +321,7 @@ bool CApplication::Create() setlocale(LC_ALL, ""); GetLogger()->Debug("Set locale to '%s'\n", locale.c_str()); - std::string trPath = m_dataPath + "/" + m_dataDirs[DIR_I18N]; - bindtextdomain("colobot", trPath.c_str()); + bindtextdomain("colobot", CBOT_I18N_DIR); bind_textdomain_codeset("colobot", "UTF-8"); textdomain("colobot"); -- cgit v1.2.3-1-g7c22 From f77734e01c85aded92cf5fdc1e7038658e6aaf29 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Thu, 20 Dec 2012 00:23:12 +0100 Subject: Installation path fixes and CMakeLists refactoring make && make install should now give a working installation. --- src/app/app.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/app/app.cpp') diff --git a/src/app/app.cpp b/src/app/app.cpp index 04f8d2a..3073d77 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -30,12 +30,11 @@ #include "object/robotmain.h" +#include #include #include -#include - #include #include #include @@ -131,7 +130,7 @@ CApplication::CApplication() m_mouseButtonsState = 0; m_trackedKeys = 0; - m_dataPath = CBOT_DEFAULT_DATADIR; + m_dataPath = COLOBOT_DEFAULT_DATADIR; m_language = LANGUAGE_ENV; @@ -274,13 +273,10 @@ bool CApplication::Create() { GetLogger()->Info("Creating CApplication\n"); - // I know, a primitive way to check for dir, but works - std::string readmePath = m_dataPath + "/README.txt"; - std::ifstream testReadme; - testReadme.open(readmePath.c_str(), std::ios_base::in); - if (!testReadme.good()) + boost::filesystem::path dataPath(m_dataPath); + if (! (boost::filesystem::exists(dataPath) && boost::filesystem::is_directory(dataPath)) ) { - GetLogger()->Error("Could not open test file in data dir: '%s'\n", readmePath.c_str()); + GetLogger()->Error("Data directory '%s' doesn't exist or is not a directory\n", m_dataPath.c_str()); m_errorMessage = std::string("Could not read from data directory:\n") + std::string("'") + m_dataPath + std::string("'\n") + std::string("Please check your installation, or supply a valid data directory by -datadir option."); @@ -322,7 +318,7 @@ bool CApplication::Create() setlocale(LC_ALL, ""); GetLogger()->Debug("Set locale to '%s'\n", locale.c_str()); - bindtextdomain("colobot", CBOT_I18N_DIR); + bindtextdomain("colobot", COLOBOT_I18N_DIR); bind_textdomain_codeset("colobot", "UTF-8"); textdomain("colobot"); -- cgit v1.2.3-1-g7c22 From f0e76ad446e58ea9b1564517fc3a823e61fd7410 Mon Sep 17 00:00:00 2001 From: erihel Date: Thu, 20 Dec 2012 21:57:57 +0100 Subject: sound fix --- src/app/app.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/app/app.cpp') diff --git a/src/app/app.cpp b/src/app/app.cpp index 3073d77..924ec74 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -89,7 +89,6 @@ CApplication::CApplication() m_private = new ApplicationPrivate(); m_iMan = new CInstanceManager(); m_eventQueue = new CEventQueue(m_iMan); - m_pluginManager = new CPluginManager(); m_profile = new CProfile(); m_engine = nullptr; @@ -158,9 +157,6 @@ CApplication::~CApplication() delete m_eventQueue; m_eventQueue = nullptr; - delete m_pluginManager; - m_pluginManager = nullptr; - delete m_profile; m_profile = nullptr; @@ -336,8 +332,7 @@ bool CApplication::Create() if (GetProfile().GetLocalProfileString("Resources", "Data", path)) m_dataPath = path; - m_pluginManager->LoadFromProfile(); - m_sound = static_cast(CInstanceManager::GetInstancePointer()->SearchInstance(CLASS_SOUND)); + m_sound = static_cast(CInstanceManager::GetInstancePointer()->SearchInstance(CLASS_SOUND)); if (!m_sound) { GetLogger()->Error("Sound not loaded, falling back to fake sound!\n"); -- cgit v1.2.3-1-g7c22 From 6d607e3ae8d60d2d5f11f053511a305db415205e Mon Sep 17 00:00:00 2001 From: erihel Date: Fri, 21 Dec 2012 17:31:55 +0100 Subject: latest changes --- src/app/app.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/app/app.cpp') diff --git a/src/app/app.cpp b/src/app/app.cpp index 924ec74..683b053 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -40,6 +40,11 @@ #include +#ifdef OPENAL_SOUND + #include "sound/oalsound/alsound.h" +#endif + + template<> CApplication* CSingleton::mInstance = nullptr; //! Static buffer for putenv locale @@ -332,12 +337,12 @@ bool CApplication::Create() if (GetProfile().GetLocalProfileString("Resources", "Data", path)) m_dataPath = path; - m_sound = static_cast(CInstanceManager::GetInstancePointer()->SearchInstance(CLASS_SOUND)); - - if (!m_sound) { - GetLogger()->Error("Sound not loaded, falling back to fake sound!\n"); - m_sound = new CSoundInterface(); - } + #ifdef OPENAL_SOUND + m_sound = static_cast(new ALSound()); + #else + GetLogger()->Info("No sound support.\n"); + m_sound = new CSoundInterface(); + #endif m_sound->Create(true); if (GetProfile().GetLocalProfileString("Resources", "Sound", path)) -- cgit v1.2.3-1-g7c22 From 1fa5f7a96fb4a1700847ebcf0b07a557da630b10 Mon Sep 17 00:00:00 2001 From: erihel Date: Tue, 25 Dec 2012 17:46:48 +0100 Subject: * Changed log level in sound module * Fixed warnings in sound module * Fixed problem with map loading when locale with different number separator --- src/app/app.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/app/app.cpp') diff --git a/src/app/app.cpp b/src/app/app.cpp index 683b053..da4fca4 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -316,7 +316,7 @@ bool CApplication::Create() langStr += locale; strcpy(S_LANGUAGE, langStr.c_str()); putenv(S_LANGUAGE); - setlocale(LC_ALL, ""); + setlocale(LC_ALL, locale.c_str()); GetLogger()->Debug("Set locale to '%s'\n", locale.c_str()); bindtextdomain("colobot", COLOBOT_I18N_DIR); -- cgit v1.2.3-1-g7c22 From c793d2d4c67a5556e39300988f42a630fc51e68d Mon Sep 17 00:00:00 2001 From: erihel Date: Tue, 25 Dec 2012 21:36:50 +0100 Subject: * Changed Ret to Get methods in sound module * Added video settings to profile * Resolution change is now posibble but restart is required --- src/app/app.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/app/app.cpp') diff --git a/src/app/app.cpp b/src/app/app.cpp index da4fca4..118e100 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -325,9 +325,6 @@ bool CApplication::Create() GetLogger()->Debug("Testing gettext translation: '%s'\n", gettext("Colobot rules!")); - // Temporarily -- only in windowed mode - m_deviceConfig.fullScreen = false; - //Create the sound instance. if (!GetProfile().InitCurrentDirectory()) { GetLogger()->Warn("Config not found. Default values will be used!\n"); @@ -383,7 +380,20 @@ bool CApplication::Create() m_exitCode = 3; return false; } - + + // load settings from profile + int iValue; + if ( GetProfile().GetLocalProfileInt("Setup", "Resolution", iValue) ) { + std::vector modes; + GetVideoResolutionList(modes, true, true); + if (static_cast(iValue) < modes.size()) + m_deviceConfig.size = modes.at(iValue); + } + + if ( GetProfile().GetLocalProfileInt("Setup", "Fullscreen", iValue) ) { + m_deviceConfig.fullScreen = (iValue == 1); + } + if (! CreateVideoSurface()) return false; // dialog is in function @@ -403,8 +413,7 @@ bool CApplication::Create() // Don't generate joystick events SDL_JoystickEventState(SDL_IGNORE); - - + // The video is ready, we can create and initalize the graphics device m_device = new Gfx::CGLDevice(m_deviceConfig); if (! m_device->Create() ) -- cgit v1.2.3-1-g7c22 From 0d825ed613ae62b0ed22a7e7f9ea1f001e3f8ea3 Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Thu, 27 Dec 2012 16:13:26 +0100 Subject: Fix locale's loading - Always inherit LC_ALL from environment; - Enforce environment only if the runtime options require it; --- src/app/app.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/app/app.cpp') diff --git a/src/app/app.cpp b/src/app/app.cpp index 118e100..27adcb1 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -312,11 +312,14 @@ bool CApplication::Create() break; } - std::string langStr = "LANGUAGE="; - langStr += locale; - strcpy(S_LANGUAGE, langStr.c_str()); - putenv(S_LANGUAGE); - setlocale(LC_ALL, locale.c_str()); + if (!locale.empty()) + { + std::string langStr = "LANG="; + langStr += locale; + strcpy(S_LANGUAGE, langStr.c_str()); + putenv(S_LANGUAGE); + } + setlocale(LC_ALL, ""); GetLogger()->Debug("Set locale to '%s'\n", locale.c_str()); bindtextdomain("colobot", COLOBOT_I18N_DIR); -- cgit v1.2.3-1-g7c22 From e62996858b2ce2be322eae55f86b4b0ad7172a08 Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Thu, 27 Dec 2012 17:10:45 +0100 Subject: Create a central version Make it 0.1.0~pre-alpha for now. - Add it to runtime program - Add it to -help option - Add it to manpage - Update translations --- src/app/app.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/app/app.cpp') diff --git a/src/app/app.cpp b/src/app/app.cpp index 27adcb1..000cfdf 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -246,7 +246,7 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) else if (arg == "-help") { GetLogger()->Message("\n"); - GetLogger()->Message("COLOBOT GOLD pre-alpha\n"); + GetLogger()->Message("Colobot %s (%s)\n",COLOBOT_CODENAME,COLOBOT_VERSION); GetLogger()->Message("\n"); GetLogger()->Message("List of available options:\n"); GetLogger()->Message(" -help this help\n"); -- cgit v1.2.3-1-g7c22 From 4cbb63f5b7824dc48e999401c625adb50075fdca Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Fri, 28 Dec 2012 12:06:37 +0100 Subject: Fixed path for loading sounds --- src/app/app.cpp | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'src/app/app.cpp') diff --git a/src/app/app.cpp b/src/app/app.cpp index 27adcb1..4d32de3 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -329,26 +329,29 @@ bool CApplication::Create() GetLogger()->Debug("Testing gettext translation: '%s'\n", gettext("Colobot rules!")); //Create the sound instance. - if (!GetProfile().InitCurrentDirectory()) { + if (!GetProfile().InitCurrentDirectory()) + { GetLogger()->Warn("Config not found. Default values will be used!\n"); m_sound = new CSoundInterface(); - } else { + } + else + { std::string path; if (GetProfile().GetLocalProfileString("Resources", "Data", path)) m_dataPath = path; - #ifdef OPENAL_SOUND - m_sound = static_cast(new ALSound()); - #else - GetLogger()->Info("No sound support.\n"); - m_sound = new CSoundInterface(); - #endif + #ifdef OPENAL_SOUND + m_sound = static_cast(new ALSound()); + #else + GetLogger()->Info("No sound support.\n"); + m_sound = new CSoundInterface(); + #endif m_sound->Create(true); if (GetProfile().GetLocalProfileString("Resources", "Sound", path)) m_sound->CacheAll(path); else - m_sound->CacheAll(m_dataPath); + m_sound->CacheAll(GetDataSubdirPath(DIR_SOUND)); } std::string standardInfoMessage = @@ -1421,24 +1424,26 @@ std::string CApplication::GetDataDirPath() return m_dataPath; } -std::string CApplication::GetDataFilePath(DataDir dataDir, const std::string& subpath) +std::string CApplication::GetDataSubdirPath(DataDir stdDir) { - int index = static_cast(dataDir); + int index = static_cast(stdDir); assert(index >= 0 && index < DIR_MAX); std::stringstream str; str << m_dataPath; str << "/"; str << m_dataDirs[index]; - str << "/"; - str << subpath; return str.str(); } -std::string CApplication::GetDataFilePath(const std::string& subpath) +std::string CApplication::GetDataFilePath(DataDir stdDir, const std::string& subpath) { + int index = static_cast(stdDir); + assert(index >= 0 && index < DIR_MAX); std::stringstream str; str << m_dataPath; str << "/"; + str << m_dataDirs[index]; + str << "/"; str << subpath; return str.str(); } -- cgit v1.2.3-1-g7c22 From f4c6f49b2fd01de2d6daff5ec1b9c181c39d09b7 Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Fri, 28 Dec 2012 22:31:47 +0100 Subject: Move language initialisation in SetLanguage --- src/app/app.cpp | 90 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 48 insertions(+), 42 deletions(-) (limited to 'src/app/app.cpp') diff --git a/src/app/app.cpp b/src/app/app.cpp index 4d32de3..32f68e1 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -285,48 +285,7 @@ bool CApplication::Create() return false; } - /* Gettext initialization */ - - std::string locale = ""; - switch (m_language) - { - default: - case LANGUAGE_ENV: - locale = ""; - break; - - case LANGUAGE_ENGLISH: - locale = "en_US.utf8"; - break; - - case LANGUAGE_GERMAN: - locale = "de_DE.utf8"; - break; - - case LANGUAGE_FRENCH: - locale = "fr_FR.utf8"; - break; - - case LANGUAGE_POLISH: - locale = "pl_PL.utf8"; - break; - } - - if (!locale.empty()) - { - std::string langStr = "LANG="; - langStr += locale; - strcpy(S_LANGUAGE, langStr.c_str()); - putenv(S_LANGUAGE); - } - setlocale(LC_ALL, ""); - GetLogger()->Debug("Set locale to '%s'\n", locale.c_str()); - - bindtextdomain("colobot", COLOBOT_I18N_DIR); - bind_textdomain_codeset("colobot", "UTF-8"); - textdomain("colobot"); - - GetLogger()->Debug("Testing gettext translation: '%s'\n", gettext("Colobot rules!")); + SetLanguage(m_language); //Create the sound instance. if (!GetProfile().InitCurrentDirectory()) @@ -1456,6 +1415,53 @@ Language CApplication::GetLanguage() void CApplication::SetLanguage(Language language) { m_language = language; + + /* Gettext initialization */ + + std::string locale = ""; + switch (m_language) + { + default: + case LANGUAGE_ENV: + locale = ""; + break; + + case LANGUAGE_ENGLISH: + locale = "en_US.utf8"; + break; + + case LANGUAGE_GERMAN: + locale = "de_DE.utf8"; + break; + + case LANGUAGE_FRENCH: + locale = "fr_FR.utf8"; + break; + + case LANGUAGE_POLISH: + locale = "pl_PL.utf8"; + break; + } + + if (locale.empty()) + { + GetLogger()->Trace("SetLanguage: Inherit LANGUAGE=%s from environment\n", getenv("LANGUAGE")); + } + else + { + std::string langStr = "LANGUAGE="; + langStr += locale; + strcpy(S_LANGUAGE, langStr.c_str()); + putenv(S_LANGUAGE); + GetLogger()->Trace("SetLanguage: Set LANGUAGE=%s in environment\n", locale.c_str()); + } + setlocale(LC_ALL, ""); + + bindtextdomain("colobot", COLOBOT_I18N_DIR); + bind_textdomain_codeset("colobot", "UTF-8"); + textdomain("colobot"); + + GetLogger()->Debug("SetLanguage: Test gettext translation: '%s'\n", gettext("Colobot rules!")); } void CApplication::SetLowCPU(bool low) -- cgit v1.2.3-1-g7c22 From 1b4208cdc5143cfc8f46da063a1a991795d7f307 Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Fri, 28 Dec 2012 23:06:12 +0100 Subject: Implement language Char for level files This currently lacks fallback to an existing entry for non-translated entries --- src/app/app.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'src/app/app.cpp') diff --git a/src/app/app.cpp b/src/app/app.cpp index 32f68e1..1e577ca 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -1412,6 +1412,32 @@ Language CApplication::GetLanguage() return m_language; } +char CApplication::GetLanguageChar() +{ + char langChar = 'E'; + switch (m_language) + { + default: + case LANGUAGE_ENV: + case LANGUAGE_ENGLISH: + langChar = 'E'; + break; + + case LANGUAGE_GERMAN: + langChar = 'D'; + break; + + case LANGUAGE_FRENCH: + langChar = 'F'; + break; + + case LANGUAGE_POLISH: + langChar = 'P'; + break; + } + return langChar; +} + void CApplication::SetLanguage(Language language) { m_language = language; @@ -1445,7 +1471,24 @@ void CApplication::SetLanguage(Language language) if (locale.empty()) { - GetLogger()->Trace("SetLanguage: Inherit LANGUAGE=%s from environment\n", getenv("LANGUAGE")); + char *envLang = getenv("LANGUAGE"); + if (strncmp(envLang,"en",2) == 0) + { + m_language = LANGUAGE_ENGLISH; + } + else if (strncmp(envLang,"de",2) == 0) + { + m_language = LANGUAGE_GERMAN; + } + else if (strncmp(envLang,"fr",2) == 0) + { + m_language = LANGUAGE_FRENCH; + } + else if (strncmp(envLang,"po",2) == 0) + { + m_language = LANGUAGE_POLISH; + } + GetLogger()->Trace("SetLanguage: Inherit LANGUAGE=%s from environment\n", envLang); } else { -- cgit v1.2.3-1-g7c22