Implemented tile image replace.

This commit is contained in:
dfighter1985 2014-07-26 02:24:32 +02:00
parent 10f757286b
commit 4c72aa85cf
2 changed files with 26 additions and 0 deletions

View file

@ -220,6 +220,7 @@ void TileEditorMainWindow::onActionDeleteTile(bool triggered)
void TileEditorMainWindow::onActionReplaceImage(bool triggered) void TileEditorMainWindow::onActionReplaceImage(bool triggered)
{ {
onActionReplaceImage(m_ui->tileViewTabWidget->currentIndex());
} }
void TileEditorMainWindow::onActionDeleteImage(bool triggered) void TileEditorMainWindow::onActionDeleteImage(bool triggered)
@ -619,6 +620,30 @@ void TileEditorMainWindow::onActionDeleteImage( int tabId )
n->setTileFilename( TileModel::TileDiffuse, "" ); n->setTileFilename( TileModel::TileDiffuse, "" );
} }
void TileEditorMainWindow::onActionReplaceImage( int tabId )
{
QListView *lv = getListViewByTab( tabId );
QModelIndex idx = lv->currentIndex();
if( !idx.isValid() )
{
QMessageBox::information( this,
tr( "Replacing tile image" ),
tr( "No tile selected!" ) );
return;
}
QString fileName = QFileDialog::getOpenFileName( this,
tr( "Select tile image" ),
"",
tr( "PNG files (*.png)" ) );
if( fileName.isEmpty() )
return;
TileItemNode *n = reinterpret_cast< TileItemNode* >( idx.internalPointer() );
n->setTileFilename( TileModel::TileDiffuse, fileName );
}
TileModel* TileEditorMainWindow::createTileModel() TileModel* TileEditorMainWindow::createTileModel()
{ {
QStringList headers; QStringList headers;

View file

@ -71,6 +71,7 @@ private:
void onActionAddTile(int tabId); void onActionAddTile(int tabId);
void onActionDeleteTile(int tabId); void onActionDeleteTile(int tabId);
void onActionDeleteImage(int tabId); void onActionDeleteImage(int tabId);
void onActionReplaceImage(int tabId);
TileModel* createTileModel(); TileModel* createTileModel();