1 |
|
|
/* |
2 |
|
|
* The ManaPlus Client |
3 |
|
|
* Copyright (C) 2008-2009 The Mana World Development Team |
4 |
|
|
* Copyright (C) 2009-2010 The Mana Developers |
5 |
|
|
* Copyright (C) 2011-2019 The ManaPlus Developers |
6 |
|
|
* |
7 |
|
|
* This file is part of The ManaPlus Client. |
8 |
|
|
* |
9 |
|
|
* This program is free software; you can redistribute it and/or modify |
10 |
|
|
* it under the terms of the GNU General Public License as published by |
11 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
12 |
|
|
* any later version. |
13 |
|
|
* |
14 |
|
|
* This program is distributed in the hope that it will be useful, |
15 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 |
|
|
* GNU General Public License for more details. |
18 |
|
|
* |
19 |
|
|
* You should have received a copy of the GNU General Public License |
20 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
21 |
|
|
*/ |
22 |
|
|
|
23 |
|
|
#include "statuseffect.h" |
24 |
|
|
|
25 |
|
|
#include "configuration.h" |
26 |
|
|
#include "soundmanager.h" |
27 |
|
|
|
28 |
|
|
#include "const/resources/spriteaction.h" |
29 |
|
|
|
30 |
|
|
#include "gui/widgets/tabs/chat/chattab.h" |
31 |
|
|
|
32 |
|
|
#include "particle/particleengine.h" |
33 |
|
|
|
34 |
|
|
#include "resources/sprite/animatedsprite.h" |
35 |
|
|
|
36 |
|
|
#include "debug.h" |
37 |
|
|
|
38 |
|
|
StatusEffect::StatusEffect() : |
39 |
|
|
mMessage(), |
40 |
|
|
mSFXEffect(), |
41 |
|
|
mStartParticleEffect(), |
42 |
|
|
mParticleEffect(), |
43 |
|
|
mIcon(), |
44 |
|
|
mAction(), |
45 |
|
|
mName(), |
46 |
|
|
mIsPersistent(false), |
47 |
|
|
mIsPoison(false), |
48 |
|
|
mIsCart(false), |
49 |
|
|
mIsRiding(false), |
50 |
|
|
mIsTrickDead(false), |
51 |
|
|
mIsPostDelay(false) |
52 |
|
|
{ |
53 |
|
|
} |
54 |
|
|
|
55 |
|
|
StatusEffect::~StatusEffect() |
56 |
|
|
{ |
57 |
|
|
} |
58 |
|
|
|
59 |
|
|
void StatusEffect::playSFX() const |
60 |
|
|
{ |
61 |
|
|
if (!mSFXEffect.empty()) |
62 |
|
|
soundManager.playSfx(mSFXEffect, 0, 0); |
63 |
|
|
} |
64 |
|
|
|
65 |
|
|
void StatusEffect::deliverMessage() const |
66 |
|
|
{ |
67 |
|
|
if (!mMessage.empty() && |
68 |
|
|
localChatTab != nullptr) |
69 |
|
|
{ |
70 |
|
|
localChatTab->chatLog(mMessage, |
71 |
|
|
ChatMsgType::BY_SERVER, |
72 |
|
|
IgnoreRecord_false, |
73 |
|
|
TryRemoveColors_true); |
74 |
|
|
} |
75 |
|
|
} |
76 |
|
|
|
77 |
|
|
Particle *StatusEffect::getStartParticle() const |
78 |
|
|
{ |
79 |
|
|
if (particleEngine == nullptr || mStartParticleEffect.empty()) |
80 |
|
|
return nullptr; |
81 |
|
|
return particleEngine->addEffect(mStartParticleEffect, 0, 0, 0); |
82 |
|
|
} |
83 |
|
|
|
84 |
|
|
Particle *StatusEffect::getParticle() const |
85 |
|
|
{ |
86 |
|
|
if (particleEngine == nullptr || mParticleEffect.empty()) |
87 |
|
|
return nullptr; |
88 |
|
|
return particleEngine->addEffect(mParticleEffect, 0, 0, 0); |
89 |
|
|
} |
90 |
|
|
|
91 |
|
|
AnimatedSprite *StatusEffect::getIcon() const |
92 |
|
|
{ |
93 |
|
|
if (mIcon.empty()) |
94 |
|
|
{ |
95 |
|
|
return nullptr; |
96 |
|
|
} |
97 |
|
|
return AnimatedSprite::load( |
98 |
|
|
pathJoin(paths.getStringValue("sprites"), mIcon), |
99 |
|
|
0); |
100 |
|
|
} |
101 |
|
|
|
102 |
|
|
std::string StatusEffect::getAction() const |
103 |
|
|
{ |
104 |
|
|
if (mAction.empty()) |
105 |
|
|
return SpriteAction::INVALID; |
106 |
|
|
return mAction; |
107 |
✓✗✓✗
|
3 |
} |