From 49f27fffbe07e66a3047812a838f03d7636cc4a9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 1 Jun 2013 18:45:31 +0300 Subject: 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. --- src/localplayer.cpp | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) (limited to 'src/localplayer.cpp') 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()) -- cgit v1.2.3-60-g2f50