1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "client_config_dialog.h"
21 #include "nel/misc/cmd_args.h"
23 #include <QSplashScreen>
25 #ifdef QT_STATICPLUGIN
29 #if defined(Q_OS_WIN32)
30 Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin
)
31 #elif defined(Q_OS_MAC)
32 Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin
)
33 #elif defined(Q_OS_UNIX)
34 Q_IMPORT_PLUGIN(QXcbIntegrationPlugin
)
35 Q_IMPORT_PLUGIN(QXcbGlxIntegrationPlugin
)
40 NLMISC::CCmdArgs Args
;
42 int main(sint32 argc
, char **argv
)
44 QApplication
app(argc
, argv
);
46 NLMISC::CApplicationContext applicationContext
;
48 // parse command-line arguments
49 Args
.setDescription("Ryzom Configuration");
50 Args
.addArg("p", "profile", "id", "Use this profile to determine what directory to use by default");
52 if (!Args
.parse(argc
, argv
)) return 1;
54 QApplication::setWindowIcon(QIcon(":/resources/welcome_icon.png"));
55 QPixmap
pixmap(":/resources/splash_screen.png" );
56 QSplashScreen
splash( pixmap
);
59 QLocale locale
= QLocale::system();
61 // load application translations
62 QTranslator localTranslator
;
63 if (localTranslator
.load(locale
, "ryzom_configuration", "_", ":/translations"))
65 QApplication::installTranslator(&localTranslator
);
68 // load Qt default translations
69 QTranslator qtTranslator
;
70 if (qtTranslator
.load(locale
, "qtbase", "_", ":/translations"))
72 QApplication::installTranslator(&qtTranslator
);
77 // - Linux and Windows: all files in Steam folder
78 // - OS X: client.cfg in ~/Library/Application Support/Ryzom, client_default.cfg in Steam folder
80 // - Linux: client.cfg in ~/.ryzom/<config>/ client_default.cfg in ~/.ryzom/ryzom_live/
81 // - Windows: client.cfg in Roaming/Ryzom/<config>/ client_default.cfg in Local/Ryzom/ryzom_live/
82 // - OS X: client.cfg in ~/Library/Application Support/Ryzom/<config>/ client_default.cfg in ~/Library/Application Support/Ryzom/ryzom_live/
85 std::string ryzomDir
= NLMISC::CPath::standardizePath(NLMISC::CPath::getApplicationDirectory("Ryzom"));
86 std::string currentDir
= Args
.getStartupPath();
87 std::string executableDir
= Args
.getProgramPath();
89 std::string configFilename
= "client.cfg";
90 std::string configPath
;
92 // search client.cfg file in config directory (Ryzom Installer)
93 if (Args
.haveArg("p"))
95 ryzomDir
= NLMISC::CPath::standardizePath(ryzomDir
+ Args
.getArg("p").front());
97 // client.cfg is always in profile directory if using -p argument
98 configPath
= ryzomDir
+ configFilename
;
103 // client.cfg is in ~/Library/Application Support/Ryzom under OS X
104 configPath
= ryzomDir
+ configFilename
;
106 // client.cfg is in current directory under other platforms
107 configPath
= currentDir
+ configFilename
;
111 // if file doesn't exist, create it
112 if (!NLMISC::CFile::fileExists(configPath
))
114 // we need the full path to client_default.cfg
115 std::string defaultConfigFilename
= "client_default.cfg";
116 std::string defaultConfigPath
;
119 // fix path inside bundle
120 defaultConfigPath
= NLMISC::CPath::makePathAbsolute("../Resources", executableDir
, true) + defaultConfigFilename
;
122 // same path as executables
123 defaultConfigPath
= executableDir
+ defaultConfigFilename
;
126 // test if default config exists in determined path
127 if (!NLMISC::CFile::fileExists(defaultConfigPath
))
129 defaultConfigPath
= currentDir
+ defaultConfigFilename
;
131 // test if default config exists in current path
132 if (!NLMISC::CFile::fileExists(defaultConfigPath
))
134 nlwarning("Unable to find %s", defaultConfigFilename
.c_str());
139 if (!CSystem::GetInstance().config
.create(configPath
, defaultConfigPath
))
141 nlwarning("Unable to create %s", configPath
.c_str());
146 if (!CSystem::GetInstance().config
.load(configPath
))
148 nlwarning("Unable to load %s", configPath
.c_str());
152 CClientConfigDialog d
;