18 #include <QGridLayout>
19 #include <QMouseEvent>
21 #include <QPushButton>
22 #include <QScrollArea>
23 #include <QStringLiteral>
25 #include <QToolButton>
49 extern QString
split_text(
const QString &text,
bool cut);
52 struct city *pcity,
bool ext);
71 setMouseTracking(
true);
72 setAttribute(Qt::WA_StyledBackground);
102 if (
req !=
nullptr) {
110 pcanvas->fill(Qt::transparent);
135 case TECH_PREREQS_KNOWN:
136 dsend_packet_player_research(&
client.
conn, tech);
139 dsend_packet_player_tech_goal(&
client.
conn, tech);
144 }
else if (
event->button() == Qt::RightButton) {
145 for (i = 0; i <
tt_help->count(); i++) {
153 }
else if (rttp->
timpr !=
nullptr) {
157 }
else if (rttp->
tunit !=
nullptr) {
160 }
else if (rttp->
tgov !=
nullptr) {
184 for (i = 0; i <
tt_help->count(); i++) {
190 tt_text = QString(buffer);
191 def_str =
"<p style='white-space:pre'><b>"
196 }
else if (rttp->
timpr !=
nullptr) {
202 }
else if (rttp->
tunit !=
nullptr) {
208 }
else if (rttp->
tgov !=
nullptr) {
211 tt_text = QString(buffer);
213 def_str =
"<p style='white-space:pre'><b>"
221 tt_text = def_str + tt_text.toHtmlEscaped();
253 QWidget::paintEvent(
event);
280 QSizePolicy size_expanding_policy(QSizePolicy::Expanding,
281 QSizePolicy::Expanding);
282 QSizePolicy size_fixed_policy(QSizePolicy::Minimum, QSizePolicy::Minimum);
289 auto sci_layout =
new QGridLayout();
291 scroll =
new QScrollArea();
294 refresh_but->setToolTip(
_(
"Press to refresh currently researched "
295 "technology calculation again."));
305 _(
"Press to locate currently researched "
306 "technology in tree."));
326 sci_layout->addWidget(
progress, 1, 6, 1, 4);
327 progress->setSizePolicy(size_fixed_policy);
328 sci_layout->addWidget(
goal_combo, 2, 0, 1, 3);
331 sci_layout->addWidget(
info_label, 2, 6, 1, 4);
336 scroll->setAutoFillBackground(
true);
337 scroll->setPalette(QPalette(QColor(215, 215, 215)));
339 scroll->setSizePolicy(size_expanding_policy);
340 sci_layout->addWidget(
scroll, 4, 0, 1, 10);
343 QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
346 QObject::connect(
refresh_but, &QAbstractButton::pressed,
this,
356 QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
359 setLayout(sci_layout);
492 for (
int i = 0; i <
curr_list->count(); i++) {
503 for (
int i = 0; i <
goal_list->count(); i++) {
538 for (
int i = 0; i <
goal_combo->count(); i++) {
597 dsend_packet_player_research(&
client.
conn, qvar.toInt());
613 dsend_packet_player_tech_goal(&
client.
conn, qvar.toInt());
672 str = QString(
_(
"none"));
676 str += QStringLiteral(
"\n");
682 str += QString(
PL_(
"%1(+%2)/%3 (%4 turn)",
"%1(+%2)/%3 (%4 turns)",
690 str += QString(
_(
"%1(+%2)/%3 (never)"))
713 if (
queen()->isRepoDlgOpen(QStringLiteral(
"SCI"))
732 if (
queen()->isRepoDlgOpen(QStringLiteral(
"SCI"))) {
737 sci_rep->deleteLater();
750 if (
queen()->isRepoDlgOpen(QStringLiteral(
"SCI"))) {
752 if (
queen()->game_tab_widget->currentIndex() == i) {
773 if (!
queen()->isRepoDlgOpen(QStringLiteral(
"SCI"))) {
775 sci_rep->
init(
raise);
static fcIcons * instance()
Returns instance of fc_icons.
int gimmeIndexOf(const QString &str)
Returns index on game tab page of given report dialog.
int addGameTab(QWidget *widget)
Inserts tab widget to game view page.
void removeRepoDlg(const QString &str)
Removes report dialog string from the list marking it as closed.
top_bar_widget * sw_science
void updateSidebarTooltips()
Updates top bar tooltips.
void gimmePlace(QWidget *widget, const QString &str)
Finds not used index on game_view_tab and returns it.
fc_game_tab_widget * game_tab_widget
void set_pixmap(struct universal *target)
Sets pixmap from given universal for custom progressbar.
void show_tooltip()
Slot for timer used to show tooltip.
void reset()
Initializes research diagram.
~research_diagram() override
Destructor for research diagram.
QSize size()
Returns size of research_diagram.
bool get_tech_position(Tech_type_id id, int *x, int *y)
Find the center of a node, identified by tech id, and return true if the node was found; false otherw...
void paintEvent(QPaintEvent *event) override
Paint event for research_diagram.
void mousePressEvent(QMouseEvent *event) override
Mouse handler for research_diagram.
QList< req_tooltip_help * > * tt_help
void mouseMoveEvent(QMouseEvent *event) override
Mouse move handler for research_diagram - for showing tooltips.
research_diagram(QWidget *parent=0)
Constructor for research diagram.
void update_reqtree()
Recreates whole diagram and schedules update.
void locate_researching()
Locate the currently researched technology in tree and scroll so that it is visible.
void locate_goal()
Locate technology goal in tree and scroll so that it is visible.
QPushButton * refresh_but
QToolButton * locate_goal_but
science_report()
Consctructor for science_report.
void push_research()
Push (redo) research when qty bulbs researched is greater than the number needed.
QList< qlist_item > * curr_list
QToolButton * locate_researching_but
research_diagram * res_diag
void scroll_reqtree_to_tech(Tech_type_id id)
Scroll the science tree to display the technology identified by tech id.
QList< qlist_item > * goal_list
void update_report()
Updates all important widgets on science_report.
void redraw()
Schedules paint event in some qt queue.
void init(bool raise)
Updates science_report and marks it as opened It has to be called soon after constructor.
void update_reqtree()
Calls update for research_diagram.
void reset_tree()
Recalculates research diagram again and updates science report.
void current_tech_changed(int index)
Slot used when combo box with current tech changes.
void goal_tech_changed(int index)
Slot used when combo box with goal have been changed.
QComboBox * researching_combo
~science_report() override
Destructor for science report Removes "SCI" string marking it as closed And frees given index on list...
bool client_is_global_observer()
Returns whether client is global observer.
struct player * client_player()
Either controlling or observing.
bool can_client_issue_orders()
Returns TRUE iff the client can issue orders (such as giving unit commands).
bool client_is_observer()
Returns whether client is observer.
struct nation_set * client_current_nation_set()
Returns the nation set in use.
#define PL_(String1, String2, n)
const char * government_name_translation(const struct government *pgovern)
Return the (translated) name of the given government.
void helptext_advance(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, int i, const nation_set *nations_to_show)
Append misc dynamic text for advance/technology.
void helptext_government(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct government *gov)
Append text for government.
char * helptext_unit(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct unit_type *utype, const nation_set *nations_to_show)
Append misc dynamic text for units.
char * helptext_building(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct impr_type *pimprove, const nation_set *nations_to_show)
FIXME: Also, in principle these could be auto-generated once, inserted into pitem->text,...
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Popup the help dialog to display help on the given string topic from the given section.
bool is_great_wonder(const struct impr_type *pimprove)
Is this building a great wonder?
const char * improvement_name_translation(const struct impr_type *pimprove)
Return the (translated) name of the given improvement.
#define fc_assert(condition)
pageGame * queen()
Return game instandce.
bool research_invention_reachable(const struct research *presearch, const Tech_type_id tech)
Returns TRUE iff the given tech is ever reachable via research by the players sharing the research by...
struct research * research_get(const struct player *pplayer)
Returns the research structure associated with the player.
QString research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Store the translated name of the given tech (including A_FUTURE) in 'buf'.
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Returns state of the tech for current research.
struct packet_ruleset_control control
struct research::@71::@73 client
struct research::research_invention inventions[A_LAST]
bool is_future_tech(Tech_type_id tech)
Is the given tech a future tech.
struct advance * advance_by_number(const Tech_type_id atype)
Return the advance for the given advance index.
const char * advance_name_translation(const struct advance *padvance)
Return the (translated) name of the given advance/technology.
#define advance_index_iterate_end
#define advance_index_iterate(_start, _index)
const QString science_dialog_text()
Returns the text to display in the science dialog.
const QString get_science_target_text()
Get the short science-target text.
int get_bulbs_per_turn(int *pours, bool *pteam, int *ptheirs)
Return total expected bulbs.
int turns_to_research_done(const struct research *presearch, int per_turn)
Return turns until research complete.
const QString get_science_goal_text(Tech_type_id goal)
Set the science-goal-label text as if we're researching the given goal.
const QPixmap * get_tech_sprite(const struct tileset *t, Tech_type_id tech)
Return the sprite for the technology/advance.
const char * utype_name_translation(const struct unit_type *punittype)
Return the (translated) name of the unit type.
void science_report_dialog_popup(bool raise)
Display the science report.
QString get_tooltip_improvement(impr_type *building, struct city *pcity, bool ext)
QString cut_helptext(const QString &text)
Remove some text from given text(help text) to show as tooltip.
bool comp_less_than(const qlist_item &q1, const qlist_item &q2)
Compare unit_items (used for techs) by name.
QString split_text(const QString &text, bool cut)
Splits long text to 80 characters.
void popdown_science_report()
Closes science report.
void science_report_dialog_redraw(void)
Resize and redraw the requirement tree.
QString get_tooltip_unit(struct unit_type *unit, bool ext)
void real_science_report_dialog_update(void *unused)
Update the science report.
void get_reqtree_dimensions(struct reqtree *reqtree, int *width, int *height)
Give the dimensions of the reqtree.
struct reqtree * create_reqtree(struct player *pplayer, bool show_all)
Generate optimized tech_tree from current ruleset.
QList< req_tooltip_help * > * draw_reqtree(struct reqtree *tree, QPixmap *pcanvas, int canvas_x, int canvas_y, int tt_x, int tt_y, int w, int h)
Draw the reqtree diagram!
Tech_type_id get_tech_on_reqtree(struct reqtree *tree, int x, int y)
Return the tech ID at the given position of the reqtree (or A_NONE).
void destroy_reqtree(struct reqtree *tree)
Free all memory used by tech_tree struct.
bool get_position_on_reqtree(struct reqtree *tree, Tech_type_id tech, int *x, int *y)
Find the center of a node, identified by tech id in a given reqtree and return true if the node was f...