From 6ca3e7e52584261f9d43de1a68c09f20a762cac1 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 13 Mar 2016 19:14:04 +0300 Subject: Move cursor drawing function from ActorSprite into Being. --- src/being/actorsprite.cpp | 14 -------------- src/being/actorsprite.h | 4 ---- src/being/being.cpp | 30 ++++++++++++++++++++++++++---- src/being/being.h | 4 ++++ src/being/flooritem.cpp | 1 - 5 files changed, 30 insertions(+), 23 deletions(-) (limited to 'src/being') diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp index eab902537..41f7d92bd 100644 --- a/src/being/actorsprite.cpp +++ b/src/being/actorsprite.cpp @@ -103,20 +103,6 @@ ActorSprite::~ActorSprite() } } -void ActorSprite::draw1(Graphics *const graphics, - const int offsetX, - const int offsetY) const -{ - FUNC_BLOCK("ActorSprite::draw1", 1) - if (mUsedTargetCursor) - { - mUsedTargetCursor->update(tick_time * MILLISECONDS_IN_A_TICK); - mUsedTargetCursor->draw(graphics, - offsetX + getTargetOffsetX() - mCursorPaddingX, - offsetY + getTargetOffsetY() - mCursorPaddingY); - } -} - void ActorSprite::logic() { BLOCK_START("ActorSprite::logic") diff --git a/src/being/actorsprite.h b/src/being/actorsprite.h index 836403c52..68964d04d 100644 --- a/src/being/actorsprite.h +++ b/src/being/actorsprite.h @@ -69,10 +69,6 @@ class ActorSprite notfinal : public CompoundSprite, public Actor virtual ActorTypeT getType() const noexcept A_WARN_UNUSED { return ActorType::Unknown; } - void draw1(Graphics *const graphics, - const int offsetX, - const int offsetY) const A_NONNULL(2); - virtual void logic(); void setMap(Map *const map) override; diff --git a/src/being/being.cpp b/src/being/being.cpp index b37db6c62..80561eabf 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -2859,7 +2859,7 @@ void Being::drawPlayer(Graphics *restrict const graphics, py + mHorseInfo->downOffsetY); } - ActorSprite::draw1(graphics, px, py); + drawBeingCursor(graphics, px, py); drawSpriteAt(graphics, px, py); for_each_horses(mUpHorseSprites) @@ -2871,16 +2871,38 @@ void Being::drawPlayer(Graphics *restrict const graphics, } else { - ActorSprite::draw1(graphics, px, py); + drawBeingCursor(graphics, px, py); drawSpriteAt(graphics, px, py); } #else - ActorSprite::draw1(graphics, px, py); + drawBeingCursor(graphics, px, py); drawSpriteAt(graphics, px, py); #endif } } +void Being::drawBeingCursor(Graphics *const graphics, + const int offsetX, + const int offsetY) const +{ + if (mUsedTargetCursor) + { + mUsedTargetCursor->update(tick_time * MILLISECONDS_IN_A_TICK); + if (!mInfo) + { + mUsedTargetCursor->draw(graphics, + offsetX - mCursorPaddingX, + offsetY - mCursorPaddingY); + } + else + { + mUsedTargetCursor->draw(graphics, + offsetX + mInfo->getTargetOffsetX() - mCursorPaddingX, + offsetY + mInfo->getTargetOffsetY() - mCursorPaddingY); + } + } +} + void Being::drawOther(Graphics *restrict const graphics, const int offsetX, const int offsetY) const restrict2 @@ -2889,7 +2911,7 @@ void Being::drawOther(Graphics *restrict const graphics, const int px = mPixelX - mapTileSize / 2 + offsetX; // getActorY() + offsetY; const int py = mPixelY - mapTileSize + offsetY; - ActorSprite::draw1(graphics, px, py); + drawBeingCursor(graphics, px, py); drawSpriteAt(graphics, px, py); } diff --git a/src/being/being.h b/src/being/being.h index 7c3860220..0b1797c38 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -1106,6 +1106,10 @@ class Being notfinal : public ActorSprite, void dumpSprites() const restrict2; + void drawBeingCursor(Graphics *const graphics, + const int offsetX, + const int offsetY) const A_NONNULL(2); + const ActorTypeT mType; /** Speech Bubble components */ diff --git a/src/being/flooritem.cpp b/src/being/flooritem.cpp index 05352c40f..3dd5e3371 100644 --- a/src/being/flooritem.cpp +++ b/src/being/flooritem.cpp @@ -193,7 +193,6 @@ void FloorItem::draw(Graphics *const graphics, const int px = getActorX() + offsetX; const int py = getActorY() + offsetY; - ActorSprite::draw1(graphics, px, py); CompoundSprite::draw(graphics, px, py); if (mHighlight) -- cgit v1.2.3-70-g09d2