Freeciv-3.2
Loading...
Searching...
No Matches
manual_buildings.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* utility */
19#include "fcintl.h"
20
21/* common */
22#include "game.h"
23
24/* client */
25#include "helpdata.h"
26
27/* tools/manual */
28#include "fc_manual.h"
29
30/**********************************************************************/
38 enum manuals manual)
39{
40 FILE *doc;
41
43
44 if (doc == NULL) {
45 return FALSE;
46 }
47
48 if (manual == MANUAL_BUILDINGS) {
49 /* TRANS: markup ... Freeciv version ... ruleset name ... markup */
50 fprintf(doc, _("%sFreeciv %s buildings help (%s)%s\n\n"), tag_info->title_begin,
52 } else {
53 /* TRANS: markup ... Freeciv version ... ruleset name ... markup */
54 fprintf(doc, _("%sFreeciv %s wonders help (%s)%s\n\n"), tag_info->title_begin,
56 }
57
58 fprintf(doc, "<table>\n<tr bgcolor=#9bc3d1><th colspan=2>%s</th>"
59 "<th>%s<br/>%s</th><th>%s<br/>%s</th><th>%s</th></tr>\n\n",
60 _("Name"), _("Cost"), _("Upkeep"),
61 _("Requirement"), _("Obsolete by"), _("More info"));
62
63 improvement_iterate(pimprove) {
64 char buf[64000];
65
66 if (!valid_improvement(pimprove)
67 || is_great_wonder(pimprove) == (manual == MANUAL_BUILDINGS)) {
68 continue;
69 }
70
71 helptext_building(buf, sizeof(buf), NULL, NULL, pimprove);
72
73 fprintf(doc, "<tr><td>%s%s%s</td><td>%s</td>\n"
74 "<td align=\"center\"><b>%d</b><br/>%d</td>\n<td>",
75 tag_info->image_begin, pimprove->graphic_str, tag_info->image_end,
77 pimprove->build_cost,
78 pimprove->upkeep);
79
80 if (requirement_vector_size(&pimprove->reqs) == 0) {
81 char text[512];
82
83 strncpy(text, Q_("?req:None"), sizeof(text) - 1);
84 fprintf(doc, "%s<br/>", text);
85 } else {
86 requirement_vector_iterate(&pimprove->reqs, req) {
87 char text[512], text2[512];
88
89 fc_snprintf(text2, sizeof(text2),
90 /* TRANS: Feature required to be absent. */
91 req->present ? "%s" : _("no %s"),
92 universal_name_translation(&req->source,
93 text, sizeof(text)));
94 fprintf(doc, "%s<br/>", text2);
96 }
97
98 fprintf(doc, "\n%s\n", tag_info->hline);
99
100 if (requirement_vector_size(&pimprove->obsolete_by) == 0) {
101 char text[512];
102
103 strncpy(text, Q_("?req:None"), sizeof(text) - 1);
104 fprintf(doc, "<em>%s</em><br/>", text);
105 } else {
106 requirement_vector_iterate(&pimprove->obsolete_by, pobs) {
107 char text[512], text2[512];
108
109 fc_snprintf(text2, sizeof(text2),
110 /* TRANS: Feature required to be absent. */
111 pobs->present ? "%s" : _("no %s"),
113 text, sizeof(text)));
114 fprintf(doc, "<em>%s</em><br/>", text2);
116 }
117
118 fprintf(doc,
119 "</td>\n<td>%s</td>\n</tr><tr><td colspan=\"5\">\n%s\n</td></tr>\n\n",
120 buf, tag_info->hline);
122
123 fprintf(doc, "</table>");
124
126
127 return TRUE;
128}
129
130/**********************************************************************/
char * incite_cost
Definition comments.c:75
void manual_finalize(struct tag_types *tag_info, FILE *doc, enum manuals manual)
Definition fc_manual.c:320
FILE * manual_start(struct tag_types *tag_info, int manual_number)
Definition fc_manual.c:291
#define Q_(String)
Definition fcintl.h:70
#define _(String)
Definition fcintl.h:67
struct civ_game game
Definition game.c:62
char * helptext_building(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct impr_type *pimprove)
Definition helpdata.c:1381
const struct impr_type * valid_improvement(const struct impr_type *pimprove)
bool is_great_wonder(const struct impr_type *pimprove)
const char * improvement_name_translation(const struct impr_type *pimprove)
#define improvement_iterate_end
#define improvement_iterate(_p)
bool manual_buildings(struct tag_types *tag_info)
static bool manual_improvements(struct tag_types *tag_info, enum manuals manual)
const char * universal_name_translation(const struct universal *psource, char *buf, size_t bufsz)
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
struct packet_ruleset_control control
Definition game.h:83
char name[MAX_LEN_NAME]
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47