Freeciv-3.1
Loading...
Searching...
No Matches
helpdlg.cpp
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// Qt
19#include <QApplication>
20#include <QGraphicsDropShadowEffect>
21#include <QGroupBox>
22#include <QHBoxLayout>
23#include <QProgressBar>
24#include <QPushButton>
25#include <QScreen>
26#include <QScrollArea>
27#include <QSplitter>
28#include <QStack>
29#include <QStringList>
30#include <QTextBrowser>
31#include <QTreeWidget>
32#include <QVBoxLayout>
33
34// utility
35#include "fcintl.h"
36
37// common
38#include "movement.h"
39#include "nation.h"
40#include "specialist.h"
41#include "terrain.h"
42#include "unit.h"
43
44// client
45#include "helpdata.h"
46
47// gui-qt
48#include "fc_client.h"
49#include "fonts.h"
50#include "helpdlg.h"
51#include "sprite.h"
52
53#define MAX_HELP_TEXT_SIZE 8192
54#define REQ_LABEL_NEVER _("(Never)")
55#define REQ_LABEL_NONE _("?tech:None")
56static help_dialog *help_dlg = NULL;
57static canvas *terrain_canvas(struct terrain *terrain,
58 const struct extra_type *resource = NULL,
59 enum extra_cause cause = EC_COUNT);
60
61/**********************************************************************/
72
73/**********************************************************************/
79void popup_help_dialog_typed(const char *item, enum help_page_type htype)
80{
81 int pos;
82 const help_item *topic;
83
84 if (help_dlg == nullptr) {
85 help_dlg = new help_dialog();
86 } else {
88 }
89
90 topic = get_help_item_spec(item, htype, &pos);
91 if (pos >= 0) {
92 help_dlg->set_topic(topic);
93 }
94 help_dlg->setVisible(true);
95 help_dlg->activateWindow();
96}
97
98/**********************************************************************/
102{
103 if (help_dlg) {
104 help_dlg->setVisible(false);
105 help_dlg->deleteLater();
106 help_dlg = NULL;
107 }
108}
109
110/**********************************************************************/
114{
115 if (help_dlg) {
117 }
118}
119
120/**********************************************************************/
123help_dialog::help_dialog(QWidget *parent) : qfc_dialog(parent)
124{
125 QHBoxLayout *hbox;
126 QPushButton *but;
127 QTreeWidgetItem *first;
128 QVBoxLayout *layout;
129 QWidget *buttons;
130
131 setWindowTitle(_("Freeciv Help Browser"));
132 history_pos = -1;
133 update_history = true;
134 layout = new QVBoxLayout(this);
135
136 splitter = new QSplitter(this);
137 layout->addWidget(splitter, 10);
138
139 tree_wdg = new QTreeWidget();
140 tree_wdg->setHeaderHidden(true);
141 make_tree();
142 splitter->addWidget(tree_wdg);
143
145 connect(
146 tree_wdg,
147 &QTreeWidget::currentItemChanged,
149 );
150 help_wdg->layout()->setContentsMargins(0, 0, 0, 0);
151 splitter->addWidget(help_wdg);
152
153 buttons = new QWidget;
154 hbox = new QHBoxLayout;
155 prev_butt = new QPushButton(style()->standardIcon(
156 QStyle::QStyle::SP_ArrowLeft), (""));
157 connect(prev_butt, &QAbstractButton::clicked, this,
159 hbox->addWidget(prev_butt);
160 next_butt = new QPushButton(style()->standardIcon(
161 QStyle::QStyle::SP_ArrowRight), (""));
162 connect(next_butt, &QAbstractButton::clicked, this,
164 hbox->addWidget(next_butt);
165 hbox->addStretch(20);
166 but = new QPushButton(style()->standardIcon(
167 QStyle::SP_DialogHelpButton), _("About Qt"));
168 connect(but, &QPushButton::pressed, &QApplication::aboutQt);
169 hbox->addWidget(but, Qt::AlignRight);
170 but = new QPushButton(style()->standardIcon(
171 QStyle::SP_DialogDiscardButton), _("Close"));
172 connect(but, &QPushButton::pressed, this, &QWidget::close);
173 hbox->addWidget(but, Qt::AlignRight);
174 buttons->setLayout(hbox);
175 layout->addWidget(buttons, 0, Qt::AlignBottom);
176
177
178 first = tree_wdg->topLevelItem(0);
179 if (first) {
180 tree_wdg->setCurrentItem(first);
181 }
182}
183
184/**********************************************************************/
191
192/**********************************************************************/
196{
197 gui()->qt_settings.help_geometry = saveGeometry();
198 gui()->qt_settings.help_splitter1 = splitter->saveState();
199}
200
201/**********************************************************************/
205{
206 QList<int> sizes;
207
208 if (!gui()->qt_settings.help_geometry.isNull()) {
209 restoreGeometry(gui()->qt_settings.help_geometry);
210 splitter->restoreState(gui()->qt_settings.help_splitter1);
211 } else {
212 QRect rect = QApplication::primaryScreen()->availableGeometry();
213
214 resize((rect.width() * 3) / 5, (rect.height() * 3) / 6);
215 sizes << rect.width() / 10 << rect.width() / 3;
216 splitter->setSizes(sizes);
217 }
218}
219
220/**********************************************************************/
224{
225 gui()->qt_settings.help_geometry = saveGeometry();
226 gui()->qt_settings.help_splitter1 = splitter->saveState();
227}
228
229/**********************************************************************/
233{
234 char *title;
235 int dep;
236 int i;
237 QHash<int, QTreeWidgetItem *> hash;
238 QIcon icon;
239 QTreeWidgetItem *item;
240 sprite *spite;
241 struct advance *padvance;
242 struct canvas *pcan;
243 struct extra_type *pextra;
244 struct government *gov;
245 struct impr_type *imp;
246 struct nation_type *nation;
247 struct terrain *pterrain;
248 struct unit_type *f_type;
249 struct drawn_sprite sprs[80];
250
251 help_items_iterate(pitem) {
252 const char *s;
253 int last;
254 title = pitem->topic;
255
256 for (s = pitem->topic; *s == ' '; s++) {
257 /* nothing */
258 }
259
260 item = new QTreeWidgetItem(QStringList(title));
261 topics_map[item] = pitem;
262 dep = s - pitem->topic;
263 hash.insert(dep, item);
264
265 if (dep == 0) {
266 tree_wdg->addTopLevelItem(item);
267 } else {
268 last = dep - 1;
269 spite = nullptr;
270
271 switch (pitem->type) {
272 case HELP_EXTRA:
275 icon = QIcon(*sprs->sprite->pm);
276 break;
277
278 case HELP_GOVERNMENT:
280 spite = get_government_sprite(tileset, gov);
281 if (spite) {
282 icon = QIcon(*spite->pm);
283 }
284 break;
285
286 case HELP_IMPROVEMENT:
287 case HELP_WONDER:
289 spite = get_building_sprite(tileset, imp);
290 if (spite) {
291 icon = QIcon(*spite->pm);
292 }
293 break;
294 case HELP_NATIONS:
295 nation = nation_by_translated_plural(s);
296 spite = get_nation_flag_sprite(tileset, nation);
297 if (spite) {
298 icon = QIcon(*spite->pm);
299 }
300 break;
301 case HELP_TECH:
302 padvance = advance_by_translated_name(s);
303 if (padvance && !is_future_tech(i = advance_number(padvance))) {
304 spite = get_tech_sprite(tileset, i);
305 if (spite) {
306 icon = QIcon(*spite->pm);
307 }
308 }
309 break;
310
311 case HELP_TERRAIN:
312 pterrain = terrain_by_translated_name(s);
313 pcan = terrain_canvas(pterrain);
314 if (pcan) {
315 icon = QIcon(pcan->map_pixmap);
316 delete pcan;
317 }
318 break;
319
320 case HELP_UNIT:
322 if (f_type) {
323 spite = get_unittype_sprite(tileset, f_type, direction8_invalid());
324 }
325 if (spite) {
326 icon = QIcon(*spite->pm);
327 }
328 break;
329
330 default:
331 break;
332 }
333
334 if (!icon.isNull()) {
335 item->setIcon(0, icon);
336 }
337
338 hash.value(last)->addChild(item);
339 }
341}
342
343/**********************************************************************/
347{
348 help_wdg->set_topic(topic);
349 // Reverse search of the item to select.
350 QHash<QTreeWidgetItem *, const help_item *>::const_iterator
351 i = topics_map.cbegin();
352 for ( ; i != topics_map.cend(); ++i) {
353 if (i.value() == topic) {
354 tree_wdg->setCurrentItem(i.key());
355 break;
356 }
357 }
358}
359
360/**********************************************************************/
364{
365 QTreeWidgetItem *i;
366
367 update_history = false;
368 if (history_pos < item_history.count()) {
369 history_pos++;
370 }
371 i = item_history.value(history_pos);
372 if (i != nullptr) {
373 tree_wdg->setCurrentItem(i);
374 }
375}
376
377/**********************************************************************/
381{
382 QTreeWidgetItem *i;
383
384 update_history = false;
385 if (history_pos > 0) {
386 history_pos--;
387 }
388 i = item_history.value(history_pos);
389 if (i != nullptr) {
390 tree_wdg->setCurrentItem(i);
391 }
392}
393
394/**********************************************************************/
398{
399 if (history_pos == 0) {
400 prev_butt->setEnabled(false);
401 } else {
402 prev_butt->setEnabled(true);
403 }
404 if (history_pos >= item_history.size() - 1) {
405 next_butt->setEnabled(false);
406 } else {
407 next_butt->setEnabled(true);
408 }
409}
410
411/**********************************************************************/
414void help_dialog::item_changed(QTreeWidgetItem *item, QTreeWidgetItem *prev)
415{
416
417 if (prev == item) {
418 return;
419 }
420
422
423 if (update_history) {
424 history_pos++;
425 item_history.append(item);
426 } else {
427 update_history = true;
428 }
430}
431
432/**********************************************************************/
435help_widget::help_widget(QWidget *parent) :
436 QWidget(parent),
437 main_widget(NULL), text_browser(NULL), bottom_panel(NULL),
438 info_panel(NULL), splitter(NULL), info_layout(NULL)
439{
440 setup_ui();
441}
442
443/**********************************************************************/
446help_widget::help_widget(const help_item *topic, QWidget *parent) :
447 QWidget(parent),
448 main_widget(NULL), text_browser(NULL), bottom_panel(NULL),
449 info_panel(NULL), splitter(NULL), info_layout(NULL)
450{
451 setup_ui();
452 set_topic(topic);
453}
454
455/**********************************************************************/
459 // Nothing to do here
460}
461
462/**********************************************************************/
466{
467 QVBoxLayout *layout;
468 QHBoxLayout *group_layout;
469
470 layout = new QVBoxLayout();
471 setLayout(layout);
472
473 box_wdg = new QFrame(this);
474 layout->addWidget(box_wdg);
475 group_layout = new QHBoxLayout(box_wdg);
476 box_wdg->setLayout(group_layout);
477 box_wdg->setFrameShape(QFrame::StyledPanel);
478 box_wdg->setFrameShadow(QFrame::Raised);
479
480 title_label = new QLabel(box_wdg);
481 title_label->setProperty(fonts::default_font, "true");
482 group_layout->addWidget(title_label);
483
484 text_browser = new QTextBrowser(this);
485 text_browser->setProperty(fonts::help_text, "true");
486 layout->addWidget(text_browser);
488
489 update_fonts();
490 splitter_sizes << 200 << 400;
491}
492
493/**********************************************************************/
516void help_widget::do_layout(bool horizontal)
517{
518 QWidget *right;
519 enum Qt::Orientation main_layout;
520 enum Qt::Orientation bottom_layout;
521
522 if (horizontal) {
523 main_layout = Qt::Horizontal;
524 bottom_layout = Qt::Vertical;
525 } else {
526 main_layout = Qt::Vertical;
527 bottom_layout = Qt::Horizontal;
528 }
529
530 layout()->removeWidget(main_widget);
531 main_widget->setParent(NULL);
532
533 if (bottom_panel) {
534 splitter = new QSplitter(bottom_layout);
535 splitter->addWidget(text_browser);
536 splitter->setStretchFactor(0, 100);
537 splitter->addWidget(bottom_panel);
538 splitter->setStretchFactor(1, 0);
539 right = splitter;
540 } else {
541 right = text_browser;
542 }
543
544 if (info_panel) {
545 splitter = new QSplitter(main_layout);
546 splitter->addWidget(info_panel);
547 splitter->setStretchFactor(0, 25);
548 splitter->addWidget(right);
549 splitter->setStretchFactor(1, 75);
550 splitter->setSizes(splitter_sizes);
552 info_panel->setLayout(info_layout);
553 } else {
554 main_widget = right;
555 }
556
557 layout()->addWidget(main_widget);
558 qobject_cast<QVBoxLayout *>(layout())->setStretchFactor(main_widget, 100);
559}
560
561/**********************************************************************/
565{
566 QList<QWidget *> l;
567 QFont *f;
568
569 l = findChildren<QWidget *>();
570
572 for (int i = 0; i < l.size(); ++i) {
573 if (l.at(i)->property(fonts::help_label).isValid()) {
574 l.at(i)->setFont(*f);
575 }
576 }
578 for (int i = 0; i < l.size(); ++i) {
579 if (l.at(i)->property(fonts::help_text).isValid()) {
580 l.at(i)->setFont(*f);
581 }
582 }
584 for (int i = 0; i < l.size(); ++i) {
585 if (l.at(i)->property(fonts::default_font).isValid()) {
586 l.at(i)->setFont(*f);
587 }
588 }
589}
590
591/**********************************************************************/
595{
596 // Save the splitter sizes to avoid jumps
597 if (info_panel) {
598 splitter_sizes = splitter->sizes();
599 }
600 // Unparent the widget we want to keep
601 text_browser->setParent(NULL);
602 // Delete everything else
603 if (text_browser != main_widget) {
604 main_widget->deleteLater();
605 }
606 // Reset pointers to defaults
608 bottom_panel = NULL;
609 info_panel = NULL;
610 splitter = NULL;
611 info_layout = NULL;
612}
613
614/**********************************************************************/
618{
619 info_panel = new QWidget();
620 info_layout = new QVBoxLayout();
621}
622
623/**********************************************************************/
626void help_widget::add_info_pixmap(QPixmap *pm, bool shadow)
627{
628 QLabel *label = new QLabel();
629 QGraphicsDropShadowEffect *effect;
630
631 label->setAlignment(Qt::AlignHCenter);
632 label->setPixmap(*pm);
633
634 if (shadow) {
635 effect = new QGraphicsDropShadowEffect(label);
636 effect->setBlurRadius(3);
637 effect->setOffset(0, 2);
638 label->setGraphicsEffect(effect);
639 }
640
641 info_layout->addWidget(label);
642}
643
644/**********************************************************************/
647void help_widget::add_info_label(const QString &text)
648{
649 QLabel *label = new QLabel(text);
650 label->setWordWrap(true);
651 label->setTextFormat(Qt::RichText);
652 label->setProperty(fonts::help_label, "true");
653 info_layout->addWidget(label);
654}
655
656/**********************************************************************/
664void help_widget::add_info_progress(const QString &text, int progress,
665 int min, int max, const QString &value)
666{
667 QGridLayout *layout;
668 QLabel *label;
669 QProgressBar *bar;
670 QWidget *wdg;
671
672 wdg = new QWidget();
673 layout = new QGridLayout(wdg);
674 layout->setContentsMargins(0, 0, 0, 0);
675 layout->setVerticalSpacing(0);
676
677 label = new QLabel(text, wdg);
678 layout->addWidget(label, 0, 0);
679 label->setProperty(fonts::help_label, "true");
680 label = new QLabel(wdg);
681 if (value.isEmpty()) {
682 label->setNum(progress);
683 } else {
684 label->setText(value);
685 }
686 label->setProperty(fonts::help_label, "true");
687 layout->addWidget(label, 0, 1, Qt::AlignRight);
688
689 bar = new QProgressBar(wdg);
690 bar->setMaximumHeight(4);
691 bar->setRange(min, max != min ? max : min + 1);
692 bar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
693 bar->setTextVisible(false);
694 bar->setValue(progress);
695 layout->addWidget(bar, 1, 0, 1, 2);
696
697 info_layout->addWidget(wdg);
698}
699
700/**********************************************************************/
704 enum unit_activity act,
705 const char *label)
706{
707 struct universal for_terr;
708 enum extra_cause cause = activity_to_extra_cause(act);
709
710 for_terr.kind = VUT_TERRAIN;
711 for_terr.value.terrain = pterr;
712
713 extra_type_by_cause_iterate(cause, pextra) {
714 if (pextra->buildable
715 && universal_fulfills_requirements(FALSE, &(pextra->reqs),
716 &for_terr)) {
717 QLabel *tb;
718 QString str;
719
720 tb = new QLabel(this);
721 tb->setProperty(fonts::help_label, "true");
722 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
723 tb->setTextFormat(Qt::RichText);
724
725 str = str + QString(label)
727 + QString(helptext_extra_for_terrain_str(pextra, pterr, act))
728 .toHtmlEscaped()
729 + "\n";
730 tb->setText(str.trimmed());
731 connect(tb, &QLabel::linkActivated,
733 info_layout->addWidget(tb);
734 }
736}
737
738/**********************************************************************/
741QString help_widget::link_me(const char *str, help_page_type hpt)
742{
743 QString s;
744 s = QString(str).toHtmlEscaped().replace(" ", "&nbsp;");
745 return " <a href=" + QString::number(hpt)
746 + "," + s + ">" + s + "</a> ";
747}
748
749/**********************************************************************/
753{
754 info_layout->addSpacing(2 * info_layout->spacing());
755}
756
757/**********************************************************************/
761{
762 info_layout->addStretch();
763}
764
765/**********************************************************************/
769void help_widget::anchor_clicked(const QString &link)
770{
771 QStringList sl;
772 int n;
773 QString st;
774 enum help_page_type type;
775
776 sl = link.split(",");
777 n = sl.at(0).toInt();
778 type = static_cast<help_page_type>(n);
779 st = sl.at(1);
780 st = st.replace("\u00A0", " ");
781
782 if (strcmp(qPrintable(st), REQ_LABEL_NEVER) != 0
783 && strcmp(qPrintable(st),
785 && strcmp(qPrintable(st),
787 popup_help_dialog_typed(qPrintable(st), type);
788 }
789}
790
791/**********************************************************************/
795{
796 char *title = topic->topic;
797 bool orient = true;
798
799 for ( ; *title == ' '; ++title) {
800 // Do nothing
801 }
802 title_label->setTextFormat(Qt::PlainText);
803 title_label->setText(title);
804
805 undo_layout();
806
807 switch (topic->type) {
808 case HELP_ANY:
809 case HELP_MULTIPLIER:
810 case HELP_RULESET:
811 case HELP_TILESET:
812 case HELP_TEXT:
813 set_topic_other(topic, title);
814 break;
815 case HELP_EXTRA:
816 orient = set_topic_extra(topic, title);
817 break;
818 case HELP_GOODS:
819 set_topic_goods(topic, title);
820 break;
821 case HELP_GOVERNMENT:
823 break;
824 case HELP_IMPROVEMENT:
825 case HELP_WONDER:
827 break;
828 case HELP_NATIONS:
829 set_topic_nation(topic, title);
830 break;
831 case HELP_SPECIALIST:
833 break;
834 case HELP_TECH:
835 set_topic_tech(topic, title);
836 break;
837 case HELP_TERRAIN:
838 set_topic_terrain(topic, title);
839 break;
840 case HELP_UNIT:
841 set_topic_unit(topic, title);
842 break;
843 case HELP_LAST: // Just to avoid warning
844 break;
845 }
846
847 do_layout(orient);
848}
849
850/**********************************************************************/
856
857/**********************************************************************/
861 const char *title)
862{
863 if (topic->text) {
864 text_browser->setPlainText(topic->text);
865 } else {
866 text_browser->setPlainText(""); // Something better to do ?
867 }
868}
869
870/**********************************************************************/
874 const char *title)
875{
876 char buffer[MAX_HELP_TEXT_SIZE];
877 int upkeep, max_upkeep;
878 struct advance *tech;
879 struct canvas *canvas;
880 const struct unit_type *obsolete;
881 struct unit_type *utype, *max_utype;
882 QList<int> list;
883 QString str;
884
886 if (utype) {
887 helptext_unit(buffer, sizeof(buffer), client.conn.playing,
888 topic->text, utype);
889 text_browser->setPlainText(buffer);
890
891 // Create information panel
893 max_utype = uclass_max_values(utype->uclass);
894
895 // Unit icon
899 );
900 canvas->map_pixmap.fill(Qt::transparent);
901 put_unittype(utype, canvas, 1.0f, 0, 0);
904
905 add_info_progress(_("Attack:"), utype->attack_strength, 0,
906 max_utype->attack_strength);
907 add_info_progress(_("Defense:"), utype->defense_strength,
908 0, max_utype->defense_strength);
909 add_info_progress(_("Moves:"), utype->move_rate, 0, max_utype->move_rate,
910 move_points_text(utype->move_rate, true));
911
913
914 add_info_progress(_("Hitpoints:"), utype->hp, 0, max_utype->hp);
916 0, utype_build_shield_cost_base(max_utype));
917 add_info_progress(_("Firepower:"), utype->firepower, 0,
918 max_utype->firepower);
919
920 // Upkeep
921 upkeep = utype->upkeep[O_FOOD] + utype->upkeep[O_GOLD]
922 + utype->upkeep[O_LUXURY] + utype->upkeep[O_SCIENCE]
923 + utype->upkeep[O_SHIELD] + utype->upkeep[O_TRADE]
924 + utype->happy_cost;
925 max_upkeep = max_utype->upkeep[O_FOOD] + max_utype->upkeep[O_GOLD]
926 + max_utype->upkeep[O_LUXURY] + max_utype->upkeep[O_SCIENCE]
927 + max_utype->upkeep[O_SHIELD] + max_utype->upkeep[O_TRADE]
928 + max_utype->happy_cost;
929 add_info_progress(_("Basic upkeep:"), upkeep, 0, max_upkeep,
931
933
934 // Tech requirement
935 tech = utype->require_advance;
936 if (tech && tech != advance_by_number(A_NONE)) {
937 QLabel *tb;
938
939 tb = new QLabel(this);
940 /* TRANS: this and similar literal strings interpreted as (Qt) HTML */
941 str = _("Requires");
942 str = "<b>" + str + "</b> "
944
945 tb->setProperty(fonts::help_label, "true");
946 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
947 tb->setTextFormat(Qt::RichText);
948 tb->setText(str.trimmed());
949 connect(tb, &QLabel::linkActivated,
951 info_layout->addWidget(tb);
952 } else {
953 add_info_label(_("No technology required."));
954 }
955
956 // Obsolescence
957 obsolete = utype->obsoleted_by;
958 if (obsolete) {
959 tech = obsolete->require_advance;
960 if (tech && tech != advance_by_number(A_NONE)) {
961 QLabel *tb;
962
963 tb = new QLabel(this);
964 str = _("Obsoleted by");
965 str = "<b>" + str + "</b> "
968 + ")";
969 tb->setProperty(fonts::help_label, "true");
970 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
971 tb->setTextFormat(Qt::RichText);
972 tb->setText(str.trimmed());
973 connect(tb, &QLabel::linkActivated,
975 info_layout->addWidget(tb);
976 } else {
978 // TRANS: Current unit obsoleted by other unit
979 QString(_("Obsoleted by %1."))
980 .arg(utype_name_translation(obsolete))
981 .toHtmlEscaped());
982 }
983 } else {
984 add_info_label(_("Never obsolete."));
985 }
986
988
989 delete max_utype;
990 } else {
991 set_topic_other(topic, title);
992 }
993}
994
995/**********************************************************************/
999 const char *title)
1000{
1001 char buffer[MAX_HELP_TEXT_SIZE];
1002 int type, value;
1003 struct sprite *spr;
1005 char req_buf[512];
1006 QString str, s1, s2;
1007 QLabel *tb;
1008
1009 if (itype) {
1010 helptext_building(buffer, sizeof(buffer), client.conn.playing,
1011 topic->text, itype);
1012 text_browser->setPlainText(buffer);
1014 spr = get_building_sprite(tileset, itype);
1015 if (spr) {
1016 add_info_pixmap(spr->pm);
1017 }
1018 str = _("Base Cost:");
1019 str = "<b>" + str + "</b>" + " "
1020 + QString::number(impr_base_build_shield_cost(itype))
1021 .toHtmlEscaped();
1023 if (!is_great_wonder(itype)) {
1024 str = _("Upkeep:");
1025 str = "<b>" + str + "</b>" + " "
1026 + QString::number(itype->upkeep).toHtmlEscaped();
1028 }
1029
1030 requirement_vector_iterate(&itype->reqs, preq) {
1031 if (!preq->present) {
1032 continue;
1033 }
1034 universal_extraction(&preq->source, &type, &value);
1035 if (type == VUT_ADVANCE) {
1036 s1 = link_me(universal_name_translation(&preq->source, req_buf,
1037 sizeof(req_buf)), HELP_TECH);
1038 } else if (type == VUT_GOVERNMENT) {
1039 s1 = link_me(universal_name_translation(&preq->source, req_buf,
1040 sizeof(req_buf)), HELP_GOVERNMENT);
1041 } else if (type == VUT_TERRAIN) {
1042 s1 = link_me(universal_name_translation(&preq->source, req_buf,
1043 sizeof(req_buf)), HELP_TERRAIN);
1044 }
1045 break;
1047
1048 if (!s1.isEmpty()) {
1049 tb = new QLabel(this);
1050 str = _("Requirement:");
1051 str = "<b>" + str + "</b> " + s1;
1052 tb->setProperty(fonts::help_label, "true");
1053 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
1054 tb->setTextFormat(Qt::RichText);
1055 tb->setText(str.trimmed());
1056 connect(tb, &QLabel::linkActivated,
1058 info_layout->addWidget(tb);
1059 }
1060
1062 if (pobs->source.kind == VUT_ADVANCE) {
1063 s2 = link_me(advance_name_translation(pobs->source.value.advance),
1064 HELP_TECH);
1065 break;
1066 }
1068
1069 str = _("Obsolete by:");
1070 str = "<b>" + str + "</b> " + s2;
1071 if (!s2.isEmpty()) {
1072 tb = new QLabel(this);
1073 tb->setProperty(fonts::help_label, "true");
1074 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
1075 tb->setTextFormat(Qt::RichText);
1076 tb->setText(str.trimmed());
1077 connect(tb, &QLabel::linkActivated,
1079 info_layout->addWidget(tb);
1080 }
1082 } else {
1083 set_topic_other(topic, title);
1084 }
1085}
1086
1087/**********************************************************************/
1091 const char *title)
1092{
1093 char buffer[MAX_HELP_TEXT_SIZE];
1094 struct sprite *spr;
1095 QLabel *tb;
1096 struct advance *padvance = advance_by_translated_name(title);
1097 QString str;
1098
1099 if (padvance) {
1100 int n = advance_number(padvance);
1101 if (!is_future_tech(n)) {
1102
1104 spr = get_tech_sprite(tileset, n);
1105 if (spr) {
1106 add_info_pixmap(spr->pm);
1107 }
1108
1109 governments_iterate(pgov) {
1110 requirement_vector_iterate(&pgov->reqs, preq) {
1111 if (VUT_ADVANCE == preq->source.kind
1112 && preq->source.value.advance == padvance) {
1113 tb = new QLabel(this);
1114 tb->setProperty(fonts::help_label, "true");
1115 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
1116 tb->setTextFormat(Qt::RichText);
1117 str = _("Allows");
1118 str = "<b>" + str + "</b> "
1120 tb->setText(str.trimmed());
1121 connect(tb, &QLabel::linkActivated,
1123 info_layout->addWidget(tb);
1124 }
1127
1128 improvement_iterate(pimprove) {
1129 if (valid_improvement(pimprove)) {
1130 requirement_vector_iterate(&pimprove->reqs, preq) {
1131 if (VUT_ADVANCE == preq->source.kind
1132 && preq->source.value.advance == padvance) {
1133 str = _("Allows");
1134 str = "<b>" + str + "</b> "
1136 is_great_wonder(pimprove) ? HELP_WONDER
1138 tb = new QLabel(this);
1139 tb->setProperty(fonts::help_label, "true");
1140 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
1141 tb->setTextFormat(Qt::RichText);
1142 tb->setText(str.trimmed());
1143 connect(tb, &QLabel::linkActivated,
1145 info_layout->addWidget(tb);
1146 }
1148
1149 requirement_vector_iterate(&pimprove->obsolete_by, pobs) {
1150 if (pobs->source.kind == VUT_ADVANCE
1151 && pobs->source.value.advance == padvance) {
1152 str = _("Obsoletes");
1153 str = "<b>" + str + "</b> "
1155 is_great_wonder(pimprove) ? HELP_WONDER
1157 tb = new QLabel(this);
1158 tb->setProperty(fonts::help_label, "true");
1159 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
1160 tb->setTextFormat(Qt::RichText);
1161 tb->setText(str.trimmed());
1162 connect(tb, &QLabel::linkActivated,
1164 info_layout->addWidget(tb);
1165 }
1167 }
1169
1170 unit_type_iterate(punittype) {
1171 if (padvance != punittype->require_advance) {
1172 continue;
1173 }
1174 str = _("Allows");
1175 str = "<b>" + str + "</b> "
1177 tb = new QLabel(this);
1178 tb->setProperty(fonts::help_label, "true");
1179 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
1180 tb->setTextFormat(Qt::RichText);
1181 tb->setText(str.trimmed());
1182 connect(tb, &QLabel::linkActivated,
1184 info_layout->addWidget(tb);
1186
1188 helptext_advance(buffer, sizeof(buffer), client.conn.playing,
1189 topic->text, n);
1190 text_browser->setPlainText(buffer);
1191
1192 }
1193 } else {
1194 set_topic_other(topic, title);
1195 }
1196}
1197
1198/**********************************************************************/
1202 const struct extra_type *resource,
1203 enum extra_cause cause)
1204{
1205 struct canvas *canvas;
1206 struct drawn_sprite sprs[80];
1207 int canvas_y, count, i, width, height;
1208 struct extra_type *pextra;
1209
1213
1215 canvas->map_pixmap.fill(Qt::transparent);
1216 for (i = 0; i < 3; ++i) {
1218 i, terrain);
1219 put_drawn_sprites(canvas, 1.0f, 0, canvas_y, count, sprs, false);
1220 }
1221
1222 pextra = NULL;
1223 if (cause != EC_COUNT) {
1224 extra_type_by_cause_iterate(cause, e) {
1225 pextra = e;
1226 break;
1228
1229 count = fill_basic_extra_sprite_array(tileset, sprs, pextra);
1230 put_drawn_sprites(canvas, 1.0f, 0, canvas_y, count, sprs, false);
1231 }
1232
1233 if (resource != NULL) {
1235 put_drawn_sprites(canvas, 1.0f, 0, canvas_y, count, sprs, false);
1236 }
1237
1238 return canvas;
1239}
1240
1241/**********************************************************************/
1246 const struct canvas *image,
1247 const QString &legend,
1248 const QString &tooltip)
1249{
1250 QGraphicsDropShadowEffect *effect;
1251 QLabel *label;
1252 QGridLayout *layout = new QGridLayout();
1253
1254 label = new QLabel();
1255 effect = new QGraphicsDropShadowEffect(label);
1256 effect->setBlurRadius(3);
1257 effect->setOffset(0, 2);
1258 label->setGraphicsEffect(effect);
1259 label->setPixmap(image->map_pixmap);
1260 layout->addWidget(label, 0, 0, 2, 1);
1261
1262 label = new QLabel(title);
1263 label->setTextFormat(Qt::PlainText);
1264 layout->addWidget(label, 0, 1, Qt::AlignBottom);
1265 label->setProperty(fonts::default_font, "true");
1266
1267 label = new QLabel(legend);
1268 label->setTextFormat(Qt::PlainText);
1269 layout->addWidget(label, 1, 1, Qt::AlignTop);
1270 label->setProperty(fonts::help_label, "true");
1271
1272 if (!tooltip.isEmpty()) {
1273 label->setToolTip(tooltip);
1274 label->setCursor(Qt::WhatsThisCursor);
1275 }
1276
1277 layout->setColumnStretch(0, 0);
1278 layout->setColumnStretch(1, 100);
1279
1280 return layout;
1281}
1282
1283/**********************************************************************/
1287 const char *title)
1288{
1289 char buffer[MAX_HELP_TEXT_SIZE];
1290 struct terrain *pterrain, *max;
1291 QVBoxLayout *vbox;
1292 bool show_panel = false;
1293 QScrollArea *area;
1294 QWidget *panel;
1295 QString str;
1296
1298 if (pterrain) {
1299 struct universal for_terr;
1300 canvas *canvas;
1301
1302 for_terr.kind = VUT_TERRAIN;
1303 for_terr.value.terrain = pterrain;
1304
1305 helptext_terrain(buffer, sizeof(buffer), client.conn.playing,
1306 topic->text, pterrain);
1307 text_browser->setPlainText(buffer);
1308
1309 // Create information panel
1311 max = terrain_max_values();
1312
1313 // Create terrain icon. Use shadow to help distinguish terrain.
1314 canvas = terrain_canvas(pterrain);
1317
1318 add_info_progress(_("Food:"), pterrain->output[O_FOOD],
1319 0, max->output[O_FOOD]);
1320 add_info_progress(_("Production:"), pterrain->output[O_SHIELD],
1321 0, max->output[O_SHIELD]);
1322 add_info_progress(_("Trade:"), pterrain->output[O_TRADE],
1323 0, max->output[O_TRADE]);
1324
1326
1327 add_info_progress(_("Move cost:"), pterrain->movement_cost,
1328 0, max->movement_cost);
1329 add_info_progress(_("Defense bonus:"), MIN(100, pterrain->defense_bonus),
1330 0, 100,
1331 // TRANS: Display a percentage, eg "50%".
1332 QString(_("%1%")).arg(pterrain->defense_bonus));
1333
1335
1336 if (pterrain->cultivate_result != T_NONE
1337 && action_id_univs_not_blocking(ACTION_CULTIVATE,
1338 NULL, &for_terr)) {
1339 QLabel *tb;
1340 char cult_buffer[1024];
1341
1342 fc_snprintf(cult_buffer, sizeof(cult_buffer), PL_("%d turn", "%d turns",
1343 pterrain->cultivate_time),
1344 pterrain->cultivate_time);
1345 str = N_("Cultiv. Rslt/Time:");;
1348 + QString(cult_buffer).toHtmlEscaped();
1349 tb = new QLabel(this);
1350 tb->setProperty(fonts::help_label, "true");
1351 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
1352 tb->setTextFormat(Qt::RichText);
1353 tb->setText(str.trimmed());
1354 connect(tb, &QLabel::linkActivated,
1356 info_layout->addWidget(tb);
1357 }
1358
1359 if (pterrain->plant_result != T_NONE
1360 && action_id_univs_not_blocking(ACTION_PLANT, NULL, &for_terr)) {
1361 QLabel *tb;
1362 char plant_buffer[1024];
1363
1364 fc_snprintf(plant_buffer, sizeof(plant_buffer), PL_("%d turn", "%d turns",
1365 pterrain->plant_time),
1366 pterrain->plant_time);
1367 str = N_("Plant Rslt/Time:");;
1370 + QString(plant_buffer).toHtmlEscaped();
1371 tb = new QLabel(this);
1372 tb->setProperty(fonts::help_label, "true");
1373 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
1374 tb->setTextFormat(Qt::RichText);
1375 tb->setText(str.trimmed());
1376 connect(tb, &QLabel::linkActivated,
1378 info_layout->addWidget(tb);
1379 }
1380
1381 if (pterrain->transform_result != T_NONE
1382 && action_id_univs_not_blocking(ACTION_TRANSFORM_TERRAIN,
1383 NULL, &for_terr)) {
1384 QLabel *tb;
1385 char tf_buffer[1024];
1386
1387 fc_snprintf(tf_buffer, sizeof(tf_buffer), PL_("%d turn", "%d turns",
1388 pterrain->transform_time),
1389 pterrain->transform_time);
1390 str = N_("Trans. Rslt/Time:");
1393 + QString(tf_buffer).toHtmlEscaped();
1394 tb = new QLabel(this);
1395 tb->setProperty(fonts::help_label, "true");
1396 tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
1397 tb->setTextFormat(Qt::RichText);
1398 tb->setText(str.trimmed());
1399 connect(tb, &QLabel::linkActivated,
1401 info_layout->addWidget(tb);
1402 }
1403
1404 if (action_id_univs_not_blocking(ACTION_IRRIGATE, NULL, &for_terr)) {
1405 /* TRANS: this and similar literal strings interpreted as (Qt) HTML */
1406 add_extras_of_act_for_terrain(pterrain, ACTIVITY_IRRIGATE, _("Build as irrigation"));
1407 }
1408 if (action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) {
1409 add_extras_of_act_for_terrain(pterrain, ACTIVITY_MINE, _("Build as mine"));
1410 }
1411 if (pterrain->road_time != 0
1412 && action_id_univs_not_blocking(ACTION_ROAD, NULL, &for_terr)) {
1413 add_extras_of_act_for_terrain(pterrain, ACTIVITY_GEN_ROAD, _("Build as road"));
1414 }
1415 if (pterrain->base_time != 0
1416 && action_id_univs_not_blocking(ACTION_BASE, NULL, &for_terr)) {
1417 add_extras_of_act_for_terrain(pterrain, ACTIVITY_BASE, _("Build as base"));
1418 }
1419
1421
1422 // Create bottom widget
1423 panel = new QWidget();
1424 vbox = new QVBoxLayout(panel);
1425
1426 if (*(pterrain->resources)) {
1427 struct extra_type **r;
1428
1429 for (r = pterrain->resources; *r; r++) {
1430 canvas = terrain_canvas(pterrain, *r);
1431 vbox->addLayout(create_terrain_widget(
1433 canvas,
1434 // TRANS: %1 food, %2 shields, %3 trade
1435 QString(_("Tile output becomes %1, %2, %3."))
1436 .arg(pterrain->output[O_FOOD] + (*r)->data.resource->output[O_FOOD])
1437 .arg(pterrain->output[O_SHIELD] + (*r)->data.resource->output[O_SHIELD])
1438 .arg(pterrain->output[O_TRADE] + (*r)->data.resource->output[O_TRADE]),
1439 // TRANS: Tooltip decorating strings like "1, 2, 3".
1440 _("Output (Food, Shields, Trade) of a tile where the resource is "
1441 "present.")));
1443 show_panel = true;
1444 }
1445 }
1446
1447 vbox->addStretch(100);
1448 vbox->setSizeConstraint(QLayout::SetMinimumSize);
1449 if (show_panel) {
1450 area = new QScrollArea();
1451 area->setWidget(panel);
1452 set_bottom_panel(area);
1453 } else {
1454 panel->deleteLater();
1455 }
1456
1457 delete max;
1458 } else {
1459 set_topic_other(topic, title);
1460 }
1461}
1462
1463/**********************************************************************/
1469 const char *title)
1470{
1471 char buffer[MAX_HELP_TEXT_SIZE];
1473
1474 if (pextra) {
1475 canvas *canvas;
1476 int canvas_y, count, width, height;
1477 struct drawn_sprite sprs[80];
1478
1479 helptext_extra(buffer, sizeof(buffer), client.conn.playing,
1480 topic->text, pextra);
1481 text_browser->setPlainText(buffer);
1482
1483 // Create information panel
1485
1486 // Create extra icon.
1491 canvas->map_pixmap.fill(Qt::transparent);
1492 count = fill_basic_extra_sprite_array(tileset, sprs, pextra);
1493 put_drawn_sprites(canvas, 1.0f, 0, canvas_y, count, sprs, false);
1496
1497 return false;
1498 } else {
1499 set_topic_other(topic, title);
1500
1501 return true;
1502 }
1503}
1504
1505/**********************************************************************/
1509 const char *title)
1510{
1511 char buffer[MAX_HELP_TEXT_SIZE];
1513 if (pspec) {
1514 helptext_specialist(buffer, sizeof(buffer), client.conn.playing,
1515 topic->text, pspec);
1516 text_browser->setPlainText(buffer);
1517 } else {
1518 set_topic_other(topic, title);
1519 }
1520}
1521
1522/**********************************************************************/
1526 const char *title)
1527{
1528 char buffer[MAX_HELP_TEXT_SIZE];
1530 if (pgov) {
1531 helptext_government(buffer, sizeof(buffer), client.conn.playing,
1532 topic->text, pgov);
1533 text_browser->setPlainText(buffer);
1534 } else {
1535 set_topic_other(topic, title);
1536 }
1537}
1538
1539/**********************************************************************/
1543 const char *title)
1544{
1545 char buffer[MAX_HELP_TEXT_SIZE];
1547 if (pnation) {
1548 helptext_nation(buffer, sizeof(buffer), pnation, topic->text);
1549 text_browser->setPlainText(buffer);
1550 } else {
1551 set_topic_other(topic, title);
1552 }
1553}
1554
1555/**********************************************************************/
1559 const char *title)
1560{
1561 char buffer[MAX_HELP_TEXT_SIZE];
1562 struct goods_type *pgood = goods_by_translated_name(title);
1563 if (pgood) {
1564 helptext_goods(buffer, sizeof(buffer), client.conn.playing,
1565 topic->text, pgood);
1566 text_browser->setText(buffer);
1567 } else {
1568 set_topic_other(topic, title);
1569 }
1570}
1571
1572/**********************************************************************/
1583{
1584 Terrain_type_id i, count;
1585 struct terrain *terrain;
1586 struct terrain *max = new struct terrain;
1587 max->base_time = 0;
1588 max->clean_fallout_time = 0;
1589 max->clean_pollution_time = 0;
1590 max->defense_bonus = 0;
1591 max->irrigation_food_incr = 0;
1592 max->irrigation_time = 0;
1593 max->mining_shield_incr = 0;
1594 max->mining_time = 0;
1595 max->movement_cost = 0;
1596 max->output[O_FOOD] = 0;
1597 max->output[O_GOLD] = 0;
1598 max->output[O_LUXURY] = 0;
1599 max->output[O_SCIENCE] = 0;
1600 max->output[O_SHIELD] = 0;
1601 max->output[O_TRADE] = 0;
1602 max->pillage_time = 0;
1603 max->road_output_incr_pct[O_FOOD] = 0;
1604 max->road_output_incr_pct[O_GOLD] = 0;
1608 max->road_output_incr_pct[O_TRADE] = 0;
1609 max->road_time = 0;
1610 max->transform_time = 0;
1611 count = terrain_count();
1612 for (i = 0; i < count; ++i) {
1614#define SET_MAX(v) \
1615 max->v = max->v > terrain->v ? max->v : terrain->v
1616 SET_MAX(base_time);
1617 SET_MAX(clean_fallout_time);
1618 SET_MAX(clean_pollution_time);
1619 SET_MAX(defense_bonus);
1620 SET_MAX(irrigation_food_incr);
1621 SET_MAX(irrigation_time);
1622 SET_MAX(mining_shield_incr);
1623 SET_MAX(mining_time);
1624 SET_MAX(movement_cost);
1625 SET_MAX(output[O_FOOD]);
1626 SET_MAX(output[O_GOLD]);
1627 SET_MAX(output[O_LUXURY]);
1628 SET_MAX(output[O_SCIENCE]);
1629 SET_MAX(output[O_SHIELD]);
1630 SET_MAX(output[O_TRADE]);
1631 SET_MAX(pillage_time);
1632 SET_MAX(road_output_incr_pct[O_FOOD]);
1633 SET_MAX(road_output_incr_pct[O_GOLD]);
1634 SET_MAX(road_output_incr_pct[O_LUXURY]);
1635 SET_MAX(road_output_incr_pct[O_SCIENCE]);
1636 SET_MAX(road_output_incr_pct[O_SHIELD]);
1637 SET_MAX(road_output_incr_pct[O_TRADE]);
1638 SET_MAX(road_time);
1639 SET_MAX(transform_time);
1640#undef SET_MAX
1641 }
1642 return max;
1643}
1644
1645/**********************************************************************/
1655{
1656 struct unit_type *max = new struct unit_type;
1657
1658 max->uclass = uclass;
1659 max->attack_strength = 0;
1660 max->bombard_rate = 0;
1661 max->build_cost = 0;
1662 max->city_size = 0;
1663 max->convert_time = 0;
1664 max->defense_strength = 0;
1665 max->firepower = 0;
1666 max->fuel = 0;
1667 max->happy_cost = 0;
1668 max->hp = 0;
1669 max->move_rate = 0;
1670 max->pop_cost = 0;
1671 max->upkeep[O_FOOD] = 0;
1672 max->upkeep[O_GOLD] = 0;
1673 max->upkeep[O_LUXURY] = 0;
1674 max->upkeep[O_SCIENCE] = 0;
1675 max->upkeep[O_SHIELD] = 0;
1676 max->upkeep[O_TRADE] = 0;
1677 max->vision_radius_sq = 0;
1678
1679 unit_type_iterate(utype) {
1680 if (utype->uclass == uclass) {
1681
1682#define SET_MAX(v) \
1683 max->v = max->v > utype->v ? max->v : utype->v
1684
1685 SET_MAX(attack_strength);
1686 SET_MAX(bombard_rate);
1687 SET_MAX(build_cost);
1688 SET_MAX(city_size);
1689 SET_MAX(convert_time);
1690 SET_MAX(defense_strength);
1691 SET_MAX(firepower);
1692 SET_MAX(fuel);
1693 SET_MAX(happy_cost);
1694 SET_MAX(hp);
1695 SET_MAX(move_rate);
1696 SET_MAX(pop_cost);
1697 SET_MAX(upkeep[O_FOOD]);
1698 SET_MAX(upkeep[O_GOLD]);
1699 SET_MAX(upkeep[O_LUXURY]);
1700 SET_MAX(upkeep[O_SCIENCE]);
1701 SET_MAX(upkeep[O_SHIELD]);
1702 SET_MAX(upkeep[O_TRADE]);
1703 SET_MAX(vision_radius_sq);
1704
1705#undef SET_MAX
1706
1707 }
1709
1710 return max;
1711}
#define action_id_univs_not_blocking(act_id, act_uni, tgt_uni)
Definition actions.h:962
#define str
Definition astring.c:76
#define n
Definition astring.c:77
void qtg_canvas_free(struct canvas *store)
Definition canvas.cpp:47
struct canvas * qtg_canvas_create(int width, int height)
Definition canvas.cpp:35
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int canvas_y
Definition canvas_g.h:43
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
static fc_font * instance()
Definition fonts.cpp:41
QFont * get_font(QString name)
Definition fonts.cpp:63
QTreeWidget * tree_wdg
Definition helpdlg.h:51
void hideEvent(QHideEvent *event)
Definition helpdlg.cpp:195
int history_pos
Definition helpdlg.h:56
bool update_history
Definition helpdlg.h:61
QPushButton * prev_butt
Definition helpdlg.h:49
help_dialog(QWidget *parent=0)
Definition helpdlg.cpp:123
void history_forward()
Definition helpdlg.cpp:363
QPushButton * next_butt
Definition helpdlg.h:50
void set_topic(const help_item *item)
Definition helpdlg.cpp:346
help_widget * help_wdg
Definition helpdlg.h:52
void make_tree()
Definition helpdlg.cpp:232
void showEvent(QShowEvent *event)
Definition helpdlg.cpp:204
QHash< QTreeWidgetItem *, const help_item * > topics_map
Definition helpdlg.h:55
void item_changed(QTreeWidgetItem *item, QTreeWidgetItem *prev)
Definition helpdlg.cpp:414
void update_fonts()
Definition helpdlg.cpp:187
QSplitter * splitter
Definition helpdlg.h:53
void closeEvent(QCloseEvent *event)
Definition helpdlg.cpp:223
void update_buttons()
Definition helpdlg.cpp:397
QList< QTreeWidgetItem * > item_history
Definition helpdlg.h:54
void history_back()
Definition helpdlg.cpp:380
void add_info_separator()
Definition helpdlg.cpp:752
QString link_me(const char *str, help_page_type hpt)
Definition helpdlg.cpp:741
void show_info_panel()
Definition helpdlg.cpp:617
void update_fonts()
Definition helpdlg.cpp:564
void set_topic_specialist(const help_item *item, const char *title)
Definition helpdlg.cpp:1508
void info_panel_done()
Definition helpdlg.cpp:760
void add_info_progress(const QString &label, int progress, int min, int max, const QString &value=QString())
Definition helpdlg.cpp:664
QSplitter * splitter
Definition helpdlg.h:89
void anchor_clicked(const QString &link)
Definition helpdlg.cpp:769
void set_bottom_panel(QWidget *widget)
Definition helpdlg.cpp:853
QWidget * main_widget
Definition helpdlg.h:85
void setup_ui()
Definition helpdlg.cpp:465
void add_info_pixmap(QPixmap *pm, bool shadow=false)
Definition helpdlg.cpp:626
void add_info_label(const QString &text)
Definition helpdlg.cpp:647
QVBoxLayout * info_layout
Definition helpdlg.h:90
void set_topic_tech(const help_item *item, const char *title)
Definition helpdlg.cpp:1090
void add_extras_of_act_for_terrain(struct terrain *pterr, enum unit_activity act, const char *label)
Definition helpdlg.cpp:703
QFrame * box_wdg
Definition helpdlg.h:82
void set_topic_other(const help_item *item, const char *title)
Definition helpdlg.cpp:860
void set_topic(const help_item *item)
Definition helpdlg.cpp:794
bool set_topic_extra(const help_item *item, const char *title)
Definition helpdlg.cpp:1468
void set_topic_nation(const help_item *item, const char *title)
Definition helpdlg.cpp:1542
QLayout * create_terrain_widget(const QString &title, const struct canvas *image, const QString &legend, const QString &tooltip=QString())
Definition helpdlg.cpp:1245
void undo_layout()
Definition helpdlg.cpp:594
QList< int > splitter_sizes
Definition helpdlg.h:91
struct unit_type * uclass_max_values(struct unit_class *uclass)
Definition helpdlg.cpp:1654
QTextBrowser * text_browser
Definition helpdlg.h:86
help_widget(QWidget *parent=0)
Definition helpdlg.cpp:435
void set_topic_terrain(const help_item *item, const char *title)
Definition helpdlg.cpp:1286
void do_layout(bool horizontal)
Definition helpdlg.cpp:516
void set_topic_goods(const help_item *item, const char *title)
Definition helpdlg.cpp:1558
QWidget * info_panel
Definition helpdlg.h:88
void set_topic_building(const help_item *item, const char *title)
Definition helpdlg.cpp:998
void set_topic_government(const help_item *item, const char *title)
Definition helpdlg.cpp:1525
void set_topic_unit(const help_item *item, const char *title)
Definition helpdlg.cpp:873
QWidget * bottom_panel
Definition helpdlg.h:87
QLabel * title_label
Definition helpdlg.h:83
struct terrain * terrain_max_values()
Definition helpdlg.cpp:1582
void reactivate()
Definition dialogs.cpp:322
struct civclient client
static struct fc_sockaddr_list * list
Definition clinet.c:102
enum event_type event
Definition events.c:81
struct extra_type * extra_type_by_translated_name(const char *name)
Definition extras.c:227
enum extra_cause activity_to_extra_cause(enum unit_activity act)
Definition extras.c:1028
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:186
#define extra_type_by_cause_iterate_end
Definition extras.h:315
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:309
int Terrain_type_id
Definition fc_types.h:343
@ O_SHIELD
Definition fc_types.h:91
@ O_FOOD
Definition fc_types.h:91
@ O_TRADE
Definition fc_types.h:91
@ O_SCIENCE
Definition fc_types.h:91
@ O_LUXURY
Definition fc_types.h:91
@ O_GOLD
Definition fc_types.h:91
const char * skip_intl_qualifier_prefix(const char *str)
Definition fcintl.c:48
#define Q_(String)
Definition fcintl.h:70
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
#define N_(String)
Definition fcintl.h:69
const char * government_name_translation(const struct government *pgovern)
Definition government.c:142
struct government * government_by_translated_name(const char *name)
Definition government.c:39
#define governments_iterate(NAME_pgov)
Definition government.h:121
#define governments_iterate_end
Definition government.h:124
static PangoLayout * layout
Definition canvas.c:331
static struct tile * pos
Definition finddlg.c:53
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Definition helpdlg.c:195
#define REQ_LABEL_NEVER
Definition helpdlg.c:143
#define REQ_LABEL_NONE
Definition helpdlg.c:142
const char * tooltip
Definition repodlgs.c:1314
const char * title
Definition repodlgs.c:1313
GType type
Definition repodlgs.c:1312
static GHashTable * hash
Definition wldlg.c:320
static struct canvas * terrain_canvas
Definition mapview.c:78
void helptext_government(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct government *gov)
Definition helpdata.c:4175
void helptext_advance(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, int i)
Definition helpdata.c:3115
void helptext_extra(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct extra_type *pextra)
Definition helpdata.c:3619
void helptext_goods(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct goods_type *pgood)
Definition helpdata.c:4094
char * helptext_unit_upkeep_str(const struct unit_type *utype)
Definition helpdata.c:4834
const char * helptext_extra_for_terrain_str(struct extra_type *pextra, struct terrain *pterrain, enum unit_activity act)
Definition helpdata.c:3585
void helptext_specialist(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct specialist *pspec)
Definition helpdata.c:4140
const struct help_item * get_help_item_spec(const char *name, enum help_page_type htype, int *pos)
Definition helpdata.c:1223
char * helptext_building(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct impr_type *pimprove)
Definition helpdata.c:1316
void helptext_terrain(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct terrain *pterrain)
Definition helpdata.c:3338
char * helptext_unit(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct unit_type *utype)
Definition helpdata.c:1763
void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation, const char *user_text)
Definition helpdata.c:4871
#define help_items_iterate(pitem)
Definition helpdata.h:70
#define help_items_iterate_end
Definition helpdata.h:74
void popdown_help_dialog(void)
Definition helpdlg.cpp:101
#define SET_MAX(v)
void popup_help_dialog_string(const char *item)
Definition helpdlg.cpp:68
static help_dialog * help_dlg
Definition helpdlg.cpp:56
void update_help_fonts()
Definition helpdlg.cpp:113
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Definition helpdlg.cpp:79
#define MAX_HELP_TEXT_SIZE
Definition helpdlg.cpp:53
help_page_type
Definition helpdlg_g.h:20
@ HELP_ANY
Definition helpdlg_g.h:20
@ HELP_MULTIPLIER
Definition helpdlg_g.h:24
@ HELP_TERRAIN
Definition helpdlg_g.h:21
@ HELP_EXTRA
Definition helpdlg_g.h:21
@ HELP_NATIONS
Definition helpdlg_g.h:23
@ HELP_LAST
Definition helpdlg_g.h:24
@ HELP_IMPROVEMENT
Definition helpdlg_g.h:20
@ HELP_UNIT
Definition helpdlg_g.h:20
@ HELP_SPECIALIST
Definition helpdlg_g.h:22
@ HELP_GOVERNMENT
Definition helpdlg_g.h:22
@ HELP_GOODS
Definition helpdlg_g.h:22
@ HELP_WONDER
Definition helpdlg_g.h:21
@ HELP_TECH
Definition helpdlg_g.h:21
@ HELP_RULESET
Definition helpdlg_g.h:23
@ HELP_TEXT
Definition helpdlg_g.h:20
@ HELP_TILESET
Definition helpdlg_g.h:23
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)
Definition movement.c:973
static mpgui * gui
Definition mpgui_qt.cpp:52
const char *const default_font
Definition fonts.h:27
const char *const notify_label
Definition fonts.h:28
const char *const help_label
Definition fonts.h:29
const char *const help_text
Definition fonts.h:30
struct nation_type * nation_by_translated_plural(const char *name)
Definition nation.c:105
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)
#define MIN(x, y)
Definition shared.h:55
struct specialist * specialist_by_translated_name(const char *name)
Definition specialist.c:130
QPixmap map_pixmap
Definition canvas.h:25
struct connection conn
Definition client_main.h:96
struct player * playing
Definition connection.h:156
struct sprite * sprite
Definition tilespec.h:111
struct resource_type * resource
Definition extras.h:150
char * topic
Definition helpdata.h:26
enum help_page_type type
Definition helpdata.h:27
char * text
Definition helpdata.h:26
struct requirement_vector obsolete_by
Definition improvement.h:76
struct requirement_vector reqs
Definition improvement.h:75
Definition climisc.h:82
QPixmap * pm
Definition sprite.h:25
struct terrain * cultivate_result
Definition terrain.h:203
struct extra_type ** resources
Definition terrain.h:197
int road_time
Definition terrain.h:201
int plant_time
Definition terrain.h:207
struct terrain * plant_result
Definition terrain.h:206
int irrigation_food_incr
Definition terrain.h:209
int clean_fallout_time
Definition terrain.h:220
int defense_bonus
Definition terrain.h:193
int cultivate_time
Definition terrain.h:204
int movement_cost
Definition terrain.h:192
int pillage_time
Definition terrain.h:221
int output[O_LAST]
Definition terrain.h:195
int transform_time
Definition terrain.h:218
int mining_time
Definition terrain.h:213
int clean_pollution_time
Definition terrain.h:219
int road_output_incr_pct[O_LAST]
Definition terrain.h:199
struct terrain * transform_result
Definition terrain.h:217
int irrigation_time
Definition terrain.h:210
int base_time
Definition terrain.h:200
int mining_shield_incr
Definition terrain.h:212
struct unit_class * uclass
Definition unittype.h:537
int pop_cost
Definition unittype.h:493
int defense_strength
Definition unittype.h:496
int firepower
Definition unittype.h:506
int build_cost
Definition unittype.h:492
int convert_time
Definition unittype.h:512
int city_size
Definition unittype.h:531
const struct unit_type * obsoleted_by
Definition unittype.h:510
int vision_radius_sq
Definition unittype.h:503
int move_rate
Definition unittype.h:497
struct advance * require_advance
Definition unittype.h:500
int bombard_rate
Definition unittype.h:528
int upkeep[O_LAST]
Definition unittype.h:519
int attack_strength
Definition unittype.h:495
int happy_cost
Definition unittype.h:518
enum universals_n kind
Definition fc_types.h:758
universals_u value
Definition fc_types.h:757
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
#define FALSE
Definition support.h:47
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
bool is_future_tech(Tech_type_id tech)
Definition tech.c:281
struct advance * advance_by_translated_name(const char *name)
Definition tech.c:185
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:290
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
#define A_NONE
Definition tech.h:43
Terrain_type_id terrain_count(void)
Definition terrain.c:106
struct terrain * terrain_by_translated_name(const char *name)
Definition terrain.c:190
const char * terrain_name_translation(const struct terrain *pterrain)
Definition terrain.c:226
struct terrain * terrain_by_number(const Terrain_type_id type)
Definition terrain.c:144
#define T_NONE
Definition terrain.h:56
struct sprite * get_government_sprite(const struct tileset *t, const struct government *gov)
Definition tilespec.c:6504
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:6494
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum direction8 facing)
Definition tilespec.c:6516
int tileset_full_tile_height(const struct tileset *t)
Definition tilespec.c:752
int fill_basic_extra_sprite_array(const struct tileset *t, struct drawn_sprite *sprs, const struct extra_type *pextra)
Definition tilespec.c:6897
int fill_basic_terrain_layer_sprite_array(struct tileset *t, struct drawn_sprite *sprs, int layer, struct terrain *pterrain)
Definition tilespec.c:6864
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:728
int tileset_full_tile_width(const struct tileset *t)
Definition tilespec.c:739
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6467
struct sprite * get_tech_sprite(const struct tileset *t, Tech_type_id tech)
Definition tilespec.c:6485
struct goods_type * goods_by_translated_name(const char *name)
struct terrain * terrain
Definition fc_types.h:602
int utype_build_shield_cost_base(const struct unit_type *punittype)
Definition unittype.c:1520
struct unit_type * unit_type_by_translated_name(const char *name)
Definition unittype.c:1804
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1612
#define unit_type_iterate(_p)
Definition unittype.h:841
#define unit_type_iterate_end
Definition unittype.h:848