diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index b20446310c..4fdeafe2eb 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -51,7 +51,6 @@ add_library( citydlg_common.cpp cityrep.cpp cityrepdata.cpp - civstatus.cpp client_main.cpp climap.cpp climisc.cpp diff --git a/client/civstatus.cpp b/client/civstatus.cpp deleted file mode 100644 index c708e7b962..0000000000 --- a/client/civstatus.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* - Copyright (c) 2021 Freeciv21 contributors. This file is - __ __ part of Freeciv21. Freeciv21 is free software: you can -/ \\..// \ redistribute it and/or modify it under the terms of the GNU - ( oo ) General Public License as published by the Free Software - \__/ Foundation, either version 3 of the License, or (at your - option) any later version. You should have received - a copy of the GNU General Public License along with Freeciv21. If not, - see https://www.gnu.org/licenses/. - */ -#include "civstatus.h" - -#include "canvas.h" -#include "client_main.h" -#include "fc_client.h" -#include "fonts.h" -#include "goto.h" -#include "mapview.h" -#include "page_game.h" -#include "player.h" -#include "text.h" -#include "tilespec.h" -#include "unitlist.h" - -#include -#include -#include - -civstatus::civstatus(QWidget *parent) : fcwidget() -{ - QLabel *label; - QImage img, cropped_img; - QPixmap pix; - QRect crop; - int icon_size; - - setParent(parent); - layout = new QHBoxLayout; - layout->setSizeConstraint(QLayout::SetMinimumSize); - setProperty("civstatus_bg", true); - auto f = fcFont::instance()->getFont(fonts::default_font); - auto fm = QFontMetrics(f); - icon_size = fm.height() * 7 / 8; - - auto spr = get_tax_sprite(tileset, O_GOLD); - label = new QLabel(); - label->setAlignment(Qt::AlignVCenter); - img = spr->toImage(); - crop = zealous_crop_rect(img); - cropped_img = img.copy(crop); - pix = QPixmap::fromImage(cropped_img.scaledToHeight(icon_size)); - label->setPixmap(pix); - - layout->addWidget(label); - economyLabel.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); - layout->addWidget(&economyLabel); - - spr = get_tax_sprite(tileset, O_SCIENCE); - label = new QLabel(); - label->setAlignment(Qt::AlignVCenter); - img = spr->toImage(); - crop = zealous_crop_rect(img); - cropped_img = img.copy(crop); - pix = QPixmap::fromImage(cropped_img.scaledToHeight(icon_size)); - label->setPixmap(pix); - layout->addWidget(label); - scienceLabel.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); - layout->addWidget(&scienceLabel); - unitLabel.setProperty("civstatus", true); - unitLabel.setToolTip( - "Number of units which cannot do any action for some time, you can " - "see those units in unit report - F2"); - economyLabel.setProperty("civstatus", true); - scienceLabel.setProperty("civstatus", true); - unitLabel.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); - layout->addWidget(&unitLabel); - layout->setSizeConstraint(QLayout::SetMinimumSize); - setLayout(layout); - - QTimer *timer = new QTimer(this); - connect(timer, &QTimer::timeout, this, &civstatus::updateInfo); - mw = new move_widget(this); - timer->start(1000); - updateInfo(); -} - -void civstatus::moveEvent(QMoveEvent *event) -{ - QPoint p; - - p = pos(); - king()->qt_settings.civstatus_x = - static_cast(p.x()) / queen()->mapview_wdg->width(); - king()->qt_settings.civstatus_y = - static_cast(p.y()) / queen()->mapview_wdg->height(); -} - -void civstatus::update_menu() {} - -void civstatus::updateInfo() -{ - int a, c; - bool b; - - if (!client_has_player()) { - return; - } - - // gold - QString economyText = - QString::number(client.conn.playing->economic.gold) + "(" - + ((player_get_expected_income(client.conn.playing) > 0) ? "+" : "") - + QString::number(player_get_expected_income(client.conn.playing)) - + ")"; - - // science - int perturn = get_bulbs_per_turn(&a, &b, &c); - int upkeep = client_player()->client.tech_upkeep; - QString scienceText = QString::number(perturn - upkeep); - - // units waiting - int unitsWaiting = 0; - unit_list_iterate(client_player()->units, punit) - { - if (!can_unit_move_now(punit) && punit->ssa_controller == SSA_NONE) { - ++unitsWaiting; - } - } - unit_list_iterate_end; - QString unitText = ""; - if (unitsWaiting) { - unitText = QString(" ✋ ") + QString::number(unitsWaiting) + " "; - } - economyLabel.setText(economyText); - scienceLabel.setText(scienceText); - unitLabel.setText(unitText); - update(); -} - -civstatus::~civstatus() {} diff --git a/client/civstatus.h b/client/civstatus.h deleted file mode 100644 index f191c561a1..0000000000 --- a/client/civstatus.h +++ /dev/null @@ -1,36 +0,0 @@ -/************************************************************************** - Copyright (c) 2021 Freeciv21 contributors. This file is - __ __ part of Freeciv21. Freeciv21 is free software: you can -/ \\..// \ redistribute it and/or modify it under the terms of the GNU - ( oo ) General Public License as published by the Free Software - \__/ Foundation, either version 3 of the License, or (at your - option) any later version. You should have received - a copy of the GNU General Public License along with Freeciv21. If not, - see https://www.gnu.org/licenses/. -**************************************************************************/ -#pragma once - -#include "widgetdecorations.h" - -class QHBoxLayout; - -class civstatus : public fcwidget { - Q_OBJECT - -public: - civstatus(QWidget *parent = nullptr); - ~civstatus() override; - void update_menu() override; -private slots: - void updateInfo(); - -protected: - void moveEvent(QMoveEvent *event) override; - -private: - move_widget *mw; - QHBoxLayout *layout; - QLabel economyLabel; - QLabel scienceLabel; - QLabel unitLabel; -}; diff --git a/client/fc_client.cpp b/client/fc_client.cpp index 402ba7c0f1..77b8262675 100644 --- a/client/fc_client.cpp +++ b/client/fc_client.cpp @@ -457,18 +457,6 @@ void fc_client::read_settings() } else { qt_settings.battlelog_y = 0.0; } - if (s.contains(QStringLiteral("civstatus_x"))) { - qt_settings.civstatus_x = - s.value(QStringLiteral("civstatus_x")).toFloat(); - } else { - qt_settings.civstatus_x = 0.0; - } - if (s.contains(QStringLiteral("civstatus_y"))) { - qt_settings.civstatus_y = - s.value(QStringLiteral("civstatus_y")).toFloat(); - } else { - qt_settings.civstatus_y = 0.0; - } qt_settings.player_repo_sort_col = -1; qt_settings.city_repo_sort_col = -1; @@ -524,8 +512,6 @@ void fc_client::write_settings() s.setValue(QStringLiteral("battlelog_scale"), qt_settings.battlelog_scale); s.setValue(QStringLiteral("battlelog_x"), qt_settings.battlelog_x); s.setValue(QStringLiteral("battlelog_y"), qt_settings.battlelog_y); - s.setValue(QStringLiteral("civstatus_x"), qt_settings.civstatus_x); - s.setValue(QStringLiteral("civstatus_y"), qt_settings.civstatus_y); s.setValue(QStringLiteral("new_turn_text"), qt_settings.show_new_turn_text); s.setValue(QStringLiteral("show_battle_log"), qt_settings.show_battle_log); diff --git a/client/fc_client.h b/client/fc_client.h index bbda9d5a10..f2fa4f0bcb 100644 --- a/client/fc_client.h +++ b/client/fc_client.h @@ -72,8 +72,6 @@ struct fc_settings { float battlelog_scale; float battlelog_x; float battlelog_y; - float civstatus_x; - float civstatus_y; }; /**************************************************************************** diff --git a/client/page_game.cpp b/client/page_game.cpp index fa6662c1f2..c874b865d0 100644 --- a/client/page_game.cpp +++ b/client/page_game.cpp @@ -25,7 +25,6 @@ #include "government.h" #include "repodlgs_g.h" // client -#include "civstatus.h" #include "client_main.h" #include "mapview_common.h" #include "text.h" @@ -154,10 +153,6 @@ pageGame::pageGame(QWidget *parent) top_bar_wdg->addWidget(sw_indicators); top_bar_wdg->addWidget(sw_message); - civ_status = new civstatus(mapview_wdg); - civ_status->setAttribute(Qt::WA_NoMousePropagation); - civ_status->show(); - city_overlay = new city_dialog(mapview_wdg); connect(mapview_wdg, &map_view::scale_changed, city_overlay, &city_dialog::refresh); @@ -533,9 +528,6 @@ bool fc_game_tab_widget::event(QEvent *event) qRound(king()->qt_settings.battlelog_x * mapview.width), qRound(king()->qt_settings.battlelog_y * mapview.height)); queen()->x_vote->move(width() / 2 - queen()->x_vote->width() / 2, 0); - queen()->civ_status->move( - qRound(king()->qt_settings.civstatus_x * mapview.width), - qRound(king()->qt_settings.civstatus_y * mapview.height)); queen()->updateSidebarTooltips(); queen()->minimap_panel->turn_done()->setEnabled( diff --git a/client/page_game.h b/client/page_game.h index ebef4f67b6..ef7b4d797d 100644 --- a/client/page_game.h +++ b/client/page_game.h @@ -19,7 +19,6 @@ class city_dialog; class fc_client; class map_view; -class civstatus; class minimap_panel; class hud_units; class indicators_widget; @@ -82,7 +81,6 @@ class pageGame : public QWidget { units_reports *units; top_bar_widget *sw_cunit; xvote *x_vote; - civstatus *civ_status; top_bar_widget *sw_diplo; indicators_widget *sw_indicators; top_bar_widget *sw_science;