/**************************************************************** ... *****************************************************************/ void refresh_unit_city_dialogs(struct unit *punit) { struct city *pcity_sup, *pcity_pre; struct city_dialog *pdialog; pcity_sup=city_list_find_id(&game.player_ptr->cities, punit->homecity); pcity_pre=game_find_city_by_coor(punit->x, punit->y); if(pcity_sup && (pdialog=get_city_dialog(pcity_sup))) city_dialog_update_supported_units(pdialog, punit->id); if(pcity_pre && (pdialog=get_city_dialog(pcity_pre))) city_dialog_update_present_units(pdialog, punit->id); }
/**************************************************************** popdown the dialog *****************************************************************/ void popdown_city_dialog(struct city *pcity) { struct city_dialog *pdialog; if((pdialog=get_city_dialog(pcity))) close_city_dialog(pdialog); }
/**************************************************************** popup the dialog 10% inside the main-window *****************************************************************/ void popup_city_dialog(struct city *pcity, int make_modal) { struct city_dialog *pdialog; if(!(pdialog=get_city_dialog(pcity))) pdialog=create_city_dialog(pcity, make_modal); xaw_set_relative_position(toplevel, pdialog->shell, 10, 10); XtPopup(pdialog->shell, XtGrabNone); }
/************************************************************************** Update city dialogs when the given unit's status changes. This typically means updating both the unit's home city (if any) and the city in which it is present (if any). **************************************************************************/ void refresh_unit_city_dialogs(struct unit *punit) { freelog(LOG_VERBOSE, "Port Me %s [@%s:%d]", __func__, __FILE__, __LINE__); #if 0 /* Demo code */ struct city *pcity_sup, *pcity_pre; struct city_dialog *pdialog; pcity_sup = game_find_city_by_number(punit->homecity); pcity_pre = tile_city(punit->tile); if (pcity_sup && (pdialog = get_city_dialog(pcity_sup))) { city_dialog_update_supported_units(pdialog); } if (pcity_pre && (pdialog = get_city_dialog(pcity_pre))) { city_dialog_update_present_units(pdialog); } #endif }
/**************************************************************** ... *****************************************************************/ void present_units_activate_close_callback(Widget w, XtPointer client_data, XtPointer call_data) { struct unit *punit; struct city *pcity; struct city_dialog *pdialog; activate_unit((int)client_data); destroy_message_dialog(w); if((punit=unit_list_find(&game.player_ptr->units, (int)client_data))) if((pcity=game_find_city_by_coor(punit->x, punit->y))) if((pdialog=get_city_dialog(pcity))) close_city_dialog(pdialog); }
/**************************************************************** ... *****************************************************************/ void support_units_callback(Widget w, XtPointer client_data, XtPointer call_data) { struct unit *punit; struct city *pcity; struct city_dialog *pdialog; if((punit=unit_list_find(&game.player_ptr->units, (int)client_data))) if((pcity=find_city_by_id(punit->homecity))) if((pdialog=get_city_dialog(pcity))) popup_message_dialog(pdialog->shell, "supportunitsdialog", unit_description(punit), present_units_activate_callback, punit->id, present_units_activate_close_callback, punit->id, /* act+c */ present_units_disband_callback, punit->id, present_units_cancel_callback, 0, 0); }
/**************************************************************** ... *****************************************************************/ void refresh_city_dialog(struct city *pcity) { struct city_dialog *pdialog; if((pdialog=get_city_dialog(pcity))) { city_dialog_update_improvement_list(pdialog); city_dialog_update_title(pdialog); city_dialog_update_supported_units(pdialog, 0); city_dialog_update_present_units(pdialog, 0); city_dialog_update_citizens(pdialog); city_dialog_update_map(pdialog); city_dialog_update_production(pdialog); city_dialog_update_output(pdialog); city_dialog_update_building(pdialog); city_dialog_update_storage(pdialog); city_dialog_update_polution(pdialog); } }