From 3ccfad6d6b259c39ca9d8edc7dbc75653a913f40 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Thu, 2 Jun 2011 16:57:10 +0300 Subject: [PATCH] Added: #1301 Added pixmap database --- .../plugins/landscape_editor/CMakeLists.txt | 6 +- .../plugins/landscape_editor/builder_zone.cpp | 104 +++++++ .../plugins/landscape_editor/builder_zone.h | 75 +++++ .../landscape_editor/builder_zone_region.cpp | 28 ++ .../landscape_editor/builder_zone_region.h | 33 +++ .../landscape_editor_plugin.h | 2 +- .../landscape_editor_window.cpp | 7 +- .../landscape_editor_window.h | 2 + .../landscape_editor_window.ui | 17 ++ .../landscape_editor/landscape_scene.cpp | 38 +++ .../landscape_editor/landscape_scene.h | 42 +++ .../landscape_editor/zone_list_model.cpp | 165 +++++++++++ .../landscape_editor/zone_list_model.h | 82 ++++++ .../landscape_editor/zone_list_widget.cpp | 44 +++ .../landscape_editor/zone_list_widget.h | 54 ++++ .../landscape_editor/zone_list_widget.ui | 266 ++++++++++++++++++ 16 files changed, 962 insertions(+), 3 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.ui diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt index 3b6a61c5e..2f7487fe7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt @@ -11,9 +11,13 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin. SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_HDR landscape_editor_plugin.h landscape_editor_window.h + landscape_scene.h + zone_list_model.h + zone_list_widget.h ) SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_UIS landscape_editor_window.ui + zone_list_widget.ui ) SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_RCS landscape_editor.qrc) @@ -37,7 +41,7 @@ ADD_LIBRARY(ovqt_plugin_landscape_editor MODULE ${SRC} ${OVQT_PLUGIN_LANDSCAPE_EDITOR_UI_HDRS} ${OVQT_PLUGIN_LANDSCAPE_EDITOR_RC_SRCS}) -TARGET_LINK_LIBRARIES(ovqt_plugin_landscape_editor ovqt_plugin_core nelmisc nel3d ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY}) +TARGET_LINK_LIBRARIES(ovqt_plugin_landscape_editor ovqt_plugin_core nelmisc nel3d nelgeorges nelligo ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY}) NL_DEFAULT_PROPS(ovqt_plugin_landscape_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: Landscape Editor") NL_ADD_RUNTIME_FLAGS(ovqt_plugin_landscape_editor) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp new file mode 100644 index 000000000..d79770cf3 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp @@ -0,0 +1,104 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 . + +// Project includes +#include "builder_zone.h" +#include "zone_list_model.h" + +// NeL includes +#include + +// Qt includes +#include +#include + +namespace LandscapeEditor +{ + +ZoneBuilder::ZoneBuilder() + : m_zoneListModel(0) +{ + m_zoneListModel = new ZoneListModel(); + m_lastPathName = ""; +} + +ZoneBuilder::~ZoneBuilder() +{ + delete m_zoneListModel; +} + +bool ZoneBuilder::init(const QString &pathName, bool makeAZone) +{ + bool bRet = true; + if (pathName != m_lastPathName) + { + m_lastPathName = pathName; + QString zoneBankPath = pathName; + zoneBankPath += "/zoneligos/"; + + // Init the ZoneBank + m_zoneBank.reset (); + if (!initZoneBank (zoneBankPath)) + { + m_zoneBank.reset (); + return false; + } + // Construct the DataBase from the ZoneBank + QString zoneBitmapPath = pathName; + zoneBitmapPath += "/zonebitmaps/"; + m_zoneListModel->resetModel(); + if (!m_zoneListModel->rebuildModel(zoneBitmapPath, m_zoneBank)) + { + m_zoneBank.reset(); + return false; + } + } + + if ((makeAZone) && (bRet)) + newZone(); + return bRet; +} + +bool ZoneBuilder::initZoneBank (const QString &pathName) +{ + QDir *dir = new QDir(pathName); + QStringList filters; + filters << "*.ligozone"; + + // Find all ligozone files in dir + QStringList listFiles = dir->entryList(filters, QDir::Files); + + std::string error; + Q_FOREACH(QString file, listFiles) + { + //nlinfo(file.toStdString().c_str()); + if (!m_zoneBank.addElement((pathName + file).toStdString(), error)) + QMessageBox::critical(0, QObject::tr("Landscape editor"), QString(error.c_str()), QMessageBox::Ok); + } + return true; +} + +ZoneListModel *ZoneBuilder::zoneModel() const +{ + return m_zoneListModel; +} + +void ZoneBuilder::newZone (bool bDisplay) +{ +} + +} /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h new file mode 100644 index 000000000..b578a2bb2 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h @@ -0,0 +1,75 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 . + +#ifndef BUILDER_ZONE_H +#define BUILDER_ZONE_H + +// Project includes + +// NeL includes +#include + +// STL includes +#include +#include + +// Qt includes +#include + +namespace LandscapeEditor +{ +class ZoneListModel; + +/** +@class ZoneBuilder +@brief ZoneBuilder contains all the shared data between the tools and the engine +@details ZoneBank contains the macro zones that is composed of several zones plus a mask +ZoneListModel contains the graphics for the zones +*/ +class ZoneBuilder +{ +public: + ZoneBuilder(); + ~ZoneBuilder(); + + // Init zoneBank and init zone pixmap database + bool init(const QString &pathName, bool bMakeAZone); + + void newZone(bool bDisplay=true); + + // Accessors + NLLIGO::CZoneBank &getZoneBank() + { + return m_zoneBank; + } + ZoneListModel *zoneModel() const; +private: + + // Scan ./zoneligos dir and add all *.ligozone files to zoneBank + bool initZoneBank (const QString &path); + + sint32 m_minX, m_maxX, m_minY, m_maxY; + QString m_lastPathName; + + ZoneListModel *m_zoneListModel; + NLLIGO::CZoneBank m_zoneBank; + std::vector m_currentSelection; +}; + +} /* namespace LandscapeEditor */ + +#endif // BUILDER_ZONE_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp new file mode 100644 index 000000000..4dbd3e9e1 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp @@ -0,0 +1,28 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 . + +// Project includes +#include "builder_zone_region.h" + +// NeL includes +#include + +// Qt includes + +namespace LandscapeEditor +{ +} /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h new file mode 100644 index 000000000..158c72715 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h @@ -0,0 +1,33 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 . + +#ifndef BUILDER_ZONE_REGION_H +#define BUILDER_ZONE_REGION_H + +// Project includes + +// NeL includes +#include + +// Qt includes + +namespace LandscapeEditor +{ + +} /* namespace LandscapeEditor */ + +#endif // BUILDER_ZONE_REGION_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h index 67a3172ee..8f9f811cf 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h @@ -91,7 +91,7 @@ public: } virtual QIcon icon() const { - return QIcon(); + return QIcon(Constants::ICON_LANDSCAPE_ITEM); } virtual void open(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index 4b075adfc..c46278f38 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -18,6 +18,7 @@ // Project includes #include "landscape_editor_window.h" #include "landscape_editor_constants.h" +#include "zone_list_model.h" #include "../core/icore.h" #include "../core/imenu_manager.h" @@ -40,7 +41,11 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) m_ui.setupUi(this); m_undoStack = new QUndoStack(this); - + /* + m_zoneBuilder = new ZoneBuilder(); + m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", false); + m_ui.zoneListWidget->setModel(m_zoneBuilder->zoneModel()); + */ createMenus(); readSettings(); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h index cc17e6cbc..61e0c7eb1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h @@ -20,6 +20,7 @@ // Project includes #include "ui_landscape_editor_window.h" +#include "builder_zone.h" // Qt includes #include @@ -47,6 +48,7 @@ private: void readSettings(); void writeSettings(); + ZoneBuilder *m_zoneBuilder; QUndoStack *m_undoStack; Ui::LandscapeEditorWindow m_ui; }; /* class LandscapeEditorWindow */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui index 5d9606ddf..ce6e905a3 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui @@ -35,7 +35,24 @@ false + + + Zones + + + 2 + + + + + + LandscapeEditor::ZoneListWidget + QWidget +
zone_list_widget.h
+ 1 +
+
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp new file mode 100644 index 000000000..f491dfa2b --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp @@ -0,0 +1,38 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 . + +// Project includes +#include "landscape_scene.h" + +// NeL includes +#include + +// Qt includes + +namespace LandscapeEditor +{ + +LandscapeScene::LandscapeScene(QObject *parent) + : QGraphicsScene(parent) +{ +} + +LandscapeScene::~LandscapeScene() +{ +} + +} /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h new file mode 100644 index 000000000..d4fb91c78 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h @@ -0,0 +1,42 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 . + +#ifndef LANDSCAPE_SCENE_H +#define LANDSCAPE_SCENE_H + +// Project includes + +// NeL includes + +// Qt includes +#include + +namespace LandscapeEditor +{ + +class LandscapeScene : public QGraphicsScene +{ + Q_OBJECT + +public: + LandscapeScene(QObject *parent = 0); + virtual ~LandscapeScene(); +}; + +} /* namespace LandscapeEditor */ + +#endif // LANDSCAPE_SCENE_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.cpp new file mode 100644 index 000000000..32dded570 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.cpp @@ -0,0 +1,165 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 . + +// Project includes +#include "zone_list_model.h" + +// NeL includes +#include + +// STL includes +#include +#include + +// Qt includes +#include +#include +#include + +namespace LandscapeEditor +{ + +ZoneListModel::ZoneListModel(int pixmapSize, QObject *parent) + : QAbstractListModel(parent), + m_pixmapSize(pixmapSize) +{ + +} +ZoneListModel::~ZoneListModel() +{ + resetModel(); +} + +int ZoneListModel::rowCount(const QModelIndex & /* parent */) const +{ + return m_pixmapMap.count(); +} + +int ZoneListModel::columnCount(const QModelIndex & /* parent */) const +{ + return 1; +} + +QVariant ZoneListModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + if (role == Qt::TextAlignmentRole) + { + return int(Qt::AlignLeft | Qt::AlignVCenter); + } + else if (role == Qt::DisplayRole) + { + return m_pixmapNameList.at(index.row()); + } + else if (role == Qt::DecorationRole) + { + QPixmap *pixmap = getSmallPixmap(m_pixmapNameList.at(index.row())); + return qVariantFromValue(*pixmap); + } + return QVariant(); +} + +QVariant ZoneListModel::headerData(int section, + Qt::Orientation /* orientation */, + int role) const +{ + if (role != Qt::DisplayRole) + return QVariant(); + return QVariant(); +} + +void ZoneListModel::setSmallPixmapSize(int pixmapSize) +{ + m_pixmapSize = pixmapSize; +} + +void ZoneListModel::resetModel() +{ + beginResetModel(); + Q_FOREACH(QString name, m_pixmapNameList) + { + QPixmap *pixmap = m_pixmapMap.value(name); + delete pixmap; + QPixmap *smallPixmap = m_smallPixmapMap.value(name); + delete smallPixmap; + } + m_pixmapMap.clear(); + m_pixmapNameList.clear(); + m_smallPixmapMap.clear(); + endResetModel(); +} + +bool ZoneListModel::rebuildModel(const QString &zonePath, NLLIGO::CZoneBank &zoneBank) +{ + beginResetModel(); + m_zonePath = zonePath; + + QProgressDialog *progressDialog = new QProgressDialog(); + + std::vector zoneNames; + zoneBank.getCategoryValues ("zone", zoneNames); + progressDialog->setRange(0, zoneNames.size()); + for (uint i = 0; i < zoneNames.size(); ++i) + { + QApplication::processEvents(); + progressDialog->setValue(i); + + NLLIGO::CZoneBankElement *zoneBankItem = zoneBank.getElementByZoneName (zoneNames[i]); + + // Read the texture file + QString zonePixmapName(zoneNames[i].c_str()); + uint8 sizeX = zoneBankItem->getSizeX(); + uint8 sizeY = zoneBankItem->getSizeY(); + const std::vector &rMask = zoneBankItem->getMask(); + + QPixmap *pixmap = new QPixmap(zonePath + zonePixmapName + ".png"); + QPixmap *smallPixmap = new QPixmap(pixmap->scaled(m_pixmapSize * sizeX, m_pixmapSize * sizeY)); + + m_pixmapMap.insert(zonePixmapName, pixmap); + m_smallPixmapMap.insert(zonePixmapName, smallPixmap); + + } + m_pixmapNameList = m_pixmapMap.keys(); + endResetModel(); + delete progressDialog; + return false; +} + +QPixmap *ZoneListModel::getPixmap(const QString &zoneName) const +{ + QPixmap *result = 0; + if (!m_pixmapMap.contains(zoneName)) + nlwarning("QPixmap %s not found", zoneName.toStdString().c_str()); + else + result = m_pixmapMap.value(zoneName); + return result; +} + +QPixmap *ZoneListModel::getSmallPixmap(const QString &zoneName) const +{ + QPixmap *result = 0; + if (!m_pixmapMap.contains(zoneName)) + nlwarning("QPixmap %s not found", zoneName.toStdString().c_str()); + else + result = m_smallPixmapMap.value(zoneName); + return result; +} + + +} /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.h new file mode 100644 index 000000000..1bfb0f93f --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.h @@ -0,0 +1,82 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 . + +#ifndef ZONE_LIST_MODEL_H +#define ZONE_LIST_MODEL_H + +// Project includes + +// NeL includes +#include + +// Qt includes +#include +#include +#include +#include + +namespace LandscapeEditor +{ + +/** +@class ZoneListModel +@brief ZoneListModel contains the image database for QGraphicsScene and +small images for QListView +@details +*/ +class ZoneListModel : public QAbstractListModel +{ + Q_OBJECT +public: + ZoneListModel(int pixmapSize = 64, QObject *parent = 0); + ~ZoneListModel(); + + int rowCount(const QModelIndex &parent) const; + int columnCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, + int role) const; + + /// Set size for small pixmaps + /// Value should be set before calling rebuildModel + void setSmallPixmapSize(int pixmapSize); + + /// Unload all images and reset model + void resetModel(); + + /// Load all images(png) from zonePath, list images gets from zoneBank + bool rebuildModel(const QString &zonePath, NLLIGO::CZoneBank &zoneBank); + + /// Get original pixmap + /// @return QPixmap* if the image is in the database ; otherwise returns 0. + QPixmap *getPixmap(const QString &zoneName) const; + + /// Get scaled pixmap (pixmapSize * zoneSize.sizeX, pixmapSize * zoneSize.sizeY) + /// @return QPixmap* if the image is in the database ; otherwise returns 0. + QPixmap *getSmallPixmap(const QString &zoneName) const; +private: + + QString m_zonePath; + int m_pixmapSize; + QMap m_pixmapMap; + QMap m_smallPixmapMap; + QList m_pixmapNameList; +}; + +} /* namespace LandscapeEditor */ + +#endif // ZONE_LIST_MODEL_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.cpp new file mode 100644 index 000000000..423c2c50f --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.cpp @@ -0,0 +1,44 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 . + +// Project includes +#include "zone_list_widget.h" + +// NeL includes +#include + +// Qt includes + +namespace LandscapeEditor +{ + +ZoneListWidget::ZoneListWidget(QWidget *parent) + : QWidget(parent) +{ + m_ui.setupUi(this); +} + +ZoneListWidget::~ZoneListWidget() +{ +} + +void ZoneListWidget::setModel(QAbstractItemModel *model) +{ + m_ui.listView->setModel(model); +} + +} /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.h new file mode 100644 index 000000000..5b90f81d6 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.h @@ -0,0 +1,54 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 . + +#ifndef ZONE_LIST_WIDGET_H +#define ZONE_LIST_WIDGET_H + +// Project includes +#include "ui_zone_list_widget.h" + +// NeL includes + +// Qt includes + +namespace LandscapeEditor +{ +/** +@class ZoneListWidget +@brief ZoneListWidget +@details +*/ +class ZoneListWidget: public QWidget +{ + Q_OBJECT + +public: + ZoneListWidget(QWidget *parent = 0); + ~ZoneListWidget(); + + void setModel(QAbstractItemModel *model); + +Q_SIGNALS: +public Q_SLOTS: +private Q_SLOTS: +private: + Ui::ZoneListWidget m_ui; +}; /* ZoneListWidget */ + +} /* namespace LandscapeEditor */ + +#endif // ZONE_LIST_WIDGET_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.ui new file mode 100644 index 000000000..725e6cf83 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.ui @@ -0,0 +1,266 @@ + + + ZoneListWidget + + + + 0 + 0 + 359 + 579 + + + + Form + + + + 3 + + + 3 + + + + + Filter + + + + 6 + + + 3 + + + + + + <Unused> + + + + + + + + + + + + Random + + + + + Fyll cycle + + + + + + + + true + + + + <Unused> + + + + + + + + true + + + + + + + true + + + + And + + + + + Or + + + + + + + + false + + + + <Unused> + + + + + + + + false + + + + + + + false + + + + And + + + + + Or + + + + + + + + false + + + + <Unused> + + + + + + + + false + + + + + + + false + + + + And + + + + + Or + + + + + + + + + + + Placement + + + + 6 + + + 3 + + + + + + + + + + + 90° + + + + + 180° + + + + + 170° + + + + + Random + + + + + Full cycle + + + + + + + + + NoFlip + + + + + Flip + + + + + Random + + + + + Fyll cycle + + + + + + + + Force + + + + + + + Not propogate + + + + + + + + + + + + + +