summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2008-10-14 21:04:46 +0000
committerIra Rice <irarice@gmail.com>2008-10-14 21:04:46 +0000
commitdc3c5d595e60a8498e44affb8ec05b91709d34fc (patch)
tree15dabb6da28bb2f30694f761cb301e2b8b312576
parentfc8760599dfd730d416bb2c646e17c5dd7dd132e (diff)
downloadmana-client-dc3c5d595e60a8498e44affb8ec05b91709d34fc.tar.gz
mana-client-dc3c5d595e60a8498e44affb8ec05b91709d34fc.tar.bz2
mana-client-dc3c5d595e60a8498e44affb8ec05b91709d34fc.tar.xz
mana-client-dc3c5d595e60a8498e44affb8ec05b91709d34fc.zip
Early addition of a particle effect disabling option. Would like to
change this in the future to update instantaneously.
-rw-r--r--src/being.cpp31
-rw-r--r--src/being.h3
-rw-r--r--src/gui/setup_video.cpp15
-rw-r--r--src/gui/setup_video.h2
-rw-r--r--src/map.cpp13
-rw-r--r--src/monster.cpp16
-rw-r--r--src/npc.cpp15
7 files changed, 64 insertions, 31 deletions
diff --git a/src/being.cpp b/src/being.cpp
index a30bf465..c4723f79 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -34,6 +34,7 @@
#include "particle.h"
#include "sound.h"
#include "localplayer.h"
+#include "configuration.h"
#include "resources/resourcemanager.h"
#include "resources/imageset.h"
@@ -71,7 +72,8 @@ Being::Being(int id, int job, Map *map):
mPx(0), mPy(0),
mSprites(VECTOREND_SPRITE, NULL),
mSpriteIDs(VECTOREND_SPRITE, 0),
- mSpriteColors(VECTOREND_SPRITE, "")
+ mSpriteColors(VECTOREND_SPRITE, ""),
+ mParticleEffects(config.getValue("particleeffects", 1))
{
setMap(map);
@@ -387,19 +389,22 @@ void Being::logic()
}
}
- //Update particle effects
- for (std::list<Particle *>::iterator i = mChildParticleEffects.begin();
- i != mChildParticleEffects.end();)
+ if (mParticleEffects)
{
- (*i)->setPosition((float)mPx + 16.0f, (float)mPy + 32.0f);
- if ((*i)->isExtinct())
+ //Update particle effects
+ for (std::list<Particle *>::iterator i = mChildParticleEffects.begin();
+ i != mChildParticleEffects.end();)
{
- (*i)->kill();
- i = mChildParticleEffects.erase(i);
- }
- else
- {
- i++;
+ (*i)->setPosition((float)mPx + 16.0f, (float)mPy + 32.0f);
+ if ((*i)->isExtinct())
+ {
+ (*i)->kill();
+ i = mChildParticleEffects.erase(i);
+ }
+ else
+ {
+ i++;
+ }
}
}
}
@@ -589,7 +594,7 @@ void Being::internalTriggerEffect(int effectId, bool sfx, bool gfx)
return;
}
- if (gfx && ed->mGFXEffect != "") {
+ if (gfx && ed->mGFXEffect != "" && mParticleEffects) {
Particle *selfFX;
selfFX = particleEngine->addEffect(ed->mGFXEffect, 0, 0);
diff --git a/src/being.h b/src/being.h
index cc6ba427..05a49d9a 100644
--- a/src/being.h
+++ b/src/being.h
@@ -405,6 +405,9 @@ class Being : public Sprite
std::vector<std::string> mSpriteColors;
std::list<Particle *> mChildParticleEffects;
+ protected:
+ bool mParticleEffects; /**< Whether to display particles or not */
+
private:
/**
* Calculates the offset in the given directions.
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index dd56ee2f..e065edae 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -106,6 +106,7 @@ Setup_Video::Setup_Video():
mFullScreenEnabled(config.getValue("screen", 0)),
mOpenGLEnabled(config.getValue("opengl", 0)),
mCustomCursorEnabled(config.getValue("customcursor", 1)),
+ mParticleEffectsEnabled(config.getValue("particleeffects", 1)),
mOpacity(config.getValue("guialpha", 0.8)),
mFps((int)config.getValue("fpslimit", 60)),
mModeListModel(new ModeListModel()),
@@ -113,6 +114,7 @@ Setup_Video::Setup_Video():
mFsCheckBox(new CheckBox("Full screen", mFullScreenEnabled)),
mOpenGLCheckBox(new CheckBox("OpenGL", mOpenGLEnabled)),
mCustomCursorCheckBox(new CheckBox("Custom cursor", mCustomCursorEnabled)),
+ mParticleEffectsCheckBox(new CheckBox("Particle effects", mParticleEffectsEnabled)),
mAlphaSlider(new Slider(0.2, 1.0)),
mFpsCheckBox(new CheckBox("FPS Limit: ")),
mFpsSlider(new Slider(10, 200)),
@@ -144,6 +146,7 @@ Setup_Video::Setup_Video():
scrollArea->setDimension(gcn::Rectangle(10, 10, 90, 50));
mFsCheckBox->setPosition(110, 10);
mOpenGLCheckBox->setPosition(110, 30);
+ mParticleEffectsCheckBox->setPosition(175, 30);
mCustomCursorCheckBox->setPosition(110, 50);
mAlphaSlider->setDimension(gcn::Rectangle(10, 80, 100, 10));
alphaLabel->setPosition(20 + mAlphaSlider->getWidth(),
@@ -163,6 +166,7 @@ Setup_Video::Setup_Video():
mFpsCheckBox->setSelected(mFps > 0);
mCustomCursorCheckBox->setActionEventId("customcursor");
+ mParticleEffectsCheckBox->setActionEventId("particleeffects");
mAlphaSlider->setActionEventId("guialpha");
mFpsCheckBox->setActionEventId("fpslimitcheckbox");
mFpsSlider->setActionEventId("fpslimitslider");
@@ -176,6 +180,7 @@ Setup_Video::Setup_Video():
mParticleDetailField->setActionEventId("particledetailfield");
mCustomCursorCheckBox->addActionListener(this);
+ mParticleEffectsCheckBox->addActionListener(this);
mAlphaSlider->addActionListener(this);
mFpsCheckBox->addActionListener(this);
mFpsSlider->addActionListener(this);
@@ -250,6 +255,7 @@ Setup_Video::Setup_Video():
add(mFsCheckBox);
add(mOpenGLCheckBox);
add(mCustomCursorCheckBox);
+ add(mParticleEffectsCheckBox);
add(mAlphaSlider);
add(alphaLabel);
add(mFpsCheckBox);
@@ -371,6 +377,8 @@ void Setup_Video::cancel()
config.setValue("screen", mFullScreenEnabled ? 1 : 0);
config.setValue("customcursor", mCustomCursorEnabled ? 1 : 0);
+ config.setValue("particleeffects", mParticleEffectsEnabled ? 1 : 0);
+ config.setValue("screen", mParticleEffectsEnabled ? 1 : 0);
config.setValue("guialpha", mOpacity);
config.setValue("opengl", mOpenGLEnabled ? 1 : 0);
}
@@ -386,6 +394,13 @@ void Setup_Video::action(const gcn::ActionEvent &event)
config.setValue("customcursor",
mCustomCursorCheckBox->isSelected() ? 1 : 0);
}
+ else if (event.getId() == "particleeffects")
+ {
+ config.setValue("particleeffects",
+ mParticleEffectsCheckBox->isSelected() ? 1 : 0);
+ new OkDialog("Particle effect settings changed",
+ "Restart your client or change maps for the change to take effect.");
+ }
else if (event.getId() == "fpslimitslider")
{
mFps = (int) mFpsSlider->getValue();
diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h
index 0d7ea700..7eb872d4 100644
--- a/src/gui/setup_video.h
+++ b/src/gui/setup_video.h
@@ -51,6 +51,7 @@ class Setup_Video : public SetupTab, public gcn::ActionListener,
bool mFullScreenEnabled;
bool mOpenGLEnabled;
bool mCustomCursorEnabled;
+ bool mParticleEffectsEnabled;
double mOpacity;
int mFps;
@@ -60,6 +61,7 @@ class Setup_Video : public SetupTab, public gcn::ActionListener,
gcn::CheckBox *mFsCheckBox;
gcn::CheckBox *mOpenGLCheckBox;
gcn::CheckBox *mCustomCursorCheckBox;
+ gcn::CheckBox *mParticleEffectsCheckBox;
gcn::Slider *mAlphaSlider;
gcn::CheckBox *mFpsCheckBox;
diff --git a/src/map.cpp b/src/map.cpp
index 3adc3498..f9454187 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -504,11 +504,14 @@ void Map::addParticleEffect(const std::string &effectFile, int x, int y)
void Map::initializeParticleEffects(Particle* particleEngine)
{
- for (std::list<ParticleEffectData>::iterator i = particleEffects.begin();
- i != particleEffects.end();
- i++
- )
+ if (config.getValue("particleeffects", 1))
{
- particleEngine->addEffect(i->file, i->x, i->y);
+ for (std::list<ParticleEffectData>::iterator i = particleEffects.begin();
+ i != particleEffects.end();
+ i++
+ )
+ {
+ particleEngine->addEffect(i->file, i->x, i->y);
+ }
}
}
diff --git a/src/monster.cpp b/src/monster.cpp
index 61f1f5c3..be22bed3 100644
--- a/src/monster.cpp
+++ b/src/monster.cpp
@@ -65,13 +65,15 @@ Monster::Monster(Uint32 id, Uint16 job, Map *map):
mSprites[c] = AnimatedSprite::load("graphics/sprites/error.xml");
}
- const std::list<std::string> &particleEffects = info.getParticleEffects();
- for ( std::list<std::string>::const_iterator i = particleEffects.begin();
- i != particleEffects.end();
- i++
- )
+ if (mParticleEffects)
{
- controlParticle(particleEngine->addEffect((*i), 0, 0));
+ const std::list<std::string> &particleEffects = info.getParticleEffects();
+ for ( std::list<std::string>::const_iterator i = particleEffects.begin();
+ i != particleEffects.end(); i++
+ )
+ {
+ controlParticle(particleEngine->addEffect((*i), 0, 0));
+ }
}
}
@@ -122,7 +124,7 @@ void Monster::setAction(Action action)
//attack particle effect
particleEffect = getInfo().getAttackParticleEffect();
- if (particleEffect != "")
+ if (particleEffect != "" && mParticleEffects)
{
switch (mDirection)
{
diff --git a/src/npc.cpp b/src/npc.cpp
index fe0b4598..3f9a1601 100644
--- a/src/npc.cpp
+++ b/src/npc.cpp
@@ -58,13 +58,16 @@ NPC::NPC(Uint32 id, Uint16 job, Map *map, Network *network):
c++;
}
- //setup particle effects
- for (std::list<std::string>::const_iterator i = info.particles.begin();
- i != info.particles.end();
- i++)
+ if (mParticleEffects)
{
- Particle *p = particleEngine->addEffect(*i, 0, 0);
- this->controlParticle(p);
+ //setup particle effects
+ for (std::list<std::string>::const_iterator i = info.particles.begin();
+ i != info.particles.end();
+ i++)
+ {
+ Particle *p = particleEngine->addEffect(*i, 0, 0);
+ this->controlParticle(p);
+ }
}
mName = 0;
}