Skip to content

Commit

Permalink
Remove minimap size settings
Browse files Browse the repository at this point in the history
The size of the minimap has been fixed for some time now. Old settings could
still interfere with the location of the chat widget, so remove any code
touching those.

See longturn#1265.
  • Loading branch information
lmoureaux committed Aug 14, 2022
1 parent becec8b commit 8cb5f00
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 61 deletions.
32 changes: 0 additions & 32 deletions client/fc_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,28 +423,6 @@ void fc_client::read_settings()
} else {
qt_settings.unit_info_pos_fy = 0.88;
}
if (s.contains(QStringLiteral("minimap_x"))) {
qt_settings.minimap_x = s.value(QStringLiteral("minimap_x")).toFloat();
} else {
qt_settings.minimap_x = 0.84;
}
if (s.contains(QStringLiteral("minimap_y"))) {
qt_settings.minimap_y = s.value(QStringLiteral("minimap_y")).toFloat();
} else {
qt_settings.minimap_y = 0.79;
}
if (s.contains(QStringLiteral("minimap_width"))) {
qt_settings.minimap_width =
s.value(QStringLiteral("minimap_width")).toFloat();
} else {
qt_settings.minimap_width = 0.15;
}
if (s.contains(QStringLiteral("minimap_height"))) {
qt_settings.minimap_height =
s.value(QStringLiteral("minimap_height")).toFloat();
} else {
qt_settings.minimap_height = 0.2;
}
if (s.contains(QStringLiteral("battlelog_scale"))) {
qt_settings.battlelog_scale =
s.value(QStringLiteral("battlelog_scale")).toFloat();
Expand Down Expand Up @@ -520,12 +498,6 @@ void fc_client::read_settings()
if (qt_settings.battlelog_scale > 5.0) {
qt_settings.battlelog_y = 5.0;
}
if (qt_settings.minimap_x < 0 || qt_settings.minimap_x > 1) {
qt_settings.chat_fx_pos = 0.84;
}
if (qt_settings.minimap_y < 0 || qt_settings.minimap_y > 1) {
qt_settings.chat_fx_pos = 0.79;
}
}

/**
Expand All @@ -544,10 +516,6 @@ void fc_client::write_settings()
s.setValue(QStringLiteral("help_splitter1"), qt_settings.help_splitter1);
s.setValue(QStringLiteral("unit_fx"), qt_settings.unit_info_pos_fx);
s.setValue(QStringLiteral("unit_fy"), qt_settings.unit_info_pos_fy);
s.setValue(QStringLiteral("minimap_x"), qt_settings.minimap_x);
s.setValue(QStringLiteral("minimap_y"), qt_settings.minimap_y);
s.setValue(QStringLiteral("minimap_width"), qt_settings.minimap_width);
s.setValue(QStringLiteral("minimap_height"), qt_settings.minimap_height);
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);
Expand Down
4 changes: 0 additions & 4 deletions client/fc_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ struct fc_settings {
QByteArray help_splitter1;
float unit_info_pos_fx;
float unit_info_pos_fy;
float minimap_x;
float minimap_y;
float minimap_width;
float minimap_height;
float battlelog_scale;
float battlelog_x;
float battlelog_y;
Expand Down
28 changes: 3 additions & 25 deletions client/minimap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
#include "page_game.h"
#include "qtg_cxxside.h"

namespace {
const auto always_visible_margin = 15;
}

/**
Constructor for minimap
*/
Expand All @@ -40,8 +36,6 @@ minimap_view::minimap_view(QWidget *parent) : fcwidget()
setAttribute(Qt::WA_OpaquePaintEvent, true);
w_ratio = 0.0;
h_ratio = 0.0;
// Dark magic: This call is required for the widget to work.
resize(0, 0);
background = QBrush(QColor(0, 0, 0));
setCursor(Qt::CrossCursor);
pix = new QPixmap;
Expand Down Expand Up @@ -226,25 +220,9 @@ void minimap_view::paint(QPainter *painter, QPaintEvent *event)
*/
void minimap_view::resizeEvent(QResizeEvent *event)
{
auto size = event->size();

if (x() + size.width() < always_visible_margin) {
size.setWidth(always_visible_margin - x());
resize(size);
}
if (y() + size.height() < always_visible_margin) {
size.setHeight(always_visible_margin - y());
resize(size);
}

if (C_S_RUNNING <= client_state() && size.width() > 0
&& size.height() > 0) {
w_ratio = static_cast<float>(width()) / gui_options.overview.width;
h_ratio = static_cast<float>(height()) / gui_options.overview.height;
king()->qt_settings.minimap_width =
static_cast<float>(size.width()) / mapview.width;
king()->qt_settings.minimap_height =
static_cast<float>(size.height()) / mapview.height;
if (C_S_RUNNING <= client_state() && !size().isEmpty()) {
w_ratio = static_cast<double>(width()) / gui_options.overview.width;
h_ratio = static_cast<double>(height()) / gui_options.overview.height;
}
update_image();
}
Expand Down

0 comments on commit 8cb5f00

Please sign in to comment.