From bcfcb5bb83d7dee09983100c4cd7a9dbbb180f87 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 4 Aug 2014 21:41:33 +0200 Subject: [PATCH] Oriented stuff. --- .../src/plugins/tile_editor/tile_bank.cpp | 18 ++++++++++++++++++ .../studio/src/plugins/tile_editor/tile_bank.h | 3 +++ .../tile_editor/tile_editor_main_window.cpp | 10 +++++----- .../src/plugins/tile_editor/tile_item.cpp | 1 - .../studio/src/plugins/tile_editor/tile_item.h | 8 -------- .../src/plugins/tile_editor/tile_model.cpp | 10 ++++++++++ .../src/plugins/tile_editor/tile_model.h | 3 +++ 7 files changed, 39 insertions(+), 14 deletions(-) diff --git a/code/studio/src/plugins/tile_editor/tile_bank.cpp b/code/studio/src/plugins/tile_editor/tile_bank.cpp index 8d9c3447c..85e69dd49 100644 --- a/code/studio/src/plugins/tile_editor/tile_bank.cpp +++ b/code/studio/src/plugins/tile_editor/tile_bank.cpp @@ -412,3 +412,21 @@ QString TileBank::getVegetation( int tileSet ) const return set->getTileVegetableDescFileName().c_str(); } +void TileBank::setOriented( int tileSet, bool b ) +{ + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); + if( set == NULL ) + return; + + set->setOriented( b ); +} + +bool TileBank::getOriented( int tileSet ) const +{ + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); + if( set == NULL ) + return false; + + return set->getOriented(); +} + diff --git a/code/studio/src/plugins/tile_editor/tile_bank.h b/code/studio/src/plugins/tile_editor/tile_bank.h index e29f4564c..ce6aa737c 100644 --- a/code/studio/src/plugins/tile_editor/tile_bank.h +++ b/code/studio/src/plugins/tile_editor/tile_bank.h @@ -32,6 +32,9 @@ public: void setVegetation( int tileSet, const QString &vegetation ); QString getVegetation( int tileSet ) const; + + void setOriented( int tileSet, bool b ); + bool getOriented( 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 3331857c1..516db5ce3 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 @@ -590,12 +590,12 @@ void TileEditorMainWindow::onOrientedStateChanged( int state ) if( !idx.isValid() ) return; - TileSetNode *node = reinterpret_cast< TileSetNode* >( idx.internalPointer() ); - + int row = idx.row(); + if( state == Qt::Checked ) - node->setOriented( true ); + m_tileModel->setOriented( row, true ); else - node->setOriented( false ); + m_tileModel->setOriented( row, false ); } void TileEditorMainWindow::onDiffuseToggled( bool b ) @@ -867,7 +867,7 @@ void TileEditorMainWindow::changeActiveTileSet(const QModelIndex &newIndex, cons else m_ui->chooseVegetPushButton->setText( "..." ); - m_ui->orientedCheckBox->setChecked( newNode->isOriented() ); + m_ui->orientedCheckBox->setChecked( m_tileModel->getOriented( newIndex.row() ) ); } else { diff --git a/code/studio/src/plugins/tile_editor/tile_item.cpp b/code/studio/src/plugins/tile_editor/tile_item.cpp index e952d8d20..7c10ef9dc 100644 --- a/code/studio/src/plugins/tile_editor/tile_item.cpp +++ b/code/studio/src/plugins/tile_editor/tile_item.cpp @@ -173,7 +173,6 @@ void Node::clear() TileSetNode::TileSetNode(QString tileSetName, Node *parent) : m_tileSetName(tileSetName) { m_parentItem = parent; - m_oriented = false; } TileSetNode::~TileSetNode() diff --git a/code/studio/src/plugins/tile_editor/tile_item.h b/code/studio/src/plugins/tile_editor/tile_item.h index 2600f47d4..8df33361b 100644 --- a/code/studio/src/plugins/tile_editor/tile_item.h +++ b/code/studio/src/plugins/tile_editor/tile_item.h @@ -79,16 +79,8 @@ 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; } - - bool isOriented() const{ return m_oriented; } - void setOriented( bool b ){ m_oriented = b; } - private: QString m_tileSetName; - QString m_vegetSet; - bool m_oriented; }; class TileTypeNode : public Node diff --git a/code/studio/src/plugins/tile_editor/tile_model.cpp b/code/studio/src/plugins/tile_editor/tile_model.cpp index 09d50cbef..f1372be80 100644 --- a/code/studio/src/plugins/tile_editor/tile_model.cpp +++ b/code/studio/src/plugins/tile_editor/tile_model.cpp @@ -406,6 +406,16 @@ QString TileModel::getVegetation( int tileSet ) const return m_tileBank->getVegetation( tileSet ); } +void TileModel::setOriented( int tileSet, bool b ) +{ + m_tileBank->setOriented( tileSet, b ); +} + +bool TileModel::getOriented( int tileSet ) const +{ + return m_tileBank->getOriented( 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 9d8e00cde..a58b55ce1 100644 --- a/code/studio/src/plugins/tile_editor/tile_model.h +++ b/code/studio/src/plugins/tile_editor/tile_model.h @@ -101,6 +101,9 @@ public: void setVegetation( int tileSet, const QString &vegetation ); QString getVegetation( int tileSet ) const; + void setOriented( int tileSet, bool b ); + bool getOriented( int tileSet ) const; + QString getLastError() const; bool hasError() const;