From 1e9e492f0f98600b5adce48d4cbb587fe30e1bdc Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 5 Aug 2014 13:42:56 +0200 Subject: [PATCH] Rotation is now set in the tilebank wrapper and applied when replacing a tile. --- .../src/plugins/tile_editor/tile_bank.cpp | 18 +++++++++++++++++- .../studio/src/plugins/tile_editor/tile_bank.h | 3 +++ .../tile_editor/tile_editor_main_window.cpp | 2 +- .../src/plugins/tile_editor/tile_item.cpp | 1 - .../studio/src/plugins/tile_editor/tile_item.h | 2 -- .../src/plugins/tile_editor/tile_model.cpp | 5 +++++ .../src/plugins/tile_editor/tile_model.h | 2 ++ 7 files changed, 28 insertions(+), 5 deletions(-) diff --git a/code/studio/src/plugins/tile_editor/tile_bank.cpp b/code/studio/src/plugins/tile_editor/tile_bank.cpp index 47e26511f..9a4d15469 100644 --- a/code/studio/src/plugins/tile_editor/tile_bank.cpp +++ b/code/studio/src/plugins/tile_editor/tile_bank.cpp @@ -198,6 +198,7 @@ TileBank::TileBank() { m_pvt = new TileBankPvt(); resetError(); + m_rotation = 0; } TileBank::~TileBank() @@ -378,6 +379,16 @@ bool TileBank::setTile( int tileset, int tile, const QString &name, const QVaria NL3D::CTileBorder border; m_pvt->buildBorder( pm, border ); + if( ( type == TileConstants::TileTransition ) && ( channel == TileConstants::TileAlpha ) ) + { + int rotBits = m_rotation; + while( rotBits > 0 ) + { + border.rotate(); + rotBits--; + } + } + QString msg; NL3D::CTileSet::TError error = m_pvt->checkTile( set, tile, type, border, channelToTBitmap( channel ), msg ); @@ -387,7 +398,7 @@ bool TileBank::setTile( int tileset, int tile, const QString &name, const QVaria if( error == NL3D::CTileSet::addFirstA128128 ) set->setBorder( channelToTBitmap( channel ), border ); - m_pvt->setTile( set, tile, 0 /* rotation */, name, channelToTBitmap( channel ), type, border ); + m_pvt->setTile( set, tile, m_rotation, name, channelToTBitmap( channel ), type, border ); return true; } @@ -618,6 +629,11 @@ QString TileBank::getTexturePath() const return m_pvt->m_bank.getAbsPath().c_str(); } +void TileBank::setRotation( int rotation ) +{ + m_rotation = rotation; +} + void TileBank::serial( NLMISC::IStream &f ) { m_pvt->m_bank.serial( f ); diff --git a/code/studio/src/plugins/tile_editor/tile_bank.h b/code/studio/src/plugins/tile_editor/tile_bank.h index 55901584a..a4620ad41 100644 --- a/code/studio/src/plugins/tile_editor/tile_bank.h +++ b/code/studio/src/plugins/tile_editor/tile_bank.h @@ -74,6 +74,8 @@ public: void setTexturePath( const QString &path ); QString getTexturePath() const; + void setRotation( int rotation ); + void serial( NLMISC::IStream &f ); bool hasError() const{ return m_hasError; } @@ -93,6 +95,7 @@ private: TileBankPvt *m_pvt; QString m_lastError; bool m_hasError; + int m_rotation; }; #endif 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 86953f6a7..0341502d5 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 @@ -335,7 +335,7 @@ void TileEditorMainWindow::onZoomFactor(int level) void TileEditorMainWindow::onRotate( int id ) { - TileItemNode::setAlphaRot( id * 90 ); + m_tileModel->setAlphaRot( id ); } void TileEditorMainWindow::onActionAddTile(bool triggered) diff --git a/code/studio/src/plugins/tile_editor/tile_item.cpp b/code/studio/src/plugins/tile_editor/tile_item.cpp index 7d339b1db..f39ba87dc 100644 --- a/code/studio/src/plugins/tile_editor/tile_item.cpp +++ b/code/studio/src/plugins/tile_editor/tile_item.cpp @@ -298,7 +298,6 @@ private: }; TileConstants::TTileChannel TileItemNode::s_displayChannel = TileConstants::TileDiffuse; -int TileItemNode::s_alphaRot = 0; TileItemNode::TileItemNode( TileConstants::TNodeTileType type, int tileId, Node *parent ) { diff --git a/code/studio/src/plugins/tile_editor/tile_item.h b/code/studio/src/plugins/tile_editor/tile_item.h index 85da09c4f..7af553c8e 100644 --- a/code/studio/src/plugins/tile_editor/tile_item.h +++ b/code/studio/src/plugins/tile_editor/tile_item.h @@ -117,7 +117,6 @@ public: static void setDisplayChannel( TileConstants::TTileChannel channel ){ s_displayChannel = channel; } static TileConstants::TTileChannel displayChannel(){ return s_displayChannel; } - static void setAlphaRot( int rot ){ s_alphaRot = rot; } QVariant pixmap( TileConstants::TTileChannel channel ) const; @@ -126,7 +125,6 @@ private: QMap m_tileWidget; static TileConstants::TTileChannel s_displayChannel; - static int s_alphaRot; int m_id; diff --git a/code/studio/src/plugins/tile_editor/tile_model.cpp b/code/studio/src/plugins/tile_editor/tile_model.cpp index f4b9dfa15..2af4c6a84 100644 --- a/code/studio/src/plugins/tile_editor/tile_model.cpp +++ b/code/studio/src/plugins/tile_editor/tile_model.cpp @@ -472,6 +472,11 @@ QString TileModel::getTexturePath() const return m_tileBank->getTexturePath(); } +void TileModel::setAlphaRot( int rotation ) +{ + m_tileBank->setRotation( rotation ); +} + 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 dafbf09f8..c6bfc8788 100644 --- a/code/studio/src/plugins/tile_editor/tile_model.h +++ b/code/studio/src/plugins/tile_editor/tile_model.h @@ -117,6 +117,8 @@ public: void setTexturePath( const QString &path ); QString getTexturePath() const; + void setAlphaRot( int rotation ); + void serial( NLMISC::IStream &f ); QString getLastError() const;