From 018fcac076950fd2ef09bf0aae4c7d0bf81a7830 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Tue, 12 Jul 2011 01:14:25 +0300 Subject: [PATCH] Changed: #1301 Removed a hard coded value. --HG-- branch : gsoc2011-worldeditorqt --- .../plugins/landscape_editor/builder_zone.cpp | 15 +++++++------- .../plugins/landscape_editor/builder_zone.h | 2 +- .../landscape_editor_constants.h | 2 ++ .../landscape_editor_window.cpp | 20 ++++++++++++++----- 4 files changed, 25 insertions(+), 14 deletions(-) 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 index b9ffe7151..cb97c20ea 100644 --- 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 @@ -49,9 +49,10 @@ ZoneBuilder::~ZoneBuilder() delete m_pixmapDatabase; } -bool ZoneBuilder::init(const QString &pathName, bool makeAZone) +bool ZoneBuilder::init(const QString &pathName, bool displayProgress) { - bool bRet = true; + if (pathName.isEmpty()) + return false; if (pathName != m_lastPathName) { m_lastPathName = pathName; @@ -59,25 +60,23 @@ bool ZoneBuilder::init(const QString &pathName, bool makeAZone) zoneBankPath += "/zoneligos/"; // Init the ZoneBank - m_zoneBank.reset (); + m_zoneBank.reset(); if (!initZoneBank (zoneBankPath)) { - m_zoneBank.reset (); + m_zoneBank.reset(); return false; } // Construct the DataBase from the ZoneBank QString zoneBitmapPath = pathName; zoneBitmapPath += "/zonebitmaps/"; m_pixmapDatabase->reset(); - if (!m_pixmapDatabase->loadPixmaps(zoneBitmapPath, m_zoneBank)) + if (!m_pixmapDatabase->loadPixmaps(zoneBitmapPath, m_zoneBank, displayProgress)) { m_zoneBank.reset(); return false; } } - if ((makeAZone) && (bRet)) - createZoneRegion(); - return bRet; + return true; } void ZoneBuilder::actionLigoTile(const LigoData &data, const ZonePosition &zonePos) 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 index 5fbd80832..213ba9b13 100644 --- 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 @@ -82,7 +82,7 @@ public: ~ZoneBuilder(); /// Init zoneBank and init zone pixmap database - bool init(const QString &pathName, bool bMakeAZone); + bool init(const QString &pathName, bool displayProgress = false); void calcMask(); bool getZoneMask (sint32 x, sint32 y); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h index 6875ddfab..9ab2dbfbc 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h @@ -28,6 +28,8 @@ const char * const LANDSCAPE_EDITOR_PLUGIN = "LandscapeEditor"; const char * const LANDSCAPE_EDITOR_SECTION = "LandscapeEditor"; const char * const LANDSCAPE_WINDOW_STATE = "LandscapeWindowState"; const char * const LANDSCAPE_WINDOW_GEOMETRY = "LandscapeWindowGeometry"; +const char * const LANDSCAPE_DATA_DIRECTORY = "LandscapeDataDirectory"; +const char * const LANDSCAPE_USE_OPENGL = "LandscapeUseOpenGL"; //resources const char * const ICON_LANDSCAPE_ITEM = ":/icons/ic_nel_landscape_item.png"; 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 4dd3163ba..3483766f9 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 @@ -58,14 +58,11 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) m_landscapeScene = new LandscapeScene(this); m_zoneBuilder = new ZoneBuilder(m_landscapeScene, m_ui.zoneListWidget, m_undoStack); - m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", false); m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder); m_ui.zoneListWidget->updateUi(); m_landscapeScene->setZoneBuilder(m_zoneBuilder); m_ui.graphicsView->setScene(m_landscapeScene); - //m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer)); - //m_ui.graphicsView->setViewport(m_oglWidget); m_ui.newLandAction->setIcon(QIcon(Core::Constants::ICON_NEW)); m_ui.saveAction->setIcon(QIcon(Core::Constants::ICON_SAVE)); @@ -95,8 +92,8 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) LandscapeEditorWindow::~LandscapeEditorWindow() { - delete m_zoneBuilder; writeSettings(); + delete m_zoneBuilder; } QUndoStack *LandscapeEditorWindow::undoStack() const @@ -137,7 +134,7 @@ void LandscapeEditorWindow::openProjectSettings() int ok = dialog->exec(); if (ok == QDialog::Accepted) { - m_zoneBuilder->init(dialog->dataPath(), false); + m_zoneBuilder->init(dialog->dataPath(), true); m_ui.zoneListWidget->updateUi(); } delete dialog; @@ -358,6 +355,18 @@ void LandscapeEditorWindow::readSettings() settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION); restoreState(settings->value(Constants::LANDSCAPE_WINDOW_STATE).toByteArray()); restoreGeometry(settings->value(Constants::LANDSCAPE_WINDOW_GEOMETRY).toByteArray()); + + // Read landscape data directory (contains sub-paths: zone logos, zone bitmaps) + m_zoneBuilder->init(settings->value(Constants::LANDSCAPE_DATA_DIRECTORY).toString()); + m_ui.zoneListWidget->updateUi(); + + // Use OpenGL graphics system instead raster graphics system + if (settings->value(Constants::LANDSCAPE_USE_OPENGL, false).toBool()) + { + m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer)); + m_ui.graphicsView->setViewport(m_oglWidget); + } + settings->endGroup(); } @@ -367,6 +376,7 @@ void LandscapeEditorWindow::writeSettings() settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION); settings->setValue(Constants::LANDSCAPE_WINDOW_STATE, saveState()); settings->setValue(Constants::LANDSCAPE_WINDOW_GEOMETRY, saveGeometry()); + settings->setValue(Constants::LANDSCAPE_DATA_DIRECTORY, m_zoneBuilder->dataPath()); settings->endGroup(); settings->sync(); }