| 1 | // This file is part of Dust Racing 2D. |
| 2 | // Copyright (C) 2015 Jussi Lind <[email protected]> |
| 3 | // |
| 4 | // Dust Racing 2D is free software: you can redistribute it and/or modify |
| 5 | // it under the terms of the GNU General Public License as published by |
| 6 | // the Free Software Foundation, either version 3 of the License, or |
| 7 | // (at your option) any later version. |
| 8 | // Dust Racing 2D is distributed in the hope that it will be useful, |
| 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | // GNU General Public License for more details. |
| 12 | // |
| 13 | // You should have received a copy of the GNU General Public License |
| 14 | // along with Dust Racing 2D. If not, see <http://www.gnu.org/licenses/>. |
| 15 | |
| 16 | #ifndef EDITORVIEW_HPP |
| 17 | #define EDITORVIEW_HPP |
| 18 | |
| 19 | #include "../common/tracktilebase.hpp" |
| 20 | #include <QGraphicsView> |
| 21 | #include <QMenu> |
| 22 | |
| 23 | class Mediator; |
| 24 | class QAction; |
| 25 | class QMouseEvent; |
| 26 | class QPaintEvent; |
| 27 | class Object; |
| 28 | class ObjectModelLoaderoader; |
| 29 | class TargetNode; |
| 30 | class TrackTile; |
| 31 | |
| 32 | class EditorView : public QGraphicsView |
| 33 | { |
| 34 | Q_OBJECT |
| 35 | |
| 36 | public: |
| 37 | explicit EditorView(Mediator & mediator); |
| 38 | |
| 39 | void updateSceneRect(); |
| 40 | |
| 41 | protected: |
| 42 | void mouseMoveEvent(QMouseEvent * event) override; |
| 43 | |
| 44 | void mousePressEvent(QMouseEvent * event) override; |
| 45 | |
| 46 | void mouseReleaseEvent(QMouseEvent * event) override; |
| 47 | |
| 48 | void keyPressEvent(QKeyEvent * event) override; |
| 49 | |
| 50 | void wheelEvent(QWheelEvent * event) override; |
| 51 | |
| 52 | private: |
| 53 | void addCurrentToolBarObjectToScene(); |
| 54 | |
| 55 | void changeTileType(TrackTile & tile, QAction * action); |
| 56 | |
| 57 | void createTileContextMenuActions(); |
| 58 | |
| 59 | void createObjectContextMenuActions(); |
| 60 | |
| 61 | void createTargetNodeContextMenuActions(); |
| 62 | |
| 63 | void eraseObjectAtCurrentClickedPos(); |
| 64 | |
| 65 | void handleMousePressEventOnTile(QMouseEvent & event, TrackTile & tile); |
| 66 | |
| 67 | void handleLeftButtonClickOnTile(TrackTile & tile); |
| 68 | |
| 69 | void handleRightButtonClickOnTile(TrackTile & tile); |
| 70 | |
| 71 | void handleMousePressEventOnObject(QMouseEvent & event, Object & object); |
| 72 | |
| 73 | void handleLeftButtonClickOnObject(Object & object); |
| 74 | |
| 75 | void handleRightButtonClickOnObject(Object & object); |
| 76 | |
| 77 | void handleMousePressEventOnTargetNode(QMouseEvent & event, TargetNode & tnode); |
| 78 | |
| 79 | void handleLeftButtonClickOnTargetNode(TargetNode & tnode); |
| 80 | |
| 81 | void handleRightButtonClickOnTargetNode(TargetNode & tnode); |
| 82 | |
| 83 | void handleTileDragRelease(QMouseEvent * event); |
| 84 | |
| 85 | void handleObjectDragRelease(QMouseEvent * event); |
| 86 | |
| 87 | void handleTargetNodeDragRelease(QMouseEvent * event); |
| 88 | |
| 89 | void openObjectContextMenu(); |
| 90 | |
| 91 | void openTargetNodeContextMenu(); |
| 92 | |
| 93 | void openTileContextMenu(TrackTile & tile); |
| 94 | |
| 95 | void setComputerHint(TrackTileBase::ComputerHint hint); |
| 96 | |
| 97 | static void setTileType(TrackTile & tile, QAction * action); |
| 98 | |
| 99 | QMenu m_tileContextMenu; |
| 100 | |
| 101 | QMenu m_objectContextMenu; |
| 102 | |
| 103 | QMenu m_targetNodeContextMenu; |
| 104 | |
| 105 | QPoint m_clickedPos; |
| 106 | |
| 107 | QPointF m_clickedScenePos; |
| 108 | |
| 109 | QAction * m_clearComputerHint = nullptr; |
| 110 | |
| 111 | QAction * m_setComputerHintBrakeHard = nullptr; |
| 112 | |
| 113 | QAction * m_setComputerHintBrake = nullptr; |
| 114 | |
| 115 | QAction * m_deleteRow = nullptr; |
| 116 | |
| 117 | QAction * m_deleteCol = nullptr; |
| 118 | |
| 119 | QAction * m_excludeFromMinimap = nullptr; |
| 120 | |
| 121 | QAction * m_forceStationaryAction = nullptr; |
| 122 | |
| 123 | Mediator & m_mediator; |
| 124 | }; |
| 125 | |
| 126 | #endif // EDITORVIEW_HPP |