a whole lotta work!!
- refactoring - completely changed the tooling (adding elements) - better re-use for more stable editing - new elements - ui adjustments - LINT for stair-editing - many more changes
This commit is contained in:
59
mapview/2D/tools/ToolMoveMap.h
Normal file
59
mapview/2D/tools/ToolMoveMap.h
Normal file
@@ -0,0 +1,59 @@
|
||||
#ifndef TOOLMOVEMAP_H
|
||||
#define TOOLMOVEMAP_H
|
||||
|
||||
#include "Tool.h"
|
||||
#include "../MapView2D.h"
|
||||
|
||||
/**
|
||||
* this tool allows moving the 2D map
|
||||
*/
|
||||
class ToolMoveMap : public Tool {
|
||||
|
||||
private:
|
||||
|
||||
bool mouseIsDown = false;
|
||||
Point3 startOffset;
|
||||
int sx;
|
||||
int sy;
|
||||
|
||||
const std::string getName() const override {
|
||||
return "MapMove";
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
virtual bool mousePressEvent(MapView2D* m, QMouseEvent* e) override {
|
||||
if (e->button() == Qt::MouseButton::MidButton) {
|
||||
mouseIsDown = true;
|
||||
this->sx = e->x();
|
||||
this->sy = e->y();
|
||||
this->startOffset = m->getScaler().getOffset();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool mouseMoveEvent(MapView2D* m, QMouseEvent* e) override {
|
||||
if (!mouseIsDown) {return false;}
|
||||
m->getScaler().setOffset(startOffset);
|
||||
m->getScaler().addOffset(e->x()-sx, e->y()-sy);
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool mouseReleaseEvent(MapView2D* m, QMouseEvent* e) override {
|
||||
(void) m;
|
||||
(void) e;
|
||||
mouseIsDown = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// virtual void keyPressEvent(MapView2D* m, QKeyEvent* e) override {
|
||||
// (void) m;
|
||||
// (void) e;
|
||||
// // TODO: move on arrow keys?
|
||||
// }
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // TOOLMOVEMAP_H
|
||||
Reference in New Issue
Block a user