2011-01-15 12:45:35 +00:00
|
|
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
|
|
|
// Copyright (C) 2010 Winch Gate Property Limited
|
|
|
|
// Copyright (C) 2010 Dzmitry Kamiahin <dnk-88@tut.by>
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as
|
|
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2010-10-22 03:34:26 +00:00
|
|
|
#include "stdpch.h"
|
|
|
|
#include <nel/misc/types_nl.h>
|
|
|
|
#include <nel/misc/app_context.h>
|
|
|
|
|
|
|
|
// Qt includes
|
2010-12-12 20:56:56 +00:00
|
|
|
#include <QtCore/QDir>
|
2011-02-12 16:07:05 +00:00
|
|
|
#include <QtCore/QSettings>
|
2010-12-02 10:52:22 +00:00
|
|
|
#include <QtGui/QMessageBox>
|
2010-10-22 03:34:26 +00:00
|
|
|
#include <QtGui/QApplication>
|
|
|
|
#include <QtGui/QSplashScreen>
|
|
|
|
|
|
|
|
// NeL includes
|
|
|
|
#include <nel/misc/debug.h>
|
|
|
|
#include <nel/misc/common.h>
|
|
|
|
#include <nel/misc/file.h>
|
2010-12-12 20:56:56 +00:00
|
|
|
#include <nel/misc/dynloadlib.h>
|
2010-10-22 03:34:26 +00:00
|
|
|
#include <nel/misc/path.h>
|
|
|
|
#include <nel/misc/command.h>
|
2010-12-04 12:03:31 +00:00
|
|
|
|
2010-10-22 03:34:26 +00:00
|
|
|
// Project includes
|
|
|
|
#include "modules.h"
|
2010-12-04 12:03:31 +00:00
|
|
|
#include "extension_system/iplugin_spec.h"
|
2010-10-22 03:34:26 +00:00
|
|
|
|
|
|
|
// nel_qt log file name
|
|
|
|
#define NLQT_LOG_FILE "nel_qt.log"
|
|
|
|
|
|
|
|
// clear nel_qt log before use
|
|
|
|
#define NLQT_ERASE_LOG true
|
|
|
|
|
|
|
|
#if !defined (NLQT_USE_LOG_LOG)
|
|
|
|
# define NLQT_USE_LOG_LOG true
|
|
|
|
#endif
|
|
|
|
#if !defined (NLQT_USE_LOG)
|
|
|
|
# define NLQT_USE_LOG 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace NLMISC;
|
|
|
|
|
2010-11-26 11:54:06 +00:00
|
|
|
namespace NLQT
|
|
|
|
{
|
2010-10-22 03:34:26 +00:00
|
|
|
|
2010-11-26 11:54:06 +00:00
|
|
|
namespace
|
|
|
|
{
|
2010-10-22 03:34:26 +00:00
|
|
|
|
|
|
|
CFileDisplayer *s_FileDisplayer = NULL;
|
|
|
|
|
|
|
|
} /* anonymous namespace */
|
|
|
|
|
|
|
|
} /* namespace NLQT */
|
|
|
|
|
|
|
|
#ifndef DATA_DIR
|
|
|
|
# define DATA_DIR "."
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef NL_OS_WINDOWS
|
|
|
|
# ifdef _UNICODE
|
|
|
|
# define tstring wstring
|
|
|
|
# else
|
|
|
|
# define tstring string
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
sint main(int argc, char **argv)
|
|
|
|
{
|
2010-11-26 11:54:06 +00:00
|
|
|
// go nel!
|
2010-12-07 12:40:45 +00:00
|
|
|
new NLMISC::CApplicationContext;
|
2010-10-22 03:34:26 +00:00
|
|
|
{
|
|
|
|
// use log.log if NEL_LOG_IN_FILE and NLQT_USE_LOG_LOG defined as 1
|
|
|
|
createDebug(NULL, NLQT_USE_LOG_LOG, false);
|
|
|
|
#if NLQT_USE_LOG
|
2010-12-04 12:03:31 +00:00
|
|
|
// create NLQT_LOG_FILE
|
2010-10-22 03:34:26 +00:00
|
|
|
// filedisplayer only deletes the 001 etc
|
|
|
|
if (NLQT_ERASE_LOG && CFile::isExists(NLQT_LOG_FILE))
|
|
|
|
CFile::deleteFile(NLQT_LOG_FILE);
|
|
|
|
// initialize the log file
|
|
|
|
NLQT::s_FileDisplayer = new CFileDisplayer();
|
|
|
|
NLQT::s_FileDisplayer->setParam(NLQT_LOG_FILE, NLQT_ERASE_LOG);
|
|
|
|
DebugLog->addDisplayer(NLQT::s_FileDisplayer);
|
|
|
|
InfoLog->addDisplayer(NLQT::s_FileDisplayer);
|
|
|
|
WarningLog->addDisplayer(NLQT::s_FileDisplayer);
|
|
|
|
AssertLog->addDisplayer(NLQT::s_FileDisplayer);
|
|
|
|
ErrorLog->addDisplayer(NLQT::s_FileDisplayer);
|
2010-11-26 11:54:06 +00:00
|
|
|
#endif
|
2010-10-22 03:34:26 +00:00
|
|
|
|
2010-12-04 12:03:31 +00:00
|
|
|
nlinfo("Welcome to NeL Object Viewer Qt!");
|
2010-11-26 11:54:06 +00:00
|
|
|
|
2010-10-22 03:34:26 +00:00
|
|
|
NLMISC::CPath::remapExtension("tga", "png", true);
|
|
|
|
}
|
|
|
|
|
|
|
|
QApplication app(argc, argv);
|
|
|
|
QSplashScreen *splash = new QSplashScreen();
|
|
|
|
splash->setPixmap(QPixmap(":/images/nel_ide_load.png"));
|
|
|
|
splash->show();
|
2010-11-26 11:54:06 +00:00
|
|
|
|
2010-12-12 20:56:56 +00:00
|
|
|
#if defined(NL_OS_MAC)
|
|
|
|
QDir::setCurrent(qApp->applicationDirPath() + QString("/../Resources"));
|
2011-02-12 16:07:05 +00:00
|
|
|
CLibrary::addLibPath((qApp->applicationDirPath() + QString("/../PlugIns/nel")).toStdString());
|
2010-12-12 20:56:56 +00:00
|
|
|
#endif
|
|
|
|
|
2010-10-22 03:34:26 +00:00
|
|
|
Modules::init();
|
2011-02-12 16:07:05 +00:00
|
|
|
QSettings *settings = new QSettings(QSettings::IniFormat, QSettings::UserScope,
|
|
|
|
QLatin1String("Ryzom Core"), QLatin1String("ObjectViewerQt"));
|
|
|
|
|
|
|
|
Modules::plugMan().setSettings(settings);
|
2010-10-22 03:34:26 +00:00
|
|
|
|
|
|
|
// load and set remap extensions from config
|
|
|
|
Modules::config().configRemapExtensions();
|
|
|
|
// load and set search paths from config
|
|
|
|
Modules::config().configSearchPaths();
|
|
|
|
|
|
|
|
Modules::mainWin().showMaximized();
|
2010-12-01 15:48:43 +00:00
|
|
|
Modules::plugMan().addObject(&Modules::mainWin());
|
2010-11-29 15:18:07 +00:00
|
|
|
|
2010-12-12 20:56:56 +00:00
|
|
|
#if !defined(NL_OS_MAC)
|
2010-11-29 15:18:07 +00:00
|
|
|
Modules::plugMan().setPluginPaths(QStringList() << QString("./plugins"));
|
2010-12-12 20:56:56 +00:00
|
|
|
#else
|
2011-02-12 16:07:05 +00:00
|
|
|
Modules::plugMan().setPluginPaths(QStringList() <<
|
|
|
|
qApp->applicationDirPath() + QString("/../PlugIns/ovqt"));
|
2010-12-12 20:56:56 +00:00
|
|
|
#endif
|
|
|
|
|
2010-11-29 15:18:07 +00:00
|
|
|
Modules::plugMan().loadPlugins();
|
2011-02-12 16:07:05 +00:00
|
|
|
|
2010-12-02 10:52:22 +00:00
|
|
|
QStringList errors;
|
2011-01-15 12:45:35 +00:00
|
|
|
Q_FOREACH (ExtensionSystem::IPluginSpec *spec, Modules::plugMan().plugins())
|
2011-02-12 16:07:05 +00:00
|
|
|
if (spec->hasError())
|
|
|
|
errors.append(spec->fileName() + " : " + spec->errorString());
|
|
|
|
|
2010-12-02 10:52:22 +00:00
|
|
|
if (!errors.isEmpty())
|
2011-02-12 16:07:05 +00:00
|
|
|
QMessageBox::warning(0, QCoreApplication::translate("Application", "Object Viewer Qt - Plugin loader messages"),
|
|
|
|
errors.join(QString::fromLatin1("\n\n")));
|
2010-12-02 10:52:22 +00:00
|
|
|
|
2010-10-22 03:34:26 +00:00
|
|
|
splash->finish(&Modules::mainWin());
|
|
|
|
int result = app.exec();
|
|
|
|
Modules::release();
|
|
|
|
return result;
|
|
|
|
}
|