diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-06-01 18:45:31 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-06-01 18:45:31 +0300 |
commit | 49f27fffbe07e66a3047812a838f03d7636cc4a9 (patch) | |
tree | 68996fa1dfc002e239513af1a92d1ffd69539204 /src/localplayer.cpp | |
parent | 69108c8a2892cf87a3d425b5e82e0eadbb5f7fa9 (diff) | |
download | manaverse-49f27fffbe07e66a3047812a838f03d7636cc4a9.tar.gz manaverse-49f27fffbe07e66a3047812a838f03d7636cc4a9.tar.bz2 manaverse-49f27fffbe07e66a3047812a838f03d7636cc4a9.tar.xz manaverse-49f27fffbe07e66a3047812a838f03d7636cc4a9.zip |
Add chat command /testparticle for testing particle effects on player.
Command: /testparticle particle.xml - set particle effect on player.
/testparticle - remove particle effect.
Each second it check for particle file update and reloading it if need.
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r-- | src/localplayer.cpp | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp index e77d3f249..c69e5b58a 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -50,6 +50,7 @@ #include "gui/sdlfont.h" #include "gui/skilldialog.h" #include "gui/socialwindow.h" +#include "gui/updaterwindow.h" #include "gui/viewport.h" #include "gui/widgets/gmtab.h" @@ -114,8 +115,8 @@ LocalPlayer::LocalPlayer(const int id, const int subtype) : mLastTargetY(0), mHomes(), mTarget(nullptr), - mPlayerFollowed(""), - mPlayerImitated(""), + mPlayerFollowed(), + mPlayerImitated(), mNextDestX(0), mNextDestY(0), mPickUpTarget(nullptr), @@ -156,9 +157,13 @@ LocalPlayer::LocalPlayer(const int id, const int subtype) : mNavigatePath(), mTargetDeadPlayers(config.getBoolValue("targetDeadPlayers")), mServerAttack(config.getBoolValue("serverAttack")), - mLastHitFrom(""), - mWaitFor(""), + mLastHitFrom(), + mWaitFor(), mAdvertTime(0), + mTestParticle(nullptr), + mTestParticleName(), + mTestParticleTime(0), + mTestParticleHash(0l), mBlockAdvert(false), mEnableAdvert(config.getBoolValue("enableAdvert")), mTradebot(config.getBoolValue("tradebot")), @@ -358,6 +363,18 @@ void LocalPlayer::slowLogic() else mAdvertTime = time + 30; } + + if (mTestParticleTime != time && !mTestParticleName.empty()) + { + unsigned long hash = UpdaterWindow::getFileHash(mTestParticleName); + if (hash != mTestParticleHash) + { + setTestParticle(mTestParticleName, false); + mTestParticleHash = hash; + } + mTestParticleTime = time; + } + BLOCK_END("LocalPlayer::slowLogic") } @@ -4310,6 +4327,24 @@ void LocalPlayer::updateStatus() const } } +void LocalPlayer::setTestParticle(const std::string &fileName, bool updateHash) +{ + mTestParticleName = fileName; + mTestParticleTime = cur_time; + if (mTestParticle) + { + mChildParticleEffects.removeLocally(mTestParticle); + mTestParticle = nullptr; + } + if (!fileName.empty()) + { + mTestParticle = particleEngine->addEffect(fileName, 0, 0, false); + controlParticle(mTestParticle); + if (updateHash) + mTestParticleHash = UpdaterWindow::getFileHash(mTestParticleName); + } +} + void AwayListener::action(const gcn::ActionEvent &event) { if (event.getId() == "ok" && player_node && player_node->getAway()) |