Changed: #1302 Added basic shell of World editor plugin.

This commit is contained in:
dnk-88 2011-07-11 00:23:28 +03:00
parent 332a2b9fc4
commit f7603d1084
10 changed files with 588 additions and 0 deletions

View file

@ -0,0 +1,48 @@
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${LIBXML2_INCLUDE_DIR}
${QT_INCLUDES})
FILE(GLOB SRC *.cpp *.h)
SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
SET(OVQT_PLUGIN_WORLD_EDITOR_HDR world_editor_plugin.h
world_editor_window.h
)
SET(OVQT_PLUGIN_WORLD_EDITOR_UIS world_editor_window.ui
)
SET(OVQT_PLUGIN_WORLD_EDITOR_RCS world_editor.qrc)
SET(QT_USE_QTGUI TRUE)
SET(QT_USE_QTOPENGL TRUE)
QT4_ADD_RESOURCES(OVQT_PLUGIN_WORLD_EDITOR_RC_SRCS ${OVQT_PLUGIN_WORLD_EDITOR_RCS})
QT4_WRAP_CPP(OVQT_PLUGIN_WORLD_EDITOR_MOC_SRC ${OVQT_PLUGIN_WORLD_EDITOR_HDR})
QT4_WRAP_UI(OVQT_PLUGIN_WORLD_EDITOR_UI_HDRS ${OVQT_PLUGIN_WORLD_EDITOR_UIS})
SOURCE_GROUP(QtResources FILES ${OVQT_PLUGIN_WORLD_EDITOR_UIS})
SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_PLUGIN_WORLD_EDITOR_UI_HDRS})
SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${OVQT_PLUGIN_WORLD_EDITOR_MOC_SRC} OVQT_PLUGIN_WORLD_EDITOR_RC_SRCS)
SOURCE_GROUP("World Editor Plugin" FILES ${SRC})
SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC})
ADD_LIBRARY(ovqt_plugin_world_editor MODULE ${SRC}
${OVQT_PLUGIN_WORLD_EDITOR_MOC_SRC}
${OVQT_EXT_SYS_SRC}
${OVQT_PLUGIN_WORLD_EDITOR_UI_HDRS}
${OVQT_PLUGIN_WORLD_EDITOR_RC_SRCS})
TARGET_LINK_LIBRARIES(ovqt_plugin_world_editor ovqt_plugin_core ovqt_plugin_landscape_editor nelmisc nel3d ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY})
NL_DEFAULT_PROPS(ovqt_plugin_world_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: World Editor")
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_world_editor)
NL_ADD_LIB_SUFFIX(ovqt_plugin_world_editor)
ADD_DEFINITIONS(-DWORLD_EDITOR_LIBRARY ${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS})
INSTALL(TARGETS ovqt_plugin_world_editor LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d)

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View file

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>icons/ic_nel_world_editor.png</file>
</qresource>
</RCC>

View file

@ -0,0 +1,39 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 WORLD_EDITOR_CONSTANTS_H
#define WORLD_EDITOR_CONSTANTS_H
namespace WorldEditor
{
namespace Constants
{
const char * const WORLD_EDITOR_PLUGIN = "WorldEditor";
//settings
const char * const WORLD_EDITOR_SECTION = "WorldEditor";
const char * const WORLD_WINDOW_STATE = "WorldWindowState";
const char * const WORLD_WINDOW_GEOMETRY = "WorldWindowGeometry";
//resources
const char * const ICON_WORLD_EDITOR = ":/icons/ic_nel_world_editor.png";
} // namespace Constants
} // namespace WorldEditor
#endif // WORLD_EDITOR_CONSTANTS_H

View file

@ -0,0 +1,30 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
// Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
//
// 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 WORLD_EDITOR_GLOBAL_H
#define WORLD_EDITOR_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(WORLD_EDITOR_LIBRARY)
# define WORLD_EDITOR_EXPORT Q_DECL_EXPORT
#else
# define WORLD_EDITOR_EXPORT Q_DECL_IMPORT
#endif
#endif // WORLD_EDITOR_GLOBAL_H

View file

