19#include <QApplication>
20#include <QGraphicsDropShadowEffect>
23#include <QProgressBar>
30#include <QTextBrowser>
53#define MAX_HELP_TEXT_SIZE 8192
54#define REQ_LABEL_NEVER _("(Never)")
55#define REQ_LABEL_NONE _("?tech:None")
147 &QTreeWidget::currentItemChanged,
150 help_wdg->layout()->setContentsMargins(0, 0, 0, 0);
156 QStyle::QStyle::SP_ArrowLeft), (
""));
157 connect(
prev_butt, &QAbstractButton::clicked,
this,
161 QStyle::QStyle::SP_ArrowRight), (
""));
162 connect(
next_butt, &QAbstractButton::clicked,
this,
165 hbox->addStretch(20);
167 QStyle::SP_DialogHelpButton),
_(
"About Qt"));
168 connect(
but, &QPushButton::pressed, &QApplication::aboutQt);
169 hbox->addWidget(
but, Qt::AlignRight);
171 QStyle::SP_DialogDiscardButton),
_(
"Close"));
172 connect(
but, &QPushButton::pressed,
this, &QWidget::close);
173 hbox->addWidget(
but, Qt::AlignRight);
198 gui()->qt_settings.help_splitter1 =
splitter->saveState();
208 if (!
gui()->qt_settings.help_geometry.isNull()) {
210 splitter->restoreState(
gui()->qt_settings.help_splitter1);
212 QRect rect = QApplication::primaryScreen()->availableGeometry();
214 resize((rect.width() * 3) / 5, (rect.height() * 3) / 6);
215 sizes << rect.width() / 10 << rect.width() / 3;
226 gui()->qt_settings.help_splitter1 =
splitter->saveState();
255 for (s =
pitem->topic; *s ==
' '; s++) {
270 switch (
pitem->type) {
336 if (!icon.isNull()) {
337 item->setIcon(0, icon);
352 QHash<QTreeWidgetItem *, const help_item *>::const_iterator
355 if (
i.value() == topic) {
479 box_wdg->setFrameShape(QFrame::StyledPanel);
480 box_wdg->setFrameShadow(QFrame::Raised);
521 enum Qt::Orientation main_layout;
525 main_layout = Qt::Horizontal;
528 main_layout = Qt::Vertical;
574 for (
int i = 0;
i <
l.size(); ++
i) {
576 l.at(
i)->setFont(*
f);
580 for (
int i = 0;
i <
l.size(); ++
i) {
582 l.at(
i)->setFont(*
f);
586 for (
int i = 0;
i <
l.size(); ++
i) {
588 l.at(
i)->setFont(*
f);
630 QLabel *label =
new QLabel();
633 label->setAlignment(Qt::AlignHCenter);
634 label->setPixmap(*pm);
640 label->setGraphicsEffect(
effect);
651 QLabel *label =
new QLabel(text);
652 label->setWordWrap(
true);
653 label->setTextFormat(Qt::RichText);
667 int min,
int max,
const QString &value)
676 layout->setContentsMargins(0, 0, 0, 0);
677 layout->setVerticalSpacing(0);
679 label =
new QLabel(text,
wdg);
680 layout->addWidget(label, 0, 0);
682 label =
new QLabel(
wdg);
683 if (value.isEmpty()) {
684 label->setNum(progress);
686 label->setText(value);
689 layout->addWidget(label, 0, 1, Qt::AlignRight);
691 bar =
new QProgressBar(
wdg);
692 bar->setMaximumHeight(4);
693 bar->setRange(min, max != min ? max : min + 1);
694 bar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
695 bar->setTextVisible(
false);
696 bar->setValue(progress);
697 layout->addWidget(bar, 1, 0, 1, 2);
716 if (pextra->buildable
722 tb =
new QLabel(
this);
724 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
725 tb->setTextFormat(Qt::RichText);
732 tb->setText(
str.trimmed());
733 connect(
tb, &QLabel::linkActivated,
746 s =
QString(
str).toHtmlEscaped().replace(
" ",
" ");
747 return " <a href=" + QString::number(
hpt)
748 +
"," + s +
">" + s +
"</a> ";
778 sl = link.split(
",");
779 n =
sl.at(0).toInt();
782 st =
st.replace(
"\u00A0",
" ");
809 switch (topic->
type) {
943 tb =
new QLabel(
this);
946 str =
"<b>" +
str +
"</b> "
950 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
951 tb->setTextFormat(Qt::RichText);
952 tb->setText(
str.trimmed());
953 connect(
tb, &QLabel::linkActivated,
967 tb =
new QLabel(
this);
968 str =
_(
"Obsoleted by");
969 str =
"<b>" +
str +
"</b> "
974 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
975 tb->setTextFormat(Qt::RichText);
976 tb->setText(
str.trimmed());
977 connect(
tb, &QLabel::linkActivated,
1022 str =
_(
"Base Cost:");
1023 str =
"<b>" +
str +
"</b>" +
" "
1029 str =
"<b>" +
str +
"</b>" +
" "
1030 + QString::number(
itype->upkeep).toHtmlEscaped();
1035 if (!
preq->present) {
1052 if (!
s1.isEmpty()) {
1053 tb =
new QLabel(
this);
1054 str =
_(
"Requirement:");
1057 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
1058 tb->setTextFormat(Qt::RichText);
1059 tb->setText(
str.trimmed());
1060 connect(
tb, &QLabel::linkActivated,
1073 str =
_(
"Obsolete by:");
1075 if (!
s2.isEmpty()) {
1076 tb =
new QLabel(
this);
1078 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
1079 tb->setTextFormat(Qt::RichText);
1080 tb->setText(
str.trimmed());
1081 connect(
tb, &QLabel::linkActivated,
1116 tb =
new QLabel(
this);
1118 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
1119 tb->setTextFormat(Qt::RichText);
1121 str =
"<b>" +
str +
"</b> "
1123 tb->setText(
str.trimmed());
1124 connect(
tb, &QLabel::linkActivated,
1137 str =
"<b>" +
str +
"</b> "
1141 tb =
new QLabel(
this);
1143 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
1144 tb->setTextFormat(Qt::RichText);
1145 tb->setText(
str.trimmed());
1146 connect(
tb, &QLabel::linkActivated,
1155 str =
_(
"Obsoletes");
1156 str =
"<b>" +
str +
"</b> "
1160 tb =
new QLabel(
this);
1162 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
1163 tb->setTextFormat(Qt::RichText);
1164 tb->setText(
str.trimmed());
1165 connect(
tb, &QLabel::linkActivated,
1180 str =
"<b>" +
str +
"</b> "
1182 tb =
new QLabel(
this);
1184 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
1185 tb->setTextFormat(Qt::RichText);
1186 tb->setText(
str.trimmed());
1187 connect(
tb, &QLabel::linkActivated,
1219 for (
i = 0;
i < 3; ++
i) {
1257 label =
new QLabel();
1259 effect->setBlurRadius(3);
1261 label->setGraphicsEffect(
effect);
1262 label->setPixmap(
image->map_pixmap);
1263 layout->addWidget(label, 0, 0, 2, 1);
1265 label =
new QLabel(
title);
1266 label->setTextFormat(Qt::PlainText);
1267 layout->addWidget(label, 0, 1, Qt::AlignBottom);
1270 label =
new QLabel(legend);
1271 label->setTextFormat(Qt::PlainText);
1272 layout->addWidget(label, 1, 1, Qt::AlignTop);
1277 label->setCursor(Qt::WhatsThisCursor);
1280 layout->setColumnStretch(0, 0);
1281 layout->setColumnStretch(1, 100);
1293 struct terrain *pterrain, *max;
1309 topic->
text, pterrain);
1348 str =
N_(
"Cultiv. Rslt/Time:");
1352 tb =
new QLabel(
this);
1354 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
1355 tb->setTextFormat(Qt::RichText);
1356 tb->setText(
str.trimmed());
1357 connect(
tb, &QLabel::linkActivated,
1370 str =
N_(
"Plant Rslt/Time:");
1374 tb =
new QLabel(
this);
1376 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
1377 tb->setTextFormat(Qt::RichText);
1378 tb->setText(
str.trimmed());
1379 connect(
tb, &QLabel::linkActivated,
1393 str =
N_(
"Trans. Rslt/Time:");
1397 tb =
new QLabel(
this);
1399 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
1400 tb->setTextFormat(Qt::RichText);
1401 tb->setText(
str.trimmed());
1402 connect(
tb, &QLabel::linkActivated,
1410 _(
"Build as irrigation"));
1414 _(
"Build as mine"));
1418 _(
"Build as road"));
1422 _(
"Build as base"));
1428 panel =
new QWidget();
1435 for (r = pterrain->
resources; *r; r++) {
1441 QString(
_(
"Tile output becomes %1, %2, %3."))
1446 _(
"Output (Food, Shields, Trade) of a tile where the resource is "
1453 vbox->addStretch(100);
1454 vbox->setSizeConstraint(QLayout::SetMinimumSize);
1457 area->setWidget(panel);
1460 panel->deleteLater();
1486 topic->
text, pextra);
1617 for (
i = 0;
i < count; ++
i) {
1620 max->v = max->v > terrain->v ? max->v : terrain->v
1623 SET_MAX(irrigation_food_incr);
1683 if (utype->uclass == uclass) {
1686 max->v = max->v > utype->v ? max->v : utype->v
#define action_id_univs_not_blocking(act_id, act_uni, tgt_uni)
void qtg_canvas_free(struct canvas *store)
struct canvas * qtg_canvas_create(int width, int height)
struct canvas int int struct sprite int int int int height
struct canvas int int canvas_y
struct canvas int int struct sprite int int int width
static fc_font * instance()
QFont * get_font(QString name)
void hideEvent(QHideEvent *event)
help_dialog(QWidget *parent=0)
void set_topic(const help_item *item)
void showEvent(QShowEvent *event)
QHash< QTreeWidgetItem *, const help_item * > topics_map
void item_changed(QTreeWidgetItem *item, QTreeWidgetItem *prev)
void closeEvent(QCloseEvent *event)
QList< QTreeWidgetItem * > item_history
static struct fc_sockaddr_list * list
const char * skip_intl_qualifier_prefix(const char *str)
#define PL_(String1, String2, n)
const char * government_name_translation(const struct government *pgovern)
struct government * government_by_translated_name(const char *name)
#define governments_iterate(NAME_pgov)
#define governments_iterate_end
static PangoLayout * layout
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
static struct canvas * terrain_canvas
void helptext_government(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct government *gov)
void helptext_advance(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, int i)
char * helptext_unit(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct unit_type *utype, bool class_help)
void helptext_extra(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct extra_type *pextra)
void helptext_goods(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct goods_type *pgood)
char * helptext_unit_upkeep_str(const struct unit_type *utype)
const char * helptext_extra_for_terrain_str(struct extra_type *pextra, struct terrain *pterrain, enum unit_activity act)
void helptext_specialist(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct specialist *pspec)
const struct help_item * get_help_item_spec(const char *name, enum help_page_type htype, int *pos)
char * helptext_building(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct impr_type *pimprove)
void helptext_terrain(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct terrain *pterrain)
void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation, const char *user_text)
#define help_items_iterate(pitem)
#define help_items_iterate_end
void popdown_help_dialog(void)
void popup_help_dialog_string(const char *item)
static help_dialog * help_dlg
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
#define MAX_HELP_TEXT_SIZE
const struct impr_type * valid_improvement(const struct impr_type *pimprove)
int impr_base_build_shield_cost(const struct impr_type *pimprove)
bool is_great_wonder(const struct impr_type *pimprove)
struct impr_type * improvement_by_translated_name(const char *name)
const char * improvement_name_translation(const struct impr_type *pimprove)
#define improvement_iterate_end
#define improvement_iterate(_p)
void put_drawn_sprites(struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y, int count, struct drawn_sprite *pdrawn, bool fog)
void put_unittype(const struct unit_type *putype, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
const char * move_points_text(int mp, bool reduce)
const char *const default_font
const char *const notify_label
const char *const help_label
const char *const help_text
struct nation_type * nation_by_translated_plural(const char *name)
void universal_extraction(const struct universal *source, int *kind, int *value)
bool universal_fulfills_requirements(bool check_necessary, const struct requirement_vector *reqs, const struct universal *source)
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 specialist * specialist_by_translated_name(const char *name)
struct terrain * cultivate_result
struct extra_type ** resources
struct terrain * plant_result
int road_output_incr_pct[O_LAST]
struct terrain * transform_result
struct unit_class * uclass
const struct unit_type * obsoleted_by
int fc_snprintf(char *str, size_t n, const char *format,...)
struct advance * advance_by_number(const Tech_type_id atype)
struct advance * advance_by_translated_name(const char *name)
const char * advance_name_translation(const struct advance *padvance)
bool is_regular_advance(struct advance *padvance)
Tech_type_id advance_number(const struct advance *padvance)
Terrain_type_id terrain_count(void)
struct terrain * terrain_by_translated_name(const char *name)
const char * terrain_name_translation(const struct terrain *pterrain)
struct terrain * terrain_by_number(const Terrain_type_id type)
struct sprite * get_government_sprite(const struct tileset *t, const struct government *gov)
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
int tileset_full_tile_height(const struct tileset *t)
int fill_basic_extra_sprite_array(const struct tileset *t, struct drawn_sprite *sprs, const struct extra_type *pextra)
int fill_basic_terrain_layer_sprite_array(struct tileset *t, struct drawn_sprite *sprs, int layer, struct terrain *pterrain)
int tileset_tile_height(const struct tileset *t)
int tileset_full_tile_width(const struct tileset *t)
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum unit_activity activity, enum direction8 facing)
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
struct sprite * get_tech_sprite(const struct tileset *t, Tech_type_id tech)
struct goods_type * goods_by_translated_name(const char *name)
bool is_tech_req_for_utype(const struct unit_type *ptype, struct advance *padv)
int utype_build_shield_cost_base(const struct unit_type *punittype)
struct advance * utype_primary_tech_req(const struct unit_type *ptype)
struct unit_type * unit_type_by_translated_name(const char *name)
const char * utype_name_translation(const struct unit_type *punittype)
#define unit_type_iterate(_p)
#define unit_type_iterate_end