mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-27 03:10:54 +00:00
Changed: #1301 Added select path button in project settings dialog. Main window landscape editor is saving own state.
--HG-- branch : gsoc2011-worldeditorqt
This commit is contained in:
parent
b25f78234b
commit
894a41cf97
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_widget.h
|
||||
landscape_actions.h
|
||||
landscape_view.h
|
||||
project_settings_dialog.h
|
||||
)
|
||||
|
||||
|
|
|
@ -164,6 +164,7 @@ bool ZoneBuilder::initZoneBank (const QString &pathName)
|
|||
if (!m_zoneBank.addElement((pathName + file).toStdString(), error))
|
||||
QMessageBox::critical(0, QObject::tr("Landscape editor"), QString(error.c_str()), QMessageBox::Ok);
|
||||
}
|
||||
delete dir;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,8 +67,8 @@ private:
|
|||
|
||||
/**
|
||||
@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
|
||||
@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.
|
||||
PixmapDatabase contains the graphics for the zones
|
||||
*/
|
||||
class ZoneBuilder
|
||||
|
|
|
@ -26,6 +26,8 @@ const char * const LANDSCAPE_EDITOR_PLUGIN = "LandscapeEditor";
|
|||
|
||||
//settings
|
||||
const char * const LANDSCAPE_EDITOR_SECTION = "LandscapeEditor";
|
||||
const char * const LANDSCAPE_WINDOW_STATE = "LandscapeWindowState";
|
||||
const char * const LANDSCAPE_WINDOW_GEOMETRY = "LandscapeWindowGeometry";
|
||||
|
||||
//resources
|
||||
const char * const ICON_LANDSCAPE_ITEM = ":/icons/ic_nel_landscape_item.png";
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
// Project includes
|
||||
#include "landscape_editor_window.h"
|
||||
#include "landscape_editor_constants.h"
|
||||
#include "builder_zone.h"
|
||||
#include "landscape_scene.h"
|
||||
#include "project_settings_dialog.h"
|
||||
|
||||
#include "../core/icore.h"
|
||||
|
@ -30,6 +32,8 @@
|
|||
// Qt includes
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtGui/QFileDialog>
|
||||
#include <QtOpenGL/QGLWidget>
|
||||
#include <QtGui/QGraphicsPixmapItem>
|
||||
|
||||
namespace LandscapeEditor
|
||||
{
|
||||
|
@ -45,6 +49,12 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent)
|
|||
m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", false);
|
||||
m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder);
|
||||
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();
|
||||
createToolBars();
|
||||
readSettings();
|
||||
|
@ -113,6 +123,8 @@ void LandscapeEditorWindow::readSettings()
|
|||
{
|
||||
QSettings *settings = Core::ICore::instance()->settings();
|
||||
settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION);
|
||||
restoreState(settings->value(Constants::LANDSCAPE_WINDOW_STATE).toByteArray());
|
||||
restoreGeometry(settings->value(Constants::LANDSCAPE_WINDOW_GEOMETRY).toByteArray());
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
|
@ -120,6 +132,8 @@ void LandscapeEditorWindow::writeSettings()
|
|||
{
|
||||
QSettings *settings = Core::ICore::instance()->settings();
|
||||
settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION);
|
||||
settings->setValue(Constants::LANDSCAPE_WINDOW_STATE, saveState());
|
||||
settings->setValue(Constants::LANDSCAPE_WINDOW_GEOMETRY, saveGeometry());
|
||||
settings->endGroup();
|
||||
settings->sync();
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
// Project includes
|
||||
#include "ui_landscape_editor_window.h"
|
||||
#include "builder_zone.h"
|
||||
|
||||
// Qt includes
|
||||
#include <QtGui/QUndoStack>
|
||||
|
@ -28,6 +27,9 @@
|
|||
namespace LandscapeEditor
|
||||
{
|
||||
|
||||
class LandscapeScene;
|
||||
class ZoneBuilder;
|
||||
|
||||
class LandscapeEditorWindow: public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -51,6 +53,7 @@ private:
|
|||
void readSettings();
|
||||
void writeSettings();
|
||||
|
||||
LandscapeScene *m_landscapeScene;
|
||||
ZoneBuilder *m_zoneBuilder;
|
||||
QUndoStack *m_undoStack;
|
||||
Ui::LandscapeEditorWindow m_ui;
|
||||
|
|
|
@ -19,8 +19,18 @@
|
|||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="margin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<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>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -73,6 +83,11 @@
|
|||
<header>list_zones_widget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LandscapeEditor::LandscapeView</class>
|
||||
<extends>QGraphicsView</extends>
|
||||
<header>landscape_view.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<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())
|
||||
return QVariant();
|
||||
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
switch (role)
|
||||
{
|
||||
case Qt::TextAlignmentRole:
|
||||
return int(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
}
|
||||
else if (role == Qt::DisplayRole)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
return m_listNames.at(index.row());
|
||||
}
|
||||
else if (role == Qt::DecorationRole)
|
||||
case Qt::DecorationRole:
|
||||
{
|
||||
QPixmap *pixmap = getPixmap(m_listNames.at(index.row()));
|
||||
return qVariantFromValue(*pixmap);
|
||||
}
|
||||
return QVariant();
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
QVariant ListZonesModel::headerData(int section,
|
||||
Qt::Orientation /* orientation */,
|
||||
int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
|
|
@ -290,7 +290,14 @@
|
|||
</widget>
|
||||
</item>
|
||||
<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>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
// Qt includes
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtGui/QFileDialog>
|
||||
#include <QtGui/QFileDialog>
|
||||
|
||||
namespace LandscapeEditor
|
||||
{
|
||||
|
@ -38,6 +39,7 @@ ProjectSettingsDialog::ProjectSettingsDialog(const QString &dataPath, QWidget *p
|
|||
m_ui.setupUi(this);
|
||||
m_ui.pathLineEdit->setText(dataPath);
|
||||
setFixedHeight(sizeHint().height());
|
||||
connect(m_ui.selectPathButton, SIGNAL(clicked()), this, SLOT(selectPath()));
|
||||
}
|
||||
|
||||
ProjectSettingsDialog::~ProjectSettingsDialog()
|
||||
|
@ -49,4 +51,11 @@ QString ProjectSettingsDialog::dataPath() const
|
|||
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 */
|
||||
|
|
|
@ -36,6 +36,9 @@ public:
|
|||
|
||||
QString dataPath() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void selectPath();
|
||||
|
||||
private:
|
||||
|
||||
Ui::ProjectSettingsDialog m_ui;
|
||||
|
|
Loading…
Reference in a new issue