@ -0,0 +1,128 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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/>.
// Project includes
#include "world_editor_plugin.h"
#include "world_editor_window.h"
#include "../core/icore.h"
#include "../core/core_constants.h"
// NeL includes
#include "nel/misc/debug.h"
// Qt includes
#include <QtCore/QObject>
namespace WorldEditor
{
WorldEditorPlugin::~WorldEditorPlugin()
{
Q_FOREACH(QObject *obj, m_autoReleaseObjects)
{
m_plugMan->removeObject(obj);
}
qDeleteAll(m_autoReleaseObjects);
m_autoReleaseObjects.clear();
}
bool WorldEditorPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
{
Q_UNUSED(errorString);
m_plugMan = pluginManager;
addAutoReleasedObject(new WorldEditorContext(this));
return true;
}
void WorldEditorPlugin::extensionsInitialized()
{
}
void WorldEditorPlugin::shutdown()
{
}
void WorldEditorPlugin::setNelContext(NLMISC::INelContext *nelContext)
{
#ifdef NL_OS_WINDOWS
// Ensure that a context doesn't exist yet.
// This only applies to platforms without PIC, e.g. Windows.
nlassert(!NLMISC::INelContext::isContextInitialised());
#endif // NL_OS_WINDOWS
m_libContext = new NLMISC::CLibraryContext(*nelContext);
}
QString WorldEditorPlugin::name() const
{
return tr("WorldEditor");
}
QString WorldEditorPlugin::version() const
{
return "0.0.1";
}
QString WorldEditorPlugin::vendor() const
{
return "GSoC2011_dnk-88";
}
QString WorldEditorPlugin::description() const
{
return "World editor ovqt plugin.";
}
QStringList WorldEditorPlugin::dependencies() const
{
QStringList list;
list.append(Core::Constants::OVQT_CORE_PLUGIN);
return list;
}
void WorldEditorPlugin::addAutoReleasedObject(QObject *obj)
{
m_plugMan->addObject(obj);
m_autoReleaseObjects.prepend(obj);
}
WorldEditorContext::WorldEditorContext(QObject *parent)
: IContext(parent),
m_worldEditorWindow(0)
{
m_worldEditorWindow = new WorldEditorWindow();
}
QUndoStack *WorldEditorContext::undoStack()
{
return m_worldEditorWindow->undoStack();
}
void WorldEditorContext::open()
{
//m_worldEditorWindow->open();
}
QWidget *WorldEditorContext::widget()
{
return m_worldEditorWindow;
}
}
Q_EXPORT_PLUGIN(WorldEditor::WorldEditorPlugin)

View file

@ -0,0 +1,108 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 WORLD_EDITOR_PLUGIN_H
#define WORLD_EDITOR_PLUGIN_H
// Project includes
#include "world_editor_constants.h"
#include "../../extension_system/iplugin.h"
#include "../core/icontext.h"
// NeL includes
#include "nel/misc/app_context.h"
// Qt includes
#include <QtCore/QObject>
#include <QtGui/QIcon>
namespace NLMISC
{
class CLibraryContext;
}
namespace ExtensionSystem
{
class IPluginSpec;
}
namespace WorldEditor
{
class WorldEditorWindow;
class WorldEditorPlugin : public QObject, public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_INTERFACES(ExtensionSystem::IPlugin)
public:
virtual ~WorldEditorPlugin();
bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString);
void extensionsInitialized();
void shutdown();
void setNelContext(NLMISC::INelContext *nelContext);
QString name() const;
QString version() const;
QString vendor() const;
QString description() const;
QStringList dependencies() const;
void addAutoReleasedObject(QObject *obj);
protected:
NLMISC::CLibraryContext *m_libContext;
private:
ExtensionSystem::IPluginManager *m_plugMan;
QList<QObject *> m_autoReleaseObjects;
};
class WorldEditorContext: public Core::IContext
{
Q_OBJECT
public:
WorldEditorContext(QObject *parent = 0);
virtual ~WorldEditorContext() {}
virtual QString id() const
{
return QLatin1String("WorldEditorContext");
}
virtual QString trName() const
{
return tr("World Editor");
}
virtual QIcon icon() const
{
return QIcon(Constants::ICON_WORLD_EDITOR);
}
virtual void open();
virtual QUndoStack *undoStack();
virtual QWidget *widget();
WorldEditorWindow *m_worldEditorWindow;
};
} // namespace WorldEditor
#endif // WORLD_EDITOR_PLUGIN_H

View file

