From e0be334456774903c9e196360ff8b614242758c0 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 11 Mar 2016 09:44:21 +0100 Subject: [PATCH 1/4] Changed: Create new client.cfg --HG-- branch : develop --- .../tools/client/client_config_qt/config.cpp | 53 ++++++++++++++++--- .../tools/client/client_config_qt/config.h | 10 +++- 2 files changed, 54 insertions(+), 9 deletions(-) diff --git a/code/ryzom/tools/client/client_config_qt/config.cpp b/code/ryzom/tools/client/client_config_qt/config.cpp index 0d41db0cd..15cd4fb9d 100644 --- a/code/ryzom/tools/client/client_config_qt/config.cpp +++ b/code/ryzom/tools/client/client_config_qt/config.cpp @@ -17,6 +17,10 @@ #include "stdpch.h" #include "config.h" +#include "nel/misc/common.h" +#include "nel/misc/i18n.h" +#include "nel/misc/path.h" + CConfig::CConfig() { } @@ -25,17 +29,50 @@ CConfig::~CConfig() { } -bool CConfig::load( const char *fileName ) +bool CConfig::create(const std::string &configFileName, const std::string &defaultFileName) +{ + NLMISC::CFile::createDirectoryTree(NLMISC::CFile::getPath(configFileName)); + + // create the basic .cfg + FILE *fp = NLMISC::nlfopen(configFileName, "w"); + + if (fp == NULL) return false; + + // store full path to default config file + fprintf(fp, "RootConfigFilename = \"%s\";\n", defaultFileName.c_str()); + + // get current locale + std::string lang = NLMISC::CI18N::getSystemLanguageCode(); + + const std::vector &languages = NLMISC::CI18N::getLanguageCodes(); + + // search if current locale is defined in language codes + for(uint i = 0; i < languages.size(); ++i) + { + if (lang == languages[i]) + { + // store the language code in the config file + fprintf(fp, "LanguageCode = \"%s\";\n", lang.c_str()); + break; + } + } + + fclose(fp); + + return true; +} + +bool CConfig::load(const std::string &fileName) { try { - cf.load( fileName ); + cf.load(fileName); - std::string def = getString( "RootConfigFilename" ); - if( def.compare( "" ) != 0 ) - dcf.load( def ); + std::string def = getString("RootConfigFilename"); + if (!def.empty()) + dcf.load(def); } - catch( NLMISC::Exception &e ) + catch (const NLMISC::Exception &e) { nlwarning( "%s", e.what() ); return false; @@ -51,7 +88,7 @@ bool CConfig::reload() cf.clear(); cf.reparse(); } - catch( NLMISC::Exception &e ) + catch (const NLMISC::Exception &e) { nlwarning( "%s", e.what() ); return false; @@ -112,7 +149,7 @@ bool CConfig::save() { cf.save(); } - catch( NLMISC::Exception &e ) + catch (const NLMISC::Exception &e) { nlwarning( "%s", e.what() ); return false; diff --git a/code/ryzom/tools/client/client_config_qt/config.h b/code/ryzom/tools/client/client_config_qt/config.h index d9ddb536e..05f82c83a 100644 --- a/code/ryzom/tools/client/client_config_qt/config.h +++ b/code/ryzom/tools/client/client_config_qt/config.h @@ -28,12 +28,20 @@ public: CConfig(); ~CConfig(); + /** + @brief Create a config file. + @param fileName - The config file to create + @param defaultFileName - The default config file to use + @return Returns true on success, returns false on failure. + */ + bool create(const std::string &fileName, const std::string &defaultFileName); + /** @brief Loads a config file. @param fileName - The file to load @return Returns true on success, returns false on failure. */ - bool load( const char *fileName ); + bool load(const std::string &fileName); /** @brief Reloads the contents of the config file From c0958ab0b53c23836005025c368e4d1703023777 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 11 Mar 2016 09:45:11 +0100 Subject: [PATCH 2/4] Fixed: Determine path of client.cfg and client_default.cfg --HG-- branch : develop --- .../tools/client/client_config_qt/main.cpp | 100 +++++++++++++++++- 1 file changed, 95 insertions(+), 5 deletions(-) diff --git a/code/ryzom/tools/client/client_config_qt/main.cpp b/code/ryzom/tools/client/client_config_qt/main.cpp index 2ee58d5bd..2967ce4a0 100644 --- a/code/ryzom/tools/client/client_config_qt/main.cpp +++ b/code/ryzom/tools/client/client_config_qt/main.cpp @@ -18,6 +18,7 @@ #include "client_config_dialog.h" #include "system.h" +#include "nel/misc/cmd_args.h" #include @@ -42,21 +43,110 @@ int main(sint32 argc, char **argv) QApplication app(argc, argv); + // parse command-line arguments + NLMISC::CCmdArgs args; + args.setDescription("Ryzom Configuration"); + args.addArg("p", "profile", "id", "Use this profile to determine what directory to use by default"); + + if (!args.parse(argc, argv)) return 1; + QApplication::setWindowIcon(QIcon(":/resources/welcome_icon.png")); QPixmap pixmap(":/resources/splash_screen.png" ); QSplashScreen splash( pixmap ); - splash.show(); - QString locale = QLocale::system().name().left(2); + QLocale locale = QLocale::system(); + // load application translations QTranslator localTranslator; - if (localTranslator.load(QString(":/translations/ryzom_configuration_%1.qm").arg(locale))) + if (localTranslator.load(locale, "ryzom_configuration", "_", ":/translations")) + { + QApplication::installTranslator(&localTranslator); + } + + // load Qt default translations + QTranslator qtTranslator; + if (qtTranslator.load(locale, "qt", "_", ":/translations")) + { + QApplication::installTranslator(&qtTranslator); + } + + // Known cases: + // 1. Steam + // - Linux and Windows: all files in Steam folder + // - OS X: client.cfg in ~/Library/Application Support/Ryzom, client_default.cfg in Steam folder + // 2. Installer + // - Linux: client.cfg in ~/.ryzom// client_default.cfg in ~/.ryzom/ryzom_live/ + // - Windows: client.cfg in Roaming/Ryzom// client_default.cfg in Local/Ryzom/ryzom_live/ + // - OS X: client.cfg in ~/Library/Application Support/Ryzom// client_default.cfg in ~/Library/Application Support/Ryzom/ryzom_live/ + + // default paths + std::string ryzomDir = NLMISC::CPath::standardizePath(NLMISC::CPath::getApplicationDirectory("Ryzom")); + std::string currentDir = args.getStartupPath(); + std::string executableDir = args.getProgramPath(); + + std::string configFilename = "client.cfg"; + std::string configPath; + + // search client.cfg file in config directory (Ryzom Installer) + if (args.haveArg("p")) + { + ryzomDir = NLMISC::CPath::standardizePath(ryzomDir + args.getArg("p").front()); + + // client.cfg is always in profile directory if using -p argument + configPath = ryzomDir + configFilename; + } + else + { +#ifdef NL_OS_MAC + // client.cfg is in ~/Library/Application Support/Ryzom under OS X + configPath = ryzomDir + configFilename; +#else + // client.cfg is in current directory under other platforms + configPath = currentDir + configFilename; +#endif + } + + // if file doesn't exist, create it + if (!NLMISC::CFile::fileExists(configPath)) { - app.installTranslator(&localTranslator); + // we need the full path to client_default.cfg + std::string defaultConfigFilename = "client_default.cfg"; + std::string defaultConfigPath; + +#ifdef NL_OS_MAC + // fix path inside bundle + defaultConfigPath = NLMISC::CPath::makePathAbsolute("../Resources", executableDir, true) + defaultConfigFilename; +#else + // same path as executables + defaultConfigPath = executableDir + defaultConfigFilename; +#endif + + // test if default config exists in determined path + if (!NLMISC::CFile::fileExists(defaultConfigPath)) + { + defaultConfigPath = currentDir + defaultConfigFilename; + + // test if default config exists in current path + if (!NLMISC::CFile::fileExists(defaultConfigPath)) + { + nlwarning("Unable to find %s", defaultConfigFilename.c_str()); + return 1; + } + } + + if (!CSystem::GetInstance().config.create(configPath, defaultConfigPath)) + { + nlwarning("Unable to create %s", configPath.c_str()); + return 1; + } } - CSystem::GetInstance().config.load( "client.cfg" ); + if (!CSystem::GetInstance().config.load(configPath)) + { + nlwarning("Unable to load %s", configPath.c_str()); + return 1; + } CClientConfigDialog d; d.show(); From e4f8bb0e162e24c4d877ea2f02970a0ba8e50d43 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 11 Mar 2016 09:48:59 +0100 Subject: [PATCH 3/4] Changed: Use MiB for RAM --HG-- branch : develop --- code/ryzom/tools/client/client_config_qt/sys_info_widget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/tools/client/client_config_qt/sys_info_widget.cpp b/code/ryzom/tools/client/client_config_qt/sys_info_widget.cpp index fa1e746bd..2acdaa8c5 100644 --- a/code/ryzom/tools/client/client_config_qt/sys_info_widget.cpp +++ b/code/ryzom/tools/client/client_config_qt/sys_info_widget.cpp @@ -27,7 +27,7 @@ CSysInfoWidget::CSysInfoWidget( QWidget *parent ) : osLabel->setText(QString::fromUtf8(CSystem::GetInstance().sysInfo.osName.c_str())); cpuLabel->setText(QString::fromUtf8(CSystem::GetInstance().sysInfo.cpuName.c_str())); - ramLabel->setText(QString(tr("%1 MB").arg(CSystem::GetInstance().sysInfo.totalRAM))); + ramLabel->setText(QString(tr("%1 MiB").arg(CSystem::GetInstance().sysInfo.totalRAM))); gfxcardLabel->setText(QString::fromUtf8(CSystem::GetInstance().sysInfo.videoDevice.c_str())); gfxdriverLabel->setText(QString::fromUtf8(CSystem::GetInstance().sysInfo.videoDriverVersion.c_str())); From b9231adb7882d15f9d9568c18f08245849dba061 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 11 Mar 2016 09:50:22 +0100 Subject: [PATCH 4/4] Fixed: ForceDXTC is not to disable compression but force it --HG-- branch : develop --- .../client/client_config_qt/display_settings_advanced_widget.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/tools/client/client_config_qt/display_settings_advanced_widget.ui b/code/ryzom/tools/client/client_config_qt/display_settings_advanced_widget.ui index 053104e2c..6c5fd71e0 100644 --- a/code/ryzom/tools/client/client_config_qt/display_settings_advanced_widget.ui +++ b/code/ryzom/tools/client/client_config_qt/display_settings_advanced_widget.ui @@ -28,7 +28,7 @@ - Disable texture compression + Force texture compression