summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/viewport.cpp2
-rw-r--r--src/map.cpp87
-rw-r--r--src/map.h9
3 files changed, 84 insertions, 14 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 66f614a8..120106cb 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -532,7 +532,7 @@ void Viewport::mouseMoved(gcn::MouseEvent &event)
void Viewport::toggleDebugPath()
{
mShowDebugPath++;
- if (mShowDebugPath > Map::MAP_SPECIAL)
+ if (mShowDebugPath > Map::MAP_SPECIAL3)
mShowDebugPath = Map::MAP_NORMAL;
if (mMap)
{
diff --git a/src/map.cpp b/src/map.cpp
index f5214420..3727efdc 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -135,8 +135,13 @@ void MapLayer::draw(Graphics *graphics, int startX, int startY,
Actors::const_iterator ai = actors.begin();
+ int dx = (mX * 32) - scrollX;
+ int dy = (mY * 32) - scrollY + 32;
+
for (int y = startY; y < endY; y++)
{
+ int y32 = y * 32;
+
// If drawing the fringe layer, make sure all actors above this row of
// tiles have been drawn
if (mIsFringeLayer)
@@ -148,15 +153,35 @@ void MapLayer::draw(Graphics *graphics, int startX, int startY,
}
}
- for (int x = startX; x < endX; x++)
+ if (debugFlags != Map::MAP_SPECIAL3)
{
- Image *img = getTile(x, y);
- if (img)
+ const int py0 = y32 + dy;
+
+ for (int x = startX; x < endX; x++)
{
- const int px = (x + mX) * 32 - scrollX;
- const int py = (y + mY) * 32 - scrollY + 32 - img->getHeight();
- if (debugFlags != Map::MAP_SPECIAL || img->getHeight() <= 32)
- graphics->drawImage(img, px, py);
+ Image *img = getTile(x, y);
+ if (img)
+ {
+ const int px = (x * 32) + dx;
+ const int py = py0 - img->getHeight();
+ if ((debugFlags != Map::MAP_SPECIAL
+ && debugFlags != Map::MAP_SPECIAL2)
+ || img->getHeight() <= 32)
+ {
+ int width = 0;
+ int c = getTileDrawWidth(x, y, endX, width);
+ if (!c)
+ {
+ graphics->drawImage(img, px, py);
+ }
+ else
+ {
+ graphics->drawImagePattern(img, px, py,
+ width, img->getHeight());
+ }
+ x += c;
+ }
+ }
}
}
}
@@ -172,6 +197,22 @@ void MapLayer::draw(Graphics *graphics, int startX, int startY,
}
}
+int MapLayer::getTileDrawWidth(int x1, int y1, int endX, int &width) const
+{
+ Image *img1 = getTile(x1, y1);
+ int c = 0;
+ width = img1->getWidth();
+ for (int x = x1 + 1; x < endX; x++)
+ {
+ Image *img = getTile(x, y1);
+ if (img != img1)
+ break;
+ c ++;
+ width += img->getWidth();
+ }
+ return c;
+}
+
Map::Map(int width, int height, int tileWidth, int tileHeight):
mWidth(width), mHeight(height),
mTileWidth(tileWidth), mTileHeight(tileHeight),
@@ -319,12 +360,34 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY)
// draw the game world
Layers::const_iterator layeri = mLayers.begin();
- for (; layeri != mLayers.end(); ++layeri)
+
+ bool overFringe = false;
+
+ if (mDebugFlags == MAP_SPECIAL3)
+ {
+ for (; layeri != mLayers.end(); ++layeri)
+ {
+ if ((*layeri)->isFringeLayer())
+ {
+ (*layeri)->draw(graphics,
+ startX, startY, endX, endY,
+ scrollX, scrollY,
+ mActors, mDebugFlags);
+ }
+ }
+ }
+ else
{
- (*layeri)->draw(graphics,
- startX, startY, endX, endY,
- scrollX, scrollY,
- mActors, mDebugFlags);
+ for (; layeri != mLayers.end() && !overFringe; ++layeri)
+ {
+ if ((*layeri)->isFringeLayer() && mDebugFlags == MAP_SPECIAL2)
+ overFringe = true;
+
+ (*layeri)->draw(graphics,
+ startX, startY, endX, endY,
+ scrollX, scrollY,
+ mActors, mDebugFlags);
+ }
}
// Draws beings with a lower opacity to make them visible
diff --git a/src/map.h b/src/map.h
index 86a5d3ee..160cb7f7 100644
--- a/src/map.h
+++ b/src/map.h
@@ -128,6 +128,11 @@ class MapLayer
const Actors &actors,
int mDebugFlags) const;
+ bool isFringeLayer()
+ { return mIsFringeLayer; }
+
+ int getTileDrawWidth(int x1, int y1, int endX, int &width) const;
+
private:
int mX, mY;
int mWidth, mHeight;
@@ -161,7 +166,9 @@ class Map : public Properties
{
MAP_NORMAL = 0,
MAP_DEBUG = 1,
- MAP_SPECIAL = 2
+ MAP_SPECIAL = 2,
+ MAP_SPECIAL2 = 3,
+ MAP_SPECIAL3 = 4
};
/**