20#include <QApplication>
22#include <QDialogButtonBox>
30#include <QRadioButton>
78 | Qt::FramelessWindowHint);
92 f_title.setCapitalization(QFont::SmallCaps);
115 if (
event->key() == Qt::Key_Escape) {
120 QWidget::keyPressEvent(
event);
133 if (
s1.contains(
'\n')) {
136 i =
s1.indexOf(
'\n');
151 QSizePolicy::Expanding);
155 QSizePolicy::Minimum);
219 p.fillRect(
rfull, g);
248 setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
251 f_text.setCapitalization(QFont::SmallCaps);
342 p.setPen(
QColor(0, 0, 0, 0));
359 | Qt::FramelessWindowHint);
374 f_title.setCapitalization(QFont::SmallCaps);
405 | QDialogButtonBox::Cancel,
406 Qt::Horizontal,
this);
408 if (
s1.contains(
'\n')) {
411 i =
s1.indexOf(
'\n');
427 QSizePolicy::Minimum);
430 layout->addWidget(button_box);
434 QObject::connect(button_box, &QDialogButtonBox::accepted,
this, &QDialog::accept);
435 QObject::connect(button_box, &QDialogButtonBox::rejected,
this, &QDialog::reject);
534 unit_lab->setContentsMargins(6, 9, 0, 3);
540 vbox->addSpacerItem(
sp);
548 vbox->setContentsMargins(0, 0, 0, 0);
567 gui()->qt_settings.unit_info_pos_fx =
static_cast<float>(
event->pos().x())
568 /
gui()->mapview_wdg->width();
569 gui()->qt_settings.unit_info_pos_fy =
static_cast<float>(
event->pos().y())
570 /
gui()->mapview_wdg->height();
601 if (
punit ==
nullptr) {
606 font.setCapitalization(QFont::AllUppercase);
612 *
gui()->qt_settings.unit_info_pos_fx),
614 *
gui()->qt_settings.unit_info_pos_fy)));
627 if (
pcity !=
nullptr) {
653 " (Selected %1 units)",
n))
655 }
else if (num > 1) {
661 " +%1 units", num-1))
666 font.setPixelSize((
text_label.height() * 9) / 10);
682 pix = QPixmap::fromImage(
img);
687 pix2.fill(Qt::transparent);
702 crop =
QRect(5, 5, pix.width() - 5, pix.height() - 5);
703 font.setCapitalization(QFont::Capitalize);
704 font.setPointSize((pix.height() * 2) / 5);
717 font.setPointSize(pix.height() / 4);
722 QString(
"+") + QString::number(fuel));
730 font.setPointSize(pix.height() / 5);
736 int t = 2 * font.pointSize();
740 p.drawText(
crop, Qt::AlignLeft | Qt::AlignBottom,
fraction1);
748 p.fillRect(
crop, Qt::white);
751 wwidth = 2 * 3 + pix.width();
766 pix = QPixmap::fromImage(
img);
777 if (
tmp !=
nullptr) {
800 if (e->button() == Qt::LeftButton) {
810 gui()->game_tab_widget->setCurrentIndex(0);
846 p.setCompositionMode(QPainter::CompositionMode_Source);
847 p.setRenderHint(QPainter::SmoothPixmapTransform);
852 p.setCompositionMode(QPainter::CompositionMode_DestinationOver);
874 if (e->button() == Qt::RightButton) {
876 }
else if (e->button() == Qt::LeftButton) {
897 QWidget::leaveEvent(
event);
911 QWidget::enterEvent(
event);
936 layout->setContentsMargins(0, 0, 0, 0);
1164 a->setFixedHeight(
height());
1165 a->setFixedWidth(
height());
1187 for (j = 0; j <
i; j++) {
1189 layout->removeWidget(ui);
1276 for (
i = 0;
i < columnCount();
i++) {
1280 for (
i = 0;
i < rowCount();
i++) {
1286 | Qt::FramelessWindowHint);
1298 curr_row =
s1.indexes().at(0).row();
1317 | Qt::FramelessWindowHint);
1353 no_name->setTitle(
_(
"Unit activity"));
1373 no_name->setTitle(
_(
"Unit HP and MP"));
1417 select =
new QPushButton(
_(
"Select"));
1418 cancel =
new QPushButton(
_(
"Cancel"));
1466 const struct player *pplayer;
1493 const struct player *pplayer;
1519 if ((
event->key() == Qt::Key_Return)
1520 || (
event->key() == Qt::Key_Enter)) {
1523 if (
event->key() == Qt::Key_Escape) {
1527 QWidget::keyPressEvent(
event);
1549 if ((
any->isChecked()
1641 if (
proad->move_cost <= movement_cost) {
1644 movement_cost =
proad->move_cost;
1671 || !
gui()->qt_settings.show_new_turn_text) {
1680 s =
QString(
_(
"Year: %1 (Turn: %2)"))
1686 s +=
" - " +
QString(
_(
"Population: %1"))
1702 s = s +
QString(
_(
"Gold: %1 (%2)"))
1713 int attacker_hp,
int defender_hp,
1714 bool make_att_veteran,
bool make_def_veteran,
1729 if (defender_hp <= 0) {
1765 dimg =
crdimg.scaledToHeight(w, Qt::SmoothTransformation);
1767 if (
dimg.width() < w) {
1768 dt =
QImage(w,
dimg.height(), QImage::Format_ARGB32_Premultiplied);
1769 dt.fill(Qt::transparent);
1771 p.drawImage(w / 2 -
dimg.width() / 2, 0,
dimg);
1775 dimg =
dimg.scaled(w, w, Qt::IgnoreAspectRatio,
1776 Qt::SmoothTransformation);
1789 aimg =
acrimg.scaledToHeight(w, Qt::SmoothTransformation);
1791 if (
aimg.width() < w) {
1792 at =
QImage(w,
dimg.height(), QImage::Format_ARGB32_Premultiplied);
1793 at.fill(Qt::transparent);
1795 p.drawImage(w / 2 -
aimg.width() / 2, 0,
aimg);
1799 aimg =
aimg.scaled(w, w, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
1870 left =
QRect(0 , 0, w , w);
1871 right =
QRect(w, 0, w , w);
1883 p.fillRect(left,
c1);
1884 p.fillRect(right,
c2);
1887 p.drawImage(left,
aimg);
1889 p.setPen(
QColor(Qt::white));
1891 p.drawText(right, Qt::AlignHCenter | Qt::AlignJustify
1892 | Qt::AlignAbsolute,
"*");
1895 p.drawText(left, Qt::AlignHCenter | Qt::AlignJustify
1896 | Qt::AlignAbsolute,
"*");
1898 p.drawText(left, Qt::AlignHorizontal_Mask,
ahploss);
1899 p.drawImage(right,
dimg);
1900 p.drawText(right, Qt::AlignHorizontal_Mask,
dhploss);
1939 QWidget* p) : QRubberBand(s, p)
1960 QRubberBand::paintEvent(
event);
1964 p.drawPixmap(0, 0,
minus);
1974 if (
event->button() == Qt::LeftButton) {
2019 gui()->qt_settings.battlelog_scale =
scale;
2025 hudc->set_fading(1.0);
2056 while (
lhuc.count() > 5) {
2062 hudc->set_fading(1.0);
2094 gui()->qt_settings.battlelog_x =
static_cast<float>(p.x()) /
mapview.
width;
2095 gui()->qt_settings.battlelog_y =
static_cast<float>(p.y())
2123 if (
hudc->get_focus()) {
2128 hudc->set_fading((5000.0 -
m_timer.elapsed()) / 1000);
2131 if (
m_timer.elapsed() >= 5000) {
QRect zealous_crop_rect(QImage &p)
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 struct sprite int int int width
const char * city_name_get(const struct city *pcity)
void mousePressEvent(QMouseEvent *e)
static fc_font * instance()
QFont * get_font(QString name)
QPixmap * get_pixmap(const QString &id)
static fc_icons * instance()
void paintEvent(QPaintEvent *event)
void leaveEvent(QEvent *event)
void mousePressEvent(QMouseEvent *e)
void mouseMoveEvent(QMouseEvent *event)
hud_action(QWidget *parent)
void enterEvent(QEnterEvent *event)
shortcut_id action_shortcut
void set_pixmap(QPixmap *p)
QList< hud_unit_combat * > lhuc
void add_combat_info(hud_unit_combat *huc)
hud_battle_log(QWidget *parent)
QVBoxLayout * main_layout
void moveEvent(QMoveEvent *event)
void timerEvent(QTimerEvent *event)
void paintEvent(QPaintEvent *event)
void showEvent(QShowEvent *event)
void timerEvent(QTimerEvent *event)
void paintEvent(QPaintEvent *event)
int set_text_title(QString s1, QString s2, bool return_exec=false)
hud_message_box(QWidget *parent)
void keyPressEvent(QKeyEvent *event)
void timerEvent(QTimerEvent *event)
hud_text(QString s, int time_secs, QWidget *parent)
void paintEvent(QPaintEvent *event)
void set_fading(float fade)
hud_unit_combat(int attacker_unit_id, int defender_unit_id, int attacker_hp, int defender_hp, bool make_att_veteran, bool make_def_veteran, float scale, QWidget *parent)
void leaveEvent(QEvent *event)
void mousePressEvent(QMouseEvent *e)
void paintEvent(QPaintEvent *event)
void init_images(bool redraw=false)
const struct unit_type * type_attacker
void set_scale(float scale)
struct tile * center_tile
const struct unit_type * type_defender
void enterEvent(QEnterEvent *event)
hud_unit_loader(struct unit *pcargo, struct tile *ptile)
void selection_changed(const QItemSelection &, const QItemSelection &)
QList< unit * > transports
void update_actions(unit_list *punits)
hud_units(QWidget *parent)
void moveEvent(QMoveEvent *event)
QHBoxLayout * main_layout
unit_actions * unit_icons
unit_actions(QWidget *parent, unit *punit)
QList< hud_action * > actions
QRadioButton * this_continent
QComboBox * unit_sel_type
void keyPressEvent(QKeyEvent *event)
QVBoxLayout * main_layout
QRadioButton * main_continent
QRadioButton * full_hp_mp
bool island_filter(struct unit *punit)
bool type_filter(struct unit *punit)
unit_hud_selector(QWidget *parent)
void select_units(int x=0)
QRadioButton * any_activity
bool activity_filter(struct unit *punit)
bool hp_filter(struct unit *punit)
bool client_is_observer(void)
bool client_has_player(void)
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
void unit_focus_add(struct unit *punit)
struct unit_list * get_units_in_focus(void)
void request_center_focus_unit(void)
struct unit * head_of_units_in_focus(void)
#define can_unit_do_activity_client(_punit_, _act_)
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
#define PL_(String1, String2, n)
const char * population_to_text(int thousand_citizen)
struct unit * game_unit_by_number(int id)
int civ_population(const struct player *pplayer)
bool goto_is_active(void)
static PangoLayout * layout
void put_terrain(struct tile *ptile, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void put_unit(const struct unit *punit, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void put_unittype(const struct unit_type *putype, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void center_tile_mapcanvas(const struct tile *ptile)
const char * move_points_text(int mp, bool reduce)
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
bool unit_can_load(const struct unit *punit)
bool can_unit_transport(const struct unit *transporter, const struct unit *transported)
const char *const default_font
const char *const notify_label
const char * nation_plural_for_player(const struct player *pplayer)
const char * science_dialog_text(void)
int player_get_expected_income(const struct player *pplayer)
struct city * player_city_by_number(const struct player *pplayer, int city_id)
struct city * player_primary_capital(const struct player *pplayer)
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
struct research * research_get(const struct player *pplayer)
bool can_build_road(const struct civ_map *nmap, struct road_type *proad, const struct unit *punit, const struct tile *ptile)
struct sprite int int int int struct sprite int int float scale
struct packet_game_info info
struct player_economic economic
struct research::@79::@81 client
enum unit_activity activity
const struct unit_type * utype
int fc_snprintf(char *str, size_t n, const char *format,...)
const char * get_infrastructure_text(bv_extras extras)
const char * popup_info_text(struct tile *ptile)
const char * get_tile_output_text(const struct tile *ptile)
bool tile_has_road(const struct tile *ptile, const struct road_type *proad)
const char * tile_get_info_text(const struct tile *ptile, bool include_nuisances, int linebreaks)
struct city * tile_city(const struct tile *ptile)
int tileset_unit_width(const struct tileset *t)
int tileset_unit_height(const struct tileset *t)
struct tileset * unscaled_tileset
bool tileset_is_isometric(const struct tileset *t)
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)
int get_transporter_occupancy(const struct unit *ptrans)
bool can_unit_change_homecity_to(const struct civ_map *nmap, const struct unit *punit, const struct city *pcity)
bool unit_can_add_or_build_city(const struct civ_map *nmap, const struct unit *punit)
struct unit * unit_transport_get(const struct unit *pcargo)
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
bool can_unit_do_autoworker(const struct unit *punit)
int get_transporter_capacity(const struct unit *punit)
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap, const struct unit *punit, bool is_free)
bool unit_transported(const struct unit *pcargo)
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const struct unit_type * unit_type_get(const struct unit *punit)
const char * unit_name_translation(const struct unit *punit)
const char * utype_rule_name(const struct unit_type *punittype)
Unit_type_id utype_number(const struct unit_type *punittype)
Unit_type_id utype_index(const struct unit_type *punittype)
const char * utype_name_translation(const struct unit_type *punittype)
#define utype_fuel(ptype)
#define unit_type_iterate(_p)
#define unit_type_iterate_end