diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-08-15 21:28:10 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-08-16 13:19:09 -0600 |
commit | d8d9232a67a03548b827bdb0515fe7a620a488f8 (patch) | |
tree | d6e0644f99e0ff89f9b320c0b479ba5a4e398125 /src/gui/viewport.cpp | |
parent | a6c2b90c2dabac18ad8052d948bc540406b3a613 (diff) | |
download | mana-d8d9232a67a03548b827bdb0515fe7a620a488f8.tar.gz mana-d8d9232a67a03548b827bdb0515fe7a620a488f8.tar.bz2 mana-d8d9232a67a03548b827bdb0515fe7a620a488f8.tar.xz mana-d8d9232a67a03548b827bdb0515fe7a620a488f8.zip |
Move more to the event system
Most of Net::InventoryHandler is now done through events. The
ActorSpriteManager was also replaced by events. A few odds and
ends were taken care of too.
Reviewed-by: Bertram
Diffstat (limited to 'src/gui/viewport.cpp')
-rw-r--r-- | src/gui/viewport.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index f63fe5c6..972920a5 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -71,6 +71,8 @@ Viewport::Viewport(): mBeingPopup = new BeingPopup; setFocusable(true); + + listen("ActorSprite"); } Viewport::~Viewport() @@ -495,19 +497,14 @@ void Viewport::mouseMoved(gcn::MouseEvent &event) const int x = (event.getX() + (int) mPixelViewX); const int y = (event.getY() + (int) mPixelViewY); - if (mHoverBeing) - mHoverBeing->removeActorSpriteListener(this); mHoverBeing = actorSpriteManager->findBeingByPixel(x, y); mBeingPopup->show(getMouseX(), getMouseY(), mHoverBeing); - if (mHoverItem) - mHoverItem->removeActorSpriteListener(this); mHoverItem = actorSpriteManager->findItem(x / mMap->getTileWidth(), y / mMap->getTileHeight()); if (mHoverBeing) { - mHoverBeing->addActorSpriteListener(this); switch (mHoverBeing->getType()) { // NPCs @@ -527,7 +524,6 @@ void Viewport::mouseMoved(gcn::MouseEvent &event) } else if (mHoverItem) { - mHoverItem->addActorSpriteListener(this); gui->setCursorType(Gui::CURSOR_PICKUP); } else @@ -552,11 +548,16 @@ void Viewport::hideBeingPopup() mBeingPopup->setVisible(false); } -void Viewport::actorSpriteDestroyed(const ActorSprite &actorSprite) +void Viewport::event(const std::string &channel, const Mana::Event &event) { - if (&actorSprite == mHoverBeing) - mHoverBeing = 0; + if (channel == "ActorSprite" && event.getName() == "Destroyed") + { + ActorSprite *actor = event.getActor("source"); - if (&actorSprite == mHoverItem) - mHoverItem = 0; + if (mHoverBeing == actor) + mHoverBeing = 0; + + if (mHoverItem == actor) + mHoverItem = 0; + } } |