diff -Nur -Xfreeciv/diff_ignore freeciv/client/gui-gtk/citydlg.c testing-buy2/client/gui-gtk/citydlg.c --- freeciv/client/gui-gtk/citydlg.c Tue Feb 12 21:15:57 2002 +++ testing-buy2/client/gui-gtk/citydlg.c Sun Feb 17 15:24:18 2002 @@ -105,7 +105,9 @@ GtkWidget *map_canvas_pixmap; GtkWidget *tradelist; GtkWidget *currently_building_frame; - GtkWidget *progress_label; + GtkWidget *shields_label; + GtkWidget *turns_label; + GtkWidget *cost_label; GtkWidget *improvement_list; GtkWidget *buy_command; GtkWidget *change_command; @@ -602,7 +604,7 @@ { int i; GtkWidget *halves, *hbox, *vbox, *page, *align; - GtkWidget *frame, *table, *label, *scrolledwin; + GtkWidget *frame, *table, *label, *scrolledwin, *sep; char *improvement_title[] = { N_("City improvements"), N_("Upkeep") @@ -813,16 +815,23 @@ gtk_container_add(GTK_CONTAINER (pdialog->overview.currently_building_frame), hbox); - pdialog->overview.progress_label = gtk_progress_bar_new(); - gtk_box_pack_start(GTK_BOX(hbox), pdialog->overview.progress_label, - TRUE, TRUE, 0); - gtk_progress_configure(GTK_PROGRESS(pdialog->overview.progress_label), - 50, 0, 100); - gtk_progress_set_show_text(GTK_PROGRESS - (pdialog->overview.progress_label), TRUE); - gtk_progress_set_format_string(GTK_PROGRESS - (pdialog->overview.progress_label), - _("%d/%d %d turns")); + pdialog->overview.shields_label = gtk_label_new(_("999/999")); + gtk_box_pack_start(GTK_BOX(hbox), pdialog->overview.shields_label, + TRUE, TRUE, 5); + + sep = gtk_vseparator_new(); + gtk_box_pack_start(GTK_BOX(hbox), sep, TRUE, TRUE, 0); + + pdialog->overview.turns_label = gtk_label_new(_("999 turns")); + gtk_box_pack_start(GTK_BOX(hbox), pdialog->overview.turns_label, + TRUE, TRUE, 5); + + sep = gtk_vseparator_new(); + gtk_box_pack_start(GTK_BOX(hbox), sep, TRUE, TRUE, 0); + + pdialog->overview.cost_label = gtk_label_new(_("cost: 9999")); + gtk_box_pack_start(GTK_BOX(hbox), pdialog->overview.cost_label, + TRUE, TRUE, 5); pdialog->overview.buy_command = gtk_accelbutton_new(_("_Buy"), pdialog->accel); @@ -1889,65 +1898,53 @@ *****************************************************************/ static void city_dialog_update_building(struct city_dialog *pdialog) { - char buf[32], buf2[200], *descr; - int turns; + char sbuf[10], tbuf[20], cbuf[20], dbuf[200], *descr; struct city *pcity = pdialog->pcity; - gfloat pct; + int turns; gtk_widget_set_sensitive(pdialog->overview.buy_command, !pcity->did_buy); - gtk_widget_set_sensitive(pdialog->overview.sell_command, - !pcity->did_sell); + gtk_widget_set_sensitive(pdialog->overview.sell_command, !pcity->did_sell); if (pcity->is_building_unit) { - turns = - city_turns_to_build(pcity, pcity->currently_building, TRUE, TRUE); - my_snprintf(buf, sizeof(buf), - concise_city_production ? "%3d/%3d:%3d" : - PL_("%3d/%3d %3d turn", "%3d/%3d %3d turns", turns), - pcity->shield_stock, - get_unit_type(pcity->currently_building)->build_cost, - turns); + turns = city_turns_to_build(pcity, pcity->currently_building, TRUE, TRUE); descr = get_unit_type(pcity->currently_building)->name; - pct = - (gfloat) pcity->shield_stock / - (get_unit_type(pcity->currently_building)->build_cost + 0.1); - pct = CLAMP(pct, 0.0, 1.0); + + my_snprintf(sbuf, sizeof(sbuf), "%3d/%-3d", pcity->shield_stock, + get_unit_type(pcity->currently_building)->build_cost); + my_snprintf(tbuf, sizeof(tbuf), PL_("%3d turn", "%3d turns", turns), turns); + my_snprintf(cbuf, sizeof(cbuf), "cost: %-5d", city_buy_cost(pcity)); + } else { if (pcity->currently_building == B_CAPITAL) { /* Capitalization is special, you can't buy it or finish making it */ - my_snprintf(buf, sizeof(buf), - concise_city_production ? "%3d/XXX:XXX" : - _("%3d/XXX XXX turns"), pcity->shield_stock); + + my_snprintf(sbuf, sizeof(sbuf), "%3d/XXX", pcity->shield_stock); + my_snprintf(tbuf, sizeof(tbuf), "XXX turns"); + my_snprintf(cbuf, sizeof(cbuf), "cost: XXX "); + gtk_widget_set_sensitive(pdialog->overview.buy_command, FALSE); - pct = 1.0; } else { - turns = - city_turns_to_build(pcity, pcity->currently_building, FALSE, - TRUE); - my_snprintf(buf, sizeof(buf), - concise_city_production ? "%3d/%3d:%3d" : - PL_("%3d/%3d %3d turn", "%3d/%3d %3d turns", turns), - pcity->shield_stock, - get_improvement_type(pcity->currently_building)-> - build_cost, turns); - - pct = (gfloat) pcity->shield_stock / - (get_improvement_type(pcity->currently_building)->build_cost + - 0.1); - pct = CLAMP(pct, 0.0, 1.0); + turns = city_turns_to_build(pcity, pcity->currently_building, FALSE, + TRUE); + + my_snprintf(sbuf, sizeof(sbuf), "%3d/%-3d", pcity->shield_stock, + get_improvement_type(pcity->currently_building)->build_cost); + my_snprintf(tbuf, sizeof(tbuf), PL_("%3d turn", "%3d turns", turns), + turns); + my_snprintf(cbuf, sizeof(cbuf), "cost: %-5d", city_buy_cost(pcity)); } + descr = get_impr_name_ex(pcity, pcity->currently_building); } - my_snprintf(buf2, sizeof(buf2), "%s%s", descr, + my_snprintf(dbuf, sizeof(dbuf), "%s%s", descr, worklist_is_empty(pcity->worklist) ? "" : _(" (worklist)")); - gtk_frame_set_label(GTK_FRAME - (pdialog->overview.currently_building_frame), buf2); - gtk_progress_set_percentage(GTK_PROGRESS - (pdialog->overview.progress_label), pct); - gtk_progress_set_format_string(GTK_PROGRESS - (pdialog->overview.progress_label), buf); + gtk_frame_set_label(GTK_FRAME(pdialog->overview.currently_building_frame), + dbuf); + gtk_label_set_text(GTK_LABEL(pdialog->overview.shields_label), sbuf); + gtk_label_set_text(GTK_LABEL(pdialog->overview.turns_label), tbuf); + gtk_label_set_text(GTK_LABEL(pdialog->overview.cost_label), cbuf); } /**************************************************************** @@ -3303,8 +3300,8 @@ GList *selection = GTK_CLIST(pdialog->overview.improvement_list)->selection; - if (!selection || pdialog->pcity->did_buy || pdialog->pcity->did_sell || - pdialog->pcity->owner != game.player_idx) { + if (!selection || pdialog->pcity->did_sell + || pdialog->pcity->owner != game.player_idx) { gtk_set_label(GTK_BUTTON(pdialog->overview.sell_command)->child, _("Sell")); gtk_widget_set_sensitive(pdialog->overview.sell_command, FALSE);