From 9cff7e13f21edf3c794085bd9d0fbbdb22ff6896 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 13 Mar 2016 19:51:48 +0300 Subject: Add separate functions for draw portals. --- src/being/being.cpp | 76 ++++++++++++++++++++++++++++++++++------------------- src/being/being.h | 9 +++++++ 2 files changed, 58 insertions(+), 27 deletions(-) (limited to 'src/being') diff --git a/src/being/being.cpp b/src/being/being.cpp index 45b971399..bbd7f63b2 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -2915,6 +2915,17 @@ void Being::drawOther(Graphics *restrict const graphics, drawOtherSpriteAt(graphics, px, py); } +void Being::drawPortal(Graphics *restrict const graphics, + const int offsetX, + const int offsetY) const restrict2 +{ + // getActorX() + offsetX; + const int px = mPixelX - mapTileSize / 2 + offsetX; + // getActorY() + offsetY; + const int py = mPixelY - mapTileSize + offsetY; + drawPortalSpriteAt(graphics, px, py); +} + void Being::draw(Graphics *restrict const graphics, const int offsetX, const int offsetY) const restrict2 @@ -2926,10 +2937,14 @@ void Being::draw(Graphics *restrict const graphics, offsetX, offsetY); break; + case ActorType::Portal: + drawPortal(graphics, + offsetX, + offsetY); + break; case ActorType::Npc: case ActorType::Monster: case ActorType::FloorItem: - case ActorType::Portal: case ActorType::LocalPet: case ActorType::Avatar: #ifdef EATHENA_SUPPORT @@ -3019,32 +3034,9 @@ void Being::drawOtherSpriteAt(Graphics *restrict const graphics, const int x, const int y) const restrict2 { - if (mHighlightMapPortals && - mMap && - mSubType == fromInt(45, BeingTypeId) && - !mMap->getHasWarps()) - { - if (!userPalette) - { - CompoundSprite::draw(graphics, x, y); - return; - } - - graphics->setColor(userPalette-> - getColorWithAlpha(UserColorId::PORTAL_HIGHLIGHT)); - - graphics->fillRectangle(Rect(x, y, - mapTileSize, mapTileSize)); - - if (mDrawHotKeys && !mName.empty()) - { - const Color &color = userPalette->getColor(UserColorId::BEING); - gui->getFont()->drawString(graphics, color, color, mName, x, y); - } - } - else if (mHighlightMonsterAttackRange && - mType == ActorType::Monster && - isAlive()) + if (mHighlightMonsterAttackRange && + mType == ActorType::Monster && + isAlive()) { if (!userPalette) { @@ -3092,6 +3084,36 @@ void Being::drawOtherSpriteAt(Graphics *restrict const graphics, } } +void Being::drawPortalSpriteAt(Graphics *restrict const graphics, + const int x, + const int y) const restrict2 +{ + if (mHighlightMapPortals && + mMap && + !mMap->getHasWarps()) + { + if (!userPalette) + { + CompoundSprite::draw(graphics, x, y); + return; + } + + graphics->setColor(userPalette-> + getColorWithAlpha(UserColorId::PORTAL_HIGHLIGHT)); + + graphics->fillRectangle(Rect(x, y, + mapTileSize, mapTileSize)); + + if (mDrawHotKeys && !mName.empty()) + { + const Color &color = userPalette->getColor(UserColorId::BEING); + gui->getFont()->drawString(graphics, color, color, mName, x, y); + } + } + + CompoundSprite::draw(graphics, x, y); +} + void Being::drawHpBar(Graphics *restrict const graphics, const int maxHP, const int hp, diff --git a/src/being/being.h b/src/being/being.h index dbdb58acb..0c61733cf 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -641,6 +641,11 @@ class Being notfinal : public ActorSprite, const int offsetY) const restrict2 A_NONNULL(2); + void drawPortal(Graphics *restrict const graphics, + const int offsetX, + const int offsetY) const + restrict2 A_NONNULL(2); + void drawBasic(Graphics *restrict const graphics, const int x, const int y) const restrict2 A_NONNULL(2); @@ -1001,6 +1006,10 @@ class Being notfinal : public ActorSprite, const int x, const int y) const restrict2 A_NONNULL(2); + void drawPortalSpriteAt(Graphics *restrict const graphics, + const int x, + const int y) const restrict2 A_NONNULL(2); + /** * Updates name's location. */ -- cgit v1.2.3-60-g2f50