diff client/gui-gtk/helpdlg.c client/gui-gtk/helpdlg.c --- client/gui-gtk/helpdlg.c Thu Jun 29 22:19:32 2000 +++ client/gui-gtk/helpdlg.c Sun Jul 2 14:51:52 2000 @@ -61,6 +61,7 @@ GtkWidget * help_text; GtkWidget * help_text_scrolled; GtkWidget * help_vbox; +GtkWidget * help_parsebox; GtkWidget * unit_tile; GtkWidget * help_box; GtkWidget * help_itable; @@ -107,6 +108,9 @@ { N_("Mine Rslt/Time:"),"", "", N_("Trans. Rslt/Time:"), "" } }; +int linelength=0; +#define TAB_LENGTH 10 +#define MAX_COLUMN 6 static void create_help_dialog(void); static void help_update_dialog(const struct help_item *pitem); @@ -115,6 +119,7 @@ static void select_help_item(int item); static void select_help_item_string(const char *item, enum help_page_type htype); +static void set_column(int column, char *new_text); /**************************************************************** ... @@ -794,8 +799,7 @@ **************************************************************************/ static void help_update_tech(const struct help_item *pitem, char *title, int i) { - int j; - GtkWidget *w, *hbox; + GtkWidget *w; char *buf = &long_buffer[0]; create_help_page(HELP_TECH); @@ -823,84 +827,7 @@ gtk_label_set_justify(GTK_LABEL(w), GTK_JUSTIFY_LEFT); gtk_container_add(GTK_CONTAINER(help_vbox), w); - for(j=0; jtech_requirement) continue; - hbox = gtk_hbox_new(FALSE, 0); - gtk_container_add(GTK_CONTAINER(help_vbox), hbox); - w = gtk_label_new(_("Allows ")); - gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0); - w = help_slink_new(get_unit_type(j)->name, HELP_UNIT); - gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0); - w = gtk_label_new("."); - gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0); - } - - for(j=0; jname); + w = help_slink_new(get_unit_type(hunit)->name, HELP_UNIT); + gtk_box_pack_start(GTK_BOX(help_parsebox), w, FALSE, FALSE, 0); +} + +/************************************************************************** +... +**************************************************************************/ +void show_tech_help_label(Tech_Type_id htech, int column) +{ + GtkWidget *w; + + set_column(column, advances[htech].name); + w = help_slink_new(advances[htech].name, HELP_TECH); + gtk_box_pack_start(GTK_BOX(help_parsebox), w, FALSE, FALSE, 0); +} + +/************************************************************************** +... +**************************************************************************/ +void show_gov_help_label(int hgov, int column) +{ + GtkWidget *w; + + set_column(column, get_government_name(hgov)); + w = help_slink_new(get_government_name(hgov), HELP_GOVERNMENT); + gtk_box_pack_start(GTK_BOX(help_parsebox), w, FALSE, FALSE, 0); +} + +/************************************************************************** +... +**************************************************************************/ +static void set_column(int column, char *new_text) +{ + GtkWidget *w; + char spacetext[TAB_LENGTH*MAX_COLUMN]; + int i; + + if(column>MAX_COLUMN) + column=MAX_COLUMN; + if(!column || column*TAB_LENGTH<=linelength) { + linelength+=strlen(new_text); + return; + } + for(i=0; itext); - - for(j=0; jtech_requirement) - sprintf(buf+strlen(buf), _("Allows %s.\n"), - get_unit_type(j)->name); - } - - for(j=0; jtext); + create_tech_help(i); + if (strlen(parsebuf)) strcat(parsebuf, "\n"); if (advances[i].helptext) { - sprintf(buf+strlen(buf), "%s\n", _(advances[i].helptext)); + sprintf(parsebuf+strlen(parsebuf), "%s\n", _(advances[i].helptext)); } } else { - create_help_page(HELP_TECH); + create_help_page(HELP_TECH); /* Why again??? --Caz 29.06.00 */ create_tech_tree(help_tech_tree, 0, game.num_tech_types, 3); - strcpy(buf, pitem->text); + strcpy(parsebuf, pitem->text); } - wordwrap_string(buf, 68); - XtVaSetValues(help_text, XtNstring, buf, NULL); + wordwrap_string(parsebuf, 68); + XtVaSetValues(help_text, XtNstring, parsebuf, NULL); } /************************************************************************** @@ -1258,4 +1231,60 @@ if(idx==-1) idx = 0; select_help_item(idx); help_update_dialog(pitem); +} + +/************************************************************************** +... +**************************************************************************/ +void new_help_line() +{ + if (strlen(parsebuf)) strcat(parsebuf, "\n"); + linelength=0; +} + +/************************************************************************** +... +**************************************************************************/ +void show_text_help_label(char *htext, int column) +{ + if(column) { + while(column*TAB_LENGTH>linelength) { + strcat(parsebuf," "); + linelength++; + } + } + strcat(parsebuf, htext); + linelength+=strlen(htext); +} + +/************************************************************************** +... +**************************************************************************/ +void show_building_help_label(int hbuilding, int column) +{ + show_text_help_label(improvement_types[hbuilding].name, column); +} + +/************************************************************************** +... +**************************************************************************/ +void show_unit_help_label(Unit_Type_id hunit, int column) +{ + show_text_help_label(get_unit_type(hunit)->name, column); +} + +/************************************************************************** +... +**************************************************************************/ +void show_tech_help_label(Tech_Type_id htech, int column) +{ + show_text_help_label(advances[htech].name, column); +} + +/************************************************************************** +... +**************************************************************************/ +void show_gov_help_label(int hgov, int column) +{ + show_text_help_label(get_government_name(hgov), column); } diff client/helpdata.c client/helpdata.c --- client/helpdata.c Thu Jun 29 22:19:32 2000 +++ client/helpdata.c Sun Jul 2 13:54:35 2000 @@ -767,18 +767,9 @@ *****************************************************************/ void helptext_tech(char *buf, int i, const char *user_text) { - int gov; - assert(buf&&user_text); strcpy(buf, user_text); - for(gov=0; govrequired_tech == i) { - sprintf(buf+strlen(buf), _("Allows changing government to %s.\n"), - g->name); - } - } if(tech_flag(i,TF_BONUS_TECH)) { sprintf(buf+strlen(buf), _("The first player to research %s gets an immediate advance.\n"), @@ -936,3 +927,64 @@ return buf; } #endif + + +int create_tech_help(Tech_Type_id tech) +{ + int j; + + if (tech>=game.num_tech_types || tech==A_NONE) + return 0; + for(j=0; jrequired_tech) { + new_help_line(); + show_text_help_label(_("Allows changing government to "),0); + show_gov_help_label(j,0); + show_text_help_label(".",0); + } + } + for(j=0; jtech_requirement) { + new_help_line(); + show_text_help_label(_("Allows "),0); + show_unit_help_label(j,0); + show_text_help_label(".",0); + } + } + for(j=0; j