~ubuntu-branches/debian/sid/freeciv/sid

« back to all changes in this revision

Viewing changes to client/gui-win32/repodlgs.c

  • Committer: Bazaar Package Importer
  • Author(s): Clint Adams, Karl Goetz, Clint Adams
  • Date: 2010-02-23 22:09:02 UTC
  • mfrom: (7.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100223220902-s3spqi1x4e190y0t
[ 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:
24
24
#include <windowsx.h>
25
25
#include <commctrl.h>
26
26
 
 
27
/* utility */
27
28
#include "fcintl.h"
28
 
#include "game.h"
 
29
#include "log.h"
 
30
#include "shared.h"
 
31
#include "support.h"
 
32
 
 
33
/* common */
29
34
#include "government.h"
30
35
#include "packets.h"
31
 
#include "shared.h"
32
 
#include "support.h"
33
36
#include "unitlist.h"
34
37
 
 
38
/* client */
35
39
#include "chatline_common.h"    /* send_chat() */ 
36
40
#include "cityrep.h"
37
 
#include "civclient.h"
 
41
#include "client_main.h"
38
42
#include "climisc.h"
39
43
#include "dialogs.h"
40
44
#include "gui_stuff.h"
57
61
 
58
62
extern HINSTANCE freecivhinst;
59
63
extern HWND root_window;
60
 
extern struct connection aconnection;
61
 
int economy_improvement_type[B_LAST];
 
64
 
 
65
struct impr_type *economy_improvement_type[B_LAST];
62
66
struct unit_type *activeunits_type[U_LAST];
63
67
 
64
68
#define ID_OPTIONS_BASE 1000
96
100
  SetWindowText(GetDlgItem(science_dlg, ID_SCIENCE_TOP), text);
97
101
  ListBox_ResetContent(GetDlgItem(science_dlg, ID_SCIENCE_LIST));
98
102
 
99
 
  tech_type_iterate(tech_id) {
100
 
    if (get_invention(game.player_ptr, tech_id) == TECH_KNOWN
101
 
        && tech_id != A_NONE) {
 
103
  advance_index_iterate(A_FIRST, tech_id) {
 
104
    if (TECH_KNOWN == player_invention_state(client.conn.playing, tech_id)) {
102
105
      id = ListBox_AddString(GetDlgItem(science_dlg, ID_SCIENCE_LIST),
103
 
                             advance_name_for_player(game.player_ptr, tech_id));
 
106
                             advance_name_for_player(client.conn.playing, tech_id));
104
107
      ListBox_SetItemData(GetDlgItem(science_dlg,ID_SCIENCE_LIST), id,
105
108
                          tech_id);
106
109
    }
107
 
  } tech_type_iterate_end;
 
110
  } advance_index_iterate_end;
108
111
 
109
112
  ComboBox_ResetContent(GetDlgItem(science_dlg, ID_SCIENCE_RESEARCH));
110
113
 
111
 
  if (get_player_research(game.player_ptr)->researching == A_UNSET) {
 
114
  if (A_UNSET == get_player_research(client.conn.playing)->researching) {
112
115
    id = ComboBox_AddString(GetDlgItem(science_dlg, ID_SCIENCE_RESEARCH),
113
 
                            advance_name_for_player(game.player_ptr, A_NONE));
 
116
                            advance_name_for_player(client.conn.playing, A_NONE));
114
117
    ComboBox_SetItemData(GetDlgItem(science_dlg, ID_SCIENCE_RESEARCH),
115
118
                         id, A_NONE);
116
119
    ComboBox_SetCurSel(GetDlgItem(science_dlg, ID_SCIENCE_RESEARCH),
118
121
    text[0] = '\0';
119
122
  } else {
120
123
    my_snprintf(text, sizeof(text), "%d/%d",
121
 
                get_player_research(game.player_ptr)->bulbs_researched,
122
 
                total_bulbs_required(game.player_ptr));
 
124
                get_player_research(client.conn.playing)->bulbs_researched,
 
125
                total_bulbs_required(client.conn.playing));
123
126
  }
124
127
 
125
128
  SetWindowText(GetDlgItem(science_dlg, ID_SCIENCE_PROG), text);
126
129
 
127
 
  if (!is_future_tech(get_player_research(game.player_ptr)->researching)) {
128
 
    tech_type_iterate(tech_id) {
129
 
      if (get_invention(game.player_ptr, tech_id) != TECH_REACHABLE) {
 
130
  if (!is_future_tech(get_player_research(client.conn.playing)->researching)) {
 
131
    advance_index_iterate(A_FIRST, tech_id) {
 
132
      if (TECH_PREREQS_KNOWN !=
 
133
            player_invention_state(client.conn.playing, tech_id)) {
130
134
        continue;
131
135
      }
132
136
 
133
137
      id = ComboBox_AddString(GetDlgItem(science_dlg, ID_SCIENCE_RESEARCH),
134
 
                              advance_name_for_player(game.player_ptr, tech_id));
 
138
                              advance_name_for_player(client.conn.playing, tech_id));
135
139
      ComboBox_SetItemData(GetDlgItem(science_dlg, ID_SCIENCE_RESEARCH),
136
140
                           id, tech_id);
137
 
      if (tech_id == get_player_research(game.player_ptr)->researching) {
 
141
      if (tech_id == get_player_research(client.conn.playing)->researching) {
138
142
        ComboBox_SetCurSel(GetDlgItem(science_dlg, ID_SCIENCE_RESEARCH),
139
143
                           id);
140
144
      }
141
 
    } tech_type_iterate_end;
 
145
    } advance_index_iterate_end;
142
146
  } else {
143
 
      tech_id = game.control.num_tech_types + 1
144
 
                + get_player_research(game.player_ptr)->future_tech;
 
147
      tech_id = advance_count() + 1
 
148
                + get_player_research(client.conn.playing)->future_tech;
145
149
      id = ComboBox_AddString(GetDlgItem(science_dlg, ID_SCIENCE_RESEARCH),
146
 
                              advance_name_for_player(game.player_ptr, tech_id));
 
150
                              advance_name_for_player(client.conn.playing, tech_id));
147
151
      ComboBox_SetItemData(GetDlgItem(science_dlg, ID_SCIENCE_RESEARCH),
148
152
                           id, tech_id);
149
153
      ComboBox_SetCurSel(GetDlgItem(science_dlg, ID_SCIENCE_RESEARCH),
151
155
  }
152
156
  ComboBox_ResetContent(GetDlgItem(science_dlg,ID_SCIENCE_GOAL));
153
157
    hist=0;
154
 
  tech_type_iterate(tech_id) {
155
 
    if (tech_is_available(game.player_ptr, tech_id)
156
 
        && get_invention(game.player_ptr, tech_id) != TECH_KNOWN
157
 
        && advances[tech_id].req[0] != A_LAST
158
 
        && advances[tech_id].req[1] != A_LAST
159
 
        && (num_unknown_techs_for_goal(game.player_ptr, tech_id) < 11
160
 
            || tech_id == get_player_research(game.player_ptr)->tech_goal)) {
 
158
  advance_index_iterate(A_FIRST, tech_id) {
 
159
    if (player_invention_reachable(client.conn.playing, tech_id)
 
160
        && TECH_KNOWN != player_invention_state(client.conn.playing, tech_id)
 
161
        && (11 > num_unknown_techs_for_goal(client.conn.playing, tech_id)
 
162
            || tech_id == get_player_research(client.conn.playing)->tech_goal)) {
161
163
      id = ComboBox_AddString(GetDlgItem(science_dlg,ID_SCIENCE_GOAL),
162
 
                              advance_name_for_player(game.player_ptr, tech_id));
 
164
                              advance_name_for_player(client.conn.playing, tech_id));
163
165
       ComboBox_SetItemData(GetDlgItem(science_dlg,ID_SCIENCE_GOAL),
164
166
                         id, tech_id);
165
 
      if (tech_id == get_player_research(game.player_ptr)->tech_goal)
 
167
      if (tech_id == get_player_research(client.conn.playing)->tech_goal)
166
168
        ComboBox_SetCurSel(GetDlgItem(science_dlg,ID_SCIENCE_GOAL),
167
169
                           id);
168
170
       
169
171
     }
170
 
  } tech_type_iterate_end;
 
172
  } advance_index_iterate_end;
171
173
 
172
 
  if (get_player_research(game.player_ptr)->tech_goal == A_UNSET) {
 
174
  if (A_UNSET == get_player_research(client.conn.playing)->tech_goal) {
173
175
    id = ComboBox_AddString(GetDlgItem(science_dlg, ID_SCIENCE_GOAL),
174
 
                            advance_name_for_player(game.player_ptr, A_NONE));
 
176
                            advance_name_for_player(client.conn.playing, A_NONE));
175
177
    ComboBox_SetItemData(GetDlgItem(science_dlg, ID_SCIENCE_GOAL),
176
178
                         id, A_NONE);
177
179
    ComboBox_SetCurSel(GetDlgItem(science_dlg, ID_SCIENCE_GOAL),
178
180
                       id);
179
181
   }
180
182
 
181
 
  steps = num_unknown_techs_for_goal(game.player_ptr,
182
 
                            get_player_research(game.player_ptr)->tech_goal);
 
183
  steps = num_unknown_techs_for_goal(client.conn.playing,
 
184
                            get_player_research(client.conn.playing)->tech_goal);
183
185
  my_snprintf(text, sizeof(text),
184
186
              PL_("(%d step)", "(%d steps)", steps), steps);
185
187
  SetWindowText(GetDlgItem(science_dlg,ID_SCIENCE_STEPS),text);
215
217
                                        to);
216
218
              
217
219
              if (IsDlgButtonChecked(hWnd, ID_SCIENCE_HELP)) {
218
 
                popup_help_dialog_typed(advance_name_translation(to), HELP_TECH);
 
220
                popup_help_dialog_typed(advance_name_translation(advance_by_number(to)),
 
221
                                        HELP_TECH);
219
222
                science_dialog_update();
220
223
              } else {
221
 
                dsend_packet_player_research(&aconnection, to);
 
224
                dsend_packet_player_research(&client.conn, to);
222
225
              }
223
226
            }
224
227
          }
231
234
 
232
235
              to = ComboBox_GetItemData(GetDlgItem(hWnd, ID_SCIENCE_GOAL),
233
236
                                        to);
234
 
              steps = num_unknown_techs_for_goal(game.player_ptr, to);
 
237
              steps = num_unknown_techs_for_goal(client.conn.playing, to);
235
238
              my_snprintf(text, sizeof(text), 
236
239
                          PL_("(%d step)", "(%d steps)", steps),
237
240
                          steps);
238
241
              SetWindowText(GetDlgItem(hWnd,ID_SCIENCE_STEPS), text);
239
 
              dsend_packet_player_tech_goal(&aconnection, to);
 
242
              dsend_packet_player_tech_goal(&client.conn, to);
240
243
            }
