diff options
author | Ira Rice <irarice@gmail.com> | 2008-10-15 17:57:54 +0000 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2008-10-15 17:57:54 +0000 |
commit | f07fdcc9668cc446d31ce2539e3934c40d103ae3 (patch) | |
tree | 7a70fc09d9e9588fbf3225057a494e775af1f1d9 /src/being.cpp | |
parent | d3f84af9d22814db0ec67e87805b3d1054afd606 (diff) | |
download | mana-f07fdcc9668cc446d31ce2539e3934c40d103ae3.tar.gz mana-f07fdcc9668cc446d31ce2539e3934c40d103ae3.tar.bz2 mana-f07fdcc9668cc446d31ce2539e3934c40d103ae3.tar.xz mana-f07fdcc9668cc446d31ce2539e3934c40d103ae3.zip |
Added patch so that players can turn on or off speech bubbles.
Diffstat (limited to 'src/being.cpp')
-rw-r--r-- | src/being.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/being.cpp b/src/being.cpp index 97ccd42e..4958700f 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -35,6 +35,7 @@ #include "sound.h" #include "localplayer.h" #include "configuration.h" +#include "text.h" #include "resources/resourcemanager.h" #include "resources/imageset.h" @@ -53,6 +54,9 @@ int Being::instances = 0; ImageSet *Being::emotionSet = NULL; +static const int X_SPEECH_OFFSET = 18; +static const int Y_SPEECH_OFFSET = 60; + Being::Being(int id, int job, Map *map): mJob(job), mX(0), mY(0), @@ -90,6 +94,7 @@ Being::Being(int id, int job, Map *map): instances++; mSpeech = ""; mIsGM = false; + mText = 0; } Being::~Being() @@ -115,6 +120,7 @@ Being::~Being() } delete mSpeechBubble; + delete mText; } void Being::setDestination(Uint16 destX, Uint16 destY) @@ -157,6 +163,17 @@ void Being::setSprite(int slot, int id, std::string color) void Being::setSpeech(const std::string &text, Uint32 time) { mSpeech = text; + + if (!config.getValue("speechbubble", 1)) + { + // don't introduce a memory leak + delete mText; + + mText = new Text(text, mPx + X_SPEECH_OFFSET, mPy - Y_SPEECH_OFFSET, + gcn::Graphics::CENTER, speechFont, + gcn::Color(255, 255, 255)); + } + mSpeechTime = 500; } @@ -361,6 +378,13 @@ void Being::logic() if (mSpeechTime > 0) mSpeechTime--; + // Remove text if speech boxes aren't being used + if (mSpeechTime == 0 && mText) + { + delete mText; + mText = 0; + } + int oldPx = mPx; int oldPy = mPy; // Update pixel coordinates @@ -442,7 +466,7 @@ void Being::drawSpeech(Graphics *graphics, int offsetX, int offsetY) int py = mPy + offsetY; // Draw speech above this being - if (mSpeechTime > 0) + if (mSpeechTime > 0 && config.getValue("speechbubble", 1)) { mSpeechBubble->setCaption(mName); mSpeechBubble->setWindowName(mName); |