summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2006-02-06 04:18:16 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2006-02-06 04:18:16 +0000
commit323b0e57c673035ad8065c7daf399124f15c24d4 (patch)
treeb1fba9f0c2e9f7d7cccb6a083a2c5b862d91901b /src
parente2c61ef8ec4f8685c0eafa2284c7485cec489021 (diff)
downloadMana-323b0e57c673035ad8065c7daf399124f15c24d4.tar.gz
Mana-323b0e57c673035ad8065c7daf399124f15c24d4.tar.bz2
Mana-323b0e57c673035ad8065c7daf399124f15c24d4.tar.xz
Mana-323b0e57c673035ad8065c7daf399124f15c24d4.zip
Use virtual methods instead of getType() checks.
Diffstat (limited to 'src')
-rw-r--r--src/being.cpp13
-rw-r--r--src/being.h4
-rw-r--r--src/localplayer.h6
-rw-r--r--src/player.cpp10
-rw-r--r--src/player.h2
5 files changed, 20 insertions, 15 deletions
diff --git a/src/being.cpp b/src/being.cpp
index b417fc34..3570fe30 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -218,19 +218,6 @@ Being::logic()
}
void
-Being::drawName(Graphics *graphics, Sint32 offsetX, Sint32 offsetY)
-{
- int px = mPx + offsetX;
- int py = mPy + offsetY;
-
- // Draw player name
- if (getType() != LOCALPLAYER) {
- graphics->setFont(speechFont);
- graphics->drawText(mName, px + 15, py + 30, gcn::Graphics::CENTER);
- }
-}
-
-void
Being::drawEmotion(Graphics *graphics, Sint32 offsetX, Sint32 offsetY)
{
int px = mPx + offsetX;
diff --git a/src/being.h b/src/being.h
index d87f06ab..edc25c09 100644
--- a/src/being.h
+++ b/src/being.h
@@ -197,8 +197,8 @@ class Being : public Sprite
/**
* Draws the name text below the being.
*/
- void
- drawName(Graphics *graphics, Sint32 offsetX, Sint32 offsetY);
+ virtual void
+ drawName(Graphics *graphics, Sint32 offsetX, Sint32 offsetY) {};
/**
* Returns the type of the being.
diff --git a/src/localplayer.h b/src/localplayer.h
index fe87fbab..7867e13d 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -51,6 +51,12 @@ class LocalPlayer : public Player
virtual void logic();
virtual void nextStep();
+ /**
+ * Draws the name text below the being.
+ */
+ virtual void
+ drawName(Graphics *graphics, Sint32 offsetX, Sint32 offsetY) {};
+
virtual Type getType() const;
void clearInventory();
diff --git a/src/player.cpp b/src/player.cpp
index 5720f0a6..71bb6ca5 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -123,3 +123,13 @@ void Player::draw(Graphics *graphics, int offsetX, int offsetY)
py - 50 + 2 * hairtable[frame][dir][1]);
}
}
+
+void
+Player::drawName(Graphics *graphics, Sint32 offsetX, Sint32 offsetY)
+{
+ int px = mPx + offsetX;
+ int py = mPy + offsetY;
+
+ graphics->setFont(speechFont);
+ graphics->drawText(mName, px + 15, py + 30, gcn::Graphics::CENTER);
+}
diff --git a/src/player.h b/src/player.h
index 5d75a1db..3c68116e 100644
--- a/src/player.h
+++ b/src/player.h
@@ -39,6 +39,8 @@ class Player : public Being
virtual Type getType() const;
virtual void draw(Graphics *graphics, int offsetX, int offsetY);
+
+ virtual void drawName(Graphics *graphics, Sint32 offsetX, Sint32 offsetY);
};
#endif