|
@@ -257,6 +257,25 @@ void MetatilesPixmapItem::pick(uint tile) {
|
257
|
257
|
emit map->paintTileChanged(map);
|
258
|
258
|
}
|
259
|
259
|
|
|
260
|
+void MetatilesPixmapItem::updateCurHoveredMetatile(QPointF pos) {
|
|
261
|
+ int x = ((int)pos.x()) / 16;
|
|
262
|
+ int y = ((int)pos.y()) / 16;
|
|
263
|
+ int width = pixmap().width() / 16;
|
|
264
|
+ int height = pixmap().height() / 16;
|
|
265
|
+ if (x < 0 || x >= width || y < 0 || y >= height) {
|
|
266
|
+ map->clearHoveredMetatile();
|
|
267
|
+ } else {
|
|
268
|
+ int block = y * width + x;
|
|
269
|
+ map->hoveredMetatileChanged(block);
|
|
270
|
+ }
|
|
271
|
+}
|
|
272
|
+
|
|
273
|
+void MetatilesPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
|
|
274
|
+ updateCurHoveredMetatile(event->pos());
|
|
275
|
+}
|
|
276
|
+void MetatilesPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) {
|
|
277
|
+ map->clearHoveredMetatile();
|
|
278
|
+}
|
260
|
279
|
void MetatilesPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
|
261
|
280
|
QPointF pos = event->pos();
|
262
|
281
|
int x = ((int)pos.x()) / 16;
|
|
@@ -269,6 +288,7 @@ void MetatilesPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
|
269
|
288
|
}
|
270
|
289
|
}
|
271
|
290
|
void MetatilesPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
|
|
291
|
+ updateCurHoveredMetatile(event->pos());
|
272
|
292
|
mousePressEvent(event);
|
273
|
293
|
}
|
274
|
294
|
void MetatilesPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|