示例#1
0
/**************************************************************************
  Creates and popups the bribe dialog
**************************************************************************/
void popup_bribe_dialog(struct unit *punit, int cost)
{
  char tbuf[128], buf[128];

  fc_snprintf(tbuf, ARRAY_SIZE(tbuf), PL_("Treasury contains %d gold.",
                                          "Treasury contains %d gold.",
                                          client_player()->economic.gold),
              client_player()->economic.gold);

  if (cost <= client_player()->economic.gold) {
    fc_snprintf(buf, sizeof(buf),
                /* 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, tbuf);
    popup_message_dialog(toplevel, "diplomatbribedialog", buf,
			 diplomat_bribe_yes_callback, 0, 0,
			 diplomat_bribe_no_callback, 0, 0,
			 NULL);
  } else {
    fc_snprintf(buf, sizeof(buf),
                /* 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, tbuf);
    popup_message_dialog(toplevel, "diplomatnogolddialog", buf,
			 diplomat_bribe_no_callback, 0, 0,
			 NULL);
  }
}
示例#2
0
/**************************************************************************
  Popup the yes/no dialog for inciting, since we know the cost now
**************************************************************************/
void popup_incite_dialog(struct city *pcity, int cost)
{
  char tbuf[128], buf[128];

  fc_snprintf(tbuf, ARRAY_SIZE(tbuf), PL_("Treasury contains %d gold.",
                                          "Treasury contains %d gold.",
                                          client_player()->economic.gold),
              client_player()->economic.gold);

  if (INCITE_IMPOSSIBLE_COST == cost) {
    fc_snprintf(buf, sizeof(buf), _("You can't incite a revolt in %s."),
		city_name(pcity));
    popup_message_dialog(toplevel, "diplomatnogolddialog", buf,
			 diplomat_incite_no_callback, 0, 0, NULL);
  } else if (cost <= client_player()->economic.gold) {
    fc_snprintf(buf, sizeof(buf),
                /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
                PL_("Incite a revolt for %d gold?\n%s",
                    "Incite a revolt for %d gold?\n%s", cost), cost, tbuf);
    diplomat_target_id = pcity->id;
    popup_message_dialog(toplevel, "diplomatrevoltdialog", buf,
                         diplomat_incite_yes_callback, 0, 0,
                         diplomat_incite_no_callback, 0, 0,
                         NULL);
  } else {
    fc_snprintf(buf, sizeof(buf),
                /* TRANS: %s is pre-pluralised "Treasury contains %d gold." */
                PL_("Inciting a revolt costs %d gold.\n%s",
                    "Inciting a revolt costs %d gold.\n%s", cost), cost, tbuf);
    popup_message_dialog(toplevel, "diplomatnogolddialog", buf,
                         diplomat_incite_no_callback, 0, 0,
                         NULL);
  }
}
示例#3
0
/****************************************************************
...
*****************************************************************/
void buy_callback(Widget w, XtPointer client_data, XtPointer call_data)
{
  struct city_dialog *pdialog;
  int value;
  char *name;
  char buf[512];
  
  pdialog=(struct city_dialog *)client_data;

  if(pdialog->pcity->is_building_unit) {
    name=get_unit_type(pdialog->pcity->currently_building)->name;
  }
  else {
    name=get_improvement_name(pdialog->pcity->currently_building);
  }
  value=build_cost(pdialog->pcity);
 
  if(game.player_ptr->economic.gold>=value) {
    sprintf(buf, "Buy %s for %d gold?\nTreasure %d gold.", 
	    name, value, game.player_ptr->economic.gold);
    popup_message_dialog(pdialog->shell, "buydialog", buf,
			 buy_callback_yes, pdialog,
			 buy_callback_no, 0, 0);
  }
  else {
    sprintf(buf, "%s costs %d gold.\nTreasure %d gold.", 
	    name, value, game.player_ptr->economic.gold);
    popup_message_dialog(pdialog->shell, "buynodialog", buf,
			 buy_callback_no, 0, 0);
  }
  
}
示例#4
0
/****************************************************************
...
*****************************************************************/
void popup_disband_dialog(struct unit_list *punits)
{
  char buf[512];

  if (get_units_disband_info(buf, sizeof(buf), punits)) {
    struct unit_list *punits2 = unit_list_copy(punits);
    popup_message_dialog(toplevel, "disbanddialog", buf,
			 unitdisband_callback_yes,
			 punits2, 0,
			 unitdisband_callback_no, 0, 0, NULL);
  } else {
    popup_message_dialog(toplevel, "disbandnodialog", buf,
			 unitdisband_callback_no, 0, 0,
			 NULL);
  }
}
示例#5
0
/****************************************************************
...
*****************************************************************/
void popup_caravan_dialog(struct unit *punit,
			  struct city *phomecity, struct city *pdestcity)
{
  char buf[128];
  
  fc_snprintf(buf, sizeof(buf),
              _("Your %s from %s reaches the city of %s.\nWhat now?"),
              unit_name_translation(punit),
              city_name(phomecity), city_name(pdestcity));
  
  caravan_city_id=pdestcity->id; /* callbacks need these */
  caravan_unit_id=punit->id;
  
  caravan_dialog=popup_message_dialog(toplevel, "caravandialog", 
			   buf,
			   caravan_establish_trade_callback, 0, 0,
			   caravan_help_build_wonder_callback, 0, 0,
			   caravan_keep_moving_callback, 0, 0,
			   NULL);
  
  if (!can_cities_trade(phomecity, pdestcity))
    XtSetSensitive(XtNameToWidget(caravan_dialog, "*button0"), FALSE);
  
  if(!unit_can_help_build_wonder(punit, pdestcity))
    XtSetSensitive(XtNameToWidget(caravan_dialog, "*button1"), FALSE);
}
示例#6
0
/****************************************************************
...
*****************************************************************/
void trade_callback(Widget w, XtPointer client_data, XtPointer call_data)
{
  int i;
  int x=0;
  char buf[512];
  struct city_dialog *pdialog;

  pdialog=(struct city_dialog *)client_data;

  sprintf(buf, "These trade routes have been established with %s:\n",
	  pdialog->pcity->name);
  
  for(i=0; i<4; i++)
    if(pdialog->pcity->trade[i]) {
      struct city *pcity;
      x=1;
      if((pcity=find_city_by_id(pdialog->pcity->trade[i]))) {
	sprintf(buf+strlen(buf), "%32s: %2d gold/year\n",
		pcity->name, 
		trade_between_cities(pdialog->pcity, pcity));
      } else {
	sprintf(buf+strlen(buf), "%32s: %2s Gold/Year\n","Unknown","??");
      }

    }
  if (!x)
    sprintf(buf+strlen(buf), "No trade routes exist.\n");
  
  popup_message_dialog(pdialog->shell, 
		       "citytradedialog", 
		       buf, 
		       trade_message_dialog_callback, 0,
		       0);
}
示例#7
0
/****************************************************************
...
*****************************************************************/
void sell_callback(Widget w, XtPointer client_data, XtPointer call_data)
{
  struct city_dialog *pdialog;
  XawListReturnStruct *ret;
  
  pdialog=(struct city_dialog *)client_data;

  ret=XawListShowCurrent(pdialog->improvement_list);

  if(ret->list_index!=XAW_LIST_NONE) {
    int i, n;
    for(i=0, n=0; i<B_LAST; i++)
      if(pdialog->pcity->improvements[i]) {
	if(n==ret->list_index) {
	  char buf[512];
	  
	  if(is_wonder(i))
	    return;
	  
	  pdialog->sell_id=i;
	  sprintf(buf, "Sell %s for %d gold?", 
		  get_improvement_name(i),
		  building_value(i));

	  popup_message_dialog(pdialog->shell, "selldialog", buf,
			       sell_callback_yes, pdialog,
			       sell_callback_no, pdialog, 0);
	  
	  return;
	}
	n++;
      }
  }
}
示例#8
0
/****************************************************************
...
*****************************************************************/
void popup_revolution_dialog(struct government *pgovernment)
{
  popup_message_dialog(toplevel, "revolutiondialog",
		       _("You say you wanna revolution?"),
		       revolution_callback_yes, pgovernment, 0,
		       revolution_callback_no, 0, 0,
		       NULL);
}
示例#9
0
文件: cma_fe.c 项目: jheusala/freeciv
/****************************************************************
 Confirm that the user wants to remove the selected preset.
*****************************************************************/
static void remove_preset(Widget w, XtPointer list,
                          XtPointer call_data)
{
  XawListReturnStruct *ret = XawListShowCurrent(preset_list);
  char buf[256]; 

  if (ret->list_index != XAW_LIST_NONE && cmafec_preset_num()) {
    fc_snprintf(buf, sizeof(buf), 
                _("Do you really want to remove %s?"),
                cmafec_preset_get_descr(ret->list_index));

    popup_message_dialog(cma_dialog, "cmaremovepreset",
                         buf, remove_preset_yes, 
                         INT_TO_XTPOINTER(ret->list_index), 0,
                         remove_preset_no, 0, 0,
                         NULL);
  }
}
示例#10
0
/****************************************************************
...
*****************************************************************/
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);
}
示例#11
0
/****************************************************************
  Popups the diplomat dialog
*****************************************************************/
void popup_diplomat_dialog(struct unit *punit, struct tile *dest_tile)
{
  struct city *pcity;
  struct unit *ptunit;
  struct astring 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(&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)) {
      diplomat_dialog =
        popup_message_dialog(toplevel, "diplomatdialog", astr_str(&text),
			       diplomat_embassy_callback, 0, 1,
			       diplomat_investigate_callback, 0, 1,
			       spy_poison_callback, 0, 1,
			       diplomat_sabotage_callback, 0, 1,
			       diplomat_steal_callback, 0, 1,
			       diplomat_incite_callback, 0, 1,
			       diplomat_keep_moving_callback_city, 0, 1,
			       diplomat_cancel_callback, 0, 0,
			       NULL);
    } else {
      diplomat_dialog =
        popup_message_dialog(toplevel, "spydialog", astr_str(&text),
			       diplomat_embassy_callback, 0,  1,
			       diplomat_investigate_callback, 0, 1,
			       spy_poison_callback, 0, 1,
			       spy_request_sabotage_list, 0, 1,
			       spy_steal_popup, 0, 1,
			       diplomat_incite_callback, 0, 1,
			       diplomat_keep_moving_callback_city, 0, 1,
			       diplomat_cancel_callback, 0, 0,
			       NULL);
    }
      
    if(!diplomat_can_do_action(punit, DIPLOMAT_EMBASSY, dest_tile)) {
      XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button0"), FALSE);
    }
    if(!diplomat_can_do_action(punit, DIPLOMAT_INVESTIGATE, dest_tile)) {
      XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button1"), FALSE);
    }
    if(!diplomat_can_do_action(punit, SPY_POISON, dest_tile)) {
      XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button2"), FALSE);
    }
    if(!diplomat_can_do_action(punit, DIPLOMAT_SABOTAGE, dest_tile)) {
      XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button3"), FALSE);
    }
    if(!diplomat_can_do_action(punit, DIPLOMAT_STEAL, dest_tile)) {
      XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button4"), FALSE);
    }
    if(!diplomat_can_do_action(punit, DIPLOMAT_INCITE, dest_tile)) {
      XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button5"), FALSE);
    }
    if(!diplomat_can_do_action(punit, DIPLOMAT_MOVE, dest_tile)) {
      XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button6"), FALSE);
    }
  } else { 
    if ((ptunit = unit_list_get(dest_tile->units, 0))) {
      /* Spy/Diplomat acting against a unit */
      
      Widget shl;

      astr_set(&text,
               _("Your %s is waiting for your command."),
               unit_name_translation(punit));
      
      diplomat_target_id=ptunit->id;

      shl=popup_message_dialog(toplevel, "spybribedialog",
			       astr_str(&text),
			       diplomat_bribe_callback, 0, 0,
			       spy_sabotage_unit_callback, 0, 0,
			       diplomat_keep_moving_callback_unit, 0, 1,
			       diplomat_cancel_callback, 0, 0,
			       NULL);
	
      if(!diplomat_can_do_action(punit, DIPLOMAT_BRIBE, dest_tile))
	XtSetSensitive(XtNameToWidget(shl, "*button0"), FALSE);
      if(!diplomat_can_do_action(punit, SPY_SABOTAGE_UNIT, dest_tile))
	XtSetSensitive(XtNameToWidget(shl, "*button1"), FALSE);
      if(!diplomat_can_do_action(punit, DIPLOMAT_MOVE, dest_tile))
        XtSetSensitive(XtNameToWidget(shl, "*button2"), FALSE);
    }
  }
  astr_free(&text);
}