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

« back to all changes in this revision

Viewing changes to client/gui-win32/dialogs.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:
23
23
#include <windowsx.h>
24
24
#include <commctrl.h>
25
25
 
 
26
/* common & utility */
26
27
#include "capability.h"
27
28
#include "fcintl.h"
28
29
#include "game.h"
36
37
#include "support.h"
37
38
#include "unitlist.h"
38
39
 
39
 
#include "civclient.h"
40
 
#include "clinet.h"
 
40
/* client */
 
41
#include "client_main.h"
41
42
#include "control.h"
42
43
#include "tilespec.h"
43
44
#include "packhand.h"
172
173
  location.
173
174
**************************************************************************/
174
175
void popup_notify_goto_dialog(const char *headline, const char *lines,
175
 
                              struct tile *ptile)
 
176
                              const struct text_tag_list *tags,
 
177
                              struct tile *ptile)
176
178
{
177
179
  struct fcwin_box *hbox;
178
180
  struct fcwin_box *vbox;
195
197
}
196
198
 
197
199
/**************************************************************************
 
200
  Popup a dialog to display connection message from server.
 
201
**************************************************************************/
 
202
void popup_connect_msg(const char *headline, const char *message)
 
203
{
 
204
  /* FIXME: Needs proper implementation.
 
205
   *        Now just puts to chat window so message is not completely lost. */
 
206
 
 
207
  output_window_append(ftc_client, message);
 
208
}
 
