mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-26 19:00:53 +00:00
Changed: #1301 Added project settings dialog.
This commit is contained in:
parent
e65bbdf0ac
commit
f4ec976fec
13 changed files with 429 additions and 99 deletions
|
@ -15,10 +15,12 @@ SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_HDR landscape_editor_plugin.h
|
||||||
list_zones_model.h
|
list_zones_model.h
|
||||||
list_zones_widget.h
|
list_zones_widget.h
|
||||||
landscape_actions.h
|
landscape_actions.h
|
||||||
|
project_settings_dialog.h
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_UIS landscape_editor_window.ui
|
SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_UIS landscape_editor_window.ui
|
||||||
list_zones_widget.ui
|
list_zones_widget.ui
|
||||||
|
project_settings_dialog.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_RCS landscape_editor.qrc)
|
SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_RCS landscape_editor.qrc)
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "builder_zone.h"
|
#include "builder_zone.h"
|
||||||
#include "list_zones_model.h"
|
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
|
@ -25,20 +24,97 @@
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
#include <QtGui/QMessageBox>
|
#include <QtGui/QMessageBox>
|
||||||
|
#include <QtGui/QApplication>
|
||||||
|
#include <QtGui/QProgressDialog>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
const int PixmapScale = 256;
|
||||||
|
|
||||||
|
PixmapDatabase::PixmapDatabase()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PixmapDatabase::~PixmapDatabase()
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PixmapDatabase::loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zoneBank)
|
||||||
|
{
|
||||||
|
QProgressDialog *progressDialog = new QProgressDialog();
|
||||||
|
progressDialog->show();
|
||||||
|
|
||||||
|
std::vector<std::string> listNames;
|
||||||
|
zoneBank.getCategoryValues ("zone", listNames);
|
||||||
|
progressDialog->setRange(0, listNames.size());
|
||||||
|
for (uint i = 0; i < listNames.size(); ++i)
|
||||||
|
{
|
||||||
|
QApplication::processEvents();
|
||||||
|
progressDialog->setValue(i);
|
||||||
|
|
||||||
|
NLLIGO::CZoneBankElement *zoneBankItem = zoneBank.getElementByZoneName (listNames[i]);
|
||||||
|
|
||||||
|
// Read the texture file
|
||||||
|
QString zonePixmapName(listNames[i].c_str());
|
||||||
|
uint8 sizeX = zoneBankItem->getSizeX();
|
||||||
|
uint8 sizeY = zoneBankItem->getSizeY();
|
||||||
|
|
||||||
|
QPixmap *pixmap = new QPixmap(zonePath + zonePixmapName + ".png");
|
||||||
|
if (pixmap->isNull())
|
||||||
|
{
|
||||||
|
// Generate filled pixmap
|
||||||
|
}
|
||||||
|
// All pixmaps must be have same size
|
||||||
|
if (pixmap->width() != sizeX * PixmapScale)
|
||||||
|
{
|
||||||
|
QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(sizeX * PixmapScale, sizeY * PixmapScale));
|
||||||
|
delete pixmap;
|
||||||
|
m_pixmapMap.insert(zonePixmapName, scaledPixmap);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_pixmapMap.insert(zonePixmapName, pixmap);
|
||||||
|
}
|
||||||
|
delete progressDialog;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PixmapDatabase::reset()
|
||||||
|
{
|
||||||
|
QStringList listNames(m_pixmapMap.keys());
|
||||||
|
Q_FOREACH(QString name, listNames)
|
||||||
|
{
|
||||||
|
QPixmap *pixmap = m_pixmapMap.value(name);
|
||||||
|
delete pixmap;
|
||||||
|
}
|
||||||
|
m_pixmapMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList PixmapDatabase::listPixmaps() const
|
||||||
|
{
|
||||||
|
return m_pixmapMap.keys();
|
||||||
|
}
|
||||||
|
|
||||||
|
QPixmap *PixmapDatabase::pixmap(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;
|
||||||
|
}
|
||||||
|
|
||||||
ZoneBuilder::ZoneBuilder()
|
ZoneBuilder::ZoneBuilder()
|
||||||
: m_zoneListModel(0)
|
: m_pixmapDatabase(0)
|
||||||
{
|
{
|
||||||
m_zoneListModel = new ListZonesModel();
|
m_pixmapDatabase = new PixmapDatabase();
|
||||||
m_lastPathName = "";
|
m_lastPathName = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
ZoneBuilder::~ZoneBuilder()
|
ZoneBuilder::~ZoneBuilder()
|
||||||
{
|
{
|
||||||
delete m_zoneListModel;
|
delete m_pixmapDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneBuilder::init(const QString &pathName, bool makeAZone)
|
bool ZoneBuilder::init(const QString &pathName, bool makeAZone)
|
||||||
|
@ -60,8 +136,8 @@ bool ZoneBuilder::init(const QString &pathName, bool makeAZone)
|
||||||
// Construct the DataBase from the ZoneBank
|
// Construct the DataBase from the ZoneBank
|
||||||
QString zoneBitmapPath = pathName;
|
QString zoneBitmapPath = pathName;
|
||||||
zoneBitmapPath += "/zonebitmaps/";
|
zoneBitmapPath += "/zonebitmaps/";
|
||||||
m_zoneListModel->resetModel();
|
m_pixmapDatabase->reset();
|
||||||
if (!m_zoneListModel->rebuildModel(zoneBitmapPath, m_zoneBank))
|
if (!m_pixmapDatabase->loadPixmaps(zoneBitmapPath, m_zoneBank))
|
||||||
{
|
{
|
||||||
m_zoneBank.reset();
|
m_zoneBank.reset();
|
||||||
return false;
|
return false;
|
||||||
|
@ -91,9 +167,14 @@ bool ZoneBuilder::initZoneBank (const QString &pathName)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ListZonesModel *ZoneBuilder::zoneModel() const
|
PixmapDatabase *ZoneBuilder::pixmapDatabase() const
|
||||||
{
|
{
|
||||||
return m_zoneListModel;
|
return m_pixmapDatabase;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ZoneBuilder::dataPath() const
|
||||||
|
{
|
||||||
|
return m_lastPathName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneBuilder::newZone (bool bDisplay)
|
void ZoneBuilder::newZone (bool bDisplay)
|
||||||
|
|
|
@ -29,16 +29,47 @@
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QMap>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
#include <QtGui/QPixmap>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
class ListZonesModel;
|
|
||||||
|
/**
|
||||||
|
@class PixmapDatabase
|
||||||
|
@brief PixmapDatabase contains the image database
|
||||||
|
@details
|
||||||
|
*/
|
||||||
|
class PixmapDatabase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PixmapDatabase();
|
||||||
|
~PixmapDatabase();
|
||||||
|
|
||||||
|
/// Load all images(png) from zonePath, list images gets from zoneBank
|
||||||
|
bool loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zoneBank);
|
||||||
|
|
||||||
|
/// Unload all images
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
/// Get list names all loaded pixmaps
|
||||||
|
QStringList listPixmaps() const;
|
||||||
|
|
||||||
|
/// Get original pixmap
|
||||||
|
/// @return QPixmap* if the image is in the database ; otherwise returns 0.
|
||||||
|
QPixmap *pixmap(const QString &zoneName) const;
|
||||||
|
private:
|
||||||
|
|
||||||
|
QMap<QString, QPixmap*> m_pixmapMap;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class ZoneBuilder
|
@class ZoneBuilder
|
||||||
@brief ZoneBuilder contains all the shared data between the tools and the engine
|
@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
|
@details ZoneBank contains the macro zones that is composed of several zones plus a mask
|
||||||
ZoneListModel contains the graphics for the zones
|
PixmapDatabase contains the graphics for the zones
|
||||||
*/
|
*/
|
||||||
class ZoneBuilder
|
class ZoneBuilder
|
||||||
{
|
{
|
||||||
|
@ -56,7 +87,11 @@ public:
|
||||||
{
|
{
|
||||||
return m_zoneBank;
|
return m_zoneBank;
|
||||||
}
|
}
|
||||||
ListZonesModel *zoneModel() const;
|
|
||||||
|
PixmapDatabase *pixmapDatabase() const;
|
||||||
|
|
||||||
|
QString dataPath() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Scan ./zoneligos dir and add all *.ligozone files to zoneBank
|
// Scan ./zoneligos dir and add all *.ligozone files to zoneBank
|
||||||
|
@ -65,7 +100,7 @@ private:
|
||||||
sint32 m_minX, m_maxX, m_minY, m_maxY;
|
sint32 m_minX, m_maxX, m_minY, m_maxY;
|
||||||
QString m_lastPathName;
|
QString m_lastPathName;
|
||||||
|
|
||||||
ListZonesModel *m_zoneListModel;
|
PixmapDatabase *m_pixmapDatabase;
|
||||||
NLLIGO::CZoneBank m_zoneBank;
|
NLLIGO::CZoneBank m_zoneBank;
|
||||||
std::vector<NLLIGO::CZoneBankElement*> m_currentSelection;
|
std::vector<NLLIGO::CZoneBankElement*> m_currentSelection;
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "landscape_editor_window.h"
|
#include "landscape_editor_window.h"
|
||||||
#include "landscape_editor_constants.h"
|
#include "landscape_editor_constants.h"
|
||||||
#include "list_zones_model.h"
|
#include "project_settings_dialog.h"
|
||||||
|
|
||||||
#include "../core/icore.h"
|
#include "../core/icore.h"
|
||||||
#include "../core/imenu_manager.h"
|
#include "../core/imenu_manager.h"
|
||||||
|
@ -43,15 +43,18 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent)
|
||||||
m_undoStack = new QUndoStack(this);
|
m_undoStack = new QUndoStack(this);
|
||||||
m_zoneBuilder = new ZoneBuilder();
|
m_zoneBuilder = new ZoneBuilder();
|
||||||
m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", false);
|
m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", false);
|
||||||
m_ui.zoneListWidget->setModel(m_zoneBuilder->zoneModel());
|
|
||||||
m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder);
|
m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder);
|
||||||
m_ui.zoneListWidget->updateUi();
|
m_ui.zoneListWidget->updateUi();
|
||||||
createMenus();
|
createMenus();
|
||||||
|
createToolBars();
|
||||||
readSettings();
|
readSettings();
|
||||||
|
|
||||||
|
connect(m_ui.projectSettingsAction, SIGNAL(triggered()), this, SLOT(openProjectSettings()));
|
||||||
}
|
}
|
||||||
|
|
||||||
LandscapeEditorWindow::~LandscapeEditorWindow()
|
LandscapeEditorWindow::~LandscapeEditorWindow()
|
||||||
{
|
{
|
||||||
|
delete m_zoneBuilder;
|
||||||
writeSettings();
|
writeSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,11 +78,37 @@ void LandscapeEditorWindow::open()
|
||||||
setCursor(Qt::ArrowCursor);
|
setCursor(Qt::ArrowCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LandscapeEditorWindow::openProjectSettings()
|
||||||
|
{
|
||||||
|
ProjectSettingsDialog *dialog = new ProjectSettingsDialog(m_zoneBuilder->dataPath(), this);
|
||||||
|
dialog->show();
|
||||||
|
int ok = dialog->exec();
|
||||||
|
if (ok == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
m_zoneBuilder->init(dialog->dataPath(), false);
|
||||||
|
m_ui.zoneListWidget->updateUi();
|
||||||
|
}
|
||||||
|
delete dialog;
|
||||||
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::createMenus()
|
void LandscapeEditorWindow::createMenus()
|
||||||
{
|
{
|
||||||
Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager();
|
Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LandscapeEditorWindow::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::SAVE);
|
||||||
|
//m_ui.fileToolBar->addAction(action);
|
||||||
|
//action = menuManager->action(Core::Constants::SAVE_AS);
|
||||||
|
//m_ui.fileToolBar->addAction(action);
|
||||||
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::readSettings()
|
void LandscapeEditorWindow::readSettings()
|
||||||
{
|
{
|
||||||
QSettings *settings = Core::ICore::instance()->settings();
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
|
|
|
@ -43,8 +43,11 @@ public Q_SLOTS:
|
||||||
void open();
|
void open();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
|
void openProjectSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createMenus();
|
void createMenus();
|
||||||
|
void createToolBars();
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QToolBar" name="toolBar">
|
<widget class="QToolBar" name="fileToolBar">
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>toolBar</string>
|
<string>toolBar</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -44,6 +44,27 @@
|
||||||
</attribute>
|
</attribute>
|
||||||
<widget class="LandscapeEditor::ListZonesWidget" name="zoneListWidget"/>
|
<widget class="LandscapeEditor::ListZonesWidget" name="zoneListWidget"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QToolBar" name="landToolBar">
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>toolBar_2</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="toolBarArea">
|
||||||
|
<enum>TopToolBarArea</enum>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="toolBarBreak">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<addaction name="projectSettingsAction"/>
|
||||||
|
</widget>
|
||||||
|
<action name="projectSettingsAction">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="landscape_editor.qrc">
|
||||||
|
<normaloff>:/icons/ic_nel_landscape_settings.png</normaloff>:/icons/ic_nel_landscape_settings.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Project settings</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "list_zones_model.h"
|
#include "list_zones_model.h"
|
||||||
|
#include "builder_zone.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
|
@ -27,15 +28,14 @@
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QSize>
|
|
||||||
#include <QtGui/QProgressDialog>
|
#include <QtGui/QProgressDialog>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
ListZonesModel::ListZonesModel(int pixmapSize, QObject *parent)
|
ListZonesModel::ListZonesModel(int scaleRatio, QObject *parent)
|
||||||
: QAbstractListModel(parent),
|
: QAbstractListModel(parent),
|
||||||
m_pixmapSize(pixmapSize)
|
m_scaleRatio(scaleRatio)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ ListZonesModel::~ListZonesModel()
|
||||||
|
|
||||||
int ListZonesModel::rowCount(const QModelIndex & /* parent */) const
|
int ListZonesModel::rowCount(const QModelIndex & /* parent */) const
|
||||||
{
|
{
|
||||||
return m_pixmapNameList.count();
|
return m_listNames.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ListZonesModel::columnCount(const QModelIndex & /* parent */) const
|
int ListZonesModel::columnCount(const QModelIndex & /* parent */) const
|
||||||
|
@ -65,11 +65,11 @@ QVariant ListZonesModel::data(const QModelIndex &index, int role) const
|
||||||
}
|
}
|
||||||
else if (role == Qt::DisplayRole)
|
else if (role == Qt::DisplayRole)
|
||||||
{
|
{
|
||||||
return m_pixmapNameList.at(index.row());
|
return m_listNames.at(index.row());
|
||||||
}
|
}
|
||||||
else if (role == Qt::DecorationRole)
|
else if (role == Qt::DecorationRole)
|
||||||
{
|
{
|
||||||
QPixmap *pixmap = getSmallPixmap(m_pixmapNameList.at(index.row()));
|
QPixmap *pixmap = getPixmap(m_listNames.at(index.row()));
|
||||||
return qVariantFromValue(*pixmap);
|
return qVariantFromValue(*pixmap);
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
@ -84,73 +84,48 @@ QVariant ListZonesModel::headerData(int section,
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListZonesModel::setSmallPixmapSize(int pixmapSize)
|
void ListZonesModel::setScaleRatio(int scaleRatio)
|
||||||
{
|
{
|
||||||
m_pixmapSize = pixmapSize;
|
m_scaleRatio = scaleRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListZonesModel::setListZones(QStringList &listZones)
|
void ListZonesModel::setListZones(QStringList &listZones)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
m_pixmapNameList.clear();
|
m_listNames.clear();
|
||||||
m_pixmapNameList = listZones;
|
m_listNames = listZones;
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListZonesModel::resetModel()
|
void ListZonesModel::resetModel()
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
Q_FOREACH(QString name, m_pixmapNameList)
|
QStringList listNames(m_pixmapMap.keys());
|
||||||
|
Q_FOREACH(QString name, listNames)
|
||||||
{
|
{
|
||||||
QPixmap *pixmap = m_pixmapMap.value(name);
|
QPixmap *pixmap = m_pixmapMap.value(name);
|
||||||
delete pixmap;
|
delete pixmap;
|
||||||
QPixmap *smallPixmap = m_smallPixmapMap.value(name);
|
|
||||||
delete smallPixmap;
|
|
||||||
}
|
}
|
||||||
m_pixmapMap.clear();
|
m_pixmapMap.clear();
|
||||||
m_pixmapNameList.clear();
|
m_listNames.clear();
|
||||||
m_smallPixmapMap.clear();
|
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ListZonesModel::rebuildModel(const QString &zonePath, NLLIGO::CZoneBank &zoneBank)
|
void ListZonesModel::rebuildModel(PixmapDatabase *pixmapDatabase)
|
||||||
{
|
{
|
||||||
|
resetModel();
|
||||||
|
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
m_zonePath = zonePath;
|
QStringList listNames;
|
||||||
|
listNames = pixmapDatabase->listPixmaps();
|
||||||
|
|
||||||
QProgressDialog *progressDialog = new QProgressDialog();
|
Q_FOREACH(QString name, listNames)
|
||||||
progressDialog->show();
|
|
||||||
|
|
||||||
std::vector<std::string> zoneNames;
|
|
||||||
zoneBank.getCategoryValues ("zone", zoneNames);
|
|
||||||
progressDialog->setRange(0, zoneNames.size());
|
|
||||||
for (uint i = 0; i < zoneNames.size(); ++i)
|
|
||||||
{
|
{
|
||||||
QApplication::processEvents();
|
QPixmap *pixmap = pixmapDatabase->pixmap(name);
|
||||||
progressDialog->setValue(i);
|
QPixmap *smallPixmap = new QPixmap(pixmap->scaled(pixmap->width() / m_scaleRatio, pixmap->height() / m_scaleRatio));
|
||||||
|
m_pixmapMap.insert(name, smallPixmap);
|
||||||
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<bool> &rMask = zoneBankItem->getMask();
|
|
||||||
|
|
||||||
QPixmap *pixmap = new QPixmap(zonePath + zonePixmapName + ".png");
|
|
||||||
if (pixmap->isNull())
|
|
||||||
{
|
|
||||||
// Generate filled pixmap
|
|
||||||
}
|
|
||||||
QPixmap *smallPixmap = new QPixmap(pixmap->scaled(m_pixmapSize * sizeX, m_pixmapSize * sizeY));
|
|
||||||
|
|
||||||
m_pixmapMap.insert(zonePixmapName, pixmap);
|
|
||||||
m_smallPixmapMap.insert(zonePixmapName, smallPixmap);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
endResetModel();
|
endResetModel();
|
||||||
delete progressDialog;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap *ListZonesModel::getPixmap(const QString &zoneName) const
|
QPixmap *ListZonesModel::getPixmap(const QString &zoneName) const
|
||||||
|
@ -163,15 +138,4 @@ QPixmap *ListZonesModel::getPixmap(const QString &zoneName) const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap *ListZonesModel::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 */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
|
@ -31,18 +31,18 @@
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
class PixmapDatabase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class ListZonesModel
|
@class ListZonesModel
|
||||||
@brief ListZonesModel contains the image database for QGraphicsScene and
|
@brief ListZonesModel contains the small images for QListView
|
||||||
small images for QListView
|
|
||||||
@details
|
@details
|
||||||
*/
|
*/
|
||||||
class ListZonesModel : public QAbstractListModel
|
class ListZonesModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ListZonesModel(int pixmapSize = 64, QObject *parent = 0);
|
ListZonesModel(int scaleRatio = 4, QObject *parent = 0);
|
||||||
~ListZonesModel();
|
~ListZonesModel();
|
||||||
|
|
||||||
int rowCount(const QModelIndex &parent) const;
|
int rowCount(const QModelIndex &parent) const;
|
||||||
|
@ -53,30 +53,25 @@ public:
|
||||||
|
|
||||||
/// Set size for small pixmaps
|
/// Set size for small pixmaps
|
||||||
/// Value should be set before calling rebuildModel
|
/// Value should be set before calling rebuildModel
|
||||||
void setSmallPixmapSize(int pixmapSize);
|
void setScaleRatio(int scaleRatio);
|
||||||
|
|
||||||
/// Unload all images and reset model
|
/// Unload all images and reset model
|
||||||
void resetModel();
|
void resetModel();
|
||||||
|
|
||||||
|
/// Set current list zones which will be available in QListView
|
||||||
void setListZones(QStringList &listZones);
|
void setListZones(QStringList &listZones);
|
||||||
|
|
||||||
/// Load all images(png) from zonePath, list images gets from zoneBank
|
/// Build own pixmaps database(all images are scaled: width/scaleRatio, height/scaleRatio) from pixmapDatabase
|
||||||
bool rebuildModel(const QString &zonePath, NLLIGO::CZoneBank &zoneBank);
|
void rebuildModel(PixmapDatabase *pixmapDatabase);
|
||||||
|
|
||||||
/// Get original pixmap
|
private:
|
||||||
|
/// Get pixmap
|
||||||
/// @return QPixmap* if the image is in the database ; otherwise returns 0.
|
/// @return QPixmap* if the image is in the database ; otherwise returns 0.
|
||||||
QPixmap *getPixmap(const QString &zoneName) const;
|
QPixmap *getPixmap(const QString &zoneName) const;
|
||||||
|
|
||||||
/// Get scaled pixmap (pixmapSize * zoneSize.sizeX, pixmapSize * zoneSize.sizeY)
|
int m_scaleRatio;
|
||||||
/// @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<QString, QPixmap*> m_pixmapMap;
|
QMap<QString, QPixmap*> m_pixmapMap;
|
||||||
QMap<QString, QPixmap*> m_smallPixmapMap;
|
QStringList m_listNames;
|
||||||
QList<QString> m_pixmapNameList;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
|
@ -37,10 +37,14 @@ namespace LandscapeEditor
|
||||||
|
|
||||||
ListZonesWidget::ListZonesWidget(QWidget *parent)
|
ListZonesWidget::ListZonesWidget(QWidget *parent)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
|
m_listZonesModel(0),
|
||||||
m_zoneBuilder(0)
|
m_zoneBuilder(0)
|
||||||
{
|
{
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
|
||||||
|
m_listZonesModel = new ListZonesModel(4, this);
|
||||||
|
m_ui.listView->setModel(m_listZonesModel);
|
||||||
|
|
||||||
m_ui.addFilterButton_1->setChecked(false);
|
m_ui.addFilterButton_1->setChecked(false);
|
||||||
m_ui.addFilterButton_2->setChecked(false);
|
m_ui.addFilterButton_2->setChecked(false);
|
||||||
m_ui.addFilterButton_3->setChecked(false);
|
m_ui.addFilterButton_3->setChecked(false);
|
||||||
|
@ -81,6 +85,10 @@ void ListZonesWidget::updateUi()
|
||||||
m_ui.categoryTypeComboBox_2->clear();
|
m_ui.categoryTypeComboBox_2->clear();
|
||||||
m_ui.categoryTypeComboBox_3->clear();
|
m_ui.categoryTypeComboBox_3->clear();
|
||||||
m_ui.categoryTypeComboBox_4->clear();
|
m_ui.categoryTypeComboBox_4->clear();
|
||||||
|
m_ui.categoryValueComboBox_1->clear();
|
||||||
|
m_ui.categoryValueComboBox_2->clear();
|
||||||
|
m_ui.categoryValueComboBox_3->clear();
|
||||||
|
m_ui.categoryValueComboBox_4->clear();
|
||||||
|
|
||||||
m_ui.categoryTypeComboBox_1->addItems(listCategories);
|
m_ui.categoryTypeComboBox_1->addItems(listCategories);
|
||||||
m_ui.categoryTypeComboBox_2->addItems(listCategories);
|
m_ui.categoryTypeComboBox_2->addItems(listCategories);
|
||||||
|
@ -88,11 +96,8 @@ void ListZonesWidget::updateUi()
|
||||||
m_ui.categoryTypeComboBox_4->addItems(listCategories);
|
m_ui.categoryTypeComboBox_4->addItems(listCategories);
|
||||||
|
|
||||||
disableSignals(false);
|
disableSignals(false);
|
||||||
}
|
|
||||||
|
|
||||||
void ListZonesWidget::setModel(QAbstractItemModel *model)
|
m_listZonesModel->rebuildModel(m_zoneBuilder->pixmapDatabase());
|
||||||
{
|
|
||||||
m_ui.listView->setModel(model);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListZonesWidget::setZoneBuilder(ZoneBuilder *zoneBuilder)
|
void ListZonesWidget::setZoneBuilder(ZoneBuilder *zoneBuilder)
|
||||||
|
@ -201,7 +206,8 @@ void ListZonesWidget::updateListZones()
|
||||||
QStringList listSelection;
|
QStringList listSelection;
|
||||||
for (size_t i = 0; i < currentSelection.size(); ++i)
|
for (size_t i = 0; i < currentSelection.size(); ++i)
|
||||||
listSelection << currentSelection[i]->getName().c_str();
|
listSelection << currentSelection[i]->getName().c_str();
|
||||||
m_zoneBuilder->zoneModel()->setListZones(listSelection);
|
|
||||||
|
m_listZonesModel->setListZones(listSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListZonesWidget::disableSignals(bool block)
|
void ListZonesWidget::disableSignals(bool block)
|
||||||
|
|
|
@ -28,10 +28,11 @@
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
class ZoneBuilder;
|
class ZoneBuilder;
|
||||||
|
class ListZonesModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class ZoneListWidget
|
@class ZoneListWidget
|
||||||
@brief ZoneListWidget
|
@brief ZoneListWidget displays list available zones in accordance with the filter settings
|
||||||
@details
|
@details
|
||||||
*/
|
*/
|
||||||
class ListZonesWidget: public QWidget
|
class ListZonesWidget: public QWidget
|
||||||
|
@ -44,21 +45,19 @@ public:
|
||||||
|
|
||||||
void updateUi();
|
void updateUi();
|
||||||
void setZoneBuilder(ZoneBuilder *zoneBuilder);
|
void setZoneBuilder(ZoneBuilder *zoneBuilder);
|
||||||
void setModel(QAbstractItemModel *model);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
public Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void updateFilters_1(const QString &value);
|
void updateFilters_1(const QString &value);
|
||||||
void updateFilters_2(const QString &value);
|
void updateFilters_2(const QString &value);
|
||||||
void updateFilters_3(const QString &value);
|
void updateFilters_3(const QString &value);
|
||||||
void updateFilters_4(const QString &value);
|
void updateFilters_4(const QString &value);
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void updateListZones();
|
void updateListZones();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void disableSignals(bool block);
|
void disableSignals(bool block);
|
||||||
|
|
||||||
|
ListZonesModel *m_listZonesModel;
|
||||||
ZoneBuilder *m_zoneBuilder;
|
ZoneBuilder *m_zoneBuilder;
|
||||||
Ui::ListZonesWidget m_ui;
|
Ui::ListZonesWidget m_ui;
|
||||||
}; /* ZoneListWidget */
|
}; /* ZoneListWidget */
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
// 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 "project_settings_dialog.h"
|
||||||
|
#include "landscape_editor_constants.h"
|
||||||
|
|
||||||
|
#include "../core/icore.h"
|
||||||
|
#include "../core/core_constants.h"
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtCore/QSettings>
|
||||||
|
#include <QtGui/QFileDialog>
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
|
||||||
|
ProjectSettingsDialog::ProjectSettingsDialog(const QString &dataPath, QWidget *parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
{
|
||||||
|
m_ui.setupUi(this);
|
||||||
|
m_ui.pathLineEdit->setText(dataPath);
|
||||||
|
setFixedHeight(sizeHint().height());
|
||||||
|
}
|
||||||
|
|
||||||
|
ProjectSettingsDialog::~ProjectSettingsDialog()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ProjectSettingsDialog::dataPath() const
|
||||||
|
{
|
||||||
|
return m_ui.pathLineEdit->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
|
@ -0,0 +1,46 @@
|
||||||
|
// 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 PROJECT_SETTINGS_DIALOG_H
|
||||||
|
#define PROJECT_SETTINGS_DIALOG_H
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "ui_project_settings_dialog.h"
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
|
||||||
|
class ProjectSettingsDialog: public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
ProjectSettingsDialog(const QString &dataPath, QWidget *parent = 0);
|
||||||
|
~ProjectSettingsDialog();
|
||||||
|
|
||||||
|
QString dataPath() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
Ui::ProjectSettingsDialog m_ui;
|
||||||
|
}; /* class ProjectSettingsDialog */
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
||||||
|
|
||||||
|
#endif // PROJECT_SETTINGS_DIALOG_H
|
|
@ -0,0 +1,97 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>ProjectSettingsDialog</class>
|
||||||
|
<widget class="QDialog" name="ProjectSettingsDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>419</width>
|
||||||
|
<height>93</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Project settings</string>
|
||||||
|
</property>
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset resource="landscape_editor.qrc">
|
||||||
|
<normaloff>:/icons/ic_nel_landscape_settings.png</normaloff>:/icons/ic_nel_landscape_settings.png</iconset>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Data directory:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="pathLineEdit"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QToolButton" name="selectPathButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Context:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1" colspan="2">
|
||||||
|
<widget class="QComboBox" name="contextComboBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" colspan="3">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources>
|
||||||
|
<include location="landscape_editor.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>ProjectSettingsDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>ProjectSettingsDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
Loading…
Reference in a new issue