173
174
**************************************************************************/
174
175
void popup_notify_goto_dialog(const char *headline, const char *lines,
176
const struct text_tag_list *tags,
177
179
struct fcwin_box *hbox;
178
180
struct fcwin_box *vbox;
197
199
/**************************************************************************
200
Popup a dialog to display connection message from server.
201
**************************************************************************/
202
void popup_connect_msg(const char *headline, const char *message)
204
/* FIXME: Needs proper implementation.
205
* Now just puts to chat window so message is not completely lost. */
207
output_window_append(ftc_client, message);
210
/**************************************************************************
199
212
**************************************************************************/
200
213
static LONG CALLBACK notify_proc(HWND hWnd,
284
297
**************************************************************************/
285
298
static void update_nation_info()
290
303
struct nation_type *nation = nation_by_number(selected_nation);
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)
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);
355
370
name,MAX_LEN_NAME);
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."));
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);
364
379
popdown_races_dialog();
484
499
* const strings. Now we just cast const away */
485
500
strings[0] = (char *) nation_adjective_translation(pnation);
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);
490
505
} nations_iterate_end;
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]);
697
712
set_unit_focus(punit);
702
717
id-=UNITSELECT_UNITS_BASE;
703
718
if ((id>=0)&&(id<100))
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);
798
813
struct unit *punit = unit_list[i];
799
814
struct unit_type *punittemp=unit_type(punit);
815
struct city *pcity = player_find_city_by_id(client.conn.playing, punit->homecity);
801
817
unit_select_ids[i]=punit->id;
802
pcity=player_find_city_by_id(game.player_ptr, punit->homecity);
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);
845
struct city *pcity = player_find_city_by_id(client.conn.playing, punit->homecity);
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;
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) : "",
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);
926
for (i = 0; i < game.control.nation_count; i++) {
927
struct nation_type *nation;
928
nation = nation_by_number(i);
930
if (!(nation->is_unavailable || nation->is_used)) {
941
nations_iterate(nation) {
942
if (!nation->is_available || nation->player) {
934
EnableWindow(GetDlgItem(races_dlg, ID_RACESDLG_NATION_BASE + i),
946
EnableWindow(GetDlgItem(races_dlg, ID_RACESDLG_NATION_BASE + nation_index(nation)),
950
} nations_iterate_end;
941
953
select_random_race(races_dlg);
971
983
*****************************************************************/
972
984
void popup_revolution_dialog(struct government *gov)
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)
994
dsend_packet_unit_establish_trade(&aconnection, caravan_unit_id);
1006
dsend_packet_unit_establish_trade(&client.conn, caravan_unit_id);
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)
1007
dsend_packet_unit_help_build_wonder(&aconnection, caravan_unit_id);
1019
dsend_packet_unit_help_build_wonder(&client.conn, caravan_unit_id);
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"),
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)
1179
1191
advance_type[j] = -1;
1181
1193
if (pvictim) { /* you don't want to know what lag can do -- Syela */
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;
1201
} advance_index_iterate_end;
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);
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"
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;
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);
1401
} impr_type_iterate_end;
1412
} improvement_iterate_end;
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);
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,
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);
1733
Base_type_id pillage_base = -1;
1734
int what = id - ID_PILLAGE_BASE;
1736
if (what > S_LAST) {
1737
pillage_base = what - S_LAST - 1;
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);
1737
1756
**************************************************************************/
1738
1757
void popup_pillage_dialog(struct unit *punit,
1739
bv_special may_pillage)
1758
bv_special may_pillage,
1742
1762
struct fcwin_box *vbox;
1743
enum tile_special_type what, prereq;
1764
enum tile_special_type prereq;
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;
1760
1782
BV_CLR_ALL(what_bv);
1761
BV_SET(what_bv, what);
1763
fcwin_box_add_button(vbox, get_infrastructure_text(what_bv),
1764
ID_PILLAGE_BASE+what,0,TRUE,FALSE,5);
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);
1785
if (what > S_LAST) {
1786
BV_SET(what_base, what - S_LAST - 1);
1788
BV_SET(what_bv, what);
1791
fcwin_box_add_button(vbox, get_infrastructure_text(what_bv, what_base),
1792
ID_PILLAGE_BASE+what,0,TRUE,FALSE,5);
1794
if (what > S_LAST) {
1795
BV_CLR(bases, what - S_LAST - 1);
1797
clear_special(&may_pillage, what);
1798
prereq = get_infrastructure_prereq(what);
1799
if (prereq != S_LAST) {
1800
clear_special(&may_pillage, prereq);
1772
1804
fcwin_box_add_button(vbox,_("Cancel"),IDCANCEL,0,TRUE,FALSE,5);