Show the image that belongs to the channel that is selected.

This commit is contained in:
dfighter1985 2014-07-30 14:28:17 +02:00
parent 2c8b513c97
commit 67ba567c66
5 changed files with 76 additions and 8 deletions

View file

@ -168,6 +168,17 @@ TileEditorMainWindow::TileEditorMainWindow(QWidget *parent)
connect( m_ui->actionOpenTileBank, SIGNAL( triggered() ), this, SLOT( open() ) );
connect( m_ui->orientedCheckBox, SIGNAL( stateChanged( int ) ), this, SLOT( onOrientedStateChanged( int ) ) );
connect( m_ui->diffuse128BT, SIGNAL( toggled( bool ) ), this, SLOT( onDiffuseToggled( bool ) ) );
connect( m_ui->diffuse256BT, SIGNAL( toggled( bool ) ), this, SLOT( onDiffuseToggled( bool ) ) );
connect( m_ui->diffuseTrBT, SIGNAL( toggled( bool ) ), this, SLOT( onDiffuseToggled( bool ) ) );
connect( m_ui->additive128BT, SIGNAL( toggled( bool ) ), this, SLOT( onAdditiveToggled( bool ) ) );
connect( m_ui->additive256BT, SIGNAL( toggled( bool ) ), this, SLOT( onAdditiveToggled( bool ) ) );
connect( m_ui->additiveTrBT, SIGNAL( toggled( bool ) ), this, SLOT( onAdditiveToggled( bool ) ) );
connect( m_ui->alphaTrBT, SIGNAL( toggled( bool ) ), this, SLOT( onAlphaToggled( bool ) ) );
connect( m_ui->tileViewTabWidget, SIGNAL( currentChanged( int ) ), this, SLOT( onTabChanged( int ) ) );
}
TileEditorMainWindow::~TileEditorMainWindow()
@ -601,6 +612,43 @@ void TileEditorMainWindow::onOrientedStateChanged( int state )
node->setOriented( false );
}
void TileEditorMainWindow::onDiffuseToggled( bool b )
{
if( !b )
return;
TileItemNode::setDisplayChannel( TileModel::TileDiffuse );
updateTab();
}
void TileEditorMainWindow::onAdditiveToggled( bool b )
{
if( !b )
return;
TileItemNode::setDisplayChannel( TileModel::TileAdditive );
updateTab();
}
void TileEditorMainWindow::onAlphaToggled( bool b )
{
if( !b )
return;
TileItemNode::setDisplayChannel( TileModel::TileAlpha );
updateTab();
}
void TileEditorMainWindow::onTabChanged( int tab )
{
if( tab == -1 )
return;
m_ui->diffuse128BT->setChecked( true );
m_ui->diffuse256BT->setChecked( true );
m_ui->diffuseTrBT->setChecked( true );
}
void TileEditorMainWindow::onActionAddTile(int tabId)
{
QModelIndex idx = m_ui->tileSetLV->currentIndex();
@ -758,6 +806,11 @@ void TileEditorMainWindow::onTileBankLoaded()
m_ui->landLW->setCurrentRow( 0 );
}
void TileEditorMainWindow::updateTab()
{
m_ui->tileViewTabWidget->currentWidget()->repaint();
}
TileModel* TileEditorMainWindow::createTileModel()
{
QStringList headers;

View file

@ -72,6 +72,12 @@ private Q_SLOTS:
void onOrientedStateChanged( int state );
void onDiffuseToggled( bool b );
void onAdditiveToggled( bool b );
void onAlphaToggled( bool b );
void onTabChanged( int tab );
void changeActiveTileSet(const QModelIndex &newIndex, const QModelIndex &oldIndex);
void onZoomFactor(int level);
@ -85,6 +91,8 @@ private:
void onTileSetRenamed( const QString &oldname, const QString &newname );
void onTileBankLoaded();
void updateTab();
TileModel* createTileModel();
QListView* getListViewByTab( int tab ) const;

View file

@ -57,7 +57,7 @@
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QRadioButton" name="radioButton_5">
<widget class="QRadioButton" name="diffuse128BT">
<property name="text">
<string>Diffuse</string>
</property>
@ -67,7 +67,7 @@
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_6">
<widget class="QRadioButton" name="additive128BT">
<property name="text">
<string>Additive</string>
</property>
@ -115,7 +115,7 @@
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QRadioButton" name="radioButton_10">
<widget class="QRadioButton" name="diffuse256BT">
<property name="text">
<string>Diffuse</string>
</property>
@ -128,7 +128,7 @@
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_9">
<widget class="QRadioButton" name="additive256BT">
<property name="text">
<string>Additive</string>
</property>
@ -185,7 +185,7 @@
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QRadioButton" name="radioButton_13">
<widget class="QRadioButton" name="diffuseTrBT">
<property name="text">
<string>Diffuse</string>
</property>
@ -195,14 +195,14 @@
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_12">
<widget class="QRadioButton" name="additiveTrBT">
<property name="text">
<string>Additive</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_11">
<widget class="QRadioButton" name="alphaTrBT">
<property name="text">
<string>Alpha</string>
</property>

View file

@ -264,6 +264,8 @@ void TileTypeNode::reindex()
///////////////////////////////////////////////////
TileModel::TTileChannel TileItemNode::s_displayChannel = TileModel::TileDiffuse;
TileItemNode::TileItemNode(int tileId, TileModel::TTileChannel channel, QString filename, Node *parent) : m_tileId(tileId)
{
m_tileFilename[channel] = filename;
@ -294,7 +296,7 @@ QString TileItemNode::getTileFilename(TileModel::TTileChannel channel)
QVariant TileItemNode::data(int column, int role) const
{
// find some way to know which file/bitmap to display
QString tileFilename = m_tileFilename[TileModel::TileDiffuse];
QString tileFilename = m_tileFilename[s_displayChannel];
if(role == TileModel::TilePixmapRole || role == Qt::DecorationRole)
{

View file

@ -115,10 +115,15 @@ public:
QString getTileFilename(TileModel::TTileChannel channel);
void setId( int id ){ m_tileId = id; }
int id() const{ return m_tileId; }
static void setDisplayChannel( TileModel::TTileChannel channel ){ s_displayChannel = channel; }
private:
int m_tileId;
QMap<TileModel::TTileChannel, QString> m_tileFilename;
QMap<TileModel::TTileChannel, TileWidget*> m_tileWidget;
static TileModel::TTileChannel s_displayChannel;
};
#endif // TILE_ITEM_H