Commit 27efdd9a80c7d068f27db8725c2315fee3e10303
- Diff rendering mode:
- inline
- side by side
mana.cbp
(1 / 0)
|   | |||
| 98 | 98 | <Unit filename="src\actor.h" /> | |
| 99 | 99 | <Unit filename="src\actorsprite.cpp" /> | |
| 100 | 100 | <Unit filename="src\actorsprite.h" /> | |
| 101 | <Unit filename="src\actorspritelistener.h" /> | ||
| 101 | 102 | <Unit filename="src\actorspritemanager.cpp" /> | |
| 102 | 103 | <Unit filename="src\actorspritemanager.h" /> | |
| 103 | 104 | <Unit filename="src\animatedsprite.cpp" /> |
mana.files
(1 / 0)
|   | |||
| 42 | 42 | ./src/actor.h | |
| 43 | 43 | ./src/actorsprite.cpp | |
| 44 | 44 | ./src/actorsprite.h | |
| 45 | ./src/actorspritelistener.h | ||
| 45 | 46 | ./src/actorspritemanager.cpp | |
| 46 | 47 | ./src/actorspritemanager.h | |
| 47 | 48 | ./src/animatedsprite.cpp |
src/CMakeLists.txt
(1 / 0)
|   | |||
| 406 | 406 | actor.h | |
| 407 | 407 | actorsprite.cpp | |
| 408 | 408 | actorsprite.h | |
| 409 | actorspritelistener.h | ||
| 409 | 410 | actorspritemanager.cpp | |
| 410 | 411 | actorspritemanager.h | |
| 411 | 412 | animatedsprite.cpp |
src/Makefile.am
(1 / 0)
|   | |||
| 305 | 305 | actor.h \ | |
| 306 | 306 | actorsprite.cpp \ | |
| 307 | 307 | actorsprite.h \ | |
| 308 | actorspritelistener.h \ | ||
| 308 | 309 | actorspritemanager.cpp \ | |
| 309 | 310 | actorspritemanager.h \ | |
| 310 | 311 | animatedsprite.cpp \ |
src/actorsprite.cpp
(16 / 0)
|   | |||
| 19 | 19 | */ | |
| 20 | 20 | ||
| 21 | 21 | #include "actorsprite.h" | |
| 22 | #include "actorspritelistener.h" | ||
| 22 | 23 | ||
| 23 | 24 | #include "client.h" | |
| 24 | 25 | #include "effectmanager.h" | |
| … | … | ||
| 65 | 65 | ||
| 66 | 66 | if (player_node && player_node->getTarget() == this) | |
| 67 | 67 | player_node->setTarget(NULL); | |
| 68 | |||
| 69 | // Notify listeners of the destruction. | ||
| 70 | for (ActorSpriteListenerIterator iter = mActorSpriteListeners.begin(), | ||
| 71 | end = mActorSpriteListeners.end(); iter != end; ++iter) | ||
| 72 | (*iter)->actorSpriteDestroyed(*this); | ||
| 68 | 73 | } | |
| 69 | 74 | ||
| 70 | 75 | bool ActorSprite::draw(Graphics *graphics, int offsetX, int offsetY) const | |
| … | … | ||
| 362 | 362 | ||
| 363 | 363 | cleanupTargetCursors(); | |
| 364 | 364 | loaded = false; | |
| 365 | } | ||
| 366 | |||
| 367 | void ActorSprite::addActorSpriteListener(ActorSpriteListener *listener) | ||
| 368 | { | ||
| 369 | mActorSpriteListeners.push_front(listener); | ||
| 370 | } | ||
| 371 | |||
| 372 | void ActorSprite::removeActorSpriteListener(ActorSpriteListener *listener) | ||
| 373 | { | ||
| 374 | mActorSpriteListeners.remove(listener); | ||
| 365 | 375 | } | |
| 366 | 376 | ||
| 367 | 377 | static const char *cursorType(int type) |
src/actorsprite.h
(16 / 0)
|   | |||
| 29 | 29 | #include <SDL_types.h> | |
| 30 | 30 | ||
| 31 | 31 | #include <set> | |
| 32 | #include <list> | ||
| 32 | 33 | ||
| 33 | 34 | class SimpleAnimation; | |
| 34 | 35 | class StatusEffect; | |
| 36 | class ActorSpriteListener; | ||
| 35 | 37 | ||
| 36 | 38 | class ActorSprite : public CompoundSprite, public Actor | |
| 37 | 39 | { | |
| … | … | ||
| 162 | 162 | ||
| 163 | 163 | static void unload(); | |
| 164 | 164 | ||
| 165 | /** | ||
| 166 | * Add an ActorSprite listener. | ||
| 167 | */ | ||
| 168 | void addActorSpriteListener(ActorSpriteListener *listener); | ||
| 169 | |||
| 170 | /** | ||
| 171 | * Remove an ActorSprite listener. | ||
| 172 | */ | ||
| 173 | void removeActorSpriteListener(ActorSpriteListener *listener); | ||
| 174 | |||
| 165 | 175 | protected: | |
| 166 | 176 | /** | |
| 167 | 177 | * Trigger visual effect, with components | |
| … | … | ||
| 239 | 239 | ||
| 240 | 240 | /** Target cursor being used */ | |
| 241 | 241 | SimpleAnimation *mUsedTargetCursor; | |
| 242 | |||
| 243 | typedef std::list<ActorSpriteListener*> ActorSpriteListeners; | ||
| 244 | typedef ActorSpriteListeners::iterator ActorSpriteListenerIterator; | ||
| 245 | ActorSpriteListeners mActorSpriteListeners; | ||
| 242 | 246 | }; | |
| 243 | 247 | ||
| 244 | 248 | #endif // ACTORSPRITE_H |
src/actorspritelistener.h
(42 / 0)
|   | |||
| 1 | /* | ||
| 2 | * The Mana Client | ||
| 3 | * Copyright (C) 2010 The Mana Developers | ||
| 4 | * | ||
| 5 | * This file is part of The Mana Client. | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License as published by | ||
| 9 | * the Free Software Foundation; either version 2 of the License, or | ||
| 10 | * any later version. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | */ | ||
| 20 | |||
| 21 | #ifndef ACTORSPRITELISTENER_H | ||
| 22 | #define ACTORSPRITELISTENER_H | ||
| 23 | |||
| 24 | class ActorSprite; | ||
| 25 | |||
| 26 | class ActorSpriteListener | ||
| 27 | { | ||
| 28 | public: | ||
| 29 | /** | ||
| 30 | * Destructor. | ||
| 31 | */ | ||
| 32 | virtual ~ActorSpriteListener() {} | ||
| 33 | |||
| 34 | /** | ||
| 35 | * Called when the ActorSprite has been destroyed. The listener will | ||
| 36 | * have to be registered first. | ||
| 37 | * @param actorSprite the ActorSprite being destroyed. | ||
| 38 | */ | ||
| 39 | virtual void actorSpriteDestroyed(const ActorSprite &actorSprite) = 0; | ||
| 40 | }; | ||
| 41 | |||
| 42 | #endif // ACTORSPRITELISTENER_H |
src/localplayer.cpp
(11 / 0)
|   | |||
| 686 | 686 | ||
| 687 | 687 | void LocalPlayer::pickUp(FloorItem *item) | |
| 688 | 688 | { | |
| 689 | if (!item) | ||
| 690 | return; | ||
| 691 | |||
| 689 | 692 | int dx = item->getTileX() - (int) getPosition().x / 32; | |
| 690 | 693 | int dy = item->getTileY() - (int) getPosition().y / 32; | |
| 691 | 694 | ||
| … | … | ||
| 703 | 703 | { | |
| 704 | 704 | setDestination(item->getPixelX() + 16, item->getPixelY() + 16); | |
| 705 | 705 | mPickUpTarget = item; | |
| 706 | mPickUpTarget->addActorSpriteListener(this); | ||
| 706 | 707 | } | |
| 707 | 708 | else | |
| 708 | 709 | { | |
| 709 | 710 | setDestination(item->getTileX(), item->getTileY()); | |
| 710 | 711 | mPickUpTarget = item; | |
| 712 | mPickUpTarget->addActorSpriteListener(this); | ||
| 711 | 713 | stopAttack(); | |
| 712 | 714 | } | |
| 713 | 715 | } | |
| 716 | } | ||
| 717 | |||
| 718 | void LocalPlayer::actorSpriteDestroyed(const ActorSprite &actorSprite) | ||
| 719 | { | ||
| 720 | if (mPickUpTarget == &actorSprite) | ||
| 721 | mPickUpTarget = 0; | ||
| 714 | 722 | } | |
| 715 | 723 | ||
| 716 | 724 | Being *LocalPlayer::getTarget() const |
src/localplayer.h
(8 / 1)
|   | |||
| 23 | 23 | #define LOCALPLAYER_H | |
| 24 | 24 | ||
| 25 | 25 | #include "being.h" | |
| 26 | #include "actorspritelistener.h" | ||
| 26 | 27 | ||
| 27 | 28 | #include "gui/userpalette.h" | |
| 28 | 29 | ||
| … | … | ||
| 110 | 110 | /** | |
| 111 | 111 | * The local player character. | |
| 112 | 112 | */ | |
| 113 | class LocalPlayer : public Being | ||
| 113 | class LocalPlayer : public Being, public ActorSpriteListener | ||
| 114 | 114 | { | |
| 115 | 115 | public: | |
| 116 | 116 | /** | |
| … | … | ||
| 163 | 163 | void setInvItem(int index, int id, int amount); | |
| 164 | 164 | ||
| 165 | 165 | void pickUp(FloorItem *item); | |
| 166 | |||
| 167 | /** | ||
| 168 | * Called when an ActorSprite has been destroyed. | ||
| 169 | * @param actorSprite the ActorSprite being destroyed. | ||
| 170 | */ | ||
| 171 | void actorSpriteDestroyed(const ActorSprite &actorSprite); | ||
| 166 | 172 | ||
| 167 | 173 | /** | |
| 168 | 174 | * Sets the attack range. |
|   | |||
| 329 | 329 | ||
| 330 | 330 | void PlayerHandler::pickUp(FloorItem *floorItem) | |
| 331 | 331 | { | |
| 332 | int id = floorItem->getId(); | ||
| 333 | MessageOut msg(PGMSG_PICKUP); | ||
| 334 | msg.writeInt16(id >> 16); | ||
| 335 | msg.writeInt16(id & 0xFFFF); | ||
| 336 | gameServerConnection->send(msg); | ||
| 332 | if (floorItem) | ||
| 333 | { | ||
| 334 | int id = floorItem->getId(); | ||
| 335 | MessageOut msg(PGMSG_PICKUP); | ||
| 336 | msg.writeInt16(id >> 16); | ||
| 337 | msg.writeInt16(id & 0xFFFF); | ||
| 338 | gameServerConnection->send(msg); | ||
| 339 | } | ||
| 337 | 340 | } | |
| 338 | 341 | ||
| 339 | 342 | void PlayerHandler::setDirection(char direction) |
|   | |||
| 582 | 582 | ||
| 583 | 583 | void PlayerHandler::pickUp(FloorItem *floorItem) | |
| 584 | 584 | { | |
| 585 | MessageOut outMsg(CMSG_ITEM_PICKUP); | ||
| 586 | outMsg.writeInt32(floorItem->getId()); | ||
| 585 | if (floorItem) | ||
| 586 | { | ||
| 587 | MessageOut outMsg(CMSG_ITEM_PICKUP); | ||
| 588 | outMsg.writeInt32(floorItem->getId()); | ||
| 589 | } | ||
| 587 | 590 | } | |
| 588 | 591 | ||
| 589 | 592 | void PlayerHandler::setDirection(char direction) |