209
 
 
210
/**************************************************************************
198
211
 
199
212
**************************************************************************/
200
213
static LONG CALLBACK notify_proc(HWND hWnd,
284
297
**************************************************************************/
285
298
static void update_nation_info()
286
299
{
287
 
/*
 
300
  /*
288
301
  int i;
289
302
  char buf[255];
290
303
  struct nation_type *nation = nation_by_number(selected_nation);
291
304
 
292
305
  buf[0] = '\0';
 
306
  */
293
307
 
 
308
/*
294
309
  for (i = 0; i < nation->num_groups; i++) {
295
310
    sz_strlcat(buf, nation->groups[i]->name);
296
311
    if (i != nation->num_groups - 1) {
309
324
**************************************************************************/
310
325
static void select_random_race(HWND hWnd)
311
326
{
312
 
  selected_nation = myrand(game.control.nation_count);
 
327
  selected_nation = myrand(nation_count());
313
328
  update_nation_info();
314
329
  update_radio_buttons(0);
315
330
}
355
370
                   name,MAX_LEN_NAME);
356
371
 
357
372
  if (strlen(name) == 0) {
358
 
    append_output_window(_("You must type a legal name."));
 
373
    output_window_append(ftc_client, _("You must type a legal name."));
359
374
    return;
360
375
  }
361
 
  dsend_packet_nation_select_req(&aconnection, races_player->player_no,
 
376
  dsend_packet_nation_select_req(&client.conn, player_number(races_player),
362
377
                                 selected_nation, is_male, name, city_style);
363
378
 
364
379
  popdown_races_dialog();
484
499
     *        const strings. Now we just cast const away */
485
500
    strings[0] = (char *) nation_adjective_translation(pnation);
486
501
 
487
 
    fcwin_listview_add_row(listview, pnation->index, 1, strings);
488
 
    visible_nations[n++] = pnation->index;
 
502
    fcwin_listview_add_row(listview, nation_index(pnation), 1, strings);
 
503
    visible_nations[n++] = nation_index(pnation);
489
504
 
490
505
  } nations_iterate_end;
491
506
 
691
706
          break;
692
707
        case UNITSELECT_READY_ALL:
693
708
          for(i=0; i<unit_select_no; i++) {
694
 
            struct unit *punit = player_find_unit_by_id(game.player_ptr,
 
709
            struct unit *punit = player_find_unit_by_id(client.conn.playing,
695
710
                                                        unit_select_ids[i]);
696
711
            if(punit) {
697
712
              set_unit_focus(punit);
702
717
          id-=UNITSELECT_UNITS_BASE;
703
718
          if ((id>=0)&&(id<100))
704
719
            {
705
 
              struct unit *punit=player_find_unit_by_id(game.player_ptr,
706
 
                                                        unit_select_ids[id]);
707
 
              if (punit && unit_owner(punit) == game.player_ptr) {
 
720
              struct unit *punit = player_find_unit_by_id(client.conn.playing,
 
721
                                                          unit_select_ids[id]);
 
722
              if (NULL != punit && unit_owner(punit) == client.conn.playing) {
708
723
                set_unit_focus(punit);
709
724
              }   
710
725
            }
797
812
    {
798
813
      struct unit *punit = unit_list[i];
799
814
      struct unit_type *punittemp=unit_type(punit);
800
 
      struct city *pcity;
 
815
      struct city *pcity = player_find_city_by_id(client.conn.playing, punit->homecity);
 
816
 
801
817
      unit_select_ids[i]=punit->id;
802
 
      pcity=player_find_city_by_id(game.player_ptr, punit->homecity);
 
818
 
803
819
      my_snprintf(buffer, sizeof(buffer), "%s(%s)\n%s",
804
820
                  utype_name_translation(punittemp),
805
821
                  pcity ? city_name(pcity) : "",
826
842
      struct canvas canvas_store;
827
843
      struct unit *punit=unit_list[i];
828
844
      struct unit_type *punittemp=unit_type(punit);
829
 
      struct city *pcity;
 
845
      struct city *pcity = player_find_city_by_id(client.conn.playing, punit->homecity);
830
846
 
831
847
      canvas_store.type = CANVAS_DC;
832
848
      canvas_store.hdc = unitsel_dc;
834
850
      canvas_store.wnd = NULL;
835
851
      canvas_store.tmp = NULL;
836
852
 
837
 
      pcity=player_find_city_by_id(game.player_ptr, punit->homecity);
838
853
      my_snprintf(buffer, sizeof(buffer), "%s(%s)\n%s",
839
854
                  utype_name_translation(punittemp),
840
855
                  pcity ? city_name(pcity) : "",
917
932
  int i;
918
933
  BOOL changed;
919
934
 
920
 
  for (i = 0; i < game.control.nation_count; i++) {
 
935
  for (i = 0; i < nation_count(); i++) {
921
936
    EnableWindow(GetDlgItem(races_dlg, ID_RACESDLG_NATION_BASE + i), TRUE);
922
937
  }
923
938
 
924
939
  changed = FALSE;
925
940
 
926
 
  for (i = 0; i < game.control.nation_count; i++) {
927
 
    struct nation_type *nation;
928
 
    nation = nation_by_number(i);
929
 
 
930
 
    if (!(nation->is_unavailable || nation->is_used)) {
 
941
  nations_iterate(nation) {
 
942
    if (!nation->is_available || nation->player) {
931
943
      continue;
932
944
    }
933
945
 
934
 
    EnableWindow(GetDlgItem(races_dlg, ID_RACESDLG_NATION_BASE + i),
 
946
    EnableWindow(GetDlgItem(races_dlg, ID_RACESDLG_NATION_BASE + nation_index(nation)),
935
947
                 FALSE);
936
948
 
937
949
    changed = TRUE;
938
 
  }
 
950
  } nations_iterate_end;
939
951
 
940
952
  if (changed) {
941
953
    select_random_race(races_dlg);
971
983
*****************************************************************/
972
984
void popup_revolution_dialog(struct government *gov)
973
985
{
974
 
  if (game.player_ptr->revolution_finishes < game.info.turn) {
 
986
  if (client.conn.playing->revolution_finishes < game.info.turn) {
975
987
    popup_message_dialog(NULL, _("Revolution!"),
976
988
                         _("You say you wanna revolution?"),
977
989
                         _("_Yes"),revolution_callback_yes, gov,
991
1003
*****************************************************************/
992
1004
static void caravan_establish_trade_callback(HWND w, void * data)
993
1005
{
994
 
  dsend_packet_unit_establish_trade(&aconnection, caravan_unit_id);
 
1006
  dsend_packet_unit_establish_trade(&client.conn, caravan_unit_id);
995
1007
 
996
1008
  destroy_message_dialog(w);
997
1009
  caravan_dialog = 0;
1004
1016
*****************************************************************/
1005
1017
static void caravan_help_build_wonder_callback(HWND w, void * data)
1006
1018
{
1007
 
  dsend_packet_unit_help_build_wonder(&aconnection, caravan_unit_id);
 
1019
  dsend_packet_unit_help_build_wonder(&client.conn, caravan_unit_id);
1008
1020
 
1009
1021
  destroy_message_dialog(w);
1010
1022
  caravan_dialog = 0;
1048
1060
  caravan_dialog=popup_message_dialog(NULL,
1049
1061
                           /*"caravandialog"*/_("Your Caravan Has Arrived"),
1050
1062
                           buf,
1051
 
                           (can_establish ? _("Establish _Traderoute") :
 
1063
                           (can_establish ? _("Establish _Trade route") :
1052
1064
                           _("Enter Marketplace")),caravan_establish_trade_callback, 0,
1053
1065
                           _("Help build _Wonder"),caravan_help_build_wonder_callback, 0,
1054
1066
                           _("_Keep moving"),caravan_keep_moving_callback, 0,
1174
1186
static void create_advances_list(struct player *pplayer,
1175
1187
                                struct player *pvictim, HWND lb)
1176
1188
{
1177
 
  int i, j;
1178
 
  j = 0;
 
1189
  int j = 0;
 
1190
 
1179
1191
  advance_type[j] = -1;
1180
1192
  
1181
1193
  if (pvictim) { /* you don't want to know what lag can do -- Syela */
1182
 
    
1183
 
    for(i=A_FIRST; i<game.control.num_tech_types; i++) {
1184
 
      if(get_invention(pvictim, i)==TECH_KNOWN && 
1185
 
         (get_invention(pplayer, i)==TECH_UNKNOWN || 
1186
 
          get_invention(pplayer, i)==TECH_REACHABLE)) {
1187
 
        ListBox_AddString(lb,advance_name_translation(i));
 
1194
    advance_index_iterate(A_FIRST, i) {
 
1195
      if(player_invention_state(pvictim, i)==TECH_KNOWN && 
 
1196
         (player_invention_state(pplayer, i)==TECH_UNKNOWN || 
 
1197
          player_invention_state(pplayer, i)==TECH_PREREQS_KNOWN)) {
 
1198
        ListBox_AddString(lb,advance_name_translation(advance_by_number(i)));
1188
1199
        advance_type[j++] = i;
1189
1200
      }
1190
 
    }
 
1201
    } advance_index_iterate_end;
1191
1202
    
1192
1203
    if(j > 0) {
1193
1204
      ListBox_AddString(lb,_("At Spy's Discretion"));
1292
1303
    fcwin_box_add_button(hbox,_("Steal"),IDOK,0,TRUE,TRUE,10);
1293
1304
    EnableWindow(GetDlgItem(spy_tech_dialog,IDOK),FALSE);
1294
1305
    fcwin_box_add_box(vbox,hbox,FALSE,FALSE,5);
1295
 
    create_advances_list(game.player_ptr, pvictim, lb);
 
1306
    create_advances_list(client.conn.playing, pvictim, lb);
1296
1307
    fcwin_set_box(spy_tech_dialog,vbox);
1297
1308
    ShowWindow(spy_tech_dialog,SW_SHOWNORMAL);
1298
1309
  }
1363
1374
    popup_message_dialog(root_window, _("Ooops..."),
1364
1375
                         _("This unit cannot be bribed!"),
1365
1376
                         diplomat_bribe_no_callback, 0, 0);
1366
 
  } else if (game.player_ptr->economic.gold >= cost) {
 
1377
  } else if (cost <= client.conn.playing->economic.gold) {
1367
1378
    my_snprintf(buf, sizeof(buf),
1368
1379
                _("Bribe unit for %d gold?\nTreasury contains %d gold."), 
1369
 
                cost, game.player_ptr->economic.gold);
 
1380
                cost, client.conn.playing->economic.gold);
1370
1381
    popup_message_dialog(root_window, /*"diplomatbribedialog"*/_("Bribe Enemy Unit"
1371
1382
), buf,
1372
1383
                        _("_Yes"), diplomat_bribe_yes_callback, 0,
1375
1386
    my_snprintf(buf, sizeof(buf),
1376
1387
                _("Bribing the unit costs %d gold.\n"
1377
1388
                  "Treasury contains %d gold."), 
1378
 
                cost, game.player_ptr->economic.gold);
 
1389
                cost, client.conn.playing->economic.gold);
1379
1390
    popup_message_dialog(root_window, /*"diplomatnogolddialog"*/
1380
1391
                _("Traitors Demand Too Much!"), buf, _("Darn"),
1381
1392
                diplomat_bribe_no_callback, 0, 0);
1393
1404
  ListBox_AddString(lb,_("City Production"));
1394
1405
  improvement_type[j++] = -1;
1395
1406
  
1396
 
  impr_type_iterate(i) {
1397
 
    if (improvement_by_number(i)->sabotage > 0) {
1398
 
      ListBox_AddString(lb,get_impr_name_ex(pcity,i));
1399
 
      improvement_type[j++] = i;
 
1407
  improvement_iterate(pimprove) {
 
1408
    if (pimprove->sabotage > 0) {
 
1409
      ListBox_AddString(lb,city_improvement_name_translation(pcity, pimprove));
 
1410
      improvement_type[j++] = improvement_index(pimprove);
1400
1411
    }  
1401
 
  } impr_type_iterate_end;
 
1412
  } improvement_iterate_end;
1402
1413
 
1403
1414
  if(j > 1) {
1404
1415
    ListBox_AddString(lb,_("At Spy's Discretion"));
1492
1503
    fcwin_box_add_button(hbox,_("Sabotage"),IDOK,0,TRUE,TRUE,10);
1493
1504
    EnableWindow(GetDlgItem(spy_sabotage_dialog,IDOK),FALSE);
1494
1505
    fcwin_box_add_box(vbox,hbox,FALSE,FALSE,5);
1495
 
    create_improvements_list(game.player_ptr, pcity, lb);
 
1506
    create_improvements_list(client.conn.playing, pcity, lb);
1496
1507
    fcwin_set_box(spy_sabotage_dialog,vbox);
1497
1508
    ShowWindow(spy_sabotage_dialog,SW_SHOWNORMAL);
1498
1509
  }
1549
1560
                city_name(pcity));
1550
1561
    popup_message_dialog(root_window, _("City can't be incited!"), buf,
1551
1562
                         _("Darn"), diplomat_incite_no_callback, 0, 0);
1552
 
  } else if (game.player_ptr->economic.gold >= cost) {
 
1563
  } else if (cost <= client.conn.playing->economic.gold) {
1553
1564
    my_snprintf(buf, sizeof(buf),
1554
1565
                _("Incite a revolt for %d gold?\nTreasury contains %d gold."), 
1555
 
                cost, game.player_ptr->economic.gold);
 
1566
                cost, client.conn.playing->economic.gold);
1556
1567
   diplomat_target_id = pcity->id;
1557
1568
   popup_message_dialog(root_window, /*"diplomatrevoltdialog"*/_("Incite a Revolt!"), buf,
1558
1569
                       _("_Yes"), diplomat_incite_yes_callback, 0,
1561
1572
    my_snprintf(buf, sizeof(buf),
1562
1573
                _("Inciting a revolt costs %d gold.\n"
1563
1574
                  "Treasury contains %d gold."), 
1564
 
                cost, game.player_ptr->economic.gold);
 
1575
                cost, client.conn.playing->economic.gold);
1565
1576
   popup_message_dialog(root_window, /*"diplomatnogolddialog"*/_("Traitors Demand Too Much!"), buf,
1566
1577
                       _("Darn"), diplomat_incite_no_callback, 0, 
1567
1578
                       0);
1593
1604
 
1594
1605
  diplomat_id=punit->id;
1595
1606
 
1596
 
  if ((pcity = tile_get_city(ptile))){
 
1607
  if ((pcity = tile_city(ptile))){
1597
1608
    /* Spy/Diplomat acting against a city */
1598
1609
 
1599
1610
    diplomat_target_id=pcity->id;
1716
1727
    id=LOWORD(wParam);
1717
1728
    if (id==IDCANCEL) {
1718
1729
      DestroyWindow(dlg);
1719
 
    } else if (id>=ID_PILLAGE_BASE) {
1720
 
      struct unit *punit=game_find_unit_by_number(unit_to_use_to_pillage);
 
1730
    } else if (id >= ID_PILLAGE_BASE) {
 
1731
      struct unit *punit = game_find_unit_by_number(unit_to_use_to_pillage);
1721
1732
      if (punit) {
 
1733
        Base_type_id pillage_base = -1;
 
1734
        int what = id - ID_PILLAGE_BASE;
 
1735
 
 
1736
        if (what > S_LAST) {
 
1737
          pillage_base = what - S_LAST - 1;
 
1738
          what = S_LAST;
 
1739
        }
 
1740
 
1722
1741
        request_new_unit_activity_targeted(punit,
1723
1742
                                           ACTIVITY_PILLAGE,
1724
 
                                           id-ID_PILLAGE_BASE);
 
1743
                                           what, pillage_base);
1725
1744
        DestroyWindow(dlg);
1726
1745
      }
1727
1746
    }
1736
1755
 
1737
1756
**************************************************************************/
1738
1757
void popup_pillage_dialog(struct unit *punit,
1739
 
                          bv_special may_pillage)
 
1758
                          bv_special may_pillage,
 
1759
                          bv_bases bases)
1740
1760
{
1741
1761
  HWND dlg;
1742
1762
  struct fcwin_box *vbox;
1743
 
  enum tile_special_type what, prereq;
 
1763
  int what;
 
1764
  enum tile_special_type prereq;
1744
1765
 
1745
1766
  if (!is_showing_pillage_dialog) {
1746
 
    is_showing_pillage_dialog = TRUE;   
 
1767
    is_showing_pillage_dialog = TRUE;
1747
1768
    unit_to_use_to_pillage = punit->id;
1748
1769
    dlg=fcwin_create_layouted_window(pillage_proc,_("What To Pillage"),
1749
1770
                                     WS_OVERLAPPEDWINDOW,
1754
1775
    vbox=fcwin_vbox_new(dlg,FALSE);
1755
1776
    fcwin_box_add_static(vbox,_("Select what to pillage:"),0,SS_LEFT,
1756
1777
                         FALSE,FALSE,10);
1757
 
    while ((what = get_preferred_pillage(may_pillage)) != S_LAST) {
 
1778
    while ((what = get_preferred_pillage(may_pillage, bases)) != S_LAST) {
1758
1779
      bv_special what_bv;
 
1780
      bv_bases what_base;
1759
1781
 
1760
1782
      BV_CLR_ALL(what_bv);
1761
 
      BV_SET(what_bv, what);
1762
 
 
1763
 
      fcwin_box_add_button(vbox, get_infrastructure_text(what_bv),
1764
 
                           ID_PILLAGE_BASE+what,0,TRUE,FALSE,5);
1765
 
 
1766
 
      clear_special(&may_pillage, what);
1767
 
      prereq = get_infrastructure_prereq(what);
1768
 
      if (prereq != S_LAST) {
1769
 
        clear_special(&may_pillage, prereq);
 
1783
      BV_CLR_ALL(what_base);
 
1784
 
 
1785
      if (what > S_LAST) {
 
1786
        BV_SET(what_base, what - S_LAST - 1);
 
1787
      } else {
 
1788
        BV_SET(what_bv, what);
 
1789
      }
 
1790
 
 
1791
      fcwin_box_add_button(vbox, get_infrastructure_text(what_bv, what_base),
 
1792
                           ID_PILLAGE_BASE+what,0,TRUE,FALSE,5);
 
1793
 
 
1794
      if (what > S_LAST) {
 
1795
        BV_CLR(bases, what - S_LAST - 1);
 
1796
      } else {
 
1797
        clear_special(&may_pillage, what);
 
1798
        prereq = get_infrastructure_prereq(what);
 
1799
        if (prereq != S_LAST) {
 
1800
          clear_special(&may_pillage, prereq);
 
1801
        }
1770
1802
      }
1771
1803
    }
1772
1804
    fcwin_box_add_button(vbox,_("Cancel"),IDCANCEL,0,TRUE,FALSE,5);