Ejemplo n.º 1
0
/**************************************************************************
...
**************************************************************************/
void update_goto_dialog(Widget goto_list)
{
  int j = 0;
  Boolean all_cities;

  if (!can_client_issue_orders()) {
    return;
  }

  XtVaGetValues(goto_all_toggle, XtNstate, &all_cities, NULL);

  cleanup_goto_list();

  if(all_cities) {
    ncities_total = 0;
    players_iterate(pplayer) {
      ncities_total += city_list_size(pplayer->cities);
    } players_iterate_end;
  } else {
Ejemplo n.º 2
0
/**************************************************************************
...
**************************************************************************/
void update_find_dialog(Widget find_list)
{
  int i, j;

  for(i=0, ncities_total=0; i<game.nplayers; i++)
    ncities_total+=city_list_size(&game.players[i].cities);

  city_name_ptrs=(char **)malloc(ncities_total*sizeof(char*));
  
  for(i=0, j=0; i<game.nplayers; i++) {
    struct genlist_iterator myiter;
    genlist_iterator_init(&myiter, &game.players[i].cities.list, 0);
    for(; ITERATOR_PTR(myiter); ITERATOR_NEXT(myiter)) {
      struct city *pcity=(struct city *)ITERATOR_PTR(myiter);
      *(city_name_ptrs+j++)=mystrdup(pcity->name);
    }
  }
  
  if(ncities_total)
    XawListChange(find_list, city_name_ptrs, ncities_total, 0, True);
}
Ejemplo n.º 3
0
/****************************************************************
popup the dialog 10% inside the main-window 
*****************************************************************/
void popup_goto_dialog(void)
{
  Position x, y;
  Dimension width, height;
  Boolean no_player_cities;

  if (!can_client_issue_orders() || get_num_units_in_focus() == 0) {
    return;
  }

  no_player_cities = !(city_list_size(client.conn.playing->cities));

  original_tile = get_center_tile_mapcanvas();
  
  XtSetSensitive(main_form, FALSE);
  
  goto_dialog_shell =
    I_T(XtCreatePopupShell("gotodialog", transientShellWidgetClass,
			   toplevel, NULL, 0));

  goto_form = XtVaCreateManagedWidget("gotoform", 
				      formWidgetClass, 
				      goto_dialog_shell, NULL);

  goto_label =
    I_L(XtVaCreateManagedWidget("gotolabel", labelWidgetClass, 
				goto_form, NULL));

  goto_viewport = XtVaCreateManagedWidget("gotoviewport", 
				      viewportWidgetClass, 
				      goto_form, 
				      NULL);

  goto_list = XtVaCreateManagedWidget("gotolist", 
				      listWidgetClass, 
				      goto_viewport, 
				      XtNlist, 
				      (XtArgVal)dummy_city_list,
				      NULL);

  goto_center_command =
    I_L(XtVaCreateManagedWidget("gotocentercommand", commandWidgetClass,
				goto_form, NULL));

  goto_airlift_command =
    I_L(XtVaCreateManagedWidget("gotoairliftcommand", commandWidgetClass,
				goto_form, NULL));

  goto_all_toggle =
    I_L(XtVaCreateManagedWidget("gotoalltoggle", toggleWidgetClass,
				goto_form,
				XtNstate, no_player_cities,
				XtNsensitive, !no_player_cities,
				NULL));

  goto_cancel_command =
    I_L(XtVaCreateManagedWidget("gotocancelcommand", commandWidgetClass,
				goto_form, NULL));

  XtAddCallback(goto_list, XtNcallback, goto_list_callback, NULL);
  XtAddCallback(goto_center_command, XtNcallback, 
		goto_goto_command_callback, NULL);
  XtAddCallback(goto_airlift_command, XtNcallback, 
		goto_airlift_command_callback, NULL);
  XtAddCallback(goto_all_toggle, XtNcallback,
		goto_all_toggle_callback, NULL);
  XtAddCallback(goto_cancel_command, XtNcallback, 
		goto_cancel_command_callback, NULL);

  XtRealizeWidget(goto_dialog_shell);

  update_goto_dialog(goto_list);

  XtVaGetValues(toplevel, XtNwidth, &width, XtNheight, &height, NULL);

  XtTranslateCoords(toplevel, (Position) width/10, (Position) height/10,
		    &x, &y);
  XtVaSetValues(goto_dialog_shell, XtNx, x, XtNy, y, NULL);

  XtPopup(goto_dialog_shell, XtGrabNone);

  /* force refresh of viewport so the scrollbar is added.
   * Buggy sun athena requires this */
  XtVaSetValues(goto_viewport, XtNforceBars, True, NULL);
}
Ejemplo n.º 4
0
  if (!can_client_issue_orders()) {
    return;
  }

  XtVaGetValues(goto_all_toggle, XtNstate, &all_cities, NULL);

  cleanup_goto_list();

  if(all_cities) {
    ncities_total = 0;
    players_iterate(pplayer) {
      ncities_total += city_list_size(pplayer->cities);
    } players_iterate_end;
  } else {
    ncities_total = city_list_size(client.conn.playing->cities);
  }

  city_name_ptrs=fc_malloc(ncities_total*sizeof(char*));
  
  players_iterate(pplayer) {
    if (!all_cities && pplayer != client.conn.playing) {
      continue;
    }
    city_list_iterate(pplayer->cities, pcity) {
      char name[MAX_LEN_NAME+3];
      sz_strlcpy(name, city_name(pcity));
      /* FIXME: should use unit_can_airlift_to(). */
      if (pcity->airlift) {
	sz_strlcat(name, "(A)");
      }