/**************************************************************** ... *****************************************************************/ void popup_caravan_dialog(struct unit *punit, struct city *phomecity, struct city *pdestcity) { char buf[128], wonder[128]; bool can_establish, can_trade, can_wonder; my_snprintf(buf, sizeof(buf), _("Your caravan from %s reaches the city of %s.\nWhat now?"), city_name(phomecity), city_name(pdestcity)); caravan_city_id=pdestcity->id; /* callbacks need these */ caravan_unit_id=punit->id; get_help_build_wonder_button_label(wonder, sizeof(wonder), &can_wonder); can_trade = can_cities_trade(phomecity, pdestcity); can_establish = can_trade && can_establish_trade_route(phomecity, pdestcity); caravan_dialog = popup_choice_dialog(GTK_WINDOW(toplevel), _("Your Caravan Has Arrived"), buf, (can_establish ? _("Establish _Traderoute") : _("Enter Marketplace")),caravan_establish_trade_callback, NULL, wonder,caravan_help_build_wonder_callback, NULL, _("_Keep moving"), NULL, NULL, NULL); g_signal_connect(caravan_dialog, "destroy", G_CALLBACK(caravan_destroy_callback), NULL); if (!can_trade) { choice_dialog_button_set_sensitive(caravan_dialog, 0, FALSE); } if (!can_wonder) { choice_dialog_button_set_sensitive(caravan_dialog, 1, FALSE); } }
/**************************************************************** Popup unit bribe dialog *****************************************************************/ void popup_bribe_dialog(struct unit *punit, int cost) { GtkWidget *shell; char buf[1024]; fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.", "Treasury contains %d gold.", client_player()->economic.gold), client_player()->economic.gold); if (unit_has_type_flag(punit, UTYF_UNBRIBABLE)) { shell = popup_choice_dialog(GTK_WINDOW(toplevel), _("Ooops..."), _("This unit cannot be bribed!"), GTK_STOCK_OK, NULL, NULL, NULL); gtk_window_present(GTK_WINDOW(shell)); return; } else if (cost <= client_player()->economic.gold) { shell = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */ PL_("Bribe unit for %d gold?\n%s", "Bribe unit for %d gold?\n%s", cost), cost, buf); gtk_window_set_title(GTK_WINDOW(shell), _("Bribe Enemy Unit")); setup_dialog(shell, toplevel); } else { shell = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */ PL_("Bribing the unit costs %d gold.\n%s", "Bribing the unit costs %d gold.\n%s", cost), cost, buf); gtk_window_set_title(GTK_WINDOW(shell), _("Traitors Demand Too Much!")); setup_dialog(shell, toplevel); } gtk_window_present(GTK_WINDOW(shell)); g_signal_connect(shell, "response", G_CALLBACK(bribe_response), NULL); }
/**************************************************************** Popup new diplomat dialog. *****************************************************************/ void popup_diplomat_dialog(struct unit *punit, struct tile *dest_tile) { struct city *pcity; struct unit *ptunit; GtkWidget *shl; struct astring title = ASTRING_INIT, text = ASTRING_INIT; diplomat_id = punit->id; if ((pcity = tile_city(dest_tile))) { /* Spy/Diplomat acting against a city */ diplomat_target_id = pcity->id; astr_set(&title, /* TRANS: %s is a unit name, e.g., Spy */ _("Choose Your %s's Strategy"), unit_name_translation(punit)); astr_set(&text, _("Your %s has arrived at %s.\nWhat is your command?"), unit_name_translation(punit), city_name(pcity)); if (!unit_has_type_flag(punit, UTYF_SPY)) { shl = popup_choice_dialog(GTK_WINDOW(toplevel), astr_str(&title), astr_str(&text), _("Establish _Embassy"), diplomat_embassy_callback, NULL, _("_Investigate City"), diplomat_investigate_callback, NULL, _("_Sabotage City"), diplomat_sabotage_callback, NULL, _("Steal _Technology"), diplomat_steal_callback, NULL, _("Incite a _Revolt"), diplomat_incite_callback, NULL, _("_Keep moving"), diplomat_keep_moving_callback, NULL, GTK_STOCK_CANCEL, diplomat_cancel_callback, NULL, NULL); if (!diplomat_can_do_action(punit, DIPLOMAT_EMBASSY, dest_tile)) choice_dialog_button_set_sensitive(shl, 0, FALSE); if (!diplomat_can_do_action(punit, DIPLOMAT_INVESTIGATE, dest_tile)) choice_dialog_button_set_sensitive(shl, 1, FALSE); if (!diplomat_can_do_action(punit, DIPLOMAT_SABOTAGE, dest_tile)) choice_dialog_button_set_sensitive(shl, 2, FALSE); if (!diplomat_can_do_action(punit, DIPLOMAT_STEAL, dest_tile)) choice_dialog_button_set_sensitive(shl, 3, FALSE); if (!diplomat_can_do_action(punit, DIPLOMAT_INCITE, dest_tile)) choice_dialog_button_set_sensitive(shl, 4, FALSE); if (!diplomat_can_do_action(punit, DIPLOMAT_MOVE, dest_tile)) choice_dialog_button_set_sensitive(shl, 5, FALSE); } else { shl = popup_choice_dialog(GTK_WINDOW(toplevel), astr_str(&title), astr_str(&text), _("Establish _Embassy"), diplomat_embassy_callback, NULL, _("_Investigate City"), diplomat_investigate_callback, NULL, _("_Poison City"), spy_poison_callback, NULL, _("Industrial _Sabotage"), spy_request_sabotage_list, NULL, _("Steal _Technology"), spy_steal_popup, NULL, _("Incite a _Revolt"), diplomat_incite_callback, NULL, _("_Keep moving"), diplomat_keep_moving_callback, NULL, GTK_STOCK_CANCEL, diplomat_cancel_callback, NULL, NULL); if (!diplomat_can_do_action(punit, DIPLOMAT_EMBASSY, dest_tile)) choice_dialog_button_set_sensitive(shl, 0, FALSE); if (!diplomat_can_do_action(punit, DIPLOMAT_INVESTIGATE, dest_tile)) choice_dialog_button_set_sensitive(shl, 1, FALSE); if (!diplomat_can_do_action(punit, SPY_POISON, dest_tile)) choice_dialog_button_set_sensitive(shl, 2, FALSE); if (!diplomat_can_do_action(punit, DIPLOMAT_SABOTAGE, dest_tile)) choice_dialog_button_set_sensitive(shl, 3, FALSE); if (!diplomat_can_do_action(punit, DIPLOMAT_STEAL, dest_tile)) choice_dialog_button_set_sensitive(shl, 4, FALSE); if (!diplomat_can_do_action(punit, DIPLOMAT_INCITE, dest_tile)) choice_dialog_button_set_sensitive(shl, 5, FALSE); if (!diplomat_can_do_action(punit, DIPLOMAT_MOVE, dest_tile)) choice_dialog_button_set_sensitive(shl, 6, FALSE); } diplomat_dialog = shl; choice_dialog_set_hide(shl, TRUE); g_signal_connect(shl, "destroy", G_CALLBACK(diplomat_destroy_callback), NULL); g_signal_connect(shl, "delete_event", G_CALLBACK(diplomat_cancel_callback), NULL); } else { if ((ptunit = unit_list_get(dest_tile->units, 0))){ /* Spy/Diplomat acting against a unit */ diplomat_target_id = ptunit->id; astr_set(&text, /* TRANS: %s is a unit name, e.g., Diplomat, Spy */ _("Your %s is waiting for your command."), unit_name_translation(punit)); shl = popup_choice_dialog(GTK_WINDOW(toplevel), _("Subvert Enemy Unit"), astr_str(&text), _("_Bribe Enemy Unit"), diplomat_bribe_callback, NULL, _("_Sabotage Enemy Unit"), spy_sabotage_unit_callback, NULL, GTK_STOCK_CANCEL, diplomat_cancel_callback, NULL, NULL); if (!diplomat_can_do_action(punit, DIPLOMAT_BRIBE, dest_tile)) { choice_dialog_button_set_sensitive(shl, 0, FALSE); } if (!diplomat_can_do_action(punit, SPY_SABOTAGE_UNIT, dest_tile)) { choice_dialog_button_set_sensitive(shl, 1, FALSE); } diplomat_dialog = shl; choice_dialog_set_hide(shl, TRUE); g_signal_connect(shl, "destroy", G_CALLBACK(diplomat_destroy_callback), NULL); g_signal_connect(shl, "delete_event", G_CALLBACK(diplomat_cancel_callback), NULL); } } astr_free(&title); astr_free(&text); }