From 64a4bb6d397cc2bf9f79637b20d22f6cac1fd462 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 4 Jul 2011 23:16:45 +0300 Subject: [PATCH] Changed: #1301 Added random and full cycle modes(for rotation and flip values too) adding zone on landscape. --- .../landscape_editor/list_zones_widget.cpp | 67 ++++++++++++++++--- .../landscape_editor/list_zones_widget.h | 10 ++- .../landscape_editor/list_zones_widget.ui | 10 ++- 3 files changed, 74 insertions(+), 13 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp index 7ce3f5421..d0bfe058c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp @@ -38,6 +38,8 @@ namespace LandscapeEditor ListZonesWidget::ListZonesWidget(QWidget *parent) : QWidget(parent), + m_rotCycle(0), + m_flipCycle(0), m_listZonesModel(0), m_zoneBuilder(0) { @@ -101,24 +103,70 @@ void ListZonesWidget::updateUi() m_listZonesModel->rebuildModel(m_zoneBuilder->pixmapDatabase()); } -QString ListZonesWidget::currentZoneName() const +QString ListZonesWidget::currentZoneName() { QString zoneName = ""; QModelIndex index = m_ui.listView->currentIndex(); if (index.isValid()) zoneName = index.data().toString(); - + if (m_ui.zoneSelectComboBox->currentIndex() == 1) + { + // Random value + if (m_listSelection.size() > 0) + { + uint32 randZone = uint32(NLMISC::frand(m_listSelection.size())); + NLMISC::clamp(randZone, (uint32)0, uint32(m_listSelection.size() - 1)); + zoneName = m_listSelection[randZone]; + } + } + else if (m_ui.zoneSelectComboBox->currentIndex() == 2) + { + // Full cycle + zoneName = m_listSelection[m_zoneNameCycle]; + m_zoneNameCycle++; + m_zoneNameCycle = m_zoneNameCycle % m_listSelection.size(); + } return zoneName; } -int ListZonesWidget::currentRot() const +int ListZonesWidget::currentRot() { - return m_ui.rotComboBox->currentIndex(); + int rot = m_ui.rotComboBox->currentIndex(); + if (rot == 4) + { + // Random value + uint32 randRot = uint32(NLMISC::frand(4.0)); + NLMISC::clamp(randRot, (uint32)0, (uint32)3); + rot = int(randRot); + } + else if (rot == 5) + { + // Full cycle + rot = m_rotCycle; + m_rotCycle++; + m_rotCycle = m_rotCycle % 4; + } + return rot; } -int ListZonesWidget::currentFlip() const +int ListZonesWidget::currentFlip() { - return m_ui.flipComboBox->currentIndex(); + int flip = m_ui.flipComboBox->currentIndex(); + if (flip == 2) + { + // Random value + uint32 randFlip = uint32(NLMISC::frand(2.0)); + NLMISC::clamp (randFlip, (uint32)0, (uint32)1); + flip = int(randFlip); + } + else if (flip == 3) + { + // Full cycle + flip = m_flipCycle; + m_flipCycle++; + m_flipCycle = m_flipCycle % 2; + } + return flip; } bool ListZonesWidget::isNotPropogate() const @@ -234,11 +282,12 @@ void ListZonesWidget::updateListZones() std::vector currentSelection; zoneBank.getSelection (currentSelection); - QStringList listSelection; + m_listSelection.clear(); + m_zoneNameCycle = 0; for (size_t i = 0; i < currentSelection.size(); ++i) - listSelection << currentSelection[i]->getName().c_str(); + m_listSelection << currentSelection[i]->getName().c_str(); - m_listZonesModel->setListZones(listSelection); + m_listZonesModel->setListZones(m_listSelection); } void ListZonesWidget::disableSignals(bool block) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h index c35e7b0fa..4128f8cc2 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h @@ -45,9 +45,9 @@ public: void updateUi(); void setZoneBuilder(ZoneBuilder *zoneBuilder); - QString currentZoneName() const; - int currentRot() const; - int currentFlip() const; + QString currentZoneName(); + int currentRot(); + int currentFlip(); bool isNotPropogate() const; bool isForce() const; @@ -62,6 +62,10 @@ private Q_SLOTS: private: void disableSignals(bool block); + int m_rotCycle, m_flipCycle; + int m_zoneNameCycle; + QStringList m_listSelection; + ListZonesModel *m_listZonesModel; ZoneBuilder *m_zoneBuilder; Ui::ListZonesWidget m_ui; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui index 4d9f63129..ed9faf74e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui @@ -39,7 +39,12 @@ - + + + + Select + + Random @@ -297,6 +302,9 @@ QAbstractItemView::ScrollPerPixel + + 1 +