summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2010-01-09 23:47:50 +0200
committerBlue <bluesansdouze@gmail.com>2010-01-10 01:12:46 +0100
commit0c86751e2ca0674e1ae6e584b9e017af8d1e48fe (patch)
tree0bd5954c3887f5444ac587a1121019ccbdd47803 /src
parenta9da8dca359f1975d1be6bbef16ea72928652880 (diff)
downloadmana-0c86751e2ca0674e1ae6e584b9e017af8d1e48fe.tar.gz
mana-0c86751e2ca0674e1ae6e584b9e017af8d1e48fe.tar.bz2
mana-0c86751e2ca0674e1ae6e584b9e017af8d1e48fe.tar.xz
mana-0c86751e2ca0674e1ae6e584b9e017af8d1e48fe.zip
Show monster inflicted damage.
Disabled by default.
Diffstat (limited to 'src')
-rw-r--r--src/being.cpp29
-rw-r--r--src/being.h7
-rw-r--r--src/gui/setup_video.cpp15
-rw-r--r--src/gui/setup_video.h2
4 files changed, 51 insertions, 2 deletions
diff --git a/src/being.cpp b/src/being.cpp
index b54f4c44..6ae71f85 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -94,7 +94,8 @@ Being::Being(int id, int job, Map *map):
#endif
mPx(0), mPy(0),
mX(0), mY(0),
- mUsedTargetCursor(NULL)
+ mUsedTargetCursor(NULL),
+ mTakedDamage(0)
{
setMap(map);
@@ -314,6 +315,12 @@ void Being::takeDamage(Being *attacker, int amount, AttackType type)
if (amount > 0)
{
+ if (getType() == MONSTER)
+ {
+ mTakedDamage += amount;
+ updateName();
+ }
+
if (type != CRITICAL)
{
effectManager->trigger(26, this);
@@ -941,9 +948,19 @@ void Being::showName()
{
delete mDispName;
mDispName = 0;
+ std::string mDisplayName(mName);
+
+ if(getType() == MONSTER)
+ {
+ if (config.getValue("showMonstersTakedDamage", false))
+ {
+ mDisplayName += ", " + toString(getTakedDamage());
+ }
+ }
- mDispName = new FlashText(mName, getPixelX(), getPixelY(),
+ mDispName = new FlashText(mDisplayName, getPixelX(), getPixelY(),
gcn::Graphics::CENTER, mNameColor);
+
}
int Being::getNumberOfLayers() const
@@ -962,3 +979,11 @@ void Being::load()
mNumberOfHairstyles = hairstyles;
}
+
+void Being::updateName()
+{
+ if (mShowName)
+ {
+ showName();
+ }
+}
diff --git a/src/being.h b/src/being.h
index 8aa34b7c..67ad8096 100644
--- a/src/being.h
+++ b/src/being.h
@@ -475,6 +475,11 @@ class Being : public Sprite, public ConfigListener
void flashName(int time);
+ int getTakedDamage() const
+ { return mTakedDamage; }
+
+ void updateName();
+
protected:
/**
* Sets the new path for this being.
@@ -586,6 +591,8 @@ class Being : public Sprite, public ConfigListener
int mPx, mPy; /**< Position in pixels */
int mX, mY; /**< Position on tile */
+ int mTakedDamage;
+
/** Target cursor being used */
SimpleAnimation* mUsedTargetCursor;
};
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index b1d40575..ec11709e 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -179,6 +179,8 @@ Setup_Video::Setup_Video():
mFullScreenEnabled(config.getValue("screen", false)),
mOpenGLEnabled(config.getValue("opengl", false)),
mCustomCursorEnabled(config.getValue("customcursor", true)),
+ mShowMonsterDamageEnabled(config.getValue("showMonstersTakedDamage",
+ false)),
mVisibleNamesEnabled(config.getValue("visiblenames", true)),
mParticleEffectsEnabled(config.getValue("particleeffects", true)),
mNameEnabled(config.getValue("showownname", false)),
@@ -221,6 +223,9 @@ Setup_Video::Setup_Video():
{
setName(_("Video"));
+ mShowMonsterDamageCheckBox = new CheckBox(_("Show monster damage"),
+ mShowMonsterDamageEnabled);
+
ScrollArea *scrollArea = new ScrollArea(mModeList);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
@@ -250,6 +255,7 @@ Setup_Video::Setup_Video():
mModeList->setActionEventId("videomode");
mCustomCursorCheckBox->setActionEventId("customcursor");
+ mShowMonsterDamageCheckBox->setActionEventId("monsterdamage");
mVisibleNamesCheckBox->setActionEventId("visiblenames");
mParticleEffectsCheckBox->setActionEventId("particleeffects");
mPickupChatCheckBox->setActionEventId("pickupchat");
@@ -266,6 +272,7 @@ Setup_Video::Setup_Video():
mModeList->addActionListener(this);
mCustomCursorCheckBox->addActionListener(this);
+ mShowMonsterDamageCheckBox->addActionListener(this);
mVisibleNamesCheckBox->addActionListener(this);
mParticleEffectsCheckBox->addActionListener(this);
mPickupChatCheckBox->addActionListener(this);
@@ -301,6 +308,7 @@ Setup_Video::Setup_Video():
place(3, 0, mOpenGLCheckBox, 1);
place(1, 1, mCustomCursorCheckBox, 3);
+ place(3, 1, mShowMonsterDamageCheckBox, 3);
place(1, 2, mVisibleNamesCheckBox, 3);
place(3, 2, mNameCheckBox, 1);
@@ -405,6 +413,7 @@ void Setup_Video::apply()
// We sync old and new values at apply time
mFullScreenEnabled = config.getValue("screen", false);
mCustomCursorEnabled = config.getValue("customcursor", true);
+ mShowMonsterDamageEnabled = config.getValue("showMonstersTakedDamage", false);
mVisibleNamesEnabled = config.getValue("visiblenames", true);
mParticleEffectsEnabled = config.getValue("particleeffects", true);
mNameEnabled = config.getValue("showownname", false);
@@ -422,6 +431,7 @@ void Setup_Video::cancel()
mFsCheckBox->setSelected(mFullScreenEnabled);
mOpenGLCheckBox->setSelected(mOpenGLEnabled);
mCustomCursorCheckBox->setSelected(mCustomCursorEnabled);
+ mShowMonsterDamageCheckBox->setSelected(mShowMonsterDamageEnabled);
mVisibleNamesCheckBox->setSelected(mVisibleNamesEnabled);
mParticleEffectsCheckBox->setSelected(mParticleEffectsEnabled);
mSpeechSlider->setValue(mSpeechMode);
@@ -432,6 +442,7 @@ void Setup_Video::cancel()
config.setValue("screen", mFullScreenEnabled);
config.setValue("customcursor", mCustomCursorEnabled);
+ config.setValue("showMonstersTakedDamage", mShowMonsterDamageEnabled);
config.setValue("visiblenames", mVisibleNamesEnabled);
config.setValue("particleeffects", mParticleEffectsEnabled);
config.setValue("speech", mSpeechMode);
@@ -476,6 +487,10 @@ void Setup_Video::action(const gcn::ActionEvent &event)
{
config.setValue("customcursor", mCustomCursorCheckBox->isSelected());
}
+ else if (event.getId() == "monsterdamage")
+ {
+ config.setValue("showMonstersTakedDamage", mShowMonsterDamageCheckBox->isSelected());
+ }
else if (event.getId() == "visiblenames")
{
config.setValue("visiblenames", mVisibleNamesCheckBox->isSelected());
diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h
index 0bcdabbe..b7d79f5c 100644
--- a/src/gui/setup_video.h
+++ b/src/gui/setup_video.h
@@ -52,6 +52,7 @@ class Setup_Video : public SetupTab, public gcn::ActionListener,
bool mFullScreenEnabled;
bool mOpenGLEnabled;
bool mCustomCursorEnabled;
+ bool mShowMonsterDamageEnabled;
bool mVisibleNamesEnabled;
bool mParticleEffectsEnabled;
bool mNameEnabled;
@@ -75,6 +76,7 @@ class Setup_Video : public SetupTab, public gcn::ActionListener,
gcn::CheckBox *mFsCheckBox;
gcn::CheckBox *mOpenGLCheckBox;
gcn::CheckBox *mCustomCursorCheckBox;
+ gcn::CheckBox *mShowMonsterDamageCheckBox;
gcn::CheckBox *mVisibleNamesCheckBox;
gcn::CheckBox *mParticleEffectsCheckBox;
gcn::CheckBox *mNameCheckBox;