@ -0,0 +1,119 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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/>.
// Project includes
#include "world_editor_window.h"
#include "world_editor_constants.h"
#include "../core/icore.h"
#include "../core/imenu_manager.h"
#include "../core/core_constants.h"
// Qt includes
#include <QtCore/QSettings>
namespace WorldEditor
{
QString _lastDir;
WorldEditorWindow::WorldEditorWindow(QWidget *parent)
: QMainWindow(parent),
m_undoStack(0)
{
m_ui.setupUi(this);
m_undoStack = new QUndoStack(this);
createMenus();
createToolBars();
// readSettings();
}
WorldEditorWindow::~WorldEditorWindow()
{
// writeSettings();
}
QUndoStack *WorldEditorWindow::undoStack() const
{
return m_undoStack;
}
void WorldEditorWindow::open()
{
/* QStringList fileNames = QFileDialog::getOpenFileNames(this,
tr("Open NeL Ligo land file"), _lastDir,
tr("All NeL Ligo land files (*.land)"));
setCursor(Qt::WaitCursor);
if (!fileNames.isEmpty())
{
QStringList list = fileNames;
_lastDir = QFileInfo(list.front()).absolutePath();
Q_FOREACH(QString fileName, fileNames)
{
}
}
setCursor(Qt::ArrowCursor);*/
}
void WorldEditorWindow::createMenus()
{
Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager();
}
void WorldEditorWindow::createToolBars()
{
Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager();
//QAction *action = menuManager->action(Core::Constants::NEW);
//m_ui.fileToolBar->addAction(action);
QAction *action = menuManager->action(Core::Constants::OPEN);
m_ui.fileToolBar->addAction(action);
action = menuManager->action(Core::Constants::UNDO);
if (action != 0)
m_ui.undoToolBar->addAction(action);
action = menuManager->action(Core::Constants::REDO);
if (action != 0)
m_ui.undoToolBar->addAction(action);
//action = menuManager->action(Core::Constants::SAVE);
//m_ui.fileToolBar->addAction(action);
//action = menuManager->action(Core::Constants::SAVE_AS);
//m_ui.fileToolBar->addAction(action);
}
void WorldEditorWindow::readSettings()
{
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::WORLD_EDITOR_SECTION);
restoreState(settings->value(Constants::WORLD_WINDOW_STATE).toByteArray());
restoreGeometry(settings->value(Constants::WORLD_WINDOW_GEOMETRY).toByteArray());
settings->endGroup();
}
void WorldEditorWindow::writeSettings()
{
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::WORLD_EDITOR_SECTION);
settings->setValue(Constants::WORLD_WINDOW_STATE, saveState());
settings->setValue(Constants::WORLD_WINDOW_GEOMETRY, saveGeometry());
settings->endGroup();
settings->sync();
}
} /* namespace LandscapeEditor */

View file

@ -0,0 +1,57 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 WORLD_EDITOR_WINDOW_H
#define WORLD_EDITOR_WINDOW_H
// Project includes
#include "ui_world_editor_window.h"
// Qt includes
#include <QtGui/QUndoStack>
namespace WorldEditor
{
class WorldEditorWindow: public QMainWindow
{
Q_OBJECT
public:
WorldEditorWindow(QWidget *parent = 0);
~WorldEditorWindow();
QUndoStack *undoStack() const;
Q_SIGNALS:
public Q_SLOTS:
void open();
private Q_SLOTS:
private:
void createMenus();
void createToolBars();
void readSettings();
void writeSettings();
QUndoStack *m_undoStack;
Ui::WorldEditorWindow m_ui;
}; /* class WorldEditorWindow */
} /* namespace WorldEditor */
#endif // WORLD_EDITOR_WINDOW_H

View file

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WorldEditorWindow</class>
<widget class="QMainWindow" name="WorldEditorWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<property name="windowIcon">
<iconset resource="world_editor.qrc">
<normaloff>:/icons/ic_nel_world_editor.png</normaloff>:/icons/ic_nel_world_editor.png</iconset>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QGraphicsView" name="graphicsView"/>
</item>
</layout>
</widget>
<widget class="QToolBar" name="fileToolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QToolBar" name="undoToolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
</widget>
<resources>
<include location="world_editor.qrc"/>
</resources>
<connections/>
</ui>