From 47ce60cbe1a1d77be8067b7b9103113499be17a5 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sun, 4 Mar 2018 16:07:52 -0800 Subject: [PATCH] Display grid lines on map editor --- editor.cpp | 14 ++++++++++++++ editor.h | 1 + 2 files changed, 15 insertions(+) diff --git a/editor.cpp b/editor.cpp index 6fb302ca..4311a316 100755 --- a/editor.cpp +++ b/editor.cpp @@ -156,6 +156,7 @@ void Editor::displayMap() { displayMapObjects(); displayMapConnections(); displayMapBorder(); + displayMapGrid(); } void Editor::displayMetatiles() { @@ -244,6 +245,19 @@ void Editor::displayMapBorder() { } } +void Editor::displayMapGrid() { + int pixelWidth = map->getWidth() * 16; + int pixelHeight = map->getHeight() * 16; + for (int i = 0; i <= map->getWidth(); i++) { + int x = i * 16; + QGraphicsLineItem *line = scene->addLine(x, 0, x, pixelHeight); + } + for (int j = 0; j <= map->getHeight(); j++) { + int y = j * 16; + QGraphicsLineItem *line = scene->addLine(0, y, pixelWidth, y); + } +} + void MetatilesPixmapItem::paintTileChanged(Map *map) { draw(); } diff --git a/editor.h b/editor.h index 76e1d65a..f81a00c3 100755 --- a/editor.h +++ b/editor.h @@ -37,6 +37,7 @@ public: void displayMapObjects(); void displayMapConnections(); void displayMapBorder(); + void displayMapGrid(); void setEditingMap(); void setEditingCollision();