summaryrefslogtreecommitdiff
path: root/src/gui/viewport.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-10-15 21:08:39 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-10-15 21:08:39 +0000
commit1e949983c13cab920a4cc445b2ed6429dd9aad5a (patch)
treee46aeb53ed54a5aad71f51bb08e0bb428f0d0d7e /src/gui/viewport.cpp
parent7df722ac2899729174c1a88bec96f658237023bf (diff)
downloadmana-client-1e949983c13cab920a4cc445b2ed6429dd9aad5a.tar.gz
mana-client-1e949983c13cab920a4cc445b2ed6429dd9aad5a.tar.bz2
mana-client-1e949983c13cab920a4cc445b2ed6429dd9aad5a.tar.xz
mana-client-1e949983c13cab920a4cc445b2ed6429dd9aad5a.zip
Added Dutch translation (incomplete) and put drawing of debug path into a
private method.
Diffstat (limited to 'src/gui/viewport.cpp')
-rw-r--r--src/gui/viewport.cpp58
1 files changed, 31 insertions, 27 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 4c6b04a2..915b618d 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -87,8 +87,8 @@ void
Viewport::loadTargetCursor(std::string filename, int width, int height,
bool outRange, Being::TargetCursorSize size)
{
- assert(size > -1);
- assert(size < 3);
+ assert(size >= Being::TC_SMALL);
+ assert(size < Being::NUM_TC);
ImageSet* currentImageSet;
SimpleAnimation* currentCursor;
@@ -226,32 +226,9 @@ Viewport::draw(gcn::Graphics *gcnGraphics)
drawTargetName(graphics);
}
- // Find a path from the player to the mouse, and draw it. This is for debug
- // purposes.
if (mShowDebugPath && mMap)
{
- // Get the current mouse position
- int mouseX, mouseY;
- SDL_GetMouseState(&mouseX, &mouseY);
-
- int mouseTileX = (mouseX + mCameraX) / 32;
- int mouseTileY = (mouseY + mCameraY) / 32;
-
- Path debugPath = mMap->findPath(
- player_node->mX / 32, player_node->mY / 32,
- mouseTileX, mouseTileY);
-
- graphics->setColor(gcn::Color(255, 0, 0));
- for (PathIterator i = debugPath.begin(); i != debugPath.end(); i++)
- {
- int squareX = i->x * 32 - mCameraX + 12;
- int squareY = i->y * 32 - mCameraY + 12;
-
- graphics->fillRectangle(gcn::Rectangle(squareX, squareY, 8, 8));
- graphics->drawText(
- toString(mMap->getMetaTile(i->x, i->y)->Gcost),
- squareX + 4, squareY + 12, gcn::Graphics::CENTER);
- }
+ drawDebugPath(graphics);
}
// Draw player nickname, speech, and emotion sprite as needed
@@ -286,7 +263,7 @@ Viewport::logic()
mWalkTime = player_node->mWalkTime;
}
- for (int i = 0; i < 3; i++)
+ for (int i = Being::TC_SMALL; i < Being::NUM_TC; i++)
{
mTargetCursorInRange[i]->update(10);
mTargetCursorOutRange[i]->update(10);
@@ -347,6 +324,33 @@ Viewport::drawTargetName(Graphics *graphics)
}
void
+Viewport::drawDebugPath(Graphics *graphics)
+{
+ // Get the current mouse position
+ int mouseX, mouseY;
+ SDL_GetMouseState(&mouseX, &mouseY);
+
+ int mouseTileX = (mouseX + mCameraX) / 32;
+ int mouseTileY = (mouseY + mCameraY) / 32;
+
+ Path debugPath = mMap->findPath(
+ player_node->mX / 32, player_node->mY / 32,
+ mouseTileX, mouseTileY);
+
+ graphics->setColor(gcn::Color(255, 0, 0));
+ for (PathIterator i = debugPath.begin(); i != debugPath.end(); i++)
+ {
+ int squareX = i->x * 32 - mCameraX + 12;
+ int squareY = i->y * 32 - mCameraY + 12;
+
+ graphics->fillRectangle(gcn::Rectangle(squareX, squareY, 8, 8));
+ graphics->drawText(
+ toString(mMap->getMetaTile(i->x, i->y)->Gcost),
+ squareX + 4, squareY + 12, gcn::Graphics::CENTER);
+ }
+}
+
+void
Viewport::mousePressed(gcn::MouseEvent &event)
{
// Check if we are alive and kickin'