From 02ccd3b1c16d63ce15ea617176e04810fa502f0c Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 24 Jul 2014 16:18:01 +0200 Subject: [PATCH] Implemented land adding. --HG-- branch : gsoc2014-dfighter --- .../tile_editor/tile_editor_main_window.cpp | 26 +++++++++++++++++++ .../tile_editor/tile_editor_main_window.h | 4 +++ 2 files changed, 30 insertions(+) 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 88090de47..1a7dc164b 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 @@ -94,6 +94,8 @@ TileEditorMainWindow::TileEditorMainWindow(QWidget *parent) connect(m_ui->tileSetUpTB, SIGNAL(clicked()), this, SLOT(onTileSetUp())); connect(m_ui->tileSetDownTB, SIGNAL(clicked()), this, SLOT(onTileSetDown())); + connect(m_ui->landAddTB, SIGNAL(clicked()), this, SLOT(onLandAdd())); + connect(m_ui->tileSetLV->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(changeActiveTileSet(const QModelIndex &, const QModelIndex &))); @@ -333,6 +335,30 @@ void TileEditorMainWindow::onTileSetDown() m_ui->tileSetLV->setCurrentIndex( model->index( r + 1, 0 ) ); } +void TileEditorMainWindow::onLandAdd() +{ + QString name = QInputDialog::getText( this, + tr("Adding new land"), + tr("Please specify the new land's name") ); + + if( name.isEmpty() ) + return; + + for( int i = 0; i < m_ui->landLW->count(); i++ ) + { + QListWidgetItem *item = m_ui->landLW->item( i ); + if( item->text() == name ) + { + QMessageBox::information( this, + tr( "Error adding new land" ), + tr( "A land with that name already exists." ) ); + return; + } + } + + m_ui->landLW->addItem( name ); +} + void TileEditorMainWindow::onActionAddTile(int tabId) { QFileDialog::Options options; diff --git a/code/studio/src/plugins/tile_editor/tile_editor_main_window.h b/code/studio/src/plugins/tile_editor/tile_editor_main_window.h index c830666a0..6d1aa82c7 100644 --- a/code/studio/src/plugins/tile_editor/tile_editor_main_window.h +++ b/code/studio/src/plugins/tile_editor/tile_editor_main_window.h @@ -47,11 +47,15 @@ public Q_SLOTS: void onActionDeleteTile(bool triggered); void onActionReplaceImage(bool triggered); void onActionDeleteImage(bool triggered); + void onTileSetAdd(); void onTileSetDelete(); void onTileSetEdit(); void onTileSetUp(); void onTileSetDown(); + + void onLandAdd(); + void changeActiveTileSet(const QModelIndex &newIndex, const QModelIndex &oldIndex); void onZoomFactor(int level);