diff options
author | David Athay <ko2fan@gmail.com> | 2007-03-20 00:50:59 +0000 |
---|---|---|
committer | David Athay <ko2fan@gmail.com> | 2007-03-20 00:50:59 +0000 |
commit | 8a49edf2371fddba894a8b0a4f05083f63475840 (patch) | |
tree | bfc4d5c75002e9cd552a4fc8bb9f5d61327df491 /src/gui | |
parent | 2eafff3f1863c9231b1729023ce3fa34f4ee302c (diff) | |
download | mana-8a49edf2371fddba894a8b0a4f05083f63475840.tar.gz mana-8a49edf2371fddba894a8b0a4f05083f63475840.tar.bz2 mana-8a49edf2371fddba894a8b0a4f05083f63475840.tar.xz mana-8a49edf2371fddba894a8b0a4f05083f63475840.zip |
Fixed target cursor animation, and changed when it is drawn.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/viewport.cpp | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 96f44068..a4a7873a 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -183,11 +183,63 @@ Viewport::draw(gcn::Graphics *gcnGraphics) mCameraX = (int) (mViewX + 16) / 32; mCameraY = (int) (mViewY + 16) / 32; - + // Draw tiles and sprites if (mMap) { mMap->draw(graphics, (int) mViewX, (int) mViewY, 0); + // Draw target marker if needed + Being *target = player_node->getTarget(); + if (target) + { + graphics->setFont(speechFont); + graphics->setColor(gcn::Color(255, 32, 32)); + int dy = (target->getType() == Being::PLAYER) ? 80 : 42; + + std::string mobName = ""; + + if (target->mJob >= 1002) + { + int mobId = target->mJob - 1002; + mobName = MonsterDB::get(mobId).getName(); + + // Find whether target is in range + int rangex = target->mX - player_node->mX; + int rangey = target->mY - player_node->mY; + int attackRange = player_node->getAttackRange(); + + // If either is negative, convert to positive + if (rangex < 0) + { + rangex = -rangex; + } + if (rangey < 0) + { + rangey = -rangey; + } + + // Draw the target cursor, which one depends if the target is in range + if (rangex > attackRange || rangey > attackRange) + { + // Draw the out of range cursor + graphics->drawImage(mTargetCursorOutRange->getCurrentImage(), + target->getPixelX() - (int) mViewX, + target->getPixelY() - (int) mViewY); + } + else + { + // Draw the in range cursor + graphics->drawImage(mTargetCursorInRange->getCurrentImage(), + target->getPixelX() - (int) mViewX, + target->getPixelY() - (int) mViewY); + } + + graphics->drawText(mobName, + target->getPixelX() - (int) mViewX + 15, + target->getPixelY() - (int) mViewY - dy, + gcn::Graphics::CENTER); + } + } mMap->draw(graphics, (int) mViewX, (int) mViewY, 1); mMap->draw(graphics, (int) mViewX, (int) mViewY, 2); mMap->drawOverlay(graphics, mViewX, mViewY, @@ -221,7 +273,7 @@ Viewport::draw(gcn::Graphics *gcnGraphics) squareX + 4, squareY + 12, gcn::Graphics::CENTER); } } - + // Draw player nickname, speech, and emotion sprite as needed Beings &beings = beingManager->getAll(); for (BeingIterator i = beings.begin(); i != beings.end(); i++) @@ -231,61 +283,6 @@ Viewport::draw(gcn::Graphics *gcnGraphics) (*i)->drawEmotion(graphics, -(int) mViewX, -(int) mViewY); } - // Draw target marker if needed - Being *target = player_node->getTarget(); - if (target) - { - graphics->setFont(speechFont); - graphics->setColor(gcn::Color(255, 32, 32)); - int dy = (target->getType() == Being::PLAYER) ? 80 : 42; - - std::string mobName = ""; - - if (target->mJob >= 1002) - { - int mobId = target->mJob - 1002; - mobName = MonsterDB::get(mobId).getName(); - - // Find whether target is in range - int rangex = target->mX - player_node->mX; - int rangey = target->mY - player_node->mY; - int attackRange = player_node->getAttackRange(); - - // If either is negative, convert to positive - if (rangex < 0) - { - rangex = -rangex; - } - if (rangey < 0) - { - rangey = -rangey; - } - - // Draw the target cursor, which one depends if the target is in range - if (rangex > attackRange || rangey > attackRange) - { - // Update animation frame and then draw the next image - mTargetCursorOutRange->update(10); - graphics->drawImage(mTargetCursorOutRange->getCurrentImage(), - target->getPixelX() - (int) mViewX, - target->getPixelY() - (int) mViewY); - } - else - { - // Update animation frame and then draw the next image - mTargetCursorInRange->update(10); - graphics->drawImage(mTargetCursorInRange->getCurrentImage(), - target->getPixelX() - (int) mViewX, - target->getPixelY() - (int) mViewY); - } - - graphics->drawText(mobName, - target->getPixelX() - (int) mViewX + 15, - target->getPixelY() - (int) mViewY - dy, - gcn::Graphics::CENTER); - } - } - // Draw contained widgets WindowContainer::draw(gcnGraphics); } @@ -308,6 +305,9 @@ Viewport::logic() mouseY / 32 + mCameraY); mWalkTime = player_node->mWalkTime; } + + mTargetCursorInRange->update(10); + mTargetCursorOutRange->update(10); } void |