|
@@ -780,7 +780,7 @@ void MetatilesPixmapItem::updateSelection(QPointF pos, Qt::MouseButton button) {
|
780
|
780
|
if ((x >= 0 && x < width) && (y >=0 && y < height)) {
|
781
|
781
|
int baseTileX = x < map->paint_metatile_initial_x ? x : map->paint_metatile_initial_x;
|
782
|
782
|
int baseTileY = y < map->paint_metatile_initial_y ? y : map->paint_metatile_initial_y;
|
783
|
|
- map->paint_tile = baseTileY * 8 + baseTileX;
|
|
783
|
+ map->paint_tile_index = baseTileY * 8 + baseTileX;
|
784
|
784
|
map->paint_tile_width = abs(map->paint_metatile_initial_x - x) + 1;
|
785
|
785
|
map->paint_tile_height = abs(map->paint_metatile_initial_y - y) + 1;
|
786
|
786
|
map->smart_paths_enabled = button == Qt::RightButton
|
|
@@ -790,6 +790,24 @@ void MetatilesPixmapItem::updateSelection(QPointF pos, Qt::MouseButton button) {
|
790
|
790
|
}
|
791
|
791
|
}
|
792
|
792
|
|
|
793
|
+void MovementPermissionsPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent* event) {
|
|
794
|
+ QPointF pos = event->pos();
|
|
795
|
+ int x = ((int)pos.x()) / 16;
|
|
796
|
+ int y = ((int)pos.y()) / 16;
|
|
797
|
+ int width = pixmap().width() / 16;
|
|
798
|
+ int height = pixmap().height() / 16;
|
|
799
|
+ if ((x >= 0 && x < width) && (y >=0 && y < height)) {
|
|
800
|
+ pick(y * width + x);
|
|
801
|
+ }
|
|
802
|
+}
|
|
803
|
+void MovementPermissionsPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event) {
|
|
804
|
+ updateCurHoveredMetatile(event->pos());
|
|
805
|
+ mousePressEvent(event);
|
|
806
|
+}
|
|
807
|
+void MovementPermissionsPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) {
|
|
808
|
+ mousePressEvent(event);
|
|
809
|
+}
|
|
810
|
+
|
793
|
811
|
void CollisionMetatilesPixmapItem::updateCurHoveredMetatile(QPointF pos) {
|
794
|
812
|
int x = ((int)pos.x()) / 16;
|
795
|
813
|
int y = ((int)pos.y()) / 16;
|
|
@@ -907,7 +925,7 @@ void MapPixmapItem::paintNormal(int x, int y) {
|
907
|
925
|
int actualY = j + y;
|
908
|
926
|
Block *block = map->getBlock(actualX, actualY);
|
909
|
927
|
if (block) {
|
910
|
|
- block->tile = map->paint_tile + i + (j * 8);
|
|
928
|
+ block->tile = map->getSelectedBlockIndex(map->paint_tile_index + i + (j * 8));
|
911
|
929
|
map->_setBlock(actualX, actualY, *block);
|
912
|
930
|
}
|
913
|
931
|
}
|
|
@@ -935,32 +953,38 @@ QList<int> MapPixmapItem::smartPathTable = QList<int>({
|
935
|
953
|
8 + 1, // 1111
|
936
|
954
|
});
|
937
|
955
|
|
938
|
|
-#define IS_SMART_PATH_TILE(block) ((block->tile >= map->paint_tile && block->tile < map->paint_tile + 3) \
|
939
|
|
- || (block->tile >= map->paint_tile + 8 && block->tile < map->paint_tile + 11) \
|
940
|
|
- || (block->tile >= map->paint_tile + 16 && block->tile < map->paint_tile + 19))
|
|
956
|
+#define IS_SMART_PATH_TILE(block) ((map->getDisplayedBlockIndex(block->tile) >= map->paint_tile_index && map->getDisplayedBlockIndex(block->tile) < map->paint_tile_index + 3) \
|
|
957
|
+ || (map->getDisplayedBlockIndex(block->tile) >= map->paint_tile_index + 8 && map->getDisplayedBlockIndex(block->tile) < map->paint_tile_index + 11) \
|
|
958
|
+ || (map->getDisplayedBlockIndex(block->tile) >= map->paint_tile_index + 16 && map->getDisplayedBlockIndex(block->tile) < map->paint_tile_index + 19))
|
941
|
959
|
|
942
|
960
|
void MapPixmapItem::paintSmartPath(int x, int y) {
|
943
|
961
|
// Smart path should never be enabled without a 3x3 block selection.
|
944
|
962
|
if (map->paint_tile_width != 3 || map->paint_tile_height != 3) return;
|
945
|
963
|
|
946
|
964
|
// Shift to the middle tile of the smart path selection.
|
947
|
|
- int openTile = map->paint_tile + 8 + 1;
|
|
965
|
+ int openTile = map->paint_tile_index + 8 + 1;
|
948
|
966
|
|
949
|
967
|
// Fill the region with the open tile.
|
950
|
|
- for (int i = -1; i <= 1 && i + x < map->getWidth() && i + x >= 0; i++)
|
951
|
|
- for (int j = -1; j <= 1 && j + y < map->getHeight() && j + y >= 0; j++) {
|
|
968
|
+ for (int i = -1; i <= 1; i++)
|
|
969
|
+ for (int j = -1; j <= 1; j++) {
|
|
970
|
+ // Check if in map bounds.
|
|
971
|
+ if (!(i + x < map->getWidth() && i + x >= 0 && j + y < map->getHeight() && j + y >= 0))
|
|
972
|
+ continue;
|
952
|
973
|
int actualX = i + x;
|
953
|
974
|
int actualY = j + y;
|
954
|
975
|
Block *block = map->getBlock(actualX, actualY);
|
955
|
976
|
if (block) {
|
956
|
|
- block->tile = openTile;
|
|
977
|
+ block->tile = map->getSelectedBlockIndex(openTile);
|
957
|
978
|
map->_setBlock(actualX, actualY, *block);
|
958
|
979
|
}
|
959
|
980
|
}
|
960
|
981
|
|
961
|
982
|
// Go back and resolve the edge tiles
|
962
|
|
- for (int i = -2; i <= 2 && i + x < map->getWidth() && i + x >= 0; i++)
|
963
|
|
- for (int j = -2; j <= 2 && j + y < map->getHeight() && j + y >= 0; j++) {
|
|
983
|
+ for (int i = -2; i <= 2; i++)
|
|
984
|
+ for (int j = -2; j <= 2; j++) {
|
|
985
|
+ // Check if in map bounds.
|
|
986
|
+ if (!(i + x < map->getWidth() && i + x >= 0 && j + y < map->getHeight() && j + y >= 0))
|
|
987
|
+ continue;
|
964
|
988
|
// Ignore the corners, which can't possible be affected by the smart path.
|
965
|
989
|
if ((i == -2 && j == -2) || (i == 2 && j == -2) ||
|
966
|
990
|
(i == -2 && j == 2) || (i == 2 && j == 2))
|
|
@@ -990,7 +1014,7 @@ void MapPixmapItem::paintSmartPath(int x, int y) {
|
990
|
1014
|
if (left && IS_SMART_PATH_TILE(left))
|
991
|
1015
|
id += 8;
|
992
|
1016
|
|
993
|
|
- block->tile = map->paint_tile + smartPathTable[id];;
|
|
1017
|
+ block->tile = map->getSelectedBlockIndex(map->paint_tile_index + smartPathTable[id]);
|
994
|
1018
|
map->_setBlock(actualX, actualY, *block);
|
995
|
1019
|
}
|
996
|
1020
|
}
|
|
@@ -1000,7 +1024,7 @@ void MapPixmapItem::floodFill(QGraphicsSceneMouseEvent *event) {
|
1000
|
1024
|
QPointF pos = event->pos();
|
1001
|
1025
|
int x = (int)(pos.x()) / 16;
|
1002
|
1026
|
int y = (int)(pos.y()) / 16;
|
1003
|
|
- map->floodFill(x, y, map->paint_tile);
|
|
1027
|
+ map->floodFill(x, y, map->getSelectedBlockIndex(map->paint_tile_index));
|
1004
|
1028
|
draw();
|
1005
|
1029
|
}
|
1006
|
1030
|
}
|
|
@@ -1011,7 +1035,7 @@ void MapPixmapItem::pick(QGraphicsSceneMouseEvent *event) {
|
1011
|
1035
|
int y = (int)(pos.y()) / 16;
|
1012
|
1036
|
Block *block = map->getBlock(x, y);
|
1013
|
1037
|
if (block) {
|
1014
|
|
- map->paint_tile = block->tile;
|
|
1038
|
+ map->paint_tile_index = map->getDisplayedBlockIndex(block->tile);
|
1015
|
1039
|
map->paint_tile_width = 1;
|
1016
|
1040
|
map->paint_tile_height = 1;
|
1017
|
1041
|
emit map->paintTileChanged(map);
|