241
244
          }
242
245
          break;
485
488
*****************************************************************/
486
489
static void upgrade_callback_yes(HWND w, void * data)
487
490
{
488
 
  dsend_packet_unit_type_upgrade(&aconnection, (size_t)data);
 
491
  dsend_packet_unit_type_upgrade(&client.conn, (size_t)data);
489
492
  destroy_message_dialog(w);
490
493
}
491
494
 
535
538
    case WM_NOTIFY:
536
539
      if (sel>=0) {
537
540
        CHECK_UNIT_TYPE(activeunits_type[sel]);
538
 
        if (can_upgrade_unittype(game.player_ptr,
 
541
        if (can_upgrade_unittype(client.conn.playing,
539
542
                                 activeunits_type[sel]) != NULL) {
540
543
          EnableWindow(GetDlgItem(activeunits_dlg,ID_MILITARY_UPGRADE),
541
544
                       TRUE);
563
566
 
564
567
              ut1 = activeunits_type[sel];
565
568
              CHECK_UNIT_TYPE(ut1);
566
 
              ut2=can_upgrade_unittype(game.player_ptr,activeunits_type[sel]);
 
569
              ut2 = can_upgrade_unittype(client.conn.playing, activeunits_type[sel]);
567
570
              my_snprintf(buf, sizeof(buf),
568
571
                          _("Upgrade as many %s to %s as possible for %d gold each?\n"
569
572
                            "Treasury contains %d gold."),
570
573
                          utype_name_translation(ut1),
571
574
                          utype_name_translation(ut2),
572
 
                          unit_upgrade_price(game.player_ptr, ut1, ut2),
573
 
                          game.player_ptr->economic.gold);    
 
575
                          unit_upgrade_price(client.conn.playing, ut1, ut2),
 
576
                          client.conn.playing->economic.gold);
574
577
 
575
578
              popup_message_dialog(NULL, 
576
579
                                   /*"upgradedialog"*/
597
600
{
598
601
  struct repoinfo {
599
602
    int active_count;
600
 
    int upkeep_shield;
601
 
    int upkeep_food;
602
 
    /* int upkeep_gold;   FIXME: add gold when gold is implemented --jjm */
 
603
    int upkeep[O_LAST];
603
604
    int building_count;
604
 
  };                         
 
605
  };
 
606
 
605
607
  if(activeunits_dlg) {
606
608
    HWND lv;
607
609
    int    i, k, can;
621
623
    }
622
624
 
623
625
    memset(unitarray, '\0', sizeof(unitarray));
624
 
    unit_list_iterate(game.player_ptr->units, punit) {
625
 
      (unitarray[unit_type(punit)->index].active_count)++;
626
 
      if (punit->homecity) {
627
 
        unitarray[unit_type(punit)->index].upkeep_shield += punit->upkeep[O_SHIELD];
628
 
        unitarray[unit_type(punit)->index].upkeep_food += punit->upkeep[O_FOOD];
629
 
        /* TODO: gold upkeep */
630
 
      }
631
 
    }
632
 
 
633
 
    unit_list_iterate_end;
634
 
    city_list_iterate(game.player_ptr->cities,pcity) {
635
 
      if (pcity->production.is_unit) {
636
 
        (unitarray[pcity->production.value].building_count)++;
 
626
 
 
627
   city_list_iterate(client.conn.playing->cities, pcity) {
 
628
      unit_list_iterate(client.conn.playing->units, punit) {
 
629
        Unit_type_id uti = utype_index(unit_type(punit));
 
630
 
 
631
        (unitarray[uti].active_count)++;
 
632
        if (punit->homecity) {
 
633
          output_type_iterate(o) {
 
634
            unitarray[uti].upkeep[o] += punit->upkeep[o];
 
635
          } output_type_iterate_end;
 
636
        }
 
637
      } unit_list_iterate_end;
 
638
   } city_list_iterate_end;
 
639
 
 
640
    city_list_iterate(client.conn.playing->cities, pcity) {
 
641
      if (VUT_UTYPE == pcity->production.kind) {
 
642
        struct unit_type *punittype = pcity->production.value.utype;
 
643
        (unitarray[utype_index(punittype)].building_count)++;
637
644
      }
638
645
    }
639
646
    city_list_iterate_end;
640
647
 
641
648
    k = 0;
642
649
    memset(&unittotals, '\0', sizeof(unittotals));
643
 
    unit_type_iterate(i) {
644
 
      if ((unitarray[i->index].active_count > 0)
645
 
          || (unitarray[i->index].building_count > 0)) {
646
 
        can = (can_upgrade_unittype(game.player_ptr, i) != NULL);
647
 
        my_snprintf(buf[0], sizeof(buf[0]), "%s", utype_name_translation(i));
 
650
    unit_type_iterate(putype) {
 
651
      int index = utype_index(putype);
 
652
      if ((unitarray[index].active_count > 0)
 
653
          || (unitarray[index].building_count > 0)) {
 
654
        can = (can_upgrade_unittype(client.conn.playing, putype) != NULL);
 
655
        my_snprintf(buf[0], sizeof(buf[0]), "%s",
 
656
                    utype_name_translation(putype));
648
657
        my_snprintf(buf[1], sizeof(buf[1]), "%c", can ? '*': '-');
649
658
        my_snprintf(buf[2], sizeof(buf[2]), "%3d",
650
 
                                   unitarray[i->index].building_count);
 
659
                    unitarray[index].building_count);
651
660
        my_snprintf(buf[3], sizeof(buf[3]), "%3d",
652
 
                                   unitarray[i->index].active_count);
 
661
                    unitarray[index].active_count);
653
662
        my_snprintf(buf[4], sizeof(buf[4]), "%3d",
654
 
                                   unitarray[i->index].upkeep_shield);
 
663
                    unitarray[index].upkeep[O_SHIELD]);
655
664
        my_snprintf(buf[5], sizeof(buf[5]), "%3d",
656
 
                                   unitarray[i->index].upkeep_food);
657
 
        fcwin_listview_add_row(lv,k,AU_COL,row);
658
 
        activeunits_type[k]=(unitarray[i->index].active_count > 0) ? i : NULL;
 
665
                    unitarray[index].upkeep[O_FOOD]);
 
666
        /* TODO: add upkeep[O_GOLD] here */
 
667
        fcwin_listview_add_row(lv,k,AU_COL,row);
 
668
        activeunits_type[k]=(unitarray[index].active_count > 0) ? putype : NULL;
659
669
        k++;
660
 
        unittotals.active_count += unitarray[i->index].active_count;
661
 
        unittotals.upkeep_shield += unitarray[i->index].upkeep_shield;
662
 
        unittotals.upkeep_food += unitarray[i->index].upkeep_food;
663
 
        unittotals.building_count += unitarray[i->index].building_count;
 
670
        unittotals.active_count += unitarray[index].active_count;
 
671
        output_type_iterate(o) {
 
672
          unittotals.upkeep[0] = unitarray[index].upkeep[o];
 
673
        } output_type_iterate_end;
 
674
        unittotals.building_count += unitarray[index].building_count;
664
675
      }
665
676
    } unit_type_iterate_end;
666
677
 
668
679
    buf[1][0]='\0';
669
680
    my_snprintf(buf[2],sizeof(buf[2]),"%d",unittotals.building_count);
670
681
    my_snprintf(buf[3],sizeof(buf[3]),"%d",unittotals.active_count);
671
 
    my_snprintf(buf[4],sizeof(buf[4]),"%d",unittotals.upkeep_shield);
672
 
    my_snprintf(buf[5],sizeof(buf[5]),"%d",unittotals.upkeep_food);  
 
682
    my_snprintf(buf[4],sizeof(buf[4]),"%d",unittotals.upkeep[O_SHIELD]);
 
683
    my_snprintf(buf[5],sizeof(buf[5]),"%d",unittotals.upkeep[O_FOOD]);
 
684
    /* TODO: add upkeep[O_GOLD] here */
673
685
    fcwin_listview_add_row(lv,k,AU_COL,row);
674
686
    EnableWindow(GetDlgItem(activeunits_dlg,ID_MILITARY_UPGRADE),FALSE);
675
687
    ListView_SetColumnWidth(lv,0,LVSCW_AUTOSIZE);
816
828
            int val = Button_GetState(GetDlgItem(tab_wnds[tab],
817
829
                                      ID_OPTIONS_BASE + i)) == BST_CHECKED;
818
830
            if (val != o->val) {
819
 
              char buffer[MAX_LEN_MSG];
820
 
              my_snprintf(buffer, MAX_LEN_MSG, "/set %s %d",
821
 
                          o->name, val);
822
 
              send_chat(buffer);
 
831
              send_chat_printf("/set %s %d", o->name, val);
823
832
            }
824
833
          } else if (SSET_INT == o->stype) {
825
834
            char buf[512];
828
837
                                    512);
829
838
            val = atoi(buf);
830
839
            if (val != o->val) {
831
 
              char buffer[MAX_LEN_MSG];
832
 
              my_snprintf(buffer, MAX_LEN_MSG, "/set %s %d",
833
 
                          o->name, val);
834
 
              send_chat(buffer);
835
 
            }       
 
840
              send_chat_printf("/set %s %d", o->name, val);
 
841
            }
836
842
          } else {
837
843
            char strval[512];
838
844
            Edit_GetText(GetDlgItem(tab_wnds[tab], ID_OPTIONS_BASE + i),
839
845
                         strval, 512);
840
846
            if (strcmp(strval, o->strval) != 0) {
841
 
              char buffer[MAX_LEN_MSG];
842
 
              my_snprintf(buffer, MAX_LEN_MSG, "/set %s %s",
843
 
                          o->name, strval);
844
 
              send_chat(buffer);
 
847
              send_chat_printf("/set %s %s", o->name, strval);
845
848
            }
846
849
          }
847
850
        }