diff --git a/include/ui/regionmapeditor.h b/include/ui/regionmapeditor.h index b057adaf..ee364b83 100644 --- a/include/ui/regionmapeditor.h +++ b/include/ui/regionmapeditor.h @@ -29,6 +29,7 @@ public: void loadRegionMapData(); void loadCityMaps(); + void setCurrentSquareOptions(); void onRegionMapTileSelectorSelectedTileChanged(unsigned id); void onCityMapTileSelectorSelectedTileChanged(unsigned id); diff --git a/src/core/regionmap.cpp b/src/core/regionmap.cpp index 3f376102..4368c9b3 100644 --- a/src/core/regionmap.cpp +++ b/src/core/regionmap.cpp @@ -174,10 +174,10 @@ void RegionMap::saveOptions(int id, QString sec, QString name, int x, int y) { if (!name.isEmpty()) { this->map_squares[index].map_name = name; this->project->mapSecToMapHoverName->insert(sec, name); + QString sName = fix_case(sec); + sMapNamesMap.insert(sName, name); if (!mapSecToMapEntry.keys().contains(sec)) { - QString sName = fix_case(sec); sMapNames.append(sName); - sMapNamesMap.insert(sName, name); struct RegionMapEntry entry = {x, y, 1, 1, sName}; mapSecToMapEntry.insert(sec, entry); } diff --git a/src/ui/regionmapeditor.cpp b/src/ui/regionmapeditor.cpp index b3e7de19..9efbf014 100644 --- a/src/ui/regionmapeditor.cpp +++ b/src/ui/regionmapeditor.cpp @@ -39,14 +39,8 @@ RegionMapEditor::~RegionMapEditor() } void RegionMapEditor::on_action_RegionMap_Save_triggered() { + setCurrentSquareOptions(); if (project && region_map) { - this->region_map->saveOptions( - this->region_map_layout_item->selectedTile, - this->ui->comboBox_RM_ConnectedMap->currentText(), - this->ui->lineEdit_RM_MapName->text(), - this->ui->spinBox_RM_Options_x->value(), - this->ui->spinBox_RM_Options_y->value() - ); this->region_map->save(); this->city_map_item->save(); this->currIndex = this->region_map_layout_item->highlightedTile; @@ -56,6 +50,18 @@ void RegionMapEditor::on_action_RegionMap_Save_triggered() { this->hasUnsavedChanges = false; } +void RegionMapEditor::setCurrentSquareOptions() { + if (project && region_map) { + this->region_map->saveOptions( + this->currIndex, + this->ui->comboBox_RM_ConnectedMap->currentText(), + this->ui->lineEdit_RM_MapName->text(), + this->ui->spinBox_RM_Options_x->value(), + this->ui->spinBox_RM_Options_y->value() + ); + } +} + void RegionMapEditor::loadRegionMapData() { this->region_map->init(project); this->currIndex = this->region_map->width() * this->region_map->padTop + this->region_map->padLeft; @@ -154,7 +160,7 @@ void RegionMapEditor::displayRegionMapLayoutOptions() { this->region_map->height() - this->region_map->padTop - this->region_map->padBottom - 1 ); - updateRegionMapLayoutOptions(currIndex); + updateRegionMapLayoutOptions(this->currIndex); // TODO: implement when the code is decompiled this->ui->label_RM_CityMap->setVisible(false); @@ -296,6 +302,7 @@ void RegionMapEditor::onRegionMapTileSelectorHoveredTileCleared() { } void RegionMapEditor::onRegionMapLayoutSelectedTileChanged(int index) { + setCurrentSquareOptions(); QString message = QString(); this->currIndex = index; this->region_map_layout_item->highlightedTile = index; @@ -306,6 +313,7 @@ void RegionMapEditor::onRegionMapLayoutSelectedTileChanged(int index) { this->ui->statusbar->showMessage(message); updateRegionMapLayoutOptions(index); + this->region_map_layout_item->draw(); } void RegionMapEditor::onRegionMapLayoutHoveredTileChanged(int index) { @@ -348,6 +356,7 @@ void RegionMapEditor::mouseEvent_region_map(QGraphicsSceneMouseEvent *event, Reg //} else if (event->buttons() & Qt::MiddleButton) {// TODO } else { item->paint(event); + this->region_map_layout_item->draw(); this->hasUnsavedChanges = true; if (event->type() == QEvent::GraphicsSceneMouseRelease) { RegionMapHistoryItem *current = history.current(); diff --git a/src/ui/regionmaplayoutpixmapitem.cpp b/src/ui/regionmaplayoutpixmapitem.cpp index 82edc5ba..f9f6c2fc 100644 --- a/src/ui/regionmaplayoutpixmapitem.cpp +++ b/src/ui/regionmaplayoutpixmapitem.cpp @@ -10,11 +10,7 @@ void RegionMapLayoutPixmapItem::draw() { QImage bottom_img = this->tile_selector->tileImg(region_map->map_squares[i].tile_img_id); QImage top_img(8, 8, QImage::Format_RGBA8888); if (region_map->map_squares[i].has_map) { - if (i == highlightedTile) { - top_img.fill(Qt::red); - } else { - top_img.fill(Qt::gray); - } + top_img.fill(Qt::gray); } else { top_img.fill(Qt::black); } @@ -55,8 +51,8 @@ void RegionMapLayoutPixmapItem::select(int index) { void RegionMapLayoutPixmapItem::highlight(int x, int y, int red) { this->highlightedTile = red; - draw(); SelectablePixmapItem::select(x + this->region_map->padLeft, y + this->region_map->padTop, 0, 0); + draw(); } void RegionMapLayoutPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {