Align border blocks
This commit is contained in:
parent
c28730e834
commit
e4a41cf201
3 changed files with 20 additions and 16 deletions
|
@ -17,9 +17,9 @@
|
|||
#define DEFAULT_BORDER_WIDTH 2
|
||||
#define DEFAULT_BORDER_HEIGHT 2
|
||||
|
||||
// Number of metatiles to draw out from edge of map. Could allow modification of this in the future.
|
||||
// Number of border blocks to draw out from edge of map. Could allow modification of this in the future.
|
||||
// porymap will reflect changes to it, but the value is hard-coded in the projects at the moment
|
||||
#define BORDER_DISTANCE 6
|
||||
#define NUM_BORDER_BLOCKS 3
|
||||
|
||||
class Map : public QObject
|
||||
{
|
||||
|
|
|
@ -263,23 +263,23 @@ QPixmap Map::renderConnection(MapConnection connection, MapLayout * fromLayout)
|
|||
int x, y, w, h;
|
||||
if (connection.direction == "up") {
|
||||
x = 0;
|
||||
y = getHeight() - BORDER_DISTANCE;
|
||||
y = getHeight() - (getBorderHeight() * NUM_BORDER_BLOCKS);
|
||||
w = getWidth();
|
||||
h = BORDER_DISTANCE;
|
||||
h = getBorderHeight() * NUM_BORDER_BLOCKS;
|
||||
} else if (connection.direction == "down") {
|
||||
x = 0;
|
||||
y = 0;
|
||||
w = getWidth();
|
||||
h = BORDER_DISTANCE;
|
||||
h = getBorderHeight() * NUM_BORDER_BLOCKS;
|
||||
} else if (connection.direction == "left") {
|
||||
x = getWidth() - BORDER_DISTANCE;
|
||||
x = getWidth() - (getBorderWidth() * NUM_BORDER_BLOCKS);
|
||||
y = 0;
|
||||
w = BORDER_DISTANCE;
|
||||
w = getBorderWidth() * NUM_BORDER_BLOCKS;
|
||||
h = getHeight();
|
||||
} else if (connection.direction == "right") {
|
||||
x = 0;
|
||||
y = 0;
|
||||
w = BORDER_DISTANCE;
|
||||
w = getBorderWidth() * NUM_BORDER_BLOCKS;
|
||||
h = getHeight();
|
||||
} else {
|
||||
// this should not happen
|
||||
|
|
|
@ -1118,6 +1118,8 @@ void Editor::displayMetatileSelector() {
|
|||
}
|
||||
|
||||
void Editor::displayMapMetatiles() {
|
||||
int borderHorzDist = map->getBorderWidth() * NUM_BORDER_BLOCKS * 16;
|
||||
int borderVertDist = map->getBorderHeight() * NUM_BORDER_BLOCKS * 16;
|
||||
map_item = new MapPixmapItem(map, this->metatile_selector_item, this->settings);
|
||||
connect(map_item, SIGNAL(mouseEvent(QGraphicsSceneMouseEvent*,MapPixmapItem*)),
|
||||
this, SLOT(mouseEvent_map(QGraphicsSceneMouseEvent*,MapPixmapItem*)));
|
||||
|
@ -1133,13 +1135,11 @@ void Editor::displayMapMetatiles() {
|
|||
map_item->draw(true);
|
||||
scene->addItem(map_item);
|
||||
|
||||
int tw = 16;
|
||||
int th = 16;
|
||||
scene->setSceneRect(
|
||||
-BORDER_DISTANCE * tw,
|
||||
-BORDER_DISTANCE * th,
|
||||
map_item->pixmap().width() + (BORDER_DISTANCE * 2) * tw,
|
||||
map_item->pixmap().height() + (BORDER_DISTANCE * 2) * th
|
||||
-borderHorzDist,
|
||||
-borderVertDist,
|
||||
map_item->pixmap().width() + borderHorzDist * 2,
|
||||
map_item->pixmap().height() + borderVertDist * 2
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1334,9 +1334,13 @@ void Editor::displayMapBorder() {
|
|||
}
|
||||
borderItems.clear();
|
||||
|
||||
int borderWidth = map->getBorderWidth();
|
||||
int borderHeight = map->getBorderHeight();
|
||||
int borderHorzDist = borderWidth * NUM_BORDER_BLOCKS;
|
||||
int borderVertDist = borderHeight * NUM_BORDER_BLOCKS;
|
||||
QPixmap pixmap = map->renderBorder();
|
||||
for (int y = -BORDER_DISTANCE; y < map->getHeight() + BORDER_DISTANCE; y += map->getBorderHeight())
|
||||
for (int x = -BORDER_DISTANCE; x < map->getWidth() + BORDER_DISTANCE; x += map->getBorderWidth()) {
|
||||
for (int y = -borderVertDist; y < map->getHeight() + borderVertDist; y += borderHeight)
|
||||
for (int x = -borderHorzDist; x < map->getWidth() + borderHorzDist; x += borderWidth) {
|
||||
QGraphicsPixmapItem *item = new QGraphicsPixmapItem(pixmap);
|
||||
item->setX(x * 16);
|
||||
item->setY(y * 16);
|
||||
|
|
Loading…
Reference in a new issue