Skip to content

Commit

Permalink
Merge all functions that pop down the city overlay
Browse files Browse the repository at this point in the history
There were three functions that all did the same thing. Simplify the API by
merging them.
  • Loading branch information
lmoureaux authored and psampathkumar committed Aug 1, 2022
1 parent 5e11267 commit 99178b0
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 30 deletions.
26 changes: 5 additions & 21 deletions client/citydlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down Expand Up @@ -2074,7 +2074,7 @@ void city_dialog::refresh()
update_cma_tab();
update_disabled();
} else {
destroy_city_dialog();
popdown_city_dialog();
}

update_map_canvas_visible();
Expand Down Expand Up @@ -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.
*/
Expand Down
6 changes: 3 additions & 3 deletions client/client_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion client/climisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion client/mapview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
2 changes: 1 addition & 1 deletion client/packhand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
3 changes: 1 addition & 2 deletions client/qtg_cxxside.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion client/top_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 99178b0

Please sign in to comment.