|
@@ -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,12 +288,38 @@ 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) {
|
275
|
295
|
mousePressEvent(event);
|
276
|
296
|
}
|
277
|
297
|
|
|
298
|
+void CollisionMetatilesPixmapItem::updateCurHoveredMetatile(QPointF pos) {
|
|
299
|
+ int x = ((int)pos.x()) / 16;
|
|
300
|
+ int y = ((int)pos.y()) / 16;
|
|
301
|
+ int width = pixmap().width() / 16;
|
|
302
|
+ int height = pixmap().height() / 16;
|
|
303
|
+ if (x < 0 || x >= width || y < 0 || y >= height) {
|
|
304
|
+ map->clearHoveredCollisionTile();
|
|
305
|
+ } else {
|
|
306
|
+ int collision = y * width + x;
|
|
307
|
+ map->hoveredCollisionTileChanged(collision);
|
|
308
|
+ }
|
|
309
|
+}
|
|
310
|
+
|
|
311
|
+void ElevationMetatilesPixmapItem::updateCurHoveredMetatile(QPointF pos) {
|
|
312
|
+ int x = ((int)pos.x()) / 16;
|
|
313
|
+ int y = ((int)pos.y()) / 16;
|
|
314
|
+ int width = pixmap().width() / 16;
|
|
315
|
+ int height = pixmap().height() / 16;
|
|
316
|
+ if (x < 0 || x >= width || y < 0 || y >= height) {
|
|
317
|
+ map->clearHoveredElevationTile();
|
|
318
|
+ } else {
|
|
319
|
+ int elevation = y * width + x;
|
|
320
|
+ map->hoveredElevationTileChanged(elevation);
|
|
321
|
+ }
|
|
322
|
+}
|
278
|
323
|
|
279
|
324
|
void MapPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
|
280
|
325
|
if (map) {
|
|
@@ -368,10 +413,29 @@ void MapPixmapItem::redo() {
|
368
|
413
|
}
|
369
|
414
|
}
|
370
|
415
|
|
|
416
|
+void MapPixmapItem::updateCurHoveredTile(QPointF pos) {
|
|
417
|
+ int x = ((int)pos.x()) / 16;
|
|
418
|
+ int y = ((int)pos.y()) / 16;
|
|
419
|
+ int blockIndex = y * map->getWidth() + x;
|
|
420
|
+ if (x < 0 || x >= map->getWidth() || y < 0 || y >= map->getHeight()) {
|
|
421
|
+ map->clearHoveredTile();
|
|
422
|
+ } else {
|
|
423
|
+ int tile = map->blockdata->blocks->at(blockIndex).tile;
|
|
424
|
+ map->hoveredTileChanged(x, y, tile);
|
|
425
|
+ }
|
|
426
|
+}
|
|
427
|
+
|
|
428
|
+void MapPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
|
|
429
|
+ updateCurHoveredTile(event->pos());
|
|
430
|
+}
|
|
431
|
+void MapPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) {
|
|
432
|
+ map->clearHoveredTile();
|
|
433
|
+}
|
371
|
434
|
void MapPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
|
372
|
435
|
emit mouseEvent(event, this);
|
373
|
436
|
}
|
374
|
437
|
void MapPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
|
|
438
|
+ updateCurHoveredTile(event->pos());
|
375
|
439
|
emit mouseEvent(event, this);
|
376
|
440
|
}
|
377
|
441
|
void MapPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|