File indexing completed on 2024-06-16 07:03:20

0001 /*
0002     SPDX-FileCopyrightText: 2003 Russell Steffen <rsteffen@bayarea.net>
0003     SPDX-FileCopyrightText: 2003 Stephan Zehetner <s.zehetner@nevox.org>
0004     SPDX-FileCopyrightText: 2006 Dmitry Suzdalev <dimsuz@gmail.com>
0005     SPDX-FileCopyrightText: 2006 Inge Wallin <inge@lysator.liu.se>
0006     SPDX-FileCopyrightText: 2006 Pierre Ducroquet <pinaraf@gmail.com>
0007     Copyright Sean D'Epagnier <geckosenator@gmail.com>
0008 
0009     SPDX-License-Identifier: GPL-2.0-or-later
0010 */
0011 
0012 #ifndef KONQUEST_MINIMAPVIEW_H
0013 #define KONQUEST_MINIMAPVIEW_H
0014 
0015 #include <QWidget>
0016 
0017 #include "map/map.h"
0018 
0019 
0020 class MiniMapView : public QWidget
0021 {
0022     Q_OBJECT
0023 
0024 public:
0025     explicit MiniMapView(QWidget *parent = nullptr);
0026     ~MiniMapView() override;
0027 
0028     void setMap(Map *newMap);
0029 
0030     /**
0031      * @note Always use hasSelection() first to make sure that the returned
0032      * selection is valid.
0033      */
0034 
0035     Coordinate selection() const { return m_selection; }
0036 
0037     bool hasSelection() const { return (m_selection.x() >= 0) && (m_selection.x() < m_map->columns()) && (m_selection.y() >= 0) && (m_selection.y() < m_map->rows()); }
0038 
0039 Q_SIGNALS:
0040     void sectorSelected(const Coordinate &coord);
0041 
0042 protected:
0043     void mousePressEvent(QMouseEvent *event) override;
0044     void paintEvent(QPaintEvent *event) override;
0045 
0046 private:
0047     void CalculateOffsets(float &, float &, float &);
0048 
0049     Map  *m_map;
0050     Coordinate m_selection;
0051 };
0052 
0053 #endif // KONQUEST_MINIMAPVIEW_H