diff options
author | Andrei Karas <akaras@inbox.ru> | 2010-01-09 01:01:17 +0200 |
---|---|---|
committer | Blue <bluesansdouze@gmail.com> | 2010-01-09 00:20:08 +0100 |
commit | b5643b417e12308163802c3a11ac28f1abd239f9 (patch) | |
tree | 68318813f4760929a5c475a655e2113d9b8db8d4 /src | |
parent | 104266da0f92ab2a765598dde59bf2e7f6426484 (diff) | |
download | mana-b5643b417e12308163802c3a11ac28f1abd239f9.tar.gz mana-b5643b417e12308163802c3a11ac28f1abd239f9.tar.bz2 mana-b5643b417e12308163802c3a11ac28f1abd239f9.tar.xz mana-b5643b417e12308163802c3a11ac28f1abd239f9.zip |
Add special map mode.
This mode hide big map objects and show collisions.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/viewport.cpp | 22 | ||||
-rw-r--r-- | src/gui/viewport.h | 4 | ||||
-rw-r--r-- | src/map.cpp | 16 | ||||
-rw-r--r-- | src/map.h | 20 |
4 files changed, 51 insertions, 11 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 01aa75ee..dc4b9721 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -86,6 +86,10 @@ Viewport::~Viewport() void Viewport::setMap(Map *map) { + if (mMap && map) + { + map->setDebugFlags(mMap->getDebugFlags()); + } mMap = map; } @@ -191,8 +195,10 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) if (mShowDebugPath) { mMap->drawCollision(graphics, (int) mPixelViewX, - (int) mPixelViewY); - _drawDebugPath(graphics); + (int) mPixelViewY, + mShowDebugPath); + if (mShowDebugPath == Map::MAP_DEBUG) + _drawDebugPath(graphics); } } @@ -462,3 +468,15 @@ void Viewport::mouseMoved(gcn::MouseEvent &event) mSelectedBeing = beingManager->findBeing(tilex, tiley); } + +void Viewport::toggleDebugPath() +{ + mShowDebugPath++; + if (mShowDebugPath > Map::MAP_SPECIAL) + mShowDebugPath = Map::MAP_NORMAL; + if (mMap) + { + mMap->setDebugFlags(mShowDebugPath); + } +} + diff --git a/src/gui/viewport.h b/src/gui/viewport.h index e4311222..e1030972 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -80,7 +80,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener, /** * Toggles whether the path debug graphics are shown */ - void toggleDebugPath() { mShowDebugPath = !mShowDebugPath; } + void toggleDebugPath(); /** * Handles mouse press on map. @@ -173,7 +173,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener, float mPixelViewY; /**< Current viewpoint in pixels. */ int mTileViewX; /**< Current viewpoint in tiles. */ int mTileViewY; /**< Current viewpoint in tiles. */ - bool mShowDebugPath; /**< Show a path from player to pointer. */ + int mShowDebugPath; /**< Show a path from player to pointer. */ bool mVisibleNames; /**< Show target names. */ bool mPlayerFollowMouse; diff --git a/src/map.cpp b/src/map.cpp index e4d68756..73686d61 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -128,7 +128,7 @@ Image* MapLayer::getTile(int x, int y) const void MapLayer::draw(Graphics *graphics, int startX, int startY, int endX, int endY, int scrollX, int scrollY, - const MapSprites &sprites) const + const MapSprites &sprites, int debugFlags) const { startX -= mX; startY -= mY; @@ -163,7 +163,8 @@ void MapLayer::draw(Graphics *graphics, int startX, int startY, { const int px = (x + mX) * 32 - scrollX; const int py = (y + mY) * 32 - scrollY + 32 - img->getHeight(); - graphics->drawImage(img, px, py); + if (debugFlags != Map::MAP_SPECIAL || img->getHeight() <= 32) + graphics->drawImage(img, px, py); } } } @@ -185,7 +186,8 @@ Map::Map(int width, int height, int tileWidth, int tileHeight): mTileWidth(tileWidth), mTileHeight(tileHeight), mMaxTileHeight(height), mOnClosedList(1), mOnOpenList(2), - mLastScrollX(0.0f), mLastScrollY(0.0f) + mLastScrollX(0.0f), mLastScrollY(0.0f), + mDebugFlags(MAP_NORMAL) { const int size = mWidth * mHeight; @@ -330,7 +332,7 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY) (*layeri)->draw(graphics, startX, startY, endX, endY, scrollX, scrollY, - mSprites); + mSprites, mDebugFlags); } // Draws beings with a lower opacity to make them visible @@ -354,7 +356,7 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY) (int) config.getValue("OverlayDetail", 2)); } -void Map::drawCollision(Graphics *graphics, int scrollX, int scrollY) +void Map::drawCollision(Graphics *graphics, int scrollX, int scrollY, int debugFlags) { int endPixelY = graphics->getHeight() + scrollY + mTileHeight - 1; int startX = scrollX / mTileWidth; @@ -371,11 +373,15 @@ void Map::drawCollision(Graphics *graphics, int scrollX, int scrollY) { for (int x = startX; x < endX; x++) { + graphics->setColor(gcn::Color(0, 0, 0, 64)); + if (debugFlags < MAP_SPECIAL) + { graphics->drawRectangle(gcn::Rectangle( x * mTileWidth - scrollX, y * mTileWidth - scrollY, 33, 33)); + } if (!getWalk(x, y, BLOCKMASK_WALL)) { @@ -130,7 +130,8 @@ class MapLayer int startX, int startY, int endX, int endY, int scrollX, int scrollY, - const MapSprites &sprites) const; + const MapSprites &sprites, + int mDebugFlags) const; private: int mX, mY; @@ -161,6 +162,13 @@ class Map : public Properties BLOCKMASK_MONSTER = 0x02 // = bin 0000 0010 }; + enum DebugType + { + MAP_NORMAL = 0, + MAP_DEBUG = 1, + MAP_SPECIAL = 2 + }; + /** * Constructor, taking map and tile size as parameters. */ @@ -195,7 +203,8 @@ class Map : public Properties /** * Visualizes collision layer for debugging */ - void drawCollision(Graphics *graphics, int scrollX, int scrollY); + void drawCollision(Graphics *graphics, int scrollX, int scrollY, + int debugFlags); /** * Adds a layer to this map. The map takes ownership of the layer. @@ -289,6 +298,10 @@ class Map : public Properties void addAnimation(int gid, TileAnimation *animation) { mTileAnimations[gid] = animation; } + void setDebugFlags(int n) {mDebugFlags = n;} + + int getDebugFlags() {return mDebugFlags;} + /** * Gets the tile animation for a specific gid */ @@ -331,6 +344,9 @@ class Map : public Properties Tilesets mTilesets; MapSprites mSprites; + // debug flags + int mDebugFlags; + // Pathfinding members int mOnClosedList, mOnOpenList; |