瀏覽代碼

Display grid lines on map editor

Marcus Huderle 6 年之前
父節點
當前提交
47ce60cbe1
共有 2 個檔案被更改,包括 15 行新增0 行删除
  1. 14
    0
      editor.cpp
  2. 1
    0
      editor.h

+ 14
- 0
editor.cpp 查看文件

@@ -156,6 +156,7 @@ void Editor::displayMap() {
156 156
     displayMapObjects();
157 157
     displayMapConnections();
158 158
     displayMapBorder();
159
+    displayMapGrid();
159 160
 }
160 161
 
161 162
 void Editor::displayMetatiles() {
@@ -244,6 +245,19 @@ void Editor::displayMapBorder() {
244 245
     }
245 246
 }
246 247
 
248
+void Editor::displayMapGrid() {
249
+    int pixelWidth = map->getWidth() * 16;
250
+    int pixelHeight = map->getHeight() * 16;
251
+    for (int i = 0; i <= map->getWidth(); i++) {
252
+        int x = i * 16;
253
+        QGraphicsLineItem *line = scene->addLine(x, 0, x, pixelHeight);
254
+    }
255
+    for (int j = 0; j <= map->getHeight(); j++) {
256
+        int y = j * 16;
257
+        QGraphicsLineItem *line = scene->addLine(0, y, pixelWidth, y);
258
+    }
259
+}
260
+
247 261
 void MetatilesPixmapItem::paintTileChanged(Map *map) {
248 262
     draw();
249 263
 }

+ 1
- 0
editor.h 查看文件

@@ -37,6 +37,7 @@ public:
37 37
     void displayMapObjects();
38 38
     void displayMapConnections();
39 39
     void displayMapBorder();
40
+    void displayMapGrid();
40 41
 
41 42
     void setEditingMap();
42 43
     void setEditingCollision();