diff --git a/client/citydlg.cpp b/client/citydlg.cpp index 0502b21dca..523b87f46d 100644 --- a/client/citydlg.cpp +++ b/client/citydlg.cpp @@ -806,7 +806,7 @@ void unit_list_item::activate_and_close_dialog() if (can_issue_orders()) { unit_focus_set(m_unit); queen()->city_overlay->dont_focus = true; - popdown_all_city_dialogs(); + popdown_city_dialog(); } } @@ -2074,7 +2074,7 @@ void city_dialog::refresh() update_cma_tab(); update_disabled(); } else { - destroy_city_dialog(); + popdown_city_dialog(); } update_map_canvas_visible(); @@ -2799,31 +2799,15 @@ void real_city_dialog_popup(struct city *pcity) } /** - Closes city dialog + * Closes the city overlay. */ -void destroy_city_dialog() +void popdown_city_dialog() { - // Only tyrans destroy cities instead building - if (king()->current_page() >= PAGE_GAME) { + if (queen()) { queen()->city_overlay->hide(); } } -/** - Close the dialog for the given city. - */ -void popdown_city_dialog(struct city *pcity) -{ - Q_UNUSED(pcity) - - popdown_all_city_dialogs(); // We only ever have one city dialog -} - -/** - Close the dialogs for all cities. - */ -void popdown_all_city_dialogs() { queen()->city_overlay->hide(); } - /** Refresh (update) all data for the given city's dialog. */ diff --git a/client/client_main.cpp b/client/client_main.cpp index 1bd1525986..93e998e4ed 100644 --- a/client/client_main.cpp +++ b/client/client_main.cpp @@ -798,7 +798,7 @@ void set_client_state(enum client_states newstate) break; case C_S_DISCONNECTED: - popdown_all_city_dialogs(); + popdown_city_dialog(); close_all_diplomacy_dialogs(); popdown_all_game_dialogs(); meswin_clear_older(MESWIN_CLEAR_ALL, 0); @@ -818,7 +818,7 @@ void set_client_state(enum client_states newstate) break; case C_S_PREPARING: - popdown_all_city_dialogs(); + popdown_city_dialog(); close_all_diplomacy_dialogs(); popdown_all_game_dialogs(); meswin_clear_older(MESWIN_CLEAR_ALL, 0); @@ -892,7 +892,7 @@ void set_client_state(enum client_states newstate) } city_list_iterate_end; } - popdown_all_city_dialogs(); + popdown_city_dialog(); close_all_diplomacy_dialogs(); popdown_all_game_dialogs(); unit_focus_set(nullptr); diff --git a/client/climisc.cpp b/client/climisc.cpp index b273156745..878d08f81b 100644 --- a/client/climisc.cpp +++ b/client/climisc.cpp @@ -154,7 +154,10 @@ void client_remove_city(struct city *pcity) // nothing yet } - popdown_city_dialog(pcity); + if (auto dialog = is_any_city_dialog_open(); + dialog && pcity->id == dialog->id) { + popdown_city_dialog(); + } game_remove_city(&wld, pcity); city_report_dialog_update(); refresh_city_mapcanvas(&old_city, ptile, true, false); diff --git a/client/mapview.cpp b/client/mapview.cpp index 512dcbeb15..2a6f5a09a0 100644 --- a/client/mapview.cpp +++ b/client/mapview.cpp @@ -612,7 +612,7 @@ void tileset_changed(void) } update_unit_info_label(get_units_in_focus()); - destroy_city_dialog(); + popdown_city_dialog(); // Update science report if open if (queen()->isRepoDlgOpen(QStringLiteral("SCI"))) { i = queen()->gimmeIndexOf(QStringLiteral("SCI")); diff --git a/client/packhand.cpp b/client/packhand.cpp index 7154491ac0..5860371b00 100644 --- a/client/packhand.cpp +++ b/client/packhand.cpp @@ -2097,7 +2097,7 @@ void handle_game_info(const struct packet_game_info *pinfo) } if (game.info.is_edit_mode != pinfo->is_edit_mode) { - popdown_all_city_dialogs(); + popdown_city_dialog(); // Clears the current goto command. clear_hover_state(); diff --git a/client/qtg_cxxside.h b/client/qtg_cxxside.h index 13f45bcd4b..1f9b43a749 100644 --- a/client/qtg_cxxside.h +++ b/client/qtg_cxxside.h @@ -48,8 +48,7 @@ void editgui_popdown_all(); void start_turn(); void real_city_dialog_popup(struct city *pcity); void real_city_dialog_refresh(struct city *pcity); -void popdown_city_dialog(struct city *pcity); -void popdown_all_city_dialogs(); +void popdown_city_dialog(); bool handmade_scenario_warning(); void refresh_unit_city_dialogs(struct unit *punit); bool city_dialog_is_open(struct city *pcity); diff --git a/client/top_bar.cpp b/client/top_bar.cpp index c56ca2d9cb..7c11636147 100644 --- a/client/top_bar.cpp +++ b/client/top_bar.cpp @@ -453,7 +453,7 @@ void top_bar::addWidget(QWidget *fsw) */ void top_bar_show_map() { - popdown_all_city_dialogs(); + popdown_city_dialog(); queen()->game_tab_widget->setCurrentIndex(0); }