~ubuntu-branches/debian/squeeze/freeciv/squeeze

« back to all changes in this revision

Viewing changes to client/gui-ftwl/mapview.c

  • Committer: Bazaar Package Importer
  • Author(s): Clint Adams, Karl Goetz, Clint Adams
  • Date: 2010-02-23 22:09:02 UTC
  • mfrom: (1.2.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20100223220902-kiyrmr9i4152cka5
Tags: 2.2.0-1
[ Karl Goetz ]
* Remove civserver files in /etc/ggzd/ (Closes: 523772, 517787)
* Adding ${misc:Depends} to all binary packages (lintian warnings)

[ Clint Adams ]
* New upstream version.
  - Drop data_dsc_use_bindir.diff (binary pathnames have changed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
#include <stdio.h>
19
19
 
 
20
/* common & utility */
20
21
#include "fcintl.h"
21
22
#include "game.h"
22
23
#include "log.h"
26
27
#include "support.h"
27
28
#include "unitlist.h"
28
29
 
29
 
#include "civclient.h"
 
30
/* client */
 
31
#include "client_main.h"
30
32
#include "climap.h"
31
33
#include "climisc.h"
32
34
#include "colors.h"
145
147
 
146
148
struct ct_string *text_templates[FONT_COUNT];
147
149
 
 
150
static bool all_dirty = FALSE;
 
151
 
 
152
struct region_list *region_list;
 
153
 
148
154
/****************************************************************************
149
155
  Return the dimensions of the area (container widget; maximum size) for
150
156
  the overview.
298
304
 
299
305
  struct ct_rect rect;
300
306
 
301
 
  freelog(LOG_NORMAL, "refresh_overview_canvas()");
 
307
  freelog(LOG_DEBUG, "refresh_overview_canvas()");
302
308
  whole_map_iterate(x, y) {
303
309
    overview_update_tile0(x, y);
304
310
  } whole_map_iterate_end;
365
371
 
366
372
#if 0
367
373
  /* try to trace that hard-to-find assert that we sometimes get */
368
 
  freelog(LOG_NORMAL, "show_city_desc(%s) pcx=%d->%d (%d) pcy=%d->%d (%d)", city_name(pcity),
 
374
  freelog(LOG_TEST, "show_city_desc(%s) pcx=%d->%d (%d) pcy=%d->%d (%d)", city_name(pcity),
369
375
          canvas_x, canvas_x+tileset_tile_width(tileset) / 2, all_rect.width,
370
376
          canvas_y, canvas_y+tileset_tile_height(tileset), all_rect.height);
371
377
#endif
383
389
  line1_b = ct_string_clone4(style->growth_template, buffer2,
384
390
                            enum_color_to_be_color(color));
385
391
 
386
 
  if (draw_city_productions && (city_owner(pcity) == game.player_idx)) {
 
392
  if (draw_city_productions && (city_owner(pcity) == client.conn.playing)) {
387
393
    get_city_mapview_production(pcity, buffer, sizeof(buffer));
388
394
    line2 =
389
395
        ct_string_clone4(style->prod_template, buffer,
450
456
  freelog(LOG_DEBUG, "flush_mapcanvas=%s", ct_rect_to_string(&rect));
451
457
  be_copy_osda_to_osda(sw_window_get_canvas_background(mapview_window),
452
458
                       mapview.store->osda, &size, &pos, &pos);
453
 
  sw_window_canvas_background_region_needs_repaint(mapview_window,
454
 
                                                   &rect);
 
459
  sw_window_canvas_background_region_needs_repaint(mapview_window, &rect);
455
460
}
456
461
 
457
462
/**************************************************************************
461
466
void dirty_rect(int canvas_x, int canvas_y,
462
467
                int pixel_width, int pixel_height)
463
468
{
464
 
  struct ct_rect rect = { canvas_x, canvas_y, pixel_width, pixel_height };
465
 
 
466
 
  //freelog(LOG_NORMAL, "dirty_rect(...)");
467
 
  sw_window_canvas_background_region_needs_repaint(mapview_window, &rect);
 
469
  if (!all_dirty) {
 
470
    struct ct_rect *rect = fc_malloc(sizeof(*rect));
 
471
  
 
472
    *rect = (struct ct_rect){ canvas_x, canvas_y, pixel_width, pixel_height };
 
473
  
 
474
    //freelog(LOG_TEST, "dirty_rect(...)");
 
475
    region_list_append(region_list, rect);
 
476
  }
468
477
}
469
478
 
470
479
/**************************************************************************
473
482
**************************************************************************/
474
483
void dirty_all(void)
475
484
{
476
 
  struct ct_rect rect;
477
 
 
478
 
  sw_widget_get_bounds(mapview_window, &rect);
479
 
  sw_window_canvas_background_region_needs_repaint(mapview_window, 
480
 
                                                   &rect);
 
485
  all_dirty = TRUE;
481
486
}
482
487
 
483
488
/**************************************************************************
487
492
**************************************************************************/
488
493
void flush_dirty(void)
489
494
{
490
 
  flush_mapcanvas(0, 0, mapview.width, mapview.height);
 
495
  if (all_dirty) {
 
496
    region_list_iterate(region_list, region) {
 
497
      free(region);
 
498
    } region_list_iterate_end;
 
499
    region_list_clear(region_list);
 
500
    
 
501
    flush_mapcanvas(0, 0, mapview.width, mapview.height);
 
502
    all_dirty = FALSE;
 
503
  } else {
 
504
    region_list_iterate(region_list, region) {
 
505
      flush_mapcanvas(region->x, region->y, region->width, region->height);
 
506
      free(region);
 
507
    } region_list_iterate_end;
 
508
    region_list_clear(region_list);
 
509
  }
 
510
  sw_paint_all();
491
511
}
492
512
 
493
513
/**************************************************************************
653
673
 
654
674
  ptile = get_focus_tile();
655
675
  unit_list_iterate(ptile->units, aunit) {
656
 
    if (game.info.player_idx == unit_owner(aunit)->player_no) {
 
676
    if (unit_owner(aunit) == client.conn.playing) {
657
677
      set_unit_focus(aunit);
658
678
      break;
659
679
    }
681
701
    item->info_text=mystrdup(popup_info_text(ptile));
682
702
  }
683
703
 
684
 
  if (tile_get_city(ptile)) {
685
 
    struct city *pcity=tile_get_city(ptile);
 
704
  if (tile_city(ptile)) {
 
705
    struct city *pcity=tile_city(ptile);
686
706
    struct tile_list2_item *item = &tile_list2.item[tile_list2.items];
687
707
 
688
708
    tile_list2.items++;
854
874
{
855
875
  char *action = (char *) data;
856
876
 
857
 
  freelog(LOG_NORMAL, "action '%s' requested", action);
 
877
  freelog(LOG_VERBOSE, "action_button_callback(): action '%s' requested", action);  
 
878
  
 
879
  if (strcmp(action, "unit_fortifying") == 0) {
 
880
    key_unit_fortify();
 
881
  } else if (strcmp(action, "unit_add_to_city") == 0) {
 
882
    key_unit_build_city();
 
883
  } else if (strcmp(action, "unit_build_city") == 0) {
 
884
    key_unit_build_city();
 
885
  } else if (strcmp(action, "unit_auto_explore") == 0) {
 
886
    key_unit_auto_explore();
 
887
  } else if (strcmp(action, "unit_irrigate") == 0) {
 
888
    key_unit_irrigate();
 
889
  } else if (strcmp(action, "unit_sentry") == 0) {
 
890
    key_unit_sentry();
 
891
  } else if (strcmp(action, "unit_return_nearest") == 0) {
 
892
/*    key_? */
 
893
  } else if (strcmp(action, "unit_disband") == 0) {
 
894
    key_unit_disband();
 
895
  } else if (strcmp(action, "unit_mine") == 0) {
 
896
    key_unit_mine();
 
897
  } else if (strcmp(action, "unit_road") == 0) {
 
898
    key_unit_road();
 
899
  } else if (strcmp(action, "unit_auto_settler") == 0) {
 
900
    key_unit_auto_settle();
 
901
  } else if (strcmp(action, "unit_connect") == 0) {
 
902
/*    key_unit_connect(enum unit_activity activity);*/
 
903
  } else if (strcmp(action, "unit_auto_attack") == 0) {
 
904
/*    key_? */    
 
905
  } else if (strcmp(action, "unit_homecity") == 0) {
 
906
    key_unit_homecity();
 
907
  } else if (strcmp(action, "unit_fortress") == 0) {
 
908
    key_unit_fortress();
 
909
  } else if (strcmp(action, "unit_pillage") == 0) {
 
910
    key_unit_pillage();
 
911
  } else if (strcmp(action, "unit_airbase") == 0) {
 
912
    key_unit_airbase();
 
913
  } else if (strcmp(action, "unit_transform") == 0) {
 
914
    key_unit_transform();
 
915
  } else if (strcmp(action, "unit_unload") == 0) {
 
916
    key_unit_unload_all();
 
917
  } else if (strcmp(action, "unit_goto") == 0) {
 
918
    key_unit_goto();
 
919
  } else if (strcmp(action, "unit_goto_city") == 0) {
 
920
/*    key_? */
 
921
  } else if (strcmp(action, "unit_airlift") == 0) {
 
922
/*    key_? */
 
923
  } else if (strcmp(action, "unit_patrol") == 0) {
 
924
    key_unit_patrol();
 
925
  } else if (strcmp(action, "unit_wait") == 0) {
 
926
    key_unit_wait();
 
927
  } else if (strcmp(action, "unit_railroad") == 0) {
 
928
/*    key_? */
 
929
  } else if (strcmp(action, "unit_done") == 0) {
 
930
    key_unit_done();
 
931
  } else {
 
932
    freelog(LOG_VERBOSE,
 
933
      "action_button_callback(): action request '%s' not handled", action);    
 
934
  }
858
935
}
859
936
 
860
937
/**************************************************************************
993
1070
      redraw_selection_rectangle();
994
1071
    }
995
1072
  } else {
996
 
    freelog(LOG_NORMAL, "action '%s' requested", action);
 
1073
    freelog(LOG_VERBOSE, "action_callback() action '%s' requested", action);
997
1074
  }
998
1075
}
999
1076
 
1121
1198
    return textyear(game.info.year);
1122
1199
  } else if (strcmp(id, "gold") == 0) {
1123
1200
    my_snprintf(buffer, sizeof(buffer),
1124
 
                "%d", game.player_ptr->economic.gold);
 
1201
                "%d", client.conn.playing->economic.gold);
1125
1202
    return buffer;
1126
1203
  } else if (strcmp(id, "nation_name") == 0) {
1127
 
      return nation_plural_for_player(game.player_ptr);
 
1204
      return nation_plural_for_player(client.conn.playing);
1128
1205
  } else if (strcmp(id, "population") == 0) {
1129
 
      return population_to_text(civ_population(game.player_ptr));
 
1206
      return population_to_text(civ_population(client.conn.playing));
1130
1207
  } else if (strcmp(id, "general") == 0) {
1131
1208
      my_snprintf(buffer, sizeof(buffer),
1132
1209
                  _("Population: %s\n"
1133
1210
                "Year: %s\n"
1134
1211
                "Gold %d\n"
1135
1212
                "Tax: %d Lux: %d Sci: %d"),
1136
 
              population_to_text(civ_population(game.player_ptr)),
1137
 
              textyear(game.info.year), game.player_ptr->economic.gold,
1138
 
              game.player_ptr->economic.tax,
1139
 
              game.player_ptr->economic.luxury,
1140
 
              game.player_ptr->economic.science);
 
1213
              population_to_text(civ_population(client.conn.playing)),
 
1214
              textyear(game.info.year),
 
1215
              client.conn.playing->economic.gold,
 
1216
              client.conn.playing->economic.tax,
 
1217
              client.conn.playing->economic.luxury,
 
1218
              client.conn.playing->economic.science);
1141
1219
      return buffer;
1142
1220
  } else if (strcmp(id, "focus_item") == 0) {
1143
1221
      return tile_list2.item[tile_list2.selected].info_text;
1147
1225
                "Year: %s "
1148
1226
                "Gold %d "
1149
1227
                "Tax: %d Lux: %d Sci: %d"),
1150
 
              population_to_text(civ_population(game.player_ptr)),
1151
 
              textyear(game.info.year), game.player_ptr->economic.gold,
1152
 
              game.player_ptr->economic.tax,
1153
 
              game.player_ptr->economic.luxury,
1154
 
              game.player_ptr->economic.science);
 
1228
              population_to_text(civ_population(client.conn.playing)),
 
1229
              textyear(game.info.year),
 
1230
              client.conn.playing->economic.gold,
 
1231
              client.conn.playing->economic.tax,
 
1232
              client.conn.playing->economic.luxury,
 
1233
              client.conn.playing->economic.science);
1155
1234
      return buffer;
1156
1235
#endif
1157
1236
  } else {
1169
1248
  struct ct_rect rect;
1170
1249
  struct ct_size screen_size;
1171
1250
 
 
1251
  region_list = region_list_new();
 
1252
  
1172
1253
  be_screen_get_size(&screen_size);
1173
1254
 
1174
1255
  env.info_get_value = info_get_value;
1211
1292
**************************************************************************/
1212
1293
void popdown_mapcanvas(void)
1213
1294
{
 
1295
  region_list_iterate(region_list, region) {
 
1296
    free(region);
 
1297
  } region_list_iterate_end;
 
1298
  region_list_free(region_list);
 
1299
  
1214
1300
  te_destroy_screen(screen);
1215
1301
}
1216
1302
 
1227
1313
**************************************************************************/
1228
1314
static void unshow_actions(void)
1229
1315
{
 
1316
  struct ct_rect rect;
1230
1317
  int i;
1231
1318
 
1232
1319
  for (i = 0; i < actions_shown.actions; i++) {
 
1320
    sw_widget_get_bounds(actions_shown.action[i].widget, &rect);    
 
1321
    be_draw_region(sw_widget_get_osda(screen->window), &rect,
 
1322
                                       be_get_color(0, 0, 0, MIN_OPACITY));
1233
1323
    sw_window_remove(actions_shown.action[i].widget);
1234
1324
    actions_shown.action[i].widget = NULL;
1235
1325
    free(actions_shown.action[i].name);
1319
1409
    if (unit_can_help_build_wonder_here(punit)) {
1320
1410
      ADD("unit_help_wonder");
1321
1411
    }
1322
 
    if (unit_can_est_traderoute_here(punit)) {
1323
 
      ADD("unit_traderoute");
 
1412
    if (unit_can_est_trade_route_here(punit)) {
 
1413
      ADD("unit_trade_route");
1324
1414
    }
1325
1415
 
1326
1416
    if (can_unit_add_or_build_city(punit)) {
1327
 
      if (tile_get_city(punit->tile)) {
 
1417
      if (tile_city(punit->tile)) {
1328
1418
        ADD("unit_add_to_city");
1329
1419
      } else {
1330
1420
        ADD("unit_build_city");
1348
1438
    if (can_unit_do_connect(punit, ACTIVITY_IDLE)) {
1349
1439
      ADD("unit_connect");
1350
1440
    }
1351
 
    if (!(is_air_unit(punit) || is_heli_unit(punit))) {
 
1441
    if (!utype_fuel(unit_type(punit))) {
1352
1442
      ADD("unit_return_nearest");
1353
1443
    }
1354
1444
    if (!unit_has_type_flag(punit, F_UNDISBANDABLE)) {
1374
1464
    struct city *pcity = item->pcity;
1375
1465
    int i;
1376
1466
 
1377
 
    if (game.player_ptr->economic.gold >= city_buy_cost(pcity)) {
 
1467
    if (city_production_buy_gold_cost(pcity) <= client.conn.playing->economic.gold) {
1378
1468
      ADD("city_buy");
1379
1469
    } else {
1380
1470
      ADD_DIS("city_buy");
1529
1619
  freelog(LOG_ERROR, "Ignore set_city_names_font_sizes call.");
1530
1620
  /* PORTME */
1531
1621
}
 
1622
 
 
1623
/**************************************************************************
 
1624
  This function will change the current mouse cursor.
 
1625
**************************************************************************/
 
1626
void update_mouse_cursor(enum cursor_type new_cursor_type)
 
1627
{
 
1628
  /* PORT ME */
 
1629
}