17 #include <QGridLayout>
19 #include <QResizeEvent>
65 : QWidget(parent), unit_selector(nullptr), update_info_timer(nullptr)
67 QGridLayout *game_layout;
70 game_layout =
new QGridLayout;
71 game_layout->setContentsMargins(0, 0, 0, 0);
72 game_layout->setSpacing(0);
83 sw_map->setIcon(QIcon(sprite));
84 sw_map->setIconSize(sprite.size());
87 sw_map->setIconSize(QSize(24, 24));
131 connect(
sw_tax, &QAbstractButton::clicked,
this,
140 message->setAttribute(Qt::WA_NoMousePropagation);
145 sw_message, &QToolButton::toggled, +[](
bool checked) {
184 chat->setAttribute(Qt::WA_NoMousePropagation);
189 x_vote->setAttribute(Qt::WA_NoMousePropagation);
194 gtd->setAttribute(Qt::WA_NoMousePropagation);
215 auto page_game_layout =
new QVBoxLayout;
217 page_game_layout->setStretchFactor(
top_bar_wdg, 0);
220 page_game_layout->setContentsMargins(0, 0, 0, 0);
221 page_game_layout->setSpacing(0);
222 setLayout(page_game_layout);
239 sw_map->setIcon(QIcon(sprite));
240 sw_map->setIconSize(sprite.size());
243 sw_map->setIconSize(QSize(24, 24));
250 : QStringLiteral(
"flag")));
264 if (
king()->current_page() != PAGE_GAME) {
290 const auto rect = screen()->geometry();
291 auto p =
sw_tax->mapToGlobal(QPoint(0,
sw_tax->height()));
314 s = QString(
_(
"%1 \nT:%2"))
344 int entries_used, building_total, unit_total, tax;
350 if (
king()->current_page() != PAGE_GAME) {
367 str = QString(
_(
"Tax: %1% Science: %2% Luxury: %3%\n"))
372 str += QString(
_(
"%1 - max rate: %2%"))
374 QString::number(max));
379 fc_snprintf(buf,
sizeof(buf),
_(
"Income: %d Total Costs: %d"), tax,
380 building_total + unit_total);
382 sw_cities->setToolTip(QString(
_(
"Cities: %1 total"))
388 sw_map->setToolTip(QLatin1String(
""));
399 bool center_next =
false;
400 bool first_tile =
false;
402 struct tile *ptile =
nullptr;
412 first_id = pcity->id;
428 if (ptile !=
nullptr) {
439 bool center_next =
false;
440 bool first_tile =
false;
442 struct tile *ptile =
nullptr;
452 first_id = pcity->id;
468 if (ptile !=
nullptr) {
480 bool center_next =
false;
481 bool first_tile =
false;
483 struct tile *ptile =
nullptr;
489 if (capital ==
nullptr) {
494 ptile = capital->
tile;
495 first_id = capital->
id;
510 if (ptile !=
nullptr) {
522 bool center_next =
false;
523 bool first_tile =
false;
525 struct tile *ptile =
nullptr;
535 first_id = punit->id;
551 if (ptile !=
nullptr) {
559 return qobject_cast<pageGame *>(
king()->pages[PAGE_GAME]);
572 connect(
this, &QStackedWidget::currentChanged,
this,
582 && (
event->type() == QEvent::Resize
583 ||
event->type() == QEvent::LayoutRequest)) {
584 const auto size =
event->type() == QEvent::Resize
585 ?
static_cast<QResizeEvent *
>(
event)->
size()
587 if (event->type() == QEvent::Resize) {
589 qRound(
size.width() *
king()->qt_settings.chat_fwidth),
590 qRound(
size.height() *
king()->qt_settings.chat_fheight));
595 chat->set_chat_visible(
true);
596 chat->resize(qRound(
size.width() *
king()->qt_settings.chat_fwidth),
597 qRound(
size.height() *
king()->qt_settings.chat_fheight));
598 chat->move(qRound(
size.width() *
king()->qt_settings.chat_fx_pos),
599 qRound(
size.height() *
king()->qt_settings.chat_fy_pos));
600 chat->set_chat_visible(visible);
620 const auto max_size = QSize(std::max(300,
size.width() / 4),
621 std::max(200,
size.height() / 3));
624 if (curr_size.width() != max_size.width()
625 || curr_size.height() != max_size.height()) {
626 const auto panel_size =
628 const auto location =
size - panel_size;
632 const auto panel_size =
634 const auto location =
size - panel_size;
650 if (
king()->is_closing()) {
654 for (
auto *sw : qAsConst(
queen()->top_bar_wdg->objects)) {
657 currentWidget()->hide();
658 widget(
index)->show();
661 if (
queen()->mapview_wdg &&
king()->current_page() == PAGE_GAME
700 qCritical(
"Failed to find place for new tab widget");
711 if (str == QLatin1String(
"MAP")) {
726 if (!
king()->is_closing()) {
const char * calendar_text()
Produce a statically allocated textual representation of the current calendar time.
#define city_list_iterate(citylist, pcity)
#define city_list_iterate_end
void city_report_dialog_popup()
Display the city report dialog.
void refresh()
Various refresh after getting new info/reply from server.
QIcon getIcon(const QString &id)
Returns icon by given name.
static fcIcons * instance()
Returns instance of fc_icons.
void set_scale(float s)
Set scale.
void update_actions()
Update possible action for given units.
void scale_changed(double scale) const
void center_on_tile(tile *tile, bool animate=true)
Centers the view on a tile.
The panel at the bottom right of the game screen, holding the minimap and the Turn Done button.
auto turn_done()
Retrieves the Turn Done button.
void refresh()
Refreshes tax rate data.
city_dialog * city_overlay
::minimap_panel * minimap_panel
void rmGameTab(int index)
Removes given tab widget from game page.
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.
bool isRepoDlgOpen(const QString &str)
Checks if given report is opened, if you create new report as tab on game page, figure out some origi...
indicators_widget * sw_indicators
top_bar_widget * sw_cities
void removeRepoDlg(const QString &str)
Removes report dialog string from the list marking it as closed.
top_bar_widget * sw_science
void updateInfoLabelTimeout()
national_budget_widget * sw_tax
void updateSidebarTooltips()
Updates top bar tooltips.
QWidget * game_main_widget
top_bar_widget * sw_cunit
QTimer * update_info_timer
void gimmePlace(QWidget *widget, const QString &str)
Finds not used index on game_view_tab and returns it.
hud_battle_log * battlelog_wdg
fc_game_tab_widget * game_tab_widget
void reloadSidebarIcons()
Reloads top bar icons (useful on theme change)
QMap< QString, QWidget * > opened_repo_dlgs
void updateInfoLabel()
Real update, updates only once per 300 ms.
national_budget_dialog * budget_dialog
top_bar_widget * sw_message
top_bar_widget * sw_diplo
void popup_budget_dialog()
Popup (or raise) the (tax/science/luxury) rates selection dialog.
void addWidget(QWidget *fsw)
Adds new top_bar widget.
enum client_states client_state()
Return current client state.
bool client_is_global_observer()
Returns whether client is global observer.
struct player * client_player()
Either controlling or observing.
bool client_is_observer()
Returns whether client is observer.
void key_unit_wait()
Handle user 'wait' input.
void key_center_capital()
Center the mapview on the player's named capital, or print a failure message.
struct unit * head_of_units_in_focus()
Return head of focus units list.
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Returns the effect bonus for a player.
class fc_client * king()
Return fc_client instance.
const char * government_name_for_player(const struct player *pplayer)
Return the (translated) name of the given government of a player.
bool get_turn_done_button_state()
Return TRUE iff the turn done button should be enabled.
void put_cross_overlay_tile(struct tile *ptile)
Draw a cross-hair overlay on a tile.
const char * nation_plural_for_player(const struct player *pplayer)
Return the (translated) plural noun of the given nation of a player.
struct nation_type * nation_of_player(const struct player *pplayer)
Return the nation of a player.
struct city_list * cities
void update_info_label(void)
Typically an info box is provided to tell the player about the state of their civilization.
static void center_next_enemy_city()
Centers next enemy city on view.
static void center_next_player_city()
Centers next player city on view.
int last_center_player_city
pageGame * queen()
Return game instandce.
static void cycle_enemy_units()
Center on next enemy unit.
int last_center_enemy_city
void toggle_units_report()
static void center_next_player_capital()
Centers next enemy capital.
int player_get_expected_income(const struct player *pplayer)
Return the expected net income of the player this turn.
struct city * player_primary_capital(const struct player *pplayer)
Locate the player's primary capital city, (nullptr Otherwise)
#define players_iterate_end
#define players_iterate(_pplayer)
void get_economy_report_units_data(struct unit_entry *entries, int *num_entries_used, int *total_cost)
Returns an array of units with gold_upkeep.
void get_economy_report_data(struct improvement_entry *entries, int *num_entries_used, int *total_cost, int *total_income)
Fills out the array of struct improvement_entry given by entries.
enum capital_type capital
struct packet_game_info info
struct player_economic economic
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
const QString science_dialog_text()
Returns the text to display in the science dialog.
const QString get_info_label_text_popup()
Return the text for the popup label on the info panel.
const QString get_info_label_text(bool moreinfo)
Return the text for the label on the info panel.
const QPixmap * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Return the sprite for the nation.
void top_bar_right_click_diplomacy()
Right click for diplomacy Opens diplomacy meeting for player For observer popups menu.
void top_bar_right_click_science()
Right click for science, allowing to choose current tech.
void top_bar_units_view()
Click for units view, allowing to close/open.
void top_bar_indicators_menu()
Popups menu on indicators widget.
void top_bar_left_click_science()
Left click for science, allowing to close/open.
void top_bar_show_map()
Callback to show map.
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
void popup_players_dialog()
Display the player list dialog.