|
mkRPG
|
00001 #ifndef MAPVIEWER_H 00002 #define MAPVIEWER_H 00003 00004 #include <Game/game.h> 00005 #include <Game/mappainter.h> 00006 #include <QtWidgets> 00007 #include <cmath> 00008 00009 00010 00026 class MapViewer : public QWidget 00027 { 00028 enum MouseState{ 00029 Rest, 00030 RClick, 00031 LClick, 00032 MClick, 00033 Moving, 00034 Selection 00035 }; 00036 Q_OBJECT 00037 public: 00053 enum SelectionMode{ 00054 PencilSelection, 00055 RectangleSelection, 00056 RegionSelection 00057 }; 00058 00059 00060 00061 explicit MapViewer(QWidget *parent = 0); 00062 void setMap(Map* m); 00063 //void adjustView(); 00064 void updateMap(); 00065 00066 inline MapPainter& mapPainter() {return mp;} 00067 00068 00069 void setSelectionMode(SelectionMode m); 00070 inline SelectionMode selectionMode() const{return sm;} 00071 00072 signals: 00073 void viewSizeChanged(QSize); 00074 void selectionChanged(); 00075 00076 public slots: 00077 void updateRequest(); 00078 00079 private slots: 00080 void mousePosChecking(); 00081 void selectionOut(); 00082 00083 private: 00084 // NOTE currently, Update IS NOT private ! 00085 00086 void wheelEvent(QWheelEvent* we); 00087 void mousePressEvent(QMouseEvent* me); 00088 void mouseMoveEvent(QMouseEvent* me); 00089 void mouseReleaseEvent(QMouseEvent*me); 00090 bool updateMousePos(PtCoords p); 00091 void mouseOutEvent(); 00092 void paintEvent(QPaintEvent* pe); 00093 void resizeEvent(QResizeEvent* re); 00094 void checkMousePos(); 00095 00096 00097 void updateSelection(ClCoords pos); 00098 void selectCellBetween(ClCoords p0, ClCoords p1, ClCoords p2); 00099 00100 MapPainter mp; 00101 00102 Map* map; 00103 00104 00105 SelectionMode sm; 00106 MouseState ms; 00107 int wi,he; 00108 ClCoords cellClicked, cellMove; 00109 QTimer *ti, *tiUp, *tiSel; 00110 QPoint clickPos, selectPos; 00111 QPointF center; 00112 bool mouseIn; 00113 00114 00115 }; 00116 00117 #endif // MAPVIEWER_H
1.7.6.1