Changed: #1307 Added extract_bot_names
--HG-- branch : gsoc2011-translationovqthg/feature/gsoc2012-fabien
parent
624cb70813
commit
32c07d0b62
@ -1,197 +0,0 @@
|
||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
// Copyright (C) 2011 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/>.
|
||||
|
||||
#include "qnel_widget.h"
|
||||
|
||||
// STL includes
|
||||
|
||||
// Qt includes
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtGui/QResizeEvent>
|
||||
|
||||
// NeL includes
|
||||
#include <nel/misc/event_server.h>
|
||||
#include <nel/misc/debug.h>
|
||||
#include <nel/3d/u_driver.h>
|
||||
#include <nel/3d/driver_user.h>
|
||||
|
||||
namespace NLQT
|
||||
{
|
||||
|
||||
QNLWidget::QNLWidget(QWidget *parent)
|
||||
: QNeLWidget(parent),
|
||||
m_driver(NULL),
|
||||
m_initialized(false),
|
||||
m_interval(25)
|
||||
{
|
||||
setMouseTracking(true);
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
init();
|
||||
#ifdef Q_OS_LINUX
|
||||
makeCurrent();
|
||||
#endif
|
||||
m_mainTimer = new QTimer(this);
|
||||
connect(m_mainTimer, SIGNAL(timeout()), this, SLOT(updateRender()));
|
||||
}
|
||||
|
||||
QNLWidget::~QNLWidget()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
void QNLWidget::init()
|
||||
{
|
||||
// create the driver
|
||||
m_driver = NL3D::UDriver::createDriver(NULL, false, NULL);
|
||||
nlassert(m_driver);
|
||||
|
||||
// initialize the nel 3d viewport
|
||||
m_driver->setDisplay((nlWindow)winId(), NL3D::UDriver::CMode(width(), height(), 32));
|
||||
|
||||
// set the cache size for the font manager(in bytes)
|
||||
m_driver->setFontManagerMaxMemory(2097152);
|
||||
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
void QNLWidget::release()
|
||||
{
|
||||
m_mainTimer->stop();
|
||||
delete m_mainTimer;
|
||||
if (m_initialized)
|
||||
{
|
||||
m_driver->release();
|
||||
delete m_driver;
|
||||
m_driver = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void QNLWidget::setInterval(int msec)
|
||||
{
|
||||
m_interval = msec;
|
||||
m_mainTimer->setInterval(msec);
|
||||
}
|
||||
|
||||
void QNLWidget::setBackgroundColor(NLMISC::CRGBA backgroundColor)
|
||||
{
|
||||
m_backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
void QNLWidget::updateRender()
|
||||
{
|
||||
if (isVisible())
|
||||
{
|
||||
if (m_initialized)
|
||||
m_driver->EventServer.pump();
|
||||
Q_EMIT updateData();
|
||||
|
||||
// Calc FPS
|
||||
static sint64 lastTime = NLMISC::CTime::getPerformanceTime ();
|
||||
sint64 newTime = NLMISC::CTime::getPerformanceTime ();
|
||||
m_fps = float(1.0 / NLMISC::CTime::ticksToSecond (newTime-lastTime));
|
||||
lastTime = newTime;
|
||||
|
||||
if (m_initialized && !m_driver->isLost())
|
||||
{
|
||||
//_driver->activate();
|
||||
m_driver->clearBuffers(m_backgroundColor);
|
||||
Q_EMIT updatePreRender();
|
||||
|
||||
Q_EMIT updatePostRender();
|
||||
// swap 3d buffers
|
||||
m_driver->swapBuffers();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QNLWidget::showEvent(QShowEvent *showEvent)
|
||||
{
|
||||
QWidget::showEvent(showEvent);
|
||||
m_driver->activate();
|
||||
m_mainTimer->start(m_interval);
|
||||
}
|
||||
|
||||
void QNLWidget::hideEvent(QHideEvent *hideEvent)
|
||||
{
|
||||
m_mainTimer->stop();
|
||||
QWidget::hideEvent(hideEvent);
|
||||
}
|
||||
|
||||
#if defined(NL_OS_WINDOWS)
|
||||
|
||||
typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
bool QNLWidget::winEvent(MSG *message, long *result)
|
||||
{
|
||||
if (m_driver && m_driver->isActive())
|
||||
{
|
||||
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser *>(m_driver)->getDriver();
|
||||
if (driver)
|
||||
{
|
||||
winProc proc = (winProc)driver->getWindowProc();
|
||||
return proc(driver, message->hwnd, message->message, message->wParam, message->lParam);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#elif defined(NL_OS_MAC)
|
||||
|
||||
typedef bool (*cocoaProc)(NL3D::IDriver *, const void *e);
|
||||
|
||||
bool QNLWidget::macEvent(EventHandlerCallRef caller, EventRef event)
|
||||
{
|
||||
if(caller)
|
||||
nlerror("You are using QtCarbon! Only QtCocoa supported, please upgrade Qt");
|
||||
|
||||
if (m_driver && m_driver->isActive())
|
||||
{
|
||||
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser *>(m_driver)->getDriver();
|
||||
if (driver)
|
||||
{
|
||||
cocoaProc proc = (cocoaProc)driver->getWindowProc();
|
||||
return proc(driver, event);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#elif defined(NL_OS_UNIX)
|
||||
|
||||
typedef bool (*x11Proc)(NL3D::IDriver *drv, XEvent *e);
|
||||
|
||||
bool QNLWidget::x11Event(XEvent *event)
|
||||
{
|
||||
if (m_driver && m_driver->isActive())
|
||||
{
|
||||
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser *>(m_driver)->getDriver();
|
||||
if (driver)
|
||||
{
|
||||
x11Proc proc = (x11Proc)driver->getWindowProc();
|
||||
return proc(driver, event);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
} /* namespace NLQT */
|
||||
|
@ -1,130 +0,0 @@
|
||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
// Copyright (C) 2011 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/>.
|
||||
|
||||
#ifndef QNEL_WIDGET_H
|
||||
#define QNEL_WIDGET_H
|
||||
|
||||
// NeL includes
|
||||
#include <nel/misc/types_nl.h>
|
||||
#include <nel/misc/rgba.h>
|
||||
#include <nel/misc/event_emitter.h>
|
||||
|
||||
// Qt includes
|
||||
#include <QtOpenGL/QGLWidget>
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
class QAction;
|
||||
|
||||
/* TODO every platform should use QWidget */
|
||||
#if defined(NL_OS_WINDOWS)
|
||||
typedef QWidget QNeLWidget;
|
||||
#elif defined(NL_OS_MAC)
|
||||
typedef QWidget QNeLWidget;
|
||||
#elif defined(NL_OS_UNIX)
|
||||
typedef QGLWidget QNeLWidget;
|
||||
#endif // NL_OS_UNIX
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class UDriver;
|
||||
class UScene;
|
||||
}
|
||||
|
||||
namespace NLQT
|
||||
{
|
||||
|
||||
/**
|
||||
@class QNLWidget
|
||||
@brief Responsible for interaction between Qt and NeL.
|
||||
@details Automatically begins to update the render if the widget is visible
|
||||
or suspends the updating of render if the widget is hidden.
|
||||
*/
|
||||
class QNLWidget : public QNeLWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QNLWidget(QWidget *parent);
|
||||
virtual ~QNLWidget();
|
||||
|
||||
/// Set the update interval renderer
|
||||
void setInterval(int msec);
|
||||
|
||||
/// Set the background color.
|
||||
void setBackgroundColor(NLMISC::CRGBA backgroundColor);
|
||||
|
||||
float fps() const
|
||||
{
|
||||
return m_fps;
|
||||
}
|
||||
|
||||
inline NLMISC::CRGBA backgroundColor() const
|
||||
{
|
||||
return m_backgroundColor;
|
||||
}
|
||||
|
||||
NL3D::UDriver *driver() const
|
||||
{
|
||||
return m_driver;
|
||||
}
|
||||
|
||||
virtual QPaintEngine* paintEngine() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
Q_SIGNALS:
|
||||
void updateData();
|
||||
void updatePreRender();
|
||||
void updatePostRender();
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateRender();
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent *showEvent);
|
||||
virtual void hideEvent(QHideEvent *hideEvent);
|
||||
|
||||
#if defined(NL_OS_WINDOWS)
|
||||
virtual bool winEvent(MSG *message, long *result);
|
||||
#elif defined(NL_OS_MAC)
|
||||
virtual bool macEvent(EventHandlerCallRef caller, EventRef event);
|
||||
#elif defined(NL_OS_UNIX)
|
||||
virtual bool x11Event(XEvent *event);
|
||||
#endif
|
||||
|
||||
private:
|
||||
void init();
|
||||
void release();
|
||||
|
||||
QNLWidget(const QNLWidget &);
|
||||
QNLWidget &operator=(const QNLWidget &);
|
||||
|
||||
NL3D::UDriver *m_driver;
|
||||
NLMISC::CRGBA m_backgroundColor;
|
||||
|
||||
QTimer *m_mainTimer;
|
||||
|
||||
bool m_initialized;
|
||||
int m_interval;
|
||||
float m_fps;
|
||||
|
||||
}; /* class QNLWidget */
|
||||
|
||||
} /* namespace NLQT */
|
||||
|
||||
|
||||
#endif // QNEL_WIDGET_H
|
@ -1,56 +0,0 @@
|
||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
// Copyright (C) 2011 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/>.
|
||||
|
||||
#include "simple_viewer.h"
|
||||
|
||||
// Qt includes
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QGridLayout>
|
||||
#include <QtGui/QMessageBox>
|
||||
|
||||
// NeL includes
|
||||
|
||||
// Project includes
|
||||
|
||||
namespace Plugin
|
||||
{
|
||||
|
||||
CSimpleViewer::CSimpleViewer(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
QGridLayout *gridLayout = new QGridLayout(this);
|
||||
gridLayout->setObjectName(QString::fromUtf8("gridLayoutSimpleViewer"));
|
||||
gridLayout->setContentsMargins(0, 0, 0, 0);
|
||||
NLQT::QNLWidget *_nelWidget = new NLQT::QNLWidget(this);
|
||||
gridLayout->addWidget(_nelWidget, 0, 0, 1, 1);
|
||||
|
||||
m_undoStack = new QUndoStack(this);
|
||||
}
|
||||
|
||||
bool CCoreListener::closeMainWindow() const
|
||||
{
|
||||
int ret = QMessageBox::question(0, tr("Example close event hook"),
|
||||
tr("Do you want to close window?"),
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
|
||||
if (ret == QMessageBox::Yes)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
} /* namespace Plugin */
|
@ -0,0 +1,169 @@
|
||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
// Copyright (C) 2011 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/>.
|
||||
|
||||
#include "translation_manager_main_window.h"
|
||||
// Project system includes
|
||||
#include "../core/icore.h"
|
||||
// Qt includes
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QTextEdit>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtGui/QErrorMessage>
|
||||
#include <QtCore/QSignalMapper>
|
||||
#include <QtGui/QTableWidget>
|
||||
#include <QtGui/QListWidget>
|
||||
#include <QtGui/QDockWidget>
|
||||
#include <QtCore/QSize>
|
||||
#include <QtGui/QGridLayout>
|
||||
struct TEntryInfo
|
||||
{
|
||||
string SheetName;
|
||||
};
|
||||
|
||||
set<string> getGenericNames();
|
||||
map<string, TEntryInfo> getSimpleNames();
|
||||
int extractBotNamesAll(map<string,list<string> > config_paths, string ligo_class_file, string trans_path, string work_path);
|
||||
|
||||
namespace Plugin
|
||||
{
|
||||
|
||||
CMainWindow::CMainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
{
|
||||
_ui.setupUi(this);
|
||||
|
||||
_toolMenu = new QMenu(tr("Primitives"), _ui.toolBar);
|
||||
_ui.toolBar->addAction(_toolMenu->menuAction());
|
||||
|
||||
QAction *extractBotNames = _toolMenu->addAction(tr("Extract bot names"));
|
||||
extractBotNames->setStatusTip(tr("Extract bot names from primitives"));
|
||||
connect(extractBotNames, SIGNAL(triggered()), this, SLOT(extractBotNames()));
|
||||
|
||||
|
||||
|
||||
readSettings();
|
||||
m_undoStack = new QUndoStack(this);
|
||||
}
|
||||
|
||||
void CMainWindow::readSettings()
|
||||
{
|
||||
QSettings *settings = Core::ICore::instance()->settings();
|
||||
settings->beginGroup("translationmanager");
|
||||
|
||||
list<string> paths = convertQStringList(settings->value("paths").toStringList()); /* paths */
|
||||
config_paths["paths"] = paths;
|
||||
list<string> pathsR = convertQStringList(settings->value("pathsR").toStringList()); /* pathsR */
|
||||
config_paths["pathsR"] = pathsR;
|
||||
list<string> georges = convertQStringList(settings->value("georges").toStringList()); /* georges */
|
||||
config_paths["georges"] = georges;
|
||||
list<string> filters = convertQStringList(settings->value("filters").toStringList()); /* filters */
|
||||
config_paths["filters"] = filters;
|
||||
|
||||
languages = convertQStringList(settings->value("trlanguages").toStringList()); /* languages */
|
||||
ligo_path = settings->value("ligo").toString().toStdString();
|
||||
translation_path = settings->value("translation").toString().toStdString();
|
||||
work_path = settings->value("work").toString().toStdString();
|
||||
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
void CMainWindow::extractBotNames()
|
||||
{
|
||||
if(verifySettings() == true)
|
||||
{
|
||||
// int extract_bot_names = extractBotNamesAll(config_paths, ligo_path, translation_path, work_path);
|
||||
|
||||
QGridLayout* mainLayout = new QGridLayout();
|
||||
|
||||
|
||||
|
||||
//contentsWindow->setAllowedAreas(Qt::LeftDockWidgetArea);
|
||||
|
||||
|
||||
QListWidget *listWidget = new QListWidget(this);
|
||||
|
||||
mainLayout->addWidget(QListWidget);
|
||||
|
||||
|
||||
|
||||
QTableWidget *tableWidget = new QTableWidget(this);
|
||||
|
||||
tableWidget->setRowCount(10);
|
||||
tableWidget->setColumnCount(5);
|
||||
|
||||
mainLayout->addWidget(QTableWidget);
|
||||
setCentralWidget(tableWidget);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CMainWindow::verifySettings()
|
||||
{
|
||||
bool count_errors = false;
|
||||
|
||||
QSettings *settings = Core::ICore::instance()->settings();
|
||||
settings->beginGroup("translationmanager");
|
||||
|
||||
if(settings->value("paths").toList().count() == 0
|
||||
|| settings->value("pathsR").toList().count() == 0
|
||||
|| settings->value("georges").toList().count() == 0
|
||||
|| settings->value("filters").toList().count() == 0)
|
||||
{
|
||||
QErrorMessage error_settings;
|
||||
error_settings.showMessage("Please write all the paths on the settings dialog.");
|
||||
error_settings.exec();
|
||||
count_errors = true;
|
||||
}
|
||||
|
||||
if((settings->value("ligo").toString().isEmpty()
|
||||
|| settings->value("translation").toString().isEmpty()
|
||||
|| settings->value("work").toString().isEmpty()
|
||||
|| settings->value("trlanguages").toList().count() == 0)
|
||||
&& count_errors == false)
|
||||
{
|
||||
QErrorMessage error_settings;
|
||||
error_settings.showMessage("Please write the paths for ligo, translation and work files and the languages on the settings dialog." + settings->value("trlanguages").toString());
|
||||
error_settings.exec();
|
||||
count_errors = true;
|
||||
}
|
||||
|
||||
settings->endGroup();
|
||||
|
||||
return !count_errors;
|
||||
|
||||
}
|
||||
|
||||
list<string> CMainWindow::convertQStringList(QStringList listq)
|
||||
{
|
||||
std::list<std::string> stdlist;
|
||||
|
||||
Q_FOREACH(QString text, listq)
|
||||
{
|
||||
stdlist.push_back(text.toStdString());
|
||||
}
|
||||
|
||||
return stdlist;
|
||||
}
|
||||
|
||||
bool CCoreListener::closeMainWindow() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} /* namespace Plugin */
|
Loading…
Reference in New Issue