From 688f6de0909cdd8c07ed7a683d4628d8c1bf7917 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 4 Aug 2014 21:33:11 +0200 Subject: [PATCH] Vegetation set stuff. --HG-- branch : gsoc2014-dfighter --- .../src/plugins/tile_editor/tile_bank.cpp | 19 +++++++++++++++++++ .../src/plugins/tile_editor/tile_bank.h | 3 +++ .../tile_editor/tile_editor_main_window.cpp | 10 ++++------ .../src/plugins/tile_editor/tile_model.cpp | 10 ++++++++++ .../src/plugins/tile_editor/tile_model.h | 3 +++ 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/code/studio/src/plugins/tile_editor/tile_bank.cpp b/code/studio/src/plugins/tile_editor/tile_bank.cpp index a44158259..8d9c3447c 100644 --- a/code/studio/src/plugins/tile_editor/tile_bank.cpp +++ b/code/studio/src/plugins/tile_editor/tile_bank.cpp @@ -393,3 +393,22 @@ void TileBank::clearImage( int ts, int type, int tile, TileConstants::TTileChann } +void TileBank::setVegetation( int tileSet, const QString &vegetation ) +{ + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); + if( set == NULL ) + return; + + set->setTileVegetableDescFileName( vegetation.toUtf8().constData() ); +} + + +QString TileBank::getVegetation( int tileSet ) const +{ + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); + if( set == NULL ) + return ""; + + return set->getTileVegetableDescFileName().c_str(); +} + diff --git a/code/studio/src/plugins/tile_editor/tile_bank.h b/code/studio/src/plugins/tile_editor/tile_bank.h index d81ae694b..e29f4564c 100644 --- a/code/studio/src/plugins/tile_editor/tile_bank.h +++ b/code/studio/src/plugins/tile_editor/tile_bank.h @@ -29,6 +29,9 @@ public: bool setTile( int tileset, int tile, const QString &name, const QVariant &pixmap, TileConstants::TTileChannel channel, TileConstants::TNodeTileType type ); void replaceImage( int ts, int type, int tile, TileConstants::TTileChannel channel, const QString &name, const QVariant &pixmap ); void clearImage( int ts, int type, int tile, TileConstants::TTileChannel channel ); + + void setVegetation( int tileSet, const QString &vegetation ); + QString getVegetation( int tileSet ) const; bool hasError() const{ return m_hasError; } QString getLastError() const{ return m_lastError; } 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 dffa7a61a..3331857c1 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 @@ -542,8 +542,7 @@ void TileEditorMainWindow::onChooseVegetation() if( vegetSet.isEmpty() ) return; - TileSetNode *node = reinterpret_cast< TileSetNode* >( idx.internalPointer() ); - node->setVegetSet( vegetSet ); + m_tileModel->setVegetation( idx.row(), vegetSet ); m_ui->chooseVegetPushButton->setText( vegetSet ); } @@ -560,8 +559,7 @@ void TileEditorMainWindow::onResetVegetation() } m_ui->chooseVegetPushButton->setText( "..." ); - TileSetNode *node = reinterpret_cast< TileSetNode* >( idx.internalPointer() ); - node->setVegetSet( "" ); + m_tileModel->setVegetation( idx.row(), "" ); } void TileEditorMainWindow::onChooseTexturePath() @@ -860,9 +858,9 @@ void TileEditorMainWindow::changeActiveTileSet(const QModelIndex &newIndex, cons if( newIndex.isValid() ) newNode = reinterpret_cast< TileSetNode* >( newIndex.internalPointer() ); - if( newNode != NULL ) + if( newIndex.isValid() ) { - QString vegetSet = newNode->vegetSet(); + QString vegetSet = m_tileModel->getVegetation( newIndex.row() ); if( !vegetSet.isEmpty() ) m_ui->chooseVegetPushButton->setText( vegetSet ); diff --git a/code/studio/src/plugins/tile_editor/tile_model.cpp b/code/studio/src/plugins/tile_editor/tile_model.cpp index 862b03bce..09d50cbef 100644 --- a/code/studio/src/plugins/tile_editor/tile_model.cpp +++ b/code/studio/src/plugins/tile_editor/tile_model.cpp @@ -396,6 +396,16 @@ void TileModel::clearImage( int ts, int type, int tile, TileConstants::TTileChan m_tileBank->clearImage( ts, type, tile, channel ); } +void TileModel::setVegetation( int tileSet, const QString &vegetation ) +{ + m_tileBank->setVegetation( tileSet, vegetation ); +} + +QString TileModel::getVegetation( int tileSet ) const +{ + return m_tileBank->getVegetation( tileSet ); +} + QString TileModel::getLastError() const{ return m_tileBank->getLastError(); } diff --git a/code/studio/src/plugins/tile_editor/tile_model.h b/code/studio/src/plugins/tile_editor/tile_model.h index d2776bc86..9d8e00cde 100644 --- a/code/studio/src/plugins/tile_editor/tile_model.h +++ b/code/studio/src/plugins/tile_editor/tile_model.h @@ -98,6 +98,9 @@ public: bool replaceImage( int ts, int type, int tile, TileConstants::TTileChannel channel, const QString &name ); void clearImage( int ts, int type, int tile, TileConstants::TTileChannel channel ); + void setVegetation( int tileSet, const QString &vegetation ); + QString getVegetation( int tileSet ) const; + QString getLastError() const; bool hasError() const;