diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-03-18 00:51:41 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-03-18 00:51:41 -0400 |
commit | f83f5af19fc828806df8be7807ca418cfd0306da (patch) | |
tree | 5d0495a0a605eb38ad72830ca4b7cede9004909f | |
parent | 2e66b27372b3547ea98ec914974c4fcdedd08053 (diff) | |
download | therapy-f83f5af19fc828806df8be7807ca418cfd0306da.tar.gz therapy-f83f5af19fc828806df8be7807ca418cfd0306da.tar.bz2 therapy-f83f5af19fc828806df8be7807ca418cfd0306da.zip |
Added ghosts of adjacent warp maps to map editor widget
-rw-r--r-- | tools/mapedit/src/consts.h | 4 | ||||
-rw-r--r-- | tools/mapedit/src/widget.cpp | 85 | ||||
-rw-r--r-- | tools/mapedit/src/widget.h | 1 |
3 files changed, 72 insertions, 18 deletions
diff --git a/tools/mapedit/src/consts.h b/tools/mapedit/src/consts.h index 5e99136..dda4151 100644 --- a/tools/mapedit/src/consts.h +++ b/tools/mapedit/src/consts.h | |||
@@ -9,5 +9,9 @@ const int MAP_WIDTH = GAME_WIDTH/TILE_WIDTH; | |||
9 | const int MAP_HEIGHT = GAME_HEIGHT/TILE_HEIGHT - 1; | 9 | const int MAP_HEIGHT = GAME_HEIGHT/TILE_HEIGHT - 1; |
10 | const int PLAYER_WIDTH[5] = {10, 0, 0, 0, 0}; | 10 | const int PLAYER_WIDTH[5] = {10, 0, 0, 0, 0}; |
11 | const int PLAYER_HEIGHT[5] = {12, 0, 0, 0, 0}; | 11 | const int PLAYER_HEIGHT[5] = {12, 0, 0, 0, 0}; |
12 | const int EDITOR_SPACING_X = MAP_WIDTH * TILE_WIDTH / 2; | ||
13 | const int EDITOR_SPACING_Y = MAP_HEIGHT * TILE_HEIGHT / 2; | ||
14 | const int EDITOR_WIDTH = MAP_WIDTH * TILE_WIDTH + EDITOR_SPACING_X * 2; | ||
15 | const int EDITOR_HEIGHT = MAP_HEIGHT * TILE_HEIGHT + EDITOR_SPACING_Y * 2; | ||
12 | 16 | ||
13 | #endif | 17 | #endif |
diff --git a/tools/mapedit/src/widget.cpp b/tools/mapedit/src/widget.cpp index aaebd38..41de4ca 100644 --- a/tools/mapedit/src/widget.cpp +++ b/tools/mapedit/src/widget.cpp | |||
@@ -5,11 +5,6 @@ | |||
5 | #include "object.h" | 5 | #include "object.h" |
6 | #include "undo.h" | 6 | #include "undo.h" |
7 | 7 | ||
8 | const int EDITOR_SPACING_X = MAP_WIDTH * TILE_WIDTH / 2; | ||
9 | const int EDITOR_SPACING_Y = MAP_HEIGHT * TILE_HEIGHT / 2; | ||
10 | const int EDITOR_WIDTH = MAP_WIDTH * TILE_WIDTH + EDITOR_SPACING_X * 2; | ||
11 | const int EDITOR_HEIGHT = MAP_HEIGHT * TILE_HEIGHT + EDITOR_SPACING_Y * 2; | ||
12 | |||
13 | IMPLEMENT_DYNAMIC_CLASS(MapeditWidget,wxScrolledCanvas) | 8 | IMPLEMENT_DYNAMIC_CLASS(MapeditWidget,wxScrolledCanvas) |
14 | 9 | ||
15 | BEGIN_EVENT_TABLE(MapeditWidget, wxScrolledCanvas) | 10 | BEGIN_EVENT_TABLE(MapeditWidget, wxScrolledCanvas) |
@@ -77,20 +72,34 @@ void MapeditWidget::OnPaint(wxPaintEvent&) | |||
77 | dc.SetBrush(*wxGREY_BRUSH); | 72 | dc.SetBrush(*wxGREY_BRUSH); |
78 | dc.DrawRectangle(0, 0, cW, cH); | 73 | dc.DrawRectangle(0, 0, cW, cH); |
79 | 74 | ||
80 | for (int y=0; y<MAP_HEIGHT; y++) | 75 | RenderMap(map, dc, tiles_dc); |
76 | |||
77 | if (map->getLeftMoveType() == Map::MoveType::Warp) | ||
81 | { | 78 | { |
82 | for (int x=0; x<MAP_WIDTH; x++) | 79 | auto tomap = map->getWorld()->getMap(map->getLeftMoveMapID()); |
83 | { | 80 | |
84 | int tile = map->getTileAt(x, y); | 81 | RenderMap(tomap.get(), dc, tiles_dc, -EDITOR_SPACING_X, EDITOR_SPACING_Y, false); |
85 | if (changeBuffer.find({x,y}) != end(changeBuffer)) | 82 | } |
86 | { | 83 | |
87 | tile = tileWidget->getSelected(); | 84 | if (map->getRightMoveType() == Map::MoveType::Warp) |
88 | } | 85 | { |
89 | 86 | auto tomap = map->getWorld()->getMap(map->getRightMoveMapID()); | |
90 | wxPoint pos {(x*TILE_WIDTH + EDITOR_SPACING_X)*scale - vX, (y*TILE_HEIGHT + EDITOR_SPACING_Y) * scale - vY}; | 87 | |
91 | 88 | RenderMap(tomap.get(), dc, tiles_dc, EDITOR_WIDTH-EDITOR_SPACING_X, EDITOR_SPACING_Y, false); | |
92 | dc.StretchBlit(pos.x, pos.y, TILE_WIDTH*scale, TILE_HEIGHT*scale, &tiles_dc, tile%8*TILE_WIDTH, tile/8*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT); | 89 | } |
93 | } | 90 | |
91 | if (map->getUpMoveType() == Map::MoveType::Warp) | ||
92 | { | ||
93 | auto tomap = map->getWorld()->getMap(map->getUpMoveMapID()); | ||
94 | |||
95 | RenderMap(tomap.get(), dc, tiles_dc, EDITOR_SPACING_X, -EDITOR_SPACING_Y, false); | ||
96 | } | ||
97 | |||
98 | if (map->getDownMoveType() == Map::MoveType::Warp) | ||
99 | { | ||
100 | auto tomap = map->getWorld()->getMap(map->getDownMoveMapID()); | ||
101 | |||
102 | RenderMap(tomap.get(), dc, tiles_dc, EDITOR_SPACING_X, EDITOR_HEIGHT-EDITOR_SPACING_Y, false); | ||
94 | } | 103 | } |
95 | 104 | ||
96 | for (auto object : map->getObjects()) | 105 | for (auto object : map->getObjects()) |
@@ -516,3 +525,43 @@ void MapeditWidget::SetMap(Map* map) | |||
516 | 525 | ||
517 | Refresh(); | 526 | Refresh(); |
518 | } | 527 | } |
528 | |||
529 | void MapeditWidget::RenderMap(Map* toRender, wxPaintDC& dc, wxMemoryDC& tiles_dc, int offset_x, int offset_y, bool main) | ||
530 | { | ||
531 | int vX, vY, vXX, vXY, vW, vH, cW, cH; | ||
532 | GetViewStart(&vX, &vY); | ||
533 | GetVirtualSize(&vW, &vH); | ||
534 | GetClientSize(&cW, &cH); | ||
535 | GetScrollPixelsPerUnit(&vXX, &vXY); | ||
536 | vX *= vXX; | ||
537 | vY *= vXY; | ||
538 | |||
539 | if (main) | ||
540 | { | ||
541 | dc.SetPen(*wxGREY_PEN); | ||
542 | dc.SetBrush(*wxTRANSPARENT_BRUSH); | ||
543 | dc.DrawRectangle(offset_x, offset_y, MAP_WIDTH*TILE_WIDTH*scale, MAP_HEIGHT*TILE_HEIGHT*scale); | ||
544 | } | ||
545 | |||
546 | for (int y=0; y<MAP_HEIGHT; y++) | ||
547 | { | ||
548 | for (int x=0; x<MAP_WIDTH; x++) | ||
549 | { | ||
550 | int tile = toRender->getTileAt(x, y); | ||
551 | |||
552 | if (main) | ||
553 | { | ||
554 | if (changeBuffer.find({x,y}) != end(changeBuffer)) | ||
555 | { | ||
556 | tile = tileWidget->getSelected(); | ||
557 | } | ||
558 | } | ||
559 | |||
560 | wxPoint pos {(x*TILE_WIDTH + offset_x)*scale - vX, (y*TILE_HEIGHT + offset_y) * scale - vY}; | ||
561 | |||
562 | wxRasterOperationMode mod = wxCOPY; | ||
563 | if (!main) mod = wxOR; | ||
564 | dc.StretchBlit(pos.x, pos.y, TILE_WIDTH*scale, TILE_HEIGHT*scale, &tiles_dc, tile%8*TILE_WIDTH, tile/8*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, mod); | ||
565 | } | ||
566 | } | ||
567 | } | ||
diff --git a/tools/mapedit/src/widget.h b/tools/mapedit/src/widget.h index c1bff31..12784f8 100644 --- a/tools/mapedit/src/widget.h +++ b/tools/mapedit/src/widget.h | |||
@@ -54,6 +54,7 @@ class MapeditWidget : public wxScrolledCanvas { | |||
54 | private: | 54 | private: |
55 | void SetTile(wxPoint pos); | 55 | void SetTile(wxPoint pos); |
56 | void SetZoomSize(int zoom); | 56 | void SetZoomSize(int zoom); |
57 | void RenderMap(Map* toRender, wxPaintDC& dc, wxMemoryDC& tiles_dc, int offset_x = EDITOR_SPACING_X, int offset_y = EDITOR_SPACING_Y, bool main = true); | ||
57 | 58 | ||
58 | Map* map = nullptr; | 59 | Map* map = nullptr; |
59 | wxBitmap tiles; | 60 | wxBitmap tiles; |