summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/being.cpp26
-rw-r--r--src/being.h2
-rw-r--r--src/gui/setup.cpp2
-rw-r--r--src/gui/setup_players.cpp2
-rw-r--r--src/gui/setup_video.cpp48
-rw-r--r--src/gui/setup_video.h2
6 files changed, 62 insertions, 20 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);
diff --git a/src/being.h b/src/being.h
index f5f1a1a7..cceebc3c 100644
--- a/src/being.h
+++ b/src/being.h
@@ -51,6 +51,7 @@ class Graphics;
class ImageSet;
class Particle;
class SpeechBubble;
+class Text;
/**
* A position along a being's path.
@@ -398,6 +399,7 @@ class Being : public Sprite
Path mPath;
std::string mSpeech;
+ Text *mText;
Uint16 mHairStyle, mHairColor;
Uint8 mGender;
Uint32 mSpeechTime;
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index 8ec3bfd8..4faa8a86 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -50,7 +50,7 @@ Setup::Setup():
{
setCloseButton(true);
int width = 310;
- int height = 290;
+ int height = 310;
setContentSize(width, height);
const char *buttonNames[] = {
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp
index 809364ea..ed1facc7 100644
--- a/src/gui/setup_players.cpp
+++ b/src/gui/setup_players.cpp
@@ -48,7 +48,7 @@
#define WIDGET_AT(row, column) (((row) * COLUMNS_NR) + column)
-static std::string table_titles[COLUMNS_NR] = {"name", "relation"};
+static std::string table_titles[COLUMNS_NR] = {" name", "relation "};
static const std::string RELATION_NAMES[PlayerRelation::RELATIONS_NR] = {
"neutral", "friend", "disregarded", "ignored"
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 612de09f..6a246501 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -107,6 +107,7 @@ Setup_Video::Setup_Video():
mOpenGLEnabled(config.getValue("opengl", 0)),
mCustomCursorEnabled(config.getValue("customcursor", 1)),
mParticleEffectsEnabled(config.getValue("particleeffects", 1)),
+ mSpeechBubbleEnabled(config.getValue("speechbubble", 1)),
mOpacity(config.getValue("guialpha", 0.8)),
mFps((int)config.getValue("fpslimit", 60)),
mModeListModel(new ModeListModel()),
@@ -115,6 +116,7 @@ Setup_Video::Setup_Video():
mOpenGLCheckBox(new CheckBox("OpenGL", mOpenGLEnabled)),
mCustomCursorCheckBox(new CheckBox("Custom cursor", mCustomCursorEnabled)),
mParticleEffectsCheckBox(new CheckBox("Particle effects", mParticleEffectsEnabled)),
+ mSpeechBubbleCheckBox(new CheckBox("Speech bubbles", mSpeechBubbleEnabled)),
mAlphaSlider(new Slider(0.2, 1.0)),
mFpsCheckBox(new CheckBox("FPS Limit: ")),
mFpsSlider(new Slider(10, 200)),
@@ -142,17 +144,18 @@ Setup_Video::Setup_Video():
mOpenGLCheckBox->setEnabled(false);
#endif
- mModeList->setDimension(gcn::Rectangle(0, 0, 60, 50));
- scrollArea->setDimension(gcn::Rectangle(10, 10, 90, 50));
+ mModeList->setDimension(gcn::Rectangle(0, 0, 60, 70));
+ scrollArea->setDimension(gcn::Rectangle(10, 10, 90, 70));
mFsCheckBox->setPosition(110, 10);
mOpenGLCheckBox->setPosition(110, 30);
mParticleEffectsCheckBox->setPosition(175, 30);
mCustomCursorCheckBox->setPosition(110, 50);
- mAlphaSlider->setDimension(gcn::Rectangle(10, 80, 100, 10));
+ mSpeechBubbleCheckBox->setPosition(110, 70);
+ mAlphaSlider->setDimension(gcn::Rectangle(10, 100, 100, 10));
alphaLabel->setPosition(20 + mAlphaSlider->getWidth(),
mAlphaSlider->getY());
- mFpsCheckBox->setPosition(90, 100);
- mFpsSlider->setDimension(gcn::Rectangle(10, 100, 75, 10));
+ mFpsCheckBox->setPosition(90, 120);
+ mFpsSlider->setDimension(gcn::Rectangle(10, 120, 75, 10));
mFpsField->setPosition(100 + mFpsCheckBox->getWidth(), 100);
mFpsField->setWidth(30);
@@ -167,6 +170,7 @@ Setup_Video::Setup_Video():
mCustomCursorCheckBox->setActionEventId("customcursor");
mParticleEffectsCheckBox->setActionEventId("particleeffects");
+ mSpeechBubbleCheckBox->setActionEventId("speechbubble");
mAlphaSlider->setActionEventId("guialpha");
mFpsCheckBox->setActionEventId("fpslimitcheckbox");
mFpsSlider->setActionEventId("fpslimitslider");
@@ -181,6 +185,7 @@ Setup_Video::Setup_Video():
mCustomCursorCheckBox->addActionListener(this);
mParticleEffectsCheckBox->addActionListener(this);
+ mSpeechBubbleCheckBox->addActionListener(this);
mAlphaSlider->addActionListener(this);
mFpsCheckBox->addActionListener(this);
mFpsSlider->addActionListener(this);
@@ -194,26 +199,26 @@ Setup_Video::Setup_Video():
mParticleDetailSlider->addActionListener(this);
mParticleDetailField->addKeyListener(this);
- mScrollRadiusSlider->setDimension(gcn::Rectangle(10, 120, 75, 10));
+ mScrollRadiusSlider->setDimension(gcn::Rectangle(10, 140, 75, 10));
gcn::Label *scrollRadiusLabel = new gcn::Label("Scroll radius");
- scrollRadiusLabel->setPosition(90, 120);
- mScrollRadiusField->setPosition(mFpsField->getX(), 120);
+ scrollRadiusLabel->setPosition(90, 140);
+ mScrollRadiusField->setPosition(mFpsField->getX(), 140);
mScrollRadiusField->setWidth(30);
mScrollRadiusField->setText(toString(mOriginalScrollRadius));
mScrollRadiusSlider->setValue(mOriginalScrollRadius);
- mScrollLazinessSlider->setDimension(gcn::Rectangle(10, 140, 75, 10));
+ mScrollLazinessSlider->setDimension(gcn::Rectangle(10, 160, 75, 10));
gcn::Label *scrollLazinessLabel = new gcn::Label("Scroll laziness");
- scrollLazinessLabel->setPosition(90, 140);
- mScrollLazinessField->setPosition(mFpsField->getX(), 140);
+ scrollLazinessLabel->setPosition(90, 160);
+ mScrollLazinessField->setPosition(mFpsField->getX(), 160);
mScrollLazinessField->setWidth(30);
mScrollLazinessField->setText(toString(mOriginalScrollLaziness));
mScrollLazinessSlider->setValue(mOriginalScrollLaziness);
- mOverlayDetailSlider->setDimension(gcn::Rectangle(10, 160, 75, 10));
+ mOverlayDetailSlider->setDimension(gcn::Rectangle(10, 180, 75, 10));
gcn::Label *overlayDetailLabel = new gcn::Label("Ambient FX");
- overlayDetailLabel->setPosition(90, 160);
- mOverlayDetailField->setPosition(180, 160);
+ overlayDetailLabel->setPosition(90, 180);
+ mOverlayDetailField->setPosition(180, 180);
mOverlayDetailField->setWidth(30);
switch (mOverlayDetail)
{
@@ -229,10 +234,10 @@ Setup_Video::Setup_Video():
}
mOverlayDetailSlider->setValue(mOverlayDetail);
- mParticleDetailSlider->setDimension(gcn::Rectangle(10, 180, 75, 10));
+ mParticleDetailSlider->setDimension(gcn::Rectangle(10, 200, 75, 10));
gcn::Label *particleDetailLabel = new gcn::Label("Particle Detail");
- particleDetailLabel->setPosition(90, 180);
- mParticleDetailField->setPosition(180, 180);
+ particleDetailLabel->setPosition(90, 200);
+ mParticleDetailField->setPosition(180, 200);
mParticleDetailField->setWidth(60);
switch (mParticleDetail)
{
@@ -256,6 +261,7 @@ Setup_Video::Setup_Video():
add(mOpenGLCheckBox);
add(mCustomCursorCheckBox);
add(mParticleEffectsCheckBox);
+ add(mSpeechBubbleCheckBox);
add(mAlphaSlider);
add(alphaLabel);
add(mFpsCheckBox);
@@ -335,6 +341,8 @@ void Setup_Video::apply()
// We sync old and new values at apply time
mFullScreenEnabled = config.getValue("screen", 0);
mCustomCursorEnabled = config.getValue("customcursor", 1);
+ mParticleEffectsEnabled = config.getValue("particleeffects", 1);
+ mSpeechBubbleEnabled = config.getValue("speechbubble", 1);
mOpacity = config.getValue("guialpha", 0.8);
mOverlayDetail = (int)config.getValue("OverlayDetail", 2);
mOpenGLEnabled = config.getValue("opengl", 0);
@@ -378,6 +386,7 @@ void Setup_Video::cancel()
config.setValue("screen", mFullScreenEnabled ? 1 : 0);
config.setValue("customcursor", mCustomCursorEnabled ? 1 : 0);
config.setValue("particleeffects", mParticleEffectsEnabled ? 1 : 0);
+ config.setValue("speechbubble", mSpeechBubbleEnabled ? 1 : 0);
config.setValue("guialpha", mOpacity);
config.setValue("opengl", mOpenGLEnabled ? 1 : 0);
}
@@ -400,6 +409,11 @@ void Setup_Video::action(const gcn::ActionEvent &event)
new OkDialog("Particle effect settings changed",
"Restart your client or change maps for the change to take effect.");
}
+ else if (event.getId() == "speechbubble")
+ {
+ config.setValue("speechbubble",
+ mSpeechBubbleCheckBox->isSelected() ? 1 : 0);
+ }
else if (event.getId() == "fpslimitslider")
{
mFps = (int) mFpsSlider->getValue();
diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h
index 7eb872d4..d0a19cb6 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 mOpenGLEnabled;
bool mCustomCursorEnabled;
bool mParticleEffectsEnabled;
+ bool mSpeechBubbleEnabled;
double mOpacity;
int mFps;
@@ -62,6 +63,7 @@ class Setup_Video : public SetupTab, public gcn::ActionListener,
gcn::CheckBox *mOpenGLCheckBox;
gcn::CheckBox *mCustomCursorCheckBox;
gcn::CheckBox *mParticleEffectsCheckBox;
+ gcn::CheckBox *mSpeechBubbleCheckBox;
gcn::Slider *mAlphaSlider;
gcn::CheckBox *mFpsCheckBox;