Implemented choosing / resetting vegetset for tile sets.

--HG--
branch : gsoc2014-dfighter
This commit is contained in:
dfighter1985 2014-07-24 23:31:37 +02:00
parent 2993c88a5d
commit df7307583b
4 changed files with 77 additions and 2 deletions

View file

@ -96,6 +96,9 @@ TileEditorMainWindow::TileEditorMainWindow(QWidget *parent)
connect(m_ui->landEditTB, SIGNAL(clicked()), this, SLOT(onLandEdit())); connect(m_ui->landEditTB, SIGNAL(clicked()), this, SLOT(onLandEdit()));
connect(m_ui->landLW, SIGNAL(currentRowChanged(int)), this, SLOT(onLandRowChanged(int))); connect(m_ui->landLW, SIGNAL(currentRowChanged(int)), this, SLOT(onLandRowChanged(int)));
connect(m_ui->chooseVegetPushButton, SIGNAL(clicked()), this, SLOT(onChooseVegetation()));
connect(m_ui->resetVegetPushButton, SIGNAL(clicked()), this, SLOT(onResetVegetation()));
// 128x128 List View // 128x128 List View
//m_ui->listView128->setItemDelegate(m_tileItemDelegate); //m_ui->listView128->setItemDelegate(m_tileItemDelegate);
m_ui->listView128->addAction(m_ui->actionAddTile); m_ui->listView128->addAction(m_ui->actionAddTile);
@ -421,6 +424,8 @@ void TileEditorMainWindow::onLandEdit()
void TileEditorMainWindow::onLandRowChanged( int row ) void TileEditorMainWindow::onLandRowChanged( int row )
{ {
m_ui->chooseVegetPushButton->setText( "..." );
if( row == -1 ) if( row == -1 )
{ {
disconnect( m_ui->tileSetLV->selectionModel(), SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ), disconnect( m_ui->tileSetLV->selectionModel(), SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
@ -456,6 +461,47 @@ void TileEditorMainWindow::onLandRowChanged( int row )
m_ui->tileSetLV->reset(); m_ui->tileSetLV->reset();
} }
void TileEditorMainWindow::onChooseVegetation()
{
QModelIndex idx = m_ui->tileSetLV->currentIndex();
if( !idx.isValid() )
{
QMessageBox::information( this,
tr("Choosing a vegetation set"),
tr("You need to select a tileset before choosing a vegetation set!") );
return;
}
QString vegetSet = QFileDialog::getOpenFileName( this,
tr( "Choose vegetation set" ),
"",
tr( "Nel vegetset files (*.vegetset)" ) );
if( vegetSet.isEmpty() )
return;
TileSetNode *node = reinterpret_cast< TileSetNode* >( idx.internalPointer() );
node->setVegetSet( vegetSet );
m_ui->chooseVegetPushButton->setText( vegetSet );
}
void TileEditorMainWindow::onResetVegetation()
{
QModelIndex idx = m_ui->tileSetLV->currentIndex();
if( !idx.isValid() )
{
QMessageBox::information( this,
tr("Resetting a vegetation set"),
tr("You need to select a tileset before resetting a vegetation set!") );
return;
}
m_ui->chooseVegetPushButton->setText( "..." );
TileSetNode *node = reinterpret_cast< TileSetNode* >( idx.internalPointer() );
node->setVegetSet( "" );
}
void TileEditorMainWindow::onActionAddTile(int tabId) void TileEditorMainWindow::onActionAddTile(int tabId)
{ {
QFileDialog::Options options; QFileDialog::Options options;
@ -493,6 +539,28 @@ void TileEditorMainWindow::changeActiveTileSet(const QModelIndex &newIndex, cons
m_ui->listViewDisplacement->setRootIndex(tileDispIdx); m_ui->listViewDisplacement->setRootIndex(tileDispIdx);
m_ui->listViewDisplacement->setCurrentIndex(m_ui->listViewDisplacement->model()->index(0, 0, m_ui->listViewDisplacement->rootIndex())); m_ui->listViewDisplacement->setCurrentIndex(m_ui->listViewDisplacement->model()->index(0, 0, m_ui->listViewDisplacement->rootIndex()));
TileSetNode *oldNode = NULL;
TileSetNode *newNode = NULL;
if( oldIndex.isValid() )
oldNode = reinterpret_cast< TileSetNode* >( oldIndex.internalPointer() );
if( newIndex.isValid() )
newNode = reinterpret_cast< TileSetNode* >( newIndex.internalPointer() );
if( newNode != NULL )
{
QString vegetSet = newNode->vegetSet();
if( !vegetSet.isEmpty() )
m_ui->chooseVegetPushButton->setText( vegetSet );
else
m_ui->chooseVegetPushButton->setText( "..." );
}
else
{
m_ui->chooseVegetPushButton->setText( "..." );
}
//nlinfo("number of rows in displacement: %d", tileDispIdx.model()->rowCount(tileDispIdx)); //nlinfo("number of rows in displacement: %d", tileDispIdx.model()->rowCount(tileDispIdx));
//m_ui->listView128->reset(); //m_ui->listView128->reset();

View file

@ -59,6 +59,9 @@ public Q_SLOTS:
void onLandEdit(); void onLandEdit();
void onLandRowChanged( int row ); void onLandRowChanged( int row );
void onResetVegetation();
void onChooseVegetation();
void changeActiveTileSet(const QModelIndex &newIndex, const QModelIndex &oldIndex); void changeActiveTileSet(const QModelIndex &newIndex, const QModelIndex &oldIndex);
void onZoomFactor(int level); void onZoomFactor(int level);

View file

@ -18,7 +18,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QTabWidget" name="tileViewTabWidget"> <widget class="QTabWidget" name="tileViewTabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>2</number> <number>4</number>
</property> </property>
<widget class="QWidget" name="tab128"> <widget class="QWidget" name="tab128">
<attribute name="title"> <attribute name="title">
@ -306,7 +306,7 @@
<item row="1" column="1"> <item row="1" column="1">
<widget class="QPushButton" name="resetVegetPushButton"> <widget class="QPushButton" name="resetVegetPushButton">
<property name="text"> <property name="text">
<string/> <string>Reset</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset> <iconset>

View file

@ -72,8 +72,12 @@ public:
const QString &getTileSetName(){ return m_tileSetName; } const QString &getTileSetName(){ return m_tileSetName; }
void setTileSetName( const QString &name ){ m_tileSetName = name; } void setTileSetName( const QString &name ){ m_tileSetName = name; }
void setVegetSet( const QString &s ){ m_vegetSet = s; }
QString vegetSet() const{ return m_vegetSet; }
private: private:
QString m_tileSetName; QString m_tileSetName;
QString m_vegetSet;
}; };
class TileTypeNode : public Node class TileTypeNode : public Node