Skip to content

Commit

Permalink
Fix issues with tile name edition
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisD3D committed Mar 16, 2024
1 parent 14bc397 commit 91812fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/screens/editorscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,21 @@ void EditorScreen::placeTileAtPosition(const Position pos, const bool is_right_c
gameArea->update();
}

void EditorScreen::onTileSelectorItemDoubleClicked(QTableWidgetItem *item) {
void EditorScreen::onTileSelectorItemDoubleClicked(const QTableWidgetItem *item) {
lastEditedItemText = item->text();
}

void EditorScreen::onTileSelectorItemChanged(QTableWidgetItem *item) {
void EditorScreen::onTileSelectorItemChanged(const QTableWidgetItem *item) {
if (lastEditedItemText.isEmpty())
return;

const QString newText = item->text();
if (map.getTypes().contains(newText)) {
QMessageBox::warning(this, "Invalid Input", "A tile type with the name " + newText + " already exists.");
tileTypeTable->item(item->row(), 0)->setText(lastEditedItemText);
lastEditedItemText.clear();
return;
}

map.setNewTypeName(lastEditedItemText, newText);

Expand Down
4 changes: 2 additions & 2 deletions src/screens/editorscreen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ class EditorScreen final : public QWidget {
public slots:
void onTileSelectorIconDoubleClicked(QTableWidgetItem *item);

void onTileSelectorItemDoubleClicked(QTableWidgetItem *item);
void onTileSelectorItemDoubleClicked(const QTableWidgetItem *item);

void onTileSelectorItemChanged(QTableWidgetItem *item);
void onTileSelectorItemChanged(const QTableWidgetItem *item);

void showTileSelectorContextMenu(const QPoint &pos);

Expand Down

0 comments on commit 91812fa

Please sign in to comment.