14 #include <QMouseEvent>
29 const auto always_visible_margin = 15;
37 setAttribute(Qt::WA_OpaquePaintEvent,
true);
38 setCursor(Qt::CrossCursor);
63 void overview_pos_nowrap(
const struct tileset *t,
int *ovr_x,
int *ovr_y,
105 painter->setPen(QColor(Qt::white));
112 for (
int i = 0; i < 4; i++) {
113 lines.append(QLineF(x[i] * w_ratio, y[i] * h_ratio,
114 x[(i + 1) % 4] * w_ratio, y[(i + 1) % 4] * h_ratio));
124 if (wrap_src_x != x[i] || wrap_src_y != y[i]) {
125 int projected_dst_x = x[(i + 1) % 4] + wrap_src_x - x[i];
126 int projected_dst_y = y[(i + 1) % 4] + wrap_src_y - y[i];
127 lines.append(QLineF(wrap_src_x * w_ratio, wrap_src_y * h_ratio,
128 projected_dst_x * w_ratio,
129 projected_dst_y * h_ratio));
140 if (wrap_dst_x != x[(i + 1) % 4] || wrap_dst_y != y[(i + 1) % 4]) {
141 int projected_src_x = x[i] + wrap_dst_x - x[(i + 1) % 4];
142 int projected_src_y = y[i] + wrap_dst_y - y[(i + 1) % 4];
143 lines.append(QLineF(projected_src_x * w_ratio,
144 projected_src_y * h_ratio, wrap_dst_x * w_ratio,
145 wrap_dst_y * h_ratio));
148 painter->drawLines(
lines);
170 return size.height() * width /
size.width() / 2;
172 return size.height() * width /
size.width();
190 painter->drawPixmap(1, 1, width() - 1, height() - 1,
193 painter->setPen(QColor(palette().color(QPalette::HighlightedText)));
194 painter->drawRect(0, 0, width() - 1, height() - 1);
203 auto size =
event->size();
205 if (x() +
size.width() < always_visible_margin) {
206 size.setWidth(always_visible_margin - x());
209 if (y() +
size.height() < always_visible_margin) {
210 size.setHeight(always_visible_margin - y());
215 &&
size.height() > 0) {
232 if (
event->button() == Qt::RightButton) {
233 auto fx =
event->pos().x();
234 auto fy =
event->pos().y();
236 /
static_cast<double>(width()));
238 /
static_cast<double>(height()));
250 event->setAccepted(
true);
void center_on_tile(tile *tile, bool animate=true)
Centers the view on a tile.
auto minimap()
Retrieves the minimap widget.
void paint(QPainter *painter, QPaintEvent *event)
Redraws visible map using stored pixmap.
void paintEvent(QPaintEvent *event) override
Paint event for minimap.
void update_menu() override
Called by close widget, cause widget has been hidden.
minimap_view(QWidget *parent)
Constructor for minimap.
int heightForWidth(int width) const override
Reimplements QWidget::heightForWidth.
QSize sizeHint() const override
Reimplements QWidget::sizeHint.
void mousePressEvent(QMouseEvent *event) override
Mouse Handler for minimap_view Left button - moves minimap Right button - recenters on some point For...
void resizeEvent(QResizeEvent *event) override
Called when minimap has been resized.
void draw_viewport(QPainter *painter)
Draws viewport on minimap.
void update_image()
Updates minimap's pixmap.
::minimap_panel * minimap_panel
enum client_states client_state()
Return current client state.
class fc_client * king()
Return fc_client instance.
#define fc_assert_ret(condition)
struct tile * map_pos_to_tile(const struct civ_map *nmap, int map_x, int map_y)
Return the tile for the given cartesian (map) position.
#define current_topo_has_flag(flag)
void update_minimap()
Return a canvas that is the overview window.
client_options * gui_options
void overview_to_map_pos(int *map_x, int *map_y, int overview_x, int overview_y)
Finds the map coordinates for a given overview (canvas) position.
void gui_to_natural_pos(const struct tileset *t, double *ntl_x, double *ntl_y, int gui_x, int gui_y)
Translate from gui to natural coordinate systems.
pageGame * queen()
Return game instandce.
#define FC_WRAP(value, range)
bool tileset_is_isometric(const struct tileset *t)
Return whether the current tileset is isometric.