Clean up project close for connections tab
This commit is contained in:
parent
3bf237ff45
commit
c8434c85b3
5 changed files with 48 additions and 21 deletions
|
@ -22,6 +22,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
|
||||||
- Fix config files being written before the project is opened successfully.
|
- Fix config files being written before the project is opened successfully.
|
||||||
- Fix the map and other project info still displaying if a new project fails to open.
|
- Fix the map and other project info still displaying if a new project fails to open.
|
||||||
- Fix unsaved changes being ignored when quitting (such as with Cmd+Q on macOS).
|
- Fix unsaved changes being ignored when quitting (such as with Cmd+Q on macOS).
|
||||||
|
- New maps are now always inserted in map dropdowns at the correct position, rather than at the bottom of the list until the project is reloaded.
|
||||||
|
|
||||||
## [5.4.1] - 2024-03-21
|
## [5.4.1] - 2024-03-21
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -174,7 +174,8 @@ private:
|
||||||
void clearBorderMetatiles();
|
void clearBorderMetatiles();
|
||||||
void clearCurrentMetatilesSelection();
|
void clearCurrentMetatilesSelection();
|
||||||
void clearMapEvents();
|
void clearMapEvents();
|
||||||
//void clearMapConnections();
|
void clearMapConnections();
|
||||||
|
void clearConnectionMask();
|
||||||
void clearMapBorder();
|
void clearMapBorder();
|
||||||
void clearMapGrid();
|
void clearMapGrid();
|
||||||
void clearWildMonTables();
|
void clearWildMonTables();
|
||||||
|
|
|
@ -1546,16 +1546,13 @@ void Editor::clearMap() {
|
||||||
clearBorderMetatiles();
|
clearBorderMetatiles();
|
||||||
clearCurrentMetatilesSelection();
|
clearCurrentMetatilesSelection();
|
||||||
clearMapEvents();
|
clearMapEvents();
|
||||||
//clearMapConnections();
|
clearMapConnections();
|
||||||
clearMapBorder();
|
clearMapBorder();
|
||||||
clearMapGrid();
|
clearMapGrid();
|
||||||
clearWildMonTables();
|
clearWildMonTables();
|
||||||
|
clearConnectionMask();
|
||||||
|
|
||||||
// TODO: Handle connections after redesign PR.
|
// Clear pointers to objects deleted elsewhere
|
||||||
selected_connection_item = nullptr;
|
|
||||||
connection_items.clear();
|
|
||||||
connection_mask = nullptr;
|
|
||||||
|
|
||||||
current_view = nullptr;
|
current_view = nullptr;
|
||||||
map = nullptr;
|
map = nullptr;
|
||||||
|
|
||||||
|
@ -1804,7 +1801,7 @@ DraggablePixmapItem *Editor::addMapEvent(Event *event) {
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::displayMapConnections() {
|
void Editor::clearMapConnections() {
|
||||||
for (ConnectionPixmapItem* item : connection_items) {
|
for (ConnectionPixmapItem* item : connection_items) {
|
||||||
if (item->scene()) {
|
if (item->scene()) {
|
||||||
item->scene()->removeItem(item);
|
item->scene()->removeItem(item);
|
||||||
|
@ -1813,13 +1810,13 @@ void Editor::displayMapConnections() {
|
||||||
}
|
}
|
||||||
selected_connection_item = nullptr;
|
selected_connection_item = nullptr;
|
||||||
connection_items.clear();
|
connection_items.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Editor::displayMapConnections() {
|
||||||
|
clearMapConnections();
|
||||||
|
|
||||||
const QSignalBlocker blocker1(ui->comboBox_DiveMap);
|
const QSignalBlocker blocker1(ui->comboBox_DiveMap);
|
||||||
const QSignalBlocker blocker2(ui->comboBox_EmergeMap);
|
const QSignalBlocker blocker2(ui->comboBox_EmergeMap);
|
||||||
ui->comboBox_DiveMap->clear();
|
|
||||||
ui->comboBox_EmergeMap->clear();
|
|
||||||
ui->comboBox_DiveMap->addItems(project->mapNames);
|
|
||||||
ui->comboBox_EmergeMap->addItems(project->mapNames);
|
|
||||||
ui->comboBox_DiveMap->setCurrentText("");
|
ui->comboBox_DiveMap->setCurrentText("");
|
||||||
ui->comboBox_EmergeMap->setCurrentText("");
|
ui->comboBox_EmergeMap->setCurrentText("");
|
||||||
|
|
||||||
|
@ -1864,8 +1861,7 @@ void Editor::createConnectionItem(MapConnection* connection) {
|
||||||
addConnectionToList(item);
|
addConnectionToList(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hides connected map tiles that cannot be seen from the current map (beyond BORDER_DISTANCE).
|
void Editor::clearConnectionMask() {
|
||||||
void Editor::maskNonVisibleConnectionTiles() {
|
|
||||||
if (connection_mask) {
|
if (connection_mask) {
|
||||||
if (connection_mask->scene()) {
|
if (connection_mask->scene()) {
|
||||||
connection_mask->scene()->removeItem(connection_mask);
|
connection_mask->scene()->removeItem(connection_mask);
|
||||||
|
@ -1873,6 +1869,11 @@ void Editor::maskNonVisibleConnectionTiles() {
|
||||||
delete connection_mask;
|
delete connection_mask;
|
||||||
connection_mask = nullptr;
|
connection_mask = nullptr;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hides connected map tiles that cannot be seen from the current map (beyond BORDER_DISTANCE).
|
||||||
|
void Editor::maskNonVisibleConnectionTiles() {
|
||||||
|
clearConnectionMask();
|
||||||
|
|
||||||
QPainterPath mask;
|
QPainterPath mask;
|
||||||
mask.addRect(scene->itemsBoundingRect().toRect());
|
mask.addRect(scene->itemsBoundingRect().toRect());
|
||||||
|
|
|
@ -1031,6 +1031,8 @@ bool MainWindow::setProjectUI() {
|
||||||
const QSignalBlocker blocker5(ui->comboBox_Weather);
|
const QSignalBlocker blocker5(ui->comboBox_Weather);
|
||||||
const QSignalBlocker blocker6(ui->comboBox_BattleScene);
|
const QSignalBlocker blocker6(ui->comboBox_BattleScene);
|
||||||
const QSignalBlocker blocker7(ui->comboBox_Type);
|
const QSignalBlocker blocker7(ui->comboBox_Type);
|
||||||
|
const QSignalBlocker blocker8(ui->comboBox_DiveMap);
|
||||||
|
const QSignalBlocker blocker9(ui->comboBox_EmergeMap);
|
||||||
|
|
||||||
// Set up project comboboxes
|
// Set up project comboboxes
|
||||||
ui->comboBox_Song->clear();
|
ui->comboBox_Song->clear();
|
||||||
|
@ -1047,6 +1049,10 @@ bool MainWindow::setProjectUI() {
|
||||||
ui->comboBox_BattleScene->addItems(project->mapBattleScenes);
|
ui->comboBox_BattleScene->addItems(project->mapBattleScenes);
|
||||||
ui->comboBox_Type->clear();
|
ui->comboBox_Type->clear();
|
||||||
ui->comboBox_Type->addItems(project->mapTypes);
|
ui->comboBox_Type->addItems(project->mapTypes);
|
||||||
|
ui->comboBox_DiveMap->clear();
|
||||||
|
ui->comboBox_DiveMap->addItems(project->mapNames);
|
||||||
|
ui->comboBox_EmergeMap->clear();
|
||||||
|
ui->comboBox_EmergeMap->addItems(project->mapNames);
|
||||||
|
|
||||||
sortMapList();
|
sortMapList();
|
||||||
|
|
||||||
|
@ -1088,6 +1094,8 @@ void MainWindow::clearProjectUI() {
|
||||||
const QSignalBlocker blocker5(ui->comboBox_Weather);
|
const QSignalBlocker blocker5(ui->comboBox_Weather);
|
||||||
const QSignalBlocker blocker6(ui->comboBox_BattleScene);
|
const QSignalBlocker blocker6(ui->comboBox_BattleScene);
|
||||||
const QSignalBlocker blocker7(ui->comboBox_Type);
|
const QSignalBlocker blocker7(ui->comboBox_Type);
|
||||||
|
const QSignalBlocker blocker8(ui->comboBox_DiveMap);
|
||||||
|
const QSignalBlocker blocker9(ui->comboBox_EmergeMap);
|
||||||
|
|
||||||
ui->comboBox_Song->clear();
|
ui->comboBox_Song->clear();
|
||||||
ui->comboBox_Location->clear();
|
ui->comboBox_Location->clear();
|
||||||
|
@ -1096,6 +1104,8 @@ void MainWindow::clearProjectUI() {
|
||||||
ui->comboBox_Weather->clear();
|
ui->comboBox_Weather->clear();
|
||||||
ui->comboBox_BattleScene->clear();
|
ui->comboBox_BattleScene->clear();
|
||||||
ui->comboBox_Type->clear();
|
ui->comboBox_Type->clear();
|
||||||
|
ui->comboBox_DiveMap->clear();
|
||||||
|
ui->comboBox_EmergeMap->clear();
|
||||||
|
|
||||||
// Clear map list
|
// Clear map list
|
||||||
mapListModel->clear();
|
mapListModel->clear();
|
||||||
|
@ -1301,6 +1311,16 @@ void MainWindow::onNewMapCreated() {
|
||||||
sortMapList();
|
sortMapList();
|
||||||
setMap(newMapName, true);
|
setMap(newMapName, true);
|
||||||
|
|
||||||
|
// Refresh any combo box that displays map names and persists between maps
|
||||||
|
// (others combo boxes like for warp destinations are repopulated when the map changes).
|
||||||
|
int index = this->editor->project->mapNames.indexOf(newMapName);
|
||||||
|
if (index >= 0) {
|
||||||
|
const QSignalBlocker blocker1(ui->comboBox_DiveMap);
|
||||||
|
const QSignalBlocker blocker2(ui->comboBox_EmergeMap);
|
||||||
|
ui->comboBox_DiveMap->insertItem(index, newMapName);
|
||||||
|
ui->comboBox_EmergeMap->insertItem(index, newMapName);
|
||||||
|
}
|
||||||
|
|
||||||
if (newMap->needsHealLocation) {
|
if (newMap->needsHealLocation) {
|
||||||
addNewEvent(Event::Type::HealLocation);
|
addNewEvent(Event::Type::HealLocation);
|
||||||
editor->project->saveHealLocations(newMap);
|
editor->project->saveHealLocations(newMap);
|
||||||
|
|
|
@ -1819,18 +1819,22 @@ bool Project::readMapGroups() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Map* Project::addNewMapToGroup(QString mapName, int groupNum, Map *newMap, bool existingLayout, bool importedMap) {
|
Map* Project::addNewMapToGroup(QString mapName, int groupNum, Map *newMap, bool existingLayout, bool importedMap) {
|
||||||
mapNames.append(mapName);
|
int mapNamePos = 0;
|
||||||
mapGroups.insert(mapName, groupNum);
|
for (int i = 0; i <= groupNum; i++)
|
||||||
groupedMapNames[groupNum].append(mapName);
|
mapNamePos += this->groupedMapNames.value(i).length();
|
||||||
|
|
||||||
|
this->mapNames.insert(mapNamePos, mapName);
|
||||||
|
this->mapGroups.insert(mapName, groupNum);
|
||||||
|
this->groupedMapNames[groupNum].append(mapName);
|
||||||
|
|
||||||
newMap->isPersistedToFile = false;
|
newMap->isPersistedToFile = false;
|
||||||
newMap->setName(mapName);
|
newMap->setName(mapName);
|
||||||
|
|
||||||
mapConstantsToMapNames.insert(newMap->constantName, newMap->name);
|
this->mapConstantsToMapNames.insert(newMap->constantName, newMap->name);
|
||||||
mapNamesToMapConstants.insert(newMap->name, newMap->constantName);
|
this->mapNamesToMapConstants.insert(newMap->name, newMap->constantName);
|
||||||
if (!existingLayout) {
|
if (!existingLayout) {
|
||||||
mapLayouts.insert(newMap->layoutId, newMap->layout);
|
this->mapLayouts.insert(newMap->layoutId, newMap->layout);
|
||||||
mapLayoutsTable.append(newMap->layoutId);
|
this->mapLayoutsTable.append(newMap->layoutId);
|
||||||
if (!importedMap) {
|
if (!importedMap) {
|
||||||
setNewMapBlockdata(newMap);
|
setNewMapBlockdata(newMap);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue