diff --git a/code/studio/src/plugins/tile_editor/tile_editor_main_window.cpp b/code/studio/src/plugins/tile_editor/tile_editor_main_window.cpp index 5e3127d51..40b3b8dfc 100644 --- a/code/studio/src/plugins/tile_editor/tile_editor_main_window.cpp +++ b/code/studio/src/plugins/tile_editor/tile_editor_main_window.cpp @@ -96,6 +96,9 @@ TileEditorMainWindow::TileEditorMainWindow(QWidget *parent) connect(m_ui->landEditTB, SIGNAL(clicked()), this, SLOT(onLandEdit())); connect(m_ui->landLW, SIGNAL(currentRowChanged(int)), this, SLOT(onLandRowChanged(int))); + connect(m_ui->chooseVegetPushButton, SIGNAL(clicked()), this, SLOT(onChooseVegetation())); + connect(m_ui->resetVegetPushButton, SIGNAL(clicked()), this, SLOT(onResetVegetation())); + // 128x128 List View //m_ui->listView128->setItemDelegate(m_tileItemDelegate); m_ui->listView128->addAction(m_ui->actionAddTile); @@ -421,6 +424,8 @@ void TileEditorMainWindow::onLandEdit() void TileEditorMainWindow::onLandRowChanged( int row ) { + m_ui->chooseVegetPushButton->setText( "..." ); + if( row == -1 ) { disconnect( m_ui->tileSetLV->selectionModel(), SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ), @@ -456,6 +461,47 @@ void TileEditorMainWindow::onLandRowChanged( int row ) m_ui->tileSetLV->reset(); } +void TileEditorMainWindow::onChooseVegetation() +{ + QModelIndex idx = m_ui->tileSetLV->currentIndex(); + if( !idx.isValid() ) + { + QMessageBox::information( this, + tr("Choosing a vegetation set"), + tr("You need to select a tileset before choosing a vegetation set!") ); + return; + } + + QString vegetSet = QFileDialog::getOpenFileName( this, + tr( "Choose vegetation set" ), + "", + tr( "Nel vegetset files (*.vegetset)" ) ); + + if( vegetSet.isEmpty() ) + return; + + TileSetNode *node = reinterpret_cast< TileSetNode* >( idx.internalPointer() ); + node->setVegetSet( vegetSet ); + + m_ui->chooseVegetPushButton->setText( vegetSet ); +} + +void TileEditorMainWindow::onResetVegetation() +{ + QModelIndex idx = m_ui->tileSetLV->currentIndex(); + if( !idx.isValid() ) + { + QMessageBox::information( this, + tr("Resetting a vegetation set"), + tr("You need to select a tileset before resetting a vegetation set!") ); + return; + } + m_ui->chooseVegetPushButton->setText( "..." ); + + TileSetNode *node = reinterpret_cast< TileSetNode* >( idx.internalPointer() ); + node->setVegetSet( "" ); +} + void TileEditorMainWindow::onActionAddTile(int tabId) { QFileDialog::Options options; @@ -493,6 +539,28 @@ void TileEditorMainWindow::changeActiveTileSet(const QModelIndex &newIndex, cons m_ui->listViewDisplacement->setRootIndex(tileDispIdx); m_ui->listViewDisplacement->setCurrentIndex(m_ui->listViewDisplacement->model()->index(0, 0, m_ui->listViewDisplacement->rootIndex())); + TileSetNode *oldNode = NULL; + TileSetNode *newNode = NULL; + + if( oldIndex.isValid() ) + oldNode = reinterpret_cast< TileSetNode* >( oldIndex.internalPointer() ); + if( newIndex.isValid() ) + newNode = reinterpret_cast< TileSetNode* >( newIndex.internalPointer() ); + + if( newNode != NULL ) + { + QString vegetSet = newNode->vegetSet(); + + if( !vegetSet.isEmpty() ) + m_ui->chooseVegetPushButton->setText( vegetSet ); + else + m_ui->chooseVegetPushButton->setText( "..." ); + } + else + { + m_ui->chooseVegetPushButton->setText( "..." ); + } + //nlinfo("number of rows in displacement: %d", tileDispIdx.model()->rowCount(tileDispIdx)); //m_ui->listView128->reset(); diff --git a/code/studio/src/plugins/tile_editor/tile_editor_main_window.h b/code/studio/src/plugins/tile_editor/tile_editor_main_window.h index 58f546ea9..de7f1d0d0 100644 --- a/code/studio/src/plugins/tile_editor/tile_editor_main_window.h +++ b/code/studio/src/plugins/tile_editor/tile_editor_main_window.h @@ -59,6 +59,9 @@ public Q_SLOTS: void onLandEdit(); void onLandRowChanged( int row ); + void onResetVegetation(); + void onChooseVegetation(); + void changeActiveTileSet(const QModelIndex &newIndex, const QModelIndex &oldIndex); void onZoomFactor(int level); diff --git a/code/studio/src/plugins/tile_editor/tile_editor_main_window.ui b/code/studio/src/plugins/tile_editor/tile_editor_main_window.ui index 07fbf08aa..387d0f23e 100644 --- a/code/studio/src/plugins/tile_editor/tile_editor_main_window.ui +++ b/code/studio/src/plugins/tile_editor/tile_editor_main_window.ui @@ -18,7 +18,7 @@ - 2 + 4 @@ -306,7 +306,7 @@ - + Reset diff --git a/code/studio/src/plugins/tile_editor/tile_item.h b/code/studio/src/plugins/tile_editor/tile_item.h index 56adfa926..e99effc62 100644 --- a/code/studio/src/plugins/tile_editor/tile_item.h +++ b/code/studio/src/plugins/tile_editor/tile_item.h @@ -72,8 +72,12 @@ public: const QString &getTileSetName(){ return m_tileSetName; } void setTileSetName( const QString &name ){ m_tileSetName = name; } + void setVegetSet( const QString &s ){ m_vegetSet = s; } + QString vegetSet() const{ return m_vegetSet; } + private: QString m_tileSetName; + QString m_vegetSet; }; class TileTypeNode : public Node