From f83f5af19fc828806df8be7807ca418cfd0306da Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 18 Mar 2015 00:51:41 -0400 Subject: Added ghosts of adjacent warp maps to map editor widget --- tools/mapedit/src/consts.h | 4 +++ tools/mapedit/src/widget.cpp | 85 ++++++++++++++++++++++++++++++++++---------- tools/mapedit/src/widget.h | 1 + 3 files changed, 72 insertions(+), 18 deletions(-) (limited to 'tools') 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; const int MAP_HEIGHT = GAME_HEIGHT/TILE_HEIGHT - 1; const int PLAYER_WIDTH[5] = {10, 0, 0, 0, 0}; const int PLAYER_HEIGHT[5] = {12, 0, 0, 0, 0}; +const int EDITOR_SPACING_X = MAP_WIDTH * TILE_WIDTH / 2; +const int EDITOR_SPACING_Y = MAP_HEIGHT * TILE_HEIGHT / 2; +const int EDITOR_WIDTH = MAP_WIDTH * TILE_WIDTH + EDITOR_SPACING_X * 2; +const int EDITOR_HEIGHT = MAP_HEIGHT * TILE_HEIGHT + EDITOR_SPACING_Y * 2; #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 @@ #include "object.h" #include "undo.h" -const int EDITOR_SPACING_X = MAP_WIDTH * TILE_WIDTH / 2; -const int EDITOR_SPACING_Y = MAP_HEIGHT * TILE_HEIGHT / 2; -const int EDITOR_WIDTH = MAP_WIDTH * TILE_WIDTH + EDITOR_SPACING_X * 2; -const int EDITOR_HEIGHT = MAP_HEIGHT * TILE_HEIGHT + EDITOR_SPACING_Y * 2; - IMPLEMENT_DYNAMIC_CLASS(MapeditWidget,wxScrolledCanvas) BEGIN_EVENT_TABLE(MapeditWidget, wxScrolledCanvas) @@ -77,20 +72,34 @@ void MapeditWidget::OnPaint(wxPaintEvent&) dc.SetBrush(*wxGREY_BRUSH); dc.DrawRectangle(0, 0, cW, cH); - for (int y=0; ygetLeftMoveType() == Map::MoveType::Warp) { - for (int x=0; xgetTileAt(x, y); - if (changeBuffer.find({x,y}) != end(changeBuffer)) - { - tile = tileWidget->getSelected(); - } - - wxPoint pos {(x*TILE_WIDTH + EDITOR_SPACING_X)*scale - vX, (y*TILE_HEIGHT + EDITOR_SPACING_Y) * scale - vY}; - - 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); - } + auto tomap = map->getWorld()->getMap(map->getLeftMoveMapID()); + + RenderMap(tomap.get(), dc, tiles_dc, -EDITOR_SPACING_X, EDITOR_SPACING_Y, false); + } + + if (map->getRightMoveType() == Map::MoveType::Warp) + { + auto tomap = map->getWorld()->getMap(map->getRightMoveMapID()); + + RenderMap(tomap.get(), dc, tiles_dc, EDITOR_WIDTH-EDITOR_SPACING_X, EDITOR_SPACING_Y, false); + } + + if (map->getUpMoveType() == Map::MoveType::Warp) + { + auto tomap = map->getWorld()->getMap(map->getUpMoveMapID()); + + RenderMap(tomap.get(), dc, tiles_dc, EDITOR_SPACING_X, -EDITOR_SPACING_Y, false); + } + + if (map->getDownMoveType() == Map::MoveType::Warp) + { + auto tomap = map->getWorld()->getMap(map->getDownMoveMapID()); + + RenderMap(tomap.get(), dc, tiles_dc, EDITOR_SPACING_X, EDITOR_HEIGHT-EDITOR_SPACING_Y, false); } for (auto object : map->getObjects()) @@ -516,3 +525,43 @@ void MapeditWidget::SetMap(Map* map) Refresh(); } + +void MapeditWidget::RenderMap(Map* toRender, wxPaintDC& dc, wxMemoryDC& tiles_dc, int offset_x, int offset_y, bool main) +{ + int vX, vY, vXX, vXY, vW, vH, cW, cH; + GetViewStart(&vX, &vY); + GetVirtualSize(&vW, &vH); + GetClientSize(&cW, &cH); + GetScrollPixelsPerUnit(&vXX, &vXY); + vX *= vXX; + vY *= vXY; + + if (main) + { + dc.SetPen(*wxGREY_PEN); + dc.SetBrush(*wxTRANSPARENT_BRUSH); + dc.DrawRectangle(offset_x, offset_y, MAP_WIDTH*TILE_WIDTH*scale, MAP_HEIGHT*TILE_HEIGHT*scale); + } + + for (int y=0; ygetTileAt(x, y); + + if (main) + { + if (changeBuffer.find({x,y}) != end(changeBuffer)) + { + tile = tileWidget->getSelected(); + } + } + + wxPoint pos {(x*TILE_WIDTH + offset_x)*scale - vX, (y*TILE_HEIGHT + offset_y) * scale - vY}; + + wxRasterOperationMode mod = wxCOPY; + if (!main) mod = wxOR; + 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); + } + } +} 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 { private: void SetTile(wxPoint pos); void SetZoomSize(int zoom); + void RenderMap(Map* toRender, wxPaintDC& dc, wxMemoryDC& tiles_dc, int offset_x = EDITOR_SPACING_X, int offset_y = EDITOR_SPACING_Y, bool main = true); Map* map = nullptr; wxBitmap tiles; -- cgit 1.4.1