summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-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
6 files changed, 23 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index e1923b67..fcc265f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
2006-02-06 Björn Steinbrink <B.Steinbrink@gmx.de>
- * ChangeLog, data/graphics/gui/browserfont.png,
+ * src/being.cpp, src/being.h, src/localplayer.h, src/player.cpp,
+ src/player.h: Use virtual methods instead of getType() checks.
+ * data/graphics/gui/browserfont.png,
data/graphics/gui/fixedfont.png, data/graphics/gui/rpgfont_wider.png,
data/graphics/gui/sansserif8.png, src/Makefile.am, src/engine.cpp,
src/floor_item.cpp, src/floor_item.h, src/flooritemmanager.cpp,
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