mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-24 08:06:13 +00:00
Changed: #1301 Added select path button in project settings dialog. Main window landscape editor is saving own state.
This commit is contained in:
parent
f02f5525aa
commit
8903f6ca4b
13 changed files with 168 additions and 14 deletions
|
@ -15,6 +15,7 @@ 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
|
||||||
|
landscape_view.h
|
||||||
project_settings_dialog.h
|
project_settings_dialog.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -164,6 +164,7 @@ bool ZoneBuilder::initZoneBank (const QString &pathName)
|
||||||
if (!m_zoneBank.addElement((pathName + file).toStdString(), error))
|
if (!m_zoneBank.addElement((pathName + file).toStdString(), error))
|
||||||
QMessageBox::critical(0, QObject::tr("Landscape editor"), QString(error.c_str()), QMessageBox::Ok);
|
QMessageBox::critical(0, QObject::tr("Landscape editor"), QString(error.c_str()), QMessageBox::Ok);
|
||||||
}
|
}
|
||||||
|
delete dir;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,8 +67,8 @@ private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@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.
|
||||||
PixmapDatabase contains the graphics for the zones
|
PixmapDatabase contains the graphics for the zones
|
||||||
*/
|
*/
|
||||||
class ZoneBuilder
|
class ZoneBuilder
|
||||||
|
|
|
@ -26,6 +26,8 @@ const char * const LANDSCAPE_EDITOR_PLUGIN = "LandscapeEditor";
|
||||||
|
|
||||||
//settings
|
//settings
|
||||||
const char * const LANDSCAPE_EDITOR_SECTION = "LandscapeEditor";
|
const char * const LANDSCAPE_EDITOR_SECTION = "LandscapeEditor";
|
||||||
|
const char * const LANDSCAPE_WINDOW_STATE = "LandscapeWindowState";
|
||||||
|
const char * const LANDSCAPE_WINDOW_GEOMETRY = "LandscapeWindowGeometry";
|
||||||
|
|
||||||
//resources
|
//resources
|
||||||
const char * const ICON_LANDSCAPE_ITEM = ":/icons/ic_nel_landscape_item.png";
|
const char * const ICON_LANDSCAPE_ITEM = ":/icons/ic_nel_landscape_item.png";
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
// 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 "builder_zone.h"
|
||||||
|
#include "landscape_scene.h"
|
||||||
#include "project_settings_dialog.h"
|
#include "project_settings_dialog.h"
|
||||||
|
|
||||||
#include "../core/icore.h"
|
#include "../core/icore.h"
|
||||||
|
@ -30,6 +32,8 @@
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
#include <QtGui/QFileDialog>
|
#include <QtGui/QFileDialog>
|
||||||
|
#include <QtOpenGL/QGLWidget>
|
||||||
|
#include <QtGui/QGraphicsPixmapItem>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
@ -45,6 +49,12 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent)
|
||||||
m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", false);
|
m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", false);
|
||||||
m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder);
|
m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder);
|
||||||
m_ui.zoneListWidget->updateUi();
|
m_ui.zoneListWidget->updateUi();
|
||||||
|
|
||||||
|
m_landscapeScene = new LandscapeScene(this);
|
||||||
|
m_ui.graphicsView->setScene(m_landscapeScene);
|
||||||
|
m_ui.graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::SampleBuffers)));
|
||||||
|
|
||||||
|
|
||||||
createMenus();
|
createMenus();
|
||||||
createToolBars();
|
createToolBars();
|
||||||
readSettings();
|
readSettings();
|
||||||
|
@ -113,6 +123,8 @@ void LandscapeEditorWindow::readSettings()
|
||||||
{
|
{
|
||||||
QSettings *settings = Core::ICore::instance()->settings();
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION);
|
settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION);
|
||||||
|
restoreState(settings->value(Constants::LANDSCAPE_WINDOW_STATE).toByteArray());
|
||||||
|
restoreGeometry(settings->value(Constants::LANDSCAPE_WINDOW_GEOMETRY).toByteArray());
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +132,8 @@ void LandscapeEditorWindow::writeSettings()
|
||||||
{
|
{
|
||||||
QSettings *settings = Core::ICore::instance()->settings();
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION);
|
settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION);
|
||||||
|
settings->setValue(Constants::LANDSCAPE_WINDOW_STATE, saveState());
|
||||||
|
settings->setValue(Constants::LANDSCAPE_WINDOW_GEOMETRY, saveGeometry());
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->sync();
|
settings->sync();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "ui_landscape_editor_window.h"
|
#include "ui_landscape_editor_window.h"
|
||||||
#include "builder_zone.h"
|
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtGui/QUndoStack>
|
#include <QtGui/QUndoStack>
|
||||||
|
@ -28,6 +27,9 @@
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class LandscapeScene;
|
||||||
|
class ZoneBuilder;
|
||||||
|
|
||||||
class LandscapeEditorWindow: public QMainWindow
|
class LandscapeEditorWindow: public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -51,6 +53,7 @@ private:
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
|
|
||||||
|
LandscapeScene *m_landscapeScene;
|
||||||
ZoneBuilder *m_zoneBuilder;
|
ZoneBuilder *m_zoneBuilder;
|
||||||
QUndoStack *m_undoStack;
|
QUndoStack *m_undoStack;
|
||||||
Ui::LandscapeEditorWindow m_ui;
|
Ui::LandscapeEditorWindow m_ui;
|
||||||
|
|
|
@ -19,8 +19,18 @@
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<property name="margin">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QGraphicsView" name="graphicsView"/>
|
<widget class="LandscapeEditor::LandscapeView" name="graphicsView">
|
||||||
|
<property name="dragMode">
|
||||||
|
<enum>QGraphicsView::NoDrag</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -73,6 +83,11 @@
|
||||||
<header>list_zones_widget.h</header>
|
<header>list_zones_widget.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>LandscapeEditor::LandscapeView</class>
|
||||||
|
<extends>QGraphicsView</extends>
|
||||||
|
<header>landscape_view.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="landscape_editor.qrc"/>
|
<include location="landscape_editor.qrc"/>
|
||||||
|
|
|
@ -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 "landscape_view.h"
|
||||||
|
#include "landscape_editor_constants.h"
|
||||||
|
|
||||||
|
#include "../core/icore.h"
|
||||||
|
#include "../core/core_constants.h"
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
|
||||||
|
LandscapeView::LandscapeView(QWidget *parent)
|
||||||
|
: QGraphicsView(parent)
|
||||||
|
{
|
||||||
|
setDragMode(ScrollHandDrag);
|
||||||
|
}
|
||||||
|
|
||||||
|
LandscapeView::~LandscapeView()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeView::wheelEvent(QWheelEvent *event)
|
||||||
|
{
|
||||||
|
double numDegrees = event->delta() / 8.0;
|
||||||
|
double numSteps = numDegrees / 15.0;
|
||||||
|
double factor = std::pow(1.125, numSteps);
|
||||||
|
scale(factor, factor);
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
|
@ -0,0 +1,49 @@
|
||||||
|
// 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 LANDSCAPE_VIEW_H
|
||||||
|
#define LANDSCAPE_VIEW_H
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtGui/QGraphicsView>
|
||||||
|
#include <QtGui/QWheelEvent>
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
|
||||||
|
class LandscapeView: public QGraphicsView
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
LandscapeView(QWidget *parent = 0);
|
||||||
|
~LandscapeView();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void wheelEvent(QWheelEvent *event);
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
}; /* class LandscapeView */
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
||||||
|
|
||||||
|
#endif // LANDSCAPE_VIEW_H
|
|
@ -59,28 +59,26 @@ QVariant ListZonesModel::data(const QModelIndex &index, int role) const
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
if (role == Qt::TextAlignmentRole)
|
switch (role)
|
||||||
{
|
{
|
||||||
|
case Qt::TextAlignmentRole:
|
||||||
return int(Qt::AlignLeft | Qt::AlignVCenter);
|
return int(Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
}
|
case Qt::DisplayRole:
|
||||||
else if (role == Qt::DisplayRole)
|
|
||||||
{
|
|
||||||
return m_listNames.at(index.row());
|
return m_listNames.at(index.row());
|
||||||
}
|
case Qt::DecorationRole:
|
||||||
else if (role == Qt::DecorationRole)
|
|
||||||
{
|
{
|
||||||
QPixmap *pixmap = getPixmap(m_listNames.at(index.row()));
|
QPixmap *pixmap = getPixmap(m_listNames.at(index.row()));
|
||||||
return qVariantFromValue(*pixmap);
|
return qVariantFromValue(*pixmap);
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant ListZonesModel::headerData(int section,
|
QVariant ListZonesModel::headerData(int section,
|
||||||
Qt::Orientation /* orientation */,
|
Qt::Orientation /* orientation */,
|
||||||
int role) const
|
int role) const
|
||||||
{
|
{
|
||||||
if (role != Qt::DisplayRole)
|
|
||||||
return QVariant();
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -290,7 +290,14 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QListView" name="listView"/>
|
<widget class="QListView" name="listView">
|
||||||
|
<property name="alternatingRowColors">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="verticalScrollMode">
|
||||||
|
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
#include <QtGui/QFileDialog>
|
#include <QtGui/QFileDialog>
|
||||||
|
#include <QtGui/QFileDialog>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
@ -38,6 +39,7 @@ ProjectSettingsDialog::ProjectSettingsDialog(const QString &dataPath, QWidget *p
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
m_ui.pathLineEdit->setText(dataPath);
|
m_ui.pathLineEdit->setText(dataPath);
|
||||||
setFixedHeight(sizeHint().height());
|
setFixedHeight(sizeHint().height());
|
||||||
|
connect(m_ui.selectPathButton, SIGNAL(clicked()), this, SLOT(selectPath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectSettingsDialog::~ProjectSettingsDialog()
|
ProjectSettingsDialog::~ProjectSettingsDialog()
|
||||||
|
@ -49,4 +51,11 @@ QString ProjectSettingsDialog::dataPath() const
|
||||||
return m_ui.pathLineEdit->text();
|
return m_ui.pathLineEdit->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProjectSettingsDialog::selectPath()
|
||||||
|
{
|
||||||
|
QString dataPath = QFileDialog::getExistingDirectory(this, tr("Select data path"), m_ui.pathLineEdit->text());
|
||||||
|
if (!dataPath.isEmpty())
|
||||||
|
m_ui.pathLineEdit->setText(dataPath);
|
||||||
|
}
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
|
@ -36,6 +36,9 @@ public:
|
||||||
|
|
||||||
QString dataPath() const;
|
QString dataPath() const;
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void selectPath();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Ui::ProjectSettingsDialog m_ui;
|
Ui::ProjectSettingsDialog m_ui;
|
||||||
|
|
Loading…
Reference in a